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
11 #ifdef HAVE_ASM_TYPES_H
12 #include <asm/types.h>
14 #include <libcfs/types.h>
18 #include <libcfs/linux/linux-time.h>
19 #include <libcfs/linux/linux-mem.h>
20 #include <libcfs/linux/linux-prim.h>
21 #include <libcfs/linux/linux-lock.h>
22 #include <libcfs/linux/linux-fs.h>
23 #include <libcfs/linux/linux-tcpip.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 # define be16_to_cpu(x) bswap_16(x)
56 # define cpu_to_be16(x) bswap_16(x)
57 # define be32_to_cpu(x) bswap_32(x)
58 # define cpu_to_be32(x) bswap_32(x)
59 # define be64_to_cpu(x) bswap_64(x)
60 # define cpu_to_be64(x) bswap_64(x)
63 # if __BYTE_ORDER == __BIG_ENDIAN
64 # define le16_to_cpu(x) bswap_16(x)
65 # define cpu_to_le16(x) bswap_16(x)
66 # define le32_to_cpu(x) bswap_32(x)
67 # define cpu_to_le32(x) bswap_32(x)
68 # define le64_to_cpu(x) bswap_64(x)
69 # define cpu_to_le64(x) bswap_64(x)
71 # define be16_to_cpu(x) (x)
72 # define cpu_to_be16(x) (x)
73 # define be32_to_cpu(x) (x)
74 # define cpu_to_be32(x) (x)
75 # define be64_to_cpu(x) (x)
76 # define cpu_to_be64(x) (x)
79 # error "Unknown byte order"
80 # endif /* __BIG_ENDIAN */
81 # endif /* __LITTLE_ENDIAN */
82 #endif /* ! __KERNEL__ */
84 struct ptldebug_header {
96 } __attribute__((packed));
99 # include <linux/sched.h> /* THREAD_SIZE */
101 # ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
102 # define THREAD_SIZE 8192
106 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
108 #if defined(__KERNEL__) && !defined(__x86_64__)
110 # define CDEBUG_STACK() (THREAD_SIZE - \
111 ((unsigned long)__builtin_dwarf_cfa() & \
114 # define CDEBUG_STACK() (THREAD_SIZE - \
115 ((unsigned long)__builtin_frame_address(0) & \
117 # endif /* __ia64__ */
119 #define __CHECK_STACK(file, func, line) \
121 unsigned long _stack = CDEBUG_STACK(); \
123 if (_stack > 3*THREAD_SIZE/4 && _stack > libcfs_stack) { \
124 libcfs_stack = _stack; \
125 libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_WARNING, \
127 "maximum lustre stack %lu\n", _stack); \
131 #define CHECK_STACK() __CHECK_STACK(__FILE__, __func__, __LINE__)
132 #else /* !__KERNEL__ */
133 #define __CHECK_STACK(X, Y, Z) do { } while(0)
134 #define CHECK_STACK() do { } while(0)
135 #define CDEBUG_STACK() (0L)
136 #endif /* __KERNEL__ */
139 #define LUSTRE_LNET_PID 12345
141 #define ENTRY_NESTING_SUPPORT (1)
142 #define ENTRY_NESTING do {;} while (0)
143 #define EXIT_NESTING do {;} while (0)
144 #define __current_nesting_level() (0)
147 * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
149 * Implementation is in linux-curproc.c
151 #define CFS_CURPROC_COMM_MAX (sizeof ((struct task_struct *)0)->comm)
153 #if defined(__KERNEL__)
154 #include <linux/capability.h>
155 typedef kernel_cap_t cfs_kernel_cap_t;
157 typedef __u32 cfs_kernel_cap_t;
160 #if defined(__KERNEL__)
162 * No stack-back-tracing in Linux for now.
164 struct cfs_stack_trace {
167 #ifndef WITH_WATCHDOG
168 #define WITH_WATCHDOG
173 #endif /* _LINUX_LIBCFS_H */