Whamcloud - gitweb
LU-1617 build: skip generated files in .gitignore
[fs/lustre-release.git] / libcfs / autoconf / lustre-libcfs.m4
1 #
2 # LN_CONFIG_CDEBUG
3 #
4 # whether to enable various libcfs debugs (CDEBUG, ENTRY/EXIT, LASSERT, etc.)
5 #
6 AC_DEFUN([LN_CONFIG_CDEBUG],
7 [
8 AC_MSG_CHECKING([whether to enable CDEBUG, CWARN])
9 AC_ARG_ENABLE([libcfs_cdebug],
10         AC_HELP_STRING([--disable-libcfs-cdebug],
11                         [disable libcfs CDEBUG, CWARN]),
12         [],[enable_libcfs_cdebug='yes'])
13 AC_MSG_RESULT([$enable_libcfs_cdebug])
14 if test x$enable_libcfs_cdebug = xyes; then
15    AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])
16 else
17    AC_DEFINE(CDEBUG_ENABLED, 0, [disable libcfs CDEBUG, CWARN])
18 fi
19
20 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
21 AC_ARG_ENABLE([libcfs_trace],
22         AC_HELP_STRING([--disable-libcfs-trace],
23                         [disable libcfs ENTRY/EXIT]),
24         [],[enable_libcfs_trace='yes'])
25 AC_MSG_RESULT([$enable_libcfs_trace])
26 if test x$enable_libcfs_trace = xyes; then
27    AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
28 else
29    AC_DEFINE(CDEBUG_ENTRY_EXIT, 0, [disable libcfs ENTRY/EXIT])
30 fi
31
32 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
33 AC_ARG_ENABLE([libcfs_assert],
34         AC_HELP_STRING([--disable-libcfs-assert],
35                         [disable libcfs LASSERT, LASSERTF]),
36         [],[enable_libcfs_assert='yes'])
37 AC_MSG_RESULT([$enable_libcfs_assert])
38 if test x$enable_libcfs_assert = xyes; then
39    AC_DEFINE(LIBCFS_DEBUG, 1, [enable libcfs LASSERT, LASSERTF])
40 fi
41 ])
42
43 #
44 # LIBCFS_CONFIG_PANIC_DUMPLOG
45 #
46 # check if tunable panic_dumplog is wanted
47 #
48 AC_DEFUN([LIBCFS_CONFIG_PANIC_DUMPLOG],
49 [AC_MSG_CHECKING([for tunable panic_dumplog support])
50 AC_ARG_ENABLE([panic_dumplog],
51        AC_HELP_STRING([--enable-panic_dumplog],
52                       [enable panic_dumplog]),
53        [],[enable_panic_dumplog='no'])
54 if test x$enable_panic_dumplog = xyes ; then
55        AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])
56        AC_MSG_RESULT([yes (by request)])
57 else
58        AC_MSG_RESULT([no])
59 fi
60 ])
61
62 # check kernel __u64 type
63 AC_DEFUN([LIBCFS_U64_LONG_LONG_LINUX],
64 [
65 AC_MSG_CHECKING([kernel __u64 is long long type])
66 tmp_flags="$EXTRA_KCFLAGS"
67 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
68 LB_LINUX_TRY_COMPILE([
69         #include <linux/types.h>
70         #include <linux/stddef.h>
71 ],[
72         unsigned long long *data;
73
74         data = (__u64*)sizeof(data);
75 ],[
76         AC_MSG_RESULT([yes])
77         AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
78                   [kernel __u64 is long long type])
79 ],[
80         AC_MSG_RESULT([no])
81 ])
82 EXTRA_KCFLAGS="$tmp_flags"
83 ])
84
85 # LIBCFS_TASKLIST_LOCK
86 # 2.6.18 remove tasklist_lock export
87 AC_DEFUN([LIBCFS_TASKLIST_LOCK],
88 [LB_CHECK_SYMBOL_EXPORT([tasklist_lock],
89 [kernel/fork.c],[
90 AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
91          [tasklist_lock exported])
92 ],[
93 ])
94 ])
95
96 # LIBCFS_DIGEST_SETKEY_FLAGS
97 # digest_alg.dia_setkey takes 4 args (2.6.18)
98 #
99 AC_DEFUN([LIBCFS_DIGEST_SETKEY_FLAGS],
100 [AC_MSG_CHECKING([if kernel dia_setkey takes 4 args])
101 LB_LINUX_TRY_COMPILE([
102         #include <linux/err.h>
103         #include <linux/crypto.h>
104 ],[
105         struct digest_alg alg;
106
107         alg.dia_setkey(NULL, NULL, 0, NULL);
108 ],[
109         AC_MSG_RESULT([yes])
110         AC_DEFINE(HAVE_DIGEST_SETKEY_FLAGS, 1, [kernel dia_setkey takes 4 args])
111 ],[
112         AC_MSG_RESULT([no])
113 ])
114 ])
115
116 # 2.6.19 API changes
117 # kmem_cache_destroy(cachep) return void instead of
118 # int
119 AC_DEFUN([LIBCFS_KMEM_CACHE_DESTROY_INT],
120 [AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
121 LB_LINUX_TRY_COMPILE([
122         #include <linux/slab.h>
123 ],[
124         int i __attribute__ ((unused));
125         i = kmem_cache_destroy(NULL);
126 ],[
127         AC_MSG_RESULT(yes)
128         AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
129                 [kmem_cache_destroy(cachep) return int])
130 ],[
131         AC_MSG_RESULT(NO)
132 ])
133 ])
134
135 # check cpumask_size (2.6.28)
136 AC_DEFUN([LIBCFS_CPUMASK_SIZE],
137 [AC_MSG_CHECKING([whether have cpumask_size()])
138 LB_LINUX_TRY_COMPILE([
139         #include <linux/cpumask.h>
140 ],[
141         int size = cpumask_size();
142 ],[
143         AC_MSG_RESULT(yes)
144         AC_DEFINE(HAVE_CPUMASK_SIZE, 1, [have cpumask_size()])
145 ],[
146         AC_MSG_RESULT(NO)
147 ])
148 ])
149
150 # check cpu topology functions
151 #
152 # topology_core_cpumask (2.6.29, not on all archs)
153 # topology_core_siblings (not on all archs)
154 # topology_thread_cpumask (2.6.29, not on all archs)
155 # topology_thread_siblings (not on all archs)
156 # cpumask_of_node/node_to_cpumask (not always exported)
157 AC_DEFUN([LIBCFS_CPU_TOPOLOGY],
158 [AC_MSG_CHECKING([whether have topology.h])
159 LB_LINUX_TRY_COMPILE([
160         #include <linux/topology.h>
161 ],[],[
162         AC_DEFINE(HAVE_CPU_TOPOLOGY, 1, [have CPU topology])
163         AC_MSG_RESULT(yes)
164
165         AC_MSG_CHECKING([whether have topology_core_cpumask])
166         LB_LINUX_TRY_COMPILE([
167                 #include <linux/topology.h>
168         ],[
169                 cpumask_t *mask = topology_core_cpumask(0);
170         ],[
171                 AC_DEFINE(HAVE_TOPOLOGY_CORE_CPUMASK, 1,
172                           [have topology_core_cpumask])
173                 AC_MSG_RESULT(yes)
174         ],[
175                 AC_MSG_RESULT(no)
176         ])
177
178         AC_MSG_CHECKING([whether have topology_core_siblings])
179         LB_LINUX_TRY_COMPILE([
180                 #include <linux/topology.h>
181         ],[
182                 cpumask_t mask = topology_core_siblings(0);
183         ],[
184                 AC_DEFINE(HAVE_TOPOLOGY_CORE_SIBLINGS, 1,
185                           [have topology_core_siblings])
186                 AC_MSG_RESULT(yes)
187         ],[
188                 AC_MSG_RESULT(no)
189         ])
190
191         AC_MSG_CHECKING([whether have topology_thread_cpumask])
192         LB_LINUX_TRY_COMPILE([
193                 #include <linux/topology.h>
194         ],[
195                 cpumask_t *mask = topology_thread_cpumask(0);
196         ],[
197                 AC_DEFINE(HAVE_TOPOLOGY_THREAD_CPUMASK, 1,
198                           [have topology_thread_cpumask])
199                 AC_MSG_RESULT(yes)
200         ],[
201                 AC_MSG_RESULT(no)
202         ])
203
204         AC_MSG_CHECKING([whether have topology_thread_siblings])
205         LB_LINUX_TRY_COMPILE([
206                 #include <linux/topology.h>
207         ],[
208                 cpumask_t mask = topology_thread_siblings(0);
209         ],[
210                 AC_DEFINE(HAVE_TOPOLOGY_THREAD_SIBLINGS, 1,
211                           [have topology_thread_siblings])
212                 AC_MSG_RESULT(yes)
213         ],[
214                 AC_MSG_RESULT(no)
215         ])
216
217         AC_MSG_CHECKING([whether have cpumask_of_node])
218         LB_LINUX_TRY_COMPILE([
219                 #include <linux/topology.h>
220         ],[
221                 cpumask_t *mask = cpumask_of_node(0);
222         ],[
223                 AC_DEFINE(HAVE_CPUMASK_OF_NODE, 1, [have cpumask_of_node])
224                 AC_MSG_RESULT(yes)
225         ],[
226                 AC_MSG_RESULT(no)
227         ])
228
229         AC_MSG_CHECKING([whether have node_to_cpumask])
230         LB_LINUX_TRY_COMPILE([
231                 #include <linux/topology.h>
232         ],[
233                 cpumask_t mask = node_to_cpumask(0);
234         ],[
235                 AC_DEFINE(HAVE_NODE_TO_CPUMASK, 1, [have node_to_cpumask])
236                 AC_MSG_RESULT(yes)
237         ],[
238                 AC_MSG_RESULT(no)
239         ])
240 ],[
241         AC_MSG_RESULT(NO)
242 ])
243 ])
244
245
246 # 2.6.20 API change INIT_WORK use 2 args and not
247 # store data inside
248 AC_DEFUN([LIBCFS_3ARGS_INIT_WORK],
249 [AC_MSG_CHECKING([check INIT_WORK want 3 args])
250 LB_LINUX_TRY_COMPILE([
251         #include <linux/workqueue.h>
252 ],[
253         struct work_struct work __attribute__ ((unused));
254
255         INIT_WORK(&work, NULL, NULL);
256 ],[
257         AC_MSG_RESULT(yes)
258         AC_DEFINE(HAVE_3ARGS_INIT_WORK, 1,
259                   [INIT_WORK use 3 args and store data inside])
260 ],[
261         AC_MSG_RESULT(NO)
262 ])
263 ])
264
265 # 2.6.21 api change. 'register_sysctl_table' use only one argument,
266 # instead of more old which need two.
267 AC_DEFUN([LIBCFS_2ARGS_REGISTER_SYSCTL],
268 [AC_MSG_CHECKING([check register_sysctl_table want 2 args])
269 LB_LINUX_TRY_COMPILE([
270         #include <linux/sysctl.h>
271 ],[
272         register_sysctl_table(NULL,0);
273 ],[
274         AC_MSG_RESULT(yes)
275         AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1,
276                   [register_sysctl_table want 2 args])
277 ],[
278         AC_MSG_RESULT(NO)
279 ])
280 ])
281
282 # 2.6.23 lost dtor argument
283 AC_DEFUN([LIBCFS_KMEM_CACHE_CREATE_DTOR],
284 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
285 LB_LINUX_TRY_COMPILE([
286         #include <linux/slab.h>
287 ],[
288         kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);
289 ],[
290         AC_MSG_RESULT(yes)
291         AC_DEFINE(HAVE_KMEM_CACHE_CREATE_DTOR, 1,
292                   [kmem_cache_create has dtor argument])
293 ],[
294         AC_MSG_RESULT(NO)
295 ])
296 ])
297
298 #2.6.23 has new shrinker API
299 AC_DEFUN([LC_REGISTER_SHRINKER],
300 [AC_MSG_CHECKING([if kernel has register_shrinker])
301 LB_LINUX_TRY_COMPILE([
302         #include <linux/mm.h>
303 ],[
304         register_shrinker(NULL);
305 ], [
306         AC_MSG_RESULT([yes])
307         AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
308                 [kernel has register_shrinker])
309 ],[
310         AC_MSG_RESULT([no])
311 ])
312 ])
313
314 # 2.6.24 request not use real numbers for ctl_name
315 AC_DEFUN([LIBCFS_SYSCTL_UNNUMBERED],
316 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
317 LB_LINUX_TRY_COMPILE([
318         #include <linux/sysctl.h>
319 ],[
320         #ifndef CTL_UNNUMBERED
321         #error CTL_UNNUMBERED not exist in kernel
322         #endif
323 ],[
324         AC_MSG_RESULT(yes)
325         AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
326                   [sysctl has CTL_UNNUMBERED])
327 ],[
328         AC_MSG_RESULT(NO)
329 ])
330 ])
331
332 # 2.6.24 lost scatterlist->page
333 AC_DEFUN([LIBCFS_SCATTERLIST_SETPAGE],
334 [AC_MSG_CHECKING([for exist sg_set_page])
335 LB_LINUX_TRY_COMPILE([
336         #include <asm/types.h>
337         #include <linux/scatterlist.h>
338 ],[
339         sg_set_page(NULL,NULL,0,0);
340 ],[
341         AC_MSG_RESULT(yes)
342         AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
343                   [struct scatterlist has page member])
344 ],[
345         AC_MSG_RESULT(NO)
346 ])
347 ])
348
349 # 2.6.24 
350 AC_DEFUN([LIBCFS_NETWORK_NAMESPACE],
351 [AC_MSG_CHECKING([for network stack has namespaces])
352 LB_LINUX_TRY_COMPILE([
353         #include <net/net_namespace.h>
354 ],[
355         struct net *net __attribute__ ((unused));
356         net = &init_net;
357 ],[
358         AC_MSG_RESULT(yes)
359         AC_DEFINE(HAVE_INIT_NET, 1,
360                   [kernel is support network namespaces ])
361 ],[
362         AC_MSG_RESULT(NO)
363 ])
364 ])
365
366 #
367 # LIBCFS_FUNC_DUMP_TRACE
368 #
369 # 2.6.23 exports dump_trace() so we can dump_stack() on any task
370 # 2.6.24 has stacktrace_ops.address with "reliable" parameter
371 #
372 AC_DEFUN([LIBCFS_FUNC_DUMP_TRACE],
373 [LB_CHECK_SYMBOL_EXPORT([dump_trace],
374 [kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c arch/x86/kernel/dumpstack_32.c arch/x86/kernel/dumpstack_64.c],[
375         tmp_flags="$EXTRA_KCFLAGS"
376         EXTRA_KCFLAGS="-Werror"
377         AC_MSG_CHECKING([whether we can really use dump_trace])
378         LB_LINUX_TRY_COMPILE([
379                 struct task_struct;
380                 struct pt_regs;
381                 #include <asm/stacktrace.h>
382         ],[
383         ],[
384                 AC_MSG_RESULT(yes)
385                 AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
386         ],[
387                 AC_MSG_RESULT(no)
388         ],[
389         ])
390         AC_MSG_CHECKING([whether print_trace_address has reliable argument])
391         LB_LINUX_TRY_COMPILE([
392                 struct task_struct;
393                 struct pt_regs;
394                 #include <asm/stacktrace.h>
395         ],[
396                 ((struct stacktrace_ops *)0)->address(NULL, 0, 0);
397         ],[
398                 AC_MSG_RESULT(yes)
399                 AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
400                           [print_trace_address has reliable argument])
401         ],[
402                 AC_MSG_RESULT(no)
403         ],[
404         ])
405         AC_MSG_CHECKING([whether stacktrace_ops.warning is exist])
406         LB_LINUX_TRY_COMPILE([
407                 struct task_struct;
408                 struct pt_regs;
409                 #include <asm/stacktrace.h>
410         ],[
411                 ((struct stacktrace_ops *)0)->warning(NULL, NULL);
412         ],[
413                 AC_MSG_RESULT(yes)
414                 AC_DEFINE(HAVE_STACKTRACE_WARNING, 1, [stacktrace_ops.warning is exist])
415         ],[
416                 AC_MSG_RESULT(no)
417         ],[
418         ])
419         AC_MSG_CHECKING([dump_trace want address])
420         LB_LINUX_TRY_COMPILE([
421                 struct task_struct;
422                 struct pt_regs;
423                 #include <asm/stacktrace.h>
424         ],[
425                 dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
426         ],[
427                 AC_MSG_RESULT(yes)
428                 AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
429                           [dump_trace want address argument])
430         ],[
431                 AC_MSG_RESULT(no)
432         ],[
433         ])
434
435 EXTRA_KCFLAGS="$tmp_flags"
436 ])
437 ])
438
439
440 # 2.6.26 use int instead of atomic for sem.count
441 AC_DEFUN([LIBCFS_SEM_COUNT],
442 [AC_MSG_CHECKING([atomic sem.count])
443 LB_LINUX_TRY_COMPILE([
444         #include <asm/semaphore.h>
445 ],[
446         struct semaphore s __attribute__ ((unused));
447
448         atomic_read(&s.count);
449 ],[
450         AC_MSG_RESULT(yes)
451         AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
452                   [semaphore counter is atomic])
453 ],[
454         AC_MSG_RESULT(NO)
455 ])
456 ])
457
458 # 2.6.27 have second argument to sock_map_fd
459 AC_DEFUN([LIBCFS_SOCK_MAP_FD_2ARG],
460 [AC_MSG_CHECKING([sock_map_fd have second argument])
461 LB_LINUX_TRY_COMPILE([
462         #include <linux/net.h>
463 ],[
464         sock_map_fd(NULL, 0);
465 ],[
466         AC_MSG_RESULT(yes)
467         AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
468                   [sock_map_fd have second argument])
469 ],[
470         AC_MSG_RESULT(NO)
471 ])
472 ])
473
474 # LIBCFS_CRED_WRAPPERS
475 #
476 # wrappers for task's credentials are in sles11
477 #
478 AC_DEFUN([LIBCFS_CRED_WRAPPERS],
479 [AC_MSG_CHECKING([if kernel has wrappers for task's credentials])
480 LB_LINUX_TRY_COMPILE([
481        #include <linux/sched.h>
482 ],[
483        uid_t uid;
484
485        uid = current_uid() + sizeof(uid);
486 ],[
487        AC_MSG_RESULT([yes])
488        AC_DEFINE(HAVE_CRED_WRAPPERS, 1, [task's cred wrappers found])
489 ],[
490        AC_MSG_RESULT([no])
491 ])
492 ])
493
494 #
495 # LN_STRUCT_CRED_IN_TASK
496 #
497 # struct cred was introduced in 2.6.29 to streamline credentials in task struct
498 #
499 AC_DEFUN([LIBCFS_STRUCT_CRED_IN_TASK],
500 [AC_MSG_CHECKING([if kernel has struct cred])
501 LB_LINUX_TRY_COMPILE([
502        #include <linux/sched.h>
503 ],[
504        struct task_struct *tsk = NULL;
505        tsk->real_cred = NULL;
506 ],[
507        AC_MSG_RESULT([yes])
508        AC_DEFINE(HAVE_STRUCT_CRED, 1, [struct cred found])
509 ],[
510        AC_MSG_RESULT([no])
511 ])
512 ])
513
514 # LIBCFS_STRUCT_SHASH_ALG
515 # struct shash_alg was introduced in 2.6.29
516 #
517 AC_DEFUN([LIBCFS_STRUCT_SHASH_ALG],
518 [AC_MSG_CHECKING([if kernel has struct shash_alg])
519 LB_LINUX_TRY_COMPILE([
520         #include <linux/err.h>
521         #include <crypto/internal/hash.h>
522 ],[
523         struct shash_alg foo;
524 ],[
525         AC_MSG_RESULT([yes])
526         AC_DEFINE(HAVE_STRUCT_SHASH_ALG, 1, [kernel has struct shash_alg])
527 ],[
528         AC_MSG_RESULT([no])
529 ])
530 ])
531
532
533 #
534 # LIBCFS_FUNC_UNSHARE_FS_STRUCT
535 #
536 # unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
537 # mess with copy_fs_struct
538 #
539 AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
540 [AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
541 tmp_flags="$EXTRA_KCFLAGS"
542 EXTRA_KCFLAGS="-Werror"
543 LB_LINUX_TRY_COMPILE([
544        #include <linux/sched.h>
545        #include <linux/fs_struct.h>
546 ],[
547        unshare_fs_struct();
548 ],[
549        AC_MSG_RESULT([yes])
550        AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
551 ],[
552        AC_MSG_RESULT([no])
553 ])
554 EXTRA_KCFLAGS="$tmp_flags"
555 ])
556
557 #
558 # LIBCFS_HAVE_IS_COMPAT_TASK
559 #
560 # Added in 2.6.17, it wasn't until 2.6.29 that all
561 # Linux architectures have is_compat_task()
562 #
563 AC_DEFUN([LIBCFS_HAVE_IS_COMPAT_TASK],
564 [AC_MSG_CHECKING([if is_compat_task() is declared])
565 LB_LINUX_TRY_COMPILE([
566         #include <linux/compat.h>
567 ],[
568         int i __attribute__ ((unused));
569         i = is_compat_task();
570 ],[
571         AC_MSG_RESULT([yes])
572         AC_DEFINE(HAVE_IS_COMPAT_TASK, 1, [is_compat_task() is available])
573 ],[
574         AC_MSG_RESULT([no])
575 ])
576 ])
577
578 #
579 # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
580 #
581 # 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
582 #
583 AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK],
584 [AC_MSG_CHECKING([if 'struct stacktrace_ops' has 'walk_stack' field])
585 LB_LINUX_TRY_COMPILE([
586         #include <asm/stacktrace.h>
587 ],[
588         ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
589 ],[
590         AC_MSG_RESULT([yes])
591         AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1, ['struct stacktrace_ops' has 'walk_stack' field])
592 ],[
593         AC_MSG_RESULT([no])
594 ])
595 ])
596
597 AC_DEFUN([LIBCFS_HAVE_OOM_H],
598 [LB_CHECK_FILE([$LINUX/include/linux/oom.h], [
599         AC_DEFINE(HAVE_LINUX_OOM_H, 1,
600                 [kernel has include/oom.h])
601 ],[
602         AC_MSG_RESULT([no])
603 ])
604 ])
605
606 #
607 # check set_mems_allowed
608 # 2.6.31 adds function set_mems_allowed in cpuset.h
609 #
610 AC_DEFUN([LIBCFS_HAVE_SET_MEMS_ALLOWED],
611 [AC_MSG_CHECKING([whether have set_mems_allowed()])
612 LB_LINUX_TRY_COMPILE([
613         #include <linux/cpuset.h>
614 ],[
615         nodemask_t mask;
616
617         set_mems_allowed(mask);
618 ],[
619         AC_MSG_RESULT(yes)
620         AC_DEFINE(HAVE_SET_MEMS_ALLOWED, 1, [have set_mems_allowed()])
621 ],[
622         AC_MSG_RESULT(NO)
623 ])
624 ])
625
626
627 #
628 # RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
629 #
630 AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR],
631 [AC_MSG_CHECKING([shrinker want self pointer in handler])
632 LB_LINUX_TRY_COMPILE([
633         #include <linux/mm.h>
634 ],[
635         struct shrinker *tmp = NULL;
636         tmp->shrink(tmp, 0, 0);
637 ],[
638         AC_MSG_RESULT(yes)
639         AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
640                   [shrinker want self pointer in handler])
641 ],[
642         AC_MSG_RESULT(no)
643 ])
644 ])
645
646 # 2.6.18 store oom parameters in task struct.
647 # 2.6.32 store oom parameters in signal struct
648 AC_DEFUN([LIBCFS_OOMADJ_IN_SIG],
649 [AC_MSG_CHECKING([kernel store oom parameters in task])
650 LB_LINUX_TRY_COMPILE([
651         #include <linux/sched.h>
652 ],[
653         ((struct signal_struct *)0)->oom_adj = 0;
654 ],[
655         AC_MSG_RESULT(yes)
656         AC_DEFINE(HAVE_OOMADJ_IN_SIG, 1,
657                   [kernel store a oom parameters in signal struct])
658 ],[
659         AC_MSG_RESULT(no)
660 ])
661 ])
662
663 #
664 # 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
665 #
666 AC_DEFUN([LIBCFS_SYSCTL_CTLNAME],
667 [AC_MSG_CHECKING([if ctl_table has a ctl_name field])
668 LB_LINUX_TRY_COMPILE([
669         #include <linux/sysctl.h>
670 ],[
671         struct ctl_table ct;
672         ct.ctl_name = sizeof(ct);
673 ],[
674         AC_MSG_RESULT(yes)
675         AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
676                   [ctl_table has ctl_name field])
677 ],[
678         AC_MSG_RESULT(no)
679 ])
680 ])
681
682 #
683 # LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
684 #
685 # 2.6.34 adds __add_wait_queue_exclusive
686 #
687 AC_DEFUN([LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE],
688 [AC_MSG_CHECKING([if __add_wait_queue_exclusive exists])
689 LB_LINUX_TRY_COMPILE([
690         #include <linux/wait.h>
691 ],[
692         wait_queue_head_t queue;
693         wait_queue_t      wait;
694
695         __add_wait_queue_exclusive(&queue, &wait);
696 ],[
697         AC_MSG_RESULT(yes)
698         AC_DEFINE(HAVE___ADD_WAIT_QUEUE_EXCLUSIVE, 1,
699                   [__add_wait_queue_exclusive exists])
700 ],[
701         AC_MSG_RESULT(no)
702 ])
703 ])
704
705 #
706 # 2.6.35 kernel has sk_sleep function
707 #
708 AC_DEFUN([LC_SK_SLEEP],
709 [AC_MSG_CHECKING([if kernel has sk_sleep])
710 LB_LINUX_TRY_COMPILE([
711         #include <net/sock.h>
712 ],[
713         sk_sleep(NULL);
714 ],[
715         AC_MSG_RESULT(yes)
716         AC_DEFINE(HAVE_SK_SLEEP, 1, [kernel has sk_sleep])
717 ],[
718         AC_MSG_RESULT(no)
719 ])
720 ])
721
722 #
723 # FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
724 # pressure shrinker from Linux 3.0
725 #
726 AC_DEFUN([LC_SHRINK_CONTROL],
727 [AC_MSG_CHECKING([shrink_control is present])
728 LB_LINUX_TRY_COMPILE([
729         #include <linux/mm.h>
730 ],[
731         struct shrink_control tmp = {0};
732         tmp.nr_to_scan = sizeof(tmp);
733 ],[
734         AC_MSG_RESULT(yes)
735         AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
736                   [shrink_control is present])
737 ],[
738         AC_MSG_RESULT(no)
739 ])
740 ])
741
742 #
743 # LIBCFS_PROG_LINUX
744 #
745 # LNet linux kernel checks
746 #
747 AC_DEFUN([LIBCFS_PROG_LINUX],
748 [
749 LIBCFS_CONFIG_PANIC_DUMPLOG
750
751 LIBCFS_U64_LONG_LONG_LINUX
752 # 2.6.18
753 LIBCFS_TASKLIST_LOCK
754 LIBCFS_HAVE_IS_COMPAT_TASK
755 LIBCFS_DIGEST_SETKEY_FLAGS
756 # 2.6.19
757 LIBCFS_KMEM_CACHE_DESTROY_INT
758 # 2.6.20
759 LIBCFS_3ARGS_INIT_WORK
760 # 2.6.21
761 LIBCFS_2ARGS_REGISTER_SYSCTL
762 # 2.6.23
763 LIBCFS_KMEM_CACHE_CREATE_DTOR
764 LC_REGISTER_SHRINKER
765 # 2.6.24
766 LIBCFS_SYSCTL_UNNUMBERED
767 LIBCFS_SCATTERLIST_SETPAGE
768 LIBCFS_NETWORK_NAMESPACE
769 LIBCFS_FUNC_DUMP_TRACE
770 # 2.6.26
771 LIBCFS_SEM_COUNT
772 # 2.6.27
773 LIBCFS_CRED_WRAPPERS
774 # 2.6.28
775 LIBCFS_CPUMASK_SIZE
776 # 2.6.29
777 LIBCFS_STRUCT_CRED_IN_TASK
778 LIBCFS_CPU_TOPOLOGY
779 LIBCFS_STRUCT_SHASH_ALG
780 # 2.6.30
781 LIBCFS_FUNC_UNSHARE_FS_STRUCT
782 LIBCFS_SOCK_MAP_FD_2ARG
783 # 2.6.31
784 LIBCFS_HAVE_SET_MEMS_ALLOWED
785 # 2.6.32
786 LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
787 LC_SHRINKER_WANT_SHRINK_PTR
788 LIBCFS_HAVE_OOM_H
789 LIBCFS_OOMADJ_IN_SIG
790 # 2.6.33
791 LIBCFS_SYSCTL_CTLNAME
792 # 2.6.34
793 LIBCFS_ADD_WAIT_QUEUE_EXCLUSIVE
794 # 2.6.35
795 LC_SK_SLEEP
796 # 2.6.40 fc15
797 LC_SHRINK_CONTROL
798 ])
799
800 #
801 # LIBCFS_PROG_DARWIN
802 #
803 # Darwin checks
804 #
805 AC_DEFUN([LIBCFS_PROG_DARWIN],
806 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
807 ])
808
809 #
810 # LIBCFS_PATH_DEFAULTS
811 #
812 # default paths for installed files
813 #
814 AC_DEFUN([LIBCFS_PATH_DEFAULTS],
815 [
816 ])
817
818 #
819 # LIBCFS_CONFIGURE
820 #
821 # other configure checks
822 #
823 AC_DEFUN([LIBCFS_CONFIGURE],
824 [# lnet/utils/portals.c
825 AC_CHECK_HEADERS([asm/types.h endian.h sys/ioctl.h])
826
827 # lnet/utils/debug.c
828 AC_CHECK_HEADERS([linux/version.h])
829
830 AC_CHECK_TYPE([spinlock_t],
831         [AC_DEFINE(HAVE_SPINLOCK_T, 1, [spinlock_t is defined])],
832         [],
833         [#include <linux/spinlock.h>])
834
835 # lnet/utils/wirecheck.c
836 AC_CHECK_FUNCS([strnlen])
837
838 AC_CHECK_TYPE([umode_t],
839         [AC_DEFINE(HAVE_UMODE_T, 1, [umode_t is defined])],
840         [],
841         [#include <asm/types.h>])
842
843 AC_CHECK_TYPE([__s8],
844         [AC_DEFINE(HAVE___S8, 1, [__s8 is defined])],
845         [],
846         [#include <asm/types.h>])
847
848 AC_CHECK_TYPE([__u8],
849         [AC_DEFINE(HAVE___U8, 1, [__u8 is defined])],
850         [],
851         [#include <asm/types.h>])
852
853 AC_CHECK_TYPE([__s16],
854         [AC_DEFINE(HAVE___S16, 1, [__s16 is defined])],
855         [],
856         [#include <asm/types.h>])
857
858 AC_CHECK_TYPE([__u16],
859         [AC_DEFINE(HAVE___U16, 1, [__u16 is defined])],
860         [],
861         [#include <asm/types.h>])
862
863 AC_CHECK_TYPE([__s32],
864         [AC_DEFINE(HAVE___S32, 1, [__s32 is defined])],
865         [],
866         [#include <asm/types.h>])
867
868 AC_CHECK_TYPE([__u32],
869         [AC_DEFINE(HAVE___U32, 1, [__u32 is defined])],
870         [],
871         [#include <asm/types.h>])
872
873 AC_CHECK_TYPE([__u64],
874         [AC_DEFINE(HAVE___U64, 1, [__u64 is defined])],
875         [],
876         [#include <asm/types.h>])
877
878 AC_CHECK_TYPE([__s64],
879         [AC_DEFINE(HAVE___S64, 1, [__s64 is defined])],
880         [],
881         [#include <asm/types.h>])
882
883 # check userland __u64 type
884 AC_MSG_CHECKING([userspace __u64 is long long type])
885 tmp_flags="$CFLAGS"
886 CFLAGS="$CFLAGS -Werror"
887 AC_COMPILE_IFELSE([
888         #include <stdio.h>
889         #include <linux/types.h>
890         #include <linux/stddef.h>
891         int main(void) {
892                 unsigned long long *data1;
893                 __u64 *data2 = NULL;
894
895                 data1 = data2;
896                 return 0;
897         }
898 ],[
899         AC_MSG_RESULT([yes])
900         AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
901                   [__u64 is long long type])
902 ],[
903         AC_MSG_RESULT([no])
904 ])
905 CFLAGS="$tmp_flags"
906
907 # --------  Check for required packages  --------------
908
909
910 AC_MSG_CHECKING([if efence debugging support is requested])
911 AC_ARG_ENABLE(efence,
912         AC_HELP_STRING([--enable-efence],
913                         [use efence library]),
914         [],[enable_efence='no'])
915 AC_MSG_RESULT([$enable_efence])
916 if test "$enable_efence" = "yes" ; then
917         LIBEFENCE="-lefence"
918         AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
919 else
920         LIBEFENCE=""
921 fi
922 AC_SUBST(LIBEFENCE)
923
924
925 # -------- check for -lpthread support ----
926 AC_MSG_CHECKING([whether to use libpthread for libcfs library])
927 AC_ARG_ENABLE([libpthread],
928         AC_HELP_STRING([--disable-libpthread],
929                 [disable libpthread]),
930         [],[enable_libpthread=yes])
931 if test "$enable_libpthread" = "yes" ; then
932         AC_CHECK_LIB([pthread], [pthread_create],
933                 [ENABLE_LIBPTHREAD="yes"],
934                 [ENABLE_LIBPTHREAD="no"])
935         if test "$ENABLE_LIBPTHREAD" = "yes" ; then
936                 AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
937                 PTHREAD_LIBS="-lpthread"
938                 AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
939         else
940                 PTHREAD_LIBS=""
941                 AC_MSG_RESULT([no libpthread is found])
942         fi
943         AC_SUBST(PTHREAD_LIBS)
944 else
945         AC_MSG_RESULT([no (disabled explicitly)])
946         ENABLE_LIBPTHREAD="no"
947 fi
948 AC_SUBST(ENABLE_LIBPTHREAD)
949
950
951 ])
952
953 #
954 # LIBCFS_CONDITIONALS
955 #
956 # AM_CONDITOINAL defines for lnet
957 #
958 AC_DEFUN([LIBCFS_CONDITIONALS],
959 [
960 ])
961
962 #
963 # LIBCFS_CONFIG_FILES
964 #
965 # files that should be generated with AC_OUTPUT
966 #
967 AC_DEFUN([LIBCFS_CONFIG_FILES],
968 [AC_CONFIG_FILES([
969 libcfs/Kernelenv
970 libcfs/Makefile
971 libcfs/autoMakefile
972 libcfs/autoconf/Makefile
973 libcfs/include/Makefile
974 libcfs/include/libcfs/Makefile
975 libcfs/include/libcfs/linux/Makefile
976 libcfs/include/libcfs/posix/Makefile
977 libcfs/include/libcfs/util/Makefile
978 libcfs/libcfs/Makefile
979 libcfs/libcfs/autoMakefile
980 libcfs/libcfs/linux/Makefile
981 libcfs/libcfs/posix/Makefile
982 libcfs/libcfs/util/Makefile
983 libcfs/include/libcfs/darwin/Makefile
984 libcfs/libcfs/darwin/Makefile
985 ])
986 ])