1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see [sun.com URL with a
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef __LIBCFS_LINUX_LIBCFS_H__
38 #define __LIBCFS_LINUX_LIBCFS_H__
40 #ifndef __LIBCFS_LIBCFS_H__
41 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
44 #ifdef HAVE_ASM_TYPES_H
45 #include <asm/types.h>
47 #include <libcfs/types.h>
51 #include <libcfs/linux/linux-time.h>
52 #include <libcfs/linux/linux-mem.h>
53 #include <libcfs/linux/linux-prim.h>
54 #include <libcfs/linux/linux-lock.h>
55 #include <libcfs/linux/linux-fs.h>
56 #include <libcfs/linux/linux-tcpip.h>
60 # include <linux/types.h>
61 # include <linux/time.h>
62 # include <asm/timex.h>
64 # include <sys/types.h>
65 # include <sys/time.h>
66 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
67 typedef unsigned long long cycles_t;
71 /* Userpace byte flipping */
73 # include <byteswap.h>
74 # define __swab16(x) bswap_16(x)
75 # define __swab32(x) bswap_32(x)
76 # define __swab64(x) bswap_64(x)
77 # define __swab16s(x) do {*(x) = bswap_16(*(x));} while (0)
78 # define __swab32s(x) do {*(x) = bswap_32(*(x));} while (0)
79 # define __swab64s(x) do {*(x) = bswap_64(*(x));} while (0)
80 # if __BYTE_ORDER == __LITTLE_ENDIAN
81 # define le16_to_cpu(x) (x)
82 # define cpu_to_le16(x) (x)
83 # define le32_to_cpu(x) (x)
84 # define cpu_to_le32(x) (x)
85 # define le64_to_cpu(x) (x)
86 # define cpu_to_le64(x) (x)
88 # define be16_to_cpu(x) bswap_16(x)
89 # define cpu_to_be16(x) bswap_16(x)
90 # define be32_to_cpu(x) bswap_32(x)
91 # define cpu_to_be32(x) bswap_32(x)
92 # define be64_to_cpu(x) bswap_64(x)
93 # define cpu_to_be64(x) bswap_64(x)
96 # if __BYTE_ORDER == __BIG_ENDIAN
97 # define le16_to_cpu(x) bswap_16(x)
98 # define cpu_to_le16(x) bswap_16(x)
99 # define le32_to_cpu(x) bswap_32(x)
100 # define cpu_to_le32(x) bswap_32(x)
101 # define le64_to_cpu(x) bswap_64(x)
102 # define cpu_to_le64(x) bswap_64(x)
104 # define be16_to_cpu(x) (x)
105 # define cpu_to_be16(x) (x)
106 # define be32_to_cpu(x) (x)
107 # define cpu_to_be32(x) (x)
108 # define be64_to_cpu(x) (x)
109 # define cpu_to_be64(x) (x)
112 # error "Unknown byte order"
113 # endif /* __BIG_ENDIAN */
114 # endif /* __LITTLE_ENDIAN */
115 #endif /* ! __KERNEL__ */
117 struct ptldebug_header {
129 } __attribute__((packed));
132 # include <linux/sched.h> /* THREAD_SIZE */
134 # ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */
135 # define THREAD_SIZE 8192
139 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
141 #if defined(__KERNEL__) && !defined(__x86_64__)
143 # define CDEBUG_STACK() (THREAD_SIZE - \
144 ((unsigned long)__builtin_dwarf_cfa() & \
147 # define CDEBUG_STACK() (THREAD_SIZE - \
148 ((unsigned long)__builtin_frame_address(0) & \
150 # endif /* __ia64__ */
152 #define __CHECK_STACK(file, func, line) \
154 unsigned int _stack = CDEBUG_STACK(); \
156 if (_stack > 3*THREAD_SIZE/4 && _stack > libcfs_stack) { \
157 libcfs_stack = _stack; \
158 libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_WARNING, \
160 "maximum lustre stack %lu\n", _stack); \
164 #define CHECK_STACK() __CHECK_STACK(__FILE__, __func__, __LINE__)
165 #else /* !__KERNEL__ */
166 #define __CHECK_STACK(X, Y, Z) do { } while(0)
167 #define CHECK_STACK() do { } while(0)
168 #define CDEBUG_STACK() (0L)
169 #endif /* __KERNEL__ */
172 #define LUSTRE_LNET_PID 12345
174 #define ENTRY_NESTING_SUPPORT (1)
175 #define ENTRY_NESTING do {;} while (0)
176 #define EXIT_NESTING do {;} while (0)
177 #define __current_nesting_level() (0)
180 * Platform specific declarations for cfs_curproc API (libcfs/curproc.h)
182 * Implementation is in linux-curproc.c
184 #define CFS_CURPROC_COMM_MAX (sizeof ((struct task_struct *)0)->comm)
186 #if defined(__KERNEL__)
187 #include <linux/capability.h>
188 typedef kernel_cap_t cfs_kernel_cap_t;
190 typedef __u32 cfs_kernel_cap_t;
193 #if defined(__KERNEL__)
195 * No stack-back-tracing in Linux for now.
197 struct cfs_stack_trace {
200 #ifndef WITH_WATCHDOG
201 #define WITH_WATCHDOG
206 #endif /* _LINUX_LIBCFS_H */