sysinitcyg.pp 3.1 KB

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