Commit | Line | Data |
---|---|---|
48d848c7 PMF |
1 | # -*- Autoconf -*- |
2 | # Process this file with autoconf to produce a configure script. | |
3 | ||
4 | ||
d61c552b | 5 | AC_INIT([userspace-rcu], [0.4.0], [mathieu dot desnoyers at polymtl dot ca]) |
48d848c7 | 6 | AC_CONFIG_AUX_DIR([config]) |
7d413817 MD |
7 | AC_CANONICAL_TARGET |
8 | AC_CANONICAL_HOST | |
48d848c7 PMF |
9 | AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip]) |
10 | AC_CONFIG_SRCDIR([urcu.h]) | |
0f4ac97f | 11 | AM_PROG_MKDIR_P |
7d413817 | 12 | |
e72596d1 MD |
13 | AC_CONFIG_HEADERS([config.h urcu/config.h]) |
14 | ||
15 | # Keep at the end to do not pollute installed header. | |
02be5561 MD |
16 | AH_TEMPLATE([CONFIG_RCU_SMP], [Enable SMP support. With SMP support enabled, uniprocessors are also supported. With SMP support disabled, UP systems work fine, but the behavior of SMP systems is undefined.]) |
17 | AH_TEMPLATE([CONFIG_RCU_HAVE_FENCE], [Defined when on a system that has memory fence instructions.]) | |
18 | AH_TEMPLATE([CONFIG_RCU_HAVE_FUTEX], [Defined when on a system with futex support.]) | |
19 | AH_TEMPLATE([CONFIG_RCU_COMPAT_ARCH], [Compatibility mode for i386 which lacks | |
bf9de1b7 | 20 | cmpxchg instruction.]) |
48d848c7 PMF |
21 | |
22 | # Checks for programs. | |
23 | AC_PROG_CC | |
24 | AC_PROG_MAKE_SET | |
25 | AC_PROG_LIBTOOL | |
26 | ||
27 | # Checks for typedefs, structures, and compiler characteristics. | |
28 | AC_C_INLINE | |
29 | AC_TYPE_PID_T | |
30 | AC_TYPE_SIZE_T | |
31 | ||
32 | # Checks for library functions. | |
33 | AC_FUNC_MALLOC | |
34 | AC_FUNC_MMAP | |
35 | AC_CHECK_FUNCS([bzero gettimeofday munmap strtoul]) | |
36 | ||
37 | # Find arch type | |
c5b9f8ff | 38 | case $host_cpu in |
7d413817 | 39 | i386) ARCHTYPE="x86"; SUBARCHTYPE="x86compat" ;; |
bf9de1b7 MD |
40 | i486) ARCHTYPE="x86";; |
41 | i586) ARCHTYPE="x86";; | |
42 | i686) ARCHTYPE="x86";; | |
48d848c7 | 43 | x86_64) ARCHTYPE="x86";; |
48d848c7 PMF |
44 | powerpc) ARCHTYPE="ppc" ;; |
45 | ppc64) ARCHTYPE="ppc" ;; | |
7d413817 | 46 | powerpc64) ARCHTYPE="ppc" ;; |
48d848c7 PMF |
47 | ppc) ARCHTYPE="ppc" ;; |
48 | s390) ARCHTYPE="s390" ;; | |
49 | s390x) ARCHTYPE="s390" ;; | |
c0a68bfa | 50 | sparc64) ARCHTYPE="sparc64" ;; |
48d848c7 PMF |
51 | *) ARCHTYPE="unknown";; |
52 | esac | |
53 | ||
54 | if test "$ARCHTYPE" = "unknown"; then | |
55 | AC_MSG_ERROR([Unable to detect the architecture.]) | |
56 | fi | |
57 | AC_SUBST(ARCHTYPE) | |
7d413817 | 58 | AC_SUBST(SUBARCHTYPE) |
48d848c7 | 59 | |
90586875 | 60 | [ |
c5b9f8ff | 61 | #if test "x$ARCHTYPE" = "xx86" -a "x$host_cpu" != "xi386" -a "x$host_cpu" != "xi486" -a "x$host_cpu" != "xi586"; then |
6cb4ed53 MD |
62 | #For now, using lock; addl compatibility mode even for i686, because the |
63 | #Pentium III is seen as a i686, but lacks mfence instruction. | |
64 | #Only using fence for x86_64. | |
c5b9f8ff | 65 | if test "x$ARCHTYPE" = "xx86" -a "x$host_cpu" != "xi386" -a "x$host_cpu" != "xi486" -a "x$host_cpu" != "xi586" -a "x$host_cpu" != "xi686"; then |
90586875 | 66 | ] |
02be5561 | 67 | AC_DEFINE([CONFIG_RCU_HAVE_FENCE], [1]) |
90586875 MD |
68 | [ |
69 | fi | |
70 | ] | |
71 | ||
49617de1 | 72 | AC_MSG_CHECKING([sys_futex()]) |
0854ccff MD |
73 | AC_TRY_COMPILE( |
74 | [ | |
75 | #include <sys/syscall.h> | |
76 | ], | |
77 | [ | |
78 | #ifndef __NR_futex | |
79 | #error "futexes not available" | |
80 | #endif | |
81 | ], | |
82 | [ | |
83 | AC_MSG_RESULT([yes]) | |
02be5561 | 84 | AC_DEFINE([CONFIG_RCU_HAVE_FUTEX], [1]) |
0854ccff MD |
85 | compat_futex_test=0 |
86 | ] | |
87 | , | |
88 | [ | |
89 | AC_MSG_RESULT([no]) | |
90 | compat_futex_test=1 | |
91 | ] | |
92 | ) | |
93 | ||
94 | AM_CONDITIONAL([COMPAT_FUTEX], [ test "x$compat_futex_test" = "x1" ]) | |
95 | ||
40646e1e | 96 | AM_CONDITIONAL([GCC_API], [test "x$ARCHTYPE" != xx86 -a "x$ARCHTYPE" != xppc]) |
48d848c7 | 97 | |
0854ccff | 98 | AM_CONDITIONAL([COMPAT_ARCH], [test "x$SUBARCHTYPE" = xx86compat ]) |
7d413817 | 99 | |
bf9de1b7 MD |
100 | [ |
101 | if test "x$SUBARCHTYPE" = xx86compat; then | |
102 | ] | |
02be5561 | 103 | AC_DEFINE([CONFIG_RCU_COMPAT_ARCH], [1]) |
bf9de1b7 MD |
104 | [ |
105 | fi | |
106 | ] | |
107 | ||
7d413817 MD |
108 | AC_ARG_ENABLE([smp-support], [ --disable-smp-support Disable SMP support. Warning: only use this |
109 | on uniprocessor systems. [[default=enabled]]], [def_smp_support=$enableval], [def_smp_support="yes"]) | |
110 | ||
111 | [ | |
112 | if test "$def_smp_support" = "no"; then | |
113 | echo "SMP support disabled." | |
114 | else | |
115 | ] | |
02be5561 | 116 | AC_DEFINE([CONFIG_RCU_SMP], [1]) |
7d413817 MD |
117 | [ |
118 | echo "SMP support enabled." | |
119 | fi | |
120 | ] | |
48d848c7 | 121 | |
d8540fc5 PA |
122 | # From the sched_setaffinity(2)'s man page: |
123 | # ~~~~ | |
124 | # The CPU affinity system calls were introduced in Linux kernel 2.5.8. | |
125 | # The library interfaces were introduced in glibc 2.3. Initially, the | |
126 | # glibc interfaces included a cpusetsize argument. In glibc 2.3.3, | |
127 | # the cpuset size argument was removed, but this argument was | |
128 | # restored in glibc 2.3.4. | |
129 | # ~~~~ | |
130 | ||
131 | # In addition to that, some vendors ported the system call to 2.4 | |
132 | # kernels. | |
133 | ||
134 | # Furthermore, when the function first appeared, the MASK argument was | |
135 | # an unsigned long pointer, while later it was made into a cpu_set_t | |
136 | # pointer. Systems that have the cpu_set_t version also should have | |
137 | # the CPU_ZERO, CPU_SET, etc. macros. | |
138 | ||
139 | # All this mess means we have to cater for at least 3 different | |
140 | # sched_setaffinity prototypes: | |
141 | ||
142 | # ~~~~ | |
143 | # int sched_setaffinity (pid_t pid, unsigned int len, unsigned long *mask); | |
144 | # int sched_setaffinity (pid_t __pid, size_t __cpusetsize, const cpu_set_t *__cpuset); | |
145 | # int sched_setaffinity (pid_t __pid, const cpu_set_t *__mask); | |
146 | # ~~~~ | |
147 | ||
148 | dnl Since we define _GNU_SOURCE in the sources, must do so too in the | |
149 | dnl autoconf tests, as defining _GNU_SOURCE or not exposes | |
150 | dnl sched_setaffinity bits differently. | |
151 | saved_CFLAGS=$CFLAGS | |
152 | CFLAGS="$CFLAGS -D_GNU_SOURCE" | |
153 | ||
154 | # First check if the function is available at all. | |
155 | AC_CHECK_FUNCS( | |
156 | [sched_setaffinity], | |
157 | [ # Okay, we have it. Check if also have cpu_set_t. If we don't, | |
158 | # then we have the first version using unsigned long, and no | |
159 | # CPU_ZERO, etc. macros. If we do have cpu_set_t, we may have the | |
160 | # version with 2 or 3 arguments. In that case, CPU_ZERO, etc., | |
161 | # should also be present, but we confirm nonetheless. | |
162 | ||
163 | AC_CHECK_TYPES( | |
164 | [cpu_set_t], | |
165 | [ # We do have it. Confirm that we have CPU_ZERO, and it actually works. | |
166 | AC_MSG_CHECKING([whether CPU_ZERO works]) | |
167 | AH_TEMPLATE([HAVE_CPU_ZERO], | |
168 | [Define to 1 if we have CPU_ZERO and if it works]) | |
169 | AC_COMPILE_IFELSE( | |
170 | [AC_LANG_PROGRAM( | |
171 | [#define _GNU_SOURCE | |
172 | #include <sched.h>], | |
173 | [cpu_set_t foo; CPU_ZERO (&foo);]) | |
174 | ], | |
175 | [ # Works! | |
176 | AC_DEFINE(HAVE_CPU_ZERO, 1) | |
177 | AC_MSG_RESULT([yes]) | |
178 | ], | |
179 | [AC_MSG_RESULT([no])] | |
180 | ) | |
181 | ||
182 | # Check how many arguments does sched_setaffinity take. | |
183 | # Should be 3 or 2. | |
184 | AC_MSG_CHECKING([how many arguments sched_setaffinity takes]) | |
185 | AC_COMPILE_IFELSE( | |
186 | [AC_LANG_PROGRAM( | |
187 | [#include <sched.h>], | |
188 | [cpu_set_t foo; sched_setaffinity (0, sizeof (foo), &foo);]) | |
189 | ], | |
190 | [sched_set_affinity_args=3], | |
191 | [sched_set_affinity_args=2]) | |
192 | AC_DEFINE_UNQUOTED(SCHED_SETAFFINITY_ARGS, $sched_set_affinity_args, | |
193 | [Define to sched_setaffinity's number of arguments.]) | |
194 | AC_MSG_RESULT([$sched_set_affinity_args]) | |
195 | ], | |
196 | [ # No cpu_set_t, always 3 args. | |
197 | AC_DEFINE(SCHED_SETAFFINITY_ARGS, 3) ], | |
198 | [#include <sched.h>] | |
199 | ) | |
200 | ] | |
201 | ) | |
202 | ||
203 | CFLAGS=$saved_CFLAGS | |
204 | ||
48d848c7 PMF |
205 | AC_CONFIG_FILES([ |
206 | Makefile | |
207 | tests/Makefile | |
208 | ]) | |
209 | AC_OUTPUT |