initc.pp 966 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. unit initc;
  2. interface
  3. { 0.99.12 had a bug that initialization/finalization only worked for
  4. objfpc,delphi mode }
  5. {$ifdef VER0_99_12}
  6. {$mode objfpc}
  7. {$endif}
  8. {$LINKLIB cygwin}
  9. { this unit is just ment to run
  10. startup code to get C code to work correctly PM }
  11. implementation
  12. procedure cygwin_crt0(p : pointer);cdecl;external;
  13. {
  14. procedure do_global_dtors;cdecl;external;
  15. this does not work because
  16. do_global_dtors is a static C function PM
  17. it is inserted into the atexit chain,
  18. but how do we call this from FPC ???
  19. it seems to be done in exit function
  20. but that one ends with _exit that is system dependent !! }
  21. { avoid loading of cygwin _exit code
  22. so that exit returns }
  23. procedure _exit(status : longint);cdecl;
  24. begin
  25. end;
  26. procedure C_exit(status : longint);popstack;external name '_exit';
  27. initialization
  28. cygwin_crt0(nil);
  29. finalization
  30. { should we pass exit code ?
  31. its apparently only used by _exit so it doesn't matter PM }
  32. C_exit(0);
  33. end.