Whamcloud - gitweb
Landing b_hd_newconfig on HEAD
[fs/lustre-release.git] / lnet / include / libcfs / winnt / libcfs.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=4:tabstop=4:
3  *
4  * Copyright (C) 2004 Cluster File Systems, Inc.
5  *
6  * This file is part of Lustre, http://www.lustre.org.
7  *
8  * Lustre is free software; you can redistribute it and/or modify it under the
9  * terms of version 2 of the GNU General Public License as published by the
10  * Free Software Foundation.
11  *
12  * Lustre is distributed in the hope that it will be useful, but WITHOUT ANY
13  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with Lustre; if not, write to the Free Software Foundation, Inc., 675 Mass
19  * Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #ifndef __LIBCFS_WINNT_LIBCFS_H__
24 #define __LIBCFS_WINNT_LIBCFS_H__
25
26 #ifndef __LIBCFS_LIBCFS_H__
27 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
28 #endif
29
30 /* workgroud for VC compiler */
31 #ifndef __FUNCTION__
32 #define __FUNCTION__ "generic"
33 #endif
34
35 #include <libcfs/winnt/winnt-types.h>
36 #include <libcfs/portals_utils.h>
37 #include <libcfs/winnt/winnt-time.h>
38 #include <libcfs/winnt/winnt-lock.h>
39 #include <libcfs/winnt/winnt-mem.h>
40 #include <libcfs/winnt/winnt-prim.h>
41 #include <libcfs/winnt/winnt-fs.h>
42 #include <libcfs/winnt/winnt-tcpip.h>
43
44 struct ptldebug_header {
45         __u32 ph_len;
46         __u32 ph_flags;
47         __u32 ph_subsys;
48         __u32 ph_mask;
49         __u32 ph_cpu_id;
50         __u32 ph_sec;
51         __u64 ph_usec;
52         __u32 ph_stack;
53         __u32 ph_pid;
54         __u32 ph_extern_pid;
55         __u32 ph_line_num;
56 } __attribute__((packed));
57
58 #ifdef __KERNEL__
59
60 enum {
61         /* if you change this, update darwin-util.c:cfs_stack_trace_fill() */
62         CFS_STACK_TRACE_DEPTH = 16
63 };
64
65 struct cfs_stack_trace {
66         void *frame[CFS_STACK_TRACE_DEPTH];
67 };
68
69 static inline __u32 query_stack_size()
70 {
71     ULONG   LowLimit, HighLimit;
72
73     IoGetStackLimits(&LowLimit, &HighLimit);
74     ASSERT(HighLimit > LowLimit);
75
76     return (__u32) (HighLimit - LowLimit);
77 }
78 #else
79 static inline __u32 query_stack_size()
80 {
81    return 4096;
82 }
83 #endif
84
85
86 #ifndef THREAD_SIZE
87 # define THREAD_SIZE query_stack_size()
88 #endif
89
90 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
91
92 #ifdef __KERNEL__
93 # ifdef  __ia64__
94 #  define CDEBUG_STACK() (THREAD_SIZE -                         \
95                           ((ulong_ptr)__builtin_dwarf_cfa() &   \
96                            (THREAD_SIZE - 1)))
97 # else
98 #  define CDEBUG_STACK (IoGetRemainingStackSize())
99 #  error "This doesn't seem right; CDEBUG_STACK should grow with the stack"
100 # endif /* __ia64__ */
101
102 #define CHECK_STACK()                                                   \
103 do {                                                                    \
104         unsigned long _stack = CDEBUG_STACK();                          \
105                                                                         \
106         if (_stack > 3*THREAD_SIZE/4 && _stack > libcfs_stack) {        \
107                 libcfs_stack = _stack;                                  \
108                 libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_WARNING,      \
109                                  __FILE__, NULL, __LINE__,              \
110                                  "maximum lustre stack %lu\n", _stack); \
111         }                                                               \
112 } while (0)
113 #else /* !__KERNEL__ */
114 #define CHECK_STACK() do { } while(0)
115 #define CDEBUG_STACK() (0L)
116 #endif /* __KERNEL__ */
117
118 /* initial pid  */
119 #define LUSTRE_LNET_PID          12345
120
121 #define ENTRY_NESTING_SUPPORT (0)
122 #define ENTRY_NESTING   do {;} while (0)
123 #define EXIT_NESTING   do {;} while (0)
124 #define __current_nesting_level() (0)
125
126 #endif /* _WINNT_LIBCFS_H */