~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to m4/openvswitch.m4

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- autoconf -*-
2
2
 
3
 
# Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
 
3
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
6
# you may not use this file except in compliance with the License.
99
99
     [ssl=check])
100
100
 
101
101
   if test "$ssl" != false; then
102
 
       m4_ifndef([PKG_CHECK_MODULES], [m4_fatal([Please install pkg-config.])])
103
 
       PKG_CHECK_MODULES([SSL], [openssl],
 
102
       AX_CHECK_OPENSSL(
104
103
         [HAVE_OPENSSL=yes],
105
104
         [HAVE_OPENSSL=no
106
105
          if test "$ssl" = check; then
168
167
     [DBDIR='${sysconfdir}/${PACKAGE}'])
169
168
   AC_SUBST([DBDIR])])
170
169
 
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).])])])
175
175
 
176
176
dnl Checks for __malloc_hook, etc., supported by glibc.
177
177
AC_DEFUN([OVS_CHECK_MALLOC_HOOKS],
390
390
       ovs_cv_groff=no
391
391
     fi])
392
392
   AM_CONDITIONAL([HAVE_GROFF], [test "$ovs_cv_groff" = yes])])
 
393
 
 
394
dnl Checks for thread-local storage support.
 
395
dnl
 
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
 
400
dnl HAVE___THREAD.
 
401
AC_DEFUN([OVS_CHECK_TLS],
 
402
  [AC_CACHE_CHECK(
 
403
     [whether $CC has <threads.h> that supports thread_local],
 
404
     [ovs_cv_thread_local],
 
405
     [AC_LINK_IFELSE(
 
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>.])
 
414
   else
 
415
     AC_CACHE_CHECK(
 
416
       [whether $CC supports __thread],
 
417
       [ovs_cv___thread],
 
418
       [AC_LINK_IFELSE(
 
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.])
 
426
     fi
 
427
   fi])
 
428
 
 
429
dnl OVS_CHECK_GCC4_ATOMICS
 
430
dnl
 
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
 
434
dnl implementations.
 
435
AC_DEFUN([OVS_CHECK_GCC4_ATOMICS],
 
436
  [AC_CACHE_CHECK(
 
437
     [whether $CC supports GCC 4.0+ atomic built-ins],
 
438
     [ovs_cv_gcc4_atomics],
 
439
     [AC_LINK_IFELSE(
 
440
        [AC_LANG_PROGRAM([[#include <stdlib.h>
 
441
 
 
442
#define ovs_assert(expr) if (!(expr)) abort();
 
443
#define TEST_ATOMIC_TYPE(TYPE)                  \
 
444
    {                                           \
 
445
        TYPE x = 1;                             \
 
446
        TYPE orig;                              \
 
447
                                                \
 
448
        __sync_synchronize();                   \
 
449
        ovs_assert(x == 1);                     \
 
450
                                                \
 
451
        __sync_synchronize();                   \
 
452
        x = 3;                                  \
 
453
        __sync_synchronize();                   \
 
454
        ovs_assert(x == 3);                     \
 
455
                                                \
 
456
        orig = __sync_fetch_and_add(&x, 1);     \
 
457
        ovs_assert(orig == 3);                  \
 
458
        __sync_synchronize();                   \
 
459
        ovs_assert(x == 4);                     \
 
460
                                                \
 
461
        orig = __sync_fetch_and_sub(&x, 2);     \
 
462
        ovs_assert(orig == 4);                  \
 
463
        __sync_synchronize();                   \
 
464
        ovs_assert(x == 2);                     \
 
465
                                                \
 
466
        orig = __sync_fetch_and_or(&x, 6);      \
 
467
        ovs_assert(orig == 2);                  \
 
468
        __sync_synchronize();                   \
 
469
        ovs_assert(x == 6);                     \
 
470
                                                \
 
471
        orig = __sync_fetch_and_and(&x, 10);    \
 
472
        ovs_assert(orig == 6);                  \
 
473
        __sync_synchronize();                   \
 
474
        ovs_assert(x == 2);                     \
 
475
                                                \
 
476
        orig = __sync_fetch_and_xor(&x, 10);    \
 
477
        ovs_assert(orig == 2);                  \
 
478
        __sync_synchronize();                   \
 
479
        ovs_assert(x == 8);                     \
 
480
    }]], [dnl
 
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);
 
492
])],
 
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+
 
498
                atomic built-ins.])
 
499
   fi])
 
500
 
 
501
dnl OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(SIZE)
 
502
dnl
 
503
dnl Checks __atomic_always_lock_free(SIZE, 0)
 
504
AC_DEFUN([OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE], 
 
505
  [AC_CACHE_CHECK(
 
506
    [value of __atomic_always_lock_free($1)],
 
507
    [ovs_cv_atomic_always_lock_free_$1],
 
508
    [AC_COMPUTE_INT(
 
509
        [ovs_cv_atomic_always_lock_free_$1],
 
510
        [__atomic_always_lock_free($1, 0)],
 
511
        [],
 
512
        [ovs_cv_atomic_always_lock_free_$1=unsupported])])
 
513
   if test ovs_cv_atomic_always_lock_free_$1 != unsupported; then
 
514
     AC_DEFINE_UNQUOTED(
 
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.])
 
520
   fi])
 
521
 
 
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])])