From c2b91fcf4028626d8778dfdb01d0824182de5e93 Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 28 Sep 1999 22:53:26 +0000 Subject: [PATCH] + InitC unit --- rtl/win32/Makefile | 9 +++++++-- rtl/win32/initc.pp | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 rtl/win32/initc.pp diff --git a/rtl/win32/Makefile b/rtl/win32/Makefile index 7ffe86b22f..b299e6086a 100644 --- a/rtl/win32/Makefile +++ b/rtl/win32/Makefile @@ -67,7 +67,7 @@ LOADEROBJECTS=wprt0 wdllprt0 # Unit Objects UNITOBJECTS=$(SYSTEMUNIT) objpas strings \ windows ole2 opengl32 winsock \ - sockets \ + sockets initc \ dos crt objects \ sysutils typinfo math \ cpu mmx getopts heaptrc @@ -216,6 +216,8 @@ winsock$(PPUEXT) : winsock.pp windows$(PPUEXT) $(SYSTEMPPU) sockets$(PPUEXT) : sockets.pp windows$(PPUEXT) winsock$(PPUEXT) $(SYSTEMPPU) \ $(INC)/sockets.inc $(INC)/socketsh.inc +initc$(PPUEXT) : initc.pp $(SYSTEMPPU) + # # TP7 Compatible RTL Units # @@ -260,7 +262,10 @@ heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMPPU) # # $Log$ -# Revision 1.36 1999-09-16 13:38:07 peter +# Revision 1.37 1999-09-28 22:53:27 pierre +# + InitC unit +# +# Revision 1.36 1999/09/16 13:38:07 peter # * windows unit include moved to wininc/ # # diff --git a/rtl/win32/initc.pp b/rtl/win32/initc.pp new file mode 100644 index 0000000000..cfc873f7d6 --- /dev/null +++ b/rtl/win32/initc.pp @@ -0,0 +1,40 @@ +unit initc; + +interface + + {$LINKLIB cygwin} + +{ this unit is just ment to run + startup code to get C code to work correctly PM } + + +implementation + +procedure cygwin_crt0(p : pointer);cdecl;external; + +{ +procedure do_global_dtors;cdecl;external; + this does not work because + do_global_dtors is a static C function PM + it is inserted into the atexit chain, + but how do we call this from FPC ??? + it seems to be done in exit function + but that one ends with _exit that is system dependent !! } + +{ avoid loading of cygwin _exit code + so that exit returns } +procedure _exit(status : longint);cdecl; +begin +end; + +procedure C_exit(status : longint);popstack;external name '_exit'; + +initialization +cygwin_crt0(nil); + +finalization +{ should we pass exit code ? + its apparently only used by _exit so it doesn't matter PM } +C_exit(0); + +end.