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