+2017-12-04 Steve Ellcey <sellcey@cavium.com>
+
+ * Makefile.am (ARCH_AARCH64_LINUX): Add IFUNC_OPTIONS and
+ libatomic_la_LIBADD.
+ * config/linux/aarch64/host-config.h: New file.
+ * configure.ac (IFUNC_RESOLVER_ARGS): Define.
+ (ARCH_AARCH64_LINUX): New conditional for IFUNC builds.
+ * configure.tgt (aarch64): Set ARCH and try_ifunc.
+ (aarch64*-*-linux*) Update config_path.
+ (aarch64*-*-linux*) Set IFUNC_RESOLVER_ARGS.
+ * libatomic_i.h (GEN_SELECTOR): Add IFUNC_RESOLVER_ARGS argument.
+ * Makefile.in: Regenerate.
+ * auto-config.h.in: Regenerate.
+ * configure: Regenerate.
+
2017-11-17 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
* configure.ac: Set CET_FLAGS, update XCFLAGS.
## On a target-specific basis, include alternates to be selected by IFUNC.
if HAVE_IFUNC
+if ARCH_AARCH64_LINUX
+IFUNC_OPTIONS = -march=armv8.1-a
+libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
+endif
if ARCH_ARM_LINUX
IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_1 = $(foreach \
+@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_1 = $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_2 = $(foreach \
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ s,$(SIZES),$(addsuffix \
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _$(s)_1_.lo,$(SIZEOBJS))) \
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ $(addsuffix \
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _8_2_.lo,$(SIZEOBJS))
-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_2 = $(addsuffix _8_1_.lo,$(SIZEOBJS))
-@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_3 = $(addsuffix _16_1_.lo,$(SIZEOBJS))
+@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_3 = $(addsuffix _8_1_.lo,$(SIZEOBJS))
+@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_4 = $(addsuffix _16_1_.lo,$(SIZEOBJS))
subdir = .
DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files)))
libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \
_$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \
- $(am__append_3)
+ $(am__append_3) $(am__append_4)
+@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv8.1-a
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define ifunc resolver function argument. */
+#undef IFUNC_RESOLVER_ARGS
+
/* Define to 1 if GNU symbol versioning is used for libatomic. */
#undef LIBAT_GNU_SYMBOL_VERSIONING
--- /dev/null
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+ This file is part of the GNU Atomic Library (libatomic).
+
+ Libatomic is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#if HAVE_IFUNC
+#include <stdlib.h>
+
+# ifdef HWCAP_ATOMICS
+# define IFUNC_COND_1 (hwcap & HWCAP_ATOMICS)
+# else
+# define IFUNC_COND_1 (false)
+# endif
+# define IFUNC_NCOND(N) (1)
+
+#endif /* HAVE_IFUNC */
+
+#include_next <host-config.h>
ARCH_I386_TRUE
ARCH_ARM_LINUX_FALSE
ARCH_ARM_LINUX_TRUE
+ARCH_AARCH64_LINUX_FALSE
+ARCH_AARCH64_LINUX_TRUE
HAVE_IFUNC_FALSE
HAVE_IFUNC_TRUE
SIZES
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11121 "configure"
+#line 11123 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11227 "configure"
+#line 11229 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
as_fn_error "Configuration ${target} is unsupported." "$LINENO" 5
fi
+# Write out the ifunc resolver arg type.
+
+cat >>confdefs.h <<_ACEOF
+#define IFUNC_RESOLVER_ARGS $IFUNC_RESOLVER_ARGS
+_ACEOF
+
+
# Disable fallbacks to __sync routines from libgcc. Otherwise we'll
# make silly decisions about what the cpu can do.
CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS"
HAVE_IFUNC_FALSE=
fi
+ if expr "$config_path" : ".* linux/aarch64 .*" > /dev/null; then
+ ARCH_AARCH64_LINUX_TRUE=
+ ARCH_AARCH64_LINUX_FALSE='#'
+else
+ ARCH_AARCH64_LINUX_TRUE='#'
+ ARCH_AARCH64_LINUX_FALSE=
+fi
+
if expr "$config_path" : ".* linux/arm .*" > /dev/null; then
ARCH_ARM_LINUX_TRUE=
ARCH_ARM_LINUX_FALSE='#'
as_fn_error "conditional \"HAVE_IFUNC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${ARCH_AARCH64_LINUX_TRUE}" && test -z "${ARCH_AARCH64_LINUX_FALSE}"; then
+ as_fn_error "conditional \"ARCH_AARCH64_LINUX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${ARCH_ARM_LINUX_TRUE}" && test -z "${ARCH_ARM_LINUX_FALSE}"; then
as_fn_error "conditional \"ARCH_ARM_LINUX\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
AC_MSG_ERROR([Configuration ${target} is unsupported.])
fi
+# Write out the ifunc resolver arg type.
+AC_DEFINE_UNQUOTED(IFUNC_RESOLVER_ARGS, $IFUNC_RESOLVER_ARGS,
+ [Define ifunc resolver function argument.])
+
# Disable fallbacks to __sync routines from libgcc. Otherwise we'll
# make silly decisions about what the cpu can do.
CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS"
AC_SUBST(SIZES)
AM_CONDITIONAL(HAVE_IFUNC, test x$libat_cv_have_ifunc = xyes)
+AM_CONDITIONAL(ARCH_AARCH64_LINUX,
+ [expr "$config_path" : ".* linux/aarch64 .*" > /dev/null])
AM_CONDITIONAL(ARCH_ARM_LINUX,
[expr "$config_path" : ".* linux/arm .*" > /dev/null])
AM_CONDITIONAL(ARCH_I386,
riscv*) ARCH=riscv ;;
sh*) ARCH=sh ;;
+ aarch64*)
+ ARCH=aarch64
+ case "${target}" in
+ aarch64*-*-linux*)
+ try_ifunc=yes
+ ;;
+ esac
+ ;;
arm*)
ARCH=arm
case "${target}" in
# Other system configury
case "${target}" in
+ aarch64*-*-linux*)
+ # OS support for atomic primitives.
+ config_path="${config_path} linux/aarch64 posix"
+ ;;
+
arm*-*-linux*)
# OS support for atomic primitives.
config_path="${config_path} linux/arm posix"
UNSUPPORTED=1
;;
esac
+
+# glibc will pass hwcap to ifunc resolver functions as an argument.
+# The type may be different on different architectures.
+case "${target}" in
+ aarch64*-*-*)
+ IFUNC_RESOLVER_ARGS="uint64_t hwcap"
+ ;;
+ *)
+ IFUNC_RESOLVER_ARGS="void"
+ ;;
+esac
# if IFUNC_NCOND(N) == 1
# define GEN_SELECTOR(X) \
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
- static typeof(C2(libat_,X)) * C2(select_,X) (void) \
+ static typeof(C2(libat_,X)) * C2(select_,X) (IFUNC_RESOLVER_ARGS) \
{ \
if (IFUNC_COND_1) \
return C3(libat_,X,_i1); \
# define GEN_SELECTOR(X) \
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN; \
- static typeof(C2(libat_,X)) * C2(select_,X) (void) \
+ static typeof(C2(libat_,X)) * C2(select_,X) (IFUNC_RESOLVER_ARGS) \
{ \
if (IFUNC_COND_1) \
return C3(libat_,X,_i1); \
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN; \
extern typeof(C2(libat_,X)) C3(libat_,X,_i3) HIDDEN; \
- static typeof(C2(libat_,X)) * C2(select_,X) (void) \
+ static typeof(C2(libat_,X)) * C2(select_,X) (IFUNC_RESOLVER_ARGS) \
{ \
if (IFUNC_COND_1) \
return C3(libat_,X,_i1); \