Whamcloud - gitweb
7f894b8b3660b9168833a8e142e4902ab827d76d
[fs/lustre-release.git] / libcfs / include / libcfs / winnt / libcfs.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
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.
11  *
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).
17  *
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
20  * copy of GPLv2].
21  *
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
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef __LIBCFS_WINNT_LIBCFS_H__
38 #define __LIBCFS_WINNT_LIBCFS_H__
39
40 #ifndef __LIBCFS_LIBCFS_H__
41 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
42 #endif
43
44 /* workgroud for VC compiler */
45 #ifndef __FUNCTION__
46 #define __FUNCTION__ "generic"
47 #endif
48
49 #include <libcfs/winnt/winnt-types.h>
50 #include <libcfs/portals_utils.h>
51 #include <libcfs/winnt/winnt-time.h>
52 #include <libcfs/winnt/winnt-lock.h>
53 #include <libcfs/winnt/winnt-mem.h>
54 #include <libcfs/winnt/winnt-prim.h>
55 #include <libcfs/winnt/winnt-fs.h>
56 #include <libcfs/winnt/winnt-tcpip.h>
57
58 struct ptldebug_header {
59         __u32 ph_len;
60         __u32 ph_flags;
61         __u32 ph_subsys;
62         __u32 ph_mask;
63         __u32 ph_cpu_id;
64         __u32 ph_sec;
65         __u64 ph_usec;
66         __u32 ph_stack;
67         __u32 ph_pid;
68         __u32 ph_extern_pid;
69         __u32 ph_line_num;
70 } __attribute__((packed));
71
72 #ifdef __KERNEL__
73
74 enum {
75         /* if you change this, update darwin-util.c:cfs_stack_trace_fill() */
76         CFS_STACK_TRACE_DEPTH = 16
77 };
78
79 struct cfs_stack_trace {
80         void *frame[CFS_STACK_TRACE_DEPTH];
81 };
82
83 static inline __u32 query_stack_size()
84 {
85     ULONG   LowLimit, HighLimit;
86
87     IoGetStackLimits(&LowLimit, &HighLimit);
88     ASSERT(HighLimit > LowLimit);
89
90     return (__u32) (HighLimit - LowLimit);
91 }
92 #else
93 static inline __u32 query_stack_size()
94 {
95    return 4096;
96 }
97 #endif
98
99
100 #ifndef THREAD_SIZE
101 # define THREAD_SIZE query_stack_size()
102 #endif
103
104 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
105
106 #ifdef __KERNEL__
107 # ifdef  __ia64__
108 #  define CDEBUG_STACK() (THREAD_SIZE -                         \
109                           ((ulong_ptr)__builtin_dwarf_cfa() &   \
110                            (THREAD_SIZE - 1)))
111 # else
112 #  define CDEBUG_STACK (IoGetRemainingStackSize())
113 #  error "This doesn't seem right; CDEBUG_STACK should grow with the stack"
114 # endif /* __ia64__ */
115
116 #define CHECK_STACK()                                                   \
117 do {                                                                    \
118         unsigned long _stack = CDEBUG_STACK();                          \
119                                                                         \
120         if (_stack > 3*THREAD_SIZE/4 && _stack > libcfs_stack) {        \
121                 libcfs_stack = _stack;                                  \
122                 libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_WARNING,      \
123                                  __FILE__, NULL, __LINE__,              \
124                                  "maximum lustre stack %lu\n", _stack); \
125         }                                                               \
126 } while (0)
127 #else /* !__KERNEL__ */
128 #define CHECK_STACK() do { } while(0)
129 #define CDEBUG_STACK() (0L)
130 #endif /* __KERNEL__ */
131
132 /* initial pid  */
133 #define LUSTRE_LNET_PID          12345
134
135 #define ENTRY_NESTING_SUPPORT (0)
136 #define ENTRY_NESTING   do {;} while (0)
137 #define EXIT_NESTING   do {;} while (0)
138 #define __current_nesting_level() (0)
139
140 #endif /* _WINNT_LIBCFS_H */