Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. NameP.h
  5. Abstract:
  6. This module defines private part of the File System Rtl component, used by
  7. name.c.
  8. Author:
  9. Gary Kimura [GaryKi] 30-Jul-1990
  10. Revision History:
  11. [t-HeathH] 17-Jul-1994 Moved this header file into the ftphelp porject, to
  12. maintain a single source base for Chicago and NT.
  13. --*/
  14. #ifndef _NAMEP_H_INCLUDED_
  15. #define _NAMEP_H_INCLUDED_
  16. #if defined(__cplusplus)
  17. extern "C" {
  18. #endif
  19. //#include "ftp.h"
  20. #include <name.h>
  21. //
  22. // The global MyFsRtl debug level variable, its values are:
  23. //
  24. // 0x00000000 Always gets printed (used when about to bug check)
  25. //
  26. // 0x00000001 Error conditions
  27. // 0x00000002 Debug hooks
  28. // 0x00000004
  29. // 0x00000008
  30. //
  31. // 0x00000010
  32. // 0x00000020
  33. // 0x00000040
  34. // 0x00000080
  35. //
  36. // 0x00000100
  37. // 0x00000200
  38. // 0x00000400
  39. // 0x00000800
  40. //
  41. // 0x00001000
  42. // 0x00002000
  43. // 0x00004000
  44. // 0x00008000
  45. //
  46. // 0x00010000
  47. // 0x00020000
  48. // 0x00040000
  49. // 0x00080000
  50. //
  51. // 0x00100000
  52. // 0x00200000
  53. // 0x00400000
  54. // 0x00800000
  55. //
  56. // 0x01000000
  57. // 0x02000000
  58. // 0x04000000 NotifyChange routines
  59. // 0x08000000 Oplock routines
  60. //
  61. // 0x10000000 Name routines
  62. // 0x20000000 FileLock routines
  63. // 0x40000000 Vmcb routines
  64. // 0x80000000 Mcb routines
  65. //
  66. //
  67. // Debug trace support
  68. //
  69. #ifdef FSRTLDBG
  70. extern LONG MyFsRtlDebugTraceLevel;
  71. extern LONG MyFsRtlDebugTraceIndent;
  72. #define DebugTrace(INDENT,LEVEL,X,Y) { \
  73. LONG _i; \
  74. if (((LEVEL) == 0) || (MyFsRtlDebugTraceLevel & (LEVEL))) { \
  75. _i = (ULONG)PsGetCurrentThread(); \
  76. DbgPrint("%08lx:",_i); \
  77. if ((INDENT) < 0) { \
  78. MyFsRtlDebugTraceIndent += (INDENT); \
  79. } \
  80. if (MyFsRtlDebugTraceIndent < 0) { \
  81. MyFsRtlDebugTraceIndent = 0; \
  82. } \
  83. for (_i=0; _i<MyFsRtlDebugTraceIndent; _i+=1) { \
  84. DbgPrint(" "); \
  85. } \
  86. DbgPrint(X,Y); \
  87. if ((INDENT) > 0) { \
  88. MyFsRtlDebugTraceIndent += (INDENT); \
  89. } \
  90. } \
  91. }
  92. #define DebugDump(STR,LEVEL,PTR) { \
  93. ULONG _i; \
  94. VOID MyFsRtlDump(); \
  95. if (((LEVEL) == 0) || (MyFsRtlDebugTraceLevel & (LEVEL))) { \
  96. _i = (ULONG)PsGetCurrentThread(); \
  97. DbgPrint("%08lx:",_i); \
  98. DbgPrint(STR); \
  99. if (PTR != NULL) {MyFsRtlDump(PTR);} \
  100. DbgBreakPoint(); \
  101. } \
  102. }
  103. #else
  104. #define DebugTrace(INDENT,LEVEL,X,Y) {NOTHING;}
  105. #define DebugDump(STR,LEVEL,PTR) {NOTHING;}
  106. #endif // FSRTLDBG
  107. //
  108. // This macro returns TRUE if a flag in a set of flags is on and FALSE
  109. // otherwise
  110. //
  111. #define FlagOn(Flags,SingleFlag) ((Flags) & (SingleFlag))
  112. #define BooleanFlagOn(Flags,SingleFlag) ((BOOLEAN)(((Flags) & (SingleFlag)) != 0))
  113. //
  114. // This macro takes a pointer (or ulong) and returns its rounded up word
  115. // value
  116. //
  117. #define WordAlign(Ptr) ( \
  118. ((((ULONG)(Ptr)) + 1) & 0xfffffffe) \
  119. )
  120. //
  121. // This macro takes a pointer (or ulong) and returns its rounded up longword
  122. // value
  123. //
  124. #define LongAlign(Ptr) ( \
  125. ((((ULONG)(Ptr)) + 3) & 0xfffffffc) \
  126. )
  127. //
  128. // This macro takes a pointer (or ulong) and returns its rounded up quadword
  129. // value
  130. //
  131. #define QuadAlign(Ptr) ( \
  132. ((((ULONG)(Ptr)) + 7) & 0xfffffff8) \
  133. )
  134. //
  135. // This macro takes a ulong and returns its value rounded up to a sector
  136. // boundary
  137. //
  138. #define SectorAlign(Ptr) ( \
  139. ((((ULONG)(Ptr)) + 511) & 0xfffffe00) \
  140. )
  141. //
  142. // This macro takes a number of bytes and returns the number of sectors
  143. // required to contain that many bytes, i.e., it sector aligns and divides
  144. // by the size of a sector.
  145. //
  146. #define SectorsFromBytes(bytes) ( \
  147. ((bytes) + 511) / 512 \
  148. )
  149. //
  150. // This macro takes a number of sectors and returns the number of bytes
  151. // contained in that many sectors.
  152. //
  153. #define BytesFromSectors(sectors) ( \
  154. (sectors) * 512 \
  155. )
  156. //
  157. // The following types and macros are used to help unpack the packed and
  158. // misaligned fields found in the Bios parameter block
  159. //
  160. typedef union _UCHAR1 {
  161. UCHAR Uchar[1];
  162. UCHAR ForceAlignment;
  163. } UCHAR1, *PUCHAR1;
  164. typedef union _UCHAR2 {
  165. UCHAR Uchar[2];
  166. USHORT ForceAlignment;
  167. } UCHAR2, *PUCHAR2;
  168. typedef union _UCHAR4 {
  169. UCHAR Uchar[4];
  170. ULONG ForceAlignment;
  171. } UCHAR4, *PUCHAR4;
  172. //
  173. // This macro copies an unaligned src byte to an aligned dst byte
  174. //
  175. #define CopyUchar1(Dst,Src) { \
  176. *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
  177. }
  178. //
  179. // This macro copies an unaligned src word to an aligned dst word
  180. //
  181. #define CopyUchar2(Dst,Src) { \
  182. *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
  183. }
  184. //
  185. // This macro copies an unaligned src longword to an aligned dsr longword
  186. //
  187. #define CopyUchar4(Dst,Src) { \
  188. *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
  189. }
  190. //
  191. // The following macros are used to establish the semantics needed
  192. // to do a return from within a try-finally clause. As a rule every
  193. // try clause must end with a label call try_exit. For example,
  194. //
  195. // try {
  196. // :
  197. // :
  198. //
  199. // try_exit: NOTHING;
  200. // } finally {
  201. //
  202. // :
  203. // :
  204. // }
  205. //
  206. // Every return statement executed inside of a try clause should use the
  207. // try_return macro. If the compiler fully supports the try-finally construct
  208. // then the macro should be
  209. //
  210. // #define try_return(S) { return(S); }
  211. //
  212. // If the compiler does not support the try-finally construct then the macro
  213. // should be
  214. //
  215. // #define try_return(S) { S; goto try_exit; }
  216. //
  217. #define try_return(S) { S; goto try_exit; }
  218. #if defined(__cplusplus)
  219. }
  220. #endif
  221. #endif // _FSRTLP_