diff options
Diffstat (limited to '')
-rw-r--r-- | configure.in | 179 |
1 files changed, 138 insertions, 41 deletions
diff --git a/configure.in b/configure.in index 46440d1..b0457e2 100644 --- a/configure.in +++ b/configure.in @@ -100,7 +100,7 @@ AH_BOTTOM([ /* * Include common private declarations. */ -#include "../apr_private_common.h" +#include "arch/apr_private_common.h" #endif /* APR_PRIVATE_H */ ]) @@ -140,6 +140,18 @@ fi AC_SUBST(APR_CONFIG_LOCATION) +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + APR_CROSS_COMPILING=maybe + elif test "x$build_alias" != "x$host_alias"; then + APR_CROSS_COMPILING=yes + fi +else + APR_CROSS_COMPILING=no +fi + +AC_SUBST(APR_CROSS_COMPILING) + # Libtool might need this symbol -- it must point to the location of # the generated libtool script (not necessarily the "top" build dir). # @@ -546,37 +558,44 @@ if test "$ap_cv_atomic_builtins" = "yes" -o "$ap_cv__atomic_builtins" = "yes"; t if test "$ap_cv__atomic_builtins" = "yes"; then AC_DEFINE(HAVE__ATOMIC_BUILTINS, 1, [Define if compiler provides 32bit __atomic builtins]) fi + has_atomic_builtins=yes +else + has_atomic_builtins=no fi AC_CACHE_CHECK([whether the compiler provides 64bit atomic builtins], [ap_cv_atomic_builtins64], [AC_TRY_RUN([ #if HAVE_STDINT_H #include <stdint.h> +typedef uint64_t u64_t; +#else +typedef unsigned long long u64_t; #endif int main(int argc, const char *const *argv) { -#if HAVE_STDINT_H - uint64_t val = 1010, tmp, *mem = &val; -#else - unsigned long long val = 1010, tmp, *mem = &val; -#endif - - if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020) + struct { + char pad0; + u64_t val; + } s; + u64_t *mem = &s.val, tmp; + + s.val = 1010; + if (__sync_fetch_and_add(&s.val, 1010) != 1010 || s.val != 2020) return 1; - tmp = val; - if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010) + tmp = s.val; + if (__sync_fetch_and_sub(mem, 1010) != tmp || s.val != 1010) return 1; - if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0) + if (__sync_sub_and_fetch(&s.val, 1010) != 0 || s.val != 0) return 1; tmp = 3030; - if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp) + if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || s.val != tmp) return 1; __sync_synchronize(); - if (__sync_lock_test_and_set(&val, 4040) != 3030) + if (__sync_lock_test_and_set(&s.val, 4040) != 3030) return 1; return 0; @@ -586,31 +605,45 @@ AC_CACHE_CHECK([whether the compiler provides 64bit __atomic builtins], [ap_cv__ [AC_TRY_RUN([ #if HAVE_STDINT_H #include <stdint.h> +typedef uint64_t u64_t; +#else +typedef unsigned long long u64_t; #endif +static int test_always_lock_free(volatile u64_t *val) +{ + return __atomic_always_lock_free(sizeof(*val), val); +} int main(int argc, const char *const *argv) { -#if HAVE_STDINT_H - uint64_t val = 1010, tmp, *mem = &val; -#else - unsigned long long val = 1010, tmp, *mem = &val; -#endif + struct { + char pad0; + u64_t val; + char pad1; + u64_t tmp; + } s; + u64_t *mem = &s.val; + + /* check if alignment matters (no fallback to libatomic) */ + if (!test_always_lock_free(&s.val)) + return 1; - if (__atomic_fetch_add(&val, 1010, __ATOMIC_SEQ_CST) != 1010 || val != 2020) + s.val = 1010; + if (__atomic_fetch_add(&s.val, 1010, __ATOMIC_SEQ_CST) != 1010 || s.val != 2020) return 1; - tmp = val; - if (__atomic_fetch_sub(mem, 1010, __ATOMIC_SEQ_CST) != tmp || val != 1010) + s.tmp = s.val; + if (__atomic_fetch_sub(mem, 1010, __ATOMIC_SEQ_CST) != s.tmp || s.val != 1010) return 1; - if (__atomic_sub_fetch(&val, 1010, __ATOMIC_SEQ_CST) != 0 || val != 0) + if (__atomic_sub_fetch(&s.val, 1010, __ATOMIC_SEQ_CST) != 0 || s.val != 0) return 1; - tmp = val; - if (!__atomic_compare_exchange_n(mem, &tmp, 3030, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) - || tmp != 0) + s.tmp = s.val; + if (!__atomic_compare_exchange_n(mem, &s.tmp, 3030, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) + || s.tmp != 0) return 1; - if (__atomic_exchange_n(&val, 4040, __ATOMIC_SEQ_CST) != 3030) + if (__atomic_exchange_n(&s.val, 4040, __ATOMIC_SEQ_CST) != 3030) return 1; return 0; @@ -772,18 +805,30 @@ void main(void) fi fi +force_generic_atomics=no +force_generic_atomics64=no +AC_CHECK_SIZEOF(void*, 4) +if test "x$ac_cv_sizeof_voidp" = "x"; then + force_generic_atomics64=yes +elif test $ac_cv_sizeof_voidp -lt 8; then + force_generic_atomics64=yes +fi AC_ARG_ENABLE(nonportable-atomics, [ --enable-nonportable-atomics Use optimized atomic code which may produce nonportable binaries], -[if test $enableval = yes; then - force_generic_atomics=no - else +[if test "$enableval" = "upto32bit"; then + force_generic_atomics64=yes + elif test "$enableval" != "yes"; then force_generic_atomics=yes fi ], [case $host_cpu in - i[[456]]86) force_generic_atomics=yes ;; - *) force_generic_atomics=no - case $host in + i[[34]]86) + force_generic_atomics=yes + ;; + i[[56]]86) + force_generic_atomics64=yes + ;; + *) case $host in *solaris2.10*) AC_TRY_COMPILE( [#include <atomic.h>], @@ -798,11 +843,14 @@ AC_ARG_ENABLE(nonportable-atomics, ;; esac ]) - if test $force_generic_atomics = yes; then AC_DEFINE([USE_ATOMICS_GENERIC], 1, [Define if use of generic atomics is requested]) fi +if test $force_generic_atomics = yes -o $force_generic_atomics64 = yes; then + AC_DEFINE([USE_ATOMICS_GENERIC64], 1, + [Define if use of 64bit generic atomics is requested]) +fi AC_SUBST(proc_mutex_is_global) AC_SUBST(eolstr) @@ -1025,7 +1073,7 @@ AC_CACHE_CHECK([for epoll support], [apr_cv_epoll], #include <sys/epoll.h> #include <unistd.h> -int main() +int main(int argc, const char *argv[]) { return epoll_create(5) == -1; }], [apr_cv_epoll=yes], [apr_cv_epoll=no], [apr_cv_epoll=no])]) @@ -1041,7 +1089,7 @@ AC_CACHE_CHECK([for epoll_create1 support], [apr_cv_epoll_create1], #include <sys/epoll.h> #include <unistd.h> -int main() +int main(int argc, const char *argv[]) { return epoll_create1(0) == -1; }], [apr_cv_epoll_create1=yes], [apr_cv_epoll_create1=no], [apr_cv_epoll_create1=no])]) @@ -1050,12 +1098,53 @@ if test "$apr_cv_epoll_create1" = "yes"; then AC_DEFINE([HAVE_EPOLL_CREATE1], 1, [Define if epoll_create1 function is supported]) fi +AC_CACHE_CHECK([whether epoll_wait has a reliable timeout (min)], + [apr_cv_epoll_wait_has_reliable_timeout], +[AC_TRY_RUN([ +#include <unistd.h> +#include <sys/epoll.h> +#include <sys/time.h> /* for gettimeofday */ + +#define TV2US(tv) ((tv).tv_sec * 1000000LL + (tv).tv_usec) + +int main(int argc, const char *argv[]) +{ + struct epoll_event events[1]; + int fd, i; +#ifdef HAVE_EPOLL_CREATE1 + fd = epoll_create1(0); +#else + fd = epoll_create(1); +#endif + if (fd < 0) { + return 1; + } + for (i = 0; i < 10; ++i) { + struct timeval t1 = {0,}, + t2 = {0,}; + (void)gettimeofday(&t1, NULL); + (void)epoll_wait(fd, events, 1, 100); /* ms */ + (void)gettimeofday(&t2, NULL); + if (TV2US(t2) - TV2US(t1) < 100000) { /* us */ + return 1; + } + } + return 0; +}], [apr_cv_epoll_wait_has_reliable_timeout=yes], + [apr_cv_epoll_wait_has_reliable_timeout=no], + [apr_cv_epoll_wait_has_reliable_timeout=no])]) + +if test "$apr_cv_epoll_wait_has_reliable_timeout" = "yes"; then + AC_DEFINE([HAVE_EPOLL_WAIT_RELIABLE_TIMEOUT], 1, + [Define if epoll_wait has a reliable timeout (min)]) +fi + # test for dup3 AC_CACHE_CHECK([for dup3 support], [apr_cv_dup3], [AC_TRY_RUN([ #include <unistd.h> -int main() +int main(int argc, const char *argv[]) { return dup3(STDOUT_FILENO, STDERR_FILENO, 0) == -1; }], [apr_cv_dup3=yes], [apr_cv_dup3=no], [apr_cv_dup3=no])]) @@ -1116,7 +1205,7 @@ AC_CACHE_CHECK([for SOCK_CLOEXEC support], [apr_cv_sock_cloexec], #include <sys/types.h> #include <sys/socket.h> -int main() +int main(int argc, const char *argv[]) { return socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0) == -1; }], [apr_cv_sock_cloexec=yes], [apr_cv_sock_cloexec=no], [apr_cv_sock_cloexec=no])]) @@ -1313,7 +1402,7 @@ if test "$ac_cv_func_mmap" = "yes" && #ifdef HAVE_SYS_MMAN_H #include <sys/mman.h> #endif - int main() + int main(int argc, const char *argv[]) { int fd; void *m; @@ -1438,6 +1527,13 @@ if test "$havemmapshm" = "1"; then APR_DECISION_OVERRIDE(USE_SHMEM_MMAP_SHM) fi ]) +AC_ARG_ENABLE(sysv-shm, +[ --enable-sysv-shm Use SysV shared memory (shmget) if available], +[ +if test "$haveshmget" = "1"; then + APR_DECISION_OVERRIDE(USE_SHMEM_SHMGET) +fi +]) case $host in *linux* ) # Linux pre-2.4 had problems with MM_SHMT_MMANON even though @@ -1708,6 +1804,7 @@ AC_SUBST(netinet_sctph) AC_SUBST(netinet_sctp_uioh) AC_SUBST(netinet_tcph) AC_SUBST(stdargh) +AC_SUBST(stddefh) AC_SUBST(stdioh) AC_SUBST(stdlibh) AC_SUBST(stringh) @@ -2376,7 +2473,7 @@ AC_TRY_RUN([ #ifndef SEM_FAILED #define SEM_FAILED (-1) #endif -int main() +int main(int argc, const char *argv[]) { sem_t *psem; const char *sem_name = "/apr_autoconf"; @@ -2437,7 +2534,7 @@ if test "$threads" = "1"; then #include <sys/types.h> #include <pthread.h> #include <stdlib.h> - int main() + int main(int argc, const char *argv[]) { pthread_mutex_t mutex; pthread_mutexattr_t attr; @@ -2575,7 +2672,7 @@ const char *fname = "conftest.fcntl"; int lockit(); -int main() +int main(int argc, const char *argv[]) { int rc, status;; proc_mutex_lock_it.l_whence = SEEK_SET; /* from current point */ |