168
167
[DBDIR='${sysconfdir}/${PACKAGE}'])
169
168
AC_SUBST([DBDIR])])
171
dnl Defines HAVE_BACKTRACE if backtrace() is declared in <execinfo.h>
172
dnl and exists in libc.
170
dnl Defines HAVE_BACKTRACE if backtrace() is found.
173
171
AC_DEFUN([OVS_CHECK_BACKTRACE],
174
[AC_CHECK_HEADER([execinfo.h], [AC_CHECK_FUNCS([backtrace])])])
172
[AC_SEARCH_LIBS([backtrace], [execinfo ubacktrace],
173
[AC_DEFINE([HAVE_BACKTRACE], [1],
174
[Define to 1 if you have backtrace(3).])])])
176
176
dnl Checks for __malloc_hook, etc., supported by glibc.
177
177
AC_DEFUN([OVS_CHECK_MALLOC_HOOKS],
392
392
AM_CONDITIONAL([HAVE_GROFF], [test "$ovs_cv_groff" = yes])])
394
dnl Checks for thread-local storage support.
396
dnl Checks whether the compiler and linker support the C11
397
dnl thread_local macro from <threads.h>, and if so defines
398
dnl HAVE_THREAD_LOCAL. If not, checks whether the compiler and linker
399
dnl support the GCC __thread extension, and if so defines
401
AC_DEFUN([OVS_CHECK_TLS],
403
[whether $CC has <threads.h> that supports thread_local],
404
[ovs_cv_thread_local],
406
[AC_LANG_PROGRAM([#include <threads.h>
407
static thread_local int var;], [return var;])],
408
[ovs_cv_thread_local=yes],
409
[ovs_cv_thread_local=no])])
410
if test $ovs_cv_thread_local = yes; then
411
AC_DEFINE([HAVE_THREAD_LOCAL], [1],
412
[Define to 1 if the C compiler and linker supports the C11
413
thread_local matcro defined in <threads.h>.])
416
[whether $CC supports __thread],
419
[AC_LANG_PROGRAM([static __thread int var;], [return var;])],
420
[ovs_cv___thread=yes],
421
[ovs_cv___thread=no])])
422
if test $ovs_cv___thread = yes; then
423
AC_DEFINE([HAVE___THREAD], [1],
424
[Define to 1 if the C compiler and linker supports the
425
GCC __thread extenions.])
429
dnl OVS_CHECK_GCC4_ATOMICS
431
dnl Checks whether the compiler and linker support GCC 4.0+ atomic built-ins.
432
dnl A compile-time only check is not enough because the compiler defers
433
dnl unimplemented built-ins to libgcc, which sometimes also lacks
435
AC_DEFUN([OVS_CHECK_GCC4_ATOMICS],
437
[whether $CC supports GCC 4.0+ atomic built-ins],
438
[ovs_cv_gcc4_atomics],
440
[AC_LANG_PROGRAM([[#include <stdlib.h>
442
#define ovs_assert(expr) if (!(expr)) abort();
443
#define TEST_ATOMIC_TYPE(TYPE) \
448
__sync_synchronize(); \
449
ovs_assert(x == 1); \
451
__sync_synchronize(); \
453
__sync_synchronize(); \
454
ovs_assert(x == 3); \
456
orig = __sync_fetch_and_add(&x, 1); \
457
ovs_assert(orig == 3); \
458
__sync_synchronize(); \
459
ovs_assert(x == 4); \
461
orig = __sync_fetch_and_sub(&x, 2); \
462
ovs_assert(orig == 4); \
463
__sync_synchronize(); \
464
ovs_assert(x == 2); \
466
orig = __sync_fetch_and_or(&x, 6); \
467
ovs_assert(orig == 2); \
468
__sync_synchronize(); \
469
ovs_assert(x == 6); \
471
orig = __sync_fetch_and_and(&x, 10); \
472
ovs_assert(orig == 6); \
473
__sync_synchronize(); \
474
ovs_assert(x == 2); \
476
orig = __sync_fetch_and_xor(&x, 10); \
477
ovs_assert(orig == 2); \
478
__sync_synchronize(); \
479
ovs_assert(x == 8); \
481
TEST_ATOMIC_TYPE(char);
482
TEST_ATOMIC_TYPE(unsigned char);
483
TEST_ATOMIC_TYPE(signed char);
484
TEST_ATOMIC_TYPE(short);
485
TEST_ATOMIC_TYPE(unsigned short);
486
TEST_ATOMIC_TYPE(int);
487
TEST_ATOMIC_TYPE(unsigned int);
488
TEST_ATOMIC_TYPE(long int);
489
TEST_ATOMIC_TYPE(unsigned long int);
490
TEST_ATOMIC_TYPE(long long int);
491
TEST_ATOMIC_TYPE(unsigned long long int);
493
[ovs_cv_gcc4_atomics=yes],
494
[ovs_cv_gcc4_atomics=no])])
495
if test $ovs_cv_gcc4_atomics = yes; then
496
AC_DEFINE([HAVE_GCC4_ATOMICS], [1],
497
[Define to 1 if the C compiler and linker supports the GCC 4.0+
501
dnl OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(SIZE)
503
dnl Checks __atomic_always_lock_free(SIZE, 0)
504
AC_DEFUN([OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE],
506
[value of __atomic_always_lock_free($1)],
507
[ovs_cv_atomic_always_lock_free_$1],
509
[ovs_cv_atomic_always_lock_free_$1],
510
[__atomic_always_lock_free($1, 0)],
512
[ovs_cv_atomic_always_lock_free_$1=unsupported])])
513
if test ovs_cv_atomic_always_lock_free_$1 != unsupported; then
515
[ATOMIC_ALWAYS_LOCK_FREE_$1B],
516
[$ovs_cv_atomic_always_lock_free_$1],
517
[If the C compiler is GCC 4.7 or later, define to the return value of
518
__atomic_always_lock_free($1, 0). If the C compiler is not GCC or is
519
an older version of GCC, the value does not matter.])
522
dnl OVS_CHECK_POSIX_AIO
523
AC_DEFUN([OVS_CHECK_POSIX_AIO],
524
[AC_SEARCH_LIBS([aio_write], [rt])
525
AM_CONDITIONAL([HAVE_POSIX_AIO], [test "$ac_cv_search_aio_write" != no])])