Преглед на файлове

* threads for go32v2,os,emx,netware

peter преди 20 години
родител
ревизия
e49fa4bd08
променени са 50 файла, в които са добавени 4924 реда и са изтрити 4669 реда
  1. 66 67
      rtl/emx/Makefile
  2. 2 4
      rtl/emx/Makefile.fpc
  3. 248 0
      rtl/emx/sysdir.inc
  4. 415 0
      rtl/emx/sysfile.inc
  5. 91 0
      rtl/emx/sysheap.inc
  6. 105 0
      rtl/emx/sysos.inc
  7. 47 0
      rtl/emx/sysosh.inc
  8. 10 778
      rtl/emx/system.pas
  9. 20 218
      rtl/emx/systhrd.inc
  10. 66 67
      rtl/go32v2/Makefile
  11. 64 65
      rtl/go32v2/Makefile.fpc
  12. 157 0
      rtl/go32v2/sysdir.inc
  13. 460 0
      rtl/go32v2/sysfile.inc
  14. 70 0
      rtl/go32v2/sysheap.inc
  15. 341 0
      rtl/go32v2/sysos.inc
  16. 39 0
      rtl/go32v2/sysosh.inc
  17. 5 956
      rtl/go32v2/system.pp
  18. 39 0
      rtl/go32v2/systhrd.inc
  19. 0 51
      rtl/go32v2/systhrds.pp
  20. 7 4
      rtl/inc/system.inc
  21. 67 68
      rtl/netware/Makefile
  22. 3 4
      rtl/netware/Makefile.fpc
  23. 5 3
      rtl/netware/classes.pp
  24. 98 0
      rtl/netware/sysdir.inc
  25. 290 0
      rtl/netware/sysfile.inc
  26. 147 0
      rtl/netware/sysheap.inc
  27. 53 0
      rtl/netware/sysos.inc
  28. 53 0
      rtl/netware/sysosh.inc
  29. 5 501
      rtl/netware/system.pp
  30. 19 74
      rtl/netware/systhrd.inc
  31. 68 69
      rtl/netwlibc/Makefile
  32. 5 5
      rtl/netwlibc/Makefile.fpc
  33. 4 2
      rtl/netwlibc/classes.pp
  34. 7 7
      rtl/netwlibc/libc.pp
  35. 98 0
      rtl/netwlibc/sysdir.inc
  36. 414 0
      rtl/netwlibc/sysfile.inc
  37. 156 0
      rtl/netwlibc/sysheap.inc
  38. 55 0
      rtl/netwlibc/sysos.inc
  39. 38 0
      rtl/netwlibc/sysosh.inc
  40. 5 636
      rtl/netwlibc/system.pp
  41. 17 59
      rtl/netwlibc/systhrd.inc
  42. 66 67
      rtl/os2/Makefile
  43. 2 4
      rtl/os2/Makefile.fpc
  44. 157 0
      rtl/os2/sysdir.inc
  45. 273 0
      rtl/os2/sysfile.inc
  46. 175 0
      rtl/os2/sysheap.inc
  47. 316 0
      rtl/os2/sysos.inc
  48. 47 0
      rtl/os2/sysosh.inc
  49. 8 839
      rtl/os2/system.pas
  50. 21 121
      rtl/os2/systhrd.inc

+ 66 - 67
rtl/emx/Makefile

@@ -250,103 +250,103 @@ endif
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil ctypes
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_LOADERS+=prt0 prt1
@@ -448,103 +448,103 @@ ifeq ($(FULL_TARGET),arm-linux)
 override TARGET_LOADERS+=prt0 prt1
 endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
@@ -1964,7 +1964,6 @@ objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
 		   $(SYSTEMUNIT)$(PPUEXT)
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
 ports$(PPUEXT) : ports.pas objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 doscalls$(PPUEXT) : $(OS2INC)/doscalls.pas strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 kbdcalls$(PPUEXT) : $(OS2INC)/kbdcalls.pas $(SYSTEMUNIT)$(PPUEXT)

+ 2 - 4
rtl/emx/Makefile.fpc

@@ -7,7 +7,7 @@ main=rtl
 
 [target]
 loaders=prt0 prt1
-units=$(SYSTEMUNIT) systhrds objpas macpas strings \
+units=$(SYSTEMUNIT) objpas macpas strings \
       ports os2def doscalls moncalls kbdcalls moucalls viocalls \
       pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi \
       dos crt objects printer matrix \
@@ -15,7 +15,7 @@ units=$(SYSTEMUNIT) systhrds objpas macpas strings \
       charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs \
       video mouse keyboard variants types rtlconst sysconst dateutil \
       strutils convutil ctypes
-rsts=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+rsts=math varutils typinfo variants pmhelp classes sysconst dateutil
 
 [require]
 nortl=y
@@ -96,8 +96,6 @@ strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
                    $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
                    $(SYSTEMUNIT)$(PPUEXT)
 
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
-
 #
 # System Dependent Units
 #

+ 248 - 0
rtl/emx/sysdir.inc

@@ -0,0 +1,248 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
+    member of the Free Pascal development team.
+
+    FPC Pascal system unit for the Win32 API.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+{*****************************************************************************
+                           Directory Handling
+*****************************************************************************}
+
+
+procedure dosdir(func:byte;const s:string);
+
+var buffer:array[0..255] of char;
+
+begin
+    move(s[1],buffer,length(s));
+    buffer[length(s)]:=#0;
+    allowslash(Pchar(@buffer));
+    asm
+        leal buffer,%edx
+        movb func,%ah
+        call syscall
+        jnc  .LDOS_DIRS1
+        movw %ax,inoutres
+    .LDOS_DIRS1:
+    end ['eax', 'edx'];
+end;
+
+
+procedure MkDir (const S: string);[IOCHECK];
+
+var buffer:array[0..255] of char;
+    Rc : word;
+
+begin
+  If (s='') or (InOutRes <> 0) then
+   exit;
+ if os_mode = osOs2 then
+    begin
+      move(s[1],buffer,length(s));
+      buffer[length(s)]:=#0;
+      allowslash(Pchar(@buffer));
+      Rc := DosCreateDir(buffer,nil);
+      if Rc <> 0 then
+       begin
+         InOutRes := Rc;
+         Errno2Inoutres;
+       end;
+    end
+  else
+   begin
+     { Under EMX 0.9d DOS this routine call may sometimes fail   }
+     { The syscall documentation indicates clearly that this     }
+     { routine was NOT tested.                                   }
+        DosDir ($39, S);
+end;
+end;
+
+
+procedure rmdir(const s : string);[IOCHECK];
+var buffer:array[0..255] of char;
+    Rc : word;
+begin
+  if (s = '.' ) then
+    InOutRes := 16;
+  If (s='') or (InOutRes <> 0) then
+   exit;
+  if os_mode = osOs2 then
+    begin
+      move(s[1],buffer,length(s));
+      buffer[length(s)]:=#0;
+      allowslash(Pchar(@buffer));
+      Rc := DosDeleteDir(buffer);
+      if Rc <> 0 then
+       begin
+         InOutRes := Rc;
+         Errno2Inoutres;
+       end;
+    end
+  else
+   begin
+     { Under EMX 0.9d DOS this routine call may sometimes fail   }
+     { The syscall documentation indicates clearly that this     }
+     { routine was NOT tested.                                   }
+        DosDir ($3A, S);
+end;
+end;
+
+{$ASMMODE INTEL}
+
+procedure ChDir (const S: string);[IOCheck];
+
+var RC: cardinal;
+    Buffer: array [0..255] of char;
+
+begin
+  If (s='') or (InOutRes <> 0) then
+   exit;
+(* According to EMX documentation, EMX has only one current directory
+   for all processes, so we'll use native calls under OS/2. *)
+            if os_Mode = osOS2 then
+                begin
+                    if (Length (S) >= 2) and (S [2] = ':') then
+                        begin
+                            RC := DosSetDefaultDisk ((Ord (S [1]) and
+                                                             not ($20)) - $40);
+                            if RC <> 0 then
+                                InOutRes := RC
+                            else
+                                if Length (S) > 2 then
+                                    begin
+                                        Move (S [1], Buffer, Length (S));
+                                        Buffer [Length (S)] := #0;
+                                        AllowSlash (PChar (@Buffer));
+                                        RC := DosSetCurrentDir (@Buffer);
+                                        if RC <> 0 then
+                                         begin
+                                            InOutRes := RC;
+                                            Errno2InOutRes;
+                                         end;
+                                    end;
+                        end
+                    else
+                        begin
+                            Move (S [1], Buffer, Length (S));
+                            Buffer [Length (S)] := #0;
+                            AllowSlash (PChar (@Buffer));
+                            RC := DosSetCurrentDir (@Buffer);
+                            if RC <> 0 then
+                             begin
+                                  InOutRes:= RC;
+                                  Errno2InOutRes;
+                             end;
+                        end;
+                end
+            else
+                if (Length (S) >= 2) and (S [2] = ':') then
+                    begin
+                        asm
+                            mov esi, S
+                            mov al, [esi + 1]
+                            and al, not (20h)
+                            sub al, 41h
+                            mov edx, eax
+                            mov ah, 0Eh
+                            call syscall
+                            mov ah, 19h
+                            call syscall
+                            cmp al, dl
+                            jz @LCHDIR
+                            mov InOutRes, 15
+@LCHDIR:
+                        end ['eax','edx','esi'];
+                        if (Length (S) > 2) and (InOutRes <> 0) then
+                            { Under EMX 0.9d DOS this routine may sometime }
+                            { fail or crash the system.                    }
+                            DosDir ($3B, S);
+                    end
+                else
+                    { Under EMX 0.9d DOS this routine may sometime }
+                    { fail or crash the system.                    }
+                    DosDir ($3B, S);
+end;
+
+{$ASMMODE ATT}
+
+procedure GetDir (DriveNr: byte; var Dir: ShortString);
+
+{Written by Michael Van Canneyt.}
+
+var sof:Pchar;
+    i:byte;
+
+begin
+    Dir [4] := #0;
+    { Used in case the specified drive isn't available }
+    sof:=pchar(@dir[4]);
+    { dir[1..3] will contain '[drivenr]:\', but is not }
+    { supplied by DOS, so we let dos string start at   }
+    { dir[4]                                           }
+    { Get dir from drivenr : 0=default, 1=A etc... }
+    asm
+        movb drivenr,%dl
+        movl sof,%esi
+        mov  $0x47,%ah
+        call syscall
+        jnc .LGetDir
+        movw %ax, InOutRes
+.LGetDir:
+    end [ 'eax','edx','esi'];
+    { Now Dir should be filled with directory in ASCIIZ, }
+    { starting from dir[4]                               }
+    dir[0]:=#3;
+    dir[2]:=':';
+    dir[3]:='\';
+    i:=4;
+    {Conversion to Pascal string }
+    while (dir[i]<>#0) do
+        begin
+            { convert path name to DOS }
+            if dir[i]='/' then
+            dir[i]:='\';
+            dir[0]:=char(i);
+            inc(i);
+        end;
+    { upcase the string (FPC function) }
+    if drivenr<>0 then   { Drive was supplied. We know it }
+        dir[1]:=chr(64+drivenr)
+    else
+        begin
+            { We need to get the current drive from DOS function 19H  }
+            { because the drive was the default, which can be unknown }
+            asm
+                movb $0x19,%ah
+                call syscall
+                addb $65,%al
+                movb %al,i
+            end ['eax'];
+            dir[1]:=char(i);
+        end;
+    if not (FileNameCaseSensitive) then dir:=upcase(dir);
+end;
+
+
+
+{
+  $Log$
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
+
+}

+ 415 - 0
rtl/emx/sysfile.inc

@@ -0,0 +1,415 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    Low leve file functions
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{****************************************************************************
+
+                          Low Level File Routines
+
+****************************************************************************}
+
+procedure allowslash(p:Pchar);
+
+{Allow slash as backslash.}
+
+var i:longint;
+
+begin
+    for i:=0 to strlen(p) do
+        if p[i]='/' then p[i]:='\';
+end;
+
+procedure do_close (H: THandle);
+
+begin
+{ Only three standard handles under real OS/2 }
+  if (h > 4) or
+     ((os_MODE = osOS2) and (h > 2)) then
+   begin
+     asm
+        pushl %ebx
+        movb $0x3e,%ah
+        movl h,%ebx
+        call syscall
+        jnc  .Lnoerror           { error code?            }
+        movw  %ax, InOutRes       { yes, then set InOutRes }
+     .Lnoerror:
+        popl %ebx
+     end ['eax'];
+   end;
+end;
+
+procedure do_erase(p:Pchar);
+
+begin
+    allowslash(p);
+    asm
+        movl P,%edx
+        movb $0x41,%ah
+        call syscall
+        jnc .LERASE1
+        movw %ax,inoutres
+    .LERASE1:
+    end ['eax', 'edx'];
+end;
+
+procedure do_rename(p1,p2:Pchar);
+
+begin
+    allowslash(p1);
+    allowslash(p2);
+    asm
+        movl P1, %edx
+        movl P2, %edi
+        movb $0x56,%ah
+        call syscall
+        jnc .LRENAME1
+        movw %ax,inoutres
+    .LRENAME1:
+    end ['eax', 'edx', 'edi'];
+end;
+
+function do_read (H: THandle; Addr: pointer; Len: longint): longint; assembler;
+asm
+    pushl %ebx
+{$IFNDEF REGCALL}
+    movl len,%ecx
+    movl addr,%edx
+    movl %eax,%ebx
+{$ELSE REGCALL}
+    movl h,%ebx
+{$ENDIF REGCALL}
+    movb $0x3f,%ah
+    call syscall
+    jnc .LDOSREAD1
+    movw %ax,inoutres
+    xorl %eax,%eax
+.LDOSREAD1:
+    popl %ebx
+end {['eax', 'ebx', 'ecx', 'edx']};
+
+function do_write (H: THandle; Addr: pointer; Len: longint): longint;
+                                                                     assembler;
+asm
+    pushl %ebx
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+{$ENDIF REGCALL}
+    xorl %eax,%eax
+    cmpl $0,len    { 0 bytes to write is undefined behavior }
+    jz   .LDOSWRITE1
+{$IFNDEF REGCALL}
+    movl len,%ecx
+    movl addr,%edx
+    movl h,%ebx
+{$ENDIF REGCALL}
+    movb $0x40,%ah
+    call syscall
+    jnc .LDOSWRITE1
+    movw %ax,inoutres
+.LDOSWRITE1:
+    popl %ebx
+end {['eax', 'ebx', 'ecx', 'edx']};
+
+function do_filepos (Handle: THandle): longint; assembler;
+asm
+    pushl %ebx
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+{$ELSE REGCALL}
+    movl handle,%ebx
+{$ENDIF REGCALL}
+    movw $0x4201,%ax
+    xorl %edx,%edx
+    call syscall
+    jnc .LDOSFILEPOS
+    movw %ax,inoutres
+    xorl %eax,%eax
+.LDOSFILEPOS:
+    popl %ebx
+end {['eax', 'ebx', 'ecx', 'edx']};
+
+procedure do_seek (Handle: THandle; Pos: longint); assembler;
+asm
+    pushl %ebx
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+{$ELSE REGCALL}
+    movl handle,%ebx
+    movl pos,%edx
+{$ENDIF REGCALL}
+    movw $0x4200,%ax
+    call syscall
+    jnc .LDOSSEEK1
+    movw %ax,inoutres
+.LDOSSEEK1:
+    popl %ebx
+end {['eax', 'ebx', 'ecx', 'edx']};
+
+function do_seekend (Handle: THandle): longint; assembler;
+asm
+    pushl %ebx
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+{$ELSE REGCALL}
+    movl handle,%ebx
+{$ENDIF REGCALL}
+    movw $0x4202,%ax
+    xorl %edx,%edx
+    call syscall
+    jnc .Lset_at_end1
+    movw %ax,inoutres;
+    xorl %eax,%eax
+.Lset_at_end1:
+    popl %ebx
+end {['eax', 'ebx', 'ecx', 'edx']};
+
+function do_filesize (Handle: THandle): longint;
+
+var aktfilepos:longint;
+
+begin
+    aktfilepos:=do_filepos(handle);
+    do_filesize:=do_seekend(handle);
+    do_seek(handle,aktfilepos);
+end;
+
+procedure do_truncate (Handle: THandle; Pos: longint); assembler;
+asm
+    pushl %ebx
+(* DOS function 40h isn't safe for this according to EMX documentation *)
+{$IFDEF REGCALL}
+    movl %eax,%ebx
+    pushl %eax
+{$ELSE REGCALL}
+    movl Handle,%ebx
+    movl Pos,%edx
+{$ENDIF REGCALL}
+    movl $0x7F25,%eax
+    call syscall
+    incl %eax
+    movl %ecx, %eax
+{$IFDEF REGCALL}
+    popl %ebx
+{$ENDIF REGCALL}
+    jnz .LTruncate1      { compare the value of EAX to verify error }
+(* File position is undefined after truncation, move to the end. *)
+    movl $0x4202,%eax
+{$IFNDEF REGCALL}
+    movl Handle,%ebx
+{$ENDIF REGCALL}
+    movl $0,%edx
+    call syscall
+    jnc .LTruncate2
+.LTruncate1:
+    movw %ax,inoutres
+.LTruncate2:
+    popl %ebx
+end {['eax', 'ebx', 'ecx', 'edx']};
+
+const
+    FileHandleCount: cardinal = 20;
+
+function Increase_File_Handle_Count: boolean;
+var Err: word;
+    L1: longint;
+    L2: cardinal;
+begin
+    if os_mode = osOS2 then
+        begin
+            L1 := 10;
+            if DosSetRelMaxFH (L1, L2) <> 0 then
+                Increase_File_Handle_Count := false
+            else
+                if L2 > FileHandleCount then
+                    begin
+                        FileHandleCount := L2;
+                        Increase_File_Handle_Count := true;
+                    end
+                else
+                    Increase_File_Handle_Count := false;
+        end
+    else
+        begin
+            Inc (FileHandleCount, 10);
+            Err := 0;
+            asm
+                pushl %ebx
+                movl $0x6700, %eax
+                movl FileHandleCount, %ebx
+                call syscall
+                jnc .LIncFHandles
+                movw %ax, Err
+.LIncFHandles:
+                popl %ebx
+            end ['eax'];
+            if Err <> 0 then
+                begin
+                    Increase_File_Handle_Count := false;
+                    Dec (FileHandleCount, 10);
+                end
+            else
+                Increase_File_Handle_Count := true;
+        end;
+end;
+
+procedure do_open(var f;p:pchar;flags:longint);
+
+{
+  filerec and textrec have both handle and mode as the first items so
+  they could use the same routine for opening/creating.
+  when (flags and $100)   the file will be append
+  when (flags and $1000)  the file will be truncate/rewritten
+  when (flags and $10000) there is no check for close (needed for textfiles)
+}
+
+var Action: cardinal;
+
+begin
+    allowslash(p);
+    { close first if opened }
+    if ((flags and $10000)=0) then
+        begin
+            case filerec(f).mode of
+                fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
+                fmclosed:;
+            else
+                begin
+                    inoutres:=102; {not assigned}
+                    exit;
+                end;
+            end;
+       end;
+    { reset file handle }
+    filerec(f).handle := UnusedHandle;
+    Action := 0;
+    { convert filemode to filerec modes }
+    case (flags and 3) of
+        0 : filerec(f).mode:=fminput;
+        1 : filerec(f).mode:=fmoutput;
+        2 : filerec(f).mode:=fminout;
+    end;
+    if (flags and $1000)<>0 then
+        Action := $50000; (* Create / replace *)
+    { empty name is special }
+    if p[0]=#0 then
+        begin
+          case FileRec(f).mode of
+            fminput :
+              FileRec(f).Handle:=StdInputHandle;
+            fminout, { this is set by rewrite }
+            fmoutput :
+              FileRec(f).Handle:=StdOutputHandle;
+            fmappend :
+              begin
+                FileRec(f).Handle:=StdOutputHandle;
+                FileRec(f).mode:=fmoutput; {fool fmappend}
+              end;
+            end;
+            exit;
+        end;
+    Action := Action or (Flags and $FF);
+(* DenyNone if sharing not specified. *)
+    if Flags and 112 = 0 then
+        Action := Action or 64;
+    asm
+        pushl %ebx
+        movl $0x7f2b, %eax
+        movl Action, %ecx
+        movl p, %edx
+        call syscall
+        cmpl $0xffffffff, %eax
+        jnz .LOPEN1
+        movw %cx, InOutRes
+        movl UnusedHandle, %eax
+.LOPEN1:
+        movl f,%edx         { Warning : This assumes Handle is first }
+        movl %eax,(%edx)    { field of FileRec                       }
+        popl %ebx
+    end ['eax', 'ecx', 'edx'];
+    if (InOutRes = 4) and Increase_File_Handle_Count then
+(* Trying again after increasing amount of file handles *)
+        asm
+            pushl %ebx
+            movl $0x7f2b, %eax
+            movl Action, %ecx
+            movl p, %edx
+            call syscall
+            cmpl $0xffffffff, %eax
+            jnz .LOPEN2
+            movw %cx, InOutRes
+            movl UnusedHandle, %eax
+.LOPEN2:
+            movl f,%edx
+            movl %eax,(%edx)
+            popl %ebx
+        end ['eax', 'ecx', 'edx'];
+      { for systems that have more handles }
+    if (FileRec (F).Handle <> UnusedHandle) then
+        begin
+            if (FileRec (F).Handle > FileHandleCount) then
+                                         FileHandleCount := FileRec (F).Handle;
+            if ((Flags and $100) <> 0) then
+                begin
+                    do_seekend (FileRec (F).Handle);
+                    FileRec (F).Mode := fmOutput; {fool fmappend}
+                end;
+        end;
+end;
+
+{$ASMMODE INTEL}
+function do_isdevice (Handle: THandle): boolean; assembler;
+(*
+var HT, Attr: longint;
+begin
+    if os_mode = osOS2 then
+        begin
+            if DosQueryHType (Handle, HT, Attr) <> 0 then HT := 1;
+        end
+    else
+*)
+asm
+    push ebx
+{$IFDEF REGCALL}
+    mov ebx, eax
+{$ELSE REGCALL}
+    mov ebx, Handle
+{$ENDIF REGCALL}
+    mov eax, 4400h
+    call syscall
+    mov eax, 1
+    jc @IsDevEnd
+    test edx, 80h           { verify if it is a file  }
+    jnz @IsDevEnd
+    dec eax                 { nope, so result is zero }
+@IsDevEnd:
+    pop ebx
+end {['eax', 'ebx', 'edx']};
+{$ASMMODE ATT}
+
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 91 - 0
rtl/emx/sysheap.inc

@@ -0,0 +1,91 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+{****************************************************************************
+
+                    Heap management releated routines.
+
+****************************************************************************}
+
+
+{ this function allows to extend the heap by calling
+syscall $7f00 resizes the brk area}
+
+function sbrk(size:longint):pointer;
+{$IFDEF DUMPGROW}
+var
+  L: longword;
+begin
+  WriteLn ('Trying to grow heap by ', Size);
+{$IFDEF CONTHEAP}
+  WriteLn ('BrkLimit is ', BrkLimit);
+{$ENDIF CONTHEAP}
+  asm
+    movl size,%edx
+    movw $0x7f00,%ax
+    call syscall     { result directly in EAX }
+    inc %eax         { Result in EAX, -1 = error (has to be transformed to 0) }
+    jz .LSbrk_End
+    dec %eax         { No error - back to previous value }
+.LSbrk_End:
+    mov  %eax,L
+  end ['eax', 'edx'];
+  WriteLn ('New heap at ', L);
+  Sbrk := pointer (L);
+end;
+{$ELSE DUMPGROW}
+                                     assembler;
+asm
+{$IFDEF REGCALL}
+    movl %eax,%edx
+{$ELSE REGCALL}
+    movl size,%edx
+{$ENDIF REGCALL}
+    movw $0x7f00,%ax
+    call syscall
+    inc %eax         { Result in EAX, -1 = error (has to be transformed to 0) }
+    jz .LSbrk_End
+    dec %eax         { No error - back to previous value }
+.LSbrk_End:
+end {['eax', 'edx']};
+{$ENDIF DUMPGROW}
+
+function SysOSAlloc (Size: ptrint): pointer;
+begin
+ SysOSAlloc := Sbrk (Size);
+end;
+
+{.$define HAS_SYSOSFREE}
+
+procedure SysOSFree (P: pointer; Size: ptrint);
+begin
+end;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 105 - 0
rtl/emx/sysos.inc

@@ -0,0 +1,105 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+var
+  ProcessID: SizeUInt;
+
+function GetProcessID:SizeUInt;
+begin
+ GetProcessID := ProcessID;
+end;
+
+
+procedure DosGetInfoBlocks (PATIB: PPThreadInfoBlock;
+                            PAPIB: PPProcessInfoBlock); cdecl;
+                            external 'DOSCALLS' index 312;
+
+function DosLoadModule (ObjName: PChar; ObjLen: cardinal; DLLName: PChar;
+                                        var Handle: cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 318;
+
+function DosQueryProcAddr (Handle, Ordinal: cardinal; ProcName: PChar;
+                                        var Address: pointer): cardinal; cdecl;
+external 'DOSCALLS' index 321;
+
+function DosSetRelMaxFH (var ReqCount: longint; var CurMaxFH: cardinal):
+                                                               cardinal; cdecl;
+external 'DOSCALLS' index 382;
+
+function DosSetCurrentDir (Name:PChar): cardinal; cdecl;
+external 'DOSCALLS' index 255;
+
+function DosSetDefaultDisk (DiskNum:cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 220;
+
+{ This is not real prototype, but is close enough }
+{ for us (the 2nd parameter is actually a pointer }
+{ to a structure).                                }
+function DosCreateDir (Name: PChar; P: pointer): cardinal; cdecl;
+external 'DOSCALLS' index 270;
+
+function DosDeleteDir (Name: PChar): cardinal; cdecl;
+external 'DOSCALLS' index 226;
+
+{This is the correct way to call external assembler procedures.}
+procedure syscall; external name '___SYSCALL';
+
+{
+procedure syscall; external 'EMX' index 2;
+
+procedure emx_init; external 'EMX' index 1;
+}
+
+
+
+   { converts an OS/2 error code to a TP compatible error }
+   { code. Same thing exists under most other supported   }
+   { systems.                                             }
+   { Only call for OS/2 DLL imported routines             }
+   Procedure Errno2InOutRes;
+   Begin
+     { errors 1..18 are the same as in DOS }
+     case InOutRes of
+      { simple offset to convert these error codes }
+      { exactly like the error codes in Win32      }
+      19..31 : InOutRes := InOutRes + 131;
+      { gets a bit more complicated ... }
+      32..33 : InOutRes := 5;
+      38 : InOutRes := 100;
+      39 : InOutRes := 101;
+      112 : InOutRes := 101;
+      110 : InOutRes := 5;
+      114 : InOutRes := 6;
+      290 : InOutRes := 290;
+     end;
+     { all other cases ... we keep the same error code }
+   end;
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 47 - 0
rtl/emx/sysosh.inc

@@ -0,0 +1,47 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{Platform specific information}
+type
+  THandle = Longint;
+
+    { the fields of this record are os dependent  }
+    { and they shouldn't be used in a program     }
+    { only the type TCriticalSection is important }
+    PRTLCriticalSection = ^TRTLCriticalSection;
+    TRTLCriticalSection = packed record
+      DebugInfo : pointer;
+      LockCount : longint;
+      RecursionCount : longint;
+      OwningThread : DWord;
+      LockSemaphore : DWord;
+      Reserved : DWord;
+    end;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 10 - 778
rtl/emx/system.pas

@@ -27,13 +27,9 @@ interface
  {$l prt1.o}
 {$endif}
 
-{$I systemh.inc}
-
-{$I heaph.inc}
+{$DEFINE EOF_CTRLZ}
 
-{Platform specific information}
-type
-  THandle = Longint;
+{$I systemh.inc}
 
 const
  LineEnding = #13#10;
@@ -136,81 +132,6 @@ var
 {$ENDIF CONTHEAP}
 
 
-var
-  ProcessID: SizeUInt;
-
-function GetProcessID:SizeUInt;
-begin
- GetProcessID := ProcessID;
-end;
-
-
-procedure DosGetInfoBlocks (PATIB: PPThreadInfoBlock;
-                            PAPIB: PPProcessInfoBlock); cdecl;
-                            external 'DOSCALLS' index 312;
-
-function DosLoadModule (ObjName: PChar; ObjLen: cardinal; DLLName: PChar;
-                                        var Handle: cardinal): cardinal; cdecl;
-external 'DOSCALLS' index 318;
-
-function DosQueryProcAddr (Handle, Ordinal: cardinal; ProcName: PChar;
-                                        var Address: pointer): cardinal; cdecl;
-external 'DOSCALLS' index 321;
-
-function DosSetRelMaxFH (var ReqCount: longint; var CurMaxFH: cardinal):
-                                                               cardinal; cdecl;
-external 'DOSCALLS' index 382;
-
-function DosSetCurrentDir (Name:PChar): cardinal; cdecl;
-external 'DOSCALLS' index 255;
-
-function DosSetDefaultDisk (DiskNum:cardinal): cardinal; cdecl;
-external 'DOSCALLS' index 220;
-
-{ This is not real prototype, but is close enough }
-{ for us (the 2nd parameter is actually a pointer }
-{ to a structure).                                }
-function DosCreateDir (Name: PChar; P: pointer): cardinal; cdecl;
-external 'DOSCALLS' index 270;
-
-function DosDeleteDir (Name: PChar): cardinal; cdecl;
-external 'DOSCALLS' index 226;
-
-{This is the correct way to call external assembler procedures.}
-procedure syscall; external name '___SYSCALL';
-
-{
-procedure syscall; external 'EMX' index 2;
-
-procedure emx_init; external 'EMX' index 1;
-}
-
-
-
-   { converts an OS/2 error code to a TP compatible error }
-   { code. Same thing exists under most other supported   }
-   { systems.                                             }
-   { Only call for OS/2 DLL imported routines             }
-   Procedure Errno2InOutRes;
-   Begin
-     { errors 1..18 are the same as in DOS }
-     case InOutRes of
-      { simple offset to convert these error codes }
-      { exactly like the error codes in Win32      }
-      19..31 : InOutRes := InOutRes + 131;
-      { gets a bit more complicated ... }
-      32..33 : InOutRes := 5;
-      38 : InOutRes := 100;
-      39 : InOutRes := 101;
-      112 : InOutRes := 101;
-      110 : InOutRes := 5;
-      114 : InOutRes := 6;
-      290 : InOutRes := 290;
-     end;
-     { all other cases ... we keep the same error code }
-   end;
-
-
 {****************************************************************************
 
                     Miscellaneous related routines.
@@ -291,700 +212,6 @@ end {['eax', 'ecx', 'edx']};
 
 {$ASMMODE ATT}
 
-{****************************************************************************
-
-                    Heap management releated routines.
-
-****************************************************************************}
-
-
-{ this function allows to extend the heap by calling
-syscall $7f00 resizes the brk area}
-
-function sbrk(size:longint):pointer;
-xxx
-{$IFDEF DUMPGROW}
-var
-  L: longword;
-begin
-  WriteLn ('Trying to grow heap by ', Size);
-{$IFDEF CONTHEAP}
-  WriteLn ('BrkLimit is ', BrkLimit);
-{$ENDIF CONTHEAP}
-  asm
-    movl size,%edx
-    movw $0x7f00,%ax
-    call syscall     { result directly in EAX }
-    inc %eax         { Result in EAX, -1 = error (has to be transformed to 0) }
-    jz .LSbrk_End
-    dec %eax         { No error - back to previous value }
-.LSbrk_End:
-    mov  %eax,L
-  end ['eax', 'edx'];
-  WriteLn ('New heap at ', L);
-  Sbrk := pointer (L);
-end;
-{$ELSE DUMPGROW}
-                                     assembler;
-asm
-{$IFDEF REGCALL}
-    movl %eax,%edx
-{$ELSE REGCALL}
-    movl size,%edx
-{$ENDIF REGCALL}
-    movw $0x7f00,%ax
-    call syscall
-    inc %eax         { Result in EAX, -1 = error (has to be transformed to 0) }
-    jz .LSbrk_End
-    dec %eax         { No error - back to previous value }
-.LSbrk_End:
-end {['eax', 'edx']};
-{$ENDIF DUMPGROW}
-
-function SysOSAlloc (Size: ptrint): pointer;
-begin
- SysOSAlloc := Sbrk (Size);
-end;
-
-{.$define HAS_SYSOSFREE}
-
-procedure SysOSFree (P: pointer; Size: ptrint);
-begin
-end;
-
-
-{$i heap.inc}
-
-{****************************************************************************
-
-                          Low Level File Routines
-
-****************************************************************************}
-
-procedure allowslash(p:Pchar);
-
-{Allow slash as backslash.}
-
-var i:longint;
-
-begin
-    for i:=0 to strlen(p) do
-        if p[i]='/' then p[i]:='\';
-end;
-
-procedure do_close (H: THandle);
-
-begin
-{ Only three standard handles under real OS/2 }
-  if (h > 4) or
-     ((os_MODE = osOS2) and (h > 2)) then
-   begin
-     asm
-        pushl %ebx
-        movb $0x3e,%ah
-        movl h,%ebx
-        call syscall
-        jnc  .Lnoerror           { error code?            }
-        movw  %ax, InOutRes       { yes, then set InOutRes }
-     .Lnoerror:
-        popl %ebx
-     end ['eax'];
-   end;
-end;
-
-procedure do_erase(p:Pchar);
-
-begin
-    allowslash(p);
-    asm
-        movl P,%edx
-        movb $0x41,%ah
-        call syscall
-        jnc .LERASE1
-        movw %ax,inoutres
-    .LERASE1:
-    end ['eax', 'edx'];
-end;
-
-procedure do_rename(p1,p2:Pchar);
-
-begin
-    allowslash(p1);
-    allowslash(p2);
-    asm
-        movl P1, %edx
-        movl P2, %edi
-        movb $0x56,%ah
-        call syscall
-        jnc .LRENAME1
-        movw %ax,inoutres
-    .LRENAME1:
-    end ['eax', 'edx', 'edi'];
-end;
-
-function do_read (H: THandle; Addr: pointer; Len: longint): longint; assembler;
-asm
-    pushl %ebx
-{$IFNDEF REGCALL}
-    movl len,%ecx
-    movl addr,%edx
-    movl %eax,%ebx
-{$ELSE REGCALL}
-    movl h,%ebx
-{$ENDIF REGCALL}
-    movb $0x3f,%ah
-    call syscall
-    jnc .LDOSREAD1
-    movw %ax,inoutres
-    xorl %eax,%eax
-.LDOSREAD1:
-    popl %ebx
-end {['eax', 'ebx', 'ecx', 'edx']};
-
-function do_write (H: THandle; Addr: pointer; Len: longint): longint;
-                                                                     assembler;
-asm
-    pushl %ebx
-{$IFDEF REGCALL}
-    movl %eax,%ebx
-{$ENDIF REGCALL}
-    xorl %eax,%eax
-    cmpl $0,len    { 0 bytes to write is undefined behavior }
-    jz   .LDOSWRITE1
-{$IFNDEF REGCALL}
-    movl len,%ecx
-    movl addr,%edx
-    movl h,%ebx
-{$ENDIF REGCALL}
-    movb $0x40,%ah
-    call syscall
-    jnc .LDOSWRITE1
-    movw %ax,inoutres
-.LDOSWRITE1:
-    popl %ebx
-end {['eax', 'ebx', 'ecx', 'edx']};
-
-function do_filepos (Handle: THandle): longint; assembler;
-asm
-    pushl %ebx
-{$IFDEF REGCALL}
-    movl %eax,%ebx
-{$ELSE REGCALL}
-    movl handle,%ebx
-{$ENDIF REGCALL}
-    movw $0x4201,%ax
-    xorl %edx,%edx
-    call syscall
-    jnc .LDOSFILEPOS
-    movw %ax,inoutres
-    xorl %eax,%eax
-.LDOSFILEPOS:
-    popl %ebx
-end {['eax', 'ebx', 'ecx', 'edx']};
-
-procedure do_seek (Handle: THandle; Pos: longint); assembler;
-asm
-    pushl %ebx
-{$IFDEF REGCALL}
-    movl %eax,%ebx
-{$ELSE REGCALL}
-    movl handle,%ebx
-    movl pos,%edx
-{$ENDIF REGCALL}
-    movw $0x4200,%ax
-    call syscall
-    jnc .LDOSSEEK1
-    movw %ax,inoutres
-.LDOSSEEK1:
-    popl %ebx
-end {['eax', 'ebx', 'ecx', 'edx']};
-
-function do_seekend (Handle: THandle): longint; assembler;
-asm
-    pushl %ebx
-{$IFDEF REGCALL}
-    movl %eax,%ebx
-{$ELSE REGCALL}
-    movl handle,%ebx
-{$ENDIF REGCALL}
-    movw $0x4202,%ax
-    xorl %edx,%edx
-    call syscall
-    jnc .Lset_at_end1
-    movw %ax,inoutres;
-    xorl %eax,%eax
-.Lset_at_end1:
-    popl %ebx
-end {['eax', 'ebx', 'ecx', 'edx']};
-
-function do_filesize (Handle: THandle): longint;
-
-var aktfilepos:longint;
-
-begin
-    aktfilepos:=do_filepos(handle);
-    do_filesize:=do_seekend(handle);
-    do_seek(handle,aktfilepos);
-end;
-
-procedure do_truncate (Handle: THandle; Pos: longint); assembler;
-asm
-    pushl %ebx
-(* DOS function 40h isn't safe for this according to EMX documentation *)
-{$IFDEF REGCALL}
-    movl %eax,%ebx
-    pushl %eax
-{$ELSE REGCALL}
-    movl Handle,%ebx
-    movl Pos,%edx
-{$ENDIF REGCALL}
-    movl $0x7F25,%eax
-    call syscall
-    incl %eax
-    movl %ecx, %eax
-{$IFDEF REGCALL}
-    popl %ebx
-{$ENDIF REGCALL}
-    jnz .LTruncate1      { compare the value of EAX to verify error }
-(* File position is undefined after truncation, move to the end. *)
-    movl $0x4202,%eax
-{$IFNDEF REGCALL}
-    movl Handle,%ebx
-{$ENDIF REGCALL}
-    movl $0,%edx
-    call syscall
-    jnc .LTruncate2
-.LTruncate1:
-    movw %ax,inoutres
-.LTruncate2:
-    popl %ebx
-end {['eax', 'ebx', 'ecx', 'edx']};
-
-const
-    FileHandleCount: cardinal = 20;
-
-function Increase_File_Handle_Count: boolean;
-var Err: word;
-    L1: longint;
-    L2: cardinal;
-begin
-    if os_mode = osOS2 then
-        begin
-            L1 := 10;
-            if DosSetRelMaxFH (L1, L2) <> 0 then
-                Increase_File_Handle_Count := false
-            else
-                if L2 > FileHandleCount then
-                    begin
-                        FileHandleCount := L2;
-                        Increase_File_Handle_Count := true;
-                    end
-                else
-                    Increase_File_Handle_Count := false;
-        end
-    else
-        begin
-            Inc (FileHandleCount, 10);
-            Err := 0;
-            asm
-                pushl %ebx
-                movl $0x6700, %eax
-                movl FileHandleCount, %ebx
-                call syscall
-                jnc .LIncFHandles
-                movw %ax, Err
-.LIncFHandles:
-                popl %ebx
-            end ['eax'];
-            if Err <> 0 then
-                begin
-                    Increase_File_Handle_Count := false;
-                    Dec (FileHandleCount, 10);
-                end
-            else
-                Increase_File_Handle_Count := true;
-        end;
-end;
-
-procedure do_open(var f;p:pchar;flags:longint);
-
-{
-  filerec and textrec have both handle and mode as the first items so
-  they could use the same routine for opening/creating.
-  when (flags and $100)   the file will be append
-  when (flags and $1000)  the file will be truncate/rewritten
-  when (flags and $10000) there is no check for close (needed for textfiles)
-}
-
-var Action: cardinal;
-
-begin
-    allowslash(p);
-    { close first if opened }
-    if ((flags and $10000)=0) then
-        begin
-            case filerec(f).mode of
-                fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
-                fmclosed:;
-            else
-                begin
-                    inoutres:=102; {not assigned}
-                    exit;
-                end;
-            end;
-       end;
-    { reset file handle }
-    filerec(f).handle := UnusedHandle;
-    Action := 0;
-    { convert filemode to filerec modes }
-    case (flags and 3) of
-        0 : filerec(f).mode:=fminput;
-        1 : filerec(f).mode:=fmoutput;
-        2 : filerec(f).mode:=fminout;
-    end;
-    if (flags and $1000)<>0 then
-        Action := $50000; (* Create / replace *)
-    { empty name is special }
-    if p[0]=#0 then
-        begin
-          case FileRec(f).mode of
-            fminput :
-              FileRec(f).Handle:=StdInputHandle;
-            fminout, { this is set by rewrite }
-            fmoutput :
-              FileRec(f).Handle:=StdOutputHandle;
-            fmappend :
-              begin
-                FileRec(f).Handle:=StdOutputHandle;
-                FileRec(f).mode:=fmoutput; {fool fmappend}
-              end;
-            end;
-            exit;
-        end;
-    Action := Action or (Flags and $FF);
-(* DenyNone if sharing not specified. *)
-    if Flags and 112 = 0 then
-        Action := Action or 64;
-    asm
-        pushl %ebx
-        movl $0x7f2b, %eax
-        movl Action, %ecx
-        movl p, %edx
-        call syscall
-        cmpl $0xffffffff, %eax
-        jnz .LOPEN1
-        movw %cx, InOutRes
-        movl UnusedHandle, %eax
-.LOPEN1:
-        movl f,%edx         { Warning : This assumes Handle is first }
-        movl %eax,(%edx)    { field of FileRec                       }
-        popl %ebx
-    end ['eax', 'ecx', 'edx'];
-    if (InOutRes = 4) and Increase_File_Handle_Count then
-(* Trying again after increasing amount of file handles *)
-        asm
-            pushl %ebx
-            movl $0x7f2b, %eax
-            movl Action, %ecx
-            movl p, %edx
-            call syscall
-            cmpl $0xffffffff, %eax
-            jnz .LOPEN2
-            movw %cx, InOutRes
-            movl UnusedHandle, %eax
-.LOPEN2:
-            movl f,%edx
-            movl %eax,(%edx)
-            popl %ebx
-        end ['eax', 'ecx', 'edx'];
-      { for systems that have more handles }
-    if (FileRec (F).Handle <> UnusedHandle) then
-        begin
-            if (FileRec (F).Handle > FileHandleCount) then
-                                         FileHandleCount := FileRec (F).Handle;
-            if ((Flags and $100) <> 0) then
-                begin
-                    do_seekend (FileRec (F).Handle);
-                    FileRec (F).Mode := fmOutput; {fool fmappend}
-                end;
-        end;
-end;
-
-{$ASMMODE INTEL}
-function do_isdevice (Handle: THandle): boolean; assembler;
-(*
-var HT, Attr: longint;
-begin
-    if os_mode = osOS2 then
-        begin
-            if DosQueryHType (Handle, HT, Attr) <> 0 then HT := 1;
-        end
-    else
-*)
-asm
-    push ebx
-{$IFDEF REGCALL}
-    mov ebx, eax
-{$ELSE REGCALL}
-    mov ebx, Handle
-{$ENDIF REGCALL}
-    mov eax, 4400h
-    call syscall
-    mov eax, 1
-    jc @IsDevEnd
-    test edx, 80h           { verify if it is a file  }
-    jnz @IsDevEnd
-    dec eax                 { nope, so result is zero }
-@IsDevEnd:
-    pop ebx
-end {['eax', 'ebx', 'edx']};
-{$ASMMODE ATT}
-
-
-{*****************************************************************************
-                           UnTyped File Handling
-*****************************************************************************}
-
-{$i file.inc}
-
-{*****************************************************************************
-                           Typed File Handling
-*****************************************************************************}
-
-{$i typefile.inc}
-
-{*****************************************************************************
-                           Text File Handling
-*****************************************************************************}
-
-{$DEFINE EOF_CTRLZ}
-
-{$i text.inc}
-
-{****************************************************************************
-
-                          Directory related routines.
-
-****************************************************************************}
-
-{*****************************************************************************
-                           Directory Handling
-*****************************************************************************}
-
-
-procedure dosdir(func:byte;const s:string);
-
-var buffer:array[0..255] of char;
-
-begin
-    move(s[1],buffer,length(s));
-    buffer[length(s)]:=#0;
-    allowslash(Pchar(@buffer));
-    asm
-        leal buffer,%edx
-        movb func,%ah
-        call syscall
-        jnc  .LDOS_DIRS1
-        movw %ax,inoutres
-    .LDOS_DIRS1:
-    end ['eax', 'edx'];
-end;
-
-
-procedure MkDir (const S: string);[IOCHECK];
-
-var buffer:array[0..255] of char;
-    Rc : word;
-
-begin
-  If (s='') or (InOutRes <> 0) then
-   exit;
- if os_mode = osOs2 then
-    begin
-      move(s[1],buffer,length(s));
-      buffer[length(s)]:=#0;
-      allowslash(Pchar(@buffer));
-      Rc := DosCreateDir(buffer,nil);
-      if Rc <> 0 then
-       begin
-         InOutRes := Rc;
-         Errno2Inoutres;
-       end;
-    end
-  else
-   begin
-     { Under EMX 0.9d DOS this routine call may sometimes fail   }
-     { The syscall documentation indicates clearly that this     }
-     { routine was NOT tested.                                   }
-        DosDir ($39, S);
-end;
-end;
-
-
-procedure rmdir(const s : string);[IOCHECK];
-var buffer:array[0..255] of char;
-    Rc : word;
-begin
-  if (s = '.' ) then
-    InOutRes := 16;
-  If (s='') or (InOutRes <> 0) then
-   exit;
-  if os_mode = osOs2 then
-    begin
-      move(s[1],buffer,length(s));
-      buffer[length(s)]:=#0;
-      allowslash(Pchar(@buffer));
-      Rc := DosDeleteDir(buffer);
-      if Rc <> 0 then
-       begin
-         InOutRes := Rc;
-         Errno2Inoutres;
-       end;
-    end
-  else
-   begin
-     { Under EMX 0.9d DOS this routine call may sometimes fail   }
-     { The syscall documentation indicates clearly that this     }
-     { routine was NOT tested.                                   }
-        DosDir ($3A, S);
-end;
-end;
-
-{$ASMMODE INTEL}
-
-procedure ChDir (const S: string);[IOCheck];
-
-var RC: cardinal;
-    Buffer: array [0..255] of char;
-
-begin
-  If (s='') or (InOutRes <> 0) then
-   exit;
-(* According to EMX documentation, EMX has only one current directory
-   for all processes, so we'll use native calls under OS/2. *)
-            if os_Mode = osOS2 then
-                begin
-                    if (Length (S) >= 2) and (S [2] = ':') then
-                        begin
-                            RC := DosSetDefaultDisk ((Ord (S [1]) and
-                                                             not ($20)) - $40);
-                            if RC <> 0 then
-                                InOutRes := RC
-                            else
-                                if Length (S) > 2 then
-                                    begin
-                                        Move (S [1], Buffer, Length (S));
-                                        Buffer [Length (S)] := #0;
-                                        AllowSlash (PChar (@Buffer));
-                                        RC := DosSetCurrentDir (@Buffer);
-                                        if RC <> 0 then
-                                         begin
-                                            InOutRes := RC;
-                                            Errno2InOutRes;
-                                         end;
-                                    end;
-                        end
-                    else
-                        begin
-                            Move (S [1], Buffer, Length (S));
-                            Buffer [Length (S)] := #0;
-                            AllowSlash (PChar (@Buffer));
-                            RC := DosSetCurrentDir (@Buffer);
-                            if RC <> 0 then
-                             begin
-                                  InOutRes:= RC;
-                                  Errno2InOutRes;
-                             end;
-                        end;
-                end
-            else
-                if (Length (S) >= 2) and (S [2] = ':') then
-                    begin
-                        asm
-                            mov esi, S
-                            mov al, [esi + 1]
-                            and al, not (20h)
-                            sub al, 41h
-                            mov edx, eax
-                            mov ah, 0Eh
-                            call syscall
-                            mov ah, 19h
-                            call syscall
-                            cmp al, dl
-                            jz @LCHDIR
-                            mov InOutRes, 15
-@LCHDIR:
-                        end ['eax','edx','esi'];
-                        if (Length (S) > 2) and (InOutRes <> 0) then
-                            { Under EMX 0.9d DOS this routine may sometime }
-                            { fail or crash the system.                    }
-                            DosDir ($3B, S);
-                    end
-                else
-                    { Under EMX 0.9d DOS this routine may sometime }
-                    { fail or crash the system.                    }
-                    DosDir ($3B, S);
-end;
-
-{$ASMMODE ATT}
-
-procedure GetDir (DriveNr: byte; var Dir: ShortString);
-
-{Written by Michael Van Canneyt.}
-
-var sof:Pchar;
-    i:byte;
-
-begin
-    Dir [4] := #0;
-    { Used in case the specified drive isn't available }
-    sof:=pchar(@dir[4]);
-    { dir[1..3] will contain '[drivenr]:\', but is not }
-    { supplied by DOS, so we let dos string start at   }
-    { dir[4]                                           }
-    { Get dir from drivenr : 0=default, 1=A etc... }
-    asm
-        movb drivenr,%dl
-        movl sof,%esi
-        mov  $0x47,%ah
-        call syscall
-        jnc .LGetDir
-        movw %ax, InOutRes
-.LGetDir:
-    end [ 'eax','edx','esi'];
-    { Now Dir should be filled with directory in ASCIIZ, }
-    { starting from dir[4]                               }
-    dir[0]:=#3;
-    dir[2]:=':';
-    dir[3]:='\';
-    i:=4;
-    {Conversion to Pascal string }
-    while (dir[i]<>#0) do
-        begin
-            { convert path name to DOS }
-            if dir[i]='/' then
-            dir[i]:='\';
-            dir[0]:=char(i);
-            inc(i);
-        end;
-    { upcase the string (FPC function) }
-    if drivenr<>0 then   { Drive was supplied. We know it }
-        dir[1]:=chr(64+drivenr)
-    else
-        begin
-            { We need to get the current drive from DOS function 19H  }
-            { because the drive was the default, which can be unknown }
-            asm
-                movb $0x19,%ah
-                call syscall
-                addb $65,%al
-                movb %al,i
-            end ['eax'];
-            dir[1]:=char(i);
-        end;
-    if not (FileNameCaseSensitive) then dir:=upcase(dir);
-end;
-
 
 {*****************************************************************************
 
@@ -1199,8 +426,8 @@ threadvar
 {$else HASTHREADVAR}
 var
 {$endif HASTHREADVAR}
-  DefaultCreator: ShortString = '';
-  DefaultFileType: ShortString = '';
+  DefaultCreator: ShortString;
+  DefaultFileType: ShortString;
 
 
 procedure SetDefaultOS2FileType (FType: ShortString);
@@ -1347,6 +574,8 @@ begin
     { no I/O-Error }
     inoutres:=0;
 
+    InitSystemThreads;
+    
 {$ifdef HASVARIANT}
     initvariantmanager;
 {$endif HASVARIANT}
@@ -1363,7 +592,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.32  2004-12-12 21:08:29  hajny
+  Revision 1.33  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.32  2004/12/12 21:08:29  hajny
     * ThreadID is shared
 
   Revision 1.31  2004/12/05 14:36:37  hajny

+ 20 - 218
rtl/emx/systhrds.pp → rtl/emx/systhrd.inc

@@ -1,9 +1,10 @@
 {
     $Id$
     This file is part of the Free Pascal run time library.
-    Copyright (c) 2002 by the Free Pascal development team.
+    Copyright (c) 2002 by Peter Vreman,
+    member of the Free Pascal development team.
 
-    EMX threading support implementation
+    Linux (pthreads) threading support implementation
 
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
@@ -13,31 +14,6 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-unit systhrds;
-interface
-
-{$S-}
-
-  type
-    { the fields of this record are os dependent  }
-    { and they shouldn't be used in a program     }
-    { only the type TCriticalSection is important }
-    PRTLCriticalSection = ^TRTLCriticalSection;
-    TRTLCriticalSection = packed record
-      DebugInfo : pointer;
-      LockCount : longint;
-      RecursionCount : longint;
-      OwningThread : DWord;
-      LockSemaphore : DWord;
-      Reserved : DWord;
-    end;
-
-{ Include generic thread interface }
-{$i threadh.inc}
-
-
-implementation
-
 
 {*****************************************************************************
                            Local Api imports
@@ -54,43 +30,6 @@ const
  dtSuspended = 1;
  dtStack_Commited = 2;
 
-type
- TByteArray = array [0..$ffff] of byte;
- PByteArray = ^TByteArray;
-
- TSysThreadIB = record
-  TID,
-  Priority,
-  Version: cardinal;
-  MCCount,
-  MCForceFlag: word;
- end;
- PSysThreadIB = ^TSysThreadIB;
-
- TThreadInfoBlock = record
-  PExChain,
-  Stack,
-  StackLimit: pointer;
-  TIB2: PSysThreadIB;
-  Version,
-  Ordinal: cardinal;
- end;
- PThreadInfoBlock = ^TThreadInfoBlock;
- PPThreadInfoBlock = ^PThreadInfoBlock;
-
- TProcessInfoBlock = record
-  PID,
-  ParentPid,
-  Handle: cardinal;
-  Cmd,
-  Env: PByteArray;
-  Status,
-  ProcType: cardinal;
- end;
- PProcessInfoBlock = ^TProcessInfoBlock;
- PPProcessInfoBlock = ^PProcessInfoBlock;
-
-
 { import the necessary stuff from the OS }
 function DosAllocThreadLocalMemory (Count: cardinal; var P: pointer): cardinal;
                                           cdecl; external 'DOSCALLS' index 454;
@@ -131,10 +70,6 @@ function DosEnterCritSec:cardinal; cdecl; external 'DOSCALLS' index 232;
 
 function DosExitCritSec:cardinal; cdecl; external 'DOSCALLS' index 233;
 
-procedure DosGetInfoBlocks (PATIB: PPThreadInfoBlock;
-                                    PAPIB: PPProcessInfoBlock); cdecl;
-                                                 external 'DOSCALLS' index 312;
-
 
 {*****************************************************************************
                              Threadvar support
@@ -178,8 +113,6 @@ begin
  DosFreeMem (DataIndex^);
 end;
 
-{ Include OS independent Threadvar initialization }
-{$i threadvar.inc}
 
     procedure InitThreadVars;
       begin
@@ -199,127 +132,22 @@ end;
 {$endif HASTHREADVAR}
 
 
-{*****************************************************************************
-                            Thread starting
-*****************************************************************************}
-
-    const
-      DefaultStackSize = 32768; { including 16384 margin for stackchecking }
-
-    type
-      pthreadinfo = ^tthreadinfo;
-      tthreadinfo = record
-        f : tthreadfunc;
-        p : pointer;
-        stklen : cardinal;
-      end;
-
-    procedure InitThread(stklen:cardinal);
-      begin
-        SysResetFPU;
-        { ExceptAddrStack and ExceptObjectStack are threadvars       }
-        { so every thread has its on exception handling capabilities }
-        SysInitExceptions;
-        { Open all stdio fds again }
-        SysInitStdio;
-        InOutRes:=0;
-        ThreadID := ...;
-        // ErrNo:=0;
-        { Stack checking }
-        StackLength:=stklen;
-        StackBottom:=Sptr - StackLength;
-      end;
-
-
-    procedure DoneThread;
-      begin
-        { Release Threadvars }
-{$ifdef HASTHREADVAR}
-        SysReleaseThreadVars;
-{$endif HASTHREADVAR}
-      end;
-
-
-    function ThreadMain(param : pointer) : pointer;cdecl;
-      var
-        ti : tthreadinfo;
-      begin
-{$ifdef HASTHREADVAR}
-        { Allocate local thread vars, this must be the first thing,
-          because the exception management and io depends on threadvars }
-        SysAllocateThreadVars;
-{$endif HASTHREADVAR}
-        { Copy parameter to local data }
-{$ifdef DEBUG_MT}
-        writeln('New thread started, initialising ...');
-{$endif DEBUG_MT}
-        ti:=pthreadinfo(param)^;
-        dispose(pthreadinfo(param));
-        { Initialize thread }
-        InitThread(ti.stklen);
-        { Start thread function }
-{$ifdef DEBUG_MT}
-        writeln('Jumping to thread function');
-{$endif DEBUG_MT}
-        ThreadMain:=pointer(ti.f(ti.p));
-      end;
-
-
-    function BeginThread(sa : Pointer;stacksize : dword;
-                         ThreadFunction : tthreadfunc;p : pointer;
-                         creationFlags : dword; var ThreadId : DWord) : DWord;
-      var
-        ti : pthreadinfo;
-      begin
-{$ifdef DEBUG_MT}
-        writeln('Creating new thread');
-{$endif DEBUG_MT}
-        { Initialize multithreading if not done }
-        if not IsMultiThread then
-         begin
-{$ifdef HASTHREADVAR}
-           InitThreadVars;
-{$endif HASTHREADVAR}
-           IsMultiThread:=true;
-         end;
-        { the only way to pass data to the newly created thread
-          in a MT safe way, is to use the heap }
-        new(ti);
-        ti^.f:=ThreadFunction;
-        ti^.p:=p;
-        ti^.stklen:=stacksize;
-        { call pthread_create }
-{$ifdef DEBUG_MT}
-        writeln('Starting new thread');
-{$endif DEBUG_MT}
-        BeginThread:=CreateThread(sa,stacksize,@ThreadMain,ti,creationflags,threadid);
-        BeginThread:=threadid;
-      end;
-
-
-    procedure EndThread(ExitCode : DWord);
-      begin
-        DoneThread;
-        ExitThread(ExitCode);
-      end;
-
-
 {*****************************************************************************
                           Delphi/Win32 compatibility
 *****************************************************************************}
 
 { we implement these procedures for win32 by importing them }
 { directly from windows                                     }
-procedure InitCriticalSection(var cs : TRTLCriticalSection);
+procedure SysInitCriticalSection(var cs : TRTLCriticalSection);
   external 'kernel32' name 'InitializeCriticalSection';
 
-procedure DoneCriticalSection(var cs : TRTLCriticalSection);
+procedure SysDoneCriticalSection(var cs : TRTLCriticalSection);
   external 'kernel32' name 'DeleteCriticalSection';
 
-procedure EnterCriticalSection(var cs : TRTLCriticalSection);
+procedure SysEnterCriticalSection(var cs : TRTLCriticalSection);
   external 'kernel32' name 'EnterCriticalSection';
 
-procedure LeaveCriticalSection(var cs : TRTLCriticalSection);
+procedure SysLeaveCriticalSection(var cs : TRTLCriticalSection);
   external 'kernel32' name 'LeaveCriticalSection';
 
 
@@ -332,22 +160,22 @@ procedure LeaveCriticalSection(var cs : TRTLCriticalSection);
 
     procedure OS2HeapMutexInit;
       begin
-         InitCriticalSection(heapmutex);
+         SysInitCriticalSection(heapmutex);
       end;
 
     procedure OS2HeapMutexDone;
       begin
-         DoneCriticalSection(heapmutex);
+         SysDoneCriticalSection(heapmutex);
       end;
 
     procedure OS2HeapMutexLock;
       begin
-         EnterCriticalSection(heapmutex);
+         SysEnterCriticalSection(heapmutex);
       end;
 
     procedure OS2HeapMutexUnlock;
       begin
-         LeaveCriticalSection(heapmutex);
+         SysLeaveCriticalSection(heapmutex);
       end;
 
     const
@@ -358,47 +186,21 @@ procedure LeaveCriticalSection(var cs : TRTLCriticalSection);
         MutexUnlock : @OS2HeapMutexUnlock;
       );
 
-    procedure InitHeapMutexes;
+    procedure InitSystemThreads;
       begin
-        SetMemoryMutexManager(Win32MemoryMutexManager);
+        SetNoThreadManager;
+        SetMemoryMutexManager(OS2MemoryMutexManager);
       end;
 
 
-{*****************************************************************************
-                             Generic overloaded
-*****************************************************************************}
-
-{ Include generic overloaded routines }
-{$i thread.inc}
-
-finalization
- DosFreeThreadLocalMemory (DataIndex);
-end;
-
-initialization
-  InitHeapMutexes;
-end.
 {
   $Log$
-  Revision 1.5  2004-01-20 23:05:31  hajny
-    * ExecuteProcess fixes, ProcessID and ThreadID added
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
 
-  Revision 1.4  2003/10/19 09:35:28  hajny
-    * fixes from OS/2 merged to EMX
-
-  Revision 1.3  2003/03/23 23:11:17  hajny
-    + emx target added
-
-  Revision 1.2  2002/11/17 22:32:05  hajny
-    * type corrections (longing x cardinal)
-
-  Revision 1.1  2002/11/17 16:45:35  hajny
-    * threads.pp renamed to systhrds.pp
-
-  Revision 1.1  2002/11/17 16:22:54  hajny
-    + RTL for emx target
-
-  Revision 1.1  2002/10/14 19:39:18  peter
-    * threads unit added for thread support
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
 
 }
+

+ 66 - 67
rtl/go32v2/Makefile

@@ -250,103 +250,103 @@ ifdef NO_EXCEPTIONS_IN_SYSTEM
 override FPCOPT+=-dNO_EXCEPTIONS_IN_SYSTEM
 endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=system systhrds objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
+override TARGET_UNITS+=system objpas macpas strings go32 dpmiexcp initc ports profile dxetype dxeload emu387 dos crt objects printer graph sysutils classes math typinfo matrix cpu mmx ucomplex getopts heaptrc lineinfo msmouse charset varutils video mouse keyboard variants vesamode types sysconst rtlconst dateutil convutil strutils
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_LOADERS+=prt0 exceptn fpu
@@ -448,103 +448,103 @@ ifeq ($(FULL_TARGET),arm-linux)
 override TARGET_LOADERS+=prt0 exceptn fpu
 endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst systhrds
+override TARGET_RSTS+=math varutils typinfo classes variants dateutil sysconst
 endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
@@ -1964,7 +1964,6 @@ objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc system$(PPUEXT)
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
 		   system$(PPUEXT)
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc system$(PPUEXT) objpas$(PPUEXT)
 go32$(PPUEXT) : go32.pp system$(PPUEXT)
 dpmiexcp$(PPUEXT) : dpmiexcp.pp exceptn$(OEXT) system$(PPUEXT)
 	$(COMPILER) -Sg dpmiexcp.pp

+ 64 - 65
rtl/go32v2/Makefile.fpc

@@ -1,11 +1,11 @@
 #
 #   Makefile.fpc for Go32v2 RTL
-#

+#
 [package]
-main=rtl

+main=rtl
 [target]
 loaders=prt0 exceptn fpu
-units=system systhrds objpas macpas strings \
+units=system objpas macpas strings \
       go32 dpmiexcp initc ports profile dxetype dxeload emu387 \
       dos crt objects printer graph \
       sysutils classes math typinfo matrix \
@@ -13,144 +13,143 @@ units=system systhrds objpas macpas strings \
       msmouse charset varutils \
       video mouse keyboard variants vesamode types \
       sysconst rtlconst dateutil convutil strutils
-rsts=math varutils typinfo classes variants dateutil sysconst systhrds 

+rsts=math varutils typinfo classes variants dateutil sysconst
 [require]
-nortl=y

+nortl=y
 [install]
-fpcpackage=y

+fpcpackage=y
 [default]
 fpcdir=../..
 target=go32v2
-cpu=i386

+cpu=i386
 [compiler]
 includedir=$(INC) $(PROCINC)
-sourcedir=$(INC) $(PROCINC)



+sourcedir=$(INC) $(PROCINC)
 [prerules]
 RTL=..
 INC=../inc
-PROCINC=../$(CPU_TARGET)

-UNITPREFIX=rtl

+PROCINC=../$(CPU_TARGET)
+UNITPREFIX=rtl
 # Use new feature from 1.0.5 version
 # that generates release PPU files
 # which will not be recompiled
 ifdef RELEASE
 override FPCOPT+=-Ur
-endif

+endif
 # Paths
 OBJPASDIR=$(RTL)/objpas
-GRAPHDIR=$(INC)/graph

+GRAPHDIR=$(INC)/graph
 # Insert exception handler in system unit
 ifdef EXCEPTIONS_IN_SYSTEM
 override FPCOPT+=-dEXCEPTIONS_IN_SYSTEM
-endif

+endif
 # Insert exception handler in system unit
 ifdef NO_EXCEPTIONS_IN_SYSTEM
 override FPCOPT+=-dNO_EXCEPTIONS_IN_SYSTEM
-endif



+endif
 [rules]
 # Get the system independent include file names.
 # This will set the following variables :
 # SYSINCNAMES
 include $(INC)/makefile.inc
-SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))

+SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
 # Get the processor dependent include file names.
 # This will set the following variables :
 # CPUINCNAMES
 include $(PROCINC)/makefile.cpu
-SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))

+SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
 # Put system unit dependencies together.
-SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)



+SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
 #
 # Loaders
-#

+#
 prt0$(OEXT) : v2prt0.as
-        $(AS) -o $(UNITTARGETDIRPREFIX)prt0$(OEXT) v2prt0.as

+        $(AS) -o $(UNITTARGETDIRPREFIX)prt0$(OEXT) v2prt0.as
 #
 # System Units (System, Objpas, Strings)
-#

+#
 system$(PPUEXT) : system.pp $(SYSDEPS)
-        $(COMPILER) -Us -Sg system.pp

+        $(COMPILER) -Us -Sg system.pp
 objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc system$(PPUEXT)
-        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp

+        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
                    $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
                    system$(PPUEXT)
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc system$(PPUEXT) objpas$(PPUEXT)

 #
 # System Dependent Units
-#

-go32$(PPUEXT) : go32.pp system$(PPUEXT)

+#
+go32$(PPUEXT) : go32.pp system$(PPUEXT)
 dpmiexcp$(PPUEXT) : dpmiexcp.pp exceptn$(OEXT) system$(PPUEXT)
-        $(COMPILER) -Sg dpmiexcp.pp

-initc$(PPUEXT) : initc.pp system$(PPUEXT)

-profile$(PPUEXT) : profile.pp dpmiexcp$(PPUEXT) go32$(PPUEXT)

-dxetype$(PPUEXT) : dxetype.pp system$(PPUEXT)

-dxeload$(PPUEXT) : dxeload.pp dxetype$(PPUEXT) system$(PPUEXT)

+        $(COMPILER) -Sg dpmiexcp.pp
+initc$(PPUEXT) : initc.pp system$(PPUEXT)
+profile$(PPUEXT) : profile.pp dpmiexcp$(PPUEXT) go32$(PPUEXT)
+dxetype$(PPUEXT) : dxetype.pp system$(PPUEXT)
+dxeload$(PPUEXT) : dxeload.pp dxetype$(PPUEXT) system$(PPUEXT)
 emu387$(PPUEXT) : emu387.pp fpu$(OEXT) strings$(PPUEXT) dxeload$(PPUEXT) \
-                  dpmiexcp$(PPUEXT)

-ports$(PPUEXT) : ports.pp objpas$(PPUEXT) system$(PPUEXT)

+                  dpmiexcp$(PPUEXT)
+ports$(PPUEXT) : ports.pp objpas$(PPUEXT) system$(PPUEXT)
 #
 # TP7 Compatible RTL Units
-#

+#
 dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc \
-               go32$(PPUEXT) strings$(PPUEXT) system$(PPUEXT)

-crt$(PPUEXT) : crt.pp $(INC)/textrec.inc go32$(PPUEXT) system$(PPUEXT)

-objects$(PPUEXT) : $(INC)/objects.pp system$(PPUEXT)

-printer$(PPUEXT) : printer.pp system$(PPUEXT)

+               go32$(PPUEXT) strings$(PPUEXT) system$(PPUEXT)
+crt$(PPUEXT) : crt.pp $(INC)/textrec.inc go32$(PPUEXT) system$(PPUEXT)
+objects$(PPUEXT) : $(INC)/objects.pp system$(PPUEXT)
+printer$(PPUEXT) : printer.pp system$(PPUEXT)
 #
 # Graph
-#

+#
 include $(GRAPHDIR)/makefile.inc
-GRAPHINCDEPS=$(addprefix $(GRAPHDIR)/,$(GRAPHINCNAMES))

+GRAPHINCDEPS=$(addprefix $(GRAPHDIR)/,$(GRAPHINCNAMES))
 graph$(PPUEXT) : graph.pp go32$(PPUEXT) ports$(PPUEXT) system$(PPUEXT) \
                  $(GRAPHINCDEPS) vesa.inc vesah.inc dpmi.inc
-        $(COMPILER) -I$(GRAPHDIR) graph.pp

+        $(COMPILER) -I$(GRAPHDIR) graph.pp
 #
 # Delphi Compatible Units
-#

+#
 sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
                     objpas$(PPUEXT) dos$(PPUEXT) go32$(PPUEXT) sysconst$(PPUEXT)
-        $(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp

+        $(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp
 classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
-                   sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconst$(PPUEXT) types$(PPUEXT)

-        $(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp

+                   sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconst$(PPUEXT) types$(PPUEXT)
+        $(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp
 typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
-        $(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp

+        $(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp
 math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
-        $(COMPILER) $(OBJPASDIR)/math.pp

+        $(COMPILER) $(OBJPASDIR)/math.pp
 varutils$(PPUEXT) : $(OBJPASDIR)/cvarutil.inc $(OBJPASDIR)/varutils.inc \
                     $(OBJPASDIR)/varutilh.inc varutils.pp
-        $(COMPILER) -I$(OBJPASDIR) varutils.pp

+        $(COMPILER) -I$(OBJPASDIR) varutils.pp
 types$(PPUEXT) : $(OBJPASDIR)/types.pp objpas$(PPUEXT)
-        $(COMPILER) $(OBJPASDIR)/types.pp

+        $(COMPILER) $(OBJPASDIR)/types.pp
 rtlconst$(PPUEXT) : $(OBJPASDIR)/rtlconst.pp
-        $(COMPILER) $(OBJPASDIR)/rtlconst.pp

+        $(COMPILER) $(OBJPASDIR)/rtlconst.pp
 sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT)
-        $(COMPILER) $(OBJPASDIR)/sysconst.pp

+        $(COMPILER) $(OBJPASDIR)/sysconst.pp
 dateutil$(PPUEXT) : $(OBJPASDIR)/dateutil.pp
-        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutil.pp

+        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/dateutil.pp
 convutil$(PPUEXT) : $(OBJPASDIR)/convutil.pp
-        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/convutil.pp

+        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/convutil.pp
 strutils$(PPUEXT) : $(OBJPASDIR)/strutils.pp
-        $(COMPILER) $(OBJPASDIR)/strutils.pp

+        $(COMPILER) $(OBJPASDIR)/strutils.pp
 #
 # Mac Pascal Model
-#

+#
 macpas$(PPUEXT) : $(INC)/macpas.pp system$(PPUEXT)
-        $(COMPILER) $(INC)/macpas.pp $(REDIR)

+        $(COMPILER) $(INC)/macpas.pp $(REDIR)
 #
 # Other system-independent RTL Units
-#

-cpu$(PPUEXT) : $(PROCINC)/cpu.pp system$(PPUEXT)

-mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) system$(PPUEXT)

-getopts$(PPUEXT) : $(INC)/getopts.pp system$(PPUEXT)

+#
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp system$(PPUEXT)
+mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) system$(PPUEXT)
+getopts$(PPUEXT) : $(INC)/getopts.pp system$(PPUEXT)
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp system$(PPUEXT)
-        $(COMPILER) -Sg $(INC)/heaptrc.pp

-lineinfo$(PPUEXT) : $(INC)/lineinfo.pp system$(PPUEXT)

-charset$(PPUEXT) : $(INC)/charset.pp system$(PPUEXT)

-ucomplex$(PPUEXT) : $(INC)/ucomplex.pp math$(PPUEXT) system$(PPUEXT)

+        $(COMPILER) -Sg $(INC)/heaptrc.pp
+lineinfo$(PPUEXT) : $(INC)/lineinfo.pp system$(PPUEXT)
+charset$(PPUEXT) : $(INC)/charset.pp system$(PPUEXT)
+ucomplex$(PPUEXT) : $(INC)/ucomplex.pp math$(PPUEXT) system$(PPUEXT)
 #
 # Other system-dependent RTL Units
-#

-msmouse$(PPUEXT) : msmouse.pp system$(PPUEXT)

+#
+msmouse$(PPUEXT) : msmouse.pp system$(PPUEXT)
 callspec$(PPUEXT) : $(INC)/callspec.pp system$(PPUEXT)

+ 157 - 0
rtl/go32v2/sysdir.inc

@@ -0,0 +1,157 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
+    member of the Free Pascal development team.
+
+    FPC Pascal system unit for the Win32 API.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{*****************************************************************************
+                           Directory Handling
+*****************************************************************************}
+
+procedure DosDir(func:byte;const s:string);
+var
+  buffer : array[0..255] of char;
+  regs   : trealregs;
+begin
+  move(s[1],buffer,length(s));
+  buffer[length(s)]:=#0;
+  AllowSlash(pchar(@buffer));
+  { True DOS does not like backslashes at end
+    Win95 DOS accepts this !!
+    but "\" and "c:\" should still be kept and accepted hopefully PM }
+  if (length(s)>0) and (buffer[length(s)-1]='\') and
+     Not ((length(s)=1) or ((length(s)=3) and (s[2]=':'))) then
+    buffer[length(s)-1]:=#0;
+  syscopytodos(longint(@buffer),length(s)+1);
+  regs.realedx:=tb_offset;
+  regs.realds:=tb_segment;
+  if LFNSupport then
+   regs.realeax:=$7100+func
+  else
+   regs.realeax:=func shl 8;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   GetInOutRes(lo(regs.realeax));
+end;
+
+
+procedure mkdir(const s : string);[IOCheck];
+begin
+  If (s='') or (InOutRes <> 0) then
+   exit;
+  DosDir($39,s);
+end;
+
+
+procedure rmdir(const s : string);[IOCheck];
+begin
+  if (s = '.' ) then
+    InOutRes := 16;
+  If (s='') or (InOutRes <> 0) then
+   exit;
+  DosDir($3a,s);
+end;
+
+
+procedure chdir(const s : string);[IOCheck];
+var
+  regs : trealregs;
+begin
+  If (s='') or (InOutRes <> 0) then
+   exit;
+{ First handle Drive changes }
+  if (length(s)>=2) and (s[2]=':') then
+   begin
+     regs.realedx:=(ord(s[1]) and (not 32))-ord('A');
+     regs.realeax:=$0e00;
+     sysrealintr($21,regs);
+     regs.realeax:=$1900;
+     sysrealintr($21,regs);
+     if byte(regs.realeax)<>byte(regs.realedx) then
+      begin
+        Inoutres:=15;
+        exit;
+      end;
+     { DosDir($3b,'c:') give Path not found error on
+       pure DOS PM }
+     if length(s)=2 then
+       exit;
+   end;
+{ do the normal dos chdir }
+  DosDir($3b,s);
+end;
+
+
+procedure GetDir (DriveNr: byte; var Dir: ShortString);
+var
+  temp : array[0..255] of char;
+  i    : longint;
+  regs : trealregs;
+begin
+  regs.realedx:=drivenr;
+  regs.realesi:=tb_offset;
+  regs.realds:=tb_segment;
+  if LFNSupport then
+   regs.realeax:=$7147
+  else
+   regs.realeax:=$4700;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   Begin
+     GetInOutRes (lo(regs.realeax));
+     Dir := char (DriveNr + 64) + ':\';
+     exit;
+   end
+  else
+   syscopyfromdos(longint(@temp),251);
+{ conversion to Pascal string including slash conversion }
+  i:=0;
+  while (temp[i]<>#0) do
+   begin
+     if temp[i]='/' then
+      temp[i]:='\';
+     dir[i+4]:=temp[i];
+     inc(i);
+   end;
+  dir[2]:=':';
+  dir[3]:='\';
+  dir[0]:=char(i+3);
+{ upcase the string }
+  if not FileNameCaseSensitive then
+   dir:=upcase(dir);
+  if drivenr<>0 then   { Drive was supplied. We know it }
+   dir[1]:=char(65+drivenr-1)
+  else
+   begin
+   { We need to get the current drive from DOS function 19H  }
+   { because the drive was the default, which can be unknown }
+     regs.realeax:=$1900;
+     sysrealintr($21,regs);
+     i:= (regs.realeax and $ff) + ord('A');
+     dir[1]:=chr(i);
+   end;
+end;
+
+
+
+{
+  $Log$
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
+
+}

+ 460 - 0
rtl/go32v2/sysfile.inc

@@ -0,0 +1,460 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    Low leve file functions
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+   { Keep Track of open files }
+   const
+      max_files = 50;
+   var
+      openfiles : array [0..max_files-1] of boolean;
+{$ifdef SYSTEMDEBUG}
+      opennames : array [0..max_files-1] of pchar;
+   const
+      free_closed_names : boolean = true;
+{$endif SYSTEMDEBUG}
+
+
+{****************************************************************************
+                        Low level File Routines
+ ****************************************************************************}
+
+procedure AllowSlash(p:pchar);
+var
+  i : longint;
+begin
+{ allow slash as backslash }
+  for i:=0 to strlen(p) do
+   if p[i]='/' then p[i]:='\';
+end;
+
+procedure do_close(handle : thandle);
+var
+  regs : trealregs;
+begin
+  if Handle<=4 then
+   exit;
+  regs.realebx:=handle;
+  if handle<max_files then
+    begin
+       openfiles[handle]:=false;
+{$ifdef SYSTEMDEBUG}
+       if assigned(opennames[handle]) and free_closed_names then
+         begin
+            sysfreememsize(opennames[handle],strlen(opennames[handle])+1);
+            opennames[handle]:=nil;
+         end;
+{$endif SYSTEMDEBUG}
+    end;
+  regs.realeax:=$3e00;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   GetInOutRes(lo(regs.realeax));
+end;
+
+
+procedure do_erase(p : pchar);
+var
+  regs : trealregs;
+begin
+  AllowSlash(p);
+  syscopytodos(longint(p),strlen(p)+1);
+  regs.realedx:=tb_offset;
+  regs.realds:=tb_segment;
+  if LFNSupport then
+   regs.realeax:=$7141
+  else
+   regs.realeax:=$4100;
+  regs.realesi:=0;
+  regs.realecx:=0;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   GetInOutRes(lo(regs.realeax));
+end;
+
+
+procedure do_rename(p1,p2 : pchar);
+var
+  regs : trealregs;
+begin
+  AllowSlash(p1);
+  AllowSlash(p2);
+  if strlen(p1)+strlen(p2)+3>tb_size then
+   HandleError(217);
+  sysseg_move(get_ds,longint(p2),dos_selector,tb,strlen(p2)+1);
+  sysseg_move(get_ds,longint(p1),dos_selector,tb+strlen(p2)+2,strlen(p1)+1);
+  regs.realedi:=tb_offset;
+  regs.realedx:=tb_offset + strlen(p2)+2;
+  regs.realds:=tb_segment;
+  regs.reales:=tb_segment;
+  if LFNSupport then
+   regs.realeax:=$7156
+  else
+   regs.realeax:=$5600;
+  regs.realecx:=$ff;            { attribute problem here ! }
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   GetInOutRes(lo(regs.realeax));
+end;
+
+
+function do_write(h:thandle;addr:pointer;len : longint) : longint;
+var
+  regs      : trealregs;
+  size,
+  writesize : longint;
+begin
+  writesize:=0;
+  while len > 0 do
+   begin
+     if len>tb_size then
+      size:=tb_size
+     else
+      size:=len;
+     syscopytodos(ptrint(addr)+writesize,size);
+     regs.realecx:=size;
+     regs.realedx:=tb_offset;
+     regs.realds:=tb_segment;
+     regs.realebx:=h;
+     regs.realeax:=$4000;
+     sysrealintr($21,regs);
+     if (regs.realflags and carryflag) <> 0 then
+      begin
+        GetInOutRes(lo(regs.realeax));
+        exit(writesize);
+      end;
+     inc(writesize,lo(regs.realeax));
+     dec(len,lo(regs.realeax));
+     { stop when not the specified size is written }
+     if lo(regs.realeax)<size then
+      break;
+   end;
+  Do_Write:=WriteSize;
+end;
+
+
+function do_read(h:thandle;addr:pointer;len : longint) : longint;
+var
+  regs     : trealregs;
+  size,
+  readsize : longint;
+begin
+  readsize:=0;
+  while len > 0 do
+   begin
+     if len>tb_size then
+      size:=tb_size
+     else
+      size:=len;
+     regs.realecx:=size;
+     regs.realedx:=tb_offset;
+     regs.realds:=tb_segment;
+     regs.realebx:=h;
+     regs.realeax:=$3f00;
+     sysrealintr($21,regs);
+     if (regs.realflags and carryflag) <> 0 then
+      begin
+        GetInOutRes(lo(regs.realeax));
+        do_read:=0;
+        exit;
+      end;
+     syscopyfromdos(ptrint(addr)+readsize,lo(regs.realeax));
+     inc(readsize,lo(regs.realeax));
+     dec(len,lo(regs.realeax));
+     { stop when not the specified size is read }
+     if lo(regs.realeax)<size then
+      break;
+   end;
+  do_read:=readsize;
+end;
+
+
+function do_filepos(handle : thandle) : longint;
+var
+  regs : trealregs;
+begin
+  regs.realebx:=handle;
+  regs.realecx:=0;
+  regs.realedx:=0;
+  regs.realeax:=$4201;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   Begin
+     GetInOutRes(lo(regs.realeax));
+     do_filepos:=0;
+   end
+  else
+   do_filepos:=lo(regs.realedx) shl 16+lo(regs.realeax);
+end;
+
+
+procedure do_seek(handle:thandle;pos : longint);
+var
+  regs : trealregs;
+begin
+  regs.realebx:=handle;
+  regs.realecx:=pos shr 16;
+  regs.realedx:=pos and $ffff;
+  regs.realeax:=$4200;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   GetInOutRes(lo(regs.realeax));
+end;
+
+
+
+function do_seekend(handle:thandle):longint;
+var
+  regs : trealregs;
+begin
+  regs.realebx:=handle;
+  regs.realecx:=0;
+  regs.realedx:=0;
+  regs.realeax:=$4202;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   Begin
+     GetInOutRes(lo(regs.realeax));
+     do_seekend:=0;
+   end
+  else
+   do_seekend:=lo(regs.realedx) shl 16+lo(regs.realeax);
+end;
+
+
+function do_filesize(handle : thandle) : longint;
+var
+  aktfilepos : longint;
+begin
+  aktfilepos:=do_filepos(handle);
+  do_filesize:=do_seekend(handle);
+  do_seek(handle,aktfilepos);
+end;
+
+
+{ truncate at a given position }
+procedure do_truncate (handle:thandle;pos:longint);
+var
+  regs : trealregs;
+begin
+  do_seek(handle,pos);
+  regs.realecx:=0;
+  regs.realedx:=tb_offset;
+  regs.realds:=tb_segment;
+  regs.realebx:=handle;
+  regs.realeax:=$4000;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   GetInOutRes(lo(regs.realeax));
+end;
+
+const
+  FileHandleCount : longint = 20;
+
+function Increase_file_handle_count : boolean;
+var
+  regs : trealregs;
+begin
+  Inc(FileHandleCount,10);
+  regs.realebx:=FileHandleCount;
+  regs.realeax:=$6700;
+  sysrealintr($21,regs);
+  if (regs.realflags and carryflag) <> 0 then
+   begin
+    Increase_file_handle_count:=false;
+    Dec (FileHandleCount, 10);
+   end
+  else
+    Increase_file_handle_count:=true;
+end;
+
+
+function dos_version : word;
+var
+  regs   : trealregs;
+begin
+  regs.realeax := $3000;
+  sysrealintr($21,regs);
+  dos_version := regs.realeax
+end;
+
+
+procedure do_open(var f;p:pchar;flags:longint);
+{
+  filerec and textrec have both handle and mode as the first items so
+  they could use the same routine for opening/creating.
+  when (flags and $100)   the file will be append
+  when (flags and $1000)  the file will be truncate/rewritten
+  when (flags and $10000) there is no check for close (needed for textfiles)
+}
+var
+  regs   : trealregs;
+  action : longint;
+begin
+  AllowSlash(p);
+{ close first if opened }
+  if ((flags and $10000)=0) then
+   begin
+     case filerec(f).mode of
+      fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
+      fmclosed : ;
+     else
+      begin
+        inoutres:=102; {not assigned}
+        exit;
+      end;
+     end;
+   end;
+{ reset file handle }
+  filerec(f).handle:=UnusedHandle;
+  action:=$1;
+{ convert filemode to filerec modes }
+  case (flags and 3) of
+   0 : filerec(f).mode:=fminput;
+   1 : filerec(f).mode:=fmoutput;
+   2 : filerec(f).mode:=fminout;
+  end;
+  if (flags and $1000)<>0 then
+   action:=$12; {create file function}
+{ empty name is special }
+  if p[0]=#0 then
+   begin
+     case FileRec(f).mode of
+       fminput :
+         FileRec(f).Handle:=StdInputHandle;
+       fminout, { this is set by rewrite }
+       fmoutput :
+         FileRec(f).Handle:=StdOutputHandle;
+       fmappend :
+         begin
+           FileRec(f).Handle:=StdOutputHandle;
+           FileRec(f).mode:=fmoutput; {fool fmappend}
+         end;
+     end;
+     exit;
+   end;
+{ real dos call }
+  syscopytodos(longint(p),strlen(p)+1);
+{$ifndef RTLLITE}
+  if LFNSupport then
+   begin
+     regs.realeax := $716c;                        { Use LFN Open/Create API }
+     regs.realedx := action;             { action if file does/doesn't exist }
+     regs.realesi := tb_offset;
+     regs.realebx := $2000 + (flags and $ff);               { file open mode }
+   end
+  else
+{$endif RTLLITE}
+   begin
+     if (action and $00f0) <> 0 then
+       regs.realeax := $3c00                     { Map to Create/Replace API }
+     else
+       regs.realeax := $3d00 + (flags and $ff);   { Map to Open_Existing API }
+     regs.realedx := tb_offset;
+   end;
+  regs.realds := tb_segment;
+  regs.realecx := $20;                                     { file attributes }
+  sysrealintr($21,regs);
+{$ifndef RTLLITE}
+  if (regs.realflags and carryflag) <> 0 then
+    if lo(regs.realeax)=4 then
+      if Increase_file_handle_count then
+        begin
+          { Try again }
+          if LFNSupport then
+            begin
+              regs.realeax := $716c;                 {Use LFN Open/Create API}
+              regs.realedx := action;      {action if file does/doesn't exist}
+              regs.realesi := tb_offset;
+              regs.realebx := $2000 + (flags and $ff);        {file open mode}
+            end
+          else
+            begin
+              if (action and $00f0) <> 0 then
+                regs.realeax := $3c00              {Map to Create/Replace API}
+              else
+                regs.realeax := $3d00 + (flags and $ff);     {Map to Open API}
+              regs.realedx := tb_offset;
+            end;
+          regs.realds := tb_segment;
+          regs.realecx := $20;                               {file attributes}
+          sysrealintr($21,regs);
+        end;
+{$endif RTLLITE}
+  if (regs.realflags and carryflag) <> 0 then
+    begin
+      GetInOutRes(lo(regs.realeax));
+      exit;
+    end
+  else
+    begin
+      filerec(f).handle:=lo(regs.realeax);
+{$ifndef RTLLITE}
+      { for systems that have more then 20 by default ! }
+      if lo(regs.realeax)>FileHandleCount then
+        FileHandleCount:=lo(regs.realeax);
+{$endif RTLLITE}
+    end;
+  if lo(regs.realeax)<max_files then
+    begin
+{$ifdef SYSTEMDEBUG}
+       if openfiles[lo(regs.realeax)] and
+          assigned(opennames[lo(regs.realeax)]) then
+         begin
+            Writeln(stderr,'file ',opennames[lo(regs.realeax)],'(',lo(regs.realeax),') not closed but handle reused!');
+            sysfreememsize(opennames[lo(regs.realeax)],strlen(opennames[lo(regs.realeax)])+1);
+         end;
+{$endif SYSTEMDEBUG}
+       openfiles[lo(regs.realeax)]:=true;
+{$ifdef SYSTEMDEBUG}
+       opennames[lo(regs.realeax)] := sysgetmem(strlen(p)+1);
+       move(p^,opennames[lo(regs.realeax)]^,strlen(p)+1);
+{$endif SYSTEMDEBUG}
+    end;
+{ append mode }
+  if ((flags and $100) <> 0) and
+   (FileRec (F).Handle <> UnusedHandle) then
+   begin
+     do_seekend(filerec(f).handle);
+     filerec(f).mode:=fmoutput; {fool fmappend}
+   end;
+end;
+
+
+function do_isdevice(handle:THandle):boolean;
+var
+  regs : trealregs;
+begin
+  regs.realebx:=handle;
+  regs.realeax:=$4400;
+  sysrealintr($21,regs);
+  do_isdevice:=(regs.realedx and $80)<>0;
+  if (regs.realflags and carryflag) <> 0 then
+   GetInOutRes(lo(regs.realeax));
+end;
+
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 70 - 0
rtl/go32v2/sysheap.inc

@@ -0,0 +1,70 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+{*****************************************************************************
+                              Heap Management
+*****************************************************************************}
+
+function __sbrk(size:longint):longint;cdecl;external;
+
+function SysOSAlloc (size: PtrInt): pointer; assembler;
+asm
+{$ifdef SYSTEMDEBUG}
+        cmpb    $1,accept_sbrk
+        je      .Lsbrk
+        movl    $0,%eax
+        jmp     .Lsbrk_fail
+      .Lsbrk:
+{$endif}
+        movl    size,%eax
+        pushl   %eax
+        call    __sbrk
+        addl    $4,%esp
+{$ifdef SYSTEMDEBUG}
+      .Lsbrk_fail:
+{$endif}
+end;
+
+{*****************************************************************************
+      OS Memory allocation / deallocation
+ ****************************************************************************}
+
+{function SysOSAlloc(size: ptrint): pointer;
+begin
+  result := sbrk(size);
+end;
+}
+{.$define HAS_SYSOSFREE}
+
+procedure SysOSFree(p: pointer; size: ptrint);
+begin
+end;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 341 - 0
rtl/go32v2/sysos.inc

@@ -0,0 +1,341 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+const
+  carryflag = 1;
+
+type
+  tseginfo=packed record
+    offset  : pointer;
+    segment : word;
+  end;
+
+var
+  old_int00 : tseginfo;cvar;
+  old_int75 : tseginfo;cvar;
+
+{$asmmode ATT}
+
+{*****************************************************************************
+                              Go32 Helpers
+*****************************************************************************}
+
+function far_strlen(selector : word;linear_address : longint) : longint;assembler;
+asm
+        movl linear_address,%edx
+        movl %edx,%ecx
+        movw selector,%gs
+.Larg19:
+        movb %gs:(%edx),%al
+        testb %al,%al
+        je .Larg20
+        incl %edx
+        jmp .Larg19
+.Larg20:
+        movl %edx,%eax
+        subl %ecx,%eax
+end;
+
+
+function tb : longint;
+begin
+  tb:=go32_info_block.linear_address_of_transfer_buffer;
+end;
+
+
+function tb_segment : longint;
+begin
+  tb_segment:=go32_info_block.linear_address_of_transfer_buffer shr 4;
+end;
+
+
+function tb_offset : longint;
+begin
+  tb_offset:=go32_info_block.linear_address_of_transfer_buffer and $f;
+end;
+
+
+function tb_size : longint;
+begin
+  tb_size:=go32_info_block.size_of_transfer_buffer;
+end;
+
+
+function dos_selector : word;
+begin
+  dos_selector:=go32_info_block.selector_for_linear_memory;
+end;
+
+
+function get_ds : word;assembler;
+asm
+        movw    %ds,%ax
+end;
+
+
+function get_cs : word;assembler;
+asm
+        movw    %cs,%ax
+end;
+
+
+procedure sysseg_move(sseg : word;source : longint;dseg : word;dest : longint;count : longint);
+begin
+   if count=0 then
+     exit;
+   if (sseg<>dseg) or ((sseg=dseg) and (source>dest)) then
+     asm
+        pushl %esi
+        pushl %edi
+        pushw %es
+        pushw %ds
+        cld
+        movl count,%ecx
+        movl source,%esi
+        movl dest,%edi
+        movw dseg,%ax
+        movw %ax,%es
+        movw sseg,%ax
+        movw %ax,%ds
+        movl %ecx,%eax
+        shrl $2,%ecx
+        rep
+        movsl
+        movl %eax,%ecx
+        andl $3,%ecx
+        rep
+        movsb
+        popw %ds
+        popw %es
+        popl %edi
+        popl %esi
+     end
+   else if (source<dest) then
+     { copy backward for overlapping }
+     asm
+        pushl %esi
+        pushl %edi
+        pushw %es
+        pushw %ds
+        std
+        movl count,%ecx
+        movl source,%esi
+        movl dest,%edi
+        movw dseg,%ax
+        movw %ax,%es
+        movw sseg,%ax
+        movw %ax,%ds
+        addl %ecx,%esi
+        addl %ecx,%edi
+        movl %ecx,%eax
+        andl $3,%ecx
+        orl %ecx,%ecx
+        jz .LSEG_MOVE1
+
+        { calculate esi and edi}
+        decl %esi
+        decl %edi
+        rep
+        movsb
+        incl %esi
+        incl %edi
+     .LSEG_MOVE1:
+        subl $4,%esi
+        subl $4,%edi
+        movl %eax,%ecx
+        shrl $2,%ecx
+        rep
+        movsl
+        cld
+        popw %ds
+        popw %es
+        popl %edi
+        popl %esi
+     end;
+end;
+
+
+function strcopy(dest,source : pchar) : pchar;assembler;
+var
+  saveeax,saveesi,saveedi : longint;
+asm
+        movl    %edi,saveedi
+        movl    %esi,saveesi
+{$ifdef REGCALL}
+        movl    %eax,saveeax
+        movl    %edx,%edi
+{$else}
+        movl    source,%edi
+{$endif}
+        testl   %edi,%edi
+        jz      .LStrCopyDone
+        leal    3(%edi),%ecx
+        andl    $-4,%ecx
+        movl    %edi,%esi
+        subl    %edi,%ecx
+{$ifdef REGCALL}
+        movl    %eax,%edi
+{$else}
+        movl    dest,%edi
+{$endif}
+        jz      .LStrCopyAligned
+.LStrCopyAlignLoop:
+        movb    (%esi),%al
+        incl    %edi
+        incl    %esi
+        testb   %al,%al
+        movb    %al,-1(%edi)
+        jz      .LStrCopyDone
+        decl    %ecx
+        jnz     .LStrCopyAlignLoop
+        .balign  16
+.LStrCopyAligned:
+        movl    (%esi),%eax
+        movl    %eax,%edx
+        leal    0x0fefefeff(%eax),%ecx
+        notl    %edx
+        addl    $4,%esi
+        andl    %edx,%ecx
+        andl    $0x080808080,%ecx
+        jnz     .LStrCopyEndFound
+        movl    %eax,(%edi)
+        addl    $4,%edi
+        jmp     .LStrCopyAligned
+.LStrCopyEndFound:
+        testl   $0x0ff,%eax
+        jz      .LStrCopyByte
+        testl   $0x0ff00,%eax
+        jz      .LStrCopyWord
+        testl   $0x0ff0000,%eax
+        jz      .LStrCopy3Bytes
+        movl    %eax,(%edi)
+        jmp     .LStrCopyDone
+.LStrCopy3Bytes:
+        xorb     %dl,%dl
+        movw     %ax,(%edi)
+        movb     %dl,2(%edi)
+        jmp     .LStrCopyDone
+.LStrCopyWord:
+        movw    %ax,(%edi)
+        jmp     .LStrCopyDone
+.LStrCopyByte:
+        movb    %al,(%edi)
+.LStrCopyDone:
+{$ifdef REGCALL}
+        movl    saveeax,%eax
+{$else}
+        movl    dest,%eax
+{$endif}
+        movl    saveedi,%edi
+        movl    saveesi,%esi
+end;
+
+
+procedure syscopytodos(addr : longint; len : longint);
+begin
+   if len > tb_size then
+     HandleError(217);
+   sysseg_move(get_ds,addr,dos_selector,tb,len);
+end;
+
+
+procedure syscopyfromdos(addr : longint; len : longint);
+begin
+   if len > tb_size then
+     HandleError(217);
+   sysseg_move(dos_selector,tb,get_ds,addr,len);
+end;
+
+
+procedure sysrealintr(intnr : word;var regs : trealregs);
+begin
+   regs.realsp:=0;
+   regs.realss:=0;
+   asm
+      pushl %ebx
+      pushl %edi
+      movw  intnr,%bx
+      xorl  %ecx,%ecx
+      movl  regs,%edi
+      movw  $0x300,%ax
+      int   $0x31
+      popl  %edi
+      popl  %ebx
+   end;
+end;
+
+
+procedure set_pm_interrupt(vector : byte;const intaddr : tseginfo);
+begin
+  asm
+        pushl   %ebx
+        movl intaddr,%eax
+        movl (%eax),%edx
+        movw 4(%eax),%cx
+        movl $0x205,%eax
+        movb vector,%bl
+        int $0x31
+        popl  %ebx
+  end;
+end;
+
+
+procedure get_pm_interrupt(vector : byte;var intaddr : tseginfo);
+begin
+  asm
+        pushl   %ebx
+        movb    vector,%bl
+        movl    $0x204,%eax
+        int     $0x31
+        movl    intaddr,%eax
+        movl    %edx,(%eax)
+        movw    %cx,4(%eax)
+        popl  %ebx
+  end;
+end;
+
+
+procedure getinoutres(def : word);
+var
+  regs : trealregs;
+begin
+  regs.realeax:=$5900;
+  regs.realebx:=$0;
+  sysrealintr($21,regs);
+  InOutRes:=lo(regs.realeax);
+  case InOutRes of
+   19 : InOutRes:=150;
+   21 : InOutRes:=152;
+   32 : InOutRes:=5;
+  end;
+  if InOutRes=0 then
+    InOutRes:=Def;
+end;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 39 - 0
rtl/go32v2/sysosh.inc

@@ -0,0 +1,39 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{Platform specific information}
+type
+  THandle = Longint;
+
+     PRTLCriticalSection = ^TRTLCriticalSection;
+     TRTLCriticalSection = record
+       Locked: boolean
+     end;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

Файловите разлики са ограничени, защото са твърде много
+ 5 - 956
rtl/go32v2/system.pp


+ 39 - 0
rtl/go32v2/systhrd.inc

@@ -0,0 +1,39 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2002 by Peter Vreman,
+    member of the Free Pascal development team.
+
+    Linux (pthreads) threading support implementation
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+Procedure InitSystemThreads;
+begin
+  { This should be changed to a real value during
+    thread driver initialization if appropriate. }
+  ThreadID := 1;
+  SetNoThreadManager;
+end;
+
+{
+  $Log$
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.1  2005/02/06 12:16:52  peter
+    * bsd thread updates
+
+  Revision 1.1  2005/02/06 11:20:52  peter
+    * threading in system unit
+    * removed systhrds unit
+
+}
+

+ 0 - 51
rtl/go32v2/systhrds.pp

@@ -1,51 +0,0 @@
-{
-    $Id$
-    This file is part of the Free Pascal run time library.
-    Copyright (c) 2002 by Peter Vreman,
-    member of the Free Pascal development team.
-
-    Dummy implementation for platforms not having real one
-
-    See the file COPYING.FPC, included in this distribution,
-    for details about the copyright.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- **********************************************************************}
-
-unit systhrds;
-{$mode objfpc}
-
-interface
-
-  type
-     PRTLCriticalSection = ^TRTLCriticalSection;
-     TRTLCriticalSection = record
-       Locked: boolean
-     end;
-
-{ Include generic thread interface }
-{$i threadh.inc}
-
-implementation
-
-{ Include generic overloaded routines }
-{$i thread.inc}
-
-{ Include OS independent threadvar initialization }
-{$ifdef HASTHREADVAR}
-{$i threadvr.inc}
-{$endif HASTHREADVAR}
-
-initialization
-  SetNoThreadManager;
-end.
-{
-  $Log$
-  Revision 1.1  2005-01-21 21:43:12  armin
-  * applied patch to compile go32v2 from Tomas (tested by John)
-
-
-}

+ 7 - 4
rtl/inc/system.inc

@@ -1023,15 +1023,15 @@ end;
                           Thread support
 *****************************************************************************}
 
-{ OS Dependent implementation }
-{$i systhrd.inc}
-
 { Generic threadmanager }
 {$i thread.inc}
 
 { Generic threadvar support }
 {$i threadvr.inc}
 
+{ OS Dependent implementation }
+{$i systhrd.inc}
+
 
 {*****************************************************************************
                             File Handling
@@ -1060,7 +1060,10 @@ end;
 
 {
   $Log$
-  Revision 1.73  2005-02-06 13:06:20  peter
+  Revision 1.74  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.73  2005/02/06 13:06:20  peter
     * moved file and dir functions to sysfile/sysdir
     * win32 thread in systemunit
 

+ 67 - 68
rtl/netware/Makefile

@@ -255,103 +255,103 @@ nlmlib.imp nwpsrv3x.imp nwpsrv.imp nwsnut.imp \
 requestr.imp socklib.imp streams.imp threads.imp \
 tli.imp vollib.imp ws2_32.imp ws2nlm.imp unicode.imp
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix dos crt objects sysconst initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_LOADERS+=nwpre prelude
@@ -453,103 +453,103 @@ ifeq ($(FULL_TARGET),arm-linux)
 override TARGET_LOADERS+=nwpre prelude
 endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+override TARGET_RSTS+=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
@@ -1975,7 +1975,6 @@ objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
 		   $(SYSTEMUNIT)$(PPUEXT)
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
 netware$(PPUEXT) : netware.pp $(SYSTEMUNIT)$(PPUEXT)
 winsock$(PPUEXT) : winsock.pp $(SYSTEMUNIT)$(PPUEXT)
 sockets$(PPUEXT) : sockets.pp netware$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
@@ -1989,7 +1988,7 @@ sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
 	$(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp
 classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
 		   sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconst$(PPUEXT) \
-		   sysconst$(PPUEXT) types$(PPUEXT) systhrds$(PPUEXT)
+		   sysconst$(PPUEXT) types$(PPUEXT)
 	$(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp
 typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
 	$(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp

+ 3 - 4
rtl/netware/Makefile.fpc

@@ -10,14 +10,14 @@ loaders=nwpre prelude
 units=$(SYSTEMUNIT) objpas macpas strings \
       lineinfo winsock heaptrc matrix \
       dos crt objects sysconst \
-      initc sysutils types typinfo systhrds classes \
+      initc sysutils types typinfo classes \
       cpu mmx getopts \
       dateutils strutils convutils \
       charset ucomplex variants \
       rtlconst math varutils freebidi utf8bidi \
       mouse video keyboard cmem sockets \
       aio nwsnut nwserv nwnit nwprot netware nwcalls ctypes
-rsts=math varutils variants typinfo classes dateutils sysconst convutils rtlconst systhrds
+rsts=math varutils variants typinfo classes dateutils sysconst convutils rtlconst
 
 [require]
 nortl=y
@@ -127,7 +127,6 @@ objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
                    $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
                    $(SYSTEMUNIT)$(PPUEXT)
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
 
 #
 # System Dependent Units
@@ -165,7 +164,7 @@ sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
 
 classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
                    sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconst$(PPUEXT) \
-                   sysconst$(PPUEXT) types$(PPUEXT) systhrds$(PPUEXT)
+                   sysconst$(PPUEXT) types$(PPUEXT)
         $(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp
 
 typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)

+ 5 - 3
rtl/netware/classes.pp

@@ -27,8 +27,7 @@ uses
   sysutils,
   types,
   typinfo,
-  rtlconst,
-  systhrds;
+  rtlconst;
 	
 
 {$i classesh.inc}
@@ -48,7 +47,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.5  2004-09-26 19:25:49  armin
+  Revision 1.6  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.5  2004/09/26 19:25:49  armin
   * exiting threads at nlm unload
 
   Revision 1.4  2004/08/01 20:02:48  armin

+ 98 - 0
rtl/netware/sysdir.inc

@@ -0,0 +1,98 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
+    member of the Free Pascal development team.
+
+    FPC Pascal system unit for the Win32 API.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{*****************************************************************************
+                           Directory Handling
+*****************************************************************************}
+procedure mkdir(const s : string);[IOCheck];
+VAR S2 : STRING;
+    Res: LONGINT;
+BEGIN
+  S2 := S;
+  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
+  S2 := S2 + #0;
+  Res := _mkdir (@S2[1]);
+  IF Res = 0 THEN
+    InOutRes:=0
+  ELSE
+    SetFileError (Res);
+END;
+
+procedure rmdir(const s : string);[IOCheck];
+VAR S2 : STRING;
+    Res: LONGINT;
+BEGIN
+  S2 := S;
+  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
+  S2 := S2 + #0;
+  Res := _rmdir (@S2[1]);
+  IF Res = 0 THEN
+    InOutRes:=0
+  ELSE
+    SetFileError (Res);
+end;
+
+procedure chdir(const s : string);[IOCheck];
+VAR S2 : STRING;
+    Res: LONGINT;
+begin
+  S2 := S;
+  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
+  S2 := S2 + #0;
+  Res := _chdir (@S2[1]);
+  IF Res = 0 THEN
+    InOutRes:=0
+  ELSE
+    SetFileError (Res);
+end;
+
+procedure getdir(drivenr : byte;var dir : shortstring);
+VAR P : ARRAY [0..255] OF CHAR;
+    i : LONGINT;
+begin
+  P[0] := #0;
+  _getcwd (@P, SIZEOF (P));
+  i := _strlen (P);
+  if i > 0 then
+  begin
+    Move (P, dir[1], i);
+    BYTE(dir[0]) := i;
+    For i := 1 to length (dir) do
+      if dir[i] = '\' then dir [i] := '/';
+    // fix / after volume, the compiler needs that
+    // normaly root of a volumes is SERVERNAME/SYS:, change that
+    // to SERVERNAME/SYS:/
+    i := pos (':',dir);
+    if (i > 0) then
+      if i = Length (dir) then dir := dir + '/' else
+      if dir [i+1] <> '/' then insert ('/',dir,i+1);
+  END ELSE
+    InOutRes := 1;
+end;
+
+
+
+{
+  $Log$
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
+
+}

+ 290 - 0
rtl/netware/sysfile.inc

@@ -0,0 +1,290 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    Low leve file functions
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+{****************************************************************************
+                        Low level File Routines
+       All these functions can set InOutRes on errors
+ ****************************************************************************}
+
+
+PROCEDURE NW2PASErr (Err : LONGINT);
+BEGIN
+  if Err = 0 then { Else it will go through all the cases }
+   exit;
+  case Err of
+   Sys_ENFILE,
+   Sys_EMFILE : Inoutres:=4;
+   Sys_ENOENT : Inoutres:=2;
+    Sys_EBADF : Inoutres:=6;
+   Sys_ENOMEM,
+   Sys_EFAULT : Inoutres:=217;
+   Sys_EINVAL : Inoutres:=218;
+    Sys_EPIPE,
+    Sys_EINTR,
+      Sys_EIO,
+   Sys_EAGAIN,
+   Sys_ENOSPC : Inoutres:=101;
+ Sys_ENAMETOOLONG,
+    Sys_ELOOP,
+  Sys_ENOTDIR : Inoutres:=3;
+    Sys_EROFS,
+   Sys_EEXIST,
+   Sys_EACCES : Inoutres:=5;
+  Sys_EBUSY   : Inoutres:=162;
+  end;
+END;
+
+FUNCTION errno : LONGINT;
+BEGIN
+  errno := __get_errno_ptr^;
+END;
+
+PROCEDURE Errno2Inoutres;
+BEGIN
+  NW2PASErr (errno);
+END;
+
+PROCEDURE SetFileError (VAR Err : LONGINT);
+BEGIN
+  IF Err >= 0 THEN
+    InOutRes := 0
+  ELSE
+  BEGIN
+    Err := errno;
+    NW2PASErr (Err);
+    Err := 0;
+  END;
+END;
+
+{ close a file from the handle value }
+procedure do_close(handle : thandle);
+VAR res : LONGINT;
+begin
+  res := _close (handle);
+  IF res <> 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0;
+end;
+
+procedure do_erase(p : pchar);
+VAR res : LONGINT;
+begin
+  res := _unlink (p);
+  IF Res < 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0;
+end;
+
+procedure do_rename(p1,p2 : pchar);
+VAR res : LONGINT;
+begin
+  res := _rename (p1,p2);
+  IF Res < 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0
+end;
+
+function do_write(h:thandle;addr:pointer;len : longint) : longint;
+VAR res : LONGINT;
+begin
+  res := _write (h,addr,len);
+  IF res > 0 THEN
+    InOutRes := 0
+  ELSE
+    SetFileError (res);
+  do_write := res;
+end;
+
+function do_read(h:thandle;addr:pointer;len : longint) : longint;
+VAR res : LONGINT;
+begin
+  res := _read (h,addr,len);
+  IF res > 0 THEN
+    InOutRes := 0
+  ELSE
+    SetFileError (res);
+  do_read := res;
+end;
+
+
+function do_filepos(handle : thandle) : longint;
+VAR res : LONGINT;
+begin
+  InOutRes:=1;
+  res := _tell (handle);
+  IF res < 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0;
+  do_filepos := res;
+end;
+
+CONST SEEK_SET = 0; // Seek from beginning of file.
+      SEEK_CUR = 1; // Seek from current position.
+      SEEK_END = 2; // Seek from end of file.
+
+
+procedure do_seek(handle:thandle;pos : longint);
+VAR res : LONGINT;
+begin
+  res := _lseek (handle,pos, SEEK_SET);
+  IF res >= 0 THEN
+    InOutRes := 0
+  ELSE
+    SetFileError (res);
+end;
+
+function do_seekend(handle:thandle):longint;
+VAR res : LONGINT;
+begin
+  res := _lseek (handle,0, SEEK_END);
+  IF res >= 0 THEN
+    InOutRes := 0
+  ELSE
+    SetFileError (res);
+  do_seekend := res;
+end;
+
+
+function do_filesize(handle : thandle) : longint;
+VAR res     : LONGINT;
+begin
+  res := _filelength (handle);
+  IF res < 0 THEN
+  BEGIN
+    SetFileError (Res);
+    do_filesize := -1;
+  END ELSE
+  BEGIN
+    InOutRes := 0;
+    do_filesize := res;
+  END;
+end;
+
+{ truncate at a given position }
+procedure do_truncate (handle:thandle;pos:longint);
+VAR res : LONGINT;
+begin
+  res := _chsize (handle,pos);
+  IF res <> 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0;
+end;
+
+// mostly stolen from syslinux
+procedure do_open(var f;p:pchar;flags:longint);
+{
+  filerec and textrec have both handle and mode as the first items so
+  they could use the same routine for opening/creating.
+  when (flags and $10)   the file will be append
+  when (flags and $100)  the file will be truncate/rewritten
+  when (flags and $1000) there is no check for close (needed for textfiles)
+}
+var
+  oflags : longint;
+Begin
+{ close first if opened }
+  if ((flags and $10000)=0) then
+   begin
+     case FileRec(f).mode of
+      fminput,fmoutput,fminout : Do_Close(FileRec(f).Handle);
+      fmclosed : ;
+     else
+      begin
+        inoutres:=102; {not assigned}
+        exit;
+      end;
+     end;
+   end;
+{ reset file Handle }
+  FileRec(f).Handle:=UnusedHandle;
+
+{ We do the conversion of filemodes here, concentrated on 1 place }
+  case (flags and 3) of
+   0 : begin
+         oflags := O_RDONLY;
+         filerec(f).mode := fminput;
+       end;
+   1 : begin
+         oflags := O_WRONLY;
+         filerec(f).mode := fmoutput;
+       end;
+   2 : begin
+         oflags := O_RDWR;
+         filerec(f).mode := fminout;
+       end;
+  end;
+  if (flags and $1000)=$1000 then
+   oflags:=oflags or (O_CREAT or O_TRUNC)
+  else
+   if (flags and $100)=$100 then
+    oflags:=oflags or (O_APPEND);
+{ empty name is special }
+  if p[0]=#0 then
+   begin
+     case FileRec(f).mode of
+       fminput :
+         FileRec(f).Handle:=StdInputHandle;
+       fminout, { this is set by rewrite }
+       fmoutput :
+         FileRec(f).Handle:=StdOutputHandle;
+       fmappend :
+         begin
+           FileRec(f).Handle:=StdOutputHandle;
+           FileRec(f).mode:=fmoutput; {fool fmappend}
+         end;
+     end;
+     exit;
+   end;
+{ real open call }
+  FileRec(f).Handle := _open(p,oflags,438);
+  //WriteLn ('_open (',p,') returned ',ErrNo, 'Handle: ',FileRec(f).Handle);
+  // errno does not seem to be set on succsess ??
+  IF FileRec(f).Handle < 0 THEN
+    if (ErrNo=Sys_EROFS) and ((OFlags and O_RDWR)<>0) then
+    begin  // i.e. for cd-rom
+      Oflags:=Oflags and not(O_RDWR);
+      FileRec(f).Handle := _open(p,oflags,438);
+    end;
+  IF FileRec(f).Handle < 0 THEN
+    Errno2Inoutres
+  ELSE
+    InOutRes := 0;
+End;
+
+function do_isdevice(handle:THandle):boolean;
+begin
+  do_isdevice := (_isatty (handle) > 0);
+end;
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 147 - 0
rtl/netware/sysheap.inc

@@ -0,0 +1,147 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{*****************************************************************************
+                              Heap Management
+*****************************************************************************}
+
+{$ifdef autoHeapRelease}
+
+const HeapInitialMaxBlocks = 32;
+type THeapSbrkBlockList = array [1.. HeapInitialMaxBlocks] of pointer;
+var  HeapSbrkBlockList : ^THeapSbrkBlockList = nil;
+     HeapSbrkLastUsed  : dword = 0;
+     HeapSbrkAllocated : dword = 0;
+
+{ function to allocate size bytes more for the program }
+{ must return the first address of new data space or nil if fail }
+{ for netware all allocated blocks are saved to free them at }
+{ exit (to avoid message "Module did not release xx resources") }
+Function Sbrk(size : longint):pointer;
+var P2 : POINTER;
+    i  : longint;
+begin
+  Sbrk := _malloc (size);
+  if Sbrk <> nil then begin
+    if HeapSbrkBlockList = nil then
+    begin
+      Pointer (HeapSbrkBlockList) := _malloc (sizeof (HeapSbrkBlockList^));
+      if HeapSbrkBlockList = nil then
+      begin
+        _free (Sbrk);
+        Sbrk := nil;
+        exit;
+      end;
+      fillchar (HeapSbrkBlockList^,sizeof(HeapSbrkBlockList^),0);
+      HeapSbrkAllocated := HeapInitialMaxBlocks;
+    end;
+    if (HeapSbrkLastUsed > 0) then
+      for i := 1 to HeapSbrkLastUsed do
+        if (HeapSbrkBlockList^[i] = nil) then
+        begin  // reuse free slot
+	  HeapSbrkBlockList^[i] := Sbrk;
+	  exit;
+        end;
+    if (HeapSbrkLastUsed = HeapSbrkAllocated) then
+    begin  { grow }
+      p2 := _realloc (HeapSbrkBlockList, (HeapSbrkAllocated + HeapInitialMaxBlocks) * sizeof(pointer));
+      if p2 = nil then  // should we better terminate with error ?
+      begin
+        _free (Sbrk);
+         Sbrk := nil;
+         exit;
+      end;
+      HeapSbrkBlockList := p2;
+      inc (HeapSbrkAllocated, HeapInitialMaxBlocks);
+    end;
+    inc (HeapSbrkLastUsed);
+    HeapSbrkBlockList^[HeapSbrkLastUsed] := Sbrk;
+  end;
+end;
+
+
+procedure FreeSbrkMem;
+var i : longint;
+begin
+  if HeapSbrkBlockList <> nil then
+  begin
+    for i := 1 to HeapSbrkLastUsed do
+      if (HeapSbrkBlockList^[i] <> nil) then
+        _free (HeapSbrkBlockList^[i]);
+    _free (HeapSbrkBlockList);
+    HeapSbrkAllocated := 0;
+    HeapSbrkLastUsed := 0;
+    HeapSbrkBlockList := nil;
+  end;
+end;
+
+{*****************************************************************************
+      OS Memory allocation / deallocation
+ ****************************************************************************}
+
+function SysOSAlloc(size: ptrint): pointer;
+begin
+  result := sbrk(size);
+end;
+
+{$define HAS_SYSOSFREE}
+
+procedure SysOSFree(p: pointer; size: ptrint);
+var i : longint;
+begin
+//fpmunmap(p, size);
+  if (HeapSbrkLastUsed > 0) then
+    for i := 1 to HeapSbrkLastUsed do
+      if (HeapSbrkBlockList^[i] = p) then
+      begin
+	_free (p);
+	HeapSbrkBlockList^[i] := nil;
+	exit;
+      end;
+  HandleError (204);  // invalid pointer operation
+end;
+
+{$else autoHeapRelease}
+
+{$define HAS_SYSOSFREE}
+
+procedure SysOSFree(p: pointer; size: ptrint);
+begin
+  _free (p);
+end;
+
+function SysOSAlloc(size: ptrint): pointer;
+begin
+  SysOSAlloc := _malloc (size);
+end;
+
+{$endif autoHeapRelease}
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 53 - 0
rtl/netware/sysos.inc

@@ -0,0 +1,53 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+{ some declarations for Netware API calls }
+{$I nwsys.inc}
+{$I errno.inc}
+
+
+var
+  CloseAllRemainingSemaphores : TSysCloseAllRemainingSemaphores = nil;
+  ReleaseThreadVars : TSysReleaseThreadVars = nil;
+  SetThreadDataAreaPtr : TSysSetThreadDataAreaPtr = nil;
+  TerminatingThreadID : longint = 0;  {used for unload, the signal handler will}
+                                      {be called from the console thread. avoid}
+                                      {calling _exit in another thread}
+
+procedure NWSysSetThreadFunctions (crs:TSysCloseAllRemainingSemaphores;
+                                   rtv:TSysReleaseThreadVars;
+				   stdata:TSysSetThreadDataAreaPtr);
+begin
+  CloseAllRemainingSemaphores := crs;
+  ReleaseThreadVars := rtv;
+  SetThreadDataAreaPtr := stdata;
+end;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 53 - 0
rtl/netware/sysosh.inc

@@ -0,0 +1,53 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+type
+  THandle = DWord;
+
+   { the fields of this record are os dependent  }
+   { and they shouldn't be used in a program     }
+   { only the type TCriticalSection is important }
+   PRTLCriticalSection = ^TRTLCriticalSection;
+   TRTLCriticalSection = packed record
+      SemaHandle : LONGINT;
+      SemaIsOpen : BOOLEAN;
+   end;
+
+{Delphi/Windows compatible priority constants, they are also defined for Unix and Win32}
+const
+   THREAD_PRIORITY_IDLE          = -15;
+   THREAD_PRIORITY_LOWEST        = -2;
+   THREAD_PRIORITY_BELOW_NORMAL  = -1;
+   THREAD_PRIORITY_NORMAL        = 0;
+   THREAD_PRIORITY_ABOVE_NORMAL  = 1;
+   THREAD_PRIORITY_HIGHEST       = 2;
+   THREAD_PRIORITY_TIME_CRITICAL = 15;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 5 - 501
rtl/netware/system.pp

@@ -33,8 +33,6 @@ interface
 
 {$I systemh.inc}
 
-type THandle = DWord;
-
 {Platform specific information}
 const
  LineEnding = #13#10;
@@ -45,8 +43,6 @@ const
 { FileNameCaseSensitive is defined separately below!!! }
  maxExitCode = 255;
 
-{ include heap support headers }
-{$I heaph.inc}
 
 CONST
   { Default filehandles }
@@ -103,28 +99,6 @@ implementation
 { include system independent routines }
 {$I system.inc}
 
-{ some declarations for Netware API calls }
-{$I nwsys.inc}
-{$I errno.inc}
-
-
-var
-  CloseAllRemainingSemaphores : TSysCloseAllRemainingSemaphores = nil;
-  ReleaseThreadVars : TSysReleaseThreadVars = nil;
-  SetThreadDataAreaPtr : TSysSetThreadDataAreaPtr = nil;
-  TerminatingThreadID : longint = 0;  {used for unload, the signal handler will}
-                                      {be called from the console thread. avoid}
-                                      {calling _exit in another thread}
-
-procedure NWSysSetThreadFunctions (crs:TSysCloseAllRemainingSemaphores;
-                                   rtv:TSysReleaseThreadVars;
-				   stdata:TSysSetThreadDataAreaPtr);
-begin
-  CloseAllRemainingSemaphores := crs;
-  ReleaseThreadVars := rtv;
-  SetThreadDataAreaPtr := stdata;
-end;
-
 //procedure __EnterDebugger; cdecl; external 'clib' name 'EnterDebugger';
 
 
@@ -163,10 +137,6 @@ end;
                          System Dependent Exit code
 *****************************************************************************}
 
-{$ifdef autoHeapRelease}
-procedure FreeSbrkMem; forward;
-{$endif}
-
 var SigTermHandlerActive : boolean;
 
 Procedure system_exit;
@@ -257,476 +227,6 @@ begin
   randseed := _time (NIL);
 end;
 
-{*****************************************************************************
-                              Heap Management
-*****************************************************************************}
-
-{$ifdef autoHeapRelease}
-
-const HeapInitialMaxBlocks = 32;
-type THeapSbrkBlockList = array [1.. HeapInitialMaxBlocks] of pointer;
-var  HeapSbrkBlockList : ^THeapSbrkBlockList = nil;
-     HeapSbrkLastUsed  : dword = 0;
-     HeapSbrkAllocated : dword = 0;
-
-{ function to allocate size bytes more for the program }
-{ must return the first address of new data space or nil if fail }
-{ for netware all allocated blocks are saved to free them at }
-{ exit (to avoid message "Module did not release xx resources") }
-Function Sbrk(size : longint):pointer;
-var P2 : POINTER;
-    i  : longint;
-begin
-  Sbrk := _malloc (size);
-  if Sbrk <> nil then begin
-    if HeapSbrkBlockList = nil then
-    begin
-      Pointer (HeapSbrkBlockList) := _malloc (sizeof (HeapSbrkBlockList^));
-      if HeapSbrkBlockList = nil then
-      begin
-        _free (Sbrk);
-        Sbrk := nil;
-        exit;
-      end;
-      fillchar (HeapSbrkBlockList^,sizeof(HeapSbrkBlockList^),0);
-      HeapSbrkAllocated := HeapInitialMaxBlocks;
-    end;
-    if (HeapSbrkLastUsed > 0) then
-      for i := 1 to HeapSbrkLastUsed do
-        if (HeapSbrkBlockList^[i] = nil) then
-        begin  // reuse free slot
-	  HeapSbrkBlockList^[i] := Sbrk;
-	  exit;
-        end;
-    if (HeapSbrkLastUsed = HeapSbrkAllocated) then
-    begin  { grow }
-      p2 := _realloc (HeapSbrkBlockList, (HeapSbrkAllocated + HeapInitialMaxBlocks) * sizeof(pointer));
-      if p2 = nil then  // should we better terminate with error ?
-      begin
-        _free (Sbrk);
-         Sbrk := nil;
-         exit;
-      end;
-      HeapSbrkBlockList := p2;
-      inc (HeapSbrkAllocated, HeapInitialMaxBlocks);
-    end;
-    inc (HeapSbrkLastUsed);
-    HeapSbrkBlockList^[HeapSbrkLastUsed] := Sbrk;
-  end;
-end;
-
-
-procedure FreeSbrkMem;
-var i : longint;
-begin
-  if HeapSbrkBlockList <> nil then
-  begin
-    for i := 1 to HeapSbrkLastUsed do
-      if (HeapSbrkBlockList^[i] <> nil) then
-        _free (HeapSbrkBlockList^[i]);
-    _free (HeapSbrkBlockList);
-    HeapSbrkAllocated := 0;
-    HeapSbrkLastUsed := 0;
-    HeapSbrkBlockList := nil;
-  end;
-end;
-
-{*****************************************************************************
-      OS Memory allocation / deallocation
- ****************************************************************************}
-
-function SysOSAlloc(size: ptrint): pointer;
-begin
-  result := sbrk(size);
-end;
-
-{$define HAS_SYSOSFREE}
-
-procedure SysOSFree(p: pointer; size: ptrint);
-var i : longint;
-begin
-//fpmunmap(p, size);
-  if (HeapSbrkLastUsed > 0) then
-    for i := 1 to HeapSbrkLastUsed do
-      if (HeapSbrkBlockList^[i] = p) then
-      begin
-	_free (p);
-	HeapSbrkBlockList^[i] := nil;
-	exit;
-      end;
-  HandleError (204);  // invalid pointer operation
-end;
-
-{$else autoHeapRelease}
-
-{$define HAS_SYSOSFREE}
-
-procedure SysOSFree(p: pointer; size: ptrint);
-begin
-  _free (p);
-end;
-
-function SysOSAlloc(size: ptrint): pointer;
-begin
-  SysOSAlloc := _malloc (size);
-end;
-
-{$endif autoHeapRelease}
-
-{ include standard heap management }
-{$I heap.inc}
-
-
-{****************************************************************************
-                        Low level File Routines
-       All these functions can set InOutRes on errors
- ****************************************************************************}
-
-
-PROCEDURE NW2PASErr (Err : LONGINT);
-BEGIN
-  if Err = 0 then { Else it will go through all the cases }
-   exit;
-  case Err of
-   Sys_ENFILE,
-   Sys_EMFILE : Inoutres:=4;
-   Sys_ENOENT : Inoutres:=2;
-    Sys_EBADF : Inoutres:=6;
-   Sys_ENOMEM,
-   Sys_EFAULT : Inoutres:=217;
-   Sys_EINVAL : Inoutres:=218;
-    Sys_EPIPE,
-    Sys_EINTR,
-      Sys_EIO,
-   Sys_EAGAIN,
-   Sys_ENOSPC : Inoutres:=101;
- Sys_ENAMETOOLONG,
-    Sys_ELOOP,
-  Sys_ENOTDIR : Inoutres:=3;
-    Sys_EROFS,
-   Sys_EEXIST,
-   Sys_EACCES : Inoutres:=5;
-  Sys_EBUSY   : Inoutres:=162;
-  end;
-END;
-
-FUNCTION errno : LONGINT;
-BEGIN
-  errno := __get_errno_ptr^;
-END;
-
-PROCEDURE Errno2Inoutres;
-BEGIN
-  NW2PASErr (errno);
-END;
-
-PROCEDURE SetFileError (VAR Err : LONGINT);
-BEGIN
-  IF Err >= 0 THEN
-    InOutRes := 0
-  ELSE
-  BEGIN
-    Err := errno;
-    NW2PASErr (Err);
-    Err := 0;
-  END;
-END;
-
-{ close a file from the handle value }
-procedure do_close(handle : thandle);
-VAR res : LONGINT;
-begin
-  res := _close (handle);
-  IF res <> 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0;
-end;
-
-procedure do_erase(p : pchar);
-VAR res : LONGINT;
-begin
-  res := _unlink (p);
-  IF Res < 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0;
-end;
-
-procedure do_rename(p1,p2 : pchar);
-VAR res : LONGINT;
-begin
-  res := _rename (p1,p2);
-  IF Res < 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0
-end;
-
-function do_write(h:thandle;addr:pointer;len : longint) : longint;
-VAR res : LONGINT;
-begin
-  res := _write (h,addr,len);
-  IF res > 0 THEN
-    InOutRes := 0
-  ELSE
-    SetFileError (res);
-  do_write := res;
-end;
-
-function do_read(h:thandle;addr:pointer;len : longint) : longint;
-VAR res : LONGINT;
-begin
-  res := _read (h,addr,len);
-  IF res > 0 THEN
-    InOutRes := 0
-  ELSE
-    SetFileError (res);
-  do_read := res;
-end;
-
-
-function do_filepos(handle : thandle) : longint;
-VAR res : LONGINT;
-begin
-  InOutRes:=1;
-  res := _tell (handle);
-  IF res < 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0;
-  do_filepos := res;
-end;
-
-CONST SEEK_SET = 0; // Seek from beginning of file.
-      SEEK_CUR = 1; // Seek from current position.
-      SEEK_END = 2; // Seek from end of file.
-
-
-procedure do_seek(handle:thandle;pos : longint);
-VAR res : LONGINT;
-begin
-  res := _lseek (handle,pos, SEEK_SET);
-  IF res >= 0 THEN
-    InOutRes := 0
-  ELSE
-    SetFileError (res);
-end;
-
-function do_seekend(handle:thandle):longint;
-VAR res : LONGINT;
-begin
-  res := _lseek (handle,0, SEEK_END);
-  IF res >= 0 THEN
-    InOutRes := 0
-  ELSE
-    SetFileError (res);
-  do_seekend := res;
-end;
-
-
-function do_filesize(handle : thandle) : longint;
-VAR res     : LONGINT;
-begin
-  res := _filelength (handle);
-  IF res < 0 THEN
-  BEGIN
-    SetFileError (Res);
-    do_filesize := -1;
-  END ELSE
-  BEGIN
-    InOutRes := 0;
-    do_filesize := res;
-  END;
-end;
-
-{ truncate at a given position }
-procedure do_truncate (handle:thandle;pos:longint);
-VAR res : LONGINT;
-begin
-  res := _chsize (handle,pos);
-  IF res <> 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0;
-end;
-
-// mostly stolen from syslinux
-procedure do_open(var f;p:pchar;flags:longint);
-{
-  filerec and textrec have both handle and mode as the first items so
-  they could use the same routine for opening/creating.
-  when (flags and $10)   the file will be append
-  when (flags and $100)  the file will be truncate/rewritten
-  when (flags and $1000) there is no check for close (needed for textfiles)
-}
-var
-  oflags : longint;
-Begin
-{ close first if opened }
-  if ((flags and $10000)=0) then
-   begin
-     case FileRec(f).mode of
-      fminput,fmoutput,fminout : Do_Close(FileRec(f).Handle);
-      fmclosed : ;
-     else
-      begin
-        inoutres:=102; {not assigned}
-        exit;
-      end;
-     end;
-   end;
-{ reset file Handle }
-  FileRec(f).Handle:=UnusedHandle;
-
-{ We do the conversion of filemodes here, concentrated on 1 place }
-  case (flags and 3) of
-   0 : begin
-         oflags := O_RDONLY;
-         filerec(f).mode := fminput;
-       end;
-   1 : begin
-         oflags := O_WRONLY;
-         filerec(f).mode := fmoutput;
-       end;
-   2 : begin
-         oflags := O_RDWR;
-         filerec(f).mode := fminout;
-       end;
-  end;
-  if (flags and $1000)=$1000 then
-   oflags:=oflags or (O_CREAT or O_TRUNC)
-  else
-   if (flags and $100)=$100 then
-    oflags:=oflags or (O_APPEND);
-{ empty name is special }
-  if p[0]=#0 then
-   begin
-     case FileRec(f).mode of
-       fminput :
-         FileRec(f).Handle:=StdInputHandle;
-       fminout, { this is set by rewrite }
-       fmoutput :
-         FileRec(f).Handle:=StdOutputHandle;
-       fmappend :
-         begin
-           FileRec(f).Handle:=StdOutputHandle;
-           FileRec(f).mode:=fmoutput; {fool fmappend}
-         end;
-     end;
-     exit;
-   end;
-{ real open call }
-  FileRec(f).Handle := _open(p,oflags,438);
-  //WriteLn ('_open (',p,') returned ',ErrNo, 'Handle: ',FileRec(f).Handle);
-  // errno does not seem to be set on succsess ??
-  IF FileRec(f).Handle < 0 THEN
-    if (ErrNo=Sys_EROFS) and ((OFlags and O_RDWR)<>0) then
-    begin  // i.e. for cd-rom
-      Oflags:=Oflags and not(O_RDWR);
-      FileRec(f).Handle := _open(p,oflags,438);
-    end;
-  IF FileRec(f).Handle < 0 THEN
-    Errno2Inoutres
-  ELSE
-    InOutRes := 0;
-End;
-
-function do_isdevice(handle:THandle):boolean;
-begin
-  do_isdevice := (_isatty (handle) > 0);
-end;
-
-
-{*****************************************************************************
-                           UnTyped File Handling
-*****************************************************************************}
-
-{$i file.inc}
-
-{*****************************************************************************
-                           Typed File Handling
-*****************************************************************************}
-
-{$i typefile.inc}
-
-{*****************************************************************************
-                           Text File Handling
-*****************************************************************************}
-
-{ should we consider #26 as the  end of a file ? }
-{?? $DEFINE EOF_CTRLZ}
-
-{$i text.inc}
-
-{*****************************************************************************
-                           Directory Handling
-*****************************************************************************}
-procedure mkdir(const s : string);[IOCheck];
-VAR S2 : STRING;
-    Res: LONGINT;
-BEGIN
-  S2 := S;
-  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
-  S2 := S2 + #0;
-  Res := _mkdir (@S2[1]);
-  IF Res = 0 THEN
-    InOutRes:=0
-  ELSE
-    SetFileError (Res);
-END;
-
-procedure rmdir(const s : string);[IOCheck];
-VAR S2 : STRING;
-    Res: LONGINT;
-BEGIN
-  S2 := S;
-  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
-  S2 := S2 + #0;
-  Res := _rmdir (@S2[1]);
-  IF Res = 0 THEN
-    InOutRes:=0
-  ELSE
-    SetFileError (Res);
-end;
-
-procedure chdir(const s : string);[IOCheck];
-VAR S2 : STRING;
-    Res: LONGINT;
-begin
-  S2 := S;
-  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
-  S2 := S2 + #0;
-  Res := _chdir (@S2[1]);
-  IF Res = 0 THEN
-    InOutRes:=0
-  ELSE
-    SetFileError (Res);
-end;
-
-procedure getdir(drivenr : byte;var dir : shortstring);
-VAR P : ARRAY [0..255] OF CHAR;
-    i : LONGINT;
-begin
-  P[0] := #0;
-  _getcwd (@P, SIZEOF (P));
-  i := _strlen (P);
-  if i > 0 then
-  begin
-    Move (P, dir[1], i);
-    BYTE(dir[0]) := i;
-    For i := 1 to length (dir) do
-      if dir[i] = '\' then dir [i] := '/';
-    // fix / after volume, the compiler needs that
-    // normaly root of a volumes is SERVERNAME/SYS:, change that
-    // to SERVERNAME/SYS:/
-    i := pos (':',dir);
-    if (i > 0) then
-      if i = Length (dir) then dir := dir + '/' else
-      if dir [i+1] <> '/' then insert ('/',dir,i+1);
-  END ELSE
-    InOutRes := 1;
-end;
 
 
 {*****************************************************************************
@@ -978,6 +478,7 @@ Begin
   IsLibrary := FALSE;
   IsConsole := TRUE;
   ExitCode  := 0;
+  InitSystemThreads;
 {$ifdef HASVARIANT}
   initvariantmanager;
 {$endif HASVARIANT}
@@ -987,7 +488,10 @@ Begin
 End.
 {
   $Log$
-  Revision 1.34  2005-02-01 20:22:49  florian
+  Revision 1.35  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.34  2005/02/01 20:22:49  florian
     * improved widestring infrastructure manager
 
   Revision 1.33  2004/12/07 11:04:42  armin

+ 19 - 74
rtl/netware/systhrds.pp → rtl/netware/systhrd.inc

@@ -1,9 +1,10 @@
 {
     $Id$
     This file is part of the Free Pascal run time library.
-    Copyright (c) 2001-2002 by the Free Pascal development team.
+    Copyright (c) 2002 by Peter Vreman,
+    member of the Free Pascal development team.
 
-    Multithreading implementation for NetWare
+    Linux (pthreads) threading support implementation
 
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
@@ -13,11 +14,6 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-{$mode objfpc}
-unit systhrds;
-interface
-
-{$S-}
 
 { Multithreading for netware, armin 16 Mar 2002
   - threads are basicly tested and working
@@ -31,39 +27,6 @@ interface
     are open semaphores on nlm unload.
 }
 
-type
-   { the fields of this record are os dependent  }
-   { and they shouldn't be used in a program     }
-   { only the type TCriticalSection is important }
-   PRTLCriticalSection = ^TRTLCriticalSection;
-   TRTLCriticalSection = packed record
-      SemaHandle : LONGINT;
-      SemaIsOpen : BOOLEAN;
-   end;
-
-{ include threading stuff }
-{$i threadh.inc}
-
-{Delphi/Windows compatible priority constants, they are also defined for Unix and Win32}
-const
-   THREAD_PRIORITY_IDLE          = -15;
-   THREAD_PRIORITY_LOWEST        = -2;
-   THREAD_PRIORITY_BELOW_NORMAL  = -1;
-   THREAD_PRIORITY_NORMAL        = 0;
-   THREAD_PRIORITY_ABOVE_NORMAL  = 1;
-   THREAD_PRIORITY_HIGHEST       = 2;
-   THREAD_PRIORITY_TIME_CRITICAL = 15;
-
-implementation
-
-function  SysGetCurrentThreadId : dword;forward;
-
-{$i thread.inc }
-
-{ some declarations for Netware API calls }
-{$I nwsys.inc}
-
-{  define DEBUG_MT}
 
 {*****************************************************************************
                              Threadvar support
@@ -144,10 +107,6 @@ begin
   end;
 end;
 
-
-{ Include OS independent Threadvar initialization }
-{$i threadvr.inc}
-
 {$endif HASTHREADVAR}
 
 
@@ -273,7 +232,7 @@ begin
 end;
 
 function GetThreadName  (threadId : longint; var threadName) : longint; cdecl; external 'clib' name 'GetThreadName';
-function GetThreadID : dword; cdecl; external 'clib' name 'GetThreadID';
+function CGetThreadID : dword; cdecl; external 'clib' name 'GetThreadID';
 //function __RenameThread (threadId : longint; threadName:pchar) : longint; cdecl; external 'clib' name 'RenameThread';
 
 function  SysWaitForThreadTerminate (threadHandle : dword; TimeoutMs : longint) : dword;
@@ -297,7 +256,7 @@ begin
   SysThreadSetPriority := true;
 end;
 
-function  SysThreadGetPriority (threadHandle : dword): Integer;
+function  SysThreadGetPriority (threadHandle : dword): Longint;
 begin
   SysThreadGetPriority := 0;
 end;
@@ -306,7 +265,7 @@ end;
 
 function  SysGetCurrentThreadId : dword;
 begin
-  SysGetCurrentThreadId := GetThreadID;
+  SysGetCurrentThreadId := CGetThreadID;
 end;
 
 
@@ -369,7 +328,7 @@ BEGIN
 END;
 
 
-PROCEDURE CloseAllRemainingSemaphores;
+PROCEDURE SysCloseAllRemainingSemaphores;
 var i : LONGINT;
 begin
   IF SemaList <> NIL then
@@ -440,9 +399,9 @@ begin
 end;
 
 
-function SetThreadDataAreaPtr (newPtr:pointer):pointer;
+function SysSetThreadDataAreaPtr (newPtr:pointer):pointer;
 begin
-  SetThreadDataAreaPtr := _GetThreadDataAreaPtr;
+  SysSetThreadDataAreaPtr := _GetThreadDataAreaPtr;
   if newPtr = nil then
     newPtr := thredvarsmainthread;
   _SaveThreadDataAreaPtr     (newPtr);
@@ -493,7 +452,7 @@ end;
 Var
   NWThreadManager : TThreadManager;
 
-Procedure SetNWThreadManager;
+Procedure InitSystemThreads;
 
 begin
   With NWThreadManager do
@@ -528,34 +487,20 @@ begin
     end;
   SetThreadManager(NWThreadManager);
   InitHeapMutexes;
-end;
-
-initialization
-  SetNWThreadManager;
-  NWSysSetThreadFunctions (@CloseAllRemainingSemaphores,
+  NWSysSetThreadFunctions (@SysCloseAllRemainingSemaphores,
                            @SysReleaseThreadVars,
-			   @SetThreadDataAreaPtr);
-
-end.
-
+			   @SysSetThreadDataAreaPtr);
+end;
 
 
 {
   $Log$
-  Revision 1.5  2004-09-26 19:25:49  armin
-  * exiting threads at nlm unload
-
-  Revision 1.4  2004/07/30 15:05:25  armin
-  make netware rtl compilable under 1.9.5
-
-  Revision 1.3  2003/10/01 21:00:09  peter
-    * GetCurrentThreadHandle renamed to GetCurrentThreadId
-
-  Revision 1.2  2003/03/27 17:14:27  armin
-  * more platform independent thread routines, needs to be implemented for unix
-
-  Revision 1.1  2003/02/16 17:12:15  armin
-  * systhrds fir netware added
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
 
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
 
 }
+

+ 68 - 69
rtl/netwlibc/Makefile

@@ -238,7 +238,7 @@ INC=$(RTL)/inc
 PROCINC=$(RTL)/$(CPU_TARGET)
 UNITPREFIX=rtl
 IMPFILES=nwsnut.imp ws2_32.imp ws2nlm.imp libc.imp netware.imp \
-libcclib.imp nwplibc.o
+libcclib.imp
 SYSTEMUNIT=system
 override FPCOPT+=-Ur
 override FPCOPT+=-dMT
@@ -246,103 +246,103 @@ CREATESMART=1
 OBJPASDIR=$(RTL)/objpas
 override BINUTILSPREFIX=$(CPU_TARGET)-netware-
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo systhrds classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas macpas strings lineinfo winsock heaptrc matrix nwsnut libc dos crt objects sysconst dynlibs initc sysutils types typinfo classes cpu mmx getopts dateutils strutils convutils charset ucomplex variants rtlconst math varutils freebidi utf8bidi mouse video keyboard cmem sockets ctypes
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_LOADERS+=nwplibc nwl_main nwl_dlle
@@ -444,103 +444,103 @@ ifeq ($(FULL_TARGET),arm-linux)
 override TARGET_LOADERS+=nwplibc nwl_main nwl_dlle
 endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_RSTS+=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+override TARGET_RSTS+=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
@@ -1968,7 +1968,6 @@ objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
 		   $(SYSTEMUNIT)$(PPUEXT)
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
 netware$(PPUEXT) : netware.pp $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) -I$(WININC) netware.pp
 winsock$(PPUEXT) : winsock.pp ../netware/winsock.pp $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
@@ -1985,7 +1984,7 @@ sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
 	$(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp
 classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
 		   sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconst$(PPUEXT) \
-		   sysconst$(PPUEXT) types$(PPUEXT) systhrds$(PPUEXT) \
+		   sysconst$(PPUEXT) types$(PPUEXT) \
 		   tthread.inc
 	$(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp
 typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)

+ 5 - 5
rtl/netwlibc/Makefile.fpc

@@ -10,14 +10,14 @@ loaders=nwplibc nwl_main nwl_dlle
 units=$(SYSTEMUNIT) objpas macpas strings \
       lineinfo winsock heaptrc matrix \
       nwsnut libc dos crt objects sysconst dynlibs \
-      initc sysutils types typinfo systhrds classes \
+      initc sysutils types typinfo classes \
       cpu mmx getopts \
       dateutils strutils convutils \
       charset ucomplex variants \
       rtlconst math varutils freebidi utf8bidi \
       mouse video keyboard cmem sockets ctypes
 
-rsts=math varutils variants convutils typinfo systhrds classes dateutils sysconst rtlconst
+rsts=math varutils variants convutils typinfo classes dateutils sysconst rtlconst
 
 [require]
 nortl=y
@@ -42,7 +42,8 @@ PROCINC=$(RTL)/$(CPU_TARGET)
 UNITPREFIX=rtl
 
 IMPFILES=nwsnut.imp ws2_32.imp ws2nlm.imp libc.imp netware.imp \
-libcclib.imp nwplibc.o
+libcclib.imp
+# nwplibc.o
 
 SYSTEMUNIT=system
 
@@ -127,7 +128,6 @@ objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
                    $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
                    $(SYSTEMUNIT)$(PPUEXT)
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
 
 #
 # System Dependent Units
@@ -169,7 +169,7 @@ sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
 
 classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \
                    sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconst$(PPUEXT) \
-                   sysconst$(PPUEXT) types$(PPUEXT) systhrds$(PPUEXT) \
+                   sysconst$(PPUEXT) types$(PPUEXT) \
                    tthread.inc
         $(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp
 

+ 4 - 2
rtl/netwlibc/classes.pp

@@ -28,7 +28,6 @@ uses
   types,
   typinfo,
   rtlconst,
-  systhrds,
   Libc;
 
 
@@ -49,7 +48,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.2  2004-09-26 19:23:34  armin
+  Revision 1.3  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.2  2004/09/26 19:23:34  armin
   * exiting threads at nlm unload
   * renamed some libc functions
 

+ 7 - 7
rtl/netwlibc/libc.pp

@@ -8337,12 +8337,9 @@ type
         spares : array[0..5] of longint;
      end;
 
-   Ppthread_mutex_t = ^pthread_mutex_t;
-   pthread_mutex_t = record
-        mutex : pointer;
-        reserved : array[0..52] of dword;
-     end;
-   TpthreadMutex = pthread_mutex_t;
+   Ppthread_mutex_t = PRtlCriticalSection;
+   pthread_mutex_t = TRtlCriticalSection;
+   TpthreadMutex = TRtlCriticalSection;
 
    Ppthread_rwlock_t = ^pthread_rwlock_t;
    pthread_rwlock_t = record
@@ -9228,7 +9225,10 @@ end.
 
 {
   $Log$
-  Revision 1.9  2005-01-04 11:25:33  armin
+  Revision 1.10  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.9  2005/01/04 11:25:33  armin
   * rtl code cleanup, compat fixes between clib and libc
 
   Revision 1.8  2004/12/29 13:01:43  armin

+ 98 - 0
rtl/netwlibc/sysdir.inc

@@ -0,0 +1,98 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
+    member of the Free Pascal development team.
+
+    FPC Pascal system unit for the Win32 API.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{*****************************************************************************
+                           Directory Handling
+*****************************************************************************}
+procedure mkdir(const s : string);[IOCheck];
+var S2 : STRING;
+    Res: LONGINT;
+BEGIN
+  S2 := S;
+  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
+  S2 := S2 + #0;
+  Res := FpMkdir (@S2[1],S_IRWXU);
+  if Res = 0 then
+    InOutRes:=0
+  else
+    SetFileError (Res);
+end;
+
+procedure rmdir(const s : string);[IOCheck];
+VAR S2 : STRING;
+    Res: LONGINT;
+BEGIN
+  S2 := S;
+  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
+  S2 := S2 + #0;
+  Res := FpRmdir (@S2[1]);
+  IF Res = 0 THEN
+    InOutRes:=0
+  ELSE
+    SetFileError (Res);
+end;
+
+procedure chdir(const s : string);[IOCheck];
+VAR S2 : STRING;
+    Res: LONGINT;
+begin
+  S2 := S;
+  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
+  S2 := S2 + #0;
+  Res := FpChdir (@S2[1]);
+  IF Res = 0 THEN
+    InOutRes:=0
+  ELSE
+    SetFileError (Res);
+end;
+
+procedure getdir(drivenr : byte;var dir : shortstring);
+var P : array [0..255] of CHAR;
+    i : LONGINT;
+begin
+  P[0] := #0;
+  getcwdpath(@P,nil,0);   // getcwd does not return volume, getcwdpath does
+  i := libc_strlen (P);
+  if i > 0 then
+  begin
+    Move (P, dir[1], i);
+    BYTE(dir[0]) := i;
+    For i := 1 to length (dir) do
+      if dir[i] = '\' then dir [i] := '/';
+    // fix / after volume, the compiler needs that
+    // normaly root of a volumes is SERVERNAME/SYS:, change that
+    // to SERVERNAME/SYS:/
+    i := pos (':',dir);
+    if (i > 0) then
+      if i = Length (dir) then dir := dir + '/' else
+      if dir [i+1] <> '/' then insert ('/',dir,i+1);
+  end else
+    InOutRes := 1;
+end;
+
+
+
+{
+  $Log$
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
+
+}

+ 414 - 0
rtl/netwlibc/sysfile.inc

@@ -0,0 +1,414 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    Low leve file functions
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{****************************************************************************
+                        Low level File Routines
+       All these functions can set InOutRes on errors
+ ****************************************************************************}
+
+
+PROCEDURE NW2PASErr (Err : LONGINT);
+BEGIN
+  if Err = 0 then { Else it will go through all the cases }
+   exit;
+  case Err of
+   Sys_ENFILE,
+   Sys_EMFILE : Inoutres:=4;
+   Sys_ENOENT : Inoutres:=2;
+    Sys_EBADF : Inoutres:=6;
+   Sys_ENOMEM,
+   Sys_EFAULT : Inoutres:=217;
+   Sys_EINVAL : Inoutres:=218;
+    Sys_EPIPE,
+    Sys_EINTR,
+      Sys_EIO,
+   Sys_EAGAIN,
+   Sys_ENOSPC : Inoutres:=101;
+ Sys_ENAMETOOLONG,
+    Sys_ELOOP,
+  Sys_ENOTDIR : Inoutres:=3;
+    Sys_EROFS,
+   Sys_EEXIST,
+   Sys_EACCES : Inoutres:=5;
+  Sys_EBUSY   : Inoutres:=162
+  else begin
+    Writeln (stderr,'NW2PASErr: unknown error ',err);
+    libc_perror('NW2PASErr');
+    Inoutres := Err;
+  end;
+  end;
+END;
+
+
+procedure Errno2Inoutres;
+begin
+  NW2PASErr (___errno^);
+end;
+
+procedure SetFileError (VAR Err : LONGINT);
+begin
+  if Err >= 0 then
+    InOutRes := 0
+  else begin
+    // libc_perror ('SetFileError');
+    Err := ___errno^;
+    NW2PASErr (Err);
+    Err := 0;
+  end;
+end;
+
+{ close a file from the handle value }
+procedure do_close(handle : thandle);
+VAR res : LONGINT;
+begin
+  {$ifdef IOpossix}
+  res := FpClose (handle);
+  {$else}
+  res := _fclose (_TFILE(handle));
+  {$endif}
+  IF res <> 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0;
+end;
+
+procedure do_erase(p : pchar);
+VAR res : LONGINT;
+begin
+  res := unlink (p);
+  IF Res < 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0;
+end;
+
+procedure do_rename(p1,p2 : pchar);
+VAR res : LONGINT;
+begin
+  res := rename (p1,p2);
+  IF Res < 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0
+end;
+
+function do_write(h:thandle;addr:pointer;len : longint) : longint;
+var res : LONGINT;
+begin
+  {$ifdef IOpossix}
+  res := Fpwrite (h,addr,len);
+  {$else}
+  res := _fwrite (addr,1,len,_TFILE(h));
+  {$endif}
+  if res > 0 then
+    InOutRes := 0
+  else
+    SetFileError (res);
+  do_write := res;
+  NXThreadYield;
+end;
+
+function do_read(h:thandle;addr:pointer;len : longint) : longint;
+VAR res : LONGINT;
+begin
+  {$ifdef IOpossix}
+  res := Fpread (h,addr,len);
+  {$else}
+  res := _fread (addr,1,len,_TFILE(h));
+  {$endif}
+  IF res > 0 THEN
+    InOutRes := 0
+  ELSE
+    SetFileError (res);
+  do_read := res;
+  NXThreadYield;
+end;
+
+
+function do_filepos(handle : thandle) : longint;
+var res : LONGINT;
+begin
+  InOutRes:=1;
+  {$ifdef IOpossix}
+  res := Fptell (handle);
+  {$else}
+  res := _ftell (_TFILE(handle));
+  {$endif}
+  if res < 0 THEN
+    SetFileError (res)
+  else
+    InOutRes := 0;
+  do_filepos := res;
+end;
+
+
+procedure do_seek(handle:thandle;pos : longint);
+VAR res : LONGINT;
+begin
+  {$ifdef IOpossix}
+  res := Fplseek (handle,pos, SEEK_SET);
+  {$else}
+  res := _fseek (_TFILE(handle),pos, SEEK_SET);
+  {$endif}
+  IF res >= 0 THEN
+    InOutRes := 0
+  ELSE
+    SetFileError (res);
+end;
+
+function do_seekend(handle:thandle):longint;
+VAR res : LONGINT;
+begin
+  {$ifdef IOpossix}
+  res := Fplseek (handle,0, SEEK_END);
+  {$else}
+  res := _fseek (_TFILE(handle),0, SEEK_END);
+  {$endif}
+  IF res >= 0 THEN
+    InOutRes := 0
+  ELSE
+    SetFileError (res);
+  do_seekend := res;
+end;
+
+
+function do_filesize(handle : thandle) : longint;
+VAR res     : LONGINT;
+    statbuf : TStat;
+begin
+  {$ifdef IOpossix}
+  res := Fpfstat (handle, statbuf);
+  {$else}
+  res := _fstat (_fileno (_TFILE(handle)), statbuf);  // was _filelength for clib
+  {$endif}
+  if res <> 0 then
+  begin
+    SetFileError (Res);
+    do_filesize := -1;
+  end else
+  begin
+    InOutRes := 0;
+    do_filesize := statbuf.st_size;
+  end;
+end;
+
+{ truncate at a given position }
+procedure do_truncate (handle:thandle;pos:longint);
+VAR res : LONGINT;
+begin
+  {$ifdef IOpossix}
+  res := ftruncate (handle,pos);
+  {$else}
+  res := _ftruncate (_fileno (_TFILE(handle)),pos);
+  {$endif}
+  IF res <> 0 THEN
+    SetFileError (res)
+  ELSE
+    InOutRes := 0;
+end;
+
+{$ifdef IOpossix}
+// mostly stolen from syslinux
+procedure do_open(var f;p:pchar;flags:longint);
+{
+  filerec and textrec have both handle and mode as the first items so
+  they could use the same routine for opening/creating.
+  when (flags and $10)   the file will be append
+  when (flags and $100)  the file will be truncate/rewritten
+  when (flags and $1000) there is no check for close (needed for textfiles)
+}
+var
+  oflags : longint;
+Begin
+{ close first if opened }
+  if ((flags and $10000)=0) then
+   begin
+     case FileRec(f).mode of
+      fminput,fmoutput,fminout : Do_Close(FileRec(f).Handle);
+      fmclosed : ;
+     else
+      begin
+        inoutres:=102; {not assigned}
+        exit;
+      end;
+     end;
+   end;
+{ reset file Handle }
+  FileRec(f).Handle:=UnusedHandle;
+
+{ We do the conversion of filemodes here, concentrated on 1 place }
+  case (flags and 3) of
+   0 : begin
+         oflags := O_RDONLY;
+         filerec(f).mode := fminput;
+       end;
+   1 : begin
+         oflags := O_WRONLY;
+         filerec(f).mode := fmoutput;
+       end;
+   2 : begin
+         oflags := O_RDWR;
+         filerec(f).mode := fminout;
+       end;
+  end;
+  if (flags and $1000)=$1000 then
+   oflags:=oflags or (O_CREAT or O_TRUNC)
+  else
+   if (flags and $100)=$100 then
+    oflags:=oflags or (O_APPEND);
+{ empty name is special }
+  if p[0]=#0 then
+   begin
+     case FileRec(f).mode of
+       fminput :
+         FileRec(f).Handle:=StdInputHandle;
+       fminout, { this is set by rewrite }
+       fmoutput :
+         FileRec(f).Handle:=StdOutputHandle;
+       fmappend :
+         begin
+           FileRec(f).Handle:=StdOutputHandle;
+           FileRec(f).mode:=fmoutput; {fool fmappend}
+         end;
+     end;
+     exit;
+   end;
+{ real open call }
+  ___errno^ := 0;
+  FileRec(f).Handle := open(p,oflags,438);
+  { open somtimes returns > -1 but errno was set }
+  if (___errno^ <> 0) or (longint(FileRec(f).Handle) < 0) then
+    if (___errno^=Sys_EROFS) and ((OFlags and O_RDWR)<>0) then
+    begin  // i.e. for cd-rom
+      Oflags:=Oflags and not(O_RDWR);
+      FileRec(f).Handle := open(p,oflags,438);
+    end;
+  if (___errno^ <> 0) or (longint(FileRec(f).Handle) < 0) then
+    Errno2Inoutres
+  else
+    InOutRes := 0;
+end;
+
+
+{$else}
+procedure do_open(var f;p:pchar;flags:longint);
+{
+  filerec and textrec have both handle and mode as the first items so
+  they could use the same routine for opening/creating.
+  when (flags and $10)   the file will be append
+  when (flags and $100)  the file will be truncate/rewritten
+  when (flags and $1000) there is no check for close (needed for textfiles)
+}
+var
+  oflags : string[10];
+Begin
+{ close first if opened }
+  if ((flags and $10000)=0) then
+   begin
+     case FileRec(f).mode of
+      fminput,fmoutput,fminout : Do_Close(FileRec(f).Handle);
+      fmclosed : ;
+     else
+      begin
+        inoutres:=102; {not assigned}
+        exit;
+      end;
+     end;
+   end;
+{ reset file Handle }
+  FileRec(f).Handle:=UnusedHandle;
+
+{ We do the conversion of filemodes here, concentrated on 1 place }
+  case (flags and 3) of
+   0 : begin
+         oflags := 'rb'#0;
+         filerec(f).mode := fminput;
+       end;
+   1 : begin
+         if (flags and $1000)=$1000 then
+	   oflags := 'w+b' else
+           oflags := 'wb';
+         filerec(f).mode := fmoutput;
+       end;
+   2 : begin
+         if (flags and $1000)=$1000 then
+	   oflags := 'w+' else
+           oflags := 'r+';
+         filerec(f).mode := fminout;
+       end;
+  end;
+  {if (flags and $1000)=$1000 then
+   oflags:=oflags or (O_CREAT or O_TRUNC)
+  else
+   if (flags and $100)=$100 then
+    oflags:=oflags or (O_APPEND);}
+{ empty name is special }
+  if p[0]=#0 then
+   begin
+     case FileRec(f).mode of
+       fminput :
+         FileRec(f).Handle:=StdInputHandle;
+       fminout, { this is set by rewrite }
+       fmoutput :
+         FileRec(f).Handle:=StdOutputHandle;
+       fmappend :
+         begin
+           FileRec(f).Handle:=StdOutputHandle;
+           FileRec(f).mode:=fmoutput; {fool fmappend}
+         end;
+     end;
+     exit;
+   end;
+{ real open call }
+  FileRec(f).Handle := THandle (_fopen (p,@oflags[1]));//_open(p,oflags,438);
+  //WriteLn ('_open (',p,') returned ',ErrNo, 'Handle: ',FileRec(f).Handle);
+  // errno does not seem to be set on succsess ??
+  {IF FileRec(f).Handle < 0 THEN
+    if (ErrNo=Sys_EROFS) and ((OFlags and O_RDWR)<>0) then
+    begin  // i.e. for cd-rom
+      Oflags:=Oflags and not(O_RDWR);
+      FileRec(f).Handle := _open(p,oflags,438);
+    end;}
+  if FileRec(f).Handle = 0 then
+    Errno2Inoutres
+  else
+    InOutRes := 0;
+End;
+{$endif}
+
+function do_isdevice(handle:THandle):boolean;
+begin
+  {$ifdef IOpossix}
+  do_isdevice := (Fpisatty (handle) > 0);
+  {$else}
+  do_isdevice := (isatty (_fileno(_TFILE(handle))) > 0);
+  {$endif}
+end;
+
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 156 - 0
rtl/netwlibc/sysheap.inc

@@ -0,0 +1,156 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{*****************************************************************************
+                              Heap Management
+*****************************************************************************}
+
+{$ifdef autoHeapRelease}
+
+const HeapInitialMaxBlocks = 32;
+type THeapSbrkBlockList = array [1.. HeapInitialMaxBlocks] of pointer;
+var  HeapSbrkBlockList : ^THeapSbrkBlockList = nil;
+     HeapSbrkLastUsed  : dword = 0;
+     HeapSbrkAllocated : dword = 0;
+     HeapSbrkReleased : boolean = false;
+
+{ function to allocate size bytes more for the program }
+{ must return the first address of new data space or nil if fail }
+{ for netware all allocated blocks are saved to free them at }
+{ exit (to avoid message "Module did not release xx resources") }
+Function SysOSAlloc(size : longint):pointer;
+var P2 : POINTER;
+    i  : longint;
+    Slept : longint;
+begin
+  if HeapSbrkReleased then
+  begin
+    _ConsolePrintf ('Error: SysOSFree called after all heap memory was released'#13#10);
+    exit(nil);
+  end;
+  SysOSAlloc := _Alloc (size,HeapAllocResourceTag);
+  if SysOSAlloc <> nil then begin
+    if HeapSbrkBlockList = nil then
+    begin
+      Pointer (HeapSbrkBlockList) := _Alloc (sizeof (HeapSbrkBlockList^),HeapListAllocResourceTag);
+      if HeapSbrkBlockList = nil then
+      begin
+        _free (SysOSAlloc);
+        SysOSAlloc := nil;
+        exit;
+      end;
+      fillchar (HeapSbrkBlockList^,sizeof(HeapSbrkBlockList^),0);
+      HeapSbrkAllocated := HeapInitialMaxBlocks;
+    end;
+    if (HeapSbrkLastUsed > 0) then
+      for i := 1 to HeapSbrkLastUsed do
+        if (HeapSbrkBlockList^[i] = nil) then
+        begin  // reuse free slot
+          HeapSbrkBlockList^[i] := SysOSAlloc;
+          exit;
+        end;
+    if (HeapSbrkLastUsed = HeapSbrkAllocated) then
+    begin  { grow }
+      slept := 0;
+      p2 := _ReallocSleepOK (HeapSbrkBlockList, (HeapSbrkAllocated + HeapInitialMaxBlocks) * sizeof(pointer),HeapListAllocResourceTag,Slept);
+      if p2 = nil then  // should we better terminate with error ?
+      begin
+        _free (SysOSAlloc);
+        SysOSAlloc := nil;
+        exit;
+      end;
+      HeapSbrkBlockList := p2;
+      inc (HeapSbrkAllocated, HeapInitialMaxBlocks);
+    end;
+    inc (HeapSbrkLastUsed);
+    HeapSbrkBlockList^[HeapSbrkLastUsed] := SysOSAlloc;
+  end;
+end;
+
+
+procedure FreeSbrkMem;
+var i : longint;
+begin
+  if HeapSbrkBlockList <> nil then
+  begin
+    for i := 1 to HeapSbrkLastUsed do
+      if (HeapSbrkBlockList^[i] <> nil) then
+        _free (HeapSbrkBlockList^[i]);
+    _free (HeapSbrkBlockList);
+    HeapSbrkAllocated := 0;
+    HeapSbrkLastUsed := 0;
+    HeapSbrkBlockList := nil;
+  end;
+  HeapSbrkReleased := true;
+  {ReturnResourceTag(HeapAllocResourceTag,1);
+  ReturnResourceTag(HeapListAllocResourceTag,1);  not in netware.imp, seems to be not needed}
+end;
+
+{*****************************************************************************
+      OS Memory allocation / deallocation
+ ****************************************************************************}
+
+{$define HAS_SYSOSFREE}
+
+procedure SysOSFree(p: pointer; size: ptrint);
+var i : longint;
+begin
+  if HeapSbrkReleased then
+  begin
+    _ConsolePrintf ('Error: SysOSFree called after all heap memory was released'#13#10);
+  end else
+  if (HeapSbrkLastUsed > 0) then
+    for i := 1 to HeapSbrkLastUsed do
+      if (HeapSbrkBlockList^[i] = p) then
+      begin
+        _free (p);
+        HeapSbrkBlockList^[i] := nil;
+        exit;
+      end;
+  HandleError (204);  // invalid pointer operation
+end;
+
+{$else autoHeapRelease}
+
+{$define HAS_SYSOSFREE}
+
+procedure SysOSFree(p: pointer; size: ptrint);
+begin
+  _free (p);
+end;
+
+function SysOSAlloc(size: ptrint): pointer;
+begin
+  SysOSAlloc := _Alloc(size,HeapAllocResourceTag);
+end;
+
+{$endif autoHeapRelease}
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 55 - 0
rtl/netwlibc/sysos.inc

@@ -0,0 +1,55 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{ some declarations for Netware API calls }
+{ I nwlibc.inc}
+{$I errno.inc}
+{$define INCLUDED_FROM_SYSTEM}
+{$I libc.pp}
+
+var
+  {$ifdef autoHeapRelease}
+  HeapListAllocResourceTag,
+  {$endif}
+  HeapAllocResourceTag : rtag_t;
+  NLMHandle : pointer;
+  ReleaseThreadVars : TSysReleaseThreadVars = nil;
+  AllocateThreadVars: TSysReleaseThreadVars = nil;
+  SetThreadDataAreaPtr : TSysSetThreadDataAreaPtr = nil;
+  TerminatingThreadID : dword = 0;
+
+procedure NWSysSetThreadFunctions (atv:TSysReleaseThreadVars;
+                                   rtv:TSysReleaseThreadVars;
+                                   stdata:TSysSetThreadDataAreaPtr);
+begin
+  AllocateThreadVars := atv;
+  ReleaseThreadVars := rtv;
+  SetThreadDataAreaPtr := stdata;
+end;
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 38 - 0
rtl/netwlibc/sysosh.inc

@@ -0,0 +1,38 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+type
+   THandle = DWord;
+   
+   PRTLCriticalSection = ^TRTLCriticalSection;
+   TRTLCriticalSection = packed record
+        mutex : pointer;
+        reserved : array[0..52] of dword;
+     end;
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 5 - 636
rtl/netwlibc/system.pp

@@ -38,7 +38,6 @@ interface
 
 {$I systemh.inc}
 
-type THandle = DWord;
 
 {Platform specific information}
 const
@@ -51,9 +50,6 @@ const
  maxExitCode = $ffff;
 
 
-{ include heap support headers }
-{$I heaph.inc}
-
 CONST
   { Default filehandles }
    UnusedHandle    : THandle = -1;
@@ -117,32 +113,6 @@ implementation
 { include system independent routines }
 {$I system.inc}
 
-{ some declarations for Netware API calls }
-{ I nwlibc.inc}
-{$I errno.inc}
-{$define INCLUDED_FROM_SYSTEM}
-{$I libc.pp}
-
-var
-  {$ifdef autoHeapRelease}
-  HeapListAllocResourceTag,
-  {$endif}
-  HeapAllocResourceTag : rtag_t;
-  NLMHandle : pointer;
-  ReleaseThreadVars : TSysReleaseThreadVars = nil;
-  AllocateThreadVars: TSysReleaseThreadVars = nil;
-  SetThreadDataAreaPtr : TSysSetThreadDataAreaPtr = nil;
-  TerminatingThreadID : dword = 0;
-
-procedure NWSysSetThreadFunctions (atv:TSysReleaseThreadVars;
-                                   rtv:TSysReleaseThreadVars;
-                                   stdata:TSysSetThreadDataAreaPtr);
-begin
-  AllocateThreadVars := atv;
-  ReleaseThreadVars := rtv;
-  SetThreadDataAreaPtr := stdata;
-end;
-
 
 procedure PASCALMAIN;external name 'PASCALMAIN';
 procedure fpc_do_exit;external name 'FPC_DO_EXIT';
@@ -152,10 +122,6 @@ procedure fpc_do_exit;external name 'FPC_DO_EXIT';
                          System Dependent Exit code
 *****************************************************************************}
 
-{$ifdef autoHeapRelease}
-procedure FreeSbrkMem; forward;
-{$endif}
-
 var SigTermHandlerActive : boolean;
 
 Procedure system_exit;
@@ -245,607 +211,6 @@ begin
   randseed := time (NIL);
 end;
 
-{*****************************************************************************
-                              Heap Management
-*****************************************************************************}
-
-{$ifdef autoHeapRelease}
-
-const HeapInitialMaxBlocks = 32;
-type THeapSbrkBlockList = array [1.. HeapInitialMaxBlocks] of pointer;
-var  HeapSbrkBlockList : ^THeapSbrkBlockList = nil;
-     HeapSbrkLastUsed  : dword = 0;
-     HeapSbrkAllocated : dword = 0;
-     HeapSbrkReleased : boolean = false;
-
-{ function to allocate size bytes more for the program }
-{ must return the first address of new data space or nil if fail }
-{ for netware all allocated blocks are saved to free them at }
-{ exit (to avoid message "Module did not release xx resources") }
-Function SysOSAlloc(size : longint):pointer;
-var P2 : POINTER;
-    i  : longint;
-    Slept : longint;
-begin
-  if HeapSbrkReleased then
-  begin
-    _ConsolePrintf ('Error: SysOSFree called after all heap memory was released'#13#10);
-    exit(nil);
-  end;
-  SysOSAlloc := _Alloc (size,HeapAllocResourceTag);
-  if SysOSAlloc <> nil then begin
-    if HeapSbrkBlockList = nil then
-    begin
-      Pointer (HeapSbrkBlockList) := _Alloc (sizeof (HeapSbrkBlockList^),HeapListAllocResourceTag);
-      if HeapSbrkBlockList = nil then
-      begin
-        _free (SysOSAlloc);
-        SysOSAlloc := nil;
-        exit;
-      end;
-      fillchar (HeapSbrkBlockList^,sizeof(HeapSbrkBlockList^),0);
-      HeapSbrkAllocated := HeapInitialMaxBlocks;
-    end;
-    if (HeapSbrkLastUsed > 0) then
-      for i := 1 to HeapSbrkLastUsed do
-        if (HeapSbrkBlockList^[i] = nil) then
-        begin  // reuse free slot
-          HeapSbrkBlockList^[i] := SysOSAlloc;
-          exit;
-        end;
-    if (HeapSbrkLastUsed = HeapSbrkAllocated) then
-    begin  { grow }
-      slept := 0;
-      p2 := _ReallocSleepOK (HeapSbrkBlockList, (HeapSbrkAllocated + HeapInitialMaxBlocks) * sizeof(pointer),HeapListAllocResourceTag,Slept);
-      if p2 = nil then  // should we better terminate with error ?
-      begin
-        _free (SysOSAlloc);
-        SysOSAlloc := nil;
-        exit;
-      end;
-      HeapSbrkBlockList := p2;
-      inc (HeapSbrkAllocated, HeapInitialMaxBlocks);
-    end;
-    inc (HeapSbrkLastUsed);
-    HeapSbrkBlockList^[HeapSbrkLastUsed] := SysOSAlloc;
-  end;
-end;
-
-
-procedure FreeSbrkMem;
-var i : longint;
-begin
-  if HeapSbrkBlockList <> nil then
-  begin
-    for i := 1 to HeapSbrkLastUsed do
-      if (HeapSbrkBlockList^[i] <> nil) then
-        _free (HeapSbrkBlockList^[i]);
-    _free (HeapSbrkBlockList);
-    HeapSbrkAllocated := 0;
-    HeapSbrkLastUsed := 0;
-    HeapSbrkBlockList := nil;
-  end;
-  HeapSbrkReleased := true;
-  {ReturnResourceTag(HeapAllocResourceTag,1);
-  ReturnResourceTag(HeapListAllocResourceTag,1);  not in netware.imp, seems to be not needed}
-end;
-
-{*****************************************************************************
-      OS Memory allocation / deallocation
- ****************************************************************************}
-
-{$define HAS_SYSOSFREE}
-
-procedure SysOSFree(p: pointer; size: ptrint);
-var i : longint;
-begin
-  if HeapSbrkReleased then
-  begin
-    _ConsolePrintf ('Error: SysOSFree called after all heap memory was released'#13#10);
-  end else
-  if (HeapSbrkLastUsed > 0) then
-    for i := 1 to HeapSbrkLastUsed do
-      if (HeapSbrkBlockList^[i] = p) then
-      begin
-        _free (p);
-        HeapSbrkBlockList^[i] := nil;
-        exit;
-      end;
-  HandleError (204);  // invalid pointer operation
-end;
-
-{$else autoHeapRelease}
-
-{$define HAS_SYSOSFREE}
-
-procedure SysOSFree(p: pointer; size: ptrint);
-begin
-  _free (p);
-end;
-
-function SysOSAlloc(size: ptrint): pointer;
-begin
-  SysOSAlloc := _Alloc(size,HeapAllocResourceTag);
-end;
-
-{$endif autoHeapRelease}
-
-{ include standard heap management }
-{$I heap.inc}
-
-
-{****************************************************************************
-                        Low level File Routines
-       All these functions can set InOutRes on errors
- ****************************************************************************}
-
-
-PROCEDURE NW2PASErr (Err : LONGINT);
-BEGIN
-  if Err = 0 then { Else it will go through all the cases }
-   exit;
-  case Err of
-   Sys_ENFILE,
-   Sys_EMFILE : Inoutres:=4;
-   Sys_ENOENT : Inoutres:=2;
-    Sys_EBADF : Inoutres:=6;
-   Sys_ENOMEM,
-   Sys_EFAULT : Inoutres:=217;
-   Sys_EINVAL : Inoutres:=218;
-    Sys_EPIPE,
-    Sys_EINTR,
-      Sys_EIO,
-   Sys_EAGAIN,
-   Sys_ENOSPC : Inoutres:=101;
- Sys_ENAMETOOLONG,
-    Sys_ELOOP,
-  Sys_ENOTDIR : Inoutres:=3;
-    Sys_EROFS,
-   Sys_EEXIST,
-   Sys_EACCES : Inoutres:=5;
-  Sys_EBUSY   : Inoutres:=162
-  else begin
-    Writeln (stderr,'NW2PASErr: unknown error ',err);
-    libc_perror('NW2PASErr');
-    Inoutres := Err;
-  end;
-  end;
-END;
-
-
-procedure Errno2Inoutres;
-begin
-  NW2PASErr (___errno^);
-end;
-
-procedure SetFileError (VAR Err : LONGINT);
-begin
-  if Err >= 0 then
-    InOutRes := 0
-  else begin
-    // libc_perror ('SetFileError');
-    Err := ___errno^;
-    NW2PASErr (Err);
-    Err := 0;
-  end;
-end;
-
-{ close a file from the handle value }
-procedure do_close(handle : thandle);
-VAR res : LONGINT;
-begin
-  {$ifdef IOpossix}
-  res := FpClose (handle);
-  {$else}
-  res := _fclose (_TFILE(handle));
-  {$endif}
-  IF res <> 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0;
-end;
-
-procedure do_erase(p : pchar);
-VAR res : LONGINT;
-begin
-  res := unlink (p);
-  IF Res < 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0;
-end;
-
-procedure do_rename(p1,p2 : pchar);
-VAR res : LONGINT;
-begin
-  res := rename (p1,p2);
-  IF Res < 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0
-end;
-
-function do_write(h:thandle;addr:pointer;len : longint) : longint;
-var res : LONGINT;
-begin
-  {$ifdef IOpossix}
-  res := Fpwrite (h,addr,len);
-  {$else}
-  res := _fwrite (addr,1,len,_TFILE(h));
-  {$endif}
-  if res > 0 then
-    InOutRes := 0
-  else
-    SetFileError (res);
-  do_write := res;
-  NXThreadYield;
-end;
-
-function do_read(h:thandle;addr:pointer;len : longint) : longint;
-VAR res : LONGINT;
-begin
-  {$ifdef IOpossix}
-  res := Fpread (h,addr,len);
-  {$else}
-  res := _fread (addr,1,len,_TFILE(h));
-  {$endif}
-  IF res > 0 THEN
-    InOutRes := 0
-  ELSE
-    SetFileError (res);
-  do_read := res;
-  NXThreadYield;
-end;
-
-
-function do_filepos(handle : thandle) : longint;
-var res : LONGINT;
-begin
-  InOutRes:=1;
-  {$ifdef IOpossix}
-  res := Fptell (handle);
-  {$else}
-  res := _ftell (_TFILE(handle));
-  {$endif}
-  if res < 0 THEN
-    SetFileError (res)
-  else
-    InOutRes := 0;
-  do_filepos := res;
-end;
-
-
-procedure do_seek(handle:thandle;pos : longint);
-VAR res : LONGINT;
-begin
-  {$ifdef IOpossix}
-  res := Fplseek (handle,pos, SEEK_SET);
-  {$else}
-  res := _fseek (_TFILE(handle),pos, SEEK_SET);
-  {$endif}
-  IF res >= 0 THEN
-    InOutRes := 0
-  ELSE
-    SetFileError (res);
-end;
-
-function do_seekend(handle:thandle):longint;
-VAR res : LONGINT;
-begin
-  {$ifdef IOpossix}
-  res := Fplseek (handle,0, SEEK_END);
-  {$else}
-  res := _fseek (_TFILE(handle),0, SEEK_END);
-  {$endif}
-  IF res >= 0 THEN
-    InOutRes := 0
-  ELSE
-    SetFileError (res);
-  do_seekend := res;
-end;
-
-
-function do_filesize(handle : thandle) : longint;
-VAR res     : LONGINT;
-    statbuf : TStat;
-begin
-  {$ifdef IOpossix}
-  res := Fpfstat (handle, statbuf);
-  {$else}
-  res := _fstat (_fileno (_TFILE(handle)), statbuf);  // was _filelength for clib
-  {$endif}
-  if res <> 0 then
-  begin
-    SetFileError (Res);
-    do_filesize := -1;
-  end else
-  begin
-    InOutRes := 0;
-    do_filesize := statbuf.st_size;
-  end;
-end;
-
-{ truncate at a given position }
-procedure do_truncate (handle:thandle;pos:longint);
-VAR res : LONGINT;
-begin
-  {$ifdef IOpossix}
-  res := ftruncate (handle,pos);
-  {$else}
-  res := _ftruncate (_fileno (_TFILE(handle)),pos);
-  {$endif}
-  IF res <> 0 THEN
-    SetFileError (res)
-  ELSE
-    InOutRes := 0;
-end;
-
-{$ifdef IOpossix}
-// mostly stolen from syslinux
-procedure do_open(var f;p:pchar;flags:longint);
-{
-  filerec and textrec have both handle and mode as the first items so
-  they could use the same routine for opening/creating.
-  when (flags and $10)   the file will be append
-  when (flags and $100)  the file will be truncate/rewritten
-  when (flags and $1000) there is no check for close (needed for textfiles)
-}
-var
-  oflags : longint;
-Begin
-{ close first if opened }
-  if ((flags and $10000)=0) then
-   begin
-     case FileRec(f).mode of
-      fminput,fmoutput,fminout : Do_Close(FileRec(f).Handle);
-      fmclosed : ;
-     else
-      begin
-        inoutres:=102; {not assigned}
-        exit;
-      end;
-     end;
-   end;
-{ reset file Handle }
-  FileRec(f).Handle:=UnusedHandle;
-
-{ We do the conversion of filemodes here, concentrated on 1 place }
-  case (flags and 3) of
-   0 : begin
-         oflags := O_RDONLY;
-         filerec(f).mode := fminput;
-       end;
-   1 : begin
-         oflags := O_WRONLY;
-         filerec(f).mode := fmoutput;
-       end;
-   2 : begin
-         oflags := O_RDWR;
-         filerec(f).mode := fminout;
-       end;
-  end;
-  if (flags and $1000)=$1000 then
-   oflags:=oflags or (O_CREAT or O_TRUNC)
-  else
-   if (flags and $100)=$100 then
-    oflags:=oflags or (O_APPEND);
-{ empty name is special }
-  if p[0]=#0 then
-   begin
-     case FileRec(f).mode of
-       fminput :
-         FileRec(f).Handle:=StdInputHandle;
-       fminout, { this is set by rewrite }
-       fmoutput :
-         FileRec(f).Handle:=StdOutputHandle;
-       fmappend :
-         begin
-           FileRec(f).Handle:=StdOutputHandle;
-           FileRec(f).mode:=fmoutput; {fool fmappend}
-         end;
-     end;
-     exit;
-   end;
-{ real open call }
-  ___errno^ := 0;
-  FileRec(f).Handle := open(p,oflags,438);
-  { open somtimes returns > -1 but errno was set }
-  if (___errno^ <> 0) or (longint(FileRec(f).Handle) < 0) then
-    if (___errno^=Sys_EROFS) and ((OFlags and O_RDWR)<>0) then
-    begin  // i.e. for cd-rom
-      Oflags:=Oflags and not(O_RDWR);
-      FileRec(f).Handle := open(p,oflags,438);
-    end;
-  if (___errno^ <> 0) or (longint(FileRec(f).Handle) < 0) then
-    Errno2Inoutres
-  else
-    InOutRes := 0;
-end;
-
-
-{$else}
-procedure do_open(var f;p:pchar;flags:longint);
-{
-  filerec and textrec have both handle and mode as the first items so
-  they could use the same routine for opening/creating.
-  when (flags and $10)   the file will be append
-  when (flags and $100)  the file will be truncate/rewritten
-  when (flags and $1000) there is no check for close (needed for textfiles)
-}
-var
-  oflags : string[10];
-Begin
-{ close first if opened }
-  if ((flags and $10000)=0) then
-   begin
-     case FileRec(f).mode of
-      fminput,fmoutput,fminout : Do_Close(FileRec(f).Handle);
-      fmclosed : ;
-     else
-      begin
-        inoutres:=102; {not assigned}
-        exit;
-      end;
-     end;
-   end;
-{ reset file Handle }
-  FileRec(f).Handle:=UnusedHandle;
-
-{ We do the conversion of filemodes here, concentrated on 1 place }
-  case (flags and 3) of
-   0 : begin
-         oflags := 'rb'#0;
-         filerec(f).mode := fminput;
-       end;
-   1 : begin
-         if (flags and $1000)=$1000 then
-	   oflags := 'w+b' else
-           oflags := 'wb';
-         filerec(f).mode := fmoutput;
-       end;
-   2 : begin
-         if (flags and $1000)=$1000 then
-	   oflags := 'w+' else
-           oflags := 'r+';
-         filerec(f).mode := fminout;
-       end;
-  end;
-  {if (flags and $1000)=$1000 then
-   oflags:=oflags or (O_CREAT or O_TRUNC)
-  else
-   if (flags and $100)=$100 then
-    oflags:=oflags or (O_APPEND);}
-{ empty name is special }
-  if p[0]=#0 then
-   begin
-     case FileRec(f).mode of
-       fminput :
-         FileRec(f).Handle:=StdInputHandle;
-       fminout, { this is set by rewrite }
-       fmoutput :
-         FileRec(f).Handle:=StdOutputHandle;
-       fmappend :
-         begin
-           FileRec(f).Handle:=StdOutputHandle;
-           FileRec(f).mode:=fmoutput; {fool fmappend}
-         end;
-     end;
-     exit;
-   end;
-{ real open call }
-  FileRec(f).Handle := THandle (_fopen (p,@oflags[1]));//_open(p,oflags,438);
-  //WriteLn ('_open (',p,') returned ',ErrNo, 'Handle: ',FileRec(f).Handle);
-  // errno does not seem to be set on succsess ??
-  {IF FileRec(f).Handle < 0 THEN
-    if (ErrNo=Sys_EROFS) and ((OFlags and O_RDWR)<>0) then
-    begin  // i.e. for cd-rom
-      Oflags:=Oflags and not(O_RDWR);
-      FileRec(f).Handle := _open(p,oflags,438);
-    end;}
-  if FileRec(f).Handle = 0 then
-    Errno2Inoutres
-  else
-    InOutRes := 0;
-End;
-{$endif}
-
-function do_isdevice(handle:THandle):boolean;
-begin
-  {$ifdef IOpossix}
-  do_isdevice := (Fpisatty (handle) > 0);
-  {$else}
-  do_isdevice := (isatty (_fileno(_TFILE(handle))) > 0);
-  {$endif}
-end;
-
-
-{*****************************************************************************
-                           UnTyped File Handling
-*****************************************************************************}
-
-{$i file.inc}
-
-{*****************************************************************************
-                           Typed File Handling
-*****************************************************************************}
-
-{$i typefile.inc}
-
-{*****************************************************************************
-                           Text File Handling
-*****************************************************************************}
-
-{$i text.inc}
-
-{*****************************************************************************
-                           Directory Handling
-*****************************************************************************}
-procedure mkdir(const s : string);[IOCheck];
-var S2 : STRING;
-    Res: LONGINT;
-BEGIN
-  S2 := S;
-  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
-  S2 := S2 + #0;
-  Res := FpMkdir (@S2[1],S_IRWXU);
-  if Res = 0 then
-    InOutRes:=0
-  else
-    SetFileError (Res);
-end;
-
-procedure rmdir(const s : string);[IOCheck];
-VAR S2 : STRING;
-    Res: LONGINT;
-BEGIN
-  S2 := S;
-  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
-  S2 := S2 + #0;
-  Res := FpRmdir (@S2[1]);
-  IF Res = 0 THEN
-    InOutRes:=0
-  ELSE
-    SetFileError (Res);
-end;
-
-procedure chdir(const s : string);[IOCheck];
-VAR S2 : STRING;
-    Res: LONGINT;
-begin
-  S2 := S;
-  IF Length (S2) = 255 THEN DEC (BYTE(S2[0]));
-  S2 := S2 + #0;
-  Res := FpChdir (@S2[1]);
-  IF Res = 0 THEN
-    InOutRes:=0
-  ELSE
-    SetFileError (Res);
-end;
-
-procedure getdir(drivenr : byte;var dir : shortstring);
-var P : array [0..255] of CHAR;
-    i : LONGINT;
-begin
-  P[0] := #0;
-  getcwdpath(@P,nil,0);   // getcwd does not return volume, getcwdpath does
-  i := libc_strlen (P);
-  if i > 0 then
-  begin
-    Move (P, dir[1], i);
-    BYTE(dir[0]) := i;
-    For i := 1 to length (dir) do
-      if dir[i] = '\' then dir [i] := '/';
-    // fix / after volume, the compiler needs that
-    // normaly root of a volumes is SERVERNAME/SYS:, change that
-    // to SERVERNAME/SYS:/
-    i := pos (':',dir);
-    if (i > 0) then
-      if i = Length (dir) then dir := dir + '/' else
-      if dir [i+1] <> '/' then insert ('/',dir,i+1);
-  end else
-    InOutRes := 1;
-end;
-
 
 {*****************************************************************************
                              Thread Handling
@@ -1184,6 +549,7 @@ Begin
 {Delphi Compatible}
   IsConsole := TRUE;
   ExitCode  := 0;
+  InitSystemThreads;
 {$ifdef HASVARIANT}
   initvariantmanager;
 {$endif HASVARIANT}
@@ -1193,7 +559,10 @@ Begin
 End.
 {
   $Log$
-  Revision 1.12  2005-02-01 20:22:49  florian
+  Revision 1.13  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.12  2005/02/01 20:22:49  florian
     * improved widestring infrastructure manager
 
   Revision 1.11  2005/01/04 11:25:34  armin

+ 17 - 59
rtl/netwlibc/systhrds.pp → rtl/netwlibc/systhrd.inc

@@ -1,11 +1,10 @@
 {
     $Id$
     This file is part of the Free Pascal run time library.
-    Copyright (c) 2002-2004 by the Free Pascal development team.
+    Copyright (c) 2002 by Peter Vreman,
+    member of the Free Pascal development team.
 
-    netware (pthreads) threading support implementation, most of
-    this is copied from the linux implementation because netware
-    libc also provides pthreads
+    Linux (pthreads) threading support implementation
 
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
@@ -15,24 +14,6 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-{$mode objfpc}
-
-unit systhrds;
-interface
-{$S-}
-
-{ Posix compliant definition }
-
-uses Libc;
-
-type
-  PRTLCriticalSection = Ppthread_mutex_t;
-  TRTLCriticalSection = pthread_mutex_t;
-
-{$define DISABLE_NO_THREAD_MANAGER}
-{$i threadh.inc}
-
-implementation
 
 { ok, so this is a hack, but it works nicely. Just never use
   a multiline argument with WRITE_DEBUG! }
@@ -43,12 +24,6 @@ implementation
 {$define WRITE_DEBUG := //}      // just comment out those lines
 {$ENDIF}
 
-{*****************************************************************************
-                             Generic overloaded
-*****************************************************************************}
-
-{$i thread.inc}
-
 {*****************************************************************************
                              Threadvar support
 *****************************************************************************}
@@ -100,19 +75,14 @@ implementation
         _Free (pthread_getspecific(tlskey));
       end;
 
-    function SetThreadDataAreaPtr (newPtr:pointer):pointer;
+    function SysSetThreadDataAreaPtr (newPtr:pointer):pointer;
     begin
-      SetThreadDataAreaPtr := pthread_getspecific(tlskey);  // return current
+      SysSetThreadDataAreaPtr := pthread_getspecific(tlskey);  // return current
       if newPtr = nil then                                  // if nil
         newPtr := thredvarsmainthread;                      // set main thread vars
       pthread_setspecific(tlskey,newPtr);
     end;
 
-
-{ Include OS independent Threadvar initialization }
-{$i threadvr.inc}
-
-
 {$endif HASTHREADVAR}
 
 
@@ -256,7 +226,7 @@ implementation
     end;
 
 
-    function  SysThreadGetPriority (threadHandle : dword): Integer;
+    function  SysThreadGetPriority (threadHandle : dword): longint;
     begin
       {priority is ignored on netware}
       SysThreadGetPriority := 0;
@@ -340,11 +310,10 @@ implementation
       end;
 
 type
-     TPthreadMutex = ppthread_mutex_t;
      Tbasiceventstate=record
          FSem: Pointer;
          FManualReset: Boolean;
-         FEventSection: TPthreadMutex;
+         FEventSection: ppthread_mutex_t;
 	end;
      plocaleventstate = ^tbasiceventstate;
 //     peventstate=pointer;
@@ -434,7 +403,7 @@ end;
 Var
   NWThreadManager : TThreadManager;
 
-Procedure SetNWThreadManager;
+Procedure InitSystemThreads;
 
 begin
   With NWThreadManager do
@@ -469,34 +438,23 @@ begin
     end;
   SetThreadManager(NWThreadManager);
   InitHeapMutexes;
-end;
-
-initialization
   {$ifdef HASTHREADVAR}
   ThVarAllocResourceTag := AllocateResourceTag(getnlmhandle,'Threadvar Memory',AllocSignature);
   {$endif}
-  SetNWThreadManager;
   NWSysSetThreadFunctions (@SysAllocateThreadVars,
                            @SysReleaseThreadVars,
-                           @SetThreadDataAreaPtr);
+                           @SysSetThreadDataAreaPtr);
+end;
+
 
-end.
 {
   $Log$
-  Revision 1.3  2004-09-26 19:23:34  armin
-  * exiting threads at nlm unload
-  * renamed some libc functions
-
-  Revision 1.2  2004/09/19 20:06:37  armin
-  * removed get/free video buf from video.pp
-  * implemented sockets
-  * basic library support
-  * threadvar memory leak removed
-  * fixes (ide now starts and editor is usable)
-  * support for lineinfo
-
-  Revision 1.1  2004/09/05 20:58:47  armin
-  * first rtl version for netwlibc
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
 
 }
 

+ 66 - 67
rtl/os2/Makefile

@@ -249,103 +249,103 @@ endif
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_LOADERS+=prt0
@@ -447,103 +447,103 @@ ifeq ($(FULL_TARGET),arm-linux)
 override TARGET_LOADERS+=prt0
 endif
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-sunos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),sparc-sunos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
 endif
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
@@ -1963,7 +1963,6 @@ objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMUNIT)$(PPUEXT)
 strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
 		   $(SYSTEMUNIT)$(PPUEXT)
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
 ports$(PPUEXT) : ports.pas objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 doscalls$(PPUEXT) : doscalls.pas strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 kbdcalls$(PPUEXT) : kbdcalls.pas $(SYSTEMUNIT)$(PPUEXT)

+ 2 - 4
rtl/os2/Makefile.fpc

@@ -7,7 +7,7 @@ main=rtl
 
 [target]
 loaders=prt0
-units=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings \
+units=$(SYSTEMUNIT) ctypes objpas macpas strings \
       ports os2def doscalls moncalls kbdcalls moucalls viocalls \
       pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi \
       dos crt objects printer matrix \
@@ -15,7 +15,7 @@ units=$(SYSTEMUNIT) systhrds ctypes objpas macpas strings \
       charset ucomplex cpu mmx getopts heaptrc lineinfo dynlibs \
       video mouse keyboard variants types rtlconst sysconst dateutil \
       strutils convutil
-rsts=math varutils typinfo variants pmhelp classes sysconst dateutil systhrds
+rsts=math varutils typinfo variants pmhelp classes sysconst dateutil
 
 [require]
 nortl=y
@@ -95,8 +95,6 @@ strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
                    $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
                    $(SYSTEMUNIT)$(PPUEXT)
 
-systhrds$(PPUEXT): systhrds.pp $(INC)/threadh.inc $(SYSTEMUNIT)$(PPUEXT) objpas$(PPUEXT)
-
 #
 # System Dependent Units
 #

+ 157 - 0
rtl/os2/sysdir.inc

@@ -0,0 +1,157 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
+    member of the Free Pascal development team.
+
+    FPC Pascal system unit for the Win32 API.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+{*****************************************************************************
+                           Directory Handling
+*****************************************************************************}
+
+procedure MkDir (const S: string);[IOCHECK];
+var buffer:array[0..255] of char;
+    Rc : word;
+begin
+  If (s='') or (InOutRes <> 0) then
+   exit;
+      move(s[1],buffer,length(s));
+      buffer[length(s)]:=#0;
+      allowslash(Pchar(@buffer));
+      Rc := DosCreateDir(buffer,nil);
+      if Rc <> 0 then
+       begin
+         InOutRes := Rc;
+         Errno2Inoutres;
+       end;
+end;
+
+
+procedure rmdir(const s : string);[IOCHECK];
+var buffer:array[0..255] of char;
+    Rc : word;
+begin
+  if (s = '.' ) then
+    InOutRes := 16;
+  If (s='') or (InOutRes <> 0) then
+   exit;
+      move(s[1],buffer,length(s));
+      buffer[length(s)]:=#0;
+      allowslash(Pchar(@buffer));
+      Rc := DosDeleteDir(buffer);
+      if Rc <> 0 then
+       begin
+         InOutRes := Rc;
+         Errno2Inoutres;
+       end;
+end;
+
+{$ASMMODE INTEL}
+
+procedure ChDir (const S: string);[IOCheck];
+
+var RC: cardinal;
+    Buffer: array [0..255] of char;
+
+begin
+  If (s='') or (InOutRes <> 0) then exit;
+  if (Length (S) >= 2) and (S [2] = ':') then
+  begin
+    RC := DosSetDefaultDisk ((Ord (S [1]) and not ($20)) - $40);
+    if RC <> 0 then
+      InOutRes := RC
+    else
+      if Length (S) > 2 then
+      begin
+        Move (S [1], Buffer, Length (S));
+        Buffer [Length (S)] := #0;
+        AllowSlash (PChar (@Buffer));
+        RC := DosSetCurrentDir (@Buffer);
+        if RC <> 0 then
+        begin
+          InOutRes := RC;
+          Errno2InOutRes;
+        end;
+      end;
+  end else begin
+    Move (S [1], Buffer, Length (S));
+    Buffer [Length (S)] := #0;
+    AllowSlash (PChar (@Buffer));
+    RC := DosSetCurrentDir (@Buffer);
+    if RC <> 0 then
+    begin
+      InOutRes:= RC;
+      Errno2InOutRes;
+    end;
+  end;
+end;
+
+{$ASMMODE ATT}
+
+procedure GetDir (DriveNr: byte; var Dir: ShortString);
+{Written by Michael Van Canneyt.}
+var sof: Pchar;
+    i:byte;
+    l,l2:cardinal;
+begin
+    Dir [4] := #0;
+    { Used in case the specified drive isn't available }
+    sof:=pchar(@dir[4]);
+    { dir[1..3] will contain '[drivenr]:\', but is not }
+    { supplied by DOS, so we let dos string start at   }
+    { dir[4]                                           }
+    { Get dir from drivenr : 0=default, 1=A etc... }
+    l:=255-3;
+    InOutRes:=longint (DosQueryCurrentDir(DriveNr, sof^, l));
+{$WARNING Result code should be translated in some cases!}
+    { Now Dir should be filled with directory in ASCIIZ, }
+    { starting from dir[4]                               }
+    dir[0]:=#3;
+    dir[2]:=':';
+    dir[3]:='\';
+    i:=4;
+    {Conversion to Pascal string }
+    while (dir[i]<>#0) do
+        begin
+            { convert path name to DOS }
+            if dir[i]='/' then
+            dir[i]:='\';
+            dir[0]:=char(i);
+            inc(i);
+        end;
+    { upcase the string (FPC function) }
+    if drivenr<>0 then   { Drive was supplied. We know it }
+        dir[1]:=chr(64+drivenr)
+    else
+        begin
+            { We need to get the current drive from DOS function 19H  }
+            { because the drive was the default, which can be unknown }
+            DosQueryCurrentDisk(l, l2);
+            dir[1]:=chr(64+l);
+        end;
+    if not (FileNameCaseSensitive) then dir:=upcase(dir);
+end;
+
+
+
+{
+  $Log$
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
+
+}

+ 273 - 0
rtl/os2/sysfile.inc

@@ -0,0 +1,273 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    Low leve file functions
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{****************************************************************************
+
+                          Low Level File Routines
+
+****************************************************************************}
+
+procedure allowslash(p:Pchar);
+{Allow slash as backslash.}
+var i:longint;
+begin
+    for i:=0 to strlen(p) do
+        if p[i]='/' then p[i]:='\';
+end;
+
+procedure do_close(h:thandle);
+begin
+{ Only three standard handles under real OS/2 }
+  if h>2 then
+  begin
+    InOutRes:=DosClose(h);
+  end;
+{$ifdef IODEBUG}
+  writeln('do_close: handle=', H, ', InOutRes=', InOutRes);
+{$endif}
+end;
+
+procedure do_erase(p:Pchar);
+begin
+  allowslash(p);
+  inoutres:=DosDelete(p);
+end;
+
+procedure do_rename(p1,p2:Pchar);
+begin
+  allowslash(p1);
+  allowslash(p2);
+  inoutres:=DosMove(p1, p2);
+end;
+
+function do_read(h:thandle;addr:pointer;len:longint):longint;
+Var
+  T: cardinal;
+begin
+{$ifdef IODEBUG}
+  write('do_read: handle=', h, ', addr=', ptrint(addr), ', length=', len);
+{$endif}
+  InOutRes:=DosRead(H, Addr, Len, T);
+  do_read:= longint (T);
+{$ifdef IODEBUG}
+  writeln(', actual_len=', t, ', InOutRes=', InOutRes);
+{$endif}
+end;
+
+function do_write(h:thandle;addr:pointer;len:longint) : longint;
+Var
+  T: cardinal;
+begin
+{$ifdef IODEBUG}
+  write('do_write: handle=', h, ', addr=', ptrint(addr), ', length=', len);
+{$endif}
+  InOutRes:=DosWrite(H, Addr, Len, T);
+  do_write:= longint (T);
+{$ifdef IODEBUG}
+  writeln(', actual_len=', t, ', InOutRes=', InOutRes);
+{$endif}
+end;
+
+function do_filepos(handle:thandle): longint;
+var
+  PosActual: cardinal;
+begin
+  InOutRes:=DosSetFilePtr(Handle, 0, 1, PosActual);
+  do_filepos:=longint (PosActual);
+{$ifdef IODEBUG}
+  writeln('do_filepos: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
+{$endif}
+end;
+
+procedure do_seek(handle:thandle;pos:longint);
+var
+  PosActual: cardinal;
+begin
+  InOutRes:=DosSetFilePtr(Handle, Pos, 0 {ZeroBased}, PosActual);
+{$ifdef IODEBUG}
+  writeln('do_seek: handle=', Handle, ', pos=', pos, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
+{$endif}
+end;
+
+function do_seekend(handle:thandle):longint;
+var
+  PosActual: cardinal;
+begin
+  InOutRes:=DosSetFilePtr(Handle, 0, 2 {EndBased}, PosActual);
+  do_seekend:=longint (PosActual);
+{$ifdef IODEBUG}
+  writeln('do_seekend: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
+{$endif}
+end;
+
+function do_filesize(handle:thandle):longint;
+var aktfilepos: cardinal;
+begin
+  aktfilepos:=do_filepos(handle);
+  do_filesize:=do_seekend(handle);
+  do_seek(handle,aktfilepos);
+end;
+
+procedure do_truncate(handle:thandle;pos:longint);
+begin
+  InOutRes:=DosSetFileSize(Handle, Pos);
+  do_seekend(handle);
+end;
+
+const
+    FileHandleCount: cardinal = 20;
+
+function Increase_File_Handle_Count: boolean;
+var Err: word;
+    L1: longint;
+    L2: cardinal;
+begin
+  L1 := 10;
+  if DosSetRelMaxFH (L1, L2) <> 0 then
+    Increase_File_Handle_Count := false
+  else
+    if L2 > FileHandleCount then
+    begin
+      FileHandleCount := L2;
+      Increase_File_Handle_Count := true;
+    end
+    else
+      Increase_File_Handle_Count := false;
+end;
+
+procedure do_open(var f;p:pchar;flags:longint);
+{
+  filerec and textrec have both handle and mode as the first items so
+  they could use the same routine for opening/creating.
+
+  when (flags and $100)   the file will be append
+  when (flags and $1000)  the file will be truncate/rewritten
+  when (flags and $10000) there is no check for close (needed for textfiles)
+}
+var
+  Action, Attrib, OpenFlags, FM: Cardinal;
+begin
+  // convert unix slashes to normal slashes
+  allowslash(p);
+
+  // close first if opened
+  if ((flags and $10000)=0) then
+  begin
+    case filerec(f).mode of
+      fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
+      fmclosed:;
+    else
+      begin
+        inoutres:=102; {not assigned}
+        exit;
+      end;
+    end;
+  end;
+
+  // reset file handle
+  filerec(f).handle := UnusedHandle;
+
+  Attrib:=0;
+  OpenFlags:=0;
+
+  // convert filesharing
+  FM := Flags and $FF and not (8);
+(* DenyNone if sharing not specified. *)
+  if FM and 112 = 0 then
+    FM := FM or 64;
+  // convert filemode to filerec modes and access mode
+  case (FM and 3) of
+    0: filerec(f).mode:=fminput;
+    1: filerec(f).mode:=fmoutput;
+    2: filerec(f).mode:=fminout;
+  end;
+
+  if (flags and $1000)<>0 then
+    OpenFlags:=OpenFlags or 2 {doOverwrite} or 16 {doCreate} // Create/overwrite
+  else
+    OpenFlags:=OpenFlags or 1 {doOpen}; // Open existing
+
+  // Handle Std I/O
+  if p[0]=#0 then
+  begin
+    case FileRec(f).mode of
+      fminput :
+        FileRec(f).Handle:=StdInputHandle;
+      fminout, // this is set by rewrite
+      fmoutput :
+        FileRec(f).Handle:=StdOutputHandle;
+      fmappend :
+        begin
+          FileRec(f).Handle:=StdOutputHandle;
+          FileRec(f).mode:=fmoutput; // fool fmappend
+        end;
+    end;
+    exit;
+  end;
+
+  Attrib:=32 {faArchive};
+
+  InOutRes:=DosOpen(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil);
+
+  // If too many open files try to set more file handles and open again
+  if (InOutRes = 4) then
+    if Increase_File_Handle_Count then
+      InOutRes:=DosOpen(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil);
+
+  If InOutRes<>0 then FileRec(F).Handle:=UnusedHandle;
+
+  // If Handle created -> make some things
+  if (FileRec(F).Handle <> UnusedHandle) then
+  begin
+
+    // Move to end of file for Append command
+    if ((Flags and $100) <> 0) then
+    begin
+      do_seekend(FileRec(F).Handle);
+      FileRec(F).Mode := fmOutput;
+    end;
+
+  end;
+
+{$ifdef IODEBUG}
+  writeln('do_open,', filerec(f).handle, ',', filerec(f).name, ',', filerec(f).mode, ', InOutRes=', InOutRes);
+{$endif}
+end;
+
+function do_isdevice (Handle: THandle): boolean;
+var
+  HT, Attr: cardinal;
+begin
+  do_isdevice:=false;
+  If DosQueryHType(Handle, HT, Attr)<>0 then exit;
+  if ht=1 then do_isdevice:=true;
+end;
+{$ASMMODE ATT}
+
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 175 - 0
rtl/os2/sysheap.inc

@@ -0,0 +1,175 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+{****************************************************************************
+
+                    Heap management releated routines.
+
+****************************************************************************}
+
+{Get some memory.
+ P          = Pointer to memory will be returned here.
+ Size       = Number of bytes to get. The size is rounded up to a multiple
+              of 4096. This is probably not the case on non-intel 386
+              versions of OS/2.
+ Flags      = One or more of the mfXXXX constants.}
+
+function DosAllocMem(var P:pointer;Size,Flag:cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 299;
+
+function DosSetMem(P:pointer;Size,Flag:cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 305;
+
+function DosFreeMem (P: pointer): cardinal; cdecl;
+external 'DOSCALLS' index 304;
+
+{$IFDEF DUMPGROW}
+ {$DEFINE EXTDUMPGROW}
+{$ENDIF DUMPGROW}
+
+{$IFDEF EXTDUMPGROW}
+var
+  Int_HeapSize: cardinal;
+{$ENDIF EXTDUMPGROW}
+
+{function GetHeapSize: longint; assembler;
+asm
+  movl Int_HeapSize, %eax
+end ['EAX'];
+}
+
+
+function SysOSAlloc (Size: PtrInt): pointer;
+var
+  P: pointer;
+  RC: cardinal;
+begin
+{$IFDEF EXTDUMPGROW}
+  if Int_HeapSize <> high (cardinal) then
+{
+  if Int_HeapSize = high (cardinal) then
+   WriteLn ('Trying to allocate first heap of size ', Size)
+  else
+}
+   WriteLn ('Trying to grow heap by ', Size, ' to ', Int_HeapSize);
+{$ENDIF}
+
+  if UseHighMem then
+   RC := DosAllocMem (P, Size, $403)
+  else
+   RC := DosAllocMem (P, Size, 3);
+  if RC = 0 then
+   begin
+{$IFDEF EXTDUMPGROW}
+  if Int_HeapSize <> high (cardinal) then
+    WriteLn ('DosAllocMem returned memory at ', cardinal (P));
+{$ENDIF}
+    RC := DosSetMem (P, Size, $410);
+    if RC = 0 then
+     begin
+{$IFDEF EXTDUMPGROW}
+      if Int_HeapSize <> high (cardinal) then
+       WriteLn ('New heap at ', cardinal (P));
+{$ENDIF EXTDUMPGROW}
+      SysOSAlloc := P;
+{$IFDEF EXTDUMPGROW}
+      if Int_HeapSize = high (cardinal) then
+       Int_HeapSize := Size
+      else
+       Inc (Int_HeapSize, Size);
+{$ENDIF EXTDUMPGROW}
+     end
+    else
+     begin
+{$IFDEF EXTDUMPGROW}
+      if Int_HeapSize <> high (cardinal) then
+       begin
+        WriteLn ('Error ', RC, ' in DosSetMem while trying to commit memory!');
+{      if Int_HeapSize = high (cardinal) then
+        WriteLn ('No allocated memory comitted yet!')
+       else
+}
+        WriteLn ('Total allocated memory is ', Int_HeapSize);
+       end;
+{$ENDIF EXTDUMPGROW}
+      RC := DosFreeMem (P);
+      SysOSAlloc := nil;
+     end;
+   end
+  else
+   begin
+    SysOSAlloc := nil;
+{$IFDEF EXTDUMPGROW}
+    if Int_HeapSize <> high (cardinal) then
+     begin
+      WriteLn ('Error ', RC, ' during additional memory allocation (DosAllocMem)!');
+{     if Int_HeapSize = high (cardinal) then
+       WriteLn ('No memory allocated yet!')
+      else
+}
+      WriteLn ('Total allocated memory is ', Int_HeapSize);
+     end;
+{$ENDIF EXTDUMPGROW}
+   end;
+end;
+
+{$define HAS_SYSOSFREE}
+
+procedure SysOSFree (P: pointer; Size: PtrInt);
+var
+  RC: cardinal;
+begin
+{$IFDEF EXTDUMPGROW}
+  WriteLn ('Trying to free memory!');
+  WriteLn ('Total allocated memory is ', Int_HeapSize);
+  Dec (Int_HeapSize, Size);
+{$ENDIF EXTDUMPGROW}
+  RC := DosSetMem (P, Size, $20);
+  if RC = 0 then
+   begin
+    RC := DosFreeMem (P);
+{$IFDEF EXTDUMPGROW}
+    if RC <> 0 then
+     begin
+      WriteLn ('Error ', RC, ' during memory deallocation (DosFreeMem)!');
+      WriteLn ('Total allocated memory is ', Int_HeapSize);
+     end;
+{$ENDIF EXTDUMPGROW}
+   end
+{$IFDEF EXTDUMPGROW}
+  else
+   begin
+    WriteLn ('Error ', RC, ' in DosSetMem while trying to decommit memory!');
+    WriteLn ('Total allocated memory is ', Int_HeapSize);
+   end;
+{$ENDIF EXTDUMPGROW}
+end;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 316 - 0
rtl/os2/sysos.inc

@@ -0,0 +1,316 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+var
+  ProcessID: SizeUInt;
+
+function GetProcessID:SizeUInt;
+begin
+ GetProcessID := ProcessID;
+end;
+
+procedure DosGetInfoBlocks (PATIB: PPThreadInfoBlock;
+                            PAPIB: PPProcessInfoBlock); cdecl;
+                            external 'DOSCALLS' index 312;
+
+function DosLoadModule (ObjName: PChar; ObjLen: cardinal; DLLName: PChar;
+                                        var Handle: cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 318;
+
+function DosQueryProcAddr (Handle, Ordinal: cardinal; ProcName: PChar;
+                                        var Address: pointer): cardinal; cdecl;
+external 'DOSCALLS' index 321;
+
+function DosSetRelMaxFH (var ReqCount: longint; var CurMaxFH: cardinal):
+                                                               cardinal; cdecl;
+external 'DOSCALLS' index 382;
+
+function DosSetCurrentDir (Name:PChar): cardinal; cdecl;
+external 'DOSCALLS' index 255;
+
+procedure DosQueryCurrentDisk(var DiskNum:cardinal;var Logical:cardinal); cdecl;
+external 'DOSCALLS' index 275;
+
+function DosSetDefaultDisk (DiskNum:cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 220;
+
+{ This is not real prototype, but is close enough }
+{ for us (the 2nd parameter is actually a pointer }
+{ to a structure).                                }
+function DosCreateDir (Name: PChar; P: pointer): cardinal; cdecl;
+external 'DOSCALLS' index 270;
+
+function DosDeleteDir (Name: PChar): cardinal; cdecl;
+external 'DOSCALLS' index 226;
+
+function DosQueryCurrentDir(DiskNum:cardinal;var Buffer;
+                            var BufLen:cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 274;
+
+function DosMove(OldFile,NewFile:PChar):cardinal; cdecl;
+    external 'DOSCALLS' index 271;
+
+function DosDelete(FileName:PChar):cardinal; cdecl;
+    external 'DOSCALLS' index 259;
+
+procedure DosExit(Action, Result: cardinal); cdecl;
+    external 'DOSCALLS' index 234;
+
+// EAs not used in System unit
+function DosOpen(FileName:PChar;var Handle: THandle;var Action:cardinal;
+                 InitSize,Attrib,OpenFlags,FileMode:cardinal;
+                 EA:Pointer): cardinal; cdecl;
+    external 'DOSCALLS' index 273;
+
+function DosClose(Handle: THandle): cardinal; cdecl;
+    external 'DOSCALLS' index 257;
+
+function DosRead(Handle: THandle; Buffer: Pointer; Count: cardinal;
+                                      var ActCount: cardinal): cardinal; cdecl;
+    external 'DOSCALLS' index 281;
+
+function DosWrite(Handle: THandle; Buffer: Pointer;Count: cardinal;
+                                      var ActCount: cardinal): cardinal; cdecl;
+    external 'DOSCALLS' index 282;
+
+function DosSetFilePtr(Handle: THandle; Pos:longint; Method:cardinal;
+                                     var PosActual: cardinal): cardinal; cdecl;
+    external 'DOSCALLS' index 256;
+
+function DosSetFileSize(Handle: THandle; Size: cardinal): cardinal; cdecl;
+    external 'DOSCALLS' index 272;
+
+function DosQueryHType(Handle: THandle; var HandType: cardinal;
+                                          var Attr: cardinal): cardinal; cdecl;
+    external 'DOSCALLS' index 224;
+
+type
+  TSysDateTime=packed record
+    Hour,
+    Minute,
+    Second,
+    Sec100,
+    Day,
+    Month: byte;
+    Year: word;
+    TimeZone: smallint;
+    WeekDay: byte;
+  end;
+
+function DosGetDateTime(var Buf:TSysDateTime): cardinal; cdecl;
+    external 'DOSCALLS' index 230;
+
+   { converts an OS/2 error code to a TP compatible error }
+   { code. Same thing exists under most other supported   }
+   { systems.                                             }
+   { Only call for OS/2 DLL imported routines             }
+   Procedure Errno2InOutRes;
+   Begin
+     { errors 1..18 are the same as in DOS }
+     case InOutRes of
+      { simple offset to convert these error codes }
+      { exactly like the error codes in Win32      }
+      19..31 : InOutRes := InOutRes + 131;
+      { gets a bit more complicated ... }
+      32..33 : InOutRes := 5;
+      38 : InOutRes := 100;
+      39 : InOutRes := 101;
+      112 : InOutRes := 101;
+      110 : InOutRes := 5;
+      114 : InOutRes := 6;
+      290 : InOutRes := 290;
+     end;
+     { all other cases ... we keep the same error code }
+   end;
+
+
+{$IFDEF OS2EXCEPTIONS}
+(*
+The operating system defines a class of error conditions called exceptions, and specifies the default actions that are taken when these exceptions occur. The system default action in most cases is to terminate the thread that caused the exception.
+
+Exception values have the following 32-bit format:
+
+ 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ÚÄÄÄÂÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
+³Sev³C³       Facility          ³               Code            ³
+ÀÄÄÄÁÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
+
+
+Sev Severity code. Possible values are described in the following list:
+
+00 Success
+01 Informational
+10 Warning
+11 Error
+
+C Customer code flag.
+
+Facility Facility code.
+
+Code Facility's status code.
+
+Exceptions that are specific to OS/2 Version 2.X (for example, XCPT_SIGNAL)
+have a facility code of 1.
+
+System exceptions include both synchronous and asynchronous exceptions.
+Synchronous exceptions are caused by events that are internal to a thread's
+execution. For example, synchronous exceptions could be caused by invalid
+parameters, or by a thread's request to end its own execution.
+
+Asynchronous exceptions are caused by events that are external to a thread's
+execution. For example, an asynchronous exception can be caused by a user's
+entering a Ctrl+C or Ctrl+Break key sequence, or by a process' issuing
+DosKillProcess to end the execution of another process.
+
+The Ctrl+Break and Ctrl+C exceptions are also known as signals, or as signal
+exceptions.
+
+The following tables show the symbolic names of system exceptions, their
+numerical values, and related information fields.
+
+Portable, Non-Fatal, Software-Generated Exceptions
+
+ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
+³Exception Name                       ³Value     ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_GUARD_PAGE_VIOLATION            ³0x80000001³
+³  ExceptionInfo[0] - R/W flag        ³          ³
+³  ExceptionInfo[1] - FaultAddr       ³          ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_UNABLE_TO_GROW_STACK            ³0x80010001³
+ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
+
+
+Portable, Fatal, Hardware-Generated Exceptions
+
+ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
+³Exception Name                       ³Value     ³Related Trap ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_ACCESS_VIOLATION                ³0xC0000005³0x09, 0x0B,  ³
+³  ExceptionInfo[0] - Flags           ³          ³0x0C, 0x0D,  ³
+³    XCPT_UNKNOWN_ACCESS  0x0         ³          ³0x0E         ³
+³    XCPT_READ_ACCESS     0x1         ³          ³             ³
+³    XCPT_WRITE_ACCESS    0x2         ³          ³             ³
+³    XCPT_EXECUTE_ACCESS  0x4         ³          ³             ³
+³    XCPT_SPACE_ACCESS    0x8         ³          ³             ³
+³    XCPT_LIMIT_ACCESS    0x10        ³          ³             ³
+³  ExceptionInfo[1] - FaultAddr       ³          ³             ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_INTEGER_DIVIDE_BY_ZERO          ³0xC000009B³0            ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_FLOAT_DIVIDE_BY_ZERO            ³0xC0000095³0x10         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_FLOAT_INVALID_OPERATION         ³0xC0000097³0x10         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_ILLEGAL_INSTRUCTION             ³0xC000001C³0x06         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_PRIVILEGED_INSTRUCTION          ³0xC000009D³0x0D         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_INTEGER_OVERFLOW                ³0xC000009C³0x04         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_FLOAT_OVERFLOW                  ³0xC0000098³0x10         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_FLOAT_UNDERFLOW                 ³0xC000009A³0x10         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_FLOAT_DENORMAL_OPERAND          ³0xC0000094³0x10         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_FLOAT_INEXACT_RESULT            ³0xC0000096³0x10         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_FLOAT_STACK_CHECK               ³0xC0000099³0x10         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_DATATYPE_MISALIGNMENT           ³0xC000009E³0x11         ³
+³  ExceptionInfo[0] - R/W flag        ³          ³             ³
+³  ExceptionInfo[1] - Alignment       ³          ³             ³
+³  ExceptionInfo[2] - FaultAddr       ³          ³             ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_BREAKPOINT                      ³0xC000009F³0x03         ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_SINGLE_STEP                     ³0xC00000A0³0x01         ³
+ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
+
+
+Portable, Fatal, Software-Generated Exceptions
+
+ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
+³Exception Name                       ³Value     ³Related Trap ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_IN_PAGE_ERROR                   ³0xC0000006³0x0E         ³
+³  ExceptionInfo[0] - FaultAddr       ³          ³             ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_PROCESS_TERMINATE               ³0xC0010001³             ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_ASYNC_PROCESS_TERMINATE         ³0xC0010002³             ³
+³  ExceptionInfo[0] - TID of          ³          ³             ³
+³      terminating thread             ³          ³             ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_NONCONTINUABLE_EXCEPTION        ³0xC0000024³             ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_INVALID_DISPOSITION             ³0xC0000025³             ³
+ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
+
+
+Non-Portable, Fatal Exceptions
+
+ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
+³Exception Name                       ³Value     ³Related Trap ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_INVALID_LOCK_SEQUENCE           ³0xC000001D³             ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_ARRAY_BOUNDS_EXCEEDED           ³0xC0000093³0x05         ³
+ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
+
+
+Unwind Operation Exceptions
+
+ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
+³Exception Name                       ³Value     ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_UNWIND                          ³0xC0000026³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_BAD_STACK                       ³0xC0000027³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_INVALID_UNWIND_TARGET           ³0xC0000028³
+ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
+
+
+Fatal Signal Exceptions
+
+ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
+³Exception Name                       ³Value     ³
+ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
+³XCPT_SIGNAL                          ³0xC0010003³
+³  ExceptionInfo[ 0 ] - Signal        ³          ³
+³      Number                         ³          ³
+ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
+*)
+{$ENDIF OS2EXCEPTIONS}
+
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 47 - 0
rtl/os2/sysosh.inc

@@ -0,0 +1,47 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2001 by Free Pascal development team
+
+    This file implements all the base types and limits required
+    for a minimal POSIX compliant subset required to port the compiler
+    to a new OS.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{Platform specific information}
+type
+  THandle = Longint;
+
+    { the fields of this record are os dependent  }
+    { and they shouldn't be used in a program     }
+    { only the type TCriticalSection is important }
+    PRTLCriticalSection = ^TRTLCriticalSection;
+    TRTLCriticalSection = packed record
+      DebugInfo : pointer;
+      LockCount : longint;
+      RecursionCount : longint;
+      OwningThread : DWord;
+      LockSemaphore : DWord;
+      Reserved : DWord;
+    end;
+
+
+{
+   $Log$
+   Revision 1.1  2005-02-06 16:57:18  peter
+     * threads for go32v2,os,emx,netware
+
+   Revision 1.1  2005/02/06 13:06:20  peter
+     * moved file and dir functions to sysfile/sysdir
+     * win32 thread in systemunit
+
+}
+

+ 8 - 839
rtl/os2/system.pas

@@ -27,6 +27,8 @@ interface
   {.$define DEBUGARGUMENTS}
 {$endif SYSTEMDEBUG}
 
+{$DEFINE EOF_CTRLZ}
+
 { $DEFINE OS2EXCEPTIONS}
 
 {$I systemh.inc}
@@ -42,12 +44,6 @@ type
 
 {$ENDIF OS2EXCEPTIONS}
 
-{$I heaph.inc}
-
-{Platform specific information}
-type
-  THandle = Longint;
-
 const
   LineEnding = #13#10;
 { LFNSupport is defined separately below!!! }
@@ -151,292 +147,6 @@ implementation
 
 {$I system.inc}
 
-var
-  ProcessID: SizeUInt;
-
-function GetProcessID:SizeUInt;
-begin
- GetProcessID := ProcessID;
-end;
-
-procedure DosGetInfoBlocks (PATIB: PPThreadInfoBlock;
-                            PAPIB: PPProcessInfoBlock); cdecl;
-                            external 'DOSCALLS' index 312;
-
-function DosLoadModule (ObjName: PChar; ObjLen: cardinal; DLLName: PChar;
-                                        var Handle: cardinal): cardinal; cdecl;
-external 'DOSCALLS' index 318;
-
-function DosQueryProcAddr (Handle, Ordinal: cardinal; ProcName: PChar;
-                                        var Address: pointer): cardinal; cdecl;
-external 'DOSCALLS' index 321;
-
-function DosSetRelMaxFH (var ReqCount: longint; var CurMaxFH: cardinal):
-                                                               cardinal; cdecl;
-external 'DOSCALLS' index 382;
-
-function DosSetCurrentDir (Name:PChar): cardinal; cdecl;
-external 'DOSCALLS' index 255;
-
-procedure DosQueryCurrentDisk(var DiskNum:cardinal;var Logical:cardinal); cdecl;
-external 'DOSCALLS' index 275;
-
-function DosSetDefaultDisk (DiskNum:cardinal): cardinal; cdecl;
-external 'DOSCALLS' index 220;
-
-{ This is not real prototype, but is close enough }
-{ for us (the 2nd parameter is actually a pointer }
-{ to a structure).                                }
-function DosCreateDir (Name: PChar; P: pointer): cardinal; cdecl;
-external 'DOSCALLS' index 270;
-
-function DosDeleteDir (Name: PChar): cardinal; cdecl;
-external 'DOSCALLS' index 226;
-
-function DosQueryCurrentDir(DiskNum:cardinal;var Buffer;
-                            var BufLen:cardinal): cardinal; cdecl;
-external 'DOSCALLS' index 274;
-
-function DosMove(OldFile,NewFile:PChar):cardinal; cdecl;
-    external 'DOSCALLS' index 271;
-
-function DosDelete(FileName:PChar):cardinal; cdecl;
-    external 'DOSCALLS' index 259;
-
-procedure DosExit(Action, Result: cardinal); cdecl;
-    external 'DOSCALLS' index 234;
-
-// EAs not used in System unit
-function DosOpen(FileName:PChar;var Handle: THandle;var Action:cardinal;
-                 InitSize,Attrib,OpenFlags,FileMode:cardinal;
-                 EA:Pointer): cardinal; cdecl;
-    external 'DOSCALLS' index 273;
-
-function DosClose(Handle: THandle): cardinal; cdecl;
-    external 'DOSCALLS' index 257;
-
-function DosRead(Handle: THandle; Buffer: Pointer; Count: cardinal;
-                                      var ActCount: cardinal): cardinal; cdecl;
-    external 'DOSCALLS' index 281;
-
-function DosWrite(Handle: THandle; Buffer: Pointer;Count: cardinal;
-                                      var ActCount: cardinal): cardinal; cdecl;
-    external 'DOSCALLS' index 282;
-
-function DosSetFilePtr(Handle: THandle; Pos:longint; Method:cardinal;
-                                     var PosActual: cardinal): cardinal; cdecl;
-    external 'DOSCALLS' index 256;
-
-function DosSetFileSize(Handle: THandle; Size: cardinal): cardinal; cdecl;
-    external 'DOSCALLS' index 272;
-
-function DosQueryHType(Handle: THandle; var HandType: cardinal;
-                                          var Attr: cardinal): cardinal; cdecl;
-    external 'DOSCALLS' index 224;
-
-type
-  TSysDateTime=packed record
-    Hour,
-    Minute,
-    Second,
-    Sec100,
-    Day,
-    Month: byte;
-    Year: word;
-    TimeZone: smallint;
-    WeekDay: byte;
-  end;
-
-function DosGetDateTime(var Buf:TSysDateTime): cardinal; cdecl;
-    external 'DOSCALLS' index 230;
-
-   { converts an OS/2 error code to a TP compatible error }
-   { code. Same thing exists under most other supported   }
-   { systems.                                             }
-   { Only call for OS/2 DLL imported routines             }
-   Procedure Errno2InOutRes;
-   Begin
-     { errors 1..18 are the same as in DOS }
-     case InOutRes of
-      { simple offset to convert these error codes }
-      { exactly like the error codes in Win32      }
-      19..31 : InOutRes := InOutRes + 131;
-      { gets a bit more complicated ... }
-      32..33 : InOutRes := 5;
-      38 : InOutRes := 100;
-      39 : InOutRes := 101;
-      112 : InOutRes := 101;
-      110 : InOutRes := 5;
-      114 : InOutRes := 6;
-      290 : InOutRes := 290;
-     end;
-     { all other cases ... we keep the same error code }
-   end;
-
-
-{$IFDEF OS2EXCEPTIONS}
-(*
-The operating system defines a class of error conditions called exceptions, and specifies the default actions that are taken when these exceptions occur. The system default action in most cases is to terminate the thread that caused the exception.
-
-Exception values have the following 32-bit format:
-
- 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
- 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-ÚÄÄÄÂÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
-³Sev³C³       Facility          ³               Code            ³
-ÀÄÄÄÁÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Sev Severity code. Possible values are described in the following list:
-
-00 Success
-01 Informational
-10 Warning
-11 Error
-
-C Customer code flag.
-
-Facility Facility code.
-
-Code Facility's status code.
-
-Exceptions that are specific to OS/2 Version 2.X (for example, XCPT_SIGNAL)
-have a facility code of 1.
-
-System exceptions include both synchronous and asynchronous exceptions.
-Synchronous exceptions are caused by events that are internal to a thread's
-execution. For example, synchronous exceptions could be caused by invalid
-parameters, or by a thread's request to end its own execution.
-
-Asynchronous exceptions are caused by events that are external to a thread's
-execution. For example, an asynchronous exception can be caused by a user's
-entering a Ctrl+C or Ctrl+Break key sequence, or by a process' issuing
-DosKillProcess to end the execution of another process.
-
-The Ctrl+Break and Ctrl+C exceptions are also known as signals, or as signal
-exceptions.
-
-The following tables show the symbolic names of system exceptions, their
-numerical values, and related information fields.
-
-Portable, Non-Fatal, Software-Generated Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_GUARD_PAGE_VIOLATION            ³0x80000001³
-³  ExceptionInfo[0] - R/W flag        ³          ³
-³  ExceptionInfo[1] - FaultAddr       ³          ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_UNABLE_TO_GROW_STACK            ³0x80010001³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Portable, Fatal, Hardware-Generated Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³Related Trap ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_ACCESS_VIOLATION                ³0xC0000005³0x09, 0x0B,  ³
-³  ExceptionInfo[0] - Flags           ³          ³0x0C, 0x0D,  ³
-³    XCPT_UNKNOWN_ACCESS  0x0         ³          ³0x0E         ³
-³    XCPT_READ_ACCESS     0x1         ³          ³             ³
-³    XCPT_WRITE_ACCESS    0x2         ³          ³             ³
-³    XCPT_EXECUTE_ACCESS  0x4         ³          ³             ³
-³    XCPT_SPACE_ACCESS    0x8         ³          ³             ³
-³    XCPT_LIMIT_ACCESS    0x10        ³          ³             ³
-³  ExceptionInfo[1] - FaultAddr       ³          ³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INTEGER_DIVIDE_BY_ZERO          ³0xC000009B³0            ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_DIVIDE_BY_ZERO            ³0xC0000095³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_INVALID_OPERATION         ³0xC0000097³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_ILLEGAL_INSTRUCTION             ³0xC000001C³0x06         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_PRIVILEGED_INSTRUCTION          ³0xC000009D³0x0D         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INTEGER_OVERFLOW                ³0xC000009C³0x04         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_OVERFLOW                  ³0xC0000098³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_UNDERFLOW                 ³0xC000009A³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_DENORMAL_OPERAND          ³0xC0000094³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_INEXACT_RESULT            ³0xC0000096³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_STACK_CHECK               ³0xC0000099³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_DATATYPE_MISALIGNMENT           ³0xC000009E³0x11         ³
-³  ExceptionInfo[0] - R/W flag        ³          ³             ³
-³  ExceptionInfo[1] - Alignment       ³          ³             ³
-³  ExceptionInfo[2] - FaultAddr       ³          ³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_BREAKPOINT                      ³0xC000009F³0x03         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_SINGLE_STEP                     ³0xC00000A0³0x01         ³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Portable, Fatal, Software-Generated Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³Related Trap ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_IN_PAGE_ERROR                   ³0xC0000006³0x0E         ³
-³  ExceptionInfo[0] - FaultAddr       ³          ³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_PROCESS_TERMINATE               ³0xC0010001³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_ASYNC_PROCESS_TERMINATE         ³0xC0010002³             ³
-³  ExceptionInfo[0] - TID of          ³          ³             ³
-³      terminating thread             ³          ³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_NONCONTINUABLE_EXCEPTION        ³0xC0000024³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INVALID_DISPOSITION             ³0xC0000025³             ³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Non-Portable, Fatal Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³Related Trap ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INVALID_LOCK_SEQUENCE           ³0xC000001D³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_ARRAY_BOUNDS_EXCEEDED           ³0xC0000093³0x05         ³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Unwind Operation Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_UNWIND                          ³0xC0000026³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_BAD_STACK                       ³0xC0000027³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INVALID_UNWIND_TARGET           ³0xC0000028³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Fatal Signal Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_SIGNAL                          ³0xC0010003³
-³  ExceptionInfo[ 0 ] - Signal        ³          ³
-³      Number                         ³          ³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
-*)
-{$ENDIF OS2EXCEPTIONS}
-
-
 
 {****************************************************************************
 
@@ -446,6 +156,7 @@ Fatal Signal Exceptions
 
 procedure system_exit;
 begin
+  DosFreeThreadLocalMemory (DataIndex);
   DosExit(1{process}, exitcode);
 end;
 
@@ -487,551 +198,6 @@ end;
 
 {$ASMMODE ATT}
 
-{****************************************************************************
-
-                    Heap management releated routines.
-
-****************************************************************************}
-
-{Get some memory.
- P          = Pointer to memory will be returned here.
- Size       = Number of bytes to get. The size is rounded up to a multiple
-              of 4096. This is probably not the case on non-intel 386
-              versions of OS/2.
- Flags      = One or more of the mfXXXX constants.}
-
-function DosAllocMem(var P:pointer;Size,Flag:cardinal): cardinal; cdecl;
-external 'DOSCALLS' index 299;
-
-function DosSetMem(P:pointer;Size,Flag:cardinal): cardinal; cdecl;
-external 'DOSCALLS' index 305;
-
-function DosFreeMem (P: pointer): cardinal; cdecl;
-external 'DOSCALLS' index 304;
-
-{$IFDEF DUMPGROW}
- {$DEFINE EXTDUMPGROW}
-{$ENDIF DUMPGROW}
-
-{$IFDEF EXTDUMPGROW}
-var
-  Int_HeapSize: cardinal;
-{$ENDIF EXTDUMPGROW}
-
-{function GetHeapSize: longint; assembler;
-asm
-  movl Int_HeapSize, %eax
-end ['EAX'];
-}
-
-
-function SysOSAlloc (Size: PtrInt): pointer;
-var
-  P: pointer;
-  RC: cardinal;
-begin
-{$IFDEF EXTDUMPGROW}
-  if Int_HeapSize <> high (cardinal) then
-{
-  if Int_HeapSize = high (cardinal) then
-   WriteLn ('Trying to allocate first heap of size ', Size)
-  else
-}
-   WriteLn ('Trying to grow heap by ', Size, ' to ', Int_HeapSize);
-{$ENDIF}
-
-  if UseHighMem then
-   RC := DosAllocMem (P, Size, $403)
-  else
-   RC := DosAllocMem (P, Size, 3);
-  if RC = 0 then
-   begin
-{$IFDEF EXTDUMPGROW}
-  if Int_HeapSize <> high (cardinal) then
-    WriteLn ('DosAllocMem returned memory at ', cardinal (P));
-{$ENDIF}
-    RC := DosSetMem (P, Size, $410);
-    if RC = 0 then
-     begin
-{$IFDEF EXTDUMPGROW}
-      if Int_HeapSize <> high (cardinal) then
-       WriteLn ('New heap at ', cardinal (P));
-{$ENDIF EXTDUMPGROW}
-      SysOSAlloc := P;
-{$IFDEF EXTDUMPGROW}
-      if Int_HeapSize = high (cardinal) then
-       Int_HeapSize := Size
-      else
-       Inc (Int_HeapSize, Size);
-{$ENDIF EXTDUMPGROW}
-     end
-    else
-     begin
-{$IFDEF EXTDUMPGROW}
-      if Int_HeapSize <> high (cardinal) then
-       begin
-        WriteLn ('Error ', RC, ' in DosSetMem while trying to commit memory!');
-{      if Int_HeapSize = high (cardinal) then
-        WriteLn ('No allocated memory comitted yet!')
-       else
-}
-        WriteLn ('Total allocated memory is ', Int_HeapSize);
-       end;
-{$ENDIF EXTDUMPGROW}
-      RC := DosFreeMem (P);
-      SysOSAlloc := nil;
-     end;
-   end
-  else
-   begin
-    SysOSAlloc := nil;
-{$IFDEF EXTDUMPGROW}
-    if Int_HeapSize <> high (cardinal) then
-     begin
-      WriteLn ('Error ', RC, ' during additional memory allocation (DosAllocMem)!');
-{     if Int_HeapSize = high (cardinal) then
-       WriteLn ('No memory allocated yet!')
-      else
-}
-      WriteLn ('Total allocated memory is ', Int_HeapSize);
-     end;
-{$ENDIF EXTDUMPGROW}
-   end;
-end;
-
-{$define HAS_SYSOSFREE}
-
-procedure SysOSFree (P: pointer; Size: PtrInt);
-var
-  RC: cardinal;
-begin
-{$IFDEF EXTDUMPGROW}
-  WriteLn ('Trying to free memory!');
-  WriteLn ('Total allocated memory is ', Int_HeapSize);
-  Dec (Int_HeapSize, Size);
-{$ENDIF EXTDUMPGROW}
-  RC := DosSetMem (P, Size, $20);
-  if RC = 0 then
-   begin
-    RC := DosFreeMem (P);
-{$IFDEF EXTDUMPGROW}
-    if RC <> 0 then
-     begin
-      WriteLn ('Error ', RC, ' during memory deallocation (DosFreeMem)!');
-      WriteLn ('Total allocated memory is ', Int_HeapSize);
-     end;
-{$ENDIF EXTDUMPGROW}
-   end
-{$IFDEF EXTDUMPGROW}
-  else
-   begin
-    WriteLn ('Error ', RC, ' in DosSetMem while trying to decommit memory!');
-    WriteLn ('Total allocated memory is ', Int_HeapSize);
-   end;
-{$ENDIF EXTDUMPGROW}
-end;
-
-{$i heap.inc}
-
-
-
-{****************************************************************************
-
-                          Low Level File Routines
-
-****************************************************************************}
-
-procedure allowslash(p:Pchar);
-{Allow slash as backslash.}
-var i:longint;
-begin
-    for i:=0 to strlen(p) do
-        if p[i]='/' then p[i]:='\';
-end;
-
-procedure do_close(h:thandle);
-begin
-{ Only three standard handles under real OS/2 }
-  if h>2 then
-  begin
-    InOutRes:=DosClose(h);
-  end;
-{$ifdef IODEBUG}
-  writeln('do_close: handle=', H, ', InOutRes=', InOutRes);
-{$endif}
-end;
-
-procedure do_erase(p:Pchar);
-begin
-  allowslash(p);
-  inoutres:=DosDelete(p);
-end;
-
-procedure do_rename(p1,p2:Pchar);
-begin
-  allowslash(p1);
-  allowslash(p2);
-  inoutres:=DosMove(p1, p2);
-end;
-
-function do_read(h:thandle;addr:pointer;len:longint):longint;
-Var
-  T: cardinal;
-begin
-{$ifdef IODEBUG}
-  write('do_read: handle=', h, ', addr=', ptrint(addr), ', length=', len);
-{$endif}
-  InOutRes:=DosRead(H, Addr, Len, T);
-  do_read:= longint (T);
-{$ifdef IODEBUG}
-  writeln(', actual_len=', t, ', InOutRes=', InOutRes);
-{$endif}
-end;
-
-function do_write(h:thandle;addr:pointer;len:longint) : longint;
-Var
-  T: cardinal;
-begin
-{$ifdef IODEBUG}
-  write('do_write: handle=', h, ', addr=', ptrint(addr), ', length=', len);
-{$endif}
-  InOutRes:=DosWrite(H, Addr, Len, T);
-  do_write:= longint (T);
-{$ifdef IODEBUG}
-  writeln(', actual_len=', t, ', InOutRes=', InOutRes);
-{$endif}
-end;
-
-function do_filepos(handle:thandle): longint;
-var
-  PosActual: cardinal;
-begin
-  InOutRes:=DosSetFilePtr(Handle, 0, 1, PosActual);
-  do_filepos:=longint (PosActual);
-{$ifdef IODEBUG}
-  writeln('do_filepos: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
-{$endif}
-end;
-
-procedure do_seek(handle:thandle;pos:longint);
-var
-  PosActual: cardinal;
-begin
-  InOutRes:=DosSetFilePtr(Handle, Pos, 0 {ZeroBased}, PosActual);
-{$ifdef IODEBUG}
-  writeln('do_seek: handle=', Handle, ', pos=', pos, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
-{$endif}
-end;
-
-function do_seekend(handle:thandle):longint;
-var
-  PosActual: cardinal;
-begin
-  InOutRes:=DosSetFilePtr(Handle, 0, 2 {EndBased}, PosActual);
-  do_seekend:=longint (PosActual);
-{$ifdef IODEBUG}
-  writeln('do_seekend: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
-{$endif}
-end;
-
-function do_filesize(handle:thandle):longint;
-var aktfilepos: cardinal;
-begin
-  aktfilepos:=do_filepos(handle);
-  do_filesize:=do_seekend(handle);
-  do_seek(handle,aktfilepos);
-end;
-
-procedure do_truncate(handle:thandle;pos:longint);
-begin
-  InOutRes:=DosSetFileSize(Handle, Pos);
-  do_seekend(handle);
-end;
-
-const
-    FileHandleCount: cardinal = 20;
-
-function Increase_File_Handle_Count: boolean;
-var Err: word;
-    L1: longint;
-    L2: cardinal;
-begin
-  L1 := 10;
-  if DosSetRelMaxFH (L1, L2) <> 0 then
-    Increase_File_Handle_Count := false
-  else
-    if L2 > FileHandleCount then
-    begin
-      FileHandleCount := L2;
-      Increase_File_Handle_Count := true;
-    end
-    else
-      Increase_File_Handle_Count := false;
-end;
-
-procedure do_open(var f;p:pchar;flags:longint);
-{
-  filerec and textrec have both handle and mode as the first items so
-  they could use the same routine for opening/creating.
-
-  when (flags and $100)   the file will be append
-  when (flags and $1000)  the file will be truncate/rewritten
-  when (flags and $10000) there is no check for close (needed for textfiles)
-}
-var
-  Action, Attrib, OpenFlags, FM: Cardinal;
-begin
-  // convert unix slashes to normal slashes
-  allowslash(p);
-
-  // close first if opened
-  if ((flags and $10000)=0) then
-  begin
-    case filerec(f).mode of
-      fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
-      fmclosed:;
-    else
-      begin
-        inoutres:=102; {not assigned}
-        exit;
-      end;
-    end;
-  end;
-
-  // reset file handle
-  filerec(f).handle := UnusedHandle;
-
-  Attrib:=0;
-  OpenFlags:=0;
-
-  // convert filesharing
-  FM := Flags and $FF and not (8);
-(* DenyNone if sharing not specified. *)
-  if FM and 112 = 0 then
-    FM := FM or 64;
-  // convert filemode to filerec modes and access mode
-  case (FM and 3) of
-    0: filerec(f).mode:=fminput;
-    1: filerec(f).mode:=fmoutput;
-    2: filerec(f).mode:=fminout;
-  end;
-
-  if (flags and $1000)<>0 then
-    OpenFlags:=OpenFlags or 2 {doOverwrite} or 16 {doCreate} // Create/overwrite
-  else
-    OpenFlags:=OpenFlags or 1 {doOpen}; // Open existing
-
-  // Handle Std I/O
-  if p[0]=#0 then
-  begin
-    case FileRec(f).mode of
-      fminput :
-        FileRec(f).Handle:=StdInputHandle;
-      fminout, // this is set by rewrite
-      fmoutput :
-        FileRec(f).Handle:=StdOutputHandle;
-      fmappend :
-        begin
-          FileRec(f).Handle:=StdOutputHandle;
-          FileRec(f).mode:=fmoutput; // fool fmappend
-        end;
-    end;
-    exit;
-  end;
-
-  Attrib:=32 {faArchive};
-
-  InOutRes:=DosOpen(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil);
-
-  // If too many open files try to set more file handles and open again
-  if (InOutRes = 4) then
-    if Increase_File_Handle_Count then
-      InOutRes:=DosOpen(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil);
-
-  If InOutRes<>0 then FileRec(F).Handle:=UnusedHandle;
-
-  // If Handle created -> make some things
-  if (FileRec(F).Handle <> UnusedHandle) then
-  begin
-
-    // Move to end of file for Append command
-    if ((Flags and $100) <> 0) then
-    begin
-      do_seekend(FileRec(F).Handle);
-      FileRec(F).Mode := fmOutput;
-    end;
-
-  end;
-
-{$ifdef IODEBUG}
-  writeln('do_open,', filerec(f).handle, ',', filerec(f).name, ',', filerec(f).mode, ', InOutRes=', InOutRes);
-{$endif}
-end;
-
-function do_isdevice (Handle: THandle): boolean;
-var
-  HT, Attr: cardinal;
-begin
-  do_isdevice:=false;
-  If DosQueryHType(Handle, HT, Attr)<>0 then exit;
-  if ht=1 then do_isdevice:=true;
-end;
-{$ASMMODE ATT}
-
-
-{*****************************************************************************
-                           UnTyped File Handling
-*****************************************************************************}
-
-{$i file.inc}
-
-{*****************************************************************************
-                           Typed File Handling
-*****************************************************************************}
-
-{$i typefile.inc}
-
-{*****************************************************************************
-                           Text File Handling
-*****************************************************************************}
-
-{$DEFINE EOF_CTRLZ}
-
-{$i text.inc}
-
-{****************************************************************************
-
-                          Directory related routines.
-
-****************************************************************************}
-
-{*****************************************************************************
-                           Directory Handling
-*****************************************************************************}
-
-procedure MkDir (const S: string);[IOCHECK];
-var buffer:array[0..255] of char;
-    Rc : word;
-begin
-  If (s='') or (InOutRes <> 0) then
-   exit;
-      move(s[1],buffer,length(s));
-      buffer[length(s)]:=#0;
-      allowslash(Pchar(@buffer));
-      Rc := DosCreateDir(buffer,nil);
-      if Rc <> 0 then
-       begin
-         InOutRes := Rc;
-         Errno2Inoutres;
-       end;
-end;
-
-
-procedure rmdir(const s : string);[IOCHECK];
-var buffer:array[0..255] of char;
-    Rc : word;
-begin
-  if (s = '.' ) then
-    InOutRes := 16;
-  If (s='') or (InOutRes <> 0) then
-   exit;
-      move(s[1],buffer,length(s));
-      buffer[length(s)]:=#0;
-      allowslash(Pchar(@buffer));
-      Rc := DosDeleteDir(buffer);
-      if Rc <> 0 then
-       begin
-         InOutRes := Rc;
-         Errno2Inoutres;
-       end;
-end;
-
-{$ASMMODE INTEL}
-
-procedure ChDir (const S: string);[IOCheck];
-
-var RC: cardinal;
-    Buffer: array [0..255] of char;
-
-begin
-  If (s='') or (InOutRes <> 0) then exit;
-  if (Length (S) >= 2) and (S [2] = ':') then
-  begin
-    RC := DosSetDefaultDisk ((Ord (S [1]) and not ($20)) - $40);
-    if RC <> 0 then
-      InOutRes := RC
-    else
-      if Length (S) > 2 then
-      begin
-        Move (S [1], Buffer, Length (S));
-        Buffer [Length (S)] := #0;
-        AllowSlash (PChar (@Buffer));
-        RC := DosSetCurrentDir (@Buffer);
-        if RC <> 0 then
-        begin
-          InOutRes := RC;
-          Errno2InOutRes;
-        end;
-      end;
-  end else begin
-    Move (S [1], Buffer, Length (S));
-    Buffer [Length (S)] := #0;
-    AllowSlash (PChar (@Buffer));
-    RC := DosSetCurrentDir (@Buffer);
-    if RC <> 0 then
-    begin
-      InOutRes:= RC;
-      Errno2InOutRes;
-    end;
-  end;
-end;
-
-{$ASMMODE ATT}
-
-procedure GetDir (DriveNr: byte; var Dir: ShortString);
-{Written by Michael Van Canneyt.}
-var sof: Pchar;
-    i:byte;
-    l,l2:cardinal;
-begin
-    Dir [4] := #0;
-    { Used in case the specified drive isn't available }
-    sof:=pchar(@dir[4]);
-    { dir[1..3] will contain '[drivenr]:\', but is not }
-    { supplied by DOS, so we let dos string start at   }
-    { dir[4]                                           }
-    { Get dir from drivenr : 0=default, 1=A etc... }
-    l:=255-3;
-    InOutRes:=longint (DosQueryCurrentDir(DriveNr, sof^, l));
-{$WARNING Result code should be translated in some cases!}
-    { Now Dir should be filled with directory in ASCIIZ, }
-    { starting from dir[4]                               }
-    dir[0]:=#3;
-    dir[2]:=':';
-    dir[3]:='\';
-    i:=4;
-    {Conversion to Pascal string }
-    while (dir[i]<>#0) do
-        begin
-            { convert path name to DOS }
-            if dir[i]='/' then
-            dir[i]:='\';
-            dir[0]:=char(i);
-            inc(i);
-        end;
-    { upcase the string (FPC function) }
-    if drivenr<>0 then   { Drive was supplied. We know it }
-        dir[1]:=chr(64+drivenr)
-    else
-        begin
-            { We need to get the current drive from DOS function 19H  }
-            { because the drive was the default, which can be unknown }
-            DosQueryCurrentDisk(l, l2);
-            dir[1]:=chr(64+l);
-        end;
-    if not (FileNameCaseSensitive) then dir:=upcase(dir);
-end;
-
 
 {*****************************************************************************
 
@@ -1574,6 +740,7 @@ begin
     DefaultCreator := '';
     DefaultFileType := '';
 
+    InitSystemThreads;
 {$ifdef HASVARIANT}
     initvariantmanager;
 {$endif HASVARIANT}
@@ -1599,11 +766,13 @@ begin
       else
        DosFreeMem (P);
      end;
-
 end.
 {
   $Log$
-  Revision 1.77  2004-12-05 14:36:38  hajny
+  Revision 1.78  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
+
+  Revision 1.77  2004/12/05 14:36:38  hajny
     + GetProcessID added
 
   Revision 1.76  2004/11/04 09:32:31  peter

+ 21 - 121
rtl/os2/systhrds.pp → rtl/os2/systhrd.inc

@@ -1,9 +1,10 @@
 {
     $Id$
     This file is part of the Free Pascal run time library.
-    Copyright (c) 2002 by the Free Pascal development team.
+    Copyright (c) 2002 by Peter Vreman,
+    member of the Free Pascal development team.
 
-    OS/2 threading support implementation
+    Linux (pthreads) threading support implementation
 
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
@@ -13,40 +14,6 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-unit systhrds;
-interface
-
-{$S-}
-
-  type
-    { the fields of this record are os dependent  }
-    { and they shouldn't be used in a program     }
-    { only the type TCriticalSection is important }
-    PRTLCriticalSection = ^TRTLCriticalSection;
-    TRTLCriticalSection = packed record
-      DebugInfo : pointer;
-      LockCount : longint;
-      RecursionCount : longint;
-      OwningThread : DWord;
-      LockSemaphore : DWord;
-      Reserved : DWord;
-    end;
-
-{ Include generic thread interface }
-{$i threadh.inc}
-
-
-implementation
-
-
-{*****************************************************************************
-                             Generic overloaded
-*****************************************************************************}
-
-{ Include generic overloaded routines }
-{$i thread.inc}
-
-
 
 {*****************************************************************************
                            Local Api imports
@@ -63,42 +30,6 @@ const
  dtSuspended = 1;
  dtStack_Commited = 2;
 
-type
- TByteArray = array [0..$ffff] of byte;
- PByteArray = ^TByteArray;
-
- TSysThreadIB = record
-  TID,
-  Priority,
-  Version: cardinal;
-  MCCount,
-  MCForceFlag: word;
- end;
- PSysThreadIB = ^TSysThreadIB;
-
- TThreadInfoBlock = record
-  PExChain,
-  Stack,
-  StackLimit: pointer;
-  TIB2: PSysThreadIB;
-  Version,
-  Ordinal: cardinal;
- end;
- PThreadInfoBlock = ^TThreadInfoBlock;
- PPThreadInfoBlock = ^PThreadInfoBlock;
-
- TProcessInfoBlock = record
-  PID,
-  ParentPid,
-  Handle: cardinal;
-  Cmd,
-  Env: PByteArray;
-  Status,
-  ProcType: cardinal;
- end;
- PProcessInfoBlock = ^TProcessInfoBlock;
- PPProcessInfoBlock = ^PProcessInfoBlock;
-
 
 { import the necessary stuff from the OS }
 function DosAllocThreadLocalMemory (Count: cardinal; var P: pointer): cardinal;
@@ -112,9 +43,6 @@ function DosCreateThread (var TID: cardinal; Address: pointer;
      aParam: pointer; Flags: cardinal; StackSize: cardinal): cardinal; cdecl;
                                                  external 'DOSCALLS' index 311;
 
-procedure DosExit (Action, Result: cardinal); cdecl;
-                                                 external 'DOSCALLS' index 234;
-
 function DosCreateMutExSem (Name: PChar; var Handle: longint; Attr: cardinal;
                State: boolean): cardinal; cdecl; external 'DOSCALLS' index 331;
 
@@ -130,22 +58,12 @@ function DosRequestMutExSem (Handle:longint; Timeout: cardinal): cardinal; cdecl
 function DosReleaseMutExSem (Handle: longint): cardinal; cdecl;
                                                  external 'DOSCALLS' index 335;
 
-function DosAllocMem (var P: pointer; Size, Flag: cardinal): cardinal; cdecl;
-                                                 external 'DOSCALLS' index 299;
-
-function DosFreeMem (P: pointer): cardinal; cdecl;
-                                                 external 'DOSCALLS' index 304;
-
 {
 function DosEnterCritSec:cardinal; cdecl; external 'DOSCALLS' index 232;
 
 function DosExitCritSec:cardinal; cdecl; external 'DOSCALLS' index 233;
 }
 
-procedure DosGetInfoBlocks (PATIB: PPThreadInfoBlock;
-                                    PAPIB: PPProcessInfoBlock); cdecl;
-                                                 external 'DOSCALLS' index 312;
-
 procedure DosSleep (MSec: cardinal); cdecl; external 'DOSCALLS' index 229;
 
 
@@ -191,9 +109,6 @@ begin
  DosFreeMem (DataIndex^);
 end;
 
-{ Include OS independent Threadvar initialization }
-{$i threadvar.inc}
-
 (*    procedure InitThreadVars;
       begin
         { allocate one ThreadVar entry from the OS, we use this entry }
@@ -216,9 +131,6 @@ end;
                             Thread starting
 *****************************************************************************}
 
-    const
-      DefaultStackSize = 32768; { including 16384 margin for stackchecking }
-
     type
       pthreadinfo = ^tthreadinfo;
       tthreadinfo = record
@@ -278,9 +190,9 @@ end;
       end;
 
 
-    function SysBeginThread (SA: pointer; StackSize: cardinal;
-                         ThreadFunction: TThreadFunc; P: pointer;
-                    CreationFlags: cardinal; var ThreadId: cardinal): cardinal;
+    function SysBeginThread(sa : Pointer;stacksize : dword;
+                         ThreadFunction : tthreadfunc;p : pointer;
+                         creationFlags : dword; var ThreadId : THandle) : DWord;
       var
         TI: PThreadInfo;
       begin
@@ -293,7 +205,7 @@ end;
 {$ifdef HASTHREADVAR}
            if DosAllocThreadLocalMemory (1, DataIndex) <> 0
              then RunError (8);
-           InitThreadVars;
+           InitThreadVars(@SysRelocateThreadVar);
 {$endif HASTHREADVAR}
            IsMultiThread:=true;
          end;
@@ -307,8 +219,8 @@ end;
 {$ifdef DEBUG_MT}
         writeln('Starting new thread');
 {$endif DEBUG_MT}
-        SysBeginThread := DosCreateThread (ThreadID, @ThreadMain, SA,
-                                           CreationFlags, StackSize: cardinal);
+        SysBeginThread := DosCreateThread (DWord(ThreadID), @ThreadMain, SA,
+                                           CreationFlags, StackSize);
       end;
 
 
@@ -376,7 +288,7 @@ end;
     end;
 
 
-    function SysThreadGetPriority (ThreadHandle: dword): integer;
+    function SysThreadGetPriority (ThreadHandle: dword): longint;
     begin
 {$WARNING TODO!}
 {
@@ -402,23 +314,23 @@ end;
 { DosEnter/ExitCritSec have quite a few limitations, so let's try to avoid
   them. I'm not sure whether mutex semaphores are SMP-safe, though... :-(  }
 
-procedure SysInitCriticalSection(var CS: TRTLCriticalSection);
+procedure SysInitCriticalSection(var CS);
 begin
 {$WARNING TODO!}
 end;
 
 
-procedure SysDoneCriticalSection (var CS: TRTLCriticalSection);
+procedure SysDoneCriticalSection (var CS);
 begin
 {$WARNING TODO!}
 end;
 
-procedure EnterCriticalSection (var CS: TRTLCriticalSection);
+procedure SysEnterCriticalSection (var CS);
 begin
 {$WARNING TODO!}
 end;
 
-procedure LeaveCriticalSection (var CS: TRTLCriticalSection);
+procedure SysLeaveCriticalSection (var CS);
 begin
 {$WARNING TODO!}
 end;
@@ -589,7 +501,7 @@ var
   OS2ThreadManager: TThreadManager;
 
 
-procedure SetOS2ThreadManager;
+procedure InitSystemThreads;
 begin
   with OS2ThreadManager do
     begin
@@ -630,27 +542,15 @@ begin
   InitHeapMutexes;
 end;
 
-finalization
- DosFreeThreadLocalMemory (DataIndex);
-end;
-
-initialization
-  SetOS2ThreadManager;
-end.
 
 {
   $Log$
-  Revision 1.3  2005-01-27 22:14:54  hajny
-    * first part of compilation fixes
+  Revision 1.1  2005-02-06 16:57:18  peter
+    * threads for go32v2,os,emx,netware
 
-  Revision 1.2  2003/10/13 21:17:31  hajny
-    * longint to cardinal corrections
-
-  Revision 1.1  2002/11/17 22:31:46  hajny
-    + first (incomplete) version of systhrds
-
-  Revision 1.1  2002/10/14 19:39:18  peter
-    * threads unit added for thread support
+  Revision 1.1  2005/02/06 13:06:20  peter
+    * moved file and dir functions to sysfile/sysdir
+    * win32 thread in systemunit
 
 }
-  
+

Някои файлове не бяха показани, защото твърде много файлове са промени