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.

109 lines
4.4 KiB

  1. /***************************************************************************
  2. Name : MYSCHED.H
  3. Comment :
  4. Functions: (see Prototypes just below)
  5. Copyright (c) Microsoft Corp. 1991, 1992, 1993
  6. Revision Log
  7. Date Name Description
  8. -------- ----- ---------------------------------------------------------
  9. ***************************************************************************/
  10. ///////////////////// Tasking/Sleep/Timing options ///////////////////
  11. //
  12. // There are 4 options available
  13. // (1) Tasking/Sleeping thru DLLSCHED: #defs reqd are !TSK !TMR and !IFK
  14. // (2) Tasking/Sleeping thru an IFKERNEL BGproc: #defs reqd TSK IFK and !TMR
  15. // (3) Tasking thru WIN32: #defs reqd WIN32 !IFK !TMR
  16. //
  17. // In this file we define the macros for each of these options
  18. /////////////////////////////////////// Tasking/Sleep/Timing options ///////
  19. #define ACTIVESLICE 50
  20. // MySetSlice(x) is defined seperately in BGT30.C and FCOM.C
  21. // MySleep() is defined seperately in BGT30.C and FCOM.C
  22. # ifdef NCR
  23. # define FComCriticalNeg(pTG, x) FComCritical(pTG, x)
  24. # else // NCR
  25. # define FComCriticalNeg(pTG, x)
  26. # endif
  27. # ifdef PCR
  28. # define EnterPageCrit() FComCritical(pTG, TRUE)
  29. # define ExitPageCrit() FComCritical(pTG, FALSE)
  30. # else
  31. # define EnterPageCrit(pTG)
  32. # define ExitPageCrit(pTG)
  33. # endif
  34. # define EnterFileT30CritSection() // replaced by Mutex stuff in EFAXRUN.H
  35. # define ExitFileT30CritSection() // replaced by Mutex stuff in EFAXRUN.H
  36. // In WIN32 LibMain is called for all sorts of reasons. WEP is not
  37. // directly called. WIN32 version of these macros calls WEP at the
  38. // right time. Also LibMain or WEP do not need to be fixed
  39. #define MYWEP \
  40. int _export CALLBACK WEP(int type)
  41. #define MYLIBMAIN \
  42. int _export CALLBACK WEP(int type); \
  43. BOOL _export WINAPI LibMain(HINSTANCE hinst, DWORD dwReason, LPVOID lpv)
  44. #define MYLIBSTARTUP(_szName) \
  45. DEBUGMSG(1, (SZMOD "LibMain called reason=%lu.P=0x%lx.T=0x%lx\r\n",\
  46. (unsigned long) dwReason,\
  47. (unsigned long) GetCurrentProcessId(),\
  48. (unsigned long) GetCurrentThreadId()\
  49. )); \
  50. if(dwReason==DLL_THREAD_ATTACH || dwReason==DLL_THREAD_DETACH) \
  51. return TRUE; \
  52. if(dwReason==DLL_PROCESS_DETACH) \
  53. return WEP(0); \
  54. if(dwReason==DLL_PROCESS_ATTACH && (_szName)) \
  55. { \
  56. HMODULE hM = GetModuleHandle(_szName); \
  57. if (hM) DisableThreadLibraryCalls(hM); \
  58. }
  59. #define MYLIBSHUTDOWN
  60. #ifdef DEBUG
  61. # ifndef WIN32
  62. # define SLIPMULT 2
  63. # define SLIPDIV 2
  64. # else
  65. # define SLIPMULT 1
  66. # define SLIPDIV 4
  67. # endif
  68. # define BEFORESLEEP DWORD t1, t2; t1=GetTickCount();
  69. # define AFTERSLEEP(x) t2=GetTickCount(); \
  70. if((t2-t1) > (((x)*SLIPMULT)+((x)/SLIPDIV))) \
  71. DEBUGMSG(1, ("!!!SLEPT %ld. Wanted only %d!!!\r\n", (t2-t1), (x)));
  72. #else
  73. # define BEFORESLEEP
  74. # define AFTERSLEEP(x)
  75. #endif
  76. // Note: timeBeginPeriod,timeEndPeriod require mmsystem.h
  77. // which is not included in windows.h if WIN32_LEAN_AND_MEAN is defined.
  78. # define MY_TWIDDLETHUMBS(ulTime) \
  79. { \
  80. BEFORESLEEP \
  81. Sleep(ulTime); \
  82. AFTERSLEEP(ulTime) \
  83. }