-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
configure.ac
205 lines (186 loc) · 5.32 KB
/
configure.ac
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
dnl Not sure which autoconf version we need, but 2.68 (from 2010)
dnl is widely available.
AC_PREREQ([2.68])
AC_DEFUN([VERSION], m4_esyscmd_s(cat VERSION))
AC_INIT([cysignals], VERSION, [https://github.com/sagemath/cysignals/issues])
AC_COPYRIGHT([GNU Lesser General Public License version 3 or later])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([src/config.h src/cysignals/cysignals_config.h])
AC_CONFIG_FILES([src/cysignals/signals.pxd])
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [enable debug output]))
if test "$enable_debug" = yes; then
AC_DEFINE([ENABLE_DEBUG_CYSIGNALS], 1, [Enable debug output])
fi
AC_PROG_CC()
dnl We use the C compiler for C++ to emulate the Python bug
dnl https://bugs.python.org/issue1222585
CXX="$CC"
CXXFLAGS="$CFLAGS"
AC_PROG_CXX()
AC_CHECK_HEADERS([execinfo.h sys/mman.h sys/prctl.h time.h sys/wait.h windows.h])
AC_CHECK_FUNCS([fork kill sigprocmask sigaltstack backtrace])
AC_MSG_CHECKING([for emms instruction])
# We add the "leal" instruction to reduce false positives in case some
# non-x86 architecture also has an "emms" instruction.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[asm("leal (%eax), %eax; emms");]])],
dnl YES
[AC_MSG_RESULT([yes])]
AC_DEFINE(HAVE_EMMS, 1, [Define to 1 if your processor understands the "emms" instruction.])
,
dnl NO
[AC_MSG_RESULT([no])]
)
AC_MSG_CHECKING([whether setjmp() saves the signal mask])
AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[
#include <stdlib.h>
#include <setjmp.h>
#include <signal.h>
]],
[[
jmp_buf env;
sigset_t set;
sigemptyset(&set);
if (sigprocmask(SIG_SETMASK, &set, NULL)) return 2;
if (setjmp(env) == 0)
{
sigaddset(&set, SIGFPE);
if (sigprocmask(SIG_SETMASK, &set, NULL)) return 3;
longjmp(env, 1);
}
if (sigprocmask(SIG_SETMASK, NULL, &set)) return 4;
return sigismember(&set, SIGFPE);
]])],
dnl YES
[AC_MSG_RESULT([yes])]
sigsetjmp=yes
,
dnl NO
[AC_MSG_RESULT([no])]
,
[AC_MSG_RESULT([cross, assume yes])]
sigsetjmp=yes
)
AC_MSG_CHECKING([for GNU libc])
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[
#include <features.h>
#ifndef __GLIBC__
syntax error!
#endif
]])],
dnl YES
[AC_MSG_RESULT([yes])]
# GNU libc implements setjmp(...) as a wrapper of sigsetjmp(..., 0)
# so we might as well call the latter directly
sigsetjmp=yes
,
dnl NO
[AC_MSG_RESULT([no])]
)
if test x$sigsetjmp = xyes; then
AC_DEFINE(CYSIGNALS_USE_SIGSETJMP, 1, [Define to 1 to use sigsetjmp() in sig_on(), as opposed to setjmp().])
fi
dnl Check for atomic operations
AC_MSG_CHECKING([for _Atomic in C code])
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[
static _Atomic int x;
]])],
dnl YES
[AC_MSG_RESULT([yes])]
AC_DEFINE(CYSIGNALS_C_ATOMIC, 1, [Define to 1 if your C compiler supports _Atomic.])
AC_MSG_CHECKING([for _Atomic with OpenMP in C code])
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fopenmp"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[
static _Atomic int x;
]])],
dnl YES
[AC_MSG_RESULT([yes])]
AC_DEFINE(CYSIGNALS_C_ATOMIC_WITH_OPENMP, 1, [Define to 1 if your C compiler supports _Atomic with OpenMP])
,
dnl NO
[AC_MSG_RESULT([no])]
)
CFLAGS="$saved_CFLAGS"
,
dnl NO
[AC_MSG_RESULT([no])]
)
AC_LANG(C++)
AC_MSG_CHECKING([for _Atomic in C++ code])
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[
static _Atomic int x;
]])],
dnl YES
[AC_MSG_RESULT([yes])]
AC_DEFINE(CYSIGNALS_CXX_ATOMIC, 1, [Define to 1 if your C++ compiler supports _Atomic.])
AC_MSG_CHECKING([for _Atomic with OpenMP in C++ code])
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fopenmp"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[
static _Atomic int x;
]])],
dnl YES
[AC_MSG_RESULT([yes])]
AC_DEFINE(CYSIGNALS_CXX_ATOMIC_WITH_OPENMP, 1, [Define to 1 if your C++ compiler supports _Atomic with OpenMP])
,
dnl NO
[AC_MSG_RESULT([no])]
)
CXXFLAGS="$saved_CXXFLAGS"
,
dnl NO
[AC_MSG_RESULT([no])]
)
AC_MSG_CHECKING([for std::atomic])
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[
#include <atomic>
static std::atomic<int> x;
]])],
dnl YES
[AC_MSG_RESULT([yes])]
AC_DEFINE(CYSIGNALS_STD_ATOMIC, 1, [Define to 1 if your C++ compiler supports std::atomic.])
AC_MSG_CHECKING([for std::atomic with OpenMP in C++ code])
saved_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fopenmp"
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[
#include <atomic>
static std::atomic<int> x;
]])],
dnl YES
[AC_MSG_RESULT([yes])]
AC_DEFINE(CYSIGNALS_STD_ATOMIC_WITH_OPENMP, 1, [Define to 1 if your C++ compiler supports std::atomic with OpenMP])
,
dnl NO
[AC_MSG_RESULT([no])]
)
CXXFLAGS="$saved_CXXFLAGS"
,
dnl NO
[AC_MSG_RESULT([no])]
)
AC_MSG_CHECKING([whether MINSIGSTKSZ is constant])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <signal.h>
]],
[[
static char alt_stack[MINSIGSTKSZ];
]])],
dnl YES
[AC_MSG_RESULT([yes])]
AC_DEFINE(MINSIGSTKSZ_IS_CONSTANT, 1, [Define to 1 if MINSIGSTKSZ defined in signal.h is constant.])
,
dnl NO
[AC_MSG_RESULT([no])]
)
AC_OUTPUT()
dnl vim:syntax=m4