1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 #ifndef __LIBCFS_LINUX_LIBCFS_H__
5 #define __LIBCFS_LINUX_LIBCFS_H__
7 #ifndef __LIBCFS_LIBCFS_H__
8 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
12 #include <libcfs/linux/linux-mem.h>
13 #include <libcfs/linux/linux-time.h>
14 #include <libcfs/linux/linux-prim.h>
15 #include <libcfs/linux/linux-lock.h>
16 #include <libcfs/linux/linux-fs.h>
17 #include <libcfs/linux/linux-tcpip.h>
19 #ifdef HAVE_ASM_TYPES_H
20 #include <asm/types.h>
22 #include <libcfs/types.h>
27 # include <linux/types.h>
28 # include <linux/time.h>
29 # include <asm/timex.h>
31 # include <sys/types.h>
32 # include <sys/time.h>
33 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
34 typedef unsigned long long cycles_t;
38 /* Userpace byte flipping */
40 # include <byteswap.h>
41 # define __swab16(x) bswap_16(x)
42 # define __swab32(x) bswap_32(x)
43 # define __swab64(x) bswap_64(x)
44 # define __swab16s(x) do {*(x) = bswap_16(*(x));} while (0)
45 # define __swab32s(x) do {*(x) = bswap_32(*(x));} while (0)
46 # define __swab64s(x) do {*(x) = bswap_64(*(x));} while (0)
47 # if __BYTE_ORDER == __LITTLE_ENDIAN
48 # define le16_to_cpu(x) (x)
49 # define cpu_to_le16(x) (x)
50 # define le32_to_cpu(x) (x)
51 # define cpu_to_le32(x) (x)
52 # define le64_to_cpu(x) (x)
53 # define cpu_to_le64(x) (x)
55 # if __BYTE_ORDER == __BIG_ENDIAN
56 # define le16_to_cpu(x) bswap_16(x)
57 # define cpu_to_le16(x) bswap_16(x)
58 # define le32_to_cpu(x) bswap_32(x)
59 # define cpu_to_le32(x) bswap_32(x)
60 # define le64_to_cpu(x) bswap_64(x)
61 # define cpu_to_le64(x) bswap_64(x)
63 # error "Unknown byte order"
64 # endif /* __BIG_ENDIAN */
65 # endif /* __LITTLE_ENDIAN */
66 #endif /* ! __KERNEL__ */
68 struct ptldebug_header {
80 } __attribute__((packed));
83 # include <linux/sched.h> /* THREAD_SIZE */
85 # ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
86 # define THREAD_SIZE 8192
90 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
92 #if defined(__KERNEL__) && !defined(__x86_64__)
94 # define CDEBUG_STACK() (THREAD_SIZE - \
95 ((unsigned long)__builtin_dwarf_cfa() & \
98 # define CDEBUG_STACK() (THREAD_SIZE - \
99 ((unsigned long)__builtin_frame_address(0) & \
101 # endif /* __ia64__ */
103 #define __CHECK_STACK(file, func, line) \
105 unsigned long _stack = CDEBUG_STACK(); \
107 if (_stack > 3*THREAD_SIZE/4 && _stack > libcfs_stack) { \
108 libcfs_stack = _stack; \
109 libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_WARNING, \
111 "maximum lustre stack %lu\n", _stack); \
115 #define CHECK_STACK() __CHECK_STACK(__FILE__, __func__, __LINE__)
116 #else /* !__KERNEL__ */
117 #define __CHECK_STACK(X, Y, Z) do { } while(0)
118 #define CHECK_STACK() do { } while(0)
119 #define CDEBUG_STACK() (0L)
120 #endif /* __KERNEL__ */
123 #define LUSTRE_LNET_PID 12345
125 #define ENTRY_NESTING_SUPPORT (1)
126 #define ENTRY_NESTING do {;} while (0)
127 #define EXIT_NESTING do {;} while (0)
128 #define __current_nesting_level() (0)
131 * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
133 * Implementation is in linux-curproc.c
135 #define CFS_CURPROC_COMM_MAX (sizeof ((struct task_struct *)0)->comm)
137 #if defined(__KERNEL__)
138 #include <linux/capability.h>
139 typedef kernel_cap_t cfs_kernel_cap_t;
141 typedef __u32 cfs_kernel_cap_t;
144 #if defined(__KERNEL__)
146 * No stack-back-tracing in Linux for now.
148 struct cfs_stack_trace {
151 #ifndef WITH_WATCHDOG
152 #define WITH_WATCHDOG
157 #endif /* _LINUX_LIBCFS_H */