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