sysinitcyg.pp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 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. {$asmmode att}
  13. unit sysinitcyg;
  14. interface
  15. implementation
  16. procedure Cygwin_crt0(p : pointer);cdecl;external name 'cygwin_crt0';
  17. procedure __main;cdecl;external name '__main';
  18. procedure asm_exit;stdcall;public name 'asm_exit';
  19. begin
  20. end;
  21. {$i sysinit.inc}
  22. procedure CMainEXE;cdecl;
  23. begin
  24. asm
  25. subl $0x8,%esp
  26. andl $0xfffffff0,%esp
  27. end;
  28. __main;
  29. SetupEntryInformation;
  30. EXE_Entry(EntryInformation);
  31. end;
  32. procedure CMainDLL;cdecl;
  33. begin
  34. asm
  35. subl $0x8,%esp
  36. andl $0xfffffff0,%esp
  37. end;
  38. __main;
  39. SetupEntryInformation;
  40. DLL_Entry(EntryInformation);
  41. end;
  42. procedure _FPC_mainCRTStartup;stdcall;public name '_mainCRTStartup';
  43. begin
  44. IsConsole:=true;
  45. asm
  46. subl $0x8,%esp
  47. andl $0xfffffff0,%esp
  48. end;
  49. { it seems cygwin messed around with the console mode so we've to
  50. store the startup console mode before cygwin can do anything (FK)
  51. }
  52. GetConsoleMode(GetStdHandle((Std_Input_Handle)),StartupConsoleMode);
  53. Cygwin_crt0(@CMainEXE);
  54. end;
  55. procedure _FPC_WinMainCRTStartup;stdcall;public name '_WinMainCRTStartup';
  56. begin
  57. IsConsole:=false;
  58. asm
  59. subl $0x8,%esp
  60. andl $0xfffffff0,%esp
  61. end;
  62. Cygwin_crt0(@CMainEXE);
  63. end;
  64. procedure _FPC_DLLMainCRTStartup(_hinstance,_dllreason,_dllparam:longint);stdcall;public name '_DLLMainCRTStartup';
  65. begin
  66. IsConsole:=true;
  67. sysinstance:=_hinstance;
  68. dllreason:=_dllreason;
  69. dllparam:=_dllparam;
  70. asm
  71. subl $0x8,%esp
  72. andl $0xfffffff0,%esp
  73. end;
  74. Cygwin_crt0(@CMainDLL);
  75. end;
  76. procedure _FPC_DLLWinMainCRTStartup(_hinstance,_dllreason,_dllparam:longint);stdcall;public name '_DLLWinMainCRTStartup';
  77. begin
  78. IsConsole:=false;
  79. sysinstance:=_hinstance;
  80. dllreason:=_dllreason;
  81. dllparam:=_dllparam;
  82. asm
  83. subl $0x8,%esp
  84. andl $0xfffffff0,%esp
  85. end;
  86. Cygwin_crt0(@CMainDLL);
  87. end;
  88. end.