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 #include <libcfs/linux/linux-mem.h>
12 #include <libcfs/linux/linux-time.h>
13 #include <libcfs/linux/linux-prim.h>
14 #include <libcfs/linux/linux-lock.h>
15 #include <libcfs/linux/linux-fs.h>
17 #ifdef HAVE_ASM_TYPES_H
18 #include <asm/types.h>
25 # include <linux/types.h>
26 # include <linux/time.h>
27 # include <asm/timex.h>
29 # include <sys/types.h>
30 # include <sys/time.h>
31 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
32 typedef unsigned long long cycles_t;
36 /* Userpace byte flipping */
38 # include <byteswap.h>
39 # define __swab16(x) bswap_16(x)
40 # define __swab32(x) bswap_32(x)
41 # define __swab64(x) bswap_64(x)
42 # define __swab16s(x) do {*(x) = bswap_16(*(x));} while (0)
43 # define __swab32s(x) do {*(x) = bswap_32(*(x));} while (0)
44 # define __swab64s(x) do {*(x) = bswap_64(*(x));} while (0)
45 # if __BYTE_ORDER == __LITTLE_ENDIAN
46 # define le16_to_cpu(x) (x)
47 # define cpu_to_le16(x) (x)
48 # define le32_to_cpu(x) (x)
49 # define cpu_to_le32(x) (x)
50 # define le64_to_cpu(x) (x)
51 # define cpu_to_le64(x) (x)
53 # if __BYTE_ORDER == __BIG_ENDIAN
54 # define le16_to_cpu(x) bswap_16(x)
55 # define cpu_to_le16(x) bswap_16(x)
56 # define le32_to_cpu(x) bswap_32(x)
57 # define cpu_to_le32(x) bswap_32(x)
58 # define le64_to_cpu(x) bswap_64(x)
59 # define cpu_to_le64(x) bswap_64(x)
61 # error "Unknown byte order"
62 # endif /* __BIG_ENDIAN */
63 # endif /* __LITTLE_ENDIAN */
64 #endif /* ! __KERNEL__ */
66 struct ptldebug_header {
78 } __attribute__((packed));
81 # include <linux/sched.h> /* THREAD_SIZE */
83 # ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
84 # define THREAD_SIZE 8192
88 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
92 # define CDEBUG_STACK (THREAD_SIZE - \
93 ((unsigned long)__builtin_dwarf_cfa() & \
96 # define CDEBUG_STACK (THREAD_SIZE - \
97 ((unsigned long)__builtin_frame_address(0) & \
99 # endif /* __ia64__ */
101 #define CHECK_STACK(stack) \
103 if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) { \
104 portals_debug_msg(DEBUG_SUBSYSTEM, D_WARNING, \
105 __FILE__, __FUNCTION__, __LINE__, \
106 (stack),"maximum lustre stack %u\n",\
107 portal_stack = (stack)); \
111 #else /* !__KERNEL__ */
112 #define CHECK_STACK(stack) do { } while(0)
113 #define CDEBUG_STACK (0L)
114 #endif /* __KERNEL__ */
119 * 1) ptl_pid_t in cray portals is only 16 bits, not 32 bits, therefore this
122 * 2) the implementation of ernal in cray portals further restricts the pid
123 * space that may be used to 0 <= pid <= 255 (an 8 bit value). Returns
124 * an error at nal init time for any pid outside this range. Other nals
125 * in cray portals don't have this restriction.
127 #define LUSTRE_PTL_PID 9
129 #define LUSTRE_PTL_PID 12345
132 #define ENTRY_NESTING_SUPPORT (0)
133 #define ENTRY_NESTING do {;} while (0)
134 #define EXIT_NESTING do {;} while (0)
135 #define __current_nesting_level() (0)
138 * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
140 * Implementation is in linux-curproc.c
142 #define CFS_CURPROC_COMM_MAX (sizeof ((struct task_struct *)0)->comm)
144 #if defined(__KERNEL__)
145 #include <linux/capability.h>
146 typedef kernel_cap_t cfs_kernel_cap_t;
148 typedef __u32 cfs_kernel_cap_t;
151 #endif /* _LINUX_LIBCFS_H */