sysinitcyg.pp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. {$ifdef FPC_USE_TLS_DIRECTORY}
  31. LinkIn(@tlsdir,@tls_callback_end,@tls_callback);
  32. {$endif}
  33. EXE_Entry(SysInitEntryInformation);
  34. end;
  35. procedure CMainDLL;cdecl;
  36. begin
  37. asm
  38. subl $0x8,%esp
  39. andl $0xfffffff0,%esp
  40. end;
  41. __main;
  42. SetupEntryInformation;
  43. DLL_Entry(SysInitEntryInformation);
  44. end;
  45. procedure _FPC_mainCRTStartup;stdcall;public name '_mainCRTStartup';
  46. begin
  47. IsConsole:=true;
  48. asm
  49. subl $0x8,%esp
  50. andl $0xfffffff0,%esp
  51. end;
  52. { it seems cygwin messed around with the console mode so we've to
  53. store the startup console mode before cygwin can do anything (FK)
  54. }
  55. GetConsoleMode(GetStdHandle((Std_Input_Handle)),StartupConsoleMode);
  56. Cygwin_crt0(@CMainEXE);
  57. end;
  58. procedure _FPC_WinMainCRTStartup;stdcall;public name '_WinMainCRTStartup';
  59. begin
  60. IsConsole:=false;
  61. asm
  62. subl $0x8,%esp
  63. andl $0xfffffff0,%esp
  64. end;
  65. Cygwin_crt0(@CMainEXE);
  66. end;
  67. procedure _FPC_DLLMainCRTStartup(_hinstance : longint;_dllreason : dword;_dllparam:Pointer);stdcall;public name '_DLLMainCRTStartup';
  68. begin
  69. IsConsole:=true;
  70. sysinstance:=_hinstance;
  71. dllreason:=_dllreason;
  72. dllparam:=PtrInt(_dllparam);
  73. asm
  74. subl $0x8,%esp
  75. andl $0xfffffff0,%esp
  76. end;
  77. Cygwin_crt0(@CMainDLL);
  78. end;
  79. procedure _FPC_DLLWinMainCRTStartup(_hinstance : longint;_dllreason : dword;_dllparam:Pointer);stdcall;public name '_DLLWinMainCRTStartup';
  80. begin
  81. IsConsole:=false;
  82. sysinstance:=_hinstance;
  83. dllreason:=_dllreason;
  84. dllparam:=PtrInt(_dllparam);
  85. asm
  86. subl $0x8,%esp
  87. andl $0xfffffff0,%esp
  88. end;
  89. Cygwin_crt0(@CMainDLL);
  90. end;
  91. end.