initc.pp 827 B

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