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.

190 lines
7.0 KiB

  1. `**********************************************************************`
  2. `* This is an include template file for tracewpp preprocessor. *`
  3. `* *`
  4. `* Copyright 1999-2000 Microsoft Corporation. All Rights Reserved. *`
  5. `**********************************************************************`
  6. // template `TemplateFile`
  7. // expects:
  8. // WPP_THIS_FILE defined (see header.tpl)
  9. // WPP_LOGGER_ARG defined
  10. // WPP_GET_LOGGER defined
  11. // WPP_ENABLED() defined
  12. #ifndef NO_CHECK_FOR_NULL_STRING
  13. #ifndef WPP_CHECK_FOR_NULL_STRING
  14. #define WPP_CHECK_FOR_NULL_STRING 1
  15. #endif
  16. #endif
  17. #define WPP_EVAL(_value_) _value_
  18. #define WPP_(Id) WPP_EVAL(WPP_) ## WPP_EVAL(Id) ## WPP_EVAL(_) ## WPP_EVAL(WPP_THIS_FILE) ## WPP_EVAL(__LINE__)
  19. #if !defined(WPP_INLINE)
  20. # define WPP_INLINE __inline
  21. #endif
  22. #if !defined(WPP_NO_ANNOTATIONS)
  23. #if !defined(WPP_ANSI_ANNOTATION)
  24. `FORALL Msg IN Messages`
  25. # define WPP_ANNOTATE_`Msg.Name` __annotation(L"TMF:", L"`Msg.Guid` `CurrentDir` // SRC=`SourceFile.Name` MJ=`ENV MAJORCOMP` MN=`ENV MINORCOMP`", L"#typev `Msg.Name` `Msg.MsgNo` \"`Msg.Text`\" // `Msg.Indent` `Msg.GooPairs`", L"{"`FORALL Arg IN Msg.Arguments`, L"`Arg.Name`, `Arg.MofType` -- `Arg.No`" `ENDFOR Arg`, L"}")
  26. `ENDFOR`
  27. #else
  28. `FORALL Msg IN Messages`
  29. # define WPP_ANNOTATE_`Msg.Name` __annotation("TMF:", "`Msg.Guid` `CurrentDir` // SRC=`SourceFile.Name` MJ=`ENV MAJORCOMP` MN=`ENV MINORCOMP`", "#typev `Msg.Name` `Msg.MsgNo` \"`Msg.Text`\" // `Msg.Indent` `Msg.GooPairs`", "{"`FORALL Arg IN Msg.Arguments`, "`Arg.Name`, `Arg.MofType` -- `Arg.No`" `ENDFOR Arg`, "}")
  30. `ENDFOR`
  31. #endif
  32. # define WPP_ANNOTATE WPP_(ANNOTATE),
  33. #else
  34. # define WPP_ANNOTATE
  35. #endif
  36. #if `TraceGuids.Count`
  37. static const GUID WPP_LOCAL_TraceGuids[] = {`FORALL Guid IN TraceGuids` `Guid.Struct`, `ENDFOR`};
  38. #endif
  39. #if !defined(WPP_TRACE_OPTIONS)
  40. enum {WPP_TRACE_OPTIONS = TRACE_MESSAGE_SEQUENCE | TRACE_MESSAGE_GUID
  41. | TRACE_MESSAGE_SYSTEMINFO | TRACE_MESSAGE_TIMESTAMP };
  42. #endif
  43. #if !defined(WPP_LOGPAIR)
  44. # define WPP_LOGPAIR(_Size, _Addr) (_Addr),((SIZE_T)_Size),
  45. #endif
  46. #define WPP_LOGTYPEVAL(_Type, _Value) WPP_LOGPAIR(sizeof(_Type), &(_Value))
  47. #define WPP_LOGTYPEPTR(_Value) WPP_LOGPAIR(sizeof(*(_Value)), (_Value))
  48. // Marshalling macros.
  49. #if !defined(WPP_LOGASTR)
  50. # if !defined(WPP_CHECK_FOR_NULL_STRING)
  51. # define WPP_LOGASTR(_value) WPP_LOGPAIR(strlen(_value) + 1, _value )
  52. # else
  53. # define WPP_LOGASTR(_value) WPP_LOGPAIR( (_value)?strlen(_value) + 1:5, (_value)?(_value):"NULL" )
  54. # endif
  55. #endif
  56. #if !defined(WPP_LOGWSTR)
  57. # if !defined(WPP_CHECK_FOR_NULL_STRING)
  58. # define WPP_LOGWSTR(_value) WPP_LOGPAIR( (wcslen(_value)+1) * sizeof(WCHAR), _value)
  59. # else
  60. # define WPP_LOGWSTR(_value) WPP_LOGPAIR( (_value)?(wcslen(_value) + 1)* sizeof(WCHAR):5 * sizeof(WCHAR), (_value)?(_value):L"NULL")
  61. # endif
  62. #endif
  63. #if !defined(WPP_LOGPGUID)
  64. # define WPP_LOGPGUID(_value) WPP_LOGPAIR( sizeof(GUID), (_value) )
  65. #endif
  66. #if !defined(WPP_LOGPSID)
  67. # if !defined(WPP_CHECK_FOR_NULL_STRING)
  68. # define WPP_LOGPSID(_value) WPP_LOGPAIR( GetLengthSid(_value), (_value) )
  69. # else
  70. # define WPP_LOGPSID(_value) WPP_LOGPAIR( (_value)? (IsValidSid(_value)? \
  71. GetLengthSid(_value):5):5, \
  72. (_value)? (IsValidSid(_value)?\
  73. (_value):"NULL"):"NULL")
  74. #endif
  75. #endif
  76. #if !defined(WPP_LOGCSTR)
  77. # define WPP_LOGCSTR(_x) \
  78. WPP_LOGPAIR( sizeof((_x).Length), &(_x).Length ) WPP_LOGPAIR( (_x).Length, (_x).Buffer )
  79. #endif
  80. #if !defined(WPP_LOGUSTR)
  81. # define WPP_LOGUSTR(_x) \
  82. WPP_LOGPAIR( sizeof((_x).Length), &(_x).Length ) WPP_LOGPAIR( (_x).Length, (_x).Buffer )
  83. #endif
  84. #if !defined(WPP_LOGPUSTR)
  85. #if !defined(WPP_CHECK_FOR_NULL_STRING)
  86. # define WPP_LOGPUSTR(_x) WPP_LOGUSTR(*(_x))
  87. #else
  88. # define WPP_LOGPUSTR(_x) WPP_LOGPAIR( (_x)?sizeof((*(_x)).Length):sizeof((USHORT)0), (_x)? &(*(_x)).Length:L"NULL")\
  89. WPP_LOGPAIR( (_x)?(*(_x)).Length:5*sizeof(WCHAR), (_x)?(*(_x)).Buffer:L"NULL")
  90. #endif
  91. #endif
  92. #if !defined(WPP_LOGPCSTR)
  93. #if !defined(WPP_CHECK_FOR_NULL_STRING)
  94. # define WPP_LOGPCSTR(_x) WPP_LOGCSTR(*(_x))
  95. #else
  96. # define WPP_LOGPCSTR(_x) WPP_LOGPAIR( (_x)?sizeof((*(_x)).Length):sizeof((USHORT)0), (_x)? &(*(_x)).Length:L"NULL")\
  97. WPP_LOGPAIR( (_x)?(*(_x)).Length:5, (_x)?((const char *)(*(_x)).Buffer):"NULL")
  98. #endif
  99. #endif
  100. #if !defined(WPP_LOGSTDSTR)
  101. #define WPP_LOGSTDSTR(_value) WPP_LOGPAIR( (_value).size()+1, (_value).c_str() )
  102. #endif
  103. `FORALL i IN TypeSigSet WHERE !UnsafeArgs`
  104. WPP_INLINE void WPP_SF_`i.Name`(WPP_LOGGER_ARG unsigned short id, LPCGUID TraceGuid`i.Arguments`)
  105. { WPP_TRACE(WPP_GET_LOGGER, WPP_TRACE_OPTIONS, (LPGUID)TraceGuid, id, `i.LogArgs` 0); }
  106. `ENDFOR`
  107. `FORALL i IN TypeSigSet WHERE UnsafeArgs`
  108. WPP_INLINE void WPP_SF_`i.Name`(WPP_LOGGER_ARG unsigned short id, LPCGUID TraceGuid, ...) {
  109. va_list ap; va_start(ap, TraceGuid); UNREFERENCED_PARAMETER(ap);
  110. {
  111. `i.DeclVars`
  112. WPP_TRACE(WPP_GET_LOGGER, WPP_TRACE_OPTIONS, (LPGUID)TraceGuid, id, `i.LogArgs` 0);
  113. }
  114. }
  115. `ENDFOR`
  116. #ifdef WPP_DEBUG
  117. `FORALL i IN Messages WHERE !MsgArgs`
  118. #define WPP_CALL_`i.Name`(`i.FixedArgs``i.MacroArgs`) ((`i.MsgVal`WPP`i.GooId`_ENABLED(`i.GooVals`)?WPP_SF_`i.TypeSig`(WPP`i.GooId`_LOGGER(`i.GooVals`) `i.MsgNo`,WPP_LOCAL_TraceGuids+0`i.MacroExprs`),1:0) \
  119. , WPP_DEBUG((`i.MacroArgs`)))
  120. `ENDFOR`
  121. #else
  122. `FORALL i IN Messages WHERE !MsgArgs`
  123. #define WPP_CALL_`i.Name`(`i.FixedArgs``i.MacroArgs`) (`i.MsgVal`WPP`i.GooId`_ENABLED(`i.GooVals`)?WPP_SF_`i.TypeSig`(WPP`i.GooId`_LOGGER(`i.GooVals`) `i.MsgNo`,WPP_LOCAL_TraceGuids+0`i.MacroExprs`),1:0)
  124. `ENDFOR`
  125. #endif
  126. // NoMsgArgs
  127. `FORALL f IN Funcs WHERE !DoubleP && !MsgArgs`
  128. #undef `f.Name`
  129. #define `f.Name` WPP_ANNOTATE WPP_(CALL)
  130. `ENDFOR`
  131. `FORALL f IN Funcs WHERE DoubleP && !MsgArgs`
  132. #undef `f.Name`
  133. #define `f.Name`(ARGS) WPP_ANNOTATE WPP_(CALL) ARGS
  134. `ENDFOR`
  135. // MsgArgs
  136. `FORALL f IN Funcs WHERE MsgArgs`
  137. #undef `f.Name`
  138. #define `f.Name`(`f.FixedArgs` MSGARGS) WPP_ANNOTATE WPP_(CALL)(`f.FixedArgs` MSGARGS)
  139. `ENDFOR`
  140. #ifdef WPP_DEBUG
  141. `FORALL i IN Messages WHERE MsgArgs`
  142. #define WPP_CALL_`i.Name`(`i.FixedArgs` MSGARGS) ((WPP`i.GooId`_ENABLED(`i.GooVals`)?WPP_SF_`i.TypeSig`(WPP`i.GooId`_LOGGER(`i.GooVals`) `i.MsgNo`,WPP_LOCAL_TraceGuids+0 WPP_R`i.ReorderSig` MSGARGS),1:0) \
  143. , WPP_DEBUG((MSGARGS)))
  144. `ENDFOR`
  145. #else
  146. `FORALL i IN Messages WHERE MsgArgs`
  147. #define WPP_CALL_`i.Name`(`i.FixedArgs` MSGARGS) (WPP`i.GooId`_ENABLED(`i.GooVals`)?WPP_SF_`i.TypeSig`(WPP`i.GooId`_LOGGER(`i.GooVals`) `i.MsgNo`,WPP_LOCAL_TraceGuids+0 WPP_R`i.ReorderSig` MSGARGS),1:0)
  148. `ENDFOR`
  149. #endif
  150. `FORALL r IN Reorder`
  151. #define WPP_R`r.Name`(`r.Arguments`) `r.Permutation`
  152. `ENDFOR`
  153. /// more stuff