Browse Source

* wcygprt is now used for cygwin (libc) linking, initc contains only cerrno

peter 21 years ago
parent
commit
294c68257b
4 changed files with 110 additions and 109 deletions
  1. 14 13
      rtl/win32/Makefile
  2. 2 1
      rtl/win32/Makefile.fpc
  3. 10 95
      rtl/win32/initc.pp
  4. 84 0
      rtl/win32/wcygprt0.as

+ 14 - 13
rtl/win32/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 1.1 [2004/10/30]
+# Don't edit, this file is generated by FPCMake Version 1.1 [2004/11/03]
 #
 default: all
 MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx palmos macos darwin emx watcom morphos netwlibc
@@ -242,7 +242,7 @@ GRAPHDIR=$(INC)/graph
 include $(WININC)/makefile.inc
 WINDOWS_SOURCE_FILES=$(addprefix $(WININC)/,$(addsuffix .inc,$(WINDOWS_FILES)))
 override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings lineinfo heaptrc matrix windows ole2 activex shellapi shlobj winsock initc cmem dos crt objects graph messages sysutils classes typinfo math varutils variants cpu mmx charset ucomplex getopts wincrt winmouse winevent sockets printer dynlibs signals video mouse keyboard types comobj dateutils rtlconst sysconst winsysut strutils convutils
-override TARGET_LOADERS+=wprt0 wdllprt0 gprt0
+override TARGET_LOADERS+=wprt0 wdllprt0 gprt0 wcygprt0
 override TARGET_RSTS+=math varutils typinfo variants classes dateutils sysconst
 override INSTALL_FPCPACKAGE=y
 override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC)
@@ -744,7 +744,7 @@ ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(ECHO),)
 ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(ECHO),)
-ECHO= __missing_command__
+ECHO= __missing_command_ECHO
 else
 ECHO:=$(firstword $(ECHO))
 endif
@@ -758,7 +758,7 @@ DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(DATE),)
 DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(DATE),)
-DATE= __missing_command__
+DATE= __missing_command_DATE
 else
 DATE:=$(firstword $(DATE))
 endif
@@ -772,7 +772,7 @@ GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(GINSTALL),)
 GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(GINSTALL),)
-GINSTALL= __missing_command__
+GINSTALL= __missing_command_GINSTALL
 else
 GINSTALL:=$(firstword $(GINSTALL))
 endif
@@ -784,7 +784,7 @@ export GINSTALL
 ifndef CPPROG
 CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(CPPROG),)
-CPPROG= __missing_command__
+CPPROG= __missing_command_CPPROG
 else
 CPPROG:=$(firstword $(CPPROG))
 endif
@@ -793,7 +793,7 @@ export CPPROG
 ifndef RMPROG
 RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(RMPROG),)
-RMPROG= __missing_command__
+RMPROG= __missing_command_RMPROG
 else
 RMPROG:=$(firstword $(RMPROG))
 endif
@@ -802,7 +802,7 @@ export RMPROG
 ifndef MVPROG
 MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(MVPROG),)
-MVPROG= __missing_command__
+MVPROG= __missing_command_MVPROG
 else
 MVPROG:=$(firstword $(MVPROG))
 endif
@@ -813,7 +813,7 @@ MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(MKDIRPROG),)
 MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(MKDIRPROG),)
-MKDIRPROG= __missing_command__
+MKDIRPROG= __missing_command_MKDIRPROG
 else
 MKDIRPROG:=$(firstword $(MKDIRPROG))
 endif
@@ -868,7 +868,7 @@ export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
 ifndef PPUMOVE
 PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(PPUMOVE),)
-PPUMOVE= __missing_command__
+PPUMOVE= __missing_command_PPUMOVE
 else
 PPUMOVE:=$(firstword $(PPUMOVE))
 endif
@@ -877,7 +877,7 @@ export PPUMOVE
 ifndef FPCMAKE
 FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(FPCMAKE),)
-FPCMAKE= __missing_command__
+FPCMAKE= __missing_command_FPCMAKE
 else
 FPCMAKE:=$(firstword $(FPCMAKE))
 endif
@@ -886,7 +886,7 @@ export FPCMAKE
 ifndef ZIPPROG
 ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(ZIPPROG),)
-ZIPPROG= __missing_command__
+ZIPPROG= __missing_command_ZIPPROG
 else
 ZIPPROG:=$(firstword $(ZIPPROG))
 endif
@@ -895,7 +895,7 @@ export ZIPPROG
 ifndef TARPROG
 TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
 ifeq ($(TARPROG),)
-TARPROG= __missing_command__
+TARPROG= __missing_command_TARPROG
 else
 TARPROG:=$(firstword $(TARPROG))
 endif
@@ -1463,6 +1463,7 @@ wprt0$(OEXT) : $(PRT0).as
 	$(AS) -o $(UNITTARGETDIRPREFIX)wprt0$(OEXT) $(PRT0).as
 gprt0$(OEXT) : gprt0.as
 wdllprt0$(OEXT) : wdllprt0.as
+wcygprt0$(OEXT) : wcygprt0.as
 $(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp win32.inc $(SYSDEPS)
 	$(COMPILER) -Us -Sg $(SYSTEMUNIT).pp
 systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)

+ 2 - 1
rtl/win32/Makefile.fpc

@@ -6,7 +6,7 @@
 main=rtl
 
 [target]
-loaders=wprt0 wdllprt0 gprt0
+loaders=wprt0 wdllprt0 gprt0 wcygprt0
 units=$(SYSTEMUNIT) systhrds objpas macpas strings \
       lineinfo heaptrc matrix \
       windows ole2 activex shellapi shlobj winsock initc cmem \
@@ -97,6 +97,7 @@ gprt0$(OEXT) : gprt0.as
 
 wdllprt0$(OEXT) : wdllprt0.as
 
+wcygprt0$(OEXT) : wcygprt0.as
 
 #
 # System Units (System, Objpas, Strings)

+ 10 - 95
rtl/win32/initc.pp

@@ -5,14 +5,12 @@ unit initc;
 
 interface
 
-type libcint   = longint;
-     plibcint = ^libcint;
+{$LINKLIB cygwin}
+{$linklib kernel32}
 
- {$LINKLIB cygwin}
- {$linklib kernel32}
-
-{ this unit is just ment to run
-  startup code to get C code to work correctly PM }
+type
+ libcint   = longint;
+ plibcint = ^libcint;
 
 function fpgetCerrno:libcint;
 procedure fpsetCerrno(err:libcint);
@@ -21,12 +19,8 @@ procedure fpsetCerrno(err:libcint);
 property cerrno:libcint read fpgetCerrno write fpsetcerrno;
 {$endif}
 
-implementation
-
-uses
-  windows;
 
-{$i textrec.inc}
+implementation
 
 function geterrnolocation: Plibcint; cdecl;external name '___errno';
 
@@ -40,92 +34,13 @@ begin
   geterrnolocation^:=err;
 end;
 
-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
-  apparently this is not enough anymore
-  use longjmp instead PM }
-var
-  entryjmpbuf,exitjmpbuf : jmp_buf;
-const
-  exitjmpbufset : boolean = false;
-
-procedure _exit(status : longint);cdecl;
-begin
-  if exitjmpbufset then
-    longjmp(exitjmpbuf,1)
-  else
-    RunError(status);
-end;
-
-procedure C_exit(status : longint);cdecl;external name '_exit';
-
-const
-   STD_INPUT_HANDLE = $fffffff6;
-   STD_OUTPUT_HANDLE = $fffffff5;
-   STD_ERROR_HANDLE = $fffffff4;
-
-
-procedure UpdateStdHandle(var t:TextRec;var stdHandle:Thandle;newHandle:Thandle);
-{ Check if the stdHandle is the same as the one in the TextRec, then
-  also update the TextRec }
-begin
-  if t.Handle=stdHandle then
-   t.Handle:=newHandle;
-  stdHandle:=newHandle;
-end;
-
-function entry  : longint;
-begin
-  longjmp(entryjmpbuf,1);
-  entry:=0;
-end;
-var
-  ConsoleMode: DWORD;
-  ConsoleModeValid : boolean;
-
-initialization
-  ConsoleModeValid:=GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), @ConsoleMode);
-  if setjmp(entryjmpbuf)=0 then
-    begin
-      cygwin_crt0(@entry);
-    end;
-
-  if ConsoleModeValid then
-    SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ConsoleMode);
-{ Reinitialize std handles that can be changed }
-  UpdateStdHandle(TextRec(Input),StdInputHandle,GetStdHandle(STD_INPUT_HANDLE));
-  UpdateStdHandle(TextRec(Output),StdOutputHandle,GetStdHandle(STD_OUTPUT_HANDLE));
-  UpdateStdHandle(TextRec(ErrOutput),StdErrorHandle,GetStdHandle(STD_ERROR_HANDLE));
-  TextRec(StdOut).Handle:=StdOutputHandle;
-  TextRec(StdErr).Handle:=StdErrorHandle;
-
-finalization
-{ should we pass exit code ?
-  its apparently only used by _exit so it doesn't matter PM }
-if setjmp(exitjmpbuf)=0 then
-  begin
-    exitjmpbufset:=true;
-    { C_exit(errorcode);
-      this code does not work correctly anymore
-      C function _exit is not called at end of exit function
-      thus the code of exit does not return at all
-      disabled PM }
-  end;
 end.
 {
   $Log$
-  Revision 1.13  2004-11-04 09:32:31  peter
+  Revision 1.14  2004-11-04 17:15:01  peter
+   * wcygprt is now used for cygwin (libc) linking, initc contains only cerrno
+
+  Revision 1.13  2004/11/04 09:32:31  peter
   ErrOutput added
 
   Revision 1.12  2004/09/14 20:08:58  hajny

+ 84 - 0
rtl/win32/wcygprt0.as

@@ -0,0 +1,84 @@
+//Startup code for WIN32 port of Free Pascal
+//Written by P.Ozerski 1998
+// modified by Pierre Muller
+     .text
+     .globl _mainCRTStartup
+_mainCRTStartup:
+     movb   $1,U_SYSTEM_ISCONSOLE
+     jmp    _start
+
+     .globl _WinMainCRTStartup
+_WinMainCRTStartup:
+     movb   $0,U_SYSTEM_ISCONSOLE
+_start:
+     subl   $0x8,%esp
+     andl   $0xfffffff0,%esp
+     push   $_cmain
+     call   _cygwin_crt0
+
+     .globl _cmain
+_cmain:
+     subl   $0x8,%esp
+     andl   $0xfffffff0,%esp
+     call   ___main
+     call   _FPC_EXE_Entry
+     ret
+
+     .globl asm_exit
+asm_exit:
+    pushl   %eax
+    call    exitprocess
+
+.text
+.globl	exitprocess
+exitprocess:
+	jmp	*.L10
+	.balign 4,144
+
+.text
+	.balign 4,144
+
+.section .idata$2
+	.rva	.L7
+	.long	0,0
+	.rva	.L6
+	.rva	.L8
+
+.section .idata$4
+.L7:
+	.rva	.L9
+	.long	0
+
+.section .idata$5
+.L8:
+
+
+.section .idata$5
+.L10:
+	.rva	.L9
+	.long	0
+
+.section .idata$6
+.L9:
+	.short	0
+	.ascii	"ExitProcess\000"
+	.balign 2,0
+
+.section .idata$7
+.L6:
+	.ascii	"kernel32.dll\000"
+
+
+
+// $Log$
+// Revision 1.1  2004-11-04 17:15:01  peter
+//  * wcygprt is now used for cygwin (libc) linking, initc contains only cerrno
+//
+// Revision 1.4  2002/11/30 18:17:35  carl
+//   + profiling support
+//
+// Revision 1.3  2002/07/28 20:43:51  florian
+//   * several fixes for linux/powerpc
+//   * several fixes to MT
+//
+//