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