File: ac_interlocked_exchange.m4

package info (click to toggle)
ctemplate 2.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,232 kB
  • ctags: 2,866
  • sloc: cpp: 27,692; sh: 10,716; ansic: 2,372; makefile: 439; python: 204; lisp: 197; perl: 86
file content (36 lines) | stat: -rw-r--r-- 1,723 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Check whether InterlockedExchange() takes a LONG or a volatile LONG
# as its first argument.  InterlockedCompareExchange is a windows
# function; obviously, this macro is useful only for cygwin and mingw,
# and other systems that compile against the windows API.
#
# Apparently the interface for this function is a bit inconsistent.
# Windows likes volatile LONG, but mingw and cygwin don't, at least
# for the versions I'm using.  But rather than try to guess who
# supports what, let's just check at configure time.  (Note: this
# is an error in C++ but only a warning in C, so we test in the former.)
#
# This function returns 'yes' if the type does not need volatile,
# and defines the symbol INTERLOCKED_EXCHANGE_NONVOLATILE.  (This
# is the expected case for mingw and cygwin).  It returns 'no',
# and defines no symbol, otherwise.  (This is the expected case for
# MSVC.)  The return value was sset this way so that we don't need
# to define any symbols on windows, which doesn't run configure.

AC_DEFUN([AC_INTERLOCKED_EXCHANGE_NONVOLATILE],
[
AC_MSG_CHECKING(whether first argument to InterlockedExchange omits volatile)
AC_CACHE_VAL(ac_cv_interlocked_exchange_nonvolatile,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([#include <windows.h>],
                [volatile LONG once; InterlockedExchange(&once,  1);],
                ac_cv_interlocked_exchange_nonvolatile="no",
                ac_cv_interlocked_exchange_nonvolatile="yes")
 AC_LANG_RESTORE
])
if test "$ac_cv_interlocked_exchange_nonvolatile" = "yes"; then
  AC_DEFINE(INTERLOCKED_EXCHANGE_NONVOLATILE, 1,
            [define if first argument to InterlockedExchange is just LONG])
fi
AC_MSG_RESULT($ac_cv_interlocked_exchange_nonvolatile)
])