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.

85 lines
1.9 KiB

  1. #pragma once
  2. /*-----------------------------------------------------------------------------
  3. Fusion Thread Local Storage (aka Per Thread Data)
  4. ----------------------------------------------------------------------------*/
  5. #include "EnumBitOperations.h"
  6. // #include "FusionDequeLinkage.h"
  7. #define FUSION_EVENT_LOG_FLAGS_DISABLE (0x00000001)
  8. #ifndef INITIALIZE_CRITICAL_SECTION_AND_SPIN_COUNT_ALLOCATE_NOW
  9. #define INITIALIZE_CRITICAL_SECTION_AND_SPIN_COUNT_ALLOCATE_NOW ( 0x80000000 )
  10. #endif
  11. class CFusionPerThreadData;
  12. BOOL
  13. FusionpPerThreadDataMain(
  14. HINSTANCE hInst,
  15. DWORD dwReason
  16. );
  17. enum EFusionpTls
  18. {
  19. eFusionpTlsCreate = 1 << 0,
  20. eFusionpTlsCanScrambleLastError = 1 << 1
  21. };
  22. ENUM_BIT_OPERATIONS(EFusionpTls)
  23. CFusionPerThreadData *
  24. FusionpGetPerThreadData(
  25. EFusionpTls = static_cast<EFusionpTls>(0)
  26. );
  27. enum EFusionSetTls
  28. {
  29. eFusionpTlsSetDefaultValue,
  30. eFusionpTlsSetReplaceExisting = 1,
  31. eFusionpTlsSetIfNull = 2
  32. };
  33. //
  34. // This function preserves last error and does not ever set it.
  35. CFusionPerThreadData *
  36. FusionpSetPerThreadData(
  37. CFusionPerThreadData *pThreadData,
  38. EFusionSetTls = eFusionpTlsSetDefaultValue
  39. );
  40. VOID
  41. FusionpClearPerThreadData(
  42. VOID
  43. );
  44. class CFusionPerThreadData
  45. {
  46. public:
  47. CFusionPerThreadData()
  48. :
  49. m_dwLastParseError(0),
  50. m_dwEventLoggingFlags(0)
  51. {
  52. }
  53. DWORD m_dwLastParseError;
  54. DWORD m_dwEventLoggingFlags;
  55. // add any additional per sxs thread data here
  56. // so we only ever consume one tls entry
  57. //
  58. // Move (a pointer to) this to the TEB in the future.
  59. LIST_ENTRY m_Linkage;
  60. //
  61. // Callback from the CDeque::Clear function - Calls the function
  62. // to clear this thread's data, which has the side-effect of
  63. // deleting the object.
  64. //
  65. inline VOID DeleteSelf() { ::FusionpClearPerThreadData(); }
  66. };