diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 6f52c6696..1de1e92c5 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -873,18 +873,43 @@ dnl ---------------------------------------------------------------------- dnl Configure libatomic-ops dnl AC_DEFUN([ECL_LIBATOMIC_OPS],[ +case "${enable_libatomic}" in + auto|system|included) ;; + *) AC_MSG_ERROR( [Invalid value of --enable-libatomic: ${enable_libatomic}] );; +esac if test "x${enable_threads}" != "xno"; then - test -d atomic || mkdir atomic - (destdir=`${PWDCMD}`; cd atomic && CC="${CC} ${PICFLAG}" \ - $srcdir/${ECL_GC_DIR}/libatomic*/configure --disable-shared --prefix=${destdir} \ + AC_CHECK_HEADER([atomic_ops.h],[system_libatomic=yes],[system_libatomic=no],[]) + AC_MSG_CHECKING( [libatomic-ops version] ) + if test "${enable_libatomic}" = auto; then + if test "${system_libatomic}" = yes; then + enable_libatomic=system + else + enable_libatomic=included + fi + fi + if test "${enable_libatomic}" = system; then + if test "${system_libatomic}" = no; then + AC_MSG_ERROR( [Cannot find libatomic-ops in the system] ) + enable_libatomic=included + fi + fi + AC_MSG_RESULT( [${enable_libatomic}] ) + if test "${enable_libatomic}" = included; then + test -d atomic || mkdir atomic + (destdir=`${PWDCMD}`; cd atomic && CC="${CC} ${PICFLAG}" \ + $srcdir/${ECL_GC_DIR}/libatomic*/configure --disable-shared --prefix=${destdir} \ --infodir=${destdir}/doc --includedir=${destdir}/ecl --with-pic \ --libdir=${destdir} --build=${build_alias} --host=${host_alias} \ CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" CC="${CC} \ ${PICFLAG}") - SUBDIRS="${SUBDIRS} atomic" - CORE_LIBS="-leclatomic ${CORE_LIBS}" - if test "${enable_shared}" = "no"; then - LIBRARIES="${LIBRARIES} ${LIBPREFIX}eclatomic.${LIBEXT}" + SUBDIRS="${SUBDIRS} atomic" + if test "${enable_shared}" = "no"; then + LIBRARIES="${LIBRARIES} ${LIBPREFIX}eclatomic.${LIBEXT}" + fi + AC_DEFINE(ECL_LIBATOMIC_OPS_H) + CORE_LIBS="-leclatomic ${CORE_LIBS}" + else + CORE_LIBS="-latomic_ops ${CORE_LIBS}" fi fi ]) diff --git a/src/c/threads/ecl_atomics.h b/src/c/threads/ecl_atomics.h index f7d3ec232..75ac82258 100755 --- a/src/c/threads/ecl_atomics.h +++ b/src/c/threads/ecl_atomics.h @@ -15,7 +15,7 @@ #ifndef ECL_ATOMICS_H #define AO_ASSUME_WINDOWS98 -#include +#include #if !defined(AO_HAVE_compare_and_swap_full) # error "ECL needs AO_compare_and_swap_full or an equivalent" diff --git a/src/configure b/src/configure index ee7ee3b58..20967a1fb 100755 --- a/src/configure +++ b/src/configure @@ -763,6 +763,7 @@ enable_shared enable_rpath enable_threads enable_boehm +enable_libatomic enable_slow_config enable_soname with_system_boehm @@ -1444,6 +1445,8 @@ Optional Features: default=NO). --enable-boehm use the Boehm-Weiser garbage collector (no|included|system|auto, default=auto) + --enable-libatomic version of the libatomic-ops library + (auto|included|system, default=auto) DEPRECATED: use --with-system-boehm=no --enable-soname link and install the library using version numbers @@ -2617,6 +2620,14 @@ else fi +# Check whether --enable-libatomic was given. +if test "${enable_libatomic+set}" = set; then : + enableval=$enable_libatomic; +else + enable_libatomic=auto +fi + + # Check whether --enable-slow-config was given. if test "${enable_slow_config+set}" = set; then : enableval=$enable_slow_config; @@ -9136,18 +9147,53 @@ fi fi +case "${enable_libatomic}" in + auto|system|included) ;; + *) as_fn_error $? "Invalid value of --enable-libatomic: ${enable_libatomic} " "$LINENO" 5;; +esac if test "x${enable_threads}" != "xno"; then - test -d atomic || mkdir atomic - (destdir=`${PWDCMD}`; cd atomic && CC="${CC} ${PICFLAG}" \ - $srcdir/${ECL_GC_DIR}/libatomic*/configure --disable-shared --prefix=${destdir} \ + ac_fn_c_check_header_mongrel "$LINENO" "atomic_ops.h" "ac_cv_header_atomic_ops_h" "$ac_includes_default" +if test "x$ac_cv_header_atomic_ops_h" = xyes; then : + system_libatomic=yes +else + system_libatomic=no +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking libatomic-ops version " >&5 +$as_echo_n "checking libatomic-ops version ... " >&6; } + if test "${enable_libatomic}" = auto; then + if test "${system_libatomic}" = yes; then + enable_libatomic=system + else + enable_libatomic=included + fi + fi + if test "${enable_libatomic}" = system; then + if test "${system_libatomic}" = no; then + as_fn_error $? "Cannot find libatomic-ops in the system " "$LINENO" 5 + enable_libatomic=included + fi + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${enable_libatomic} " >&5 +$as_echo "${enable_libatomic} " >&6; } + if test "${enable_libatomic}" = included; then + test -d atomic || mkdir atomic + (destdir=`${PWDCMD}`; cd atomic && CC="${CC} ${PICFLAG}" \ + $srcdir/${ECL_GC_DIR}/libatomic*/configure --disable-shared --prefix=${destdir} \ --infodir=${destdir}/doc --includedir=${destdir}/ecl --with-pic \ --libdir=${destdir} --build=${build_alias} --host=${host_alias} \ CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" CC="${CC} \ ${PICFLAG}") - SUBDIRS="${SUBDIRS} atomic" - CORE_LIBS="-leclatomic ${CORE_LIBS}" - if test "${enable_shared}" = "no"; then - LIBRARIES="${LIBRARIES} ${LIBPREFIX}eclatomic.${LIBEXT}" + SUBDIRS="${SUBDIRS} atomic" + if test "${enable_shared}" = "no"; then + LIBRARIES="${LIBRARIES} ${LIBPREFIX}eclatomic.${LIBEXT}" + fi + $as_echo "#define ECL_LIBATOMIC_OPS_H 1" >>confdefs.h + + CORE_LIBS="-leclatomic ${CORE_LIBS}" + else + CORE_LIBS="-latomic_ops ${CORE_LIBS}" fi fi diff --git a/src/configure.in b/src/configure.in index d8a0f6dc1..f1f72ec38 100644 --- a/src/configure.in +++ b/src/configure.in @@ -50,6 +50,12 @@ AC_ARG_ENABLE(boehm, [(no|included|system|auto, default=auto)] ), [], [enable_boehm=auto] ) +AC_ARG_ENABLE(libatomic, + AS_HELP_STRING( [--enable-libatomic], + [version of the libatomic-ops library] + [(auto|included|system, default=auto)] ), + [], [enable_libatomic=auto] ) + AC_ARG_ENABLE(slow-config, AS_HELP_STRING( [DEPRECATED: use --with-system-boehm=no] ), [], [enable_slow_config=no] ) diff --git a/src/h/config.h.in b/src/h/config.h.in index 7be803c90..822e226f2 100644 --- a/src/h/config.h.in +++ b/src/h/config.h.in @@ -89,6 +89,7 @@ # undef _endthreadex # endif #endif +#undef ECL_LIBATOMIC_OPS_H /* Network streams */ #undef TCP diff --git a/src/h/internal.h b/src/h/internal.h index b6d3b97e8..021d01732 100755 --- a/src/h/internal.h +++ b/src/h/internal.h @@ -419,7 +419,11 @@ extern void cl_write_object(cl_object x, cl_object stream); #endif /* ECL_THREADS */ #ifdef ECL_THREADS -# include +# ifdef ECL_LIBATOMIC_OPS_H +# include +# else +# include +# endif #else # define AO_load(x) (x) # define AO_store(x,y) ((x)=(y))