Source code of Windows XP (NT5)
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.

165 lines
5.7 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. #define WPP_EVAL(_value_) _value_
  13. #define WPP_(Id) WPP_EVAL(WPP_) ## WPP_EVAL(Id) ## WPP_EVAL(_) ## WPP_EVAL(WPP_THIS_FILE) ## WPP_EVAL(__LINE__)
  14. #if !defined(WPP_INLINE)
  15. # define WPP_INLINE __inline
  16. #endif
  17. #if !defined(WPP_NO_ANNOTATIONS)
  18. #if !defined(WPP_ANSI_ANNOTATION)
  19. `FORALL Msg IN Messages`
  20. # 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"}")
  21. `ENDFOR`
  22. #else
  23. `FORALL Msg IN Messages`
  24. # 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`, "}")
  25. `ENDFOR`
  26. #endif
  27. # define WPP_ANNOTATE WPP_(ANNOTATE),
  28. #else
  29. # define WPP_ANNOTATE
  30. #endif
  31. #if `TraceGuids.Count`
  32. static const GUID WPP_LOCAL_TraceGuids[] = {`FORALL Guid IN TraceGuids` `Guid.Struct`, `ENDFOR`};
  33. #endif
  34. #if !defined(WPP_TRACE_OPTIONS)
  35. enum {WPP_TRACE_OPTIONS = TRACE_MESSAGE_SEQUENCE | TRACE_MESSAGE_GUID
  36. | TRACE_MESSAGE_SYSTEMINFO | TRACE_MESSAGE_TIMESTAMP };
  37. #endif
  38. #if !defined(WPP_LOGPAIR)
  39. # define WPP_LOGPAIR(_Size, _Addr) (_Addr),(_Size),
  40. #endif
  41. #define WPP_LOGTYPEVAL(_Type, _Value) WPP_LOGPAIR(sizeof(_Type), &(_Value))
  42. #define WPP_LOGTYPEPTR(_Value) WPP_LOGPAIR(sizeof(*(_Value)), (_Value))
  43. // Marshalling macros.
  44. #if !defined(WPP_LOGASTR)
  45. # if !defined(WPP_CHECK_FOR_NULL_STRING)
  46. # define WPP_LOGASTR(_value) WPP_LOGPAIR(strlen(_value) + 1, _value )
  47. # else
  48. # define WPP_LOGASTR(_value) WPP_LOGPAIR( (_value)?strlen(_value) + 1:5, (_value)?(_value):"NULL" )
  49. # endif
  50. #endif
  51. #if !defined(WPP_LOGWSTR)
  52. # if !defined(WPP_CHECK_FOR_NULL_STRING)
  53. # define WPP_LOGWSTR(_value) WPP_LOGPAIR( (wcslen(_value)+1) * sizeof(WCHAR), _value)
  54. # else
  55. # define WPP_LOGWSTR(_value) WPP_LOGPAIR( (_value)?(wcslen(_value) + 1)* sizeof(WCHAR):5 * sizeof(WCHAR), (_value)?(_value):L"NULL")
  56. # endif
  57. #endif
  58. #if !defined(WPP_LOGPGUID)
  59. # define WPP_LOGPGUID(_value) WPP_LOGPAIR( sizeof(GUID), (_value) )
  60. #endif
  61. #if !defined(WPP_LOGPSID)
  62. # define WPP_LOGPSID(_value) WPP_LOGPAIR( GetLengthSid(_value), (_value) )
  63. #endif
  64. #if !defined(WPP_LOGCSTR)
  65. # define WPP_LOGCSTR(_x) \
  66. WPP_LOGPAIR( sizeof((_x).Length), &(_x).Length ) WPP_LOGPAIR( (_x).Length, (_x).Buffer )
  67. #endif
  68. #if !defined(WPP_LOGUSTR)
  69. # define WPP_LOGUSTR(_x) \
  70. WPP_LOGPAIR( sizeof((_x).Length), &(_x).Length ) WPP_LOGPAIR( (_x).Length, (_x).Buffer )
  71. #endif
  72. #if !defined(WPP_LOGPUSTR)
  73. # define WPP_LOGPUSTR(_x) WPP_LOGUSTR(*(_x))
  74. #endif
  75. #if !defined(WPP_LOGPCSTR)
  76. # define WPP_LOGPCSTR(_x) WPP_LOGCSTR(*(_x))
  77. #endif
  78. #if !defined(WPP_LOGSTDSTR)
  79. #define WPP_LOGSTDSTR(_value) WPP_LOGPAIR( (_value).size()+1, (_value).c_str() )
  80. #endif
  81. `FORALL i IN TypeSigSet WHERE !UnsafeArgs`
  82. WPP_INLINE void WPP_SF_`i.Name`(WPP_LOGGER_ARG unsigned short id, LPCGUID TraceGuid`i.Arguments`)
  83. { WPP_TRACE(WPP_GET_LOGGER, WPP_TRACE_OPTIONS, (LPGUID)TraceGuid, id, `i.LogArgs` 0); }
  84. `ENDFOR`
  85. `FORALL i IN TypeSigSet WHERE UnsafeArgs`
  86. WPP_INLINE void WPP_SF_`i.Name`(WPP_LOGGER_ARG unsigned short id, LPCGUID TraceGuid, ...) {
  87. va_list ap; va_start(ap, TraceGuid); UNREFERENCED_PARAMETER(ap);
  88. {
  89. `i.DeclVars`
  90. WPP_TRACE(WPP_GET_LOGGER, WPP_TRACE_OPTIONS, (LPGUID)TraceGuid, id, `i.LogArgs` 0);
  91. }
  92. }
  93. `ENDFOR`
  94. #ifdef WPP_DEBUG
  95. `FORALL i IN Messages WHERE !MsgArgs`
  96. #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) \
  97. , WPP_DEBUG((`i.MacroArgs`)))
  98. `ENDFOR`
  99. #else
  100. `FORALL i IN Messages WHERE !MsgArgs`
  101. #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)
  102. `ENDFOR`
  103. #endif
  104. // NoMsgArgs
  105. `FORALL f IN Funcs WHERE !DoubleP && !MsgArgs`
  106. #undef `f.Name`
  107. #define `f.Name` WPP_ANNOTATE WPP_(CALL)
  108. `ENDFOR`
  109. `FORALL f IN Funcs WHERE DoubleP && !MsgArgs`
  110. #undef `f.Name`
  111. #define `f.Name`(ARGS) WPP_ANNOTATE WPP_(CALL) ARGS
  112. `ENDFOR`
  113. // MsgArgs
  114. `FORALL f IN Funcs WHERE MsgArgs`
  115. #undef `f.Name`
  116. #define `f.Name`(`f.FixedArgs` MSGARGS) WPP_ANNOTATE WPP_(CALL)(`f.FixedArgs` MSGARGS)
  117. `ENDFOR`
  118. #ifdef WPP_DEBUG
  119. `FORALL i IN Messages WHERE MsgArgs`
  120. #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) \
  121. , WPP_DEBUG((MSGARGS)))
  122. `ENDFOR`
  123. #else
  124. `FORALL i IN Messages WHERE MsgArgs`
  125. #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)
  126. `ENDFOR`
  127. #endif
  128. `FORALL r IN Reorder`
  129. #define WPP_R`r.Name`(`r.Arguments`) `r.Permutation`
  130. `ENDFOR`
  131. /// more stuff