sysinitgprof.pp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2006 by Florian Klaempfl and Pavel Ozerski
  4. member of the Free Pascal development team.
  5. Win32 cygwin profiler startup code
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit sysinitgprof;
  13. interface
  14. implementation
  15. {$linklib gmon}
  16. {$linklib gcc}
  17. {$linklib cygwin}
  18. {$linklib user32}
  19. {$linklib kernel32}
  20. var
  21. SysInstance : Longint;external name '_FPC_SysInstance';
  22. etext : record end;external name 'etext';
  23. monstarted : dword;
  24. procedure EXE_Entry; external name '_FPC_EXE_Entry';
  25. function DLL_Entry : longbool; external name '_FPC_DLL_Entry';
  26. procedure Cygwin_crt0(p : pointer);cdecl;external name 'cygwin_crt0';
  27. procedure __main;cdecl;external name '__main';
  28. procedure monstartup(main,etext : pointer);cdecl;external name 'monstartup';
  29. procedure CMainEXE;cdecl;forward;
  30. procedure CMainDLL;cdecl;forward;
  31. procedure EXEgmon_start;
  32. begin
  33. if monstarted=0 then
  34. begin
  35. inc(monstarted);
  36. monstartup(@CMainExe,@etext);
  37. end;
  38. end;
  39. procedure DLLgmon_start;
  40. begin
  41. if monstarted=0 then
  42. begin
  43. inc(monstarted);
  44. monstartup(@CMainDLL,@etext);
  45. end;
  46. end;
  47. procedure CMainEXE;cdecl;
  48. begin
  49. asm
  50. subl $0x8,%esp
  51. andl $0xfffffff0,%esp
  52. end;
  53. EXEgmon_start;
  54. __main;
  55. EXE_Entry;
  56. end;
  57. procedure CMainDLL;cdecl;
  58. begin
  59. asm
  60. subl $0x8,%esp
  61. andl $0xfffffff0,%esp
  62. end;
  63. DLLgmon_start;
  64. __main;
  65. DLL_Entry;
  66. end;
  67. procedure _FPC_mainCRTStartup;stdcall;public name '_mainCRTStartup';
  68. begin
  69. IsConsole:=true;
  70. asm
  71. subl $0x8,%esp
  72. andl $0xfffffff0,%esp
  73. end;
  74. Cygwin_crt0(@CMainEXE);
  75. end;
  76. procedure _FPC_WinMainCRTStartup;stdcall;public name '_WinMainCRTStartup';
  77. begin
  78. IsConsole:=false;
  79. asm
  80. subl $0x8,%esp
  81. andl $0xfffffff0,%esp
  82. end;
  83. Cygwin_crt0(@CMainEXE);
  84. end;
  85. procedure _FPC_DLLMainCRTStartup(_hinstance,_dllreason,_dllparam:longint);stdcall;public name '_DLLMainCRTStartup';
  86. begin
  87. IsConsole:=true;
  88. sysinstance:=_hinstance;
  89. dllreason:=_dllreason;
  90. dllparam:=_dllparam;
  91. asm
  92. subl $0x8,%esp
  93. andl $0xfffffff0,%esp
  94. end;
  95. Cygwin_crt0(@CMainDLL);
  96. end;
  97. procedure _FPC_DLLWinMainCRTStartup(_hinstance,_dllreason,_dllparam:longint);stdcall;public name '_DLLWinMainCRTStartup';
  98. begin
  99. IsConsole:=false;
  100. sysinstance:=_hinstance;
  101. dllreason:=_dllreason;
  102. dllparam:=_dllparam;
  103. asm
  104. subl $0x8,%esp
  105. andl $0xfffffff0,%esp
  106. end;
  107. Cygwin_crt0(@CMainDLL);
  108. end;
  109. end.