diff options
Diffstat (limited to 'rtl/os2')
-rw-r--r-- | rtl/os2/Makefile | 224 | ||||
-rw-r--r-- | rtl/os2/Makefile.fpc | 31 | ||||
-rw-r--r-- | rtl/os2/dos.pas | 164 | ||||
-rw-r--r-- | rtl/os2/doscall2.pas | 2236 | ||||
-rw-r--r-- | rtl/os2/doscalls.pas | 609 | ||||
-rw-r--r-- | rtl/os2/dynlibs.inc | 28 | ||||
-rw-r--r-- | rtl/os2/os2def.pas | 1009 | ||||
-rw-r--r-- | rtl/os2/sysdir.inc | 18 | ||||
-rw-r--r-- | rtl/os2/sysfile.inc | 153 | ||||
-rw-r--r-- | rtl/os2/sysheap.inc | 17 | ||||
-rw-r--r-- | rtl/os2/sysos.inc | 33 | ||||
-rw-r--r-- | rtl/os2/system.pas | 501 | ||||
-rw-r--r-- | rtl/os2/systhrd.inc | 304 | ||||
-rw-r--r-- | rtl/os2/sysucode.inc | 1654 | ||||
-rw-r--r-- | rtl/os2/sysutils.pp | 400 | ||||
-rw-r--r-- | rtl/os2/tthread.inc | 11 |
16 files changed, 6311 insertions, 1081 deletions
diff --git a/rtl/os2/Makefile b/rtl/os2/Makefile index cd98e1a082..b811f734cd 100644 --- a/rtl/os2/Makefile +++ b/rtl/os2/Makefile @@ -1,9 +1,9 @@ # -# Don't edit, this file is generated by FPCMake Version 2.0.0 [2014-04-01 rev 27428] +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2014-12-07 rev 29213] # default: all -MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim i386-android m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii powerpc-aix sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-netbsd x86_64-solaris x86_64-openbsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian arm-android powerpc64-linux powerpc64-darwin powerpc64-embedded powerpc64-aix avr-embedded armeb-linux armeb-embedded mips-linux mipsel-linux mipsel-embedded mipsel-android jvm-java jvm-android i8086-msdos -BSDs = freebsd netbsd openbsd darwin +MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim i386-android i386-aros m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii powerpc-aix sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-netbsd x86_64-solaris x86_64-openbsd x86_64-darwin x86_64-win64 x86_64-embedded x86_64-dragonfly arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian arm-android powerpc64-linux powerpc64-darwin powerpc64-embedded powerpc64-aix avr-embedded armeb-linux armeb-embedded mips-linux mipsel-linux mipsel-embedded mipsel-android jvm-java jvm-android i8086-msdos +BSDs = freebsd netbsd openbsd darwin dragonfly UNIXs = linux $(BSDs) solaris qnx haiku aix LIMIT83fs = go32v2 os2 emx watcom msdos OSNeedsComspecToRunBatch = go32v2 watcom @@ -345,229 +345,235 @@ endif OBJPASDIR=$(RTL)/objpas GRAPHDIR=$(INC)/graph ifeq ($(FULL_TARGET),i386-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-go32v2) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-win32) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-os2) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-freebsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-beos) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-haiku) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-solaris) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-qnx) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-netware) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-openbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-wdosx) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-emx) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-watcom) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-netwlibc) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-wince) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-symbian) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-nativent) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-iphonesim) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-android) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable +endif +ifeq ($(FULL_TARGET),i386-aros) +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),m68k-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),m68k-freebsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),m68k-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),m68k-amiga) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),m68k-atari) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),m68k-openbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),m68k-palmos) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),m68k-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-amiga) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-macos) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-morphos) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-wii) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc-aix) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),sparc-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),sparc-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),sparc-solaris) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),sparc-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),x86_64-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),x86_64-freebsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),x86_64-netbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),x86_64-solaris) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),x86_64-openbsd) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),x86_64-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),x86_64-win64) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),x86_64-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable +endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-palmos) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-wince) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-gba) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-nds) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-symbian) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),arm-android) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc64-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc64-darwin) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc64-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),powerpc64-aix) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),avr-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),armeb-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),armeb-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),mips-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),mipsel-linux) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),mipsel-embedded) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),mipsel-android) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),jvm-java) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),jvm-android) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i8086-msdos) -override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll +override TARGET_UNITS+=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos sysutils fgl classes math typinfo charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs types rtlconst sysconst so32dll fpwidestring character unicodedata unicodenumtable endif ifeq ($(FULL_TARGET),i386-linux) override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 @@ -638,6 +644,9 @@ endif ifeq ($(FULL_TARGET),i386-android) override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 endif +ifeq ($(FULL_TARGET),i386-aros) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 +endif ifeq ($(FULL_TARGET),m68k-linux) override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 endif @@ -725,6 +734,9 @@ endif ifeq ($(FULL_TARGET),x86_64-embedded) override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 +endif ifeq ($(FULL_TARGET),arm-linux) override TARGET_IMPLICITUNITS+=exeinfo cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp437 cp646 cp850 cp856 cp866 cp874 cp8859_1 cp8859_5 cp8859_2 cp852 endif @@ -863,6 +875,9 @@ endif ifeq ($(FULL_TARGET),i386-android) override TARGET_LOADERS+=prt0 endif +ifeq ($(FULL_TARGET),i386-aros) +override TARGET_LOADERS+=prt0 +endif ifeq ($(FULL_TARGET),m68k-linux) override TARGET_LOADERS+=prt0 endif @@ -950,6 +965,9 @@ endif ifeq ($(FULL_TARGET),x86_64-embedded) override TARGET_LOADERS+=prt0 endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +override TARGET_LOADERS+=prt0 +endif ifeq ($(FULL_TARGET),arm-linux) override TARGET_LOADERS+=prt0 endif @@ -1088,6 +1106,9 @@ endif ifeq ($(FULL_TARGET),i386-android) override TARGET_RSTS+=math typinfo pmhelp classes sysconst endif +ifeq ($(FULL_TARGET),i386-aros) +override TARGET_RSTS+=math typinfo pmhelp classes sysconst +endif ifeq ($(FULL_TARGET),m68k-linux) override TARGET_RSTS+=math typinfo pmhelp classes sysconst endif @@ -1175,6 +1196,9 @@ endif ifeq ($(FULL_TARGET),x86_64-embedded) override TARGET_RSTS+=math typinfo pmhelp classes sysconst endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +override TARGET_RSTS+=math typinfo pmhelp classes sysconst +endif ifeq ($(FULL_TARGET),arm-linux) override TARGET_RSTS+=math typinfo pmhelp classes sysconst endif @@ -1314,6 +1338,9 @@ endif ifeq ($(FULL_TARGET),i386-android) override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) endif +ifeq ($(FULL_TARGET),i386-aros) +override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) +endif ifeq ($(FULL_TARGET),m68k-linux) override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) endif @@ -1401,6 +1428,9 @@ endif ifeq ($(FULL_TARGET),x86_64-embedded) override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) +endif ifeq ($(FULL_TARGET),arm-linux) override COMPILER_INCLUDEDIR+=$(INC) $(PROCINC) endif @@ -1539,6 +1569,9 @@ endif ifeq ($(FULL_TARGET),i386-android) override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON) endif +ifeq ($(FULL_TARGET),i386-aros) +override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON) +endif ifeq ($(FULL_TARGET),m68k-linux) override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON) endif @@ -1626,6 +1659,9 @@ endif ifeq ($(FULL_TARGET),x86_64-embedded) override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON) endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON) +endif ifeq ($(FULL_TARGET),arm-linux) override COMPILER_SOURCEDIR+=$(INC) $(PROCINC) $(COMMON) endif @@ -1937,6 +1973,12 @@ EXEEXT= HASSHAREDLIB=1 SHORTSUFFIX=lnx endif +ifeq ($(OS_TARGET),dragonfly) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=df +endif ifeq ($(OS_TARGET),freebsd) BATCHEXT=.sh EXEEXT= @@ -1982,6 +2024,11 @@ EXEEXT= SHAREDLIBEXT=.library SHORTSUFFIX=amg endif +ifeq ($(OS_TARGET),aros) +EXEEXT= +SHAREDLIBEXT=.library +SHORTSUFFIX=aros +endif ifeq ($(OS_TARGET),morphos) EXEEXT= SHAREDLIBEXT=.library @@ -2446,7 +2493,7 @@ endif ifdef CREATESHARED override FPCOPT+=-Cg endif -ifneq ($(findstring $(OS_TARGET),freebsd openbsd netbsd linux solaris),) +ifneq ($(findstring $(OS_TARGET),dragonfly freebsd openbsd netbsd linux solaris),) ifeq ($(CPU_TARGET),x86_64) override FPCOPT+=-Cg endif @@ -2904,6 +2951,7 @@ kbdcalls$(PPUEXT) : kbdcalls.pas $(SYSTEMUNIT)$(PPUEXT) moucalls$(PPUEXT) : moucalls.pas $(SYSTEMUNIT)$(PPUEXT) moncalls$(PPUEXT) : moncalls.pas strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) os2def$(PPUEXT) : os2def.pas $(SYSTEMUNIT)$(PPUEXT) +doscall2$(PPUEXT) : doscalls$(PPUEXT) os2def$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) pmwin$(PPUEXT) : pmwin.pas os2def$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) pmbitmap$(PPUEXT) : pmbitmap.pas $(SYSTEMUNIT)$(PPUEXT) pmgpi$(PPUEXT) : pmgpi.pas pmbitmap$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) @@ -2926,11 +2974,11 @@ classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \ sysutils$(PPUEXT) typinfo$(PPUEXT) rtlconst$(PPUEXT) types$(PPUEXT) \ objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) fgl$(PPUEXT) $(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp -fgl$(PPUEXT) : $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) system$(PPUEXT) sysutils$(PPUEXT) +fgl$(PPUEXT) : $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) $(COMPILER) $(OBJPASDIR)/fgl.pp math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(OBJPASDIR)/math.pp -typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT) rtlconst$(PPUEXT) +typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT) rtlconst$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp types$(PPUEXT) : $(OBJPASDIR)/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(OBJPASDIR)/types.pp @@ -2938,7 +2986,7 @@ rtlconst$(PPUEXT) : $(OBJPASDIR)/rtlconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUE $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/rtlconst.pp sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(OBJPASDIR)/sysconst.pp -macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT) +macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(INC)/macpas.pp $(REDIR) cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMUNIT)$(PPUEXT) mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) @@ -2948,7 +2996,15 @@ heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT) lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT) lnfodwrf$(PPUEXT) : $(INC)/lnfodwrf.pp $(SYSTEMUNIT)$(PPUEXT) charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT) -cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas system$(PPUEXT) charset$(PPUEXT) +unicodenumtable$(PPUEXT) : $(OBJPASDIR)/unicodenumtable.pas $(SYSTEMUNIT)$(PPUEXT) + $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/unicodenumtable.pas +unicodedata$(PPUEXT) : $(OBJPASDIR)/unicodedata.pas unicodenumtable$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) + $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/unicodedata.pas +character$(PPUEXT) : $(OBJPASDIR)/character.pas sysutils$(PPUEXT) rtlconst$(PPUEXT) unicodedata$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) + $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/character.pas +fpwidestring$(PPUEXT) : $(OBJPASDIR)/fpwidestring.pp unicodedata$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) + $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/fpwidestring.pp +cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas $(SYSTEMUNIT)$(PPUEXT) charset$(PPUEXT) $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cpall.pas ctypes$(PPUEXT) : $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT) -variants$(PPUEXT) : $(INC)/variants.pp varutils$(PPUEXT) typinfo$(PPUEXT) +variants$(PPUEXT) : $(INC)/variants.pp varutils$(PPUEXT) typinfo$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) diff --git a/rtl/os2/Makefile.fpc b/rtl/os2/Makefile.fpc index bdc78e468e..766caa31c8 100644 --- a/rtl/os2/Makefile.fpc +++ b/rtl/os2/Makefile.fpc @@ -8,13 +8,14 @@ main=rtl [target] loaders=prt0 units=$(SYSTEMUNIT) uuchar ctypes objpas macpas iso7185 strings \ - ports os2def doscalls moncalls kbdcalls moucalls viocalls \ + ports os2def doscalls doscall2 moncalls kbdcalls moucalls viocalls \ pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi \ dos \ sysutils fgl classes math typinfo \ charset cpall cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs \ types rtlconst sysconst \ - so32dll + so32dll fpwidestring character \ + unicodedata unicodenumtable rsts=math typinfo pmhelp classes sysconst implicitunits=exeinfo \ cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 \ @@ -118,6 +119,8 @@ moncalls$(PPUEXT) : moncalls.pas strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) os2def$(PPUEXT) : os2def.pas $(SYSTEMUNIT)$(PPUEXT) +doscall2$(PPUEXT) : doscalls$(PPUEXT) os2def$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) + pmwin$(PPUEXT) : pmwin.pas os2def$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) pmbitmap$(PPUEXT) : pmbitmap.pas $(SYSTEMUNIT)$(PPUEXT) @@ -151,7 +154,7 @@ dynlibs$(PPUEXT) : $(INC)/dynlibs.pas doscalls$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) dos$(PPUEXT) : dos.pas $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \ doscalls$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) -#graph$(PPUEXT) : graph.pp +#graph$(PPUEXT) : graph.pp $(SYSTEMUNIT)$(PPUEXT) # # Delphi Compatible Units @@ -166,13 +169,13 @@ classes$(PPUEXT) : classes.pp $(wildcard $(OBJPASDIR)/classes/*.inc) \ objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) fgl$(PPUEXT) $(COMPILER) -Fi$(OBJPASDIR)/classes classes.pp -fgl$(PPUEXT) : $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) system$(PPUEXT) sysutils$(PPUEXT) +fgl$(PPUEXT) : $(OBJPASDIR)/fgl.pp objpas$(PPUEXT) types$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) $(COMPILER) $(OBJPASDIR)/fgl.pp math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(OBJPASDIR)/math.pp -typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT) rtlconst$(PPUEXT) +typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT) rtlconst$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp types$(PPUEXT) : $(OBJPASDIR)/types.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) @@ -188,7 +191,7 @@ sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUE # Mac Pascal Model # -macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT) +macpas$(PPUEXT) : $(INC)/macpas.pp objpas$(PPUEXT) math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) $(COMPILER) $(INC)/macpas.pp $(REDIR) # @@ -210,7 +213,19 @@ lnfodwrf$(PPUEXT) : $(INC)/lnfodwrf.pp $(SYSTEMUNIT)$(PPUEXT) charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT) -cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas system$(PPUEXT) charset$(PPUEXT) +unicodenumtable$(PPUEXT) : $(OBJPASDIR)/unicodenumtable.pas $(SYSTEMUNIT)$(PPUEXT) + $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/unicodenumtable.pas + +unicodedata$(PPUEXT) : $(OBJPASDIR)/unicodedata.pas unicodenumtable$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) + $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/unicodedata.pas + +character$(PPUEXT) : $(OBJPASDIR)/character.pas sysutils$(PPUEXT) rtlconst$(PPUEXT) unicodedata$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) + $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/character.pas + +fpwidestring$(PPUEXT) : $(OBJPASDIR)/fpwidestring.pp unicodedata$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) + $(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/fpwidestring.pp + +cpall$(PPUEXT): $(RTL)/charmaps/cpall.pas $(SYSTEMUNIT)$(PPUEXT) charset$(PPUEXT) $(COMPILER) -Fu$(INC) -Fi$(RTL)/charmaps $(RTL)/charmaps/cpall.pas ctypes$(PPUEXT) : $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT) @@ -219,4 +234,4 @@ ctypes$(PPUEXT) : $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT) # # Other system-dependent RTL Units # -variants$(PPUEXT) : $(INC)/variants.pp varutils$(PPUEXT) typinfo$(PPUEXT) +variants$(PPUEXT) : $(INC)/variants.pp varutils$(PPUEXT) typinfo$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) diff --git a/rtl/os2/dos.pas b/rtl/os2/dos.pas index 4092d4c3c2..232434d4f4 100644 --- a/rtl/os2/dos.pas +++ b/rtl/os2/dos.pas @@ -113,6 +113,8 @@ begin P:=Path; D:=DirList; DosError := DosSearchPath (dsIgnoreNetErrs, PChar(D), PChar(P), @A, 255); + if DosError <> 0 then + OSErrorWatch (DosError); fsearch := StrPas (@A); end; @@ -124,12 +126,16 @@ begin DosError := DosQueryFileInfo (FileRec (F).Handle, ilStandard, @FStat, SizeOf (FStat)); if DosError=0 then - begin + begin Time := FStat.TimeLastWrite + longint (FStat.DateLastWrite) shl 16; if Time = 0 then Time := FStat.TimeCreation + longint (FStat.DateCreation) shl 16; - end else + end + else + begin Time:=0; + OSErrorWatch (DosError); + end; end; @@ -140,14 +146,18 @@ begin RC := DosQueryFileInfo (FileRec (F).Handle, ilStandard, @FStat, SizeOf (FStat)); if RC = 0 then - begin + begin FStat.DateLastAccess := Hi (Time); FStat.DateLastWrite := Hi (Time); FStat.TimeLastAccess := Lo (Time); FStat.TimeLastWrite := Lo (Time); RC := DosSetFileInfo (FileRec (F).Handle, ilStandard, @FStat, SizeOf (FStat)); - end; + if RC <> 0 then + OSErrorWatch (RC); + end + else + OSErrorWatch (RC); DosError := integer (RC); end; @@ -170,7 +180,10 @@ begin LastExecRes := Res; end else - LastExecRes.ExitCode := RC shl 16; + begin + LastExecRes.ExitCode := RC shl 16; + OSErrorWatch (RC); + end; end; if LastExecRes.ExitCode > high (word) then DosExitCode := high (word) @@ -186,10 +199,10 @@ var ArgSize: word; ObjName: string; Res: TResultCodes; - RC: cardinal; + RC, RC2: cardinal; ExecAppType: cardinal; HQ: THandle; - SPID, STID, SCtr, QName: string; + SPID, STID, QName: string; SID, PID: cardinal; SD: TStartData; RD: TRequestData; @@ -198,9 +211,8 @@ var Prio: byte; DSS: boolean; SR: SearchRec; - -const - MaxArgsSize = 3072; (* Amount of memory reserved for arguments in bytes. *) + MaxArgsSize: PtrUInt; (* Amount of memory reserved for arguments in bytes. *) + MaxArgsSizeInc: word; begin { LastDosExitCode := Exec (Path, ExecRunFlags (ExecFlags), efDefault, ComLine);} @@ -213,6 +225,12 @@ begin else QName := Path; FindClose (SR); + MaxArgsSize := Length (ComLine) + Length (QName) + 256; (* More than enough *) + if MaxArgsSize > high (word) then + begin + DosError := 8; (* Not quite, but "not enough memory" is close enough *) + Exit; + end; if ComLine = '' then begin Args0 := nil; @@ -224,8 +242,19 @@ begin Args := Args0; (* Work around a bug in OS/2 - argument to DosExecPgm *) (* should not cross a 64K boundary. *) - if ((PtrUInt (Args) + 1024) and $FFFF) < 1024 then - Inc (pointer (Args), 1024); + while ((PtrUInt (Args) + MaxArgsSize) and $FFFF) < MaxArgsSize do + begin + MaxArgsSizeInc := MaxArgsSize - + ((PtrUInt (Args) + MaxArgsSize) and $FFFF); + Inc (MaxArgsSize, MaxArgsSizeInc); + if MaxArgsSize > high (word) then + begin + DosError := 8; (* Not quite, but "not enough memory" is close enough *) + Exit; + end; + ReallocMem (Args0, MaxArgsSize); + Inc (pointer (Args), MaxArgsSizeInc); + end; ArgSize := 0; Move (QName [1], Args^ [ArgSize], Length (QName)); Inc (ArgSize, Length (QName)); @@ -239,22 +268,28 @@ begin Args^ [ArgSize] := 0; end; - if (DosQueryAppType (PChar (Args), ExecAppType) = 0) and - (ApplicationType and 3 = ExecAppType and 3) then + RC := DosQueryAppType (PChar (Args), ExecAppType); + if RC <> 0 then + OSErrorWatch (RC) + else + if (ApplicationType and 3 = ExecAppType and 3) then (* DosExecPgm should work... *) - begin - DSS := false; - Res.ExitCode := $FFFFFFFF; - RC := DosExecPgm (ObjName, cardinal (ExecFlags), Args, nil, Res, Path); - if RC = 0 then - begin - LastExecFlags := ExecFlags; - LastExecRes := Res; - LastDosErrorModuleName := ''; - end - else - if (RC = 190) or (RC = 191) then - DSS := true; + begin + DSS := false; + Res.ExitCode := $FFFFFFFF; + RC := DosExecPgm (ObjName, cardinal (ExecFlags), Args, nil, Res, Path); + if RC = 0 then + begin + LastExecFlags := ExecFlags; + LastExecRes := Res; + LastDosErrorModuleName := ''; + end + else + begin + if (RC = 190) or (RC = 191) then + DSS := true; + OSErrorWatch (RC); + end; end else DSS := true; @@ -273,6 +308,8 @@ begin LastExecFlags := ExecFlags; SD.TermQ := @QName [1]; RC := DosCreateQueue (HQ, quFIFO or quConvert_Address, @QName [1]); + if RC <> 0 then + OSErrorWatch (RC); end; deAsync, deAsyncResult: @@ -318,24 +355,40 @@ begin SD.ObjectBuffer := @ObjName [1]; SD.ObjectBuffLen := SizeOf (ObjName) - 1; RC := DosStartSession (SD, SID, PID); + if RC <> 0 then + OSErrorWatch (RC); if (RC = 0) or (RC = 457) then begin LastExecRes.PID := PID; if ExecFlags = deSync then begin RC := DosReadQueue (HQ, RD, CISize, PCI, 0, 0, Prio, 0); + if RC <> 0 then + OSErrorWatch (RC); if (RC = 0) and (PCI^.SessionID = SID) then begin LastExecRes.ExitCode := PCI^.Return; - DosCloseQueue (HQ); - DosFreeMem (PCI); + RC2 := DosCloseQueue (HQ); + if RC2 <> 0 then + OSErrorWatch (RC2); + RC2 := DosFreeMem (PCI); + if RC2 <> 0 then + OSErrorWatch (RC2); end else - DosCloseQueue (HQ); + begin + RC2 := DosCloseQueue (HQ); + if RC2 <> 0 then + OSErrorWatch (RC2); + end; end; end else if ExecFlags = deSync then - DosCloseQueue (HQ); + begin + RC2 := DosCloseQueue (HQ); + if RC2 <> 0 then + OSErrorWatch (RC2); + end; end; end; if RC <> 0 then @@ -383,12 +436,15 @@ end; procedure SetDate (Year, Month, Day: word); var DT: TDateTime; + RC: cardinal; begin DosGetDateTime (DT); DT.Year := Year; DT.Month := byte (Month); DT.Day := byte (Day); - DosSetDateTime (DT); + RC := DosSetDateTime (DT); + if RC <> 0 then + OSErrorWatch (RC); end; @@ -407,13 +463,16 @@ end; procedure SetTime (Hour, Minute, Second, Sec100: word); var DT: TDateTime; + RC: cardinal; begin DosGetDateTime (DT); DT.Hour := byte (Hour); DT.Minute := byte (Minute); DT.Second := byte (Second); DT.Sec100 := byte (Sec100); - DosSetDateTime (DT); + RC := DosSetDateTime (DT); + if RC <> 0 then + OSErrorWatch (RC); end; function DiskFree (Drive: byte): int64; @@ -426,7 +485,10 @@ begin DiskFree := int64 (FI.Free_Clusters) * int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector) else - DiskFree := -1; + begin + DiskFree := -1; + OSErrorWatch (RC); + end; end; @@ -439,7 +501,10 @@ begin DiskSize := int64 (FI.Total_Clusters) * int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector) else - DiskSize := -1; + begin + DiskSize := -1; + OSErrorWatch (RC); + end; end; @@ -474,7 +539,10 @@ begin DosError := integer (DosFindFirst (Path, F.Handle, Attr and FindResvdMask, F.FStat, SizeOf (F.FStat^), Count, ilStandard)); - if (DosError = 0) and (Count = 0) then DosError := 18; + if DosError <> 0 then + OSErrorWatch (DosError) + else if Count = 0 then + DosError := 18; DosSearchRec2SearchRec (F); end; @@ -488,14 +556,22 @@ begin Count := 1; DosError := integer (DosFindNext (F.Handle, F.FStat, SizeOf (F.FStat^), Count)); - if (DosError = 0) and (Count = 0) then DosError := 18; + if DosError <> 0 then + OSErrorWatch (DosError) + else if Count = 0 then + DosError := 18; DosSearchRec2SearchRec (F); end; procedure FindClose (var F: SearchRec); begin - if F.Handle <> THandle ($FFFFFFFF) then DosError := DosFindClose (F.Handle); + if F.Handle <> THandle ($FFFFFFFF) then + begin + DosError := integer (DosFindClose (F.Handle)); + if DosError <> 0 then + OSErrorWatch (DosError); + end; Dispose (F.FStat); end; @@ -607,7 +683,9 @@ begin RC := DosQueryPathInfo (P, ilStandard, @PathInfo, SizeOf (PathInfo)); DosError := integer (RC); if RC = 0 then - Attr := PathInfo.AttrFile; + Attr := PathInfo.AttrFile + else + OSErrorWatch (RC); end; @@ -628,11 +706,15 @@ begin {$endif FPC_ANSI_TEXTFILEREC} RC := DosQueryPathInfo (P, ilStandard, @PathInfo, SizeOf (PathInfo)); if RC = 0 then - begin + begin PathInfo.AttrFile := Attr; RC := DosSetPathInfo (P, ilStandard, @PathInfo, SizeOf (PathInfo), doWriteThru); - end; + if RC <> 0 then + OSErrorWatch (RC); + end + else + OSErrorWatch (RC); DosError := integer (RC); end; diff --git a/rtl/os2/doscall2.pas b/rtl/os2/doscall2.pas new file mode 100644 index 0000000000..feb0be6220 --- /dev/null +++ b/rtl/os2/doscall2.pas @@ -0,0 +1,2236 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2014 by the Free Pascal development team. + + Additional OS/2 API functions implemented in DOSCALL1.DLL: + - File handling (64-bit functions available in WSeB/MCP/eCS and + protected access to file handles as available in OS/2 2.1+) + - Certain SMP related functions for querying and setting status + of processors and thread and system affinity (available + in SMP-ready versions of OS/2 kernels) + - Support for working with extended LIBPATH (available in + OS/2 Warp 4.0 and higher). + Availability of individual functions is checked dynamically during + initialization and fake (simulated) functions are used if running + under an OS/2 version not providing the respective functionality. + + 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 DosCall2; + +{***************************************************************************} +interface +{***************************************************************************} + +uses + DosCalls, Strings; + +const +(* Status in DosGet/SetProcessorStatus *) + PROC_OFFLINE = 0; (* Processor is offline *) + PROC_ONLINE = 1; (* Processor is online *) +(* Scope in DosQueryThreadAffinity *) + AFNTY_THREAD = 0; (* Return the current threads processor affinity mask. *) + AFNTY_SYSTEM = 1; (* Return the system's current capable processor affinity + mask. *) +(* Flags in DosQuery/SetExtLibPath *) + BEGIN_LIBPATH = 1; (* The new path is searched before the LIBPATH. *) + END_LIBPATH = 2; (* The new path is searched after the LIBPATH. *) + +(* Constants for DosSuppressPopups *) + SPU_DisableSuppression = 0; + SPU_EnableSuppression = 1; + +(* Constants for DosDumpProcess *) + DDP_DisableProcDump = 0; + DDP_EnableProcDump = 1; + DDP_PerformProcDump = 2; + +(* Constants for DosPerfSysCall *) + Cmd_KI_Enable = $60; + Cmd_KI_RdCnt = $63; + Cmd_SoftTrace_Log = $14; + +(* Constants for DosQueryABIOSSupport *) + HW_Cfg_MCA = 1; + HW_Cfg_EISA = 2; + HW_Cfg_ABIOS_Supported = 4; + HW_Cfg_ABIOS_Present = 8; + HW_Cfg_PCI = 16; + HW_Cfg_OEM_ABIOS = 32; + HW_Cfg_IBM_ABIOS = 0; + HW_Cfg_Pentium_CPU = 64; + +(* Constants for DosQueryThreadContext - Level *) + Context_Control = 1; { Control registers: SS:ESP, CS:EIP, EFLAGS and EBP } + Context_Integer = 2; { EAX, EBX, ECX, EDX, ESI and EDI } + Context_Segments = 4; { Segment registers: DS, ES, FS, and GS } + Context_Floating_Point = 8; { Numeric coprocessor state } + Context_Full = 15; { All of the above } + + + +type + TFileLockL = record + case boolean of + false: + (Offset: int64; (* Offset to beginning of the lock (or unlock) range. *) + Range: int64); (* Length of the lock (or unlock) range in bytes. *) + (* Length of 0 => locking (or unlocking) not required. *) + true: + (lOffset: int64; + lRange: int64); + end; + PFileLockL = ^TFileLockL; + + TMPAffinity = record + Mask: array [0..1] of cardinal; + end; + PMPAffinity = ^TMPAffinity; + + TCPUUtil = record + TotalLow, + TotalHigh, + IdleLow, + IdleHigh, + BusyLow, + BusyHigh, + IntrLow, + IntrHigh: cardinal; + end; + PCPUUtil = ^TCPUUtil; + + +function DosOpenL (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize: int64; + Attrib, OpenFlags, FileMode: cardinal; + EA: pointer): cardinal; cdecl; + +function DosSetFilePtrL (Handle: THandle; Pos: int64; Method: cardinal; + var PosActual: int64): cardinal; cdecl; + +function DosSetFileSizeL (Handle: THandle; Size: int64): cardinal; cdecl; + +function DosProtectOpen (FileName: PChar; var Handle: longint; + var Action: longint; InitSize, Attrib, + OpenFlags, OpenMode: longint; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectOpen (const FileName: string; var Handle: longint; + var Action: longint; InitSize, Attrib, + OpenFlags, OpenMode: longint; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; + +function DosProtectOpen (const FileName: string; var Handle: THandle; + var Action: cardinal; InitSize, Attrib, + OpenFlags, OpenMode: cardinal; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; + +function DosProtectRead (Handle: longint; var Buffer; Count: longint; + var ActCount: longint; FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectWrite (Handle: longint; const Buffer; Count: longint; + var ActCount: longint; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectSetFilePtr (Handle: longint; Pos, Method: longint; + var PosActual: longint; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectSetFilePtr (Handle: THandle; Pos: longint; + FileHandleLockID: cardinal): cardinal; + +function DosProtectGetFilePtr (Handle: longint; + var PosActual: longint; FileHandleLockID: cardinal): cardinal; + +function DosProtectGetFilePtr (Handle: THandle; + var PosActual: cardinal; FileHandleLockID: cardinal): cardinal; + +function DosProtectEnumAttribute (Handle: THandle; Entry: cardinal; var Buf; + BufSize: cardinal; var Count: cardinal; + InfoLevel: cardinal; + FileHandleLockID: cardinal): cardinal; + +function DosProtectEnumAttribute (const FileName: string; Entry: cardinal; + var Buf; BufSize: cardinal; + var Count: cardinal; InfoLevel: cardinal; + FileHandleLockID: cardinal): cardinal; + +function DosProtectOpen (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize, Attrib, + OpenFlags, OpenMode: cardinal; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectClose (Handle: THandle; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectRead (Handle: THandle; var Buffer; Count: cardinal; + var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectWrite (Handle: THandle; const Buffer; Count: cardinal; + var ActCount: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectSetFilePtr (Handle: THandle; Pos: longint; + Method: cardinal; var PosActual: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectSetFileSize (Handle: THandle; Size: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectQueryFHState (Handle: THandle; var FileMode: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectSetFHState (Handle: THandle; FileMode: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectQueryFileInfo (Handle: THandle; InfoLevel: cardinal; + AFileStatus: PFileStatus; FileStatusLen: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectSetFileInfo (Handle: THandle; InfoLevel: cardinal; + AFileStatus: PFileStatus; FileStatusLen: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectEnumAttribute (RefType: cardinal; AFile: pointer; + Entry: cardinal; var Buf; BufSize: cardinal; + var Count: cardinal; InfoLevel: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +function DosProtectSetFileLocks (Handle: THandle; + var Unlock, Lock: TFileLock; + Timeout, Flags: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + +(* + DosCancelLockRequestL cancels an outstanding DosSetFileLocksL request. + If two threads in a process are waiting on a lock file range, and another + thread issues DosCancelLockRequestL for that lock file range, then both + waiting threads are released. + Not all file-system drivers (FSDs) can cancel an outstanding lock request. + Local Area Network (LAN) servers cannot cancel an outstanding lock request + if they use a version of the operating system prior to OS/2 Version 2.00. + +Possible results: + 0 No_Error + 6 Error_Invalid_Handle + 87 Error_Invalid_Parameter + 173 Error_Cancel_Violation + + Handle = File handle used in the DosSetFileLocksL function + that is to be cancelled. + Lock = Specification of the lock request to be cancelled. +*) +function DosCancelLockRequestL (Handle: THandle; + var Lock: TFileLockL): cardinal; cdecl; + +(* +DosProtectSetFileLocksL locks and unlocks a range of an open file. + +Parameters: + Handle = file handle + Unlock = record containing the offset and length of a range to be unlocked + Lock = record containing the offset and length of a range to be locked + Timeout = the maximum time that the process is to wait for the requested locks + (in milliseconds) + Flags = bit mask specifying action to be taken. + Bits 31..2 are reserved. + Bit 1 (Atomic) means request for atomic locking - if the bit is set + and the lock range is equal to the unlock range, an atomic lock occurs. + If this bit is set to 1 and the lock range is not equal to the unlock + range, an error is returned. If this bit is set to 0, then the lock + may or may not occur atomically with the unlock. + Bit 0 (Share) defines the type of access that other processes may have + to the file range that is being locked. If this bit is set to 0 + (default), other processes have no access to the locked file range. + The current process has exclusive access to the locked file range, + which must not overlap any other locked file range. If this bit is set + to 1, the current process and other processes have shared read only + access to the locked file range. A file range with shared access may + overlap any other file range with shared access, but must not overlap + any other file range with exclusive access. + + FileHandleLockID = filehandle lockid returned by a previous DosProtectOpenL. + +Possible return codes: +0 NO_ERROR +6 ERROR_INVALID_HANDLE +33 ERROR_LOCK_VIOLATION +36 ERROR_SHARING_BUFFER_EXCEEDED +87 ERROR_INVALID_PARAMETER +95 ERROR_INTERRUPT +174 ERROR_ATOMIC_LOCK_NOT_SUPPORTED +175 ERROR_READ_LOCKS_NOT_SUPPORTED + +Remarks: +DosProtectSetFileLocksL allows a process to lock and unlock a range in a file. +The time during which a file range is locked should be short. + +If the lock and unlock ranges are both zero, ERROR_LOCK_VIOLATION is returned +to the caller. + +If you only want to lock a file range, set the unlock file offset and the +unlock range length to zero. + +If you only want to unlock a file range, set the lock file offset and the lock +range length to zero. + +When the Atomic bit of flags is set to 0, and DosProtectSetFileLocksL specifies +a lock operation and an unlock operation, the unlock operation occurs first, +and then the lock operation is performed. If an error occurs during the unlock +operation, an error code is returned and the lock operation is not performed. +If an error occurs during the lock operation, an error code is returned and the +unlock remains in effect if it was successful. + +The lock operation is atomic when all of these conditions are met: +- The Atomic bit is set to 1 in flags +- The unlock range is the same as the lock range +- The process has shared access to the file range, and has requested exclusive + access to it; or the process has exclusive access to the file range, and has + requested shared access to it. + +Some file system drivers (FSDs) may not support atomic lock operations. +Versions of the operating system prior to OS/2 Version 2.00 do not support +atomic lock operations. If the application receives the error code +ERROR_ATOMIC_LOCK_NOT_SUPPORTED, the application should unlock the file range +and then lock it using a non-atomic operation (with the atomic bit set to 0 +in Flags). The application should also refresh its internal buffers before +making any changes to the file. + +If you issue DosProtectClose to close a file with locks still in effect, +the locks are released in no defined sequence. + +If you end a process with a file open, and you have locks in effect in that +file, the file is closed and the locks are released in no defined sequence. + +The locked range can be anywhere in the logical file. Locking beyond the end +of the file is not an error. A file range to be locked exclusively must first +be cleared of any locked file sub-ranges or overlapping locked file ranges. + +If you repeat DosProtectSetFileLocksL for the same file handle and file range, +then you duplicate access to the file range. Access to locked file ranges +is not duplicated across DosExecPgm. The proper method of using locks is +to attempt to lock the file range, and to examine the return value. + +The following table shows the level of access granted when the accessed file +range is locked with an exclusive lock or a shared lock. Owner refers to +a process that owns the lock. Non-owner refers to a process that does not own +the lock. + + Action Exclusive Lock Shared Lock +=================================================================== + Owner read Success Success +------------------------------------------------------------------- + Non-owner Wait for unlock. Return Success + read error code after time-out. +------------------------------------------------------------------- + Owner write Success Wait for unlock. Return + error code after time-out. +------------------------------------------------------------------- + Non-owner Wait for unlock. Return Wait for unlock. Return + write error code after time-out. error code after time-out. +------------------------------------------------------------------- + + +If only locking is specified, DosProtectSetFileLocksL locks the specified file +range using Lock. If the lock operation cannot be accomplished, an error is +returned, and the file range is not locked. + +After the lock request is processed, a file range can be unlocked using the +Unlock parameter of another DosProtectSetFileLocksL request. If unlocking +cannot be accomplished, an error is returned. + +Instead of denying read/write access to an entire file by specifying access +and sharing modes with DosProtectOpenL requests, a process attempts to lock +only the range needed for read/write access and examines the error code +returned. + +Once a specified file range is locked exclusively, read and write access by +another process is denied until the file range is unlocked. If both unlocking +and locking are specified by DosProtectSetFileLocksL, the unlocking operation +is performed first, then locking is done. +*) +function DosProtectSetFileLocksL (Handle: THandle; var Unlock: TFileLockL; + var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + +(* +DosSetFileLocksL locks and unlocks a range of an open file. + +Parameters: + Handle = file handle + Unlock = record containing the offset and length of a range to be unlocked + Lock = record containing the offset and length of a range to be locked + Timeout = the maximum time that the process is to wait for the requested locks + (in milliseconds) + Flags = bit mask specifying action to be taken. + Bits 31..2 are reserved. + Bit 1 (Atomic) means request for atomic locking - if the bit is set + and the lock range is equal to the unlock range, an atomic lock occurs. + If this bit is set to 1 and the lock range is not equal to the unlock + range, an error is returned. If this bit is set to 0, then the lock + may or may not occur atomically with the unlock. + Bit 0 (Share) defines the type of access that other processes may have + to the file range that is being locked. If this bit is set to 0 + (default), other processes have no access to the locked file range. + The current process has exclusive access to the locked file range, + which must not overlap any other locked file range. If this bit is set + to 1, the current process and other processes have shared read only + access to the locked file range. A file range with shared access may + overlap any other file range with shared access, but must not overlap + any other file range with exclusive access. + +Possible return codes: + 0 NO_ERROR + 1 ERROR_INVALID_FUNCTION + 6 ERROR_INVALID_HANDLE + 33 ERROR_LOCK_VIOLATION + 36 ERROR_SHARING_BUFFER_EXCEEDED + 87 ERROR_INVALID_PARAMETER + 95 ERROR_INTERRUPT +174 ERROR_ATOMIC_LOCK_NOT_SUPPORTED +175 ERROR_READ_LOCKS_NOT_SUPPORTED + +Remarks: +DosSetFileLocksL allows a process to lock and unlock a range in a file. The +time during which a file range is locked should be short. + +If the lock and unlock ranges are both zero, ERROR_LOCK_VIOLATION is returned +to the caller. + +If you only want to lock a file range, set the unlock file offset and the +unlock range length to zero. + +If you only want to unlock a file range, set the lock file offset and the lock +range length to zero. + +When the Atomic bit of flags is set to 0, and DosSetFileLocksL specifies a lock +operation and an unlock operation, the unlock operation occurs first, and then +the lock operation is performed. If an error occurs during the unlock +operation, an error code is returned and the lock operation is not performed. +If an error occurs during the lock operation, an error code is returned and the +unlock remains in effect if it was successful. + +The lock operation is atomic when all of these conditions are met: +- The Atomic bit is set to 1 in flags +- The unlock range is the same as the lock range +- The process has shared access to the file range, and has requested exclusive + access to it; or the process has exclusive access to the file range, and has + requested shared access to it. + +Some file system drivers (FSDs) may not support atomic lock operations. +Versions of the operating system prior to OS/2 Version 2.00 do not support +atomic lock operations. If the application receives the error code +ERROR_ATOMIC_LOCK_NOT_SUPPORTED, the application should unlock the file range +and then lock it using a non-atomic operation (with the atomic bit set to 0 in +flags). The application should also refresh its internal buffers before making +any changes to the file. + +If you issue DosClose to close a file with locks still in effect, the locks are +released in no defined sequence. + +If you end a process with a file open, and you have locks in effect in that +file, the file is closed and the locks are released in no defined sequence. + +The locked range can be anywhere in the logical file. Locking beyond the end of +the file is not an error. A file range to be locked exclusively must first be +cleared of any locked file subranges or overlapping locked file ranges. + +If you repeat DosSetFileLocksL for the same file handle and file range, then +you duplicate access to the file range. Access to locked file ranges is not +duplicated across DosExecPgm. The proper method of using locks is to attempt to +lock the file range, and to examine the return value. + +The following table shows the level of access granted when the accessed file +range is locked with an exclusive lock or a shared lock. Owner refers to +a process that owns the lock. Non-owner refers to a process that does not own +the lock. + + Action Exclusive Lock Shared Lock +=================================================================== + Owner read Success Success +------------------------------------------------------------------- + Non-owner Wait for unlock. Return Success + read error code after time-out. +------------------------------------------------------------------- + Owner write Success Wait for unlock. Return + error code after time-out. +------------------------------------------------------------------- + Non-owner Wait for unlock. Return Wait for unlock. Return + write error code after time-out. error code after time-out. +------------------------------------------------------------------- + +If only locking is specified, DosSetFileLocksL locks the specified file range +using Lock. If the lock operation cannot be accomplished, an error is +returned, and the file range is not locked. + +After the lock request is processed, a file range can be unlocked using the +Unlock parameter of another DosSetFileLocksL request. If unlocking cannot be +accomplished, an error is returned. + +Instead of denying read/write access to an entire file by specifying access and +sharing modes with DosOpenL requests, a process attempts to lock only the range +needed for read/write access and examines the error code returned. + +Once a specified file range is locked exclusively, read and write access by +another process is denied until the file range is unlocked. If both unlocking +and locking are specified by DosSetFileLocksL, the unlocking operation is +performed first, then locking is done. +*) +function DosSetFileLocksL (Handle: THandle; var Unlock: TFileLockL; + var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal): cardinal; cdecl; + +(* +DosProtectOpenL opens a new file, an existing file, or a replacement for an +existing file and returns a protected file handle. An open file can have +extended attributes. + +Parameters: + FileName = ASCIIZ path name of the file or device to be opened. + Handle = handle for the file is returned here. + Action = value that specifies the action taken by DosProtectOpenL is returned + here; if DosProtectOpenL fails, this value has no meaning, otherwise, + it is one of the following values: + 1 FILE_EXISTED - file already existed. + 2 FILE_CREATED - file was created. + 3 FILE_TRUNCATED - file existed and was changed to a given size (file was + replaced). + InitSize = new logical size of the file (end of data, EOD), in bytes; this + parameter is significant only when creating a new file or replacing + an existing one. Otherwise, it is ignored. It is an error to create + or replace a file with a nonzero length if the OpenMode + Access-Mode flag is set to read-only. + Attrib = file attributes; this parameter contains the following bit fields: + Bits Description + + 31..6 - reserved, must be 0. + 5 FILE_ARCHIVED (0x00000020) - file has been archived. + 4 FILE_DIRECTORY (0x00000010) - file is a subdirectory. + 3 - reserved, must be 0. + 2 FILE_SYSTEM (0x00000004) - file is a system file. + 1 FILE_HIDDEN (0x00000002) - file is hidden and does not appear in + a directory listing. + 0 FILE_READONLY (0x00000001) - file can be read from, but not written + to. + 0 FILE_NORMAL (0x00000000) - file can be read from or written to. + +File attributes apply only if the file is created. These bits may be set +individually or in combination. For example, an attribute value of 0x00000021 +(bits 5 and 0 set to 1) indicates a read-only file that has been archived. + + OpenFlags = the action to be taken depending on whether the file exists or + does not exist. This parameter contains the following bit fields: + Bits Description + 31..8 - reserved, must be 0. + 7..4 - the following flags apply if the file does not exist: + 0000 OPEN_ACTION_FAIL_IF_NEW + Open an existing file; fail if the file does not exist. + 0001 OPEN_ACTION_CREATE_IF_NEW + Create the file if the file does not exist. + 3..0 The following flags apply if the file does not exist: + 0000 OPEN_ACTION_FAIL_IF_EXISTS + Open the file; fail if the file already exists. + 0001 OPEN_ACTION_OPEN_IF_EXISTS + Open the file if it already exists. + 0010 OPEN_ACTION_REPLACE_IF_EXISTS + Replace the file if it already exists. + + OpenMode = the mode of the open function. This parameter contains the + following bit fields: + Bits Description + 31 - reserved, must be zero. + 30 OPEN_FLAGS_PROTECTED_HANDLE (0x40000000) - protected file handle flag. + 0 - unprotected Handle + 1 - protected Handle + Protected handle requires the FileHandleLockID to be specified on subsequent + DosProtectxxxx calls. + + Unprotected handle requires the FileHandleLockID value to be specified as + zero on subsequent DosProtectxxxx calls. An unprotected handle may be used + with the unprotected calls such as DosRead and DosWrite. + + 29 OPEN_SHARE_DENYLEGACY (0x10000000) + Deny read/write access by the DosOpen command: + 0 - allow read/write access by the DosOpen command. + 1 - deny read/write access by the DosOpen command. + A file opened by DosOpenL will not be allowed to grow larger than 2GB while + that same file is open via a legacy DosOpen call. Setting this bit to 1 will + prevent access by the obsolete DosOpen API and ensure that no error will + occur when growing the file. + 28..16 - reserved, must be zero. + 15 OPEN_FLAGS_DASD (0x00008000) + Direct Open flag: + 0 - FileName represents a file to be opened normally. + 1 - FileName is drive (such as C or A), and represents a mounted + disk or diskette volume to be opened for direct access. + 14 OPEN_FLAGS_WRITE_THROUGH (0x00004000) + Write-Through flag: + 0 - writes to the file may go through the file-system driver's + cache; the file-system driver writes the sectors when the + cache is full or the file is closed. + 1 - writes to the file may go through the file-system driver's + cache, but the sectors are written (the actual file I/O + operation is completed) before a synchronous write call + returns. This state of the file defines it as a synchronous + file. For synchronous files, this bit must be set, because the + data must be written to the medium for synchronous write + operations. + This bit flag is not inherited by child processes. + 13 OPEN_FLAGS_FAIL_ON_ERROR (0x00002000) + Fail-Errors flag. Media I/O errors are handled as follows: + 0 - reported through the system critical-error handler. + 1 - reported directly to the caller by way of a return code. + Media I/O errors generated through Category 08h Logical Disk Control IOCtl + Commands always get reported directly to the caller by way of return code. + The Fail-Errors function applies only to non-IOCtl handle-based file I/O + calls. + + This flag bit is not inherited by child processes. + + 12 OPEN_FLAGS_NO_CACHE (0x00001000) + No-Cache/Cache flag: + 0 - the file-system driver should place data from I/O operations + into its cache. + 1 - I/O operations to the file need not be done through the + file-system driver's cache. + The setting of this bit determines whether file-system drivers should place + data into the cache. Like the write-through bit, this is a per-handle bit, + and is not inherited by child processes. + 11 - reserved; must be 0. + 10..8 - the locality of reference flags contain information about how the + application is to get access to the file. The values are as + follows: + 000 OPEN_FLAGS_NO_LOCALITY (0x00000000) + No locality known. + 001 OPEN_FLAGS_SEQUENTIAL (0x00000100) + Mainly sequential access. + 010 OPEN_FLAGS_RANDOM (0x00000200) + Mainly random access. + 011 OPEN_FLAGS_RANDOMSEQUENTIAL (0x00000300) + Random with some locality. + 7 OPEN_FLAGS_NOINHERIT (0x00000080) + Inheritance flag: + 0 - file handle is inherited by a process created from a call to + DosExecPgm. + 1 - file handle is private to the current process. + This bit is not inherited by child processes. + 6..4 Sharing Mode flags; this field defines any restrictions to file + access placed by the caller on other processes. The values are as + follows: + 001 OPEN_SHARE_DENYREADWRITE (0x00000010) + Deny read write access. + 010 OPEN_SHARE_DENYWRITE (0x00000020) + Deny write access. + 011 OPEN_SHARE_DENYREAD (0x00000030) + Deny read access. + 100 OPEN_SHARE_DENYNONE (0x00000040) + Deny neither read nor write access (deny none). + Any other value is invalid. + 3 Reserved; must be 0. + 2..0 Access-Mode flags. This field defines the file access required by the + caller. The values are as follows: + 000 OPEN_ACCESS_READONLY (0x00000000) + Read-only access + 001 OPEN_ACCESS_WRITEONLY (0x00000001) + Write-only access + 010 OPEN_ACCESS_READWRITE (0x00000002) + Read/write access. + Any other value is invalid, as are any other combinations. + +File sharing requires the cooperation of sharing processes. This cooperation is +communicated through sharing and access modes. Any sharing restrictions placed +on a file opened by a process are removed when the process closes the file with +a DosClose request. + +Sharing Mode: +Specifies the type of file access that other processes may have. For example, +if other processes can continue to read the file while your process is +operating on it, specify Deny Write. The sharing mode prevents other processes +from writing to the file but still allows them to read it. + +Access Mode: +Specifies the type of file access (access mode) needed by your process. For +example, if your process requires read/write access, and another process has +already opened the file with a sharing mode of Deny None, your DosProtectOpenL +request succeeds. However, if the file is open with a sharing mode of Deny +Write, the process is denied access. + +If the file is inherited by a child process, all sharing and access +restrictions also are inherited. + +If an open file handle is duplicated by a call to DosDupHandle, all sharing and +access restrictions also are duplicated. + + EA = pointer to an extended attribute buffer. The address of the + extended-attribute buffer, which contains an EAOP2 structure. The + fpFEA2List field in the EAOP2 structure points to a data area where the + relevant FEA2 list is to be found. The fpGEA2List and oError fields are + ignored. +Output fpGEA2List and fpFEA2List are unchanged. The area that fpFEA2List points +to is unchanged. If an error occurred during the set, oError is the offset of +the FEA2 entry where the error occurred. The return code from DosProtectOpenL +is the error code for that error condition. If no error occurred, oError is +undefined. + + EA is nil, then no extended attributes are defined for the file. If extended + attributes are not to be defined or modified, the pointer EA must be set to + nil. + + FileHandleLockID = 32-bit LockID for the file handle is returned here. + +Possible return codes: + 0 NO_ERROR + 2 ERROR_FILE_NOT_FOUND + 3 ERROR_PATH_NOT_FOUND + 4 ERROR_TOO_MANY_OPEN_FILES + 5 ERROR_ACCESS_DENIED + 12 ERROR_INVALID_ACCESS + 26 ERROR_NOT_DOS_DISK + 32 ERROR_SHARING_VIOLATION + 36 ERROR_SHARING_BUFFER_EXCEEDED + 82 ERROR_CANNOT_MAKE + 87 ERROR_INVALID_PARAMETER + 99 ERROR_DEVICE_IN_USE +108 ERROR_DRIVE_LOCKED +110 ERROR_OPEN_FAILED +112 ERROR_DISK_FULL +206 ERROR_FILENAME_EXCED_RANGE +231 ERROR_PIPE_BUSY + +Remarks: +A successful DosProtectOpenL request returns a handle and a 32-bit LockID for +accessing the file. The read/write pointer is set at the first byte of the +file. The position of the pointer can be changed with DosProtectSetFilePtrL or +by read and write operations on the file. + +The file s date and time can be queried with DosProtectQueryFileInfo. They are +set with DosProtectSetFileInfo. + +The read-only attribute of a file can be set with the ATTRIB command. + +ulAttribute cannot be set to Volume Label. To set volume-label information, +issue DosProtectSetFileInfo with a logical drive number. Volume labels cannot +be opened. + +InitSize affects the size of the file only when the file is new or is +a replacement. If an existing file is opened, cbFile is ignored. To change the +size of the existing file, issue DosProtectSetFileSizeL. + +The value in InitSize is a recommended size. If the full size cannot be +allocated, the open request may still succeed. The file system makes +a reasonable attempt to allocate the new size in an area that is as nearly +contiguous as possible on the medium. When the file size is extended, the +values of the new bytes are undefined. + +The Direct Open bit provides direct access to an entire disk or diskette +volume, independent of the file system. This mode of opening the volume that is +currently on the drive returns a handle to the calling function; the handle +represents the logical volume as a single file. The calling function specifies +this handle with a DosDevIOCtl Category 8, DSK_LOCKDRIVE request to prevent +other processes from accessing the logical volume. When you are finished using +the logical volume, issue a DosDevIOCtl Category 8, DSK_UNLOCKDRIVE request to +allow other processes to access the logical volume. + +The file-handle state bits can be set by DosProtectOpenL and +DosProtectSetFHState. An application can query the file-handle state bits, as +well as the rest of the Open Mode field, by issuing DosProtectQueryFHState. + +You can use an TEAOP2 structure to set extended attributes in EA when creating +a file, replacing an existing file, or truncating an existing file. No extended +attributes are set when an existing file is just opened. + +A replacement operation is logically equivalent to atomically deleting and +re-creating the file. This means that any extended attributes associated with +the file also are deleted before the file is re-created. + +The FileHandleLockID returned is required on each of the DosProtectxxx +functions. An incorrect pfhFileHandleLockID on subsequent DosProtectxxx calls +results in an ERROR_ACCESS_DENIED return code. + +The DosProtectxxx functions can be used with a NULL filehandle LockID, if the +subject filehandle was obtained from DosOpen. +*) +function DosProtectOpenL (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize: int64; Attrib, + OpenFlags, OpenMode: cardinal; EA: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; + + +(* +DosProtectSetFilePtrL moves the read or write pointer according to the type +of move specified. + +Parameters: + Handle = the handle returned by a previous DosOpenL function. + Pos = The signed distance (offset) to move, in bytes. + Method = The method of moving - location in the file at which the read/write + pointer starts before adding the Pos offset. The values and their + meanings are as shown in the following list: + 0 FILE_BEGIN - move the pointer from the beginning of the file. + 1 FILE_CURRENT - move the pointer from the current location of the + read/write pointer. + 2 FILE_END - move the pointer from the end of the file; use this method + to determine a file's size. + PosActual = address of the new pointer location. + FileHandleLockID = The filehandle lockid returned by a previous + DosProtectOpenL. + +Possible return codes: + 0 NO_ERROR + 1 ERROR_INVALID_FUNCTION + 6 ERROR_INVALID_HANDLE +132 ERROR_SEEK_ON_DEVICE +131 ERROR_NEGATIVE_SEEK +130 ERROR_DIRECT_ACCESS_HANDLE + +Remarks: + +The read/write pointer in a file is a signed 64-bit number. A negative value +for Pos moves the pointer backward in the file; a positive value moves it +forward. DosProtectSetFilePtrL cannot be used to move to a negative position in +the file. + +DosProtectSetFilePtrL cannot be used for a character device or pipe. +*) +function DosProtectSetFilePtrL (Handle: THandle; Pos: int64; + Method: cardinal; var PosActual: int64; + FileHandleLockID: cardinal): cardinal; cdecl; +(* +DosProtectSetFileSizeL changes the size of a file. + +Parameters: + Handle = handle of the file whose size to be changed. + Size = new size, in bytes, of the file. + FileHandleLockID = the filehandle lockid obtained from DosProtectOpenL. + +Possible return codes: + 0 NO_ERROR + 5 ERROR_ACCESS_DENIED + 6 ERROR_INVALID_HANDLE + 26 ERROR_NOT_DOS_DISK + 33 ERROR_LOCK_VIOLATION + 87 ERROR_INVALID_PARAMETER +112 ERROR_DISK_FULL + +Remarks: + +When DosProtectSetFileSizeL is issued, the file must be open in a mode that +allows write access. + +The size of the open file can be truncated or extended. If the file size is +being extended, the file system tries to allocate additional bytes in +a contiguous (or nearly contiguous) space on the medium. The values of the new +bytes are undefined. +*) +function DosProtectSetFileSizeL (Handle: THandle; Size: int64; + FileHandleLockID: cardinal): cardinal; cdecl; + +(* +DosGetProcessorStatus allows checking status of individual processors +in a SMP machine. + +Parameters: +ProcID = Procesor ID numbered 1 through n, where there are n processors in + total. +Status = Returned processor status defined as follows: + PROC_OFFLINE 0x00000000 Processor is offline + PROC_ONLINE 0x00000001 Processor is online + +Possible return codes: + 0 NO_ERROR +87 ERROR_INVALID_PARAMETER +*) +function DosGetProcessorStatus (ProcID: cardinal; + var Status: cardinal): cardinal; cdecl; + + +(* +DosSetProcessorStatus sets the ONLINE or OFFLINE status of a processor on +an SMP system. The processor status may be queried using DosGetProcessorStatus. +ONLINE status implies the processor is available for running work. OFFLINE +status implies the processor is not available for running work. The processor +that executes DosSetProcessorStatus must be ONLINE. + +Parameters: +ProcID = Processor ID numbered from 1 through n, where there are n processors + in total. +Status = Requested processor status defined as follows: + PROC_OFFLINE 0x00000000 Processor is offline. + PROC_ONLINE 0x00000001 Processor is online. + +Possible return codes: + 0 NO_ERROR +87 ERROR_INVALID_PARAMETER +*) +function DosSetProcessorStatus (ProcID: cardinal; + Status: cardinal): cardinal; cdecl; + +(* +DosQueryThreadAffinity allows a thread to inquire for the current thread's +processor affinity mask and the system's capable processor affinity mask. + +Parameters: +Scope = Scope of the query defined by one of the following values: + AFNTY_THREAD Return the current threads processor affinity mask. + AFNTY_SYSTEM Return the system's current capable processor affinity mask. +AffinityMask = Affinity mask is returned here; processors 0..31 are in Mask [0] + and processors 32..63 are in Mask [1]. + +Possible return codes: +13 ERROR_INVALID_DATA +87 ERROR_INVALID_PARAMETER +*) +function DosQueryThreadAffinity (Scope: cardinal; + var AffinityMask: TMPAffinity): cardinal; cdecl; + +(* +DosQueryExtLibPath returns the current path to be searched before or after the +system LIBPATH when locating DLLs. + +Parameters: +ExtLIBPATH = Buffer for receiving the extended LIBPATH string. + +??? +If the buffer pointed to by this parameter is not large enough to hold +the extended LIBPATH or an extended LIBPATH is not currently defined, this +parameter returns a pointer to a NULL string. +??? How is it detected if the size is not passed??? + +Flags - flag indicating when the new path is searched - possible values: + BEGIN_LIBPATH - The new path is searched before the LIBPATH. + END_LIBPATH - The new path is searched after the LIBPATH. + +Possible return codes: + 0 NO_ERROR + 87 ERROR_INVALID_PARAMETER +122 ERROR_INSUFFICIENT_BUFER +*) +function DosQueryExtLibPath (ExtLibPath: PChar; Flags: cardinal): cardinal; + cdecl; + +(* +DosSetExtLibPath defines the current path to be searched before or after the +system LIBPATH when locating DLLs. + +Parameters: +ExtLIBPATH = New extended LIBPATH string. Maximum size is 1024 bytes. + A pointer to a NULL string removes the extended LIBPATH. +Flags = When the new path is searched - possible values: + BEGIN_LIBPATH (1) - the new path is searched before the LIBPATH. + END_LIBPATH (2) - the new path is searched after the LIBPATH. + +The LIBPATH string is an environment variable found in the CONFIG.SYS file +consisting of a set of paths. If a fully-qualified path is not specified when +a module is loaded, the system searches these paths to find the DLL. + +There are two extended LIBPATH strings, BeginLIBPATH and EndLIBPATH. +BeginLIBPATH is searched before the system LIBPATH, and EndLIBPATH is searched +after both BeginLIBPATH and the system LIBPATH. These extended LIBPATHs can be +set either from the command line using the "SET" command, or by calling +DosSetExtLIBPATH. When DosSetExtLIBPATH is called, all modifications become +specific to that process. Initial settings can be set for all processes in the +system by setting the values in CONFIG.SYS using the "set" command. + +Note: The extended LIBPATHs are not true environment variables, and do not +appear when querying the environment. + +Every process inherits the settings of BeginLIBPATH and EndLIBPATH from the +process that starts it. If the extended library paths are initialized in +CONFIG.SYS, those extended library paths become the initial settings for new +processes. If a process changes BeginLIBPATH or EndLIBPATH and starts a new +process, the new child process inherits the changed contents. Child processes +that inherit their parent's extended LIBPATHs maintain their own copy. +Modifications made by the parent after the child has been created have no +effect on the children. + +This function permits the use of two symbols within the path string: +%BeginLIBPATH% and %EndLIBPATH%. These symbols are replaced with the current +string settings for the extended library paths. + +The LIBPATHs strings are only searched when the specified DLL is not currently +loaded. The only way to guarantee that the DLL being used is the correct +version is to set the fully-qualified path in DosLoadModule. When a request is +made to load a module and a path is not specified, the system searches the +paths in the LIBPATH string and uses the first instance of the specified DLL it +finds. If the new paths are added to the search strings, the system does not +check those directories to see if a different version exists. Consequently, if +two processes started from different directories use the same DLL, but +different versions of that DLL exist in both directories, the version of the +DLL loaded by the first process is the one used by both processes. The only way +to prevent this from occurring is to specify the path to the DLL when +DosLoadModule is called. + +Consequently, if one process sets its BeginLIBPATH to C:\PROCESS1\DLL and loads +the DLL MYAPP.DLL from that directory, and then a second process sets its +BeginLIBPATH to C:\PROCESS2\DLL and there is for a different version of +MYAPP.DLL in C:\PROCESS2\DLL, the second process will link to the DLL from +C:\PROCESS1\DLL since it was already loaded. + +Both BeginLIBPATH and EndLIBPATH can be set from the command line using the SET +command. + +Possible return codes: +0 NO_ERROR +8 ERROR_NOT_ENOUGH_MEMORY +87 ERROR_INVALID_PARAMETER +161 ERROR_BAD_PATHNAME +*) +function DosSetExtLibPath (ExtLibPath: PChar; Flags: cardinal): cardinal; + cdecl; + +(* +DosQueryModFromEIP queries a module handle and name from a given flat address. +It takes a flat 32 bit address as a parameter and returns information about the +module (a protected mode application currently executing) owning the storage. + +Parameters: +HMod = Address of a location in which the module handle is returned. +ObjNum = Address of a cardinal where the module object number corresponding to + the Address is returned. The object number is zero based. +BuffLen = Length of the user supplied buffer pointed to by Buff. +Buff = Address of a user supplied buffer in which the module name is returned. +Offset = Address where the offset to the object corresponding to the Address is + returned. The offset is zero based. +Address = Input address to be queried. + +Possible return codes: + 0 NO_ERROR + 87 ERROR_INVALID_PARAMETER +487 ERROR_INVALID_ADDRESS +*) +function DosQueryModFromEIP (var HMod: THandle; var ObjNum: cardinal; + BuffLen: cardinal; Buff: PChar; var Offset: cardinal; + Address: PtrUInt): cardinal; cdecl; + + +(* +DosDumpProcess initiates a process dump from a specified process. This may be used as part of an error handling routine to gather information about an error that may be analyzed later using the OS/2 System Dump Formatter. Configuration of Process Dump may be done using the PDUMPSYS, PDUMPUSR, and PROCDUMP commands. + +Parameters: +Flag = Function to be performed (one of DDP_* constants). + DDP_DISABLEPROCDUMP (0) - disable process dumps + DDP_ENABLEPROCDUMP (1) - enable process dumps + DDP_PERFORMPROCDUMP (2) - perform process dump (if the user enabled it using + the PROCDUMP command; ERROR_INVALID_PARAMETER is + returned otherwise) +Drive = The ASCII character for the drive on which process dump files are + to be created, or 0 to use the drive originally specified by the user + using the PROCDUMP command. This is required only with the + DDP_ENABLEPROCDUMP (PROCDUMP command allows customizing fully the drive + and path). +PID = The process to be dumped. 0 specifies the current process; otherwise + a valid process ID must be specified. This parameter is actioned only + with DDP_PERFORMPROCDUMP. + +Possible return Codes. + 0 NO_ERROR +87 ERROR_INVALID PARAMETER + +Remarks: +Use the PDUMPUSR command to specify what information will be dumped. + +Use the PROCDUMP command to customize options per process and in particular +to specify whether child or parent process will be dumped. + +For maximum flexibility the use of DosDumpProcess should be limited +to the DDP_PERFORMPROCDUMP function. This allows you to specify whether +Process Dump should be enabled through the use of the PROCDUMP command. +You may customize Process Dump completely through use of the PDUMPUSR, +PDUMPSYS, AND PROCDUMP commands. For further information, see PROCDUMP.DOC +in the OS2\SYSTEM\RAS directory. DDP_ENABLEPROCDUMP and DDP_DISABLEPROCDUMP +are provided for backwards compatibility only. +*) +function DosDumpProcess (Flag: cardinal; Drive: char; + PID: cardinal): cardinal; cdecl; + + +(* +Suppress application trap popups and log them to the file POPUPLOG.OS2. + +Parameters: +Flag = Flag indicating whether pop-up suppression should be enabled + or disabled (one of SPU_* constants - 0 or 1). +Drive = The drive letter for the log file (used only when pop-up suppression is + enabled). + +Remarks: +When pop-ups are suppressed through DosSuppressPopUps, the system does not +display trap screens on the user's terminal. The user will not be required +to respond to the abort, retry, continue message. Instead, the system displays +message SYS3571 and logs the name of the process to the POPUPLOG.OS2 log file +in the root directory of the specified drive. The system will also log +the message inserts in the log file. + +If the log file does not exist, the system will create it. If the log file +exists, the system appends to it. If the system cannot open the file (for +example, because the drive does not exist), the system will not log the pop-up +information. + +When pop-up suppression is enabled, the system overrides any settings +established by DosError on a per-process basis. + +This API overrides the potential initial setting (e.g. 'SUPPRESSPOPUPS=c') +in CONFIG.SYS. + +The drive letter for the log file may also be specified on the +DosSuppressPopUps API. + +If an invalid flag (a flag other than SPU_ENABLESUPPRESSION +or SPU_DISABLESUPPRESSION) or an invalid drive (a drive other than an upper- or +lowercase letter) is specified on DosSuppressPopUps, the system returns error +code ERROR_INVALID_PARAMETER. Otherwise, the system returns NO_ERROR. + +Possible error codes: + 0 NO_ERROR +87 ERROR_INVALID_PARAMETER +*) +function DosSuppressPopups (Flag: cardinal; Drive: char): cardinal; cdecl; + + +(* +DosPerfSysCall retrieves system performance information and performs software +tracing. + +Parameters: +Command = Command to be performed; the following commands are accepted: + CMD_KI_RDCNT ($63) - reads CPU utilization information in both uniprocessor + and symmetric multi-processor (SMP) environments by + taking a snapshot of the time stamp counters. To + determine CPU utilization, the application must compute + the difference between two time stamp snapshots using 64 + bit aritimetic. + CMD_SOFTTRACE_LOG ($14) - records software trace information. +Parm1 (CPUUtil) = Command-specific. In case of CMD_KI_RDCNT, pointer to + TCPUUtil record. In case of CMD_SOFTTRACE_LOG, major code for + the trace entry in the range of 0 to 255. Major codes 184 + ($B8) and 185 ($B9) have been reserved for IBM customer use. + Major code 1 is reserved for exclusive use by IBM. +Parm2 = Command-specific. In case of CMD_KI_RdCnt, it must be 0. In case of + CMD_SOFTTRACE_LOG, minor code for the trace entry in the range of + 0 to 255. +Parm3 (HookData) = Command-specific. In case of CMD_KI_RdCnt, it must be 0. In + case of CMD_SOFTTRACE_LOG, pointer to a HOOKDATA data + structure (see example code). + +Possible return codes: +0 NO_ERROR +1 ERROR_INVALID_FUNCTION + +Remarks: +DosPerfSysCall is a general purpose performance function. This function accepts +four parameters. The first parameter is the command requested. The other three +parameters are command specific. + +Some functions of DosPerfSysCall may have a dependency on Intel Pentium or +Pentium-Pro (or higher) support. If a function cannot be provided because OS/2 +is not running on a processor with the required features, a return code will +indicate an attempt to use an unsupported function. + +Example code (C): + int main (int argc, char *argv[]) + { + APIRET rc; + BYTE HookBuffer [256]; + HOOKDATA Hookdata = {0,HookBuffer}; + ULONG ulMajor, ulMinor; + *((PULONG) HookBuffer[0]) = 1; + *((PULONG) HookBuffer[4]) = 2; + *((PULONG) HookBuffer[8]) = 3; + strcpy((PSZ HookBuffer[12], "Test of 3 ULONG values and a string.") + HookData.ulLength = 12 + strlen((PSZ HookBuffer[12]) + 1; + + ulMajor = 0x00b8 + ulMinor = 0x0001 + + rc = DosPerfSystCall(CMD_SOFTTRACE_LOG, ulMajor, ulMinor, (ULONG) HookData); + if (rc != NO_ERROR) { + fprintf (stderr, "CMD_SOFTTRACE_LOG failed rc = %u\n", rc); + return 1; + } + + return NO_ERROR; + } +*) +function DosPerfSysCall (Command, Parm1, Parm2, + Parm3: cardinal): cardinal; cdecl; +function DosPerfSysCall (Command, Parm1, Parm2: cardinal; + var HookData): cardinal; cdecl; +function DosPerfSysCall (Command: cardinal; var CpuUtil: TCPUUtil; Parm2, + Parm3: cardinal): cardinal; cdecl; + + +(* +Query context of a suspended thread. + +Parameters: +TID = Thread ID +Level = Desired level of information +Context = Thread context record + +DosQueryThreadContext returns the context record of a suspended thread. +A thread may be suspended by using DosSuspendThread or DosEnterCritSec. +If DosSuspendThread is used, the caller must allow some time for OS/2 to +suspend the thread before querying its context. + +Note: Values from the thread context should be used only when the state +of the target thread is known. + +Possible return codes: + 0 NO_ERROR + 87 ERROR_INVALID_PARAMETER + 90 ERROR_NOT_FROZEN +115 ERROR_PROTECTION_VIOLATION +309 ERROR_INVALID_THREADID +*) +function DosQueryThreadContext (TID: cardinal; Level: cardinal; + var Context: TContextRecord): cardinal; cdecl; + + +(* +DosQueryABIOSSupport returns flags that indicate various basic hardware +configurations. + +Parameters: +Reserved = Must be set to 0, no other value is defined. + +The result of this function contains combination of flags (HW_Cfg_* constants) +signalizing the underlying hardware configuration. +*) +function DosQueryABIOSSupport (Reserved: cardinal): cardinal; cdecl; + + +{***************************************************************************} +implementation +{***************************************************************************} + +uses + OS2Def; + + +function DummyDosCancelLockRequestL (Handle: THandle; var Lock: TFileLockL): cardinal; cdecl; +var + Lock0: TFileLock; +begin + if (Lock.Offset > high (longint)) or (Lock.Range > high (longint)) or + (Lock.Offset < 0) or (Lock.Range < 0) then + DummyDosCancelLockRequestL := Error_Invalid_Parameter + else + begin + Lock0.Offset := longint (Lock.Offset); + Lock0.Range := longint (Lock.Range); + DummyDosCancelLockRequestL := DosCancelLockRequest (Handle, Lock0); + end; +end; + + +function DummyDosProtectSetFileLocksL (Handle: THandle; var Unlock: TFileLockL; + var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +var + Lock0: TFileLock; + UnLock0: TFileLock; +begin + if (Lock.Offset > high (longint)) or (Lock.Range > high (longint)) or + (Unlock.Offset > high (longint)) or (Unlock.Range > high (longint)) then + DummyDosProtectSetFileLocksL := Error_Invalid_Parameter + else + begin + Lock0.Offset := longint (Lock.Offset); + Lock0.Range := longint (Lock.Range); + Unlock0.Offset := longint (Unlock.Offset); + Unlock0.Range := longint (Lock.Range); + DummyDosProtectSetFileLocksL := DosProtectSetFileLocks (Handle, Unlock0, + Lock0, Timeout, Flags, FileHandleLockID); + end; +end; + + +function DummyDosSetFileLocksL (Handle: THandle; var Unlock: TFileLockL; + var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal): cardinal; cdecl; +var + Lock0: TFileLock; + UnLock0: TFileLock; +begin + if (Lock.Offset > high (longint)) or (Lock.Range > high (longint)) or + (Lock.Offset < 0) or (Lock.Range < 0) or + (Unlock.Offset < 0) or (Unlock.Range < 0) or + (Unlock.Offset > high (longint)) or (Unlock.Range > high (longint)) then + DummyDosSetFileLocksL := Error_Invalid_Parameter + else + begin + Lock0.Offset := longint (Lock.Offset); + Lock0.Range := longint (Lock.Range); + Unlock0.Offset := longint (Unlock.Offset); + Unlock0.Range := longint (Lock.Range); + DummyDosSetFileLocksL := DosSetFileLocks (Handle, Unlock0, Lock0, Timeout, + Flags); + end; +end; + + +function DummyDosProtectOpenL (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize: int64; Attrib, + OpenFlags, OpenMode: cardinal; EA: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; +begin + if InitSize > high (longint) then + DummyDosProtectOpenL := Error_Invalid_Parameter + else + DummyDosProtectOpenL := DosProtectOpen (FileName, Handle, Action, + longint (InitSize), Attrib, OpenFlags, OpenMode, EA, FileHandleLockID); +end; + + +function DummyDosProtectSetFilePtrL (Handle: THandle; Pos: int64; + Method: cardinal; var PosActual: int64; + FileHandleLockID: cardinal): cardinal; cdecl; +var + PosActual0: cardinal; +begin + if (Pos < low (longint)) or (Pos > high (longint)) then + DummyDosProtectSetFilePtrL := Error_Invalid_Parameter + else + begin + DummyDosProtectSetFilePtrL := DosProtectSetFilePtr (Handle, longint (Pos), + Method, PosActual0, FileHandleLockID); + PosActual := PosActual0; + end; +end; + + +function DummyDosProtectSetFileSizeL (Handle: THandle; Size: int64; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + if (Size > high (cardinal)) then + DummyDosProtectSetFileSizeL := Error_Invalid_Parameter + else + DummyDosProtectSetFileSizeL := DosProtectSetFileSize (Handle, + cardinal (Size), FileHandleLockID); +end; + + +function DummyDosProtectSetFileLocks (Handle: THandle; + var Unlock, Lock: TFileLock; + Timeout, Flags: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + if FileHandleLockID <> 0 then + DummyDosProtectSetFileLocks := Error_Invalid_Parameter + else + DummyDosProtectSetFileLocks := DosSetFileLocks (Handle, Unlock, Lock, + Timeout, Flags); +end; + + +function DummyDosProtectOpen (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize, Attrib, + OpenFlags, OpenMode: cardinal; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectOpen := DosOpen (FileName, Handle, Action, InitSize, Attrib, + OpenFlags, OpenMode, EA); + FileHandleLockID := 0; +end; + + +function DummyDosProtectClose (Handle: THandle; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectClose := DosClose (Handle); +end; + + +function DummyDosProtectRead (Handle: THandle; var Buffer; Count: cardinal; + var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectRead := DosRead (Handle, Buffer, Count, ActCount); +end; + + +function DummyDosProtectWrite (Handle: THandle; const Buffer; Count: cardinal; + var ActCount: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectWrite := DosWrite (Handle, Buffer, Count, ActCount); +end; + + +function DummyDosProtectSetFilePtr (Handle: THandle; Pos: longint; + Method: cardinal; var PosActual: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectSetFilePtr := DosSetFilePtr (Handle, Pos, Method, PosActual); +end; + + +function DummyDosProtectSetFileSize (Handle: THandle; Size: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectSetFileSize := DosSetFileSize (Handle, Size); +end; + + +function DummyDosProtectQueryFHState (Handle: THandle; var FileMode: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectQueryFHState := DosQueryFHState (Handle, FileMode); +end; + + +function DummyDosProtectSetFHState (Handle: THandle; FileMode: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectSetFHState := DosSetFHState (Handle, FileMode); +end; + + +function DummyDosProtectQueryFileInfo (Handle: THandle; InfoLevel: cardinal; + AFileStatus: PFileStatus; FileStatusLen: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectQueryFileInfo := DosQueryFileInfo (Handle, InfoLevel, + AFileStatus, FileStatusLen); +end; + + +function DummyDosProtectSetFileInfo (Handle: THandle; InfoLevel: cardinal; + AFileStatus: PFileStatus; FileStatusLen: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectSetFileInfo := DosSetFileInfo (Handle, InfoLevel, + AFileStatus, FileStatusLen); +end; + + +function DummyDosProtectEnumAttribute (RefType: cardinal; AFile: pointer; + Entry: cardinal; var Buf; BufSize: cardinal; + var Count: cardinal; InfoLevel: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; +begin + DummyDosProtectEnumAttribute := DosEnumAttribute (RefType, AFile, Entry, + Buf, BufSize, Count, InfoLevel); +end; + + +function DummyDosGetProcessorStatus (ProcID: cardinal; + var Status: cardinal): cardinal; cdecl; +begin + if ProcID = 1 then + begin + Status := 1; + DummyDosGetProcessorStatus := No_Error; + end + else + DummyDosGetProcessorStatus := Error_Invalid_Parameter; +end; + + +function DummyDosSetProcessorStatus (ProcID: cardinal; + Status: cardinal): cardinal; cdecl; +begin + DummyDosSetProcessorStatus := Error_Invalid_Parameter; +end; + + +function DummyDosQueryThreadAffinity (Scope: cardinal; + var AffinityMask: TMPAffinity): cardinal; cdecl; +begin + DummyDosQueryThreadAffinity := Error_Invalid_Function; +end; + + +function DummyDosSetThreadAffinity (var AffinityMask: TMPAffinity): cardinal; + cdecl; +begin + DummyDosSetThreadAffinity := Error_Invalid_Function; +end; + + +function DummyDosQueryExtLibPath (ExtLibPath: PChar; + Flags: cardinal): cardinal; cdecl; +begin + if ExtLibPath <> nil then + begin + ExtLibPath := #0; + DummyDosQueryExtLibPath := No_Error; + end + else + DummyDosQueryExtLibPath := Error_Invalid_Parameter; +end; + + +function DummyDosSetExtLibPath (ExtLibPath: PChar; Flags: cardinal): cardinal; + cdecl; +begin + DummyDosSetExtLibPath := Error_Not_Enough_Memory; +end; + + +function DummyDosQueryModFromEIP (var HMod: THandle; var ObjNum: cardinal; + BuffLen: cardinal; Buff: PChar; var Offset: cardinal; + Address: PtrUInt): cardinal; cdecl; +begin + DummyDosQueryModFromEIP := Error_Invalid_Parameter; + HMod := THandle (-1); + ObjNum := 0; + if Buff <> nil then + Buff^ := #0; + Offset := 0; +end; + + +function DummyDosDumpProcess (Flag: cardinal; Drive: cardinal; + PID: cardinal): cardinal; cdecl; +begin + DummyDosDumpProcess := Error_Invalid_Function; +end; + + +function DummyDosSuppressPopups (Flag: cardinal; Drive: char): cardinal; cdecl; +begin + DummyDosSuppressPopups := Error_Invalid_Function; +end; + + +function DummyDosPerfSysCall (Command, Parm1, Parm2, + Parm3: cardinal): cardinal; cdecl; +begin + DummyDosPerfSysCall := Error_Invalid_Function; +end; + + +function DummyDosQueryThreadContext (TID: cardinal; Level: cardinal; + var Context: TContextRecord): cardinal; cdecl; +begin + DummyDosQueryThreadContext := Error_Invalid_Function; +end; + + +function DummyDosQueryABIOSSupport (Reserved: cardinal): cardinal; cdecl; +begin + DummyDosQueryABIOSSupport := 0; +end; + + + +type + TDosProtectOpen = function (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize, Attrib, + OpenFlags, OpenMode: cardinal; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectClose = function (Handle: THandle; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectRead = function (Handle: THandle; var Buffer; Count: cardinal; + var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectWrite = function (Handle: THandle; const Buffer; Count: cardinal; + var ActCount: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectSetFilePtr = function (Handle: THandle; Pos: longint; + Method: cardinal; var PosActual: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectSetFileSize = function (Handle: THandle; Size: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectQueryFHState = function (Handle: THandle; var FileMode: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectSetFHState = function (Handle: THandle; FileMode: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectQueryFileInfo = function (Handle: THandle; InfoLevel: cardinal; + AFileStatus: PFileStatus; FileStatusLen: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectSetFileInfo = function (Handle: THandle; InfoLevel: cardinal; + AFileStatus: PFileStatus; FileStatusLen: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectEnumAttribute = function (RefType: cardinal; AFile: pointer; + Entry: cardinal; var Buf; BufSize: cardinal; + var Count: cardinal; InfoLevel: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectSetFileLocks = function (Handle: THandle; + var Unlock, Lock: TFileLock; + Timeout, Flags: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosCancelLockRequestL = function (Handle: THandle; var Lock: TFileLockL): + cardinal; cdecl; + + TDosProtectSetFileLocksL = function (Handle: THandle; var Unlock: TFileLockL; + var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosSetFileLocksL = function (Handle: THandle; var Unlock: TFileLockL; + var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal): cardinal; cdecl; + + TDosProtectOpenL = function (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize: int64; Attrib, + OpenFlags, OpenMode: cardinal; EA: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectSetFilePtrL = function (Handle: THandle; Pos: int64; + Method: cardinal; + var PosActual: int64; FileHandleLockID: cardinal): cardinal; cdecl; + + TDosProtectSetFileSizeL = function (Handle: THandle; Size: int64; + FileHandleLockID: cardinal): cardinal; cdecl; + + TDosGetProcessorStatus = function (ProcID: cardinal; + var Status: cardinal): cardinal; cdecl; + + TDosSetProcessorStatus = function (ProcID: cardinal; + Status: cardinal): cardinal; cdecl; + + TDosQueryThreadAffinity = function (Scope: cardinal; + var AffinityMask: TMPAffinity): cardinal; cdecl; + + TDosSetThreadAffinity = function (var AffinityMask: TMPAffinity): cardinal; + cdecl; + + TDosQueryExtLibPath = function (ExtLibPath: PChar; + Flags: cardinal): cardinal; cdecl; + + TDosSetExtLibPath = function (ExtLibPath: PChar; Flags: cardinal): cardinal; + cdecl; + + TDosQueryModFromEIP = function (var HMod: THandle; var ObjNum: cardinal; + BuffLen: cardinal; Buff: PChar; var Offset: cardinal; + Address: PtrUInt): cardinal; cdecl; + + TDosDumpProcess = function (Flag: cardinal; Drive: cardinal; + PID: cardinal): cardinal; cdecl; + + TDosSuppressPopups = function (Flag: cardinal; Drive: char): cardinal; cdecl; + + TDosPerfSysCall = function (Command, Parm1, Parm2, + Parm3: cardinal): cardinal; cdecl; + + TDosQueryThreadContext = function (TID: cardinal; Level: cardinal; + var Context: TContextRecord): cardinal; cdecl; + + TDosQueryABIOSSupport = function (Reserved: cardinal): cardinal; cdecl; + + + +const + Sys_DosCancelLockRequestL: TDosCancelLockRequestL = + @DummyDosCancelLockRequestL; + Sys_DosSetFileLocksL: TDosSetFileLocksL = @DummyDosSetFileLocksL; + Sys_DosProtectSetFileLocksL: TDosProtectSetFileLocksL = + @DummyDosProtectSetFileLocksL; + Sys_DosProtectOpenL: TDosProtectOpenL = @DummyDosProtectOpenL; + Sys_DosProtectSetFilePtrL: TDosProtectSetFilePtrL = + @DummyDosProtectSetFilePtrL; + Sys_DosProtectSetFileSizeL: TDosProtectSetFileSizeL = + @DummyDosProtectSetFileSizeL; + Sys_DosProtectOpen: TDosProtectOpen = @DummyDosProtectOpen; + Sys_DosProtectClose: TDosProtectClose = @DummyDosProtectClose; + Sys_DosProtectRead: TDosProtectRead = @DummyDosProtectRead; + Sys_DosProtectWrite: TDosProtectWrite = @DummyDosProtectWrite; + Sys_DosProtectSetFilePtr: TDosProtectSetFilePtr = @DummyDosProtectSetFilePtr; + Sys_DosProtectSetFileSize: TDosProtectSetFileSize = + @DummyDosProtectSetFileSize; + Sys_DosProtectQueryFHState: TDosProtectQueryFHState = + @DummyDosProtectQueryFHState; + Sys_DosProtectSetFHState: TDosProtectSetFHState = @DummyDosProtectSetFHState; + Sys_DosProtectQueryFileInfo: TDosProtectQueryFileInfo = + @DummyDosProtectQueryFileInfo; + Sys_DosProtectSetFileInfo: TDosProtectSetFileInfo = + @DummyDosProtectSetFileInfo; + Sys_DosProtectEnumAttribute: TDosProtectEnumAttribute = + @DummyDosProtectEnumAttribute; + Sys_DosProtectSetFileLocks: TDosProtectSetFileLocks = + @DummyDosProtectSetFileLocks; + Sys_DosGetProcessorStatus: TDosGetProcessorStatus = + @DummyDosGetProcessorStatus; + Sys_DosSetProcessorStatus: TDosSetProcessorStatus = + @DummyDosSetProcessorStatus; + Sys_DosQueryThreadAffinity: TDosQueryThreadAffinity = + @DummyDosQueryThreadAffinity; + Sys_DosSetThreadAffinity: TDosSetThreadAffinity = @DummyDosSetThreadAffinity; + Sys_DosQueryExtLibPath: TDosQueryExtLibPath = @DummyDosQueryExtLibPath; + Sys_DosSetExtLibPath: TDosSetExtLibPath = @DummyDosSetExtLibPath; + Sys_DosQueryModFromEIP: TDosQueryModFromEIP = @DummyDosQueryModFromEIP; + Sys_DosDumpProcess: TDosDumpProcess = @DummyDosDumpProcess; + Sys_DosSuppressPopups: TDosSuppressPopups = @DummyDosSuppressPopups; + Sys_DosPerfSysCall: TDosPerfSysCall = @DummyDosPerfSysCall; + Sys_DosQueryThreadContext: TDosQueryThreadContext = + @DummyDosQueryThreadContext; + Sys_DosQueryABIOSSupport: TDosQueryABIOSSupport = @DummyDosQueryABIOSSupport; + + + +function DosOpenL (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize: int64; + Attrib, OpenFlags, FileMode: cardinal; + EA: pointer): cardinal; cdecl; inline; +begin + DosOpenL := Sys_DosOpenL (FileName, Handle, Action, InitSize, Attrib, + OpenFlags, FileMode, EA); +end; + + +function DosSetFilePtrL (Handle: THandle; Pos: int64; Method: cardinal; + var PosActual: int64): cardinal; cdecl; inline; +begin + DosSetFilePtrL := Sys_DosSetFilePtrL (Handle, Pos, Method, PosActual); +end; + + +function DosSetFileSizeL (Handle: THandle; Size: int64): cardinal; cdecl; + inline; +begin + DosSetFileSizeL := Sys_DosSetFileSizeL (Handle, Size); +end; + + +function DosProtectOpen (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize, Attrib, + OpenFlags, OpenMode: cardinal; EA: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectOpen := Sys_DosProtectOpen (FileName, Handle, Action, InitSize, + Attrib, OpenFlags, OpenMode, EA, FileHandleLockID); +end; + + +function DosProtectClose (Handle: THandle; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectClose := Sys_DosProtectClose (Handle, FileHandleLockID); +end; + + +function DosProtectRead (Handle: THandle; var Buffer; Count: cardinal; + var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectRead := Sys_DosProtectRead (Handle, Buffer, Count, ActCount, + FileHandleLockID); +end; + + +function DosProtectWrite (Handle: THandle; const Buffer; Count: cardinal; + var ActCount: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectWrite := Sys_DosProtectWrite (Handle, Buffer, Count, ActCount, + FileHandleLockID); +end; + + +function DosProtectSetFilePtr (Handle: THandle; Pos: longint; + Method: cardinal; var PosActual: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFilePtr := Sys_DosProtectSetFilePtr (Handle, Pos, Method, + PosActual, FileHandleLockID); +end; + + +function DosProtectSetFileSize (Handle: THandle; Size: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFileSize := Sys_DosProtectSetFileSize (Handle, Size, + FileHandleLockID); +end; + + +function DosProtectQueryFHState (Handle: THandle; var FileMode: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectQueryFHState := Sys_DosProtectQueryFHState (Handle, FileMode, + FileHandleLockID); +end; + + +function DosProtectSetFHState (Handle: THandle; FileMode: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFHState := Sys_DosProtectSetFHState (Handle, FileMode, + FileHandleLockID); +end; + + +function DosProtectQueryFileInfo (Handle: THandle; InfoLevel: cardinal; + AFileStatus: PFileStatus; FileStatusLen: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectQueryFileInfo := Sys_DosProtectQueryFileInfo (Handle, InfoLevel, + AFileStatus, FileStatusLen, FileHandleLockID); +end; + + +function DosProtectSetFileInfo (Handle: THandle; InfoLevel: cardinal; + AFileStatus: PFileStatus; FileStatusLen: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFileInfo := Sys_DosProtectSetFileInfo (Handle, InfoLevel, + AFileStatus, FileStatusLen, FileHandleLockID); +end; + + +function DosProtectEnumAttribute (RefType: cardinal; AFile: pointer; + Entry: cardinal; var Buf; BufSize: cardinal; + var Count: cardinal; InfoLevel: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectEnumAttribute := Sys_DosProtectEnumAttribute (RefType, AFile, + Entry, Buf, BufSize, Count, InfoLevel, FileHandleLockID); +end; + + +function DosProtectSetFileLocks (Handle: THandle; + var Unlock, Lock: TFileLock; + Timeout, Flags: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFileLocks := Sys_DosProtectSetFileLocks (Handle, Unlock, Lock, + Timeout, Flags, FileHandleLockID); +end; + + +function DosProtectOpen (FileName: PChar; var Handle: longint; + var Action: longint; InitSize, Attrib, + OpenFlags, OpenMode: longint; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectOpen := Sys_DosProtectOpen (FileName, THandle (Handle), + cardinal (Action), cardinal (InitSize), cardinal (Attrib), + cardinal (OpenFlags), cardinal (OpenMode), EA, FileHandleLockID); +end; + + +function DosProtectOpen (const FileName: string; var Handle: longint; + var Action: longint; InitSize, Attrib, + OpenFlags, OpenMode: longint; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; +var + T: array [0..255] of char; +begin + StrPCopy (@T, FileName); + DosProtectOpen := Sys_DosProtectOpen (@T, THandle (Handle), + cardinal (Action), cardinal (InitSize), cardinal (Attrib), + cardinal (OpenFlags), cardinal (OpenMode), EA, FileHandleLockID); +end; + + +function DosProtectOpen (const FileName: string; var Handle: THandle; + var Action: cardinal; InitSize, Attrib, + OpenFlags, OpenMode: cardinal; ea: PEAOp2; + var FileHandleLockID: cardinal): cardinal; +var + T: array [0..255] of char; +begin + StrPCopy (@T, FileName); + DosProtectOpen := Sys_DosProtectOpen (@T, Handle, Action, InitSize, Attrib, + OpenFlags, OpenMode, EA, FileHandleLockID); +end; + + +function DosProtectRead (Handle: longint; var Buffer; Count: longint; + var ActCount: longint; FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectRead := Sys_DosProtectRead (THandle (Handle), Buffer, + cardinal (Count), cardinal (ActCount), FileHandleLockID); +end; + + +function DosProtectWrite (Handle: longint; const Buffer; Count: longint; + var ActCount: longint; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectWrite := Sys_DosProtectWrite (THandle (Handle), Buffer, + cardinal (Count), cardinal (ActCount), FileHandleLockID); +end; + + +function DosProtectSetFilePtr (Handle: longint; Pos, Method: longint; + var PosActual: longint; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFilePtr := Sys_DosProtectSetFilePtr (THandle (Handle), + cardinal (Pos), cardinal (Method), cardinal (PosActual), FileHandleLockID); +end; + + +function DosProtectSetFilePtr (Handle: THandle; Pos: longint; + FileHandleLockID: cardinal): cardinal; +var + PosActual: cardinal; +begin + DosProtectSetFilePtr := DosProtectSetFilePtr (Handle, Pos, 0, PosActual, + FileHandleLockID); +end; + + +function DosProtectGetFilePtr (Handle: longint; + var PosActual: longint; FileHandleLockID: cardinal): cardinal; +begin + DosProtectGetFilePtr := DosProtectSetFilePtr (THandle (Handle), 0, 1, + cardinal (PosActual), FileHandleLockID); +end; + + +function DosProtectGetFilePtr (Handle: THandle; + var PosActual: cardinal; FileHandleLockID: cardinal): cardinal; +begin + DosProtectGetFilePtr := DosProtectSetFilePtr (Handle, 0, 1, PosActual, + FileHandleLockID); +end; + + +function DosProtectEnumAttribute (Handle: THandle; Entry: cardinal; var Buf; + BufSize: cardinal; var Count: cardinal; + InfoLevel: cardinal; + FileHandleLockID: cardinal): cardinal; +begin + DosProtectEnumAttribute := DosProtectEnumAttribute (0, @Handle, Entry, Buf, + BufSize, Count, InfoLevel, FileHandleLockID); +end; + + +function DosProtectEnumAttribute (const FileName: string; Entry: cardinal; + var Buf; BufSize: cardinal; + var Count: cardinal; InfoLevel: cardinal; + FileHandleLockID: cardinal): cardinal; +var + T: array [0..255] of char; +begin + StrPCopy (@T, FileName); + DosProtectEnumAttribute := DosProtectEnumAttribute (1, @T, Entry, Buf, + BufSize, Count, InfoLevel, FileHandleLockID); +end; + + +function DosCancelLockRequestL (Handle: THandle; + var Lock: TFileLockL): cardinal; cdecl; inline; +begin + DosCancelLockRequestL := Sys_DosCancelLockRequestL (Handle, Lock); +end; + + +function DosProtectSetFileLocksL (Handle: THandle; var Unlock: TFileLockL; + var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFileLocksL := Sys_DosProtectSetFileLocksL (Handle, Unlock, Lock, + Timeout, Flags, FileHandleLockID); +end; + + +function DosSetFileLocksL (Handle: THandle; var Unlock: TFileLockL; + var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal): cardinal; cdecl; + inline; +begin + DosSetFileLocksL := Sys_DosSetFileLocksL (Handle, Unlock, Lock, Timeout, + Flags); +end; + + +function DosProtectOpenL (FileName: PChar; var Handle: THandle; + var Action: cardinal; InitSize: int64; Attrib, + OpenFlags, OpenMode: cardinal; EA: PEAOp2; + var FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectOpenL := Sys_DosProtectOpenL (FileName, Handle, Action, InitSize, + Attrib, OpenFlags, OpenMode, EA, FileHandleLockID); +end; + + +function DosProtectSetFilePtrL (Handle: THandle; Pos: int64; + Method: cardinal; var PosActual: int64; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFilePtrL := Sys_DosProtectSetFilePtrL (Handle, Pos, Method, + PosActual, FileHandleLockID); +end; + + +function DosProtectSetFileSizeL (Handle: THandle; Size: int64; + FileHandleLockID: cardinal): cardinal; cdecl; inline; +begin + DosProtectSetFileSizeL := Sys_DosProtectSetFileSizeL (Handle, Size, + FileHandleLockID); +end; + + +function DosGetProcessorStatus (ProcID: cardinal; + var Status: cardinal): cardinal; cdecl; inline; +begin + DosGetProcessorStatus := Sys_DosGetProcessorStatus (ProcID, Status); +end; + + +function DosSetProcessorStatus (ProcID: cardinal; + Status: cardinal): cardinal; cdecl; inline; +begin + DosSetProcessorStatus := Sys_DosSetProcessorStatus (ProcID, Status); +end; + + +function DosQueryThreadAffinity (Scope: cardinal; + var AffinityMask: TMPAffinity): cardinal; cdecl; inline; +begin + DosQueryThreadAffinity := Sys_DosQueryThreadAffinity (Scope, AffinityMask); +end; + + +function DosSetThreadAffinity (var AffinityMask: TMPAffinity): cardinal; cdecl; + inline; +begin + DosSetThreadAffinity := Sys_DosSetThreadAffinity (AffinityMask); +end; + + +function DosQueryExtLibPath (ExtLibPath: PChar; Flags: cardinal): cardinal; + cdecl; inline; +begin + DosQueryExtLibPath := Sys_DosQueryExtLibPath (ExtLibPath, Flags); +end; + + +function DosSetExtLibPath (ExtLibPath: PChar; Flags: cardinal): cardinal; + cdecl; inline; +begin + DosSetExtLibPath := Sys_DosSetExtLibPath (ExtLibPath, Flags); +end; + + +function DosQueryModFromEIP (var HMod: THandle; var ObjNum: cardinal; + BuffLen: cardinal; Buff: PChar; var Offset: cardinal; + Address: PtrUInt): cardinal; cdecl; inline; +begin + DosQueryModFromEIP := Sys_DosQueryModFromEIP (HMod, ObjNum, BuffLen, Buff, + Offset, Address); +end; + + +function DosDumpProcess (Flag: cardinal; Drive: char; + PID: cardinal): cardinal; cdecl; inline; +begin + DosDumpProcess := Sys_DosDumpProcess (Flag, cardinal (Drive), PID); +end; + + +function DosSuppressPopups (Flag: cardinal; + Drive: char): cardinal; cdecl; inline; +begin + DosSuppressPopups := Sys_DosSuppressPopups (Flag, Drive); +end; + + +function DosPerfSysCall (Command, Parm1, Parm2, + Parm3: cardinal): cardinal; cdecl; inline; +begin + DosPerfSysCall := Sys_DosPerfSysCall (Command, Parm1, Parm2, Parm3); +end; + + +function DosPerfSysCall (Command, Parm1, Parm2: cardinal; + var HookData): cardinal; cdecl; +begin + DosPerfSysCall := Sys_DosPerfSysCall (Command, Parm1, Parm2, + PtrUInt (HookData)); +end; + + +function DosPerfSysCall (Command: cardinal; var CpuUtil: TCPUUtil; Parm2, + Parm3: cardinal): cardinal; cdecl; +begin + DosPerfSysCall := Sys_DosPerfSysCall (Command, PtrUInt (@CPUUtil), Parm2, + Parm3); +end; + + +function DosQueryThreadContext (TID: cardinal; Level: cardinal; + var Context: TContextRecord): cardinal; cdecl; inline; +begin + DosQueryThreadContext := Sys_DosQueryThreadContext (TID, Level, Context); +end; + + +function DosQueryABIOSSupport (Reserved: cardinal): cardinal; cdecl; inline; +begin + DosQueryABIOSSupport := Sys_DosQueryABIOSSupport (Reserved); +end; + + +var + P: pointer; + +begin + if FSApi64 then + (* DosCallsHandle successfully initialized during initialization of unit *) + (* System and basic 64-bit functions were loaded successfully. *) + begin + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32CancelLockRequestL, nil, P) + = 0 then + Sys_DosCancelLockRequestL := TDosCancelLockRequestL (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileLocksL, nil, P) + = 0 then + Sys_DosProtectSetFileLocksL := TDosProtectSetFileLocksL (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SetFileLocksL, nil, P) + = 0 then + Sys_DosSetFileLocksL := TDosSetFileLocksL (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectOpenL, nil, P) = 0 + then + Sys_DosProtectOpenL := TDosProtectOpenL (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFilePtrL, nil, P) + = 0 then + Sys_DosProtectSetFilePtrL := TDosProtectSetFilePtrL (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileSizeL, nil, P) + = 0 then + Sys_DosProtectSetFileSizeL := TDosProtectSetFileSizeL (P); + end; + + if DosCallsHandle = THandle (-1) then + Exit; + + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectOpen, nil, P) = 0 then + begin + Sys_DosProtectOpen := TDosProtectOpen (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectClose, nil, P) = 0 + then + Sys_DosProtectClose := TDosProtectClose (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectRead, nil, P) = 0 then + Sys_DosProtectRead := TDosProtectRead (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectWrite, nil, P) = 0 + then + Sys_DosProtectWrite := TDosProtectWrite (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFilePtr, nil, + P) = 0 then + Sys_DosProtectSetFilePtr := TDosProtectSetFilePtr (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileSize, nil, + P) = 0 then + Sys_DosProtectSetFileSize := TDosProtectSetFileSize (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectQueryFHState, nil, + P) = 0 then + Sys_DosProtectQueryFHState := TDosProtectQueryFHState (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFHState, nil, + P) = 0 then + Sys_DosProtectSetFHState := TDosProtectSetFHState (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectQueryFileInfo, nil, + P) = 0 then + Sys_DosProtectQueryFileInfo := TDosProtectQueryFileInfo (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileInfo, nil, + P) = 0 then + Sys_DosProtectSetFileInfo := TDosProtectSetFileInfo (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectEnumAttribute, nil, + P) = 0 then + Sys_DosProtectEnumAttribute := TDosProtectEnumAttribute (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileLocks, nil, + P) = 0 then + Sys_DosProtectSetFileLocks := TDosProtectSetFileLocks (P); + end; + + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32GetProcessorStatus, nil, + P) = 0 then + Sys_DosGetProcessorStatus := TDosGetProcessorStatus (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SetProcessorStatus, nil, + P) = 0 then + Sys_DosSetProcessorStatus := TDosSetProcessorStatus (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryThreadAffinity, nil, + P) = 0 then + Sys_DosQueryThreadAffinity := TDosQueryThreadAffinity (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SetThreadAffinity, nil, + P) = 0 then + Sys_DosSetThreadAffinity := TDosSetThreadAffinity (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryExtLibPath, nil, + P) = 0 then + Sys_DosQueryExtLibPath := TDosQueryExtLibPath (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SetExtLibPath, nil, + P) = 0 then + Sys_DosSetExtLibPath := TDosSetExtLibPath (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryModFromEIP, nil, + P) = 0 then + Sys_DosQueryModFromEIP := TDosQueryModFromEIP (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32DumpProcess, nil, P) = 0 then + Sys_DosDumpProcess := TDosDumpProcess (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SuppressPopups, nil, + P) = 0 then + Sys_DosSuppressPopups := TDosSuppressPopups (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32PerfSysCall, nil, P) = 0 then + Sys_DosPerfSysCall := TDosPerfSysCall (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryThreadContext, nil, + P) = 0 then + Sys_DosQueryThreadContext := TDosQueryThreadContext (P); + if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryABIOSSupport, nil, + P) = 0 then + Sys_DosQueryABIOSSupport := TDosQueryABIOSSupport (P); +end. + +(* +Todo: +DosCreateSpinLock = DOSCALLS.449 - might be simulated using semaphores on non-SMP +DosAcquireSpinLock = DOSCALLS.450 - might be simulated using semaphores on non-SMP +DosReleaseSpinLock = DOSCALLS.451 - might be simulated using semaphores on non-SMP +DosFreeSpinLock = DOSCALLS.452 - might be simulated using semaphores on non-SMP + +type + TSpinLock = cardinal; + HSpinLock = TSpinLock; + PSpinLock = ^TSpinLock; + PHSpinLock = PSpinLock; + +function DosCreateSpinLock (var SpinLock: TSpinLock): cardinal; cdecl; +procedure DosAcquireSpinLock (SpinLock: TSpinLock); cdecl; +procedure DosReleaseSpinLock (SpinLock: TSpinLock); cdecl; +function DosFreeSpinLock (SpinLock: TSpinLock): cardinal; cdecl; + + DosQueryModFromEIP - may be simulated by returning empty value if not available or possibly by using data returned by DosQuerySysState (if they are equal across different OS/2 versions?) + +___ function Dos16QueryModFromCS (...): ... +external 'DOSCALLS' index 359; + + + DosVerifyPidTid - may be implemented by analyzing information returned by DosQuerySysState + +x DosQueryExtLibPath - may be simulated by providing empty result if not available +x DosSetExtLibPath - may be simulated by returning ERROR_NOT_ENOUGH_MEMORY if not available + + Dos32AcquireSpinLock | DOSCALLS | SMP | SMP + Dos32FreeSpinLock | DOSCALLS | SMP | SMP +x Dos32GetProcessorStatus | DOSCALLS | SMP | SMP + Dos32ReleaseSpinLock | DOSCALLS | SMP | SMP +x Dos32SetProcessorStatus | DOSCALLS | SMP | SMP + Dos32TestPSD | DOSCALLS | SMP | SMP + +x Dos32QueryThreadAffinity | DOSCALLS | PROC | 2.45 +(x) Dos32QueryThreadContext | DOSCALLS | XCPT | 2.40 +x Dos32SetThreadAffinity | DOSCALLS | PROC | 2.45 + + Dos32AllocThreadLocalMemory | DOSCALLS | PROC | 2.30 + Dos32FreeThreadLocalMemory | DOSCALLS | PROC | 2.30 + Dos32ListIO | DOSCALLS | FILE | 2.45 +x Dos32ProtectClose | DOSCALLS | FILE | 2.10 +x Dos32ProtectEnumAttribute | DOSCALLS | FILE | 2.10 +x Dos32ProtectOpen | DOSCALLS | FILE | 2.10 +x Dos32ProtectQueryFHState | DOSCALLS | FILE | 2.10 +x Dos32ProtectQueryFileInfo | DOSCALLS | FILE | 2.10 +x Dos32ProtectRead | DOSCALLS | FILE | 2.10 +x Dos32ProtectSetFHState | DOSCALLS | FILE | 2.10 +x Dos32ProtectSetFileInfo | DOSCALLS | FILE | 2.10 +x Dos32ProtectSetFileLocks | DOSCALLS | FILE | 2.10 +x Dos32ProtectSetFilePtr | DOSCALLS | FILE | 2.10 +x Dos32ProtectSetFileSize | DOSCALLS | FILE | 2.10 +x Dos32ProtectWrite | DOSCALLS | FILE | 2.10 + Dos32QueryABIOSSupport | DOSCALLS | MOD | 2.10 +(x) Dos32QueryModFromEIP | DOSCALLS | MOD | 2.10 +(x) Dos32SuppressPopUps | DOSCALLS | MISC | 2.10 + Dos32VerifyPidTid | DOSCALLS | MISC | 2.30 +*) diff --git a/rtl/os2/doscalls.pas b/rtl/os2/doscalls.pas index 0088c20e9c..e5bb10cc01 100644 --- a/rtl/os2/doscalls.pas +++ b/rtl/os2/doscalls.pas @@ -1,9 +1,14 @@ { This file is part of the Free Pascal run time library. - Copyright (c) 1999-2002 by the Free Pascal development team. + Copyright (c) 1999-2014 by the Free Pascal development team. - Basic OS/2 constants, types and functions - implemented (mostly) in DOSCALL1.DLL. + Basic OS/2 constants, types and functions implemented (mostly) + in DOSCALL1.DLL. Only functions available in all 32-bit OS/2 + versions (i.e. starting with OS/2 2.0) are included here + to make sure that programs using this unit could still run on + these old versions. Certain functions supported in later versions + which could be emulated on older versions are provided in unit + DosCall2 (using dynamic loading of the respective entry points). See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -533,10 +538,6 @@ type TFileLock=record function DosSetFileLocks(Handle:THandle;var Unlock,Lock:TFileLock; Timeout,Flags: cardinal):cardinal; cdecl; -function DosProtectSetFileLocks (Handle: THandle; var Unlock, Lock: TFileLock; - Timeout, Flags: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - {Cancel a filelock area. Handle = File handle. @@ -702,7 +703,7 @@ const doFail = 0; OPEN_ACTION_FAIL_IF_NEW =doFail; { ---- ---- 0000 ---- } OPEN_ACTION_CREATE_IF_NEW =DoCreate; { ---- ---- 0001 ---- } -{Usefull constants for openmode parameter.} +{Useful constants for openmode parameter.} const doRead = 0; doWrite = 1; @@ -720,7 +721,7 @@ const doRead = 0; doDASD = 32768; - { DosOpen/DosSetFHandState flags } + { Dos(Protect)Open(L)/Dos(Protect)SetFHState flags } OPEN_ACCESS_READONLY =doRead; { ---- ---- ---- -000 } OPEN_ACCESS_WRITEONLY =doWrite; { ---- ---- ---- -001 } OPEN_ACCESS_READWRITE =doReadWrite; { ---- ---- ---- -010 } @@ -740,6 +741,7 @@ const doRead = 0; OPEN_FLAGS_DASD =doDASD; { 1--- ---- ---- ---- } OPEN_FLAGS_NONSPOOLED =$00040000; + OPEN_SHARE_DENYLEGACY =$10000000; OPEN_FLAGS_PROTECTED_HANDLE =$40000000; @@ -793,6 +795,10 @@ The bits in the filemode parameter have the following meanings: before write operation functions return. Bit 15: DASD flag. 0 = Open a file or device. 1 = Open a drive as file. + Bit 29: 32-bit access flag. 0 = Allow opening the file using DosOpen. + 1 = Avoid file to be open using DosOpen as well. + Bit 30: Protection flag. 0 = File handle is not protected. + 1 = File handle is protected. When the DASD flag is set, the whole drive is read as a single file. The file starts with 512 bytes of bootsector, then 512 bytes of the second sector etc. @@ -821,33 +827,10 @@ function DosCreate(const FileName:string;var Handle: THandle; function DosOpen(const FileName:string;var Handle: THandle; Attrib,OpenMode:cardinal):cardinal; -function DosProtectOpen (FileName: PChar; var Handle: longint; - var Action: longint; InitSize, Attrib, - OpenFlags, OpenMode: longint; ea: PEAOp2; - var FileHandleLockID: cardinal): cardinal; cdecl; - -function DosProtectOpen (FileName: PChar; var Handle: THandle; - var Action: cardinal; InitSize, Attrib, - OpenFlags, OpenMode: cardinal; ea: PEAOp2; - var FileHandleLockID: cardinal): cardinal; cdecl; - -function DosProtectOpen (const FileName: string; var Handle: longint; - var Action: longint; InitSize, Attrib, - OpenFlags, OpenMode: longint; ea: PEAOp2; - var FileHandleLockID: cardinal): cardinal; - -function DosProtectOpen (const FileName: string; var Handle: THandle; - var Action: cardinal; InitSize, Attrib, - OpenFlags, OpenMode: cardinal; ea: PEAOp2; - var FileHandleLockID: cardinal): cardinal; - {Close a file. Cannot fail if handle does exist.} function DosClose (Handle: THandle): cardinal; cdecl; -function DosProtectClose (Handle: THandle; - FileHandleLockID: cardinal): cardinal; cdecl; - {Read from a file or other type of handle. Handle = File handle. @@ -860,12 +843,6 @@ function DosRead (Handle: longint; var Buffer; Count: longint; function DosRead (Handle: THandle; var Buffer; Count: cardinal; var ActCount:cardinal):cardinal; cdecl; -function DosProtectRead (Handle: longint; var Buffer; Count: longint; - var ActCount: longint; FileHandleLockID: cardinal): cardinal; cdecl; - -function DosProtectRead (Handle: THandle; var Buffer; Count: cardinal; - var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl; - {Write to a file or other type of handle. Handle = File handle. @@ -878,14 +855,6 @@ function DosWrite (Handle: longint; const Buffer; Count: longint; function DosWrite (Handle: THandle; const Buffer; Count: cardinal; var ActCount:cardinal):cardinal; cdecl; -function DosProtectWrite (Handle: longint; const Buffer; Count: longint; - var ActCount: longint; - FileHandleLockID: cardinal): cardinal; cdecl; - -function DosProtectWrite (Handle: THandle; const Buffer; Count: cardinal; - var ActCount: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - const dsZeroBased=0; {Set filepointer from begin of file.} dsRelative=1; {Set filepointer relative to the current one.} dsEndBased=2; {Set filepointer from end of file.} @@ -899,38 +868,20 @@ function DosSetFilePtr (Handle: longint; Pos: longint; Method: cardinal; var PosActual: longint): cardinal; cdecl; function DosSetFilePtr (Handle: THandle; Pos: longint; Method: cardinal; var PosActual: cardinal): cardinal; cdecl; -function DosProtectSetFilePtr (Handle: longint; Pos, Method: longint; - var PosActual: longint; - FileHandleLockID: cardinal): cardinal; cdecl; - -function DosProtectSetFilePtr (Handle: THandle; Pos: longint; Method: cardinal; - var PosActual: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - {This variant seeks always from begin of file and does not return the actual position.} function DosSetFilePtr (Handle: THandle; Pos: longint): cardinal; -function DosProtectSetFilePtr (Handle: THandle; Pos: longint; - FileHandleLockID: cardinal): cardinal; + {This variant returns the current filepointer.} function DosGetFilePtr (Handle: longint; var PosActual: longint): cardinal; function DosGetFilePtr (Handle: THandle; var PosActual: cardinal): cardinal; -function DosProtectGetFilePtr (Handle: longint; - var PosActual: longint; FileHandleLockID: cardinal): cardinal; - -function DosProtectGetFilePtr (Handle: THandle; - var PosActual: cardinal; FileHandleLockID: cardinal): cardinal; - {Use DosQueryFileInfo or DosQueryPathInfo to get the size of a file.} {Change the size of a file.} function DosSetFileSize (Handle: THandle; Size: cardinal): cardinal; cdecl; -function DosProtectSetFileSize (Handle: THandle; Size: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - {Flush update the changes to a file to disk.} function DosResetBuffer (Handle: THandle): cardinal; cdecl; @@ -950,16 +901,10 @@ function DosQueryFHState (Handle: longint; var FileMode: longint): cardinal; function DosQueryFHState (Handle: THandle; var FileMode: cardinal): cardinal; cdecl; -function DosProtectQueryFHState (Handle: THandle; var FileMode: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - {Set information about a specific handle. See DosOpen for a description of FileMode.} function DosSetFHState (Handle: THandle; FileMode: cardinal): cardinal; cdecl; -function DosProtectSetFHState (Handle: THandle; FileMode: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - {Useful constants for the handle type.} const dhFile = 0; dhDevice = 1; @@ -1011,7 +956,7 @@ function DosMove(const OldFile,NewFile:string):cardinal; const dcExisting=1; {Overwrite existing files.} dcAppend=2; {Append to existing file.} - dcFailAs=4; {?? Info wanted!} + dcFailEAs=4; {Discard EAs if not supported by target FS} {Copy a file. OldFile = source file @@ -1282,19 +1227,11 @@ function DosFindClose (Handle: THandle): cardinal; cdecl; function DosQueryFileInfo (Handle: THandle; InfoLevel: cardinal; AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal; cdecl; -function DosProtectQueryFileInfo (Handle: THandle; InfoLevel: cardinal; - AFileStatus: PFileStatus; FileStatusLen: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - {Set info about a file. File must be opened with write permissions. See above fo the parameters.} function DosSetFileInfo (Handle: THandle; InfoLevel: cardinal; AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal; cdecl; -function DosProtectSetFileInfo (Handle: THandle; InfoLevel: cardinal; - AFileStatus: PFileStatus; FileStatusLen: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - {Return info about a file. In contradiction to the above functions, the file does not have to be open.} function DosQueryPathInfo(FileName:PChar;InfoLevel:cardinal; @@ -1337,32 +1274,16 @@ function DosEnumAttribute(RefType: cardinal; const AFile: THandle; Entry: cardinal; var Buf; BufSize: cardinal; var Count: cardinal; InfoLevel: cardinal): cardinal; cdecl; -function DosProtectEnumAttribute (RefType: cardinal; AFile: pointer; - Entry: cardinal; var Buf; BufSize: cardinal; - var Count: cardinal; InfoLevel: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; - function DosEnumAttribute (Handle: longint; Entry: longint; var Buf; BufSize: longint; var Count: longint; InfoLevel: longint): cardinal; function DosEnumAttribute (Handle: THandle; Entry: cardinal; var Buf; BufSize: cardinal; var Count: cardinal; InfoLevel: cardinal): cardinal; -function DosProtectEnumAttribute (Handle: THandle; Entry: cardinal; var Buf; - BufSize: cardinal; var Count: cardinal; - InfoLevel: cardinal; - FileHandleLockID: cardinal): cardinal; - function DosEnumAttribute (const FileName: string; Entry: cardinal; var Buf; BufSize: cardinal; var Count: cardinal; InfoLevel: cardinal): cardinal; -function DosProtectEnumAttribute (const FileName: string; Entry: cardinal; - var Buf; BufSize: cardinal; - var Count: cardinal; InfoLevel: cardinal; - FileHandleLockID: cardinal): cardinal; - - {Get an environment variable. Name = Name of environment variable to get. Value = Receives pointer to environment string.} @@ -2351,11 +2272,16 @@ function DosQueryCollate(Size:longint;var Country:TCountryCode; function DosQueryCollate (Size: cardinal; var Country: TCountryCode; Buf:PByteArray; var TableLen: cardinal): cardinal; cdecl; -{Get the current codepage. The PWordArray is filled with the current code - page followed by alternative codepages.} -function DosQueryCP(Size:longint;CodePages:PWordArray; +{Get the current codepage. The return buffer (CodePages) is filled with the + current code page followed by the list of prepared codepages as specified in + CONFIG.SYS - all of them returned as DWORDs, typically not more than 3 should + be necessary. Return value of 473 indicates that not all values fit into the + provided space.} +function DosQueryCP(Size:longint; PCodePages: PWordArray; var ActSize:longint):cardinal; cdecl; -function DosQueryCP (Size: cardinal; CodePages: PWordArray; +function DosQueryCP(Size: cardinal; PCodePages: PWordArray; + var ActSize:cardinal):cardinal; cdecl; +function DosQueryCP (Size: cardinal; var CodePages; var ActSize: cardinal): cardinal; cdecl; {Change the codepage, but only for the current process.} @@ -2720,7 +2646,7 @@ function DosGetMessage(Table:PInsertTable;TableSize:longint;Buf:PChar; var MsgSize:longint):cardinal; function DosGetMessage (Table: PInsertTable; TableSize: cardinal; Buf: PChar; BufSize, MsgNumber: cardinal; FileName: PChar; - var MsgSize: cardinal): cardinal; + var MsgSize: cardinal): cardinal; cdecl; {And a variant using strings and open arrays. function DosGetMessage(const Table:array of PString;var Buf:string; BufSize,MsgNumber:longint;const FileName:PChar):cardinal;} @@ -3893,6 +3819,96 @@ function DosQuerySysState (EntityList, EntityLevel, PID, TID: cardinal; PDataBuf: pointer; cbBuf: cardinal): cardinal; cdecl; +{ + Creates a private Read/Write alias or an LDT code segment alias to part + of an existing memory object. The alias object is accessible only to the + process that created it. The original object must be accessible to the caller + of DosAliasMem. + + An alias is removed by calling DosFreeMem with the alias address. + + Although it is possible to create a Read/Write alias to a code segment + to allow code modification, this is not recommended. On Pentium processors, + and later, pipe-lining techniques used by the processor might allow + the processor not to be aware of the modified code, if appropriate + pipe-line serialization is not performed by the programmer. For further + information see the processor documentation. + + Possible return values: + 0 No_Error + 8 Error_Not_Enough_Memory + 87 Error_Invalid_Parameter + 95 Error_Interrupt + 32798 Error_Crosses_Object_Boundary + +pMem = Pointer to the memory to be aliased. It must be on a page boundary + (i.e. aligned to 4 kB), but may specify an address within a memory + object. +Size = Specifies size in bytes for the memory to alias. The entire range + must lie within a single memory object and must be committed + if OBJ_SELMAPALL is specified. +Alias = Pointer where the address of the aliased memory is returned. + The corresponding LDT selector is not explicitly returned but may be + calculated by using the Compatibility Mapping Algorithm + ((Alias shr 13) or 7). +Flags = Combination of the following values: + obj_SelMapAll = $800 (Create a Read/Write 32 bit alias + to the address specified. The entire range + must be committed, start on page boundary + and be within the extent of a single memory + object. An LDT selector is created to map + the entire range specified. If obj_SelMapAll + is not specified, then size is rounded up + to a 4K multiple and the alias created + inherits the permissions from the pages + of the original object.) + obj_Tile = $40 (Obj_Tile may be specified, but currently + this is enforced whether or not specified. + This forces LDT selectors to be based + on 64K boundaries.) + sel_Code = 1 (Marks the LDT alias selector(s) + Read-Executable code selectors.) + sel_Use32 = 2 (Used with obj_SelMapAll, otherwise ignored. + Marks the first alias LDT selector + as a 32 bit selector by setting the BIG/C32 + bit.) +} +function DosAliasMem (pMem: pointer; Size: cardinal; var Alias: pointer; + Flags: cardinal): cardinal; cdecl; + +const + PAG_INVALID = 0; (* Page is invalid. *) + PAG_NPOUT = 0; (* Page is not present, not in core. *) + PAG_PRESENT = 1; (* Page is present. *) + PAG_NPIN = 2; (* Page is not present, in core. *) + PAG_PRESMASK = 3; (* Present state mask. *) + PAG_RESIDENT = 16; (* Page is resident. *) + PAG_SWAPPABLE = 32; (* Page is swappable. *) + PAG_DISCARDABLE = 48; (* Page is discardable. *) + PAG_TYPEMASK = 48; (* Typemask *) + +{ +DosQueryMemState gets the status of a range of pages in memory. Its input +parameters are an address and size. The address is rounded down to page +boundary and size is rounded up to a whole number of pages. The status +of the pages in the range is returned in the state parameter, and the size +of the range queried is returned in the size parameter. If the pages +in the range have conflicting states, then the state of the first page +is returned. + +Parameters: +PMem - Pointer to memory to be queried +Size - Size of memory to be queried +State - Flags (PAG_*) indicating state of the memory (or the first memory page + if the states for the following pages differ): + +Possible return codes: + 0 - NO_ERROR + 87 - ERROR_INVALID_PARAMETER +487 - ERROR_INVALID_ADDRESS +} +function DosQueryMemState (PMem: pointer; var Size: cardinal; + var State: cardinal): cardinal; cdecl; {***************************************************************************} implementation @@ -4008,11 +4024,6 @@ function DosSetFileLocks (Handle: THandle; var Unlock, Lock: TFileLock; Timeout, Flags: cardinal): cardinal; cdecl; external 'DOSCALLS' index 428; -function DosProtectSetFileLocks (Handle: THandle; var Unlock, Lock: TFileLock; - Timeout, Flags: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 639; - function DosCancelLockRequest (Handle: THandle; var Lock: TFileLock): cardinal; cdecl; external 'DOSCALLS' index 429; @@ -4089,49 +4100,9 @@ begin DosOpen:=DosOpen(@T,Handle,Action,0,Attrib,1,OpenMode,nil); end; -function DosProtectOpen (FileName: PChar; var Handle: longint; - var Action: longint; InitSize, Attrib, - OpenFlags, OpenMode: longint; ea: PEAOp2; - var FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 637; - -function DosProtectOpen (FileName: PChar; var Handle: THandle; - var Action: cardinal; InitSize, Attrib, - OpenFlags, OpenMode: cardinal; ea: PEAOp2; - var FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 637; - -function DosProtectOpen (const FileName: string; var Handle: longint; - var Action: longint; InitSize, Attrib, - OpenFlags, OpenMode: longint; ea: PEAOp2; - var FileHandleLockID: cardinal): cardinal; - -var T:array[0..255] of char; - -begin - StrPCopy(@T,FileName); - DosProtectOpen:=DosProtectOpen(@T,Handle,Action,InitSize,Attrib,OpenFlags,OpenMode,EA,FileHandleLockID); -end; - -function DosProtectOpen (const FileName: string; var Handle: THandle; - var Action: cardinal; InitSize, Attrib, - OpenFlags, OpenMode: cardinal; ea: PEAOp2; - var FileHandleLockID: cardinal): cardinal; - -var T:array[0..255] of char; - -begin - StrPCopy(@T,FileName); - DosProtectOpen:=DosProtectOpen(@T,Handle,Action,InitSize,Attrib,OpenFlags,OpenMode,EA,FileHandleLockID); -end; - function DosClose (Handle: THandle): cardinal; cdecl; external 'DOSCALLS' index 257; -function DosProtectClose (Handle: THandle; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 638; - function DosRead(Handle:longint;var Buffer;Count:longint; var ActCount:longint):cardinal; cdecl; external 'DOSCALLS' index 281; @@ -4140,14 +4111,6 @@ function DosRead (Handle: THandle; var Buffer; Count: cardinal; var ActCount: cardinal): cardinal; cdecl; external 'DOSCALLS' index 281; -function DosProtectRead (Handle: longint; var Buffer; Count: longint; - var ActCount: longint; FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 641; - -function DosProtectRead (Handle: THandle; var Buffer; Count: cardinal; - var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 641; - function DosWrite(Handle:longint;const Buffer;Count:longint; var ActCount:longint):cardinal; cdecl; external 'DOSCALLS' index 282; @@ -4156,16 +4119,6 @@ function DosWrite (Handle: THandle; const Buffer; Count: cardinal; var ActCount: cardinal): cardinal; cdecl; external 'DOSCALLS' index 282; -function DosProtectWrite (Handle: longint; const Buffer; Count: longint; - var ActCount: longint; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 642; - -function DosProtectWrite (Handle: THandle; const Buffer; Count: cardinal; - var ActCount: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 642; - function DosSetFilePtr(Handle:longint;Pos:longint;Method:cardinal; var PosActual:longint):cardinal; cdecl; external 'DOSCALLS' index 256; @@ -4182,26 +4135,6 @@ begin DosSetFilePtr:=DosSetFilePtr(Handle,Pos,0,PosActual); end; -function DosProtectSetFilePtr (Handle: longint; Pos, Method: longint; - var PosActual: longint; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 621; - -function DosProtectSetFilePtr (Handle: THandle; Pos: longint; Method: cardinal; - var PosActual: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 621; - -function DosProtectSetFilePtr (Handle: THandle; Pos: longint; - FileHandleLockID: cardinal): cardinal; - -var PosActual:cardinal; - -begin - DosProtectSetFilePtr:=DosProtectSetFilePtr(Handle,Pos,0,PosActual, - FileHandleLockID); -end; - function DosGetFilePtr(Handle:longint;var PosActual:longint):cardinal; begin @@ -4214,29 +4147,9 @@ begin DosGetFilePtr:=DosSetFilePtr(Handle,0,1,PosActual); end; -function DosProtectGetFilePtr (Handle: longint; - var PosActual: longint; FileHandleLockID: cardinal): cardinal; - -begin - DosProtectGetFilePtr := DosProtectSetFilePtr (Handle, 0, 1, PosActual, - FileHandleLockID); -end; - -function DosProtectGetFilePtr (Handle: THandle; - var PosActual: cardinal; FileHandleLockID: cardinal): cardinal; - -begin - DosProtectGetFilePtr := DosProtectSetFilePtr (Handle, 0, 1, PosActual, - FileHandleLockID); -end; - function DosSetFileSize (Handle: THandle; Size: cardinal): cardinal; cdecl; external 'DOSCALLS' index 272; -function DosProtectSetFileSize (Handle: THandle; Size: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 640; - function DosResetBuffer (Handle: THandle): cardinal; cdecl; external 'DOSCALLS' index 254; @@ -4251,17 +4164,9 @@ function DosQueryFHState (Handle: THandle; var FileMode: cardinal): cardinal; cdecl; external 'DOSCALLS' index 276; -function DosProtectQueryFHState (Handle: THandle; var FileMode: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 645; - function DosSetFHState (Handle: THandle; FileMode: cardinal): cardinal; cdecl; external 'DOSCALLS' index 221; -function DosProtectSetFHState (Handle: THandle; FileMode: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 644; - function DosQueryHType(Handle:longint;var HandType:longint; var Attr:longint):cardinal; cdecl; external 'DOSCALLS' index 224; @@ -4459,23 +4364,11 @@ function DosQueryFileInfo (Handle: THandle; InfoLevel: cardinal; FileStatusLen: cardinal): cardinal; cdecl; external 'DOSCALLS' index 279; -function DosProtectQueryFileInfo (Handle: THandle; InfoLevel: cardinal; - AFileStatus: PFileStatus; - FileStatusLen: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 646; - function DosSetFileInfo (Handle: THandle; InfoLevel: cardinal; AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal; cdecl; external 'DOSCALLS' index 218; -function DosProtectSetFileInfo (Handle: THandle; InfoLevel: cardinal; - AFileStatus: PFileStatus; - FileStatusLen: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 643; - function DosQueryPathInfo (FileName: PChar; InfoLevel: cardinal; AFileStatus: PFileStatus; FileStatusLen: cardinal): cardinal; cdecl; external 'DOSCALLS' index 223; @@ -4519,12 +4412,6 @@ function DosEnumAttribute (RefType: cardinal; const AFile: THandle; cdecl; external 'DOSCALLS' index 372; -function DosProtectEnumAttribute (RefType: cardinal; AFile: pointer; - Entry: cardinal; var Buf; BufSize: cardinal; - var Count: cardinal; InfoLevel: cardinal; - FileHandleLockID: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 636; - function DosEnumAttribute (Handle: longint; Entry: longint; var Buf; BufSize: longint; var Count: longint; InfoLevel: longint): cardinal; @@ -4543,16 +4430,6 @@ begin InfoLevel); end; -function DosProtectEnumAttribute (Handle: THandle; Entry: cardinal; var Buf; - BufSize: cardinal; var Count: cardinal; - InfoLevel: cardinal; - FileHandleLockID: cardinal): cardinal; - -begin - DosProtectEnumAttribute := DosProtectEnumAttribute (0, @Handle, Entry, Buf, - BufSize, Count, InfoLevel, FileHandleLockID); -end; - function DosEnumAttribute (const FileName: string; Entry: cardinal;var Buf;BufSize: cardinal; var Count: cardinal; InfoLevel: cardinal): cardinal; @@ -4565,19 +4442,6 @@ begin InfoLevel); end; -function DosProtectEnumAttribute (const FileName: string; Entry: cardinal; - var Buf; BufSize: cardinal; - var Count: cardinal; InfoLevel: cardinal; - FileHandleLockID: cardinal): cardinal; - -var T: array [0..255] of char; - -begin - StrPCopy (@T, FileName); - DosProtectEnumAttribute := DosProtectEnumAttribute (1, @T, Entry, Buf, - BufSize, Count, InfoLevel, FileHandleLockID); -end; - function DosScanEnv(Name:PChar;var Value:PChar):cardinal; cdecl; external 'DOSCALLS' index 227; @@ -5198,11 +5062,15 @@ function DosQueryCollate (Size: cardinal; var Country: TCountryCode; Buf: PByteArray; var TableLen: cardinal): cardinal; cdecl; external 'NLS' index 8; -function DosQueryCP(Size:longint;CodePages:PWordArray; +function DosQueryCP(Size:longint; PCodePages:PWordArray; var ActSize:longint):cardinal; cdecl; external 'DOSCALLS' index 291; -function DosQueryCP (Size: cardinal; CodePages: PWordArray; +function DosQueryCP (Size: cardinal; PCodePages: PWordArray; + var ActSize: cardinal): cardinal; cdecl; +external 'DOSCALLS' index 291; + +function DosQueryCP (Size: cardinal; var CodePages; var ActSize: cardinal): cardinal; cdecl; external 'DOSCALLS' index 291; @@ -5375,20 +5243,10 @@ function DosTrueGetMessage (MsgSeg: pointer; Table: PInsertTable; var MsgSize: cardinal): cardinal; cdecl; external 'MSG' index 6; -function DosTrueGetMessage (MsgSeg: pointer; Table: PInsertTable; - TableSize: longint; Buf: PChar; - BufSize, MsgNumber: longint; FileName: PChar; - var MsgSize: longint): cardinal; cdecl; -external 'MSG' index 6; - function DosIQueryMessageCP (var Buf; BufSize: cardinal; FileName: PChar; var InfoSize: cardinal; MesSeg: pointer): cardinal; cdecl; external 'MSG' index 8; -function DosIQueryMessageCP (var Buf; BufSize: longint; FileName: PChar; - var InfoSize: longint; MesSeg: pointer): cardinal; cdecl; -external 'MSG' index 8; - procedure MagicHeaderEnd; assembler; forward; {$ASMMODE INTEL} @@ -5404,18 +5262,21 @@ end; function DosGetMessage (Table: PInsertTable; TableSize: cardinal; Buf: PChar; BufSize, MsgNumber: cardinal; FileName: PChar; - var MsgSize: cardinal): cardinal; -begin - DosGetMessage := DosTrueGetMessage(@MagicHeaderStart,Table,TableSize, - Buf,BufSize,MsgNumber,FileName,MsgSize); + var MsgSize: cardinal): cardinal; cdecl; assembler; + nostackframe; +asm + pop eax + push offset MagicHeaderStart + push eax + jmp DosTrueGetMessage end; function DosGetMessage (Table: PInsertTable; TableSize:longint;Buf:PChar; - BufSize,MsgNumber:longint;FileName:PChar; - var MsgSize:longint):cardinal; + BufSize,MsgNumber:longint;FileName:PChar; + var MsgSize:longint):cardinal; begin - DosGetMessage := DosTrueGetMessage(@MagicHeaderStart,Table,TableSize, - Buf,BufSize,MsgNumber,FileName,MsgSize); + DosGetMessage := DosGetMessage (Table, cardinal (TableSize), Buf, + cardinal (BufSize), cardinal (MsgNumber), FileName, cardinal (MsgSize)); end; function DosQueryMessageCP (var Buf; BufSize: cardinal; FileName: PChar; @@ -5428,8 +5289,8 @@ end; function DosQueryMessageCP(var Buf;BufSize:longint;FileName:PChar; var InfoSize:longint):cardinal; begin - DosQueryMessageCP := DosIQueryMessageCP(Buf, BufSize, FileName, InfoSize, - @MagicHeaderStart); + DosQueryMessageCP := DosIQueryMessageCP(Buf, cardinal (BufSize), FileName, + cardinal (InfoSize), @MagicHeaderStart); end; procedure MagicHeaderEnd; assembler; @@ -5765,31 +5626,49 @@ function LogAddEntries (Handle: cardinal; Service: cardinal; function LogAddEntries (Handle: cardinal; Service: cardinal; var LogEntries: TLogEntryRec): cardinal; cdecl; external 'DOSCALLS' index 432; +function DosQueryMemState (PMem: pointer; var Size: cardinal; + var State: cardinal): cardinal; cdecl; +external 'DOSCALLS' index 307; + (* Todo: -function DosRawReadNPipe ...; cdecl; -external 'DOSCALLS' index 246; +function DosRawReadNPipe (HPIPE hPipe, + PVOID pBuffer, + ULONG cbRead, + PULONG pcbActual); cdecl; +external 'DOSCALLS' index 246; - no documentation??? -function DosRawWriteNPipe ...; cdecl; -external 'DOSCALLS' index 247; +function DosRawWriteNPipe (HPIPE hPipe, + PVOID pBuffer, + ULONG cbWrite, + PULONG pcbActual); cdecl; +external 'DOSCALLS' index 247; - no documentation??? function DosSetCP ...; cdecl; -external 'DOSCALLS' index 288; +external 'DOSCALLS' index 288; - no documentation??? function DosDynamicTrace ...; cdecl; -external 'DOSCALLS' index 316; +external 'DOSCALLS' index 316; - no documentation??? -function DosRegisterPerfCtrs ...; cdecl; -external 'DOSCALLS' index 367; +function DosRegisterPerfCtrs (PBYTE pbDataBlk, + PBYTE pbTextBlk, + ULONG flFlags); cdecl; +external 'DOSCALLS' index 367; - no documentation??? -function DosQueryDOSProperty ...; cdecl; -external 'DOSCALLS' index 373; +function DosQueryDOSProperty (SGID sgid, + PSZ pszName, + ULONG cb, + PSZ pch); cdecl; +external 'DOSCALLS' index 373; - no documentation??? -function DosSetDOSProperty ...; cdecl; -external 'DOSCALLS' index 374; +function DosSetDOSProperty (SGID sgid, + PSZ pszName, + ULONG cb, + PSZ pch); cdecl; +external 'DOSCALLS' index 374; - no documentation??? function DosProfile ...; cdecl; -external 'DOSCALLS' index 377; +external 'DOSCALLS' index 377; - no documentation??? *) function DosReplaceModule (OldModule, NewModule, BackupModule: PChar): @@ -5797,137 +5676,62 @@ function DosReplaceModule (OldModule, NewModule, BackupModule: PChar): external 'DOSCALLS' index 417; (* -function DosTIB ...; cdecl; +??? function DosTIB ...; cdecl; external 'DOSCALLS' index 419; -function DosOpenChangeNotify ...; cdecl; +??? function DosOpenChangeNotify ...; cdecl; external 'DOSCALLS' index 440; -function DosResetChangeNotify ...; cdecl; +??? function DosResetChangeNotify ...; cdecl; external 'DOSCALLS' index 441; -function DosCloseChangeNotify ...; cdecl; +??? function DosCloseChangeNotify ...; cdecl; external 'DOSCALLS' index 442; -function DosInitializePorthole ...; cdecl; +??? function DosInitializePorthole ...; cdecl; external 'DOSCALLS' index 580; -function DosQueryHeaderInfo ...; cdecl; +??? function DosQueryHeaderInfo ...; cdecl; external 'DOSCALLS' index 582; -WSeB/eCS APIs: - Creates a private Read/Write alias or an LDT code segment alias to part - of an existing memory object. The alias object is accessible only to the - process that created it. The original object must be accessible to the caller - of DosAliasMem. - - An alias is removed by calling DosFreeMem with the alias address. - - Although it is possible to create a Read/Write alias to a code segment - to allow code modification, this is not recommended. On Pentium processors, - and later, pipe-lining techniques used by the processor might allow - the processor not to be aware of the modified code, if appropriate - pipe-line serialization is not performed by the programmer. For further - information see the processor documentation. - - Possible return values: - 0 No_Error - 8 Error_Not_Enough_Memory - 87 Error_Invalid_Parameter - 95 Error_Interrupt - 32798 Error_Crosses_Object_Boundary - -pMem = Pointer to the memory to be aliased. It must be on a page boundary - (i.e. aligned to 4 kB), but may specify an address within a memory - object. -Size = Specifies size in bytes for the memory to alias. The entire range - must lie within a single memory object and must be committed - if OBJ_SELMAPALL is specified. -Alias = Pointer where the address of the aliased memory is returned. - The corresponding LDT selector is not explicitly returned but may be - calculated by using the Compatibility Mapping Algorithm - ((Alias shr 13) or 7). -Flags = Combination of the following values: - obj_SelMapAll = $800 (Create a Read/Write 32 bit alias - to the address specified. The entire range - must be committed, start on page boundary - and be within the extent of a single memory - object. An LDT selector is created to map - the entire range specified. If obj_SelMapAll - is not specified, then size is rounded up - to a 4K multiple and the alias created - inherits the permissions from the pages - of the original object.) - obj_Tile = $40 (Obj_Tile may be specified, but currently - this is enforced whether or not specified. - This forces LDT selectors to be based - on 64K boundaries.) - sel_Code = 1 (Marks the LDT alias selector(s) - Read-Executable code selectors.) - sel_Use32 = 2 (Used with obj_SelMapAll, otherwise ignored. - Marks the first alias LDT selector - as a 32 bit selector by setting the BIG/C32 - bit.) -functionDosAliasMem (pMem: pointer; Size: cardinal; var Alias: pointer; Flags: cardinal): cardinal; cdecl; -external 'DOSCALLS' index 298; - - DosCancelLockRequestL cancels an outstanding DosSetFileLocksL request. - If two threads in a process are waiting on a lock file range, and another - thread issues DosCancelLockRequestL for that lock file range, then both - waiting threads are released. - Not all file-system drivers (FSDs) can cancel an outstanding lock request. - Local Area Network (LAN) servers cannot cancel an outstanding lock request - if they use a version of the operating system prior to OS/2 Version 2.00. +DosCreateThread2 2.45 +DosDumpProcess 2.10 +DosForceSystemDump - ??? -Possible return values: - 0 No_Error - 6 Error_Invalid_Handle - 87 Error_Invalid_Parameter - 173 Error_Cancel_Violation - -hFile = File handle used in the DosSetFileLocksL function - that is to be cancelled. -pflLockL = Address of the structure describing the lock request to cancel. - -function DosCancelLockRequestL (hFile: THandle; pflLock: PFileLockL): cardinal; cdecl; -external 'DOSCALLS' index ???; +??? function DosQueryPageUsage (...): cardinal; cdecl; +external 'DOSCALLS' index 358; -function DosCancelLockRequestL (hFile: THandle; const Lock: TFileLockL): cardinal; cdecl; -external 'DOSCALLS' index ???; + DosPerfSystemCall 2.40 -DosCreateThread2 -DosDumpProcess -DosForceSystemDump functionDosGetProcessorStatus (...): cardinal; cdecl; external 'DOSCALLS' index 447; -function DosQueryPageUsage (...): cardinal; cdecl; -external 'DOSCALLS' index 358; - + DosSetProcessorStatus = DOSCALLS.448 -DosSetProcessorStatus = DOSCALLS.448 -DosCreateSpinLock = DOSCALLS.449 -DosAcquireSpinLock = DOSCALLS.450 -DosReleaseSpinLock = DOSCALLS.451 -DosFreeSpinLock = DOSCALLS.452 -DosListIO -DosListIOL -DosOpenL = DOSCALLS.981 -DosPerfSystemCall -DosProtectOpenL -DosProtectSetFileLocksL -DosProtectSetFilePrtL -DosProtectSetFileSizeL -DosQueryABIOSSuport - -functionDosQueryMemState (...): cardinal; cdecl; -external 'DOSCALLS' index 307; +type + TSpinLock = cardinal; + HSpinLock = TSpinLock; + PSpinLock = ^TSpinLock; + PHSpinLock = PSpinLock; + +function DosCreateSpinLock (var SpinLock: TSpinLock): cardinal; cdecl; +procedure DosAcquireSpinLock (SpinLock: TSpinLock); cdecl; +procedure DosReleaseSpinLock (SpinLock: TSpinLock); cdecl; +function DosFreeSpinLock (SpinLock: TSpinLock): cardinal; cdecl; + + DosCreateSpinLock = DOSCALLS.449 + DosAcquireSpinLock = DOSCALLS.450 + DosReleaseSpinLock = DOSCALLS.451 + DosFreeSpinLock = DOSCALLS.452 + DosListIO 2.45 + DosListIOL 2.45 + DosQueryABIOSSuport 2.10 ___ functionDos16QueryModFromCS (...): ... external 'DOSCALLS' index 359; -DosQueryModFromEIP + DosQueryModFromEIP 2.10 *) function DosQuerySysState (EntityList, EntityLevel, PID, TID: cardinal; var Buffer; BufLen: cardinal): cardinal; cdecl; @@ -5937,14 +5741,15 @@ function DosQuerySysState (EntityList, EntityLevel, PID, TID: cardinal; PDataBuf: pointer; cbBuf: cardinal): cardinal; cdecl; external 'DOSCALLS' index 368; +function DosAliasMem (pMem: pointer; Size: cardinal; var Alias: pointer; + Flags: cardinal): cardinal; cdecl; +external 'DOSCALLS' index 298; + (* -DosQueryThreadAffinity -DosSetFileLocksL -DosSetFilePtrL = DOSCALLS.988 -DosSetFileSizeL = DOSCALLS.989 -DosSetThreadAffinity -Dos16SysTrace -DosVerifyPidTid + DosQueryThreadAffinity + DosSetThreadAffinity + Dos16SysTrace + DosVerifyPidTid 2.30 *) diff --git a/rtl/os2/dynlibs.inc b/rtl/os2/dynlibs.inc index ac37305fe1..bd791ea857 100644 --- a/rtl/os2/dynlibs.inc +++ b/rtl/os2/dynlibs.inc @@ -54,7 +54,10 @@ begin if DynLibErrNo = 0 then Result := Handle else - Result := NilHandle; + begin + Result := NilHandle; + OSErrorWatch (DynLibErrNo); + end; end; function GetProcedureAddress (Lib: TLibHandle; const ProcName: AnsiString): pointer; @@ -66,7 +69,10 @@ begin if DynLibErrNo = 0 then Result := P else - Result := nil; + begin + Result := nil; + OSErrorWatch (DynLibErrNo); + end; end; function GetProcedureAddress (Lib: TLibHandle; Ordinal: TOrdinalEntry): pointer; @@ -78,7 +84,10 @@ begin if DynLibErrNo = 0 then Result := P else - Result := nil; + begin + Result := nil; + OSErrorWatch (DynLibErrNo); + end; end; function UnloadLibrary (Lib: TLibHandle): boolean; @@ -86,6 +95,8 @@ begin DynLibErrPath [0] := #0; DynLibErrNo := DosFreeModule (Lib); Result := DynLibErrNo = 0; + if DynLibErrNo <> 0 then + OSErrorWatch (DynLibErrNo); end; function GetDynLibsError: longint; @@ -106,18 +117,23 @@ begin GetDynLibsErrorStr := '' else begin + Result := ''; VarArr [1] := @DynLibErrPath [0]; RC := DosGetMessage (@VarArr, 1, @OutBuf [0], SizeOf (OutBuf), DynLibErrNo, @SysMsgFile [0], RetMsgSize); if RC = 0 then - Result := StrPas (@OutBuf [0]) + begin + SetLength (Result, RetMsgSize); + Move (OutBuf [0], Result [1], RetMsgSize); + end else begin Str (DynLibErrNo, Result); Result := 'Error ' + Result; + if DynLibErrPath [0] <> #0 then + Result := StrPas (@DynLibErrPath [0]) + ' - ' + Result; + OSErrorWatch (RC); end; - if DynLibErrPath [0] <> #0 then - Result := StrPas (@DynLibErrPath [0]) + ' - ' + Result; end; end; diff --git a/rtl/os2/os2def.pas b/rtl/os2/os2def.pas index 5b0bbfde78..d53295fd2f 100644 --- a/rtl/os2/os2def.pas +++ b/rtl/os2/os2def.pas @@ -293,21 +293,25 @@ const { Constants from bseord.h header file (ordinal numbers of API functions) } const +(* ANSICALL.DLL *) Ord_AnsiINJECT = 1; Ord_AnsiKEYDEF = 2; Ord_AnsiINTERP = 3; +(* PMBIDI.DLL *) Ord_NlsCONVERTBIDINUMERICS = 1; Ord_NlsCONVERTBIDISTRING = 2; + Ord_NlsINTSETBIDIATT = 3; + Ord_NlsINTQUERYBIDIATT = 4; Ord_NlsSETBIDIATT = 5; Ord_NlsQUERYBIDIATT = 6; Ord_NlsINVERSESTRING = 7; Ord_NlsSETBIDIPRINT = 8; Ord_NlsEDITSHAPE = 9; Ord_NlsSHAPEBIDISTRING = 10; - Ord_NlsINTSETBIDIATT = 3; - Ord_NlsINTQUERYBIDIATT = 4; Ord_NLPOPUP = 11; +(* BKSCALLS.DLL *) Ord_BksMAIN = 1; +(* PMDRAG.DLL *) Ord_DrgACCESSDRAGINFO = 1; Ord_DrgADDSTRHANDLE = 2; Ord_DrgALLOCDRAGINFO = 3; @@ -339,8 +343,6 @@ const Ord_DrgVERIFYTRUETYPE = 29; Ord_DrgVERIFYTYPE = 30; Ord_DrgVERIFYTYPESET = 31; - Ord_DrgDRAGFILES = 63; - Ord_DrgACCEPTDROPPEDFILES = 64; Ord_Drg32ACCESSDRAGINFO = 32; Ord_Drg32ADDSTRHANDLE = 33; Ord_Drg32ALLOCDRAGINFO = 34; @@ -372,17 +374,11 @@ const Ord_Drg32VERIFYTRUETYPE = 60; Ord_Drg32VERIFYTYPE = 61; Ord_Drg32VERIFYTYPESET = 62; + Ord_DrgDRAGFILES = 63; + Ord_DrgACCEPTDROPPEDFILES = 64; Ord_Drg32DRAGFILES = 65; Ord_Drg32ACCEPTDROPPEDFILES = 66; - Ord_FKAINIT = 64; - Ord_QUERYFKADISPLAYDETAILS = 65; - Ord_WinFKAWNDPROC = 66; - Ord_WinLOADFKA = 67; - Ord_WinCREATEFKA = 68; - Ord_WinSETFKAFORM = 69; - Ord_WinQUERYFKAFORM = 70; - Ord_WinGOTOFKA = 71; - Ord_WinGOFROMFKA = 72; +(* HELPMGR.DLL *) Ord_WinCREATEHELPINSTANCE = 1; Ord_WinDESTROYHELPINSTANCE = 2; Ord_WinQUERYHELPINSTANCE = 3; @@ -395,6 +391,15 @@ const Ord_Win32ASSOCIATEHELPINSTANCE = 54; Ord_Win32LOADHELPTABLE = 55; Ord_Win32CREATEHELPTABLE = 56; + Ord_FKAINIT = 64; + Ord_QUERYFKADISPLAYDETAILS = 65; + Ord_WinFKAWNDPROC = 66; + Ord_WinLOADFKA = 67; + Ord_WinCREATEFKA = 68; + Ord_WinSETFKAFORM = 69; + Ord_WinQUERYFKAFORM = 70; + Ord_WinGOTOFKA = 71; + Ord_WinGOFROMFKA = 72; Ord_DDFINITIALIZE = 74; Ord_DDFPARA = 75; Ord_DDFSETFORMAT = 76; @@ -410,6 +415,7 @@ const Ord_DDFMETAFILE = 86; Ord_DDFSETFONT = 87; Ord_DDFBITMAP = 88; +(* KBDCALLS.DLL *) Ord_KbdSETCUSTXT = 1; Ord_KbdGETCP = 3; Ord_KbdCHARIN = 4; @@ -430,11 +436,13 @@ const Ord_KbdOPEN = 23; Ord_KbdGETHWID = 24; Ord_KbdSETHWID = 25; - Ord_DosMONOPEN = 4; - Ord_DosMONCLOSE = 3; - Ord_DosMONREAD = 2; +(* MONCALLS.DLL *) Ord_DosMONWRITE = 1; + Ord_DosMONREAD = 2; + Ord_DosMONCLOSE = 3; + Ord_DosMONOPEN = 4; Ord_DosMONREG = 5; +(* MOUCALLS.DLL *) Ord_MouGETPTRSHAPE = 1; Ord_MouSETPTRSHAPE = 2; Ord_MouGETNUMMICKEYS = 3; @@ -462,6 +470,7 @@ const Ord_MouINITREAL = 27; Ord_MouGETTHRESHOLD = 29; Ord_MouSETTHRESHOLD = 30; +(* MSG.DLL *) Ord_DosPUTMESSAGE = 1; Ord_DosTRUEGETMESSAGE = 2; Ord_DosINSMESSAGE = 3; @@ -470,6 +479,7 @@ const Ord_Dos32TRUEGETMESSAGE = 6; Ord_DosIQUERYMESSAGECP = 7; Ord_Dos32IQUERYMESSAGECP = 8; +(* NLS.DLL *) Ord_DosCASEMAP = 1; Ord_DosGETCOLLATE = 2; Ord_DosGETCTRYINFO = 3; @@ -478,6 +488,7 @@ const Ord_Dos32QUERYDBCSENV = 6; Ord_Dos32MAPCASE = 7; Ord_Dos32QUERYCOLLATE = 8; +(* NAMPIPES.DLL *) Ord_DosMAKENMPIPE = 1; Ord_DosQNMPIPEINFO = 2; Ord_DosCONNECTNMPIPE = 3; @@ -492,109 +503,149 @@ const Ord_DosRAWWRITENMPIPE = 12; Ord_DosSETNMPIPESEM = 13; Ord_DosQNMPIPESEMSTATE = 14; - Ord_DosCWAIT = 2; - Ord_DosENTERCRITSEC = 3; - Ord_DosEXIT = 5; - Ord_DosEXITCRITSEC = 6; - Ord_DosEXITLIST = 7; - Ord_DosGETINFOSEG = 8; - Ord_DosGETPRTY = 9; - Ord_DosKILLPROCESS = 10; - Ord_DosSETPRTY = 11; - Ord_DosPTRACE = 12; - Ord_DosHOLDSIGNAL = 13; - Ord_DosSETSIGHANDLER = 14; - Ord_DosFLAGPROCESS = 15; - Ord_DosMAKEPIPE = 16; - Ord_DosSEMSETWAIT = 20; - Ord_DosMUXSEMWAIT = 22; - Ord_DosCLOSESEM = 23; - Ord_DosCREATESEM = 24; - Ord_DosOPENSEM = 25; - Ord_DosRESUMETHREAD = 26; - Ord_DosSUSPENDTHREAD = 27; - Ord_DosSETDATETIME = 28; +(* DOSCALLS.DLL *) +{ +xxx Ord_DosICreateThread = 1; +} + Ord_DosCWAIT = 2; (* callgate *) + Ord_DosENTERCRITSEC = 3; (* callgate *) + Ord_DosIExecPgm = 4; (* callgate *) + Ord_DosEXIT = 5; (* callgate *) + Ord_DosEXITCRITSEC = 6; (* callgate *) + Ord_DosEXITLIST = 7; (* callgate *) + Ord_DosGETINFOSEG = 8; (* callgate *) + Ord_DosGETPRTY = 9; (* callgate *) + Ord_DosKILLPROCESS = 10; (* callgate *) + Ord_DosSETPRTY = 11; (* callgate *) + Ord_DosPTRACE = 12; (* callgate *) + Ord_DosHOLDSIGNAL = 13; (* callgate *) + Ord_DosSETSIGHANDLER = 14; (* callgate *) + Ord_DosFLAGPROCESS = 15; (* callgate *) + Ord_DosMAKEPIPE = 16; (* callgate *) + Ord_DosISysSemClear = 17; (* callgate *) + Ord_DosISemRequest = 18; (* callgate *) + Ord_DosISysSemSet = 19; (* callgate *) + Ord_DosSEMSETWAIT = 20; (* callgate *) + Ord_DosISemWait = 21; (* callgate *) + Ord_DosMUXSEMWAIT = 22; (* callgate *) + Ord_DosCLOSESEM = 23; (* callgate *) + Ord_DosCREATESEM = 24; (* callgate *) + Ord_DosOPENSEM = 25; (* callgate *) + Ord_DosRESUMETHREAD = 26; (* callgate *) + Ord_DosSUSPENDTHREAD = 27; (* callgate *) + Ord_DosSETDATETIME = 28; (* callgate *) Ord_DosTIMERASYNC = 29; Ord_DosTIMERSTART = 30; Ord_DosTIMERSTOP = 31; - Ord_DosSLEEP = 32; - Ord_DosGETDATETIME = 33; - Ord_DosALLOCSEG = 34; - Ord_DosALLOCSHRSEG = 35; - Ord_DosGETSHRSEG = 36; - Ord_DosGIVESEG = 37; - Ord_DosREALLOCSEG = 38; - Ord_DosFREESEG = 39; - Ord_DosALLOCHUGE = 40; - Ord_DosGETHUGESHIFT = 41; - Ord_DosREALLOCHUGE = 42; - Ord_DosCREATECSALIAS = 43; - Ord_DosLOADMODULE = 44; - Ord_DosGETPROCADDR = 45; - Ord_DosFREEMODULE = 46; - Ord_DosGETMODHANDLE = 47; - Ord_DosGETMODNAME = 48; - Ord_DosGETMACHINEMODE = 49; - Ord_DosBEEP = 50; - Ord_DosCLIACCESS = 51; - Ord_DosDEVCONFIG = 52; - Ord_DosDEVIOCTL = 53; - Ord_DosBUFRESET = 56; - Ord_DosCHDIR = 57; - Ord_DosCHGFILEPTR = 58; - Ord_DosCLOSE = 59; - Ord_DosDELETE = 60; - Ord_DosDUPHANDLE = 61; - Ord_DosFILELOCKS = 62; - Ord_DosFINDCLOSE = 63; - Ord_DosFINDFIRST = 64; - Ord_DosFINDNEXT = 65; - Ord_DosMKDIR = 66; - Ord_DosMOVE = 67; - Ord_DosNEWSIZE = 68; - Ord_DosPORTACCESS = 69; - Ord_DosOPEN = 70; - Ord_DosQCURDIR = 71; - Ord_DosQCURDISK = 72; - Ord_DosQFHANDSTATE = 73; - Ord_DosQFILEINFO = 74; - Ord_DosQFILEMODE = 75; - Ord_DosQFSINFO = 76; - Ord_DosQHANDTYPE = 77; - Ord_DosQVERIFY = 78; - Ord_DosRMDIR = 80; - Ord_DosSELECTDISK = 81; - Ord_DosSETFHANDSTATE = 82; - Ord_DosSETFILEINFO = 83; - Ord_DosSETFILEMODE = 84; - Ord_DosSETMAXFH = 85; - Ord_DosSETVERIFY = 86; - Ord_DosSYSTEMSERVICE = 88; - Ord_DosSETVEC = 89; - Ord_DosSYSTRACE = 90; - Ord_DosGETENV = 91; - Ord_DosGETVERSION = 92; - Ord_DosGETPID = 94; - Ord_DosOPEN2 = 95; - Ord_DosLIBINIT = 96; - Ord_DosSETFSINFO = 97; - Ord_DosQPATHINFO = 98; - Ord_DosDEVIOCTL2 = 99; - Ord_DosSETPATHINFO = 104; - Ord_DosISETRELMAXFH = 108; - Ord_DosIDEVIOCTL = 109; + Ord_DosSLEEP = 32; (* callgate *) + Ord_DosGETDATETIME = 33; (* callgate *) + Ord_DosALLOCSEG = 34; (* callgate *) + Ord_DosALLOCSHRSEG = 35; (* callgate *) + Ord_DosGETSHRSEG = 36; (* callgate *) + Ord_DosGIVESEG = 37; (* callgate *) + Ord_DosREALLOCSEG = 38; (* callgate *) + Ord_DosFREESEG = 39; (* callgate *) + Ord_DosALLOCHUGE = 40; (* callgate *) + Ord_DosGETHUGESHIFT = 41; (* callgate *) + Ord_DosREALLOCHUGE = 42; (* callgate *) + Ord_DosCREATECSALIAS = 43; (* callgate *) + Ord_DosLOADMODULE = 44; (* callgate *) + Ord_DosGETPROCADDR = 45; (* callgate *) + Ord_DosFREEMODULE = 46; (* callgate *) + Ord_DosGETMODHANDLE = 47; (* callgate *) + Ord_DosGETMODNAME = 48; (* callgate *) + Ord_DosGETMACHINEMODE = 49; (* callgate *) + Ord_DosBEEP = 50; (* callgate *) + Ord_DosCLIACCESS = 51; (* callgate *) + Ord_DosDEVCONFIG = 52; (* callgate *) + Ord_DosDEVIOCTL = 53; (* callgate *) + Ord_DosSGSwitch = 54; (* callgate *) + Ord_DosSGSwitchMe = 55; (* callgate *) + Ord_DosBUFRESET = 56; (* callgate *) + Ord_DosCHDIR = 57; (* callgate *) + Ord_DosCHGFILEPTR = 58; (* callgate *) + Ord_DosCLOSE = 59; (* callgate *) + Ord_DosDELETE = 60; (* callgate *) + Ord_DosDUPHANDLE = 61; (* callgate *) + Ord_DosFILELOCKS = 62; (* callgate *) + Ord_DosFINDCLOSE = 63; (* callgate *) + Ord_DosFINDFIRST = 64; (* callgate *) + Ord_DosFINDNEXT = 65; (* callgate *) + Ord_DosMKDIR = 66; (* callgate *) + Ord_DosMOVE = 67; (* callgate *) + Ord_DosNEWSIZE = 68; (* callgate *) + Ord_DosPORTACCESS = 69; (* callgate *) + Ord_DosOPEN = 70; (* callgate *) + Ord_DosQCURDIR = 71; (* callgate *) + Ord_DosQCURDISK = 72; (* callgate *) + Ord_DosQFHANDSTATE = 73; (* callgate *) + Ord_DosQFILEINFO = 74; (* callgate *) + Ord_DosQFILEMODE = 75; (* callgate *) + Ord_DosQFSINFO = 76; (* callgate *) + Ord_DosQHANDTYPE = 77; (* callgate *) + Ord_DosQVERIFY = 78; (* callgate *) + Ord_DosIRead = 79; (* callgate *) + Ord_DosRMDIR = 80; (* callgate *) + Ord_DosSELECTDISK = 81; (* callgate *) + Ord_DosSETFHANDSTATE = 82; (* callgate *) + Ord_DosSETFILEINFO = 83; (* callgate *) + Ord_DosSETFILEMODE = 84; (* callgate *) + Ord_DosSETMAXFH = 85; (* callgate *) + Ord_DosSETVERIFY = 86; (* callgate *) + Ord_DosIWrite = 87; (* callgate *) + Ord_DosSYSTEMSERVICE = 88; (* callgate *) + Ord_DosSETVEC = 89; (* callgate *) + Ord_DosSYSTRACE = 90; (* callgate *) + Ord_DosGETENV = 91; (* callgate *) + Ord_DosGETVERSION = 92; (* callgate *) + Ord_DosQTraceInfo = 93; (* callgate *) + Ord_DosGETPID = 94; (* callgate *) + Ord_DosOPEN2 = 95; (* callgate *) + Ord_DosLIBINIT = 96; (* callgate *) + Ord_DosSETFSINFO = 97; (* callgate *) + Ord_DosQPATHINFO = 98; (* callgate *) + Ord_DosDEVIOCTL2 = 99; (* callgate *) + Ord_DosICanonicalize = 100; (* callgate *) + Ord_DosSetFgnd = 101; (* callgate *) +{ +xxx Ord_DosSwapTaskInit = 102; +xxx Ord_DosReadPhys = 103; +} + Ord_DosSETPATHINFO = 104; (* callgate *) + Ord_DosSGSwitchProc2 = 105; (* callgate *) + Ord_STRUCHECK = 106; (* callgate *) + Ord_STRURESUPDATE = 107; (* callgate *) + Ord_DosISETRELMAXFH = 108; (* callgate *) + Ord_DosIDEVIOCTL = 109; (* callgate *) Ord_Dos32FORCEDELETE = 110; Ord_Dos32KILLTHREAD = 111; Ord_DosQUERYRASINFO = 112; - Ord_DosERROR = 120; - Ord_DosGETSEG = 121; - Ord_DosLOCKSEG = 122; - Ord_DosUNLOCKSEG = 123; - Ord_DosSIZESEG = 126; - Ord_DosMEMAVAIL = 127; - Ord_DosPHYSICALDISK = 129; - Ord_DosGETCP = 130; - Ord_DosSENDSIGNAL = 134; + Ord_Dos32DumpProcess = 113; + Ord_Dos32SuppressPopUps = 114; + Ord_THK32ALLOCMEM = 115; + Ord_THK32FREEMEM = 116; + Ord_THK32ALLOCSTACK = 117; + Ord_DosOpen2Compt = 118; (* callgate *) + Ord_DosGetSTDA = 119; (* callgate *) + Ord_DosERROR = 120; (* callgate *) + Ord_DosGETSEG = 121; (* callgate *) + Ord_DosLOCKSEG = 122; (* callgate *) + Ord_DosUNLOCKSEG = 123; (* callgate *) +{ +xxx Ord_DosSGSwitchProc = 124; +} + Ord_DosIRamSemWake = 125; (* callgate *) + Ord_DosSIZESEG = 126; (* callgate *) + Ord_DosMEMAVAIL = 127; (* callgate *) + Ord_DosIRamSemRequest = 128; (* callgate *) + Ord_DosPHYSICALDISK = 129; (* callgate *) + Ord_DosGETCP = 130; (* callgate *) + Ord_DosISetCP = 131; (* callgate *) +{ +xxx Ord_DosGlobalSeg = 132; +xxx Ord_DosProfile = 133; +} + Ord_DosSENDSIGNAL = 134; (* callgate *) Ord_DosHUGESHIFT = 135; Ord_DosHUGEINCR = 136; Ord_DosREAD = 137; @@ -605,45 +656,75 @@ const Ord_DosSEMWAIT = 142; Ord_DosSEMSET = 143; Ord_DosEXECPGM = 144; - Ord_DosCREATETHREAD = 145; - Ord_DosSUBSET = 146; - Ord_DosSUBALLOC = 147; - Ord_DosSUBFREE = 148; + Ord_DosCREATETHREAD = 145; (* callgate *) + Ord_DosSUBSET = 146; (* callgate *) + Ord_DosSUBALLOC = 147; (* callgate *) + Ord_DosSUBFREE = 148; (* callgate *) Ord_DosREADASYNC = 149; Ord_DosWRITEASYNC = 150; Ord_DosSEARCHPATH = 151; Ord_DosSCANENV = 152; Ord_DosSETCP = 153; - Ord_DosGETRESOURCE = 155; - Ord_DosGETPPID = 156; - Ord_DosCALLBACK = 157; - Ord_DosR2STACKREALLOC = 160; - Ord_DosFSRAMSEMREQUEST = 161; - Ord_DosFSRAMSEMCLEAR = 162; + Ord_DosQProcStatus = 154; (* callgate *) + Ord_DosGETRESOURCE = 155; (* callgate *) + Ord_DosGETPPID = 156; (* callgate *) + Ord_DosCALLBACK = 157; (* callgate *) + Ord_DosICallBack = 158; (* callgate *) + Ord_DosRetForward = 159; (* callgate *) + Ord_DosR2STACKREALLOC = 160; (* callgate *) + Ord_DosFSRAMSEMREQUEST = 161; (* callgate *) + Ord_DosFSRAMSEMCLEAR = 162; (* callgate *) Ord_DosQAPPTYPE = 163; Ord_DosSETPROCCP = 164; - Ord_DosDYNAMICTRACE = 165; - Ord_DosQSYSINFO = 166; - Ord_DosFSATTACH = 181; - Ord_DosQFSATTACH = 182; - Ord_DosFSCTL = 183; - Ord_DosFINDFIRST2 = 184; - Ord_DosMKDIR2 = 185; - Ord_DosFILEIO = 186; - Ord_DosFINDNOTIFYCLOSE = 187; - Ord_DosFINDNOTIFYFIRST = 188; - Ord_DosFINDNOTIFYNEXT = 189; - Ord_DosEDITNAME = 191; + Ord_DosDYNAMICTRACE = 165; (* callgate *) + Ord_DosQSYSINFO = 166; (* callgate *) + Ord_DosIMakeNmPipe = 167; (* callgate *) + Ord_DosICallNmPipe = 168; (* callgate *) + Ord_DosIConnectNmPipe = 169; (* callgate *) + Ord_DosIDisconnectNmPipe = 170; (* callgate *) + Ord_DosIPeekNmPipe = 171; (* callgate *) + Ord_DosIQNmPipeInfo = 172; (* callgate *) + Ord_DosIQNmPHandState = 173; (* callgate *) + Ord_DosISetNmPHandState = 174; (* callgate *) + Ord_DosITransactNmPipe = 175; (* callgate *) + Ord_DosIWaitNmPipe = 176; (* callgate *) + Ord_DosISetNmPipeSem = 177; (* callgate *) + Ord_DosIQNmPipeSemState = 178; (* callgate *) + Ord_DosIRawReadNmPipe = 179; (* callgate *) + Ord_DosIRawWriteNmPipe = 180; (* callgate *) + Ord_DosFSATTACH = 181; (* callgate *) + Ord_DosQFSATTACH = 182; (* callgate *) + Ord_DosFSCTL = 183; (* callgate *) + Ord_DosFINDFIRST2 = 184; (* callgate *) + Ord_DosMKDIR2 = 185; (* callgate *) + Ord_DosFILEIO = 186; (* callgate *) + Ord_DosFINDNOTIFYCLOSE = 187; (* callgate *) + Ord_DosFINDNOTIFYFIRST = 188; (* callgate *) + Ord_DosFINDNOTIFYNEXT = 189; (* callgate *) + Ord_DosSetTraceInfo = 190; (* callgate *) + Ord_DosEDITNAME = 191; (* callgate *) + Ord_DosLogMode = 192; (* callgate *) + Ord_DosLogEntry = 193; (* callgate *) + Ord_DosGetLogBuffer = 194; (* callgate *) + Ord_DosLogRegister = 195; + Ord_DosLogRead = 196; + Ord_DosFindFromName = 197; (* callgate *) + Ord_DosOPLockRelease = 198; (* callgate *) + Ord_DosOPLockWait = 199; (* callgate *) + Ord_DosICopy = 200; (* callgate *) Ord_DosCOPY = 201; - Ord_DosFORCEDELETE = 203; - Ord_DosENUMATTRIBUTE = 204; - Ord_DosSHUTDOWN = 206; - Ord_DosGETRESOURCE2 = 207; - Ord_DosFREERESOURCE = 208; + Ord_DosIQAppType = 202; (* callgate *) + Ord_DosFORCEDELETE = 203; (* callgate *) + Ord_DosENUMATTRIBUTE = 204; (* callgate *) + Ord_DosOPLockShutdown = 205; (* callgate *) + Ord_DosSHUTDOWN = 206; (* callgate *) + Ord_DosGETRESOURCE2 = 207; (* callgate *) + Ord_DosFREERESOURCE = 208; (* callgate *) Ord_Dos32SETMAXFH = 209; Ord_Dos32SETVERIFY = 210; Ord_Dos32ERRCLASS = 211; Ord_Dos32ERROR = 212; + Ord_DosCreateVDM = 213; (* callgate *) Ord_DosMAXPATHLEN = 214; Ord_DosPAGESIZE = 215; Ord_DosLOCALINFO = 216; @@ -692,6 +773,7 @@ const Ord_Dos32DELETE = 259; Ord_Dos32DUPHANDLE = 260; Ord_Dos32EDITNAME = 261; + Ord_THK32FREESTACK = 262; Ord_Dos32FINDCLOSE = 263; Ord_Dos32FINDFIRST = 264; Ord_Dos32FINDNEXT = 265; @@ -722,7 +804,12 @@ const Ord_Dos32STOPTIMER = 290; Ord_Dos32QUERYCP = 291; Ord_Dos32SETDATETIME = 292; + Ord_THK32AllocBlock = 293; + Ord_THK32FreeBlock = 294; + Ord_THK32R3DS = 295; Ord_Dos32EXITLIST = 296; + Ord_Dos32AllocProtectedMem = 297; + Ord_Dos32AliasMem = 298; Ord_Dos32ALLOCMEM = 299; Ord_Dos32ALLOCSHAREDMEM = 300; Ord_Dos32GETNAMEDSHAREDMEM = 301; @@ -731,11 +818,15 @@ const Ord_Dos32FREEMEM = 304; Ord_Dos32SETMEM = 305; Ord_Dos32QUERYMEM = 306; + Ord_Dos32QueryMemState = 307; Ord_Dos32OPENVDD = 308; Ord_Dos32REQUESTVDD = 309; Ord_Dos32CLOSEVDD = 310; Ord_Dos32CREATETHREAD = 311; Ord_Dos32GETINFOBLOCKS = 312; + Ord_DosAllocProtSeg = 313; (* callgate *) + Ord_DosAllocShrProtSeg = 314; (* callgate *) + Ord_DosAllocProtHuge = 315; (* callgate *) Ord_Dos32DYNAMICTRACE = 316; Ord_Dos32DEBUG = 317; Ord_Dos32LOADMODULE = 318; @@ -778,9 +869,20 @@ const Ord_Dos32UNSETEXCEPTIONHANDLER = 355; Ord_Dos32RAISEEXCEPTION = 356; Ord_Dos32UNWINDEXCEPTION = 357; + Ord_Dos32QueryPageUsage = 358; + Ord_DosQueryModFromCS = 359; (* callgate *) + Ord_Dos32QueryModFromEIP = 360; + Ord_DosFPDataArea = 361; Ord_Dos32TMRQUERYFREQ = 362; Ord_Dos32TMRQUERYTIME = 363; + Ord_Dos32AliasPerfCtrs = 364; + Ord_Dos32ConfigPerf = 365; + Ord_Dos32DeconPerf = 366; Ord_Dos32REGISTERPERFCTRS = 367; + Ord_Dos32QuerySysState = 368; + Ord_Dos32FlatCS = 369; + Ord_Dos32FlatDS = 370; + Ord_Dos32QueryABIOSSupport = 371; Ord_Dos32ENUMATTRIBUTE = 372; Ord_Dos32QUERYDOSPROPERTY = 373; Ord_Dos32SETDOSPROPERTY = 374; @@ -792,7 +894,42 @@ const Ord_Dos32ENTERMUSTCOMPLETE = 380; Ord_Dos32EXITMUSTCOMPLETE = 381; Ord_Dos32SETRELMAXFH = 382; + Ord_MsgPutMessage = 383; + Ord_MsgTrueGetMessage = 384; + Ord_MsgInsMessage = 385; + Ord_Msg32InsertMessage = 386; + Ord_Msg32PutMessage = 387; + Ord_Msg32TrueGetMessage = 388; + Ord_MsgIQueryMessageCP = 389; + Ord_Msg32IQueryMessageCP = 390; + Ord_NLSCaseMap = 391; + Ord_NLSGetCollate = 392; + Ord_NLSGetCtryInfo = 393; + Ord_NLSGetDBCSEv = 394; + Ord_NLS32QueryCtryInfo = 395; + Ord_NLS32QueryDBCSEnv = 396; + Ord_NLS32MapCase = 397; + Ord_NLS32QueryCollate = 398; + Ord_NPipeMakeNmPipe = 399; + Ord_NPipeQNmPipeInfo = 400; + Ord_NPipeConnectNmPipe = 401; + Ord_NPipeDisconnectNmPipe = 402; + Ord_NPipeQNmPHandState = 403; + Ord_NPipeSetNmPHandState = 404; + Ord_NPipePeekNmPipe = 405; + Ord_NPipeWaitNmPipe = 406; + Ord_NPipeTransactNmPipe = 407; + Ord_NPipeCallNmPipe = 408; + Ord_NPipeRawReadNmPipe = 409; + Ord_NPipeRawWriteNmPipe = 410; + Ord_NPipeSetNmPipeSem = 411; + Ord_NPipeQNmPipeSemState = 412; + Ord_StartLazyWriter = 413; + Ord_HPFSStartLazyWriter = 413; + Ord__QueInst_Data = 414; + Ord_QueInstanceData = 414; Ord_Dos32SHUTDOWN = 415; + Ord_Dos32ICacheModule = 416; Ord_Dos32REPLACEMODULE = 417; Ord_Dos32ACKNOWLEDGESIGNALEXC = 418; Ord_Dos32TIB = 419; @@ -803,22 +940,588 @@ const Ord_DosSELTOFLAT = 424; Ord_Dos32FLATTOSEL = 425; Ord_Dos32SELTOFLAT = 426; + Ord_DosIODelayCnt = 427; Ord_Dos32SETFILELOCKS = 428; Ord_Dos32CANCELLOCKREQUEST = 429; - Ord_DosOPENCHANGENOTIFY = 437; - Ord_DosRESETCHANGENOTIFY = 438; - Ord_DosCLOSECHANGENOTIFY = 439; + Ord_DosOPENCHANGENOTIFY = 437; (* callgate *) + Ord_DosRESETCHANGENOTIFY = 438; (* callgate *) + Ord_DosCLOSECHANGENOTIFY = 439; (* callgate *) Ord_Dos32OPENCHANGENOTIFY = 440; Ord_Dos32RESETCHANGENOTIFY = 441; Ord_Dos32CLOSECHANGENOTIFY = 442; + Ord_DosQueryABIOSSupport = 443; (* callgate *) + Ord_Dos32ForceSystemDump = 444; + Ord_Dos32GetProcessorStatus = 447; + Ord_Dos32SetProcessorStatus = 448; + Ord_DosCreateSpinLock = 449; (* callgate *) + Ord_DosAcquireSpinLock = 450; (* callgate *) + Ord_DosReleaseSpinLock = 451; (* callgate *) + Ord_DosFreeSpinLock = 452; (* callgate *) + Ord_Dos32TestPSD = 453; + Ord_Dos32AllocThreadLocalMemory = 454; + Ord_Dos32FreeThreadLocalMemory = 455; + Ord_Dos32VerifyPIDTID = 460; +{ +xxx Ord_PTDA_LANMAN_SEC = 464; +xxx Ord_PTDA_PID = 465; +xxx Ord_SAS_SEL = 466; +xxx Ord_TCB_OPCOOKIE = 467; +xxx Ord_TCB_OPFLAGS = 468; +xxx Ord_TCB_NEWFLAGS = 469; +xxx Ord_TCB_USER_ID = 470; +xxx Ord_TCB_PROC_ID = 471; +xxx Ord_TCB_FSHARING = 472; +xxx Ord_TCB_SRVATTRIB = 473; +xxx Ord_TCB_ALLOWED = 474; +xxx Ord_TCB_PRTCB = 475; +xxx Ord_TCB_NUMBER = 476; +xxx Ord_TCB_THISSFT = 477; +xxx Ord_TCB_THISCDS = 478; +xxx Ord_TKOPTDA = 479; +xxx Ord_PTDA_CRITSEC = 480; +xxx Ord_PTDA_HOLDSIGCNT = 481; +xxx Ord_PTDA_PPTDAPARENT = 482; +xxx Ord_PTDA_PGDATA = 483; +xxx Ord_PTDA_HANDLE = 484; +xxx Ord_PTDA_MODULE = 485; +xxx Ord_PTDA_LDTHANDLE = 486; +xxx Ord_PTDA_CODEPAGE_TAG = 487; +xxx Ord_PTDA_JFN_LENGTH = 488; +xxx Ord_PTDA_JFN_PTABLE = 489; +xxx Ord_PTDA_JFN_FLG_PTR = 490; +xxx Ord_PTDA_EXTERR_LOCUS = 491; +xxx Ord_PTDA_EXTERR = 492; +xxx Ord_PTDA_EXTERR_ACTION = 493; +xxx Ord_PTDA_EXTERR_CLASS = 494; +xxx Ord_PTDA_PPID = 495; +xxx Ord_PTDA_PROCTYPE = 496; +xxx Ord_PTDA_CURRTCB = 497; +xxx Ord_PTDA_CURRTSD = 498; +xxx Ord_PTDA_SIGNATURE = 499; +xxx 500 T32EXITLIST +xxx 501 T32ALLOCPROTECTEDMEM +xxx 502 T32ALIASMEM +xxx 503 T32ALLOCMEM +xxx 504 T32ALLOCSHAREDMEM +xxx 505 T32GETNAMEDSHAREDMEM +xxx 506 T32GETSHAREDMEM +xxx 507 T32GIVESHAREDMEM +xxx 508 T32FREEMEM +xxx 509 T32SETMEM +xxx 510 T32QUERYMEM +xxx 511 T32QUERYMEMSTATE +xxx 512 T32OPENVDD +xxx 513 T32REQUESTVDD +xxx 514 T32CLOSEVDD +xxx 515 T32CREATETHREAD +xxx 516 T32DYNAMICTRACE +xxx 517 T32DEBUG +xxx 518 T32QUERYPROCADDR +xxx 519 T32CREATEEVENTSEM +xxx 520 T32OPENEVENTSEM +xxx 521 T32CLOSEEVENTSEM +xxx 522 T32RESETEVENTSEM +xxx 523 T32POSTEVENTSEM +xxx 524 T32WAITEVENTSEM +xxx 525 T32QUERYEVENTSEM +xxx 526 T32CREATEMUTEXSEM +xxx 527 T32OPENMUTEXSEM +xxx 528 T32CLOSEMUTEXSEM +xxx 529 T32REQUESTMUTEXSEM +xxx 530 T32RELEASEMUTEXSEM +xxx 531 T32QUERYMUTEXSEM +xxx 532 T32CREATEMUXWAITSEM +xxx 533 T32OPENMUXWAITSEM +xxx 534 T32CLOSEMUXWAITSEM +xxx 535 T32WAITMUXWAITSEM +xxx 536 T32ADDMUXWAITSEM +xxx 537 T32DELETEMUXWAITSEM +xxx 538 T32QUERYMUXWAITSEM +xxx 539 T32QUERYSYSINFO +xxx 540 T32WAITTHREAD +} + Ord_DosIOpenL = 541; (* callgate *) + Ord_DosIProtectOpenL = 542; (* callgate *) + Ord_DosISetFileSizeL = 543; (* callgate *) + Ord_DosIProtectSetFileSizeL = 544; (* callgate *) +{ +xxx Ord_Dos32ExceptionCallBack = 545; +} + Ord_THK32STRLEN = 546; + Ord_THK32_UNITHUNK = 547; + Ord_Dos32R3ExceptionDispatcher = 548; + Ord_DosLibiDisp = 549; + Ord_DosLibiDisp16 = 550; + Ord_DosLibiDisp32 = 551; + Ord_DosR3ExitAddr = 552; + Ord_Dos32R3ExitAddr = 553; +{ +xxx Ord_Dos32IRead = 554; +xxx Ord_Dos32IWrite = 556; +} + Ord_Dos32CreateSpinLock = 557; + Ord_Dos32AcquireSpinLock = 558; + Ord_Dos32ReleaseSpinLock = 559; + Ord_Dos32FreeSpinLock = 560; + Ord_Dos32PMR3WaitEventSem = 561; + Ord_Dos32PMR3PostEventSem = 562; + Ord_Dos32QueryThreadAffinity = 563; + Ord_Dos32SetThreadAffinity = 564; + Ord_DosISetFileInfo = 565; (* callgate *) + Ord_DosISetPathInfo = 566; (* callgate *) + Ord_DosOpenL = 567; (* callgate *) + Ord_DosSetFilePtrL = 568; + Ord_DosIFindNext = 569; (* callgate *) + Ord_DosSetFileSizeL = 570; Ord_Dos32QUERYRESOURCESIZE = 572; Ord_DosQUERYRESOURCESIZE = 573; + Ord_DosPMSemWait = 574; + Ord_DosPMMuxSemWait = 575; + Ord_THK16_UNITHUNK = 576; + Ord_HT16_STARTUP = 577; + Ord_HT16_CLEANUP = 578; + Ord_HT32_STARTUP = 579; Ord_Dos32INITIALIZEPORTHOLE = 580; + Ord_HT32_CLEANUP = 581; Ord_Dos32QUERYHEADERINFO = 582; Ord_DosINITIALIZEPORTHOLE = 583; Ord_DosQUERYHEADERINFO = 584; + Ord__Dos32IMonRead = 585; + Ord_Mon32IMonRead = 585; Ord_Dos32QUERYPROCTYPE = 586; Ord_DosQUERYPROCTYPE = 587; + Ord__Dos32IMonWrite = 588; + Ord_Mon32IMonWrite = 588; + Ord_DosISigDispatch = 589; + Ord_Dos32PMPOSTEVENTSEM = 590; + Ord_Dos32PMWAITEVENTSEM = 591; + Ord_Dos32DllTermDisp = 592; + Ord_Dos32PMREQUESTMUTEXSEM = 593; + Ord_Dos32IRaiseException = 594; + Ord_Dos32PMWAITMUXWAITSEM = 595; + Ord_Dos32PM16SEMCHK = 596; + Ord_Dos32IQueryFHState = 597; (* callgate *) + Ord_Dos32ISetFHState = 598; (* callgate *) + Ord_Dos32LDTSel = 599; + Ord_Dos32R3Frestor = 600; + Ord_DosIFindFirst = 601; (* callgate *) +{ +xxx 606 MonDosMonOpen +xxx 607 MonDosMonClose +xxx 608 MonDosMonRead +xxx 609 MonDosMonWrite +xxx 610 MonDosMonReg +xxx Ord_Dos32IProtectWrite = 615; +} + Ord_DosIProtectSetFileInfo = 617; (* callgate *) +{ +xxx Ord_Dos32IProtectSetFileInfo = 618; +} + Ord_Dos32IProtectSetFHState = 619; (* callgate *) + Ord_Dos32IProtectQueryFHState = 620; (* callgate *) + Ord_Dos32PROTECTSETFILEPTR = 621; + Ord_DosPROTECTCLOSE = 622; (* callgate *) + Ord_DosPROTECTFILEIO = 623; (* callgate *) + Ord_DosPROTECTFILELOCKS = 624; (* callgate *) + Ord_DosIProtectRead = 625; (* callgate *) + Ord_DosIProtectWrite = 626; (* callgate *) + Ord_DosPROTECTNEWSIZE = 627; (* callgate *) + Ord_DosPROTECTOPEN = 628; (* callgate *) + Ord_DosPROTECTQFHANDSTATE = 629; (* callgate *) + Ord_DosPROTECTSETFHANDSTATE = 630; (* callgate *) + Ord_DosPROTECTQFILEINFO = 631; (* callgate *) + Ord_DosPROTECTSETFILEINFO = 632; (* callgate *) + Ord_DosPROTECTCHGFILEPTR = 634; (* callgate *) + Ord_DosPROTECTENUMATTRIBUTE = 635; (* callgate *) + Ord_Dos32PROTECTENUMATTRIBUTE = 636; + Ord_Dos32PROTECTOPEN = 637; + Ord_Dos32PROTECTCLOSE = 638; + Ord_Dos32PROTECTSETFILELOCKS = 639; + Ord_Dos32PROTECTSETFILESIZE = 640; + Ord_Dos32PROTECTREAD = 641; + Ord_Dos32PROTECTWRITE = 642; + Ord_Dos32PROTECTSETFILEINFO = 643; + Ord_Dos32PROTECTSETFHSTATE = 644; + Ord_Dos32PROTECTQUERYFHSTATE = 645; + Ord_Dos32PROTECTQUERYFILEINFO = 646; +{ +xxx Ord_Dos32IProtectRead = 647; +} + Ord_DosCloseMessageFile = 649; + Ord_DosLDRDirtyWorker = 650; (* callgate *) + Ord_Dos16LDRDirtyWorker = 651; (* callgate *) +{ +xxx 652 Ord_Dos32IGetInfoBlocks +} + Ord_T32IGETINFOBLOCKS = 653; (* callgate *) + Ord_T32GETPROCESSORSTATUS = 656; (* callgate *) + Ord_T32SETPROCESSORSTATUS = 657; (* callgate *) + Ord_T32TESTPSD = 658; (* callgate *) + Ord_T32QUERYTHREADAFFINITY = 659; (* callgate *) + Ord_T32SETTHREADAFFINITY = 660; (* callgate *) + Ord_QueDos32READQUEUE = 661; + Ord_QueDos32PURGEQUEUE = 662; + Ord_QueDos32CLOSEQUEUE = 663; + Ord_QueDos32QUERYQUEUE = 664; + Ord_QueDos32PEEKQUEUE = 665; + Ord_QueDos32WRITEQUEUE = 666; + Ord_QueDos32OPENQUEUE = 667; + Ord_QueDos32CREATEQUEUE = 668; + Ord_SMGDos32STARTSESSION = 669; + Ord_SMGDos32SELECTSESSION = 670; + Ord_SMGDos32SETSESSION = 671; + Ord_SMGDos32STOPSESSION = 672; + Ord_SMGREGISTERNOTIFICATION = 673; + Ord_QueDosREADQUEUE = 674; + Ord_QueDosPURGEQUEUE = 675; + Ord_QueDosCLOSEQUEUE = 676; + Ord_QueDosQUERYQUEUE = 677; + Ord_QueDosPEEKQUEUE = 678; + Ord_QueDosWRITEQUEUE = 679; + Ord_QueDosOPENQUEUE = 680; + Ord_QueDosCREATEQUEUE = 681; + Ord_CHRDosSMGETME = 682; + Ord_CHRDosSMFREEMEM = 683; + Ord_CHRDosSMGETSGCB = 684; + Ord_CHRDosSMINITSGCB = 685; + Ord_SMGDosSMSGDOPOPUP = 686; + Ord_SMGDosSMSWITCH = 687; + Ord_SMGDosSMSERVEAPPREQ = 688; + Ord_SMGDosGETTIMES = 689; + Ord_SMGDosSMSETTITLE = 690; + Ord_SMGDosSCRUNLOCK = 691; + Ord_SMGDosSMDOAPPREQ = 692; + Ord_SMGDosSTOPSESSION = 693; + Ord_SMGDosSELECTSESSION = 694; + Ord_SMGDosSCRLOCK = 695; + Ord_SMGDosSAVREDRAWWAIT = 696; + Ord_SMGDosSAVREDRAWUNDO = 697; + Ord_SMGDosSMSGENDPOPUP = 698; + Ord_SMGDosSETSESSION = 699; + Ord_SMGDosSETMNLOCKTIME = 700; + Ord_SMGDosMODEUNDO = 701; + Ord_SMGDosSTARTSESSION = 702; + Ord_SMGDosSMGETSTATUS = 703; + Ord_SMGDosSMMODEWAIT = 704; + Ord_SMGDosSMTERMINATE = 705; + Ord_SMGDosSMGETAPPREQ = 706; + Ord_SMGDosSMINITIALIZE = 707; + Ord_SMGDosSMSTART = 708; + Ord_SMGDosSMPARENTSWITCH = 709; + Ord_SMGDosSMPAUSE = 710; + Ord_SMGDosSMHDEINIT = 711; + Ord_SMGDosSMPMPRESENT = 712; + Ord_SMGDosSMREGISTERDD = 713; + Ord_SMGDosSMNOTIFYDD = 714; + Ord_SMGDosSMNOTIFYDD2 = 715; + Ord_SMGDosSMOPENDD = 716; + Ord_SMGDosSMSETSESSIONTYPE = 717; + Ord_CHRBASEINIT = 718; + Ord_OS2BASEINIT = 718; + Ord_MouDosGETPTRSHAPE = 719; + Ord_MouDosSETPTRSHAPE = 720; + Ord_MouDosGETNUMMICKEYS = 721; + Ord_MouDosGETTHRESHOLD = 722; + Ord_MouDosSHELLINIT = 723; + Ord_MouDosGETSCALEFACT = 724; + Ord_MouDosFLUSHQUE = 725; + Ord_MouDosGETNUMBUTTONS = 726; + Ord_MouDosCLOSE = 727; + Ord_MouDosSETTHRESHOLD = 728; + Ord_MouDosSETSCALEFACT = 729; + Ord_MouDosGETNUMQUEEL = 730; + Ord_MouDosDEREGISTER = 731; + Ord_MouDosGETEVENTMASK = 732; + Ord_MouDosSETEVENTMASK = 733; + Ord_MouDosOPEN = 734; + Ord_MouDosREMOVEPTR = 735; + Ord_MouDosGETPTRPOS = 736; + Ord_MouDosREADEVENTQUE = 737; + Ord_MouDosSETPTRPOS = 738; + Ord_MouDosGETDEVSTATUS = 739; + Ord_MouDosSYNCH = 740; + Ord_MouDosREGISTER = 741; + Ord_MouDosSETDEVSTATUS = 742; + Ord_MouDosDRAWPTR = 743; + Ord_MouDosINITREAL = 744; + Ord_KbdDosSETCUSTXT = 745; + Ord_KbdDosPROCESSINIT = 746; + Ord_KbdDosGETCP = 747; + Ord_KbdDosCHARIN = 748; + Ord_KbdDosSETCP = 749; + Ord_KbdDosLOADINSTANCE = 750; + Ord_KbdDosSYNCH = 751; + Ord_KbdDosREGISTER = 752; + Ord_KbdDosSTRINGIN = 753; + Ord_KbdDosGETSTATUS = 754; + Ord_KbdDosSETSTATUS = 755; + Ord_KbdDosGETFOCUS = 756; + Ord_KbdDosFLUSHBUFFER = 757; + Ord_KbdDosXLATE = 758; + Ord_KbdDosSWITCHFGND = 759; + Ord_KbdDosSHELLINIT = 760; + Ord_KbdDosCLOSE = 761; + Ord_KbdDosFREEFOCUS = 762; + Ord_KbdDosFREE = 763; + Ord_KbdDosDEREGISTER = 764; + Ord_KbdDosSETFGND = 765; + Ord_KbdDosPEEK = 766; + Ord_KbdDosOPEN = 767; + Ord_KbdDosGETHWID = 768; + Ord_KbdDosSETHWID = 769; + Ord_VioDosENDPOPUP = 770; + Ord_VioDosGETPHYSBUF = 771; + Ord_VioDosGETANSI = 772; + Ord_VioDosFREE = 773; + Ord_VioDosSETANSI = 774; + Ord_VioDosDEREGISTER = 775; + Ord_VioDosSCROLLUP = 776; + Ord_VioDosPRTSC = 777; + Ord_VioDosGETCURPOS = 778; + Ord_VioDosWRTCELLSTR = 779; + Ord_VioDosPOPUP = 780; + Ord_VioDosSCROLLRT = 781; + Ord_VioDosWRTCHARSTR = 782; + Ord_VioDosAVS_PRTSC = 783; + Ord_VioDosSETCURPOS = 784; + Ord_VioDosSRFUNBLOCK = 785; + Ord_VioDosSRFBLOCK = 786; + Ord_VioDosSCRUNLOCK = 787; + Ord_VioDosWRTTTY = 788; + Ord_VioDosSAVE = 789; + Ord_VioDosGETMODE = 790; + Ord_VioDosSETMODE = 791; + Ord_VioDosSCRLOCK = 792; + Ord_VioDosREADCELLSTR = 793; + Ord_VioDosSAVREDRAWWAIT = 794; + Ord_VioDosWRTNATTR = 795; + Ord_VioDosGETCURTYPE = 796; + Ord_VioDosSAVREDRAWUNDO = 797; + Ord_VioDosGETFONT = 798; + Ord_VioDosREADCHARSTR = 799; + Ord_VioDosGETBUF = 800; + Ord_VioDosSETCURTYPE = 801; + Ord_VioDosSETFONT = 802; + Ord_VioDosHETINIT = 803; + Ord_VioDosMODEUNDO = 804; + Ord_VioDosSSWSWITCH = 805; + Ord_VioDosMODEWAIT = 806; + Ord_VioDosAVS_PRTSCTOGGLE = 807; + Ord_VioDosGETCP = 808; + Ord_VioDosRESTORE = 809; + Ord_VioDosSETCP = 810; + Ord_VioDosSHOWBUF = 811; + Ord_VioDosSCROLLLF = 812; + Ord_VioDosREGISTER = 813; + Ord_VioDosGETCONFIG = 814; + Ord_VioDosSCROLLDN = 815; + Ord_VioDosWRTCHARSTRATT = 816; + Ord_VioDosGETSTATE = 817; + Ord_VioDosPRTSCTOGGLE = 818; + Ord_VioDosSETSTATE = 819; + Ord_VioDosWRTNCELL = 820; + Ord_VioDosWRTNCHAR = 821; + Ord_VioDosSHELLINIT = 822; + Ord_VioDosASSOCIATE = 823; + Ord_VioDosCREATEPS = 824; + Ord_VioDosDELETESETID = 825; + Ord_VioDosGETDEVICECELLSIZE = 826; + Ord_VioDosGETORG = 827; + Ord_VioDosCREATELOGFONT = 828; + Ord_VioDosDESTROYPS = 829; + Ord_VioDosQUERYSETIDS = 830; + Ord_VioDosSETORG = 831; + Ord_VioDosQUERYFONTS = 832; + Ord_VioDosSETDEVICECELLSIZE = 833; + Ord_VioDosSHOWPS = 834; + Ord_VioDosGETPSADDRESS = 835; + Ord_VioDosQUERYCONSOLE = 836; + Ord_VioDosREDRAWSIZE = 837; + Ord_VioDosGLOBALREG = 838; + Ord_XVioDosSETCASTATE = 839; + Ord_XVioDosCHECKCHARTYPE = 840; + Ord_XVioDosDESTROYCA = 841; + Ord_XVioDosCREATECA = 842; + Ord_VioDosCHECKCHARTYPE = 843; + Ord_XVioDosGETCASTATE = 844; + Ord_BvsDosMAIN = 845; + Ord_BvsDosREDRAWSIZE = 846; + Ord_BvsDosGETPTRDRAWNAME = 847; + Ord_AnsiDosINJECT = 848; + Ord_AnsiDosKEYDEF = 849; + Ord_AnsiDosINTERP = 850; + Ord_BksDosMAIN = 851; + Ord_BmsDosMAIN = 852; + Ord_MouDosGETHOTKEY = 853; + Ord_MouDosSETHOTKEY = 854; + Ord_SMGDosSMSYSINIT = 855; + Ord_SMGQHKEYBDHANDLE = 856; + Ord_SMGQHMOUSEHANDLE = 857; + Ord_CHRQueueRamSem = 858; + Ord_SMQueueRamSem = 858; + Ord_CHRArray = 859; + Ord_SMArray = 859; + Ord_CHRPIDArray = 860; + Ord_SMPIDArray = 860; + Ord_CHRInitialized = 861; + Ord_SMInitialized = 861; + Ord_CHRArraySize = 862; + Ord_SMArraySize = 862; + Ord_CHRBVSGLOBAL = 863; + Ord_BVSGLOBAL = 863; + Ord_CHRSMGINSTANCE = 864; + Ord_SMGINSTANCE = 864; + Ord_CHRBVHINSTANCE = 865; + Ord_BVHINSTANCE = 865; + Ord_THK32ALIASMEM = 866; + Ord_THK32FREEALIAS = 867; + Ord_THK32ALLOCVARLEN = 868; + Ord_THK32HANDLEBOUNDARY = 869; + Ord_THK32HANDLESTRING = 870; + Ord_THK32DEALLOC = 871; + Ord_THK32XHNDLR = 872; + Ord_Dos32SETEXTLIBPATH = 873; + Ord_Dos32QUERYEXTLIBPATH = 874; + Ord_Dos32PM16SEMRST = 875; + Ord_Dos32SYSCTL = 876; + Ord_Dos32QUERYTHREADCONTEXT = 877; + Ord_DosSGQUERYTOPMOST = 878; + Ord_Dos32PERFSYSCALL = 976; + Ord_Dos32OPENL = 981; + Ord_Dos32PROTECTOPENL = 982; + Ord_Dos32PROTECTSETFILELOCKSL = 983; + Ord_Dos32PROTECTSETFILEPTRL = 984; + Ord_Dos32PROTECTSETFILESIZEL = 985; + Ord_Dos32SETFILELOCKSL = 986; + Ord_Dos32CANCELLOCKREQUESTL = 987; + Ord_Dos32SETFILEPTRL = 988; + Ord_Dos32SETFILESIZEL = 989; + Ord_Dos32LISTIOL = 990; +{ +xxx Ord_DosFSRAMSEMREQUEST2 = 991; +xxx Ord_DosFSRAMSEMCLEAR2 = 992; +} + Ord_Dos32SystemService = 995; + Ord_Dos32LISTIO = 996; + Ord_Dos32CREATETHREAD2 = 997; + Ord_DosSETEXTLIBPATH = 998; + Ord_DosQUERYEXTLIBPATH = 999; +{ +xxx 1000 T32EXITLIST +xxx 1001 T32ALLOCPROTECTEDMEM +xxx 1002 T32ALIASMEM +xxx 1003 T32ALLOCMEM +xxx 1004 T32ALLOCSHAREDMEM +xxx 1005 T32GETNAMEDSHAREDMEM +xxx 1006 T32GETSHAREDMEM +xxx 1007 T32GIVESHAREDMEM +xxx 1008 T32FREEMEM +xxx 1009 T32SETMEM +xxx 1010 T32QUERYMEM +xxx 1011 T32QUERYMEMSTATE +xxx 1012 T32OPENVDD +xxx 1013 T32REQUESTVDD +xxx 1014 T32CLOSEVDD +xxx 1015 T32CREATETHREAD +xxx 1016 T32DYNAMICTRACE +xxx 1017 T32DEBUG +xxx 1018 T32QUERYPROCADDR +xxx 1019 T32CREATEEVENTSEM +xxx 1020 T32OPENEVENTSEM +xxx 1021 T32CLOSEEVENTSEM +xxx 1022 T32RESETEVENTSEM +xxx 1023 T32POSTEVENTSEM +xxx 1024 T32WAITEVENTSEM +xxx 1025 T32QUERYEVENTSEM +xxx 1026 T32CREATEMUTEXSEM +xxx 1027 T32OPENMUTEXSEM +xxx 1028 T32CLOSEMUTEXSEM +xxx 1029 T32REQUESTMUTEXSEM +xxx 1030 T32RELEASEMUTEXSEM +xxx 1031 T32QUERYMUTEXSEM +xxx 1032 T32CREATEMUXWAITSEM +xxx 1033 T32OPENMUXWAITSEM +xxx 1034 T32CLOSEMUXWAITSEM +xxx 1035 T32WAITMUXWAITSEM +xxx 1036 T32ADDMUXWAITSEM +xxx 1037 T32DELETEMUXWAITSEM +xxx 1038 T32QUERYMUXWAITSEM +xxx 1039 T32QUERYSYSINFO +xxx 1040 T32WAITTHREAD +xxx 1041 T32GETRESOURCE +xxx 1042 T32FREERESOURCE +xxx 1043 T32EXCEPTIONCALLBACK +xxx 1044 T32QUERYPAGEUSAGE +xxx 1045 T32FORCESYSTEMDUMP +xxx 1046 TI32ASYNCTIMER +xxx 1047 TI32STARTTIMER +xxx 1048 T32QUERYABIOSSUPPORT +xxx 1049 T32QUERYMODFROMEIP +xxx 1050 T32ALIASPERFCTRS +xxx 1051 T32CONFIGUREPERF +xxx 1052 T32DECONPERF +xxx 1053 T32REGISTERPERFCTRS +xxx 1054 T32QUERYSYSSTATE +xxx 1055 T32IREAD +xxx 1056 T32IWRITE +xxx 1057 T32TMRQUERYFREQ +xxx 1058 T32TMRQUERYTIME +xxx 1059 T32IMONREAD +xxx 1060 T32IMONWRITE +xxx 1061 T32QUERYRESOURCESIZE +xxx 1062 T32PROFILE +xxx 1063 T32SETSIGNALEXCEPTIONFOCUS +xxx 1064 T32SENDSIGNALEXCEPTION +xxx 1065 T32STARTTIMER +xxx 1066 T32STOPTIMER +xxx 1067 T32ASYNCTIMER +xxx 1068 T32INITIALIZEPORTHOLE +xxx 1069 T32QUERYHEADERINFO +xxx 1070 T32QUERYPROCTYPE +xxx 1071 T32IEXITMUSTCOMPLETE +xxx 1072 T32ICACHEMODULE +xxx 1073 T32DLLTERM +xxx 1074 T32IRAISEEXCEPTION +xxx 1075 T32ACKNOWLEDGESIGNALEXCEPTION +xxx 1076 T32QUERYDOSPROPERTY +xxx 1077 T32SETDOSPROPERTY +xxx 1078 T32SETFILELOCKS +xxx 1079 T32CANCELLOCKREQUEST +xxx 1080 T32KILLTHREAD +xxx 1081 TQUERYRASINFO +xxx 1082 T32DUMPPROCESS +xxx 1083 T32SUPPRESSPOPUPS +xxx 1084 T32IPROTECTWRITE +xxx 1085 T32PROTECTSETFILELOCKS +xxx 1086 T32IPROTECTREAD +xxx 1087 T32PMPOSTEVENTSEM +xxx 1088 T32PMWAITEVENTSEM +xxx 1089 T32PMREQUESTMUTEXSEM +xxx 1090 T32PMWAITMUXWAITSEM +xxx 1091 T32PM16SEMCHK +xxx 1092 T32ALLOCTHREADLOCALMEMORY +xxx 1093 T32FREETHREADLOCALMEMORY +xxx 1094 T32SETEXTLIBPATH +xxx 1095 T32QUERYEXTLIBPATH +xxx 1096 T32PM16SEMRST +xxx 1097 T32VERIFYPIDTID +xxx 1098 T32SYSCTL +xxx 1099 T32QUERYTHREADCONTEXT +xxx 1101 T32PERFSYSCALL +xxx 1102 T32LISTIO +xxx 1103 T32PMR3WAITEVENTSEM +xxx 1104 T32PMR3POSTEVENTSEM +xxx 1105 T32CREATETHREAD2 +xxx 1106 T32PROTECTSETFILELOCKSL +xxx 1107 T32IPROTECTSETFILEPTRL +xxx 1108 T32SETFILELOCKSL +xxx 1109 T32CANCELLOCKREQUESTL +xxx 1110 T32ISETFILEPTRL +xxx 1111 T32LISTIOL +xxx 1116 T32ISETFILEPTR +xxx 1117 T32IPROTECTSETFILEPTR +} +(* PMGPI.DLL *) Ord_DevOPENDC = 1; Ord_DevCLOSEDC = 2; Ord_DevPOSTDEVICEMODES = 3; @@ -1367,6 +2070,7 @@ const Ord_Gpi32CONVERTWITHMATRIX = 618; Ord_Gpi32LOADPUBLICFONTS = 622; Ord_Gpi32UNLOADPUBLICFONTS = 623; +(* PMWIN.DLL *) Ord_WinQUERYDESKTOPWINDOW = 1; Ord_WinQUERYOBJECTWINDOW = 2; Ord_WinREGISTERCLASS = 3; @@ -1607,16 +2311,12 @@ const Ord_DumWinCREATEHELPTABLE = 314; Ord_DumWinLOADHELPTABLE = 315; Ord_DumWinQUERYHELPINSTANCE = 316; - Ord_DummyHelpEntry = 322; - Ord_WinSETCLASSTHUNKPROC = 959; - Ord_WinQUERYCLASSTHUNKPROC = 960; - Ord_WinSETWINDOWTHUNKPROC = 961; - Ord_WinQUERYWINDOWTHUNKPROC = 962; Ord_WinQUERYWINDOWMODEL = 317; Ord_WinSETDESKTOPBKGND = 318; Ord_WinQUERYDESKTOPBKGND = 319; Ord_WinPOPUPMENU = 320; Ord_WinREALIZEPALETTE = 321; + Ord_DummyHelpEntry = 322; Ord_WinDELETELIBRARY = 602; Ord_WinLOADPROCEDURE = 603; Ord_WinDELETEPROCEDURE = 604; @@ -1874,17 +2574,23 @@ const Ord_Win32SAVEWINDOWPOS = 943; Ord_Win32GETERASEPS = 952; Ord_Win32RELEASEERASEPS = 953; - Ord_Win32SETPOINTEROWNER = 971; + Ord_WinSETCLASSTHUNKPROC = 959; + Ord_WinQUERYCLASSTHUNKPROC = 960; + Ord_WinSETWINDOWTHUNKPROC = 961; + Ord_WinQUERYWINDOWTHUNKPROC = 962; Ord_Win32STRETCHPOINTER = 968; + Ord_Win32SETPOINTEROWNER = 971; Ord_Win32SETERRORINFO = 977; Ord_Win32WAITEVENTSEM = 978; Ord_Win32REQUESTMUTEXSEM = 979; Ord_Win32WAITMUXWAITSEM = 980; +(* PMPIC.DLL *) Ord_PicPRINT = 1; Ord_PicICHG = 2; Ord_Pic32PRINT = 11; Ord_Pic32ICHG = 12; Ord_Prf32PIF2MET = 13; +(* PMSHAPI.DLL *) Ord_WinQUERYPROFILEINT = 2; Ord_WinQUERYPROFILESTRING = 3; Ord_WinWRITEPROFILESTRING = 4; @@ -1987,6 +2693,7 @@ const Ord_WinSTARTAPP = 201; Ord_WinHAPPFROMPID = 208; Ord_WinHSWITCHFROMHAPP = 209; +(* QUECALLS.DLL *) Ord_DosREADQUEUE = 1; Ord_DosPURGEQUEUE = 2; Ord_DosCLOSEQUEUE = 3; @@ -2003,6 +2710,7 @@ const Ord_Dos32WRITEQUEUE = 14; Ord_Dos32OPENQUEUE = 15; Ord_Dos32CREATEQUEUE = 16; +(* SESMGR.DLL *) Ord_DosSTOPSESSION = 8; Ord_DosSELECTSESSION = 9; Ord_DosSETSESSION = 14; @@ -2012,11 +2720,13 @@ const Ord_Dos32SELECTSESSION = 38; Ord_Dos32SETSESSION = 39; Ord_Dos32STOPSESSION = 40; + Ord_WinFONTDLG = 2; Ord_WinDEFFONTDLGPROC = 3; Ord_WinFILEDLG = 4; Ord_WinDEFFILEDLGPROC = 5; Ord_WinFREEFILEDLGLIST = 6; +(* VIOCALLS.DLL *) Ord_VioENDPOPUP = 1; Ord_VioGETPHYSBUF = 2; Ord_VioGETANSI = 3; @@ -2080,6 +2790,7 @@ const Ord_XVioCREATECA = 74; Ord_VioCHECKCHARTYPE = 75; Ord_XVioGETCASTATE = 76; +(* PMVIOP.DLL *) Ord_WinDefAVioWindowProc = 30; { Declarations from bsedev.h header file (low-level device access) } diff --git a/rtl/os2/sysdir.inc b/rtl/os2/sysdir.inc index 4688b633fd..77edff2ef7 100644 --- a/rtl/os2/sysdir.inc +++ b/rtl/os2/sysdir.inc @@ -29,6 +29,7 @@ begin begin InOutRes := Rc; Errno2Inoutres; + OSErrorWatch (RC); end; end; @@ -47,6 +48,7 @@ begin begin InOutRes := Rc; Errno2Inoutres; + OSErrorWatch (RC); end; end; @@ -63,7 +65,10 @@ begin begin RC := DosSetDefaultDisk ((Ord (S [1]) and not ($20)) - $40); if RC <> 0 then - InOutRes := RC + begin + InOutRes := RC; + OSErrorWatch (RC); + end else if Len > 2 then begin @@ -75,6 +80,7 @@ begin begin InOutRes := RC; Errno2InOutRes; + OSErrorWatch (RC); end; end; end else begin @@ -86,6 +92,7 @@ begin begin InOutRes:= RC; Errno2InOutRes; + OSErrorWatch (RC); end; end; end; @@ -97,6 +104,7 @@ procedure do_GetDir (DriveNr: byte; var Dir: RawByteString); var sof: Pchar; i:byte; l,l2:cardinal; + RC: cardinal; begin setlength(Dir,255); Dir [4] := #0; @@ -109,7 +117,13 @@ begin { TODO: if max path length is > 255, increase the setlength parameter above and the 255 below } l:=255-3; - InOutRes:=longint (DosQueryCurrentDir(DriveNr, sof^, l)); + RC := DosQueryCurrentDir(DriveNr, sof^, l); + if RC <> 0 then + begin + InOutRes := longint (RC); + Errno2Inoutres; + OSErrorWatch (RC); + end; {$WARNING Result code should be translated in some cases!} { Now Dir should be filled with directory in ASCIIZ, } { starting from dir[4] } diff --git a/rtl/os2/sysfile.inc b/rtl/os2/sysfile.inc index 5361158156..8a5795e64c 100644 --- a/rtl/os2/sysfile.inc +++ b/rtl/os2/sysfile.inc @@ -2,7 +2,7 @@ This file is part of the Free Pascal run time library. Copyright (c) 2001 by Free Pascal development team - Low leve file functions + Low level file functions See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -20,12 +20,19 @@ ****************************************************************************} procedure do_close(h:thandle); +var + RC: cardinal; begin { Only three standard handles under real OS/2 } if h>2 then - begin - InOutRes:=DosClose(h); - end; + begin + RC := DosClose (H); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; + end; {$ifdef IODEBUG} writeln('do_close: handle=', H, ', InOutRes=', InOutRes); {$endif} @@ -34,10 +41,16 @@ end; procedure do_erase(p:Pchar; pchangeable: boolean); var oldp: pchar; + RC: cardinal; begin oldp:=p; DoDirSeparators(p,pchangeable); - inoutres:=DosDelete(p); + RC := DosDelete (P); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; if p<>oldp then freemem(p); end; @@ -45,12 +58,18 @@ end; procedure do_rename(p1,p2:Pchar; p1changeable, p2changeable: boolean); var oldp1, oldp2 : pchar; + RC: cardinal; begin oldp1:=p1; oldp2:=p2; DoDirSeparators(p1,p1changeable); DoDirSeparators(p2,p2changeable); - inoutres:=DosMove(p1, p2); + RC := DosMove (p1, p2); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; if p1<>oldp1 then freemem(p1); if p2<>oldp2 then @@ -60,11 +79,17 @@ end; function do_read(h:thandle;addr:pointer;len:longint):longint; Var T: cardinal; + RC: cardinal; begin {$ifdef IODEBUG} write('do_read: handle=', h, ', addr=', ptrint(addr), ', length=', len); {$endif} - InOutRes:=DosRead(H, Addr, Len, T); + RC := DosRead(H, Addr, Len, T); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; do_read:= longint (T); {$ifdef IODEBUG} writeln(', actual_len=', t, ', InOutRes=', InOutRes); @@ -74,11 +99,17 @@ end; function do_write(h:thandle;addr:pointer;len:longint) : longint; Var T: cardinal; + RC: cardinal; begin {$ifdef IODEBUG} write('do_write: handle=', h, ', addr=', ptrint(addr), ', length=', len); {$endif} - InOutRes:=DosWrite(H, Addr, Len, T); + RC := DosWrite(H, Addr, Len, T); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; do_write:= longint (T); {$ifdef IODEBUG} writeln(', actual_len=', t, ', InOutRes=', InOutRes); @@ -88,8 +119,14 @@ end; function Do_FilePos (Handle: THandle): int64; var PosActual: int64; + RC: cardinal; begin - InOutRes := Sys_DosSetFilePtrL (Handle, 0, 1, PosActual); + RC := Sys_DosSetFilePtrL (Handle, 0, 1, PosActual); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; Do_FilePos := PosActual; {$ifdef IODEBUG} writeln('do_filepos: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes); @@ -99,8 +136,14 @@ end; procedure Do_Seek (Handle: THandle; Pos: int64); var PosActual: int64; + RC: cardinal; begin - InOutRes:=Sys_DosSetFilePtrL(Handle, Pos, 0 {ZeroBased}, PosActual); + RC := Sys_DosSetFilePtrL(Handle, Pos, 0 {ZeroBased}, PosActual); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; {$ifdef IODEBUG} writeln('do_seek: handle=', Handle, ', pos=', pos, ', actual_pos=', PosActual, ', InOutRes=', InOutRes); {$endif} @@ -109,9 +152,17 @@ end; function Do_SeekEnd (Handle: THandle): int64; var PosActual: int64; + RC: cardinal; begin - InOutRes := Sys_DosSetFilePtrL (Handle, 0, 2 {EndBased}, PosActual); - Do_SeekEnd := PosActual; + RC := Sys_DosSetFilePtrL (Handle, 0, 2 {EndBased}, PosActual); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + Do_SeekEnd := -1; + end + else + Do_SeekEnd := PosActual; {$ifdef IODEBUG} writeln('do_seekend: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes); {$endif} @@ -122,14 +173,25 @@ var AktFilePos: int64; begin AktFilePos := Do_FilePos (Handle); - Do_FileSize := Do_SeekEnd (Handle); - Do_Seek (Handle, AktFilePos); + if InOutRes = 0 then + begin + Do_FileSize := Do_SeekEnd (Handle); + Do_Seek (Handle, AktFilePos); + end; end; procedure Do_Truncate (Handle: THandle; Pos: int64); +var + RC: cardinal; begin - InOutRes := Sys_DosSetFileSizeL (Handle, Pos); - Do_SeekEnd (Handle); + RC := Sys_DosSetFileSizeL (Handle, Pos); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end + else + Do_SeekEnd (Handle); end; @@ -137,21 +199,25 @@ const FileHandleCount: cardinal = 20; function Increase_File_Handle_Count: boolean; -var Err: word; - L1: longint; +var L1: longint; L2: cardinal; + RC: cardinal; begin L1 := 10; - if DosSetRelMaxFH (L1, L2) <> 0 then - Increase_File_Handle_Count := false + RC := DosSetRelMaxFH (L1, L2); + if RC <> 0 then + begin + Increase_File_Handle_Count := false; + OSErrorWatch (RC); + end else - if L2 > FileHandleCount then + if L2 > FileHandleCount then begin FileHandleCount := L2; Increase_File_Handle_Count := true; end - else - Increase_File_Handle_Count := false; + else + Increase_File_Handle_Count := false; end; procedure do_open(var f;p:pchar;flags:longint; pchangeable: boolean); @@ -166,13 +232,13 @@ procedure do_open(var f;p:pchar;flags:longint; pchangeable: boolean); var Action, Attrib, OpenFlags, FM: Cardinal; oldp : pchar; + RC: cardinal; 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); + fminput,fmoutput,fminout : Do_Close (FileRec (F).Handle); fmclosed:; else begin @@ -228,14 +294,26 @@ begin DoDirSeparators(p,pchangeable); Attrib:=32 {faArchive}; - InOutRes:=Sys_DosOpenL(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil); + RC := Sys_DosOpenL(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; // 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:=Sys_DosOpenL(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil); - - If InOutRes<>0 then FileRec(F).Handle:=UnusedHandle; + if Increase_File_Handle_Count then + begin + RC := Sys_DosOpenL(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil); + if RC <> 0 then + begin + InOutRes := longint (RC); + OSErrorWatch (RC); + end; + end; + if RC <> 0 then + FileRec(F).Handle:=UnusedHandle; // If Handle created -> make some things if (FileRec(F).Handle <> UnusedHandle) then @@ -248,7 +326,9 @@ begin FileRec(F).Mode := fmOutput; end; - end; + end + else + FileRec(f).mode:=fmclosed; if oldp<>p then freemem(p); @@ -261,9 +341,16 @@ end; function do_isdevice (Handle: THandle): boolean; var HT, Attr: cardinal; + RC: cardinal; begin do_isdevice:=false; - If DosQueryHType(Handle, HT, Attr)<>0 then exit; - if ht=1 then do_isdevice:=true; + RC := DosQueryHType(Handle, HT, Attr); + if RC <> 0 then + begin + OSErrorWatch (RC); + Exit; + end; + if ht=1 then + do_isdevice:=true; end; {$ASMMODE ATT} diff --git a/rtl/os2/sysheap.inc b/rtl/os2/sysheap.inc index f5147bcc13..c163523fc1 100644 --- a/rtl/os2/sysheap.inc +++ b/rtl/os2/sysheap.inc @@ -1,10 +1,8 @@ { This file is part of the Free Pascal run time library. - Copyright (c) 2001 by Free Pascal development team + Copyright (c) 2001-2014 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. + This file implements heap management for OS/2. See the file COPYING.FPC, included in this distribution, for details about the copyright. @@ -87,6 +85,7 @@ begin else begin SysOSAlloc := nil; + OSErrorWatch (RC); {$IFDEF EXTDUMPGROW} if Int_HeapSize <> high (cardinal) then begin @@ -104,25 +103,23 @@ end; {$define HAS_SYSOSFREE} procedure SysOSFree (P: pointer; Size: ptruint); -{$IFDEF EXTDUMPGROW} var RC: cardinal; -{$ENDIF EXTDUMPGROW} begin {$IFDEF EXTDUMPGROW} WriteLn ('Trying to free memory!'); WriteLn ('Total allocated memory is ', Int_HeapSize); Dec (Int_HeapSize, Size); - RC := {$ENDIF EXTDUMPGROW} - DosFreeMem (P); -{$IFDEF EXTDUMPGROW} + RC := DosFreeMem (P); if RC <> 0 then begin + OSErrorWatch (RC); +{$IFDEF EXTDUMPGROW} WriteLn ('Error ', RC, ' during memory deallocation (DosFreeMem)!'); WriteLn ('Total allocated memory is ', Int_HeapSize); - end; {$ENDIF EXTDUMPGROW} + end; end; diff --git a/rtl/os2/sysos.inc b/rtl/os2/sysos.inc index ab3edc5a60..cb7dc74a04 100644 --- a/rtl/os2/sysos.inc +++ b/rtl/os2/sysos.inc @@ -54,7 +54,7 @@ type var ProcessID: SizeUInt; -function GetProcessID:SizeUInt; +function GetProcessID: SizeUInt; begin GetProcessID := ProcessID; end; @@ -79,7 +79,7 @@ procedure DosGetInfoBlocks (PATIB: PPThreadInfoBlock; external 'DOSCALLS' index 312; function DosLoadModule (ObjName: PChar; ObjLen: cardinal; DLLName: PChar; - var Handle: cardinal): cardinal; cdecl; + var Handle: THandle): cardinal; cdecl; external 'DOSCALLS' index 318; function DosQueryModuleHandle (DLLName: PChar; var Handle: THandle): cardinal; @@ -420,3 +420,32 @@ external 'DOSCALLS' index 306; function DosQuerySysInfo (First, Last: cardinal; var Buf; BufSize: cardinal): cardinal; cdecl; external 'DOSCALLS' index 348; + +type + TCPArray = array [0..2] of cardinal; + PCPArray = ^TCPArray; + +function DosQueryCP (Size: cardinal; CodePages: PCPArray; + var ActSize: cardinal): cardinal; cdecl; +external 'DOSCALLS' index 291; + +function DosSetProcessCP (CP: cardinal): cardinal; cdecl; +external 'DOSCALLS' index 289; + +type + TCountryCode = record + Country, {Country to query info about (0=current).} + CodePage: cardinal; {Code page to query info about (0=current).} + end; + +function DosMapCase (Size: cardinal; var Country: TCountryCode; + AString: PChar): cardinal; cdecl; +external 'NLS' index 7; + +function DosQueryDBCSEnv (Size: cardinal; var Country: TCountryCode; + Buf: PChar): cardinal; cdecl; +external 'NLS' index 6; + +function DosQueryCollate (Size: cardinal; var Country: TCountryCode; + Buf: PByteArray; var TableLen: cardinal): cardinal; cdecl; +external 'NLS' index 8; diff --git a/rtl/os2/system.pas b/rtl/os2/system.pas index e0b55edcdc..9557b374d1 100644 --- a/rtl/os2/system.pas +++ b/rtl/os2/system.pas @@ -27,6 +27,7 @@ interface {$endif SYSTEMDEBUG} {$DEFINE OS2EXCEPTIONS} +{$DEFINE OS2UNICODE} {$define DISABLE_NO_THREAD_MANAGER} {$DEFINE HAS_GETCPUCOUNT} @@ -51,23 +52,30 @@ const RealMaxPathLen: word = MaxPathLen; (* Default value only - real value queried from the system on startup. *) -type Tos=(osDOS,osOS2,osDPMI); +type + TOS = (osDOS, osOS2, osDPMI); (* For compatibility with target EMX *) + TUConvObject = pointer; + TLocaleObject = pointer; -const OS_Mode: Tos = osOS2; - First_Meg: pointer = nil; +const + OS_Mode: TOS = osOS2; (* For compatibility with target EMX *) + First_Meg: pointer = nil; (* For compatibility with target EMX *) -const UnusedHandle=-1; - StdInputHandle=0; - StdOutputHandle=1; - StdErrorHandle=2; + UnusedHandle=-1; + StdInputHandle=0; + StdOutputHandle=1; + StdErrorHandle=2; - LFNSupport: boolean = true; - FileNameCaseSensitive: boolean = false; - FileNameCasePreserving: boolean = true; - CtrlZMarksEOF: boolean = true; (* #26 is considered as end of file *) + LFNSupport: boolean = true; + FileNameCaseSensitive: boolean = false; + FileNameCasePreserving: boolean = true; + CtrlZMarksEOF: boolean = true; (* #26 is considered as end of file *) + RTLUsesWinCP: boolean = true; (* UnicodeString manager shall treat *) +(* codepage numbers passed to RTL functions as those used under MS Windows *) +(* and translates them to their OS/2 equivalents if necessary. *) - sLineBreak = LineEnding; - DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; + sLineBreak = LineEnding; + DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF; var { C-compatible arguments and environment } @@ -90,26 +98,61 @@ var ApplicationType: cardinal; const - HeapAllocFlags: cardinal = $53; (* Compatible to VP/2 *) - (* mfPag_Commit or mfObj_Tile or mfPag_Write or mfPag_Read *) + HeapAllocFlags: cardinal = $53; (* Compatible to VP/2 *) + (* mfPag_Commit or mfObj_Tile or mfPag_Write or mfPag_Read *) function ReadUseHighMem: boolean; procedure WriteUseHighMem (B: boolean); -(* Is allocation of memory above 512 MB address limit allowed? Initialized *) -(* during initialization of system unit according to capabilities of the *) -(* underlying OS/2 version, can be overridden by user - heap is allocated *) -(* for all threads, so the setting isn't declared as a threadvar and *) -(* should be only changed at the beginning of the main thread if needed. *) +(* Is allocation of memory above 512 MB address limit allowed? Even if use *) +(* of high memory is supported by the underlying OS/2 version, just a subset *) +(* of OS/2 API functions can work with memory buffers located in high *) +(* memory. Since FPC RTL allocates heap using memory pools received from *) +(* the operating system and thus memory allocation from the operating system *) +(* may happen at a different time than allocation of memory from FPC heap, *) +(* use of high memory shall be enabled only if the given program is ensured *) +(* not to use any OS/2 API function beyond the limited set supporting it any *) +(* time between enabling this feature and program termination. *) property UseHighMem: boolean read ReadUseHighMem write WriteUseHighMem; (* UseHighMem is provided for compatibility with 2.0.x. *) + +{$IFDEF OS2UNICODE} +function OS2CPtoRtlCP (CP: cardinal; ReqFlags: byte; + var UConvObj: TUConvObject): TSystemCodepage; + +function RtlCPtoOS2CP (RtlCP: TSystemCodepage; ReqFlags: byte; + var UConvObj: TUConvObject): cardinal; + +function OS2CPtoRtlCP (CP: cardinal; ReqFlags: byte): TSystemCodepage; + +function RtlCPtoOS2CP (RtlCP: TSystemCodepage; ReqFlags: byte): cardinal; + +(* function RtlChangeCP (CP: TSystemCodePage; const stdcp: TStandardCodePageEnum): longint; *) +{$ENDIF OS2UNICODE} + + const (* Are file sizes > 2 GB (64-bit) supported on the current system? *) FSApi64: boolean = false; + UniAPI: boolean = false; + +(* Support for tracking I/O errors returned by OS/2 API calls - emulation *) +(* of GetLastError / fpGetError functionality used e.g. in Sysutils. *) +type + TOSErrorWatch = procedure (Error: cardinal); + +procedure NoErrorTracking (Error: cardinal); + +(* This shall be invoked whenever a non-zero error is returned by OS/2 APIs *) +(* used in the RTL. Direct OS/2 API calls in user programs are not covered! *) +const + OSErrorWatch: TOSErrorWatch = @NoErrorTracking; + +function SetOSErrorTracking (P: pointer): pointer; procedure SetDefaultOS2FileType (FType: ShortString); @@ -127,21 +170,62 @@ type TDosSetFileSizeL = function (Handle: THandle; Size: int64): cardinal; cdecl; -function DummyDosOpenL (FileName: PChar; var Handle: THandle; - var Action: cardinal; InitSize: int64; - Attrib, OpenFlags, FileMode: cardinal; - EA: pointer): cardinal; cdecl; + TUniCreateUConvObject = function (const CpName: PWideChar; + var UConv_Object: TUConvObject): longint; cdecl; -function DummyDosSetFilePtrL (Handle: THandle; Pos: int64; Method: cardinal; - var PosActual: int64): cardinal; cdecl; + TUniFreeUConvObject = function (UConv_Object: TUConvObject): longint; cdecl; + + TUniMapCpToUcsCp = function (const Codepage: cardinal; + CodepageName: PWideChar; const N: cardinal): longint; cdecl; + + TUniUConvFromUcs = function (UConv_Object: TUConvObject; + var UcsBuf: PWideChar; var UniCharsLeft: longint; var OutBuf: PChar; + var OutBytesLeft: longint; var NonIdentical: longint): longint; cdecl; + + TUniUConvToUcs = function (UConv_Object: TUConvObject; var InBuf: PChar; + var InBytesLeft: longint; var UcsBuf: PWideChar; var UniCharsLeft: longint; + var NonIdentical: longint): longint; cdecl; -function DummyDosSetFileSizeL (Handle: THandle; Size: int64): cardinal; cdecl; + TUniToLower = function (UniCharIn: WideChar): WideChar; cdecl; + + TUniToUpper = function (UniCharIn: WideChar): WideChar; cdecl; + + TUniStrColl = function (Locale_Object: TLocaleObject; + const UCS1, UCS2: PWideChar): longint; cdecl; + + TUniCreateLocaleObject = function (LocaleSpecType: longint; + const LocaleSpec: pointer; + var Locale_Object: TLocaleObject): longint; cdecl; + + TUniFreeLocaleObject = function (Locale_Object: TLocaleObject): longint; + cdecl; const - Sys_DosOpenL: TDosOpenL = @DummyDosOpenL; - Sys_DosSetFilePtrL: TDosSetFilePtrL = @DummyDosSetFilePtrL; - Sys_DosSetFileSizeL: TDosSetFileSizeL = @DummyDosSetFileSizeL; + DosCallsHandle: THandle = THandle (-1); +{$IFDEF OS2UNICODE} + UConvHandle: THandle = THandle (-1); + LibUniHandle: THandle = THandle (-1); +{$ENDIF OS2UNICODE} + + +var + Sys_DosOpenL: TDosOpenL; + Sys_DosSetFilePtrL: TDosSetFilePtrL; + Sys_DosSetFileSizeL: TDosSetFileSizeL; +{$IFDEF OS2UNICODE} + Sys_UniCreateUConvObject: TUniCreateUConvObject; + Sys_UniFreeUConvObject: TUniFreeUConvObject; + Sys_UniMapCpToUcsCp: TUniMapCpToUcsCp; + Sys_UniUConvFromUcs: TUniUConvFromUcs; + Sys_UniUConvToUcs: TUniUConvToUcs; + Sys_UniToLower: TUniToLower; + Sys_UniToUpper: TUniToUpper; + Sys_UniStrColl: TUniStrColl; + Sys_UniCreateLocaleObject: TUniCreateLocaleObject; + Sys_UniFreeLocaleObject: TUniFreeLocaleObject; + +{$ENDIF OS2UNICODE} implementation @@ -174,12 +258,15 @@ function Is_Prefetch (P: pointer): boolean; InstrLo, InstrHi, OpCode: byte; I: longint; MemSize, MemAttrs: cardinal; + RC: cardinal; begin Is_Prefetch := false; MemSize := SizeOf (A); - if (DosQueryMem (P, MemSize, MemAttrs) = 0) and - (MemAttrs and (mfPag_Free or mfPag_Commit) <> 0) + RC := DosQueryMem (P, MemSize, MemAttrs); + if RC <> 0 then + OSErrorWatch (RC) + else if (MemAttrs and (mfPag_Free or mfPag_Commit) <> 0) and (MemSize >= SizeOf (A)) then Move (P^, A [0], SizeOf (A)) else @@ -289,6 +376,7 @@ var Res: cardinal; Err: byte; Must_Reset_FPU: boolean; + RC: cardinal; {$IFDEF SYSTEMEXCEPTIONDEBUG} CurSS: cardinal; B: byte; @@ -382,7 +470,9 @@ begin {$ENDIF SYSTEMEXCEPTIONDEBUG} Report^.Exception_Num := 0; Res := Xcpt_Continue_Execution; - DosAcknowledgeSignalException (Report^.Parameters [0]); + RC := DosAcknowledgeSignalException (Report^.Parameters [0]); + if RC <> 0 then + OSErrorWatch (RC); end else Err := 217; @@ -443,7 +533,9 @@ begin {$ENDIF SYSTEMEXCEPTIONDEBUG} Report^.Exception_Num := 0; Res := Xcpt_Continue_Execution; - DosAcknowledgeSignalException (Report^.Parameters [0]); + RC := DosAcknowledgeSignalException (Report^.Parameters [0]); + if RC <> 0 then + OSErrorWatch (RC); end else Err := 217; @@ -504,6 +596,7 @@ var procedure Install_Exception_Handler; var T: cardinal; + RC: cardinal; begin {$ifdef SYSTEMEXCEPTIONDEBUG} (* ThreadInfoBlock is located at FS:[0], the first *) @@ -524,9 +617,15 @@ begin DosSetExceptionHandler (ExcptReg^); if IsConsole then begin - DosSetSignalExceptionFocus (1, T); - DosAcknowledgeSignalException (Xcpt_Signal_Intr); - DosAcknowledgeSignalException (Xcpt_Signal_Break); + RC := DosSetSignalExceptionFocus (1, T); + if RC <> 0 then + OSErrorWatch (RC); + RC := DosAcknowledgeSignalException (Xcpt_Signal_Intr); + if RC <> 0 then + OSErrorWatch (RC); + RC := DosAcknowledgeSignalException (Xcpt_Signal_Break); + if RC <> 0 then + OSErrorWatch (RC); end; {$ifdef SYSTEMEXCEPTIONDEBUG} asm @@ -538,8 +637,11 @@ begin end; procedure Remove_Exception_Handlers; +var + RC: cardinal; begin - DosUnsetExceptionHandler (ExcptReg^); + RC := DosUnsetExceptionHandler (ExcptReg^); + OSErrorWatch (RC); end; {$ENDIF OS2EXCEPTIONS} @@ -686,6 +788,10 @@ begin end; procedure SysInitStdIO; +(* +var + RC: cardinal; +*) begin { Setup stdin, stdout and stderr, for GUI apps redirect stderr,stdout to be displayed in a messagebox } @@ -695,21 +801,36 @@ begin StdErrorHandle := longint(GetStdHandle(cardinal(STD_ERROR_HANDLE))); if not IsConsole then - begin - if (DosLoadModule (nil, 0, 'PMWIN', PMWinHandle) = 0) and - (DosQueryProcAddr (PMWinHandle, 789, nil, pointer (WinMessageBox)) = 0) - and - (DosQueryProcAddr (PMWinHandle, 763, nil, pointer (WinInitialize)) = 0) - and - (DosQueryProcAddr (PMWinHandle, 716, nil, pointer (WinCreateMsgQueue)) - = 0) - then - begin + begin + RC := DosLoadModule (nil, 0, 'PMWIN', PMWinHandle); + if RC <> 0 then + OSErrorWatch (RC) + else + begin + RC := DosQueryProcAddr (PMWinHandle, 789, nil, pointer (WinMessageBox)); + if RC <> 0 then + OSErrorWatch (RC) + else + begin + RC := DosQueryProcAddr (PMWinHandle, 763, nil, pointer (WinInitialize)); + if RC <> 0 then + OSErrorWatch (RC) + else + begin + RC := DosQueryProcAddr (PMWinHandle, 716, nil, pointer (WinCreateMsgQueue)); + if RC <> 0 then + OSErrorWatch (RC) + else + begin WinInitialize (0); WinCreateMsgQueue (0, 0); - end - else - HandleError (2); + end + end + end + end; + if RC <> 0 then + HandleError (2); + AssignError (StdErr); AssignError (StdOut); Assign (Output, ''); @@ -824,9 +945,25 @@ begin end; +(* The default handler does not store the OS/2 API error codes. *) +procedure NoErrorTracking (Error: cardinal); +begin +end; + + +function SetOSErrorTracking (P: pointer): pointer; +begin + SetOSErrorTracking := OSErrorWatch; + if P = nil then + OSErrorWatch := @NoErrorTracking + else + OSErrorWatch := TOSErrorWatch (P); +end; + + procedure InitEnvironment; var env_count : longint; - dos_env,cp : pchar; + cp : pchar; begin env_count:=0; cp:=environment; @@ -870,14 +1007,15 @@ var pc,arg : pchar; quote : char; argvlen : PtrInt; + RC: cardinal; procedure allocarg(idx,len: PtrInt); - var - oldargvlen : PtrInt; +{ var + oldargvlen : PtrInt;} begin if idx>=argvlen then begin - oldargvlen:=argvlen; +{ oldargvlen:=argvlen;} argvlen:=(idx+8) and (not 7); sysreallocmem(argv,argvlen*sizeof(pointer)); { fillchar(argv[oldargvlen],(argvlen-oldargvlen)*sizeof(pointer),0);} @@ -896,7 +1034,8 @@ begin ArgLen := StrLen (PChar (PIB^.Cmd)); Inc (ArgLen); - if DosQueryModuleName (PIB^.Handle, MaxPathLen, CmdLine) = 0 then + RC := DosQueryModuleName (PIB^.Handle, MaxPathLen, CmdLine); + if RC = 0 then ArgVLen := Succ (StrLen (CmdLine)) else (* Error occurred - use program name from command line as fallback. *) @@ -1070,10 +1209,17 @@ end; function GetFileHandleCount: longint; var L1: longint; L2: cardinal; + RC: cardinal; begin L1 := 0; (* Don't change the amount, just check. *) - if DosSetRelMaxFH (L1, L2) <> 0 then GetFileHandleCount := 50 - else GetFileHandleCount := L2; + RC := DosSetRelMaxFH (L1, L2); + if RC <> 0 then + begin + GetFileHandleCount := 50; + OSErrorWatch (RC); + end + else + GetFileHandleCount := L2; end; function CheckInitialStkLen (StkLen: SizeUInt): SizeUInt; @@ -1081,144 +1227,165 @@ begin CheckInitialStkLen := StkLen; end; -var TIB: PThreadInfoBlock; - RC: cardinal; - ErrStr: string; - P: pointer; - DosCallsHandle: THandle; - DW: cardinal; +var + TIB: PThreadInfoBlock; + RC: cardinal; + P: pointer; + DW: cardinal; const - DosCallsName: array [0..8] of char = 'DOSCALLS'#0; + DosCallsName: array [0..8] of char = 'DOSCALLS'#0; {$IFDEF OS2UNICODE} - {$I sysucode.inc} + {$I sysucode.inc} {$ENDIF OS2UNICODE} -{*var} -{* ST: pointer;} -{*} begin {$IFDEF OS2EXCEPTIONS} -(* asm - { allocate space for exception registration record } - pushl $0 - pushl $0} -{* pushl %fs:(0)} - { movl %esp,%fs:(0) - but don't insert it as it doesn't - point to anything yet - this will be used in signals unit } - movl %esp,%eax - movl %eax,ExcptReg - pushl %ebp - movl %esp,%eax -{* movl %eax,st*} - movl %eax,StackTop - end; -{* StackTop:=st;} -*) asm - xorl %eax,%eax - movw %ss,%ax - movl %eax,_SS - end; + asm + xorl %eax,%eax + movw %ss,%ax + movl %eax,_SS + end; {$ENDIF OS2EXCEPTIONS} - DosGetInfoBlocks (@TIB, @PIB); - StackLength := CheckInitialStkLen (InitialStkLen); - { OS/2 has top of stack in TIB^.StackLimit - unlike Windows where it is in TIB^.Stack } - StackBottom := TIB^.StackLimit - StackLength; + DosGetInfoBlocks (@TIB, @PIB); + StackLength := CheckInitialStkLen (InitialStkLen); + { OS/2 has top of stack in TIB^.StackLimit - unlike Windows where it is in TIB^.Stack } + StackBottom := TIB^.StackLimit - StackLength; - {Set type of application} - ApplicationType := PIB^.ProcType; - ProcessID := PIB^.PID; - ThreadID := TIB^.TIB2^.TID; - IsConsole := ApplicationType <> 3; + {Set type of application} + ApplicationType := PIB^.ProcType; + ProcessID := PIB^.PID; + ThreadID := TIB^.TIB2^.TID; + IsConsole := ApplicationType <> 3; - {Query maximum path length (QSV_MAX_PATH_LEN = 1)} - if DosQuerySysInfo (1, 1, DW, SizeOf (DW)) = 0 then - RealMaxPathLen := DW; + {Query maximum path length (QSV_MAX_PATH_LEN = 1)} + if DosQuerySysInfo (1, 1, DW, SizeOf (DW)) = 0 then + RealMaxPathLen := DW; - ExitProc := nil; + ExitProc := nil; {$IFDEF OS2EXCEPTIONS} - Install_Exception_Handler; + Install_Exception_Handler; {$ENDIF OS2EXCEPTIONS} - (* Initialize the amount of file handles *) - FileHandleCount := GetFileHandleCount; - - {Initialize the heap.} - (* Logic is following: - The heap is initially restricted to low address space (< 512 MB). - If underlying OS/2 version allows using more than 512 MB per process - (OS/2 WarpServer for e-Business, eComStation, possibly OS/2 Warp 4.0 - with FP13 and above as well), use of this high memory is allowed for - future memory allocations at the end of System unit initialization. - The consequences are that the compiled application can allocate more - memory, but it must make sure to use direct DosAllocMem calls if it - needs a memory block for some system API not supporting high memory. - This is probably no problem for direct calls to these APIs, but - there might be situations when a memory block needs to be passed - to a 3rd party DLL which in turn calls such an API call. In case - of problems usage of high memory can be turned off by setting - UseHighMem to false - the program should change the setting at its - very beginning (e.g. in initialization section of the first unit - listed in the "uses" section) to avoid having preallocated memory - from the high memory region before changing value of this variable. *) - InitHeap; - - if DosQueryModuleHandle (@DosCallsName [0], DosCallsHandle) = 0 then - begin - if DosQueryProcAddr (DosCallsHandle, OrdDosOpenL, nil, P) = 0 then - begin - Sys_DosOpenL := TDosOpenL (P); - if DosQueryProcAddr (DosCallsHandle, OrdDosSetFilePtrL, nil, P) = 0 - then - begin - Sys_DosSetFilePtrL := TDosSetFilePtrL (P); - if DosQueryProcAddr (DosCallsHandle, OrdDosSetFileSizeL, nil, - P) = 0 then - begin - Sys_DosSetFileSizeL := TDosSetFileSizeL (P); - FSApi64 := true; - end; - end; - end; - end; + (* Initialize the amount of file handles *) + FileHandleCount := GetFileHandleCount; + + {Initialize the heap.} + (* Logic is following: + The heap is initially restricted to low address space (< 512 MB). + If underlying OS/2 version allows using more than 512 MB per process + (OS/2 WarpServer for e-Business, eComStation, possibly OS/2 Warp 4.0 + with FP13 and above as well), use of this high memory is allowed for + future memory allocations at the end of System unit initialization. + The consequences are that the compiled application can allocate more + memory, but it must make sure to use direct DosAllocMem calls if it + needs a memory block for some system API not supporting high memory. + This is probably no problem for direct calls to these APIs, but + there might be situations when a memory block needs to be passed + to a 3rd party DLL which in turn calls such an API call. In case + of problems usage of high memory can be turned off by setting + UseHighMem to false - the program should change the setting at its + very beginning (e.g. in initialization section of the first unit + listed in the "uses" section) to avoid having preallocated memory + from the high memory region before changing value of this variable. *) + InitHeap; + + Sys_DosOpenL := @DummyDosOpenL; + Sys_DosSetFilePtrL := @DummyDosSetFilePtrL; + Sys_DosSetFileSizeL := @DummyDosSetFileSizeL; + RC := DosQueryModuleHandle (@DosCallsName [0], DosCallsHandle); + if RC = 0 then + begin + RC := DosQueryProcAddr (DosCallsHandle, OrdDosOpenL, nil, P); + if RC = 0 then + begin + Sys_DosOpenL := TDosOpenL (P); + RC := DosQueryProcAddr (DosCallsHandle, OrdDosSetFilePtrL, nil, P); + if RC = 0 then + begin + Sys_DosSetFilePtrL := TDosSetFilePtrL (P); + RC := DosQueryProcAddr (DosCallsHandle, OrdDosSetFileSizeL, nil, P); + if RC = 0 then + begin + Sys_DosSetFileSizeL := TDosSetFileSizeL (P); + FSApi64 := true; + end; + end; + end; + if RC <> 0 then + OSErrorWatch (RC); + RC := DosQueryProcAddr (DosCallsHandle, OrdDosAllocThreadLocalMemory, + nil, P); + if RC = 0 then + begin + DosAllocThreadLocalMemory := TDosAllocThreadLocalMemory (P); + RC := DosQueryProcAddr (DosCallsHandle, OrdDosAllocThreadLocalMemory, + nil, P); + if RC = 0 then + begin + DosFreeThreadLocalMemory := TDosFreeThreadLocalMemory (P); + TLSAPISupported := true; + end + else + OSErrorWatch (RC); + end + else + OSErrorWatch (RC); + end + else + OSErrorWatch (RC); - { ... and exceptions } - SysInitExceptions; - fpc_cpucodeinit; + { ... and exceptions } + SysInitExceptions; + fpc_cpucodeinit; - InitUnicodeStringManager; -{$ifdef OS2UCODE} - InitOS2WideStrings; -{$endif OS2UCODE} + InitUnicodeStringManager; - { ... and I/O } - SysInitStdIO; +{$IFDEF OS2UNICODE} + InitOS2WideStringManager; - { no I/O-Error } - inoutres:=0; + InitDefaultCP; +{$ELSE OS2UNICODE} +(* Otherwise called within InitDefaultCP... *) + RC := DosQueryCP (SizeOf (CPArr), @CPArr, ReturnedSize); + if (RC <> 0) and (RC <> 473) then + begin + OSErrorWatch (RC); + CPArr [0] := 850; + end + else if (ReturnedSize < 4) then + CPArr [0] := 850; + DefaultFileSystemCodePage := CPArr [0]; +{$ENDIF OS2UNICODE} + DefaultSystemCodePage := DefaultFileSystemCodePage; + DefaultRTLFileSystemCodePage := DefaultFileSystemCodePage; + DefaultUnicodeCodePage := CP_UTF16; + + { ... and I/O } + SysInitStdIO; - {Initialize environment (must be after InitHeap because allocates memory)} - Environment := pointer (PIB^.Env); - InitEnvironment; + { no I/O-Error } + InOutRes:=0; - InitArguments; + {Initialize environment (must be after InitHeap because allocates memory)} + Environment := pointer (PIB^.Env); + InitEnvironment; - DefaultCreator := ''; - DefaultFileType := ''; + InitArguments; - InitSystemThreads; - InitVariantManager; + DefaultCreator := ''; + DefaultFileType := ''; + + InitSystemThreads; {$IFDEF EXTDUMPGROW} { Int_HeapSize := high (cardinal);} {$ENDIF EXTDUMPGROW} {$ifdef SYSTEMEXCEPTIONDEBUG} - if IsConsole then - WriteLn (StdErr, 'Old exception ', HexStr (OldExceptAddr, 8), + if IsConsole then + WriteLn (StdErr, 'Old exception ', HexStr (OldExceptAddr, 8), ', new exception ', HexStr (NewExceptAddr, 8), ', _SS = ', HexStr (_SS, 8)); {$endif SYSTEMEXCEPTIONDEBUG} end. diff --git a/rtl/os2/systhrd.inc b/rtl/os2/systhrd.inc index 61f976f460..f798eff510 100644 --- a/rtl/os2/systhrd.inc +++ b/rtl/os2/systhrd.inc @@ -1,6 +1,6 @@ { This file is part of the Free Pascal run time library. - Copyright (c) 2002-2011 by Tomas Hajny, + Copyright (c) 2002-2014 by Tomas Hajny, member of the Free Pascal development team. OS/2 threading support implementation @@ -18,6 +18,9 @@ Local Api imports *****************************************************************************} +var + OS2ThreadManager: TThreadManager; + const pag_Read = 1; pag_Write = 2; @@ -98,12 +101,27 @@ type PFSRec: pointer; end; + TDosAllocThreadLocalMemory = function (Count: cardinal; var P: pointer): + cardinal; cdecl; + + TDosFreeThreadLocalMemory = function (P: pointer): cardinal; cdecl; + + +const + DosAllocThreadLocalMemory: TDosAllocThreadLocalMemory = nil; + DosFreeThreadLocalMemory: TDosFreeThreadLocalMemory = nil; + OrdDosAllocThreadLocalMemory = 454; + OrdDosFreeThreadLocalMemory = 455; + TLSAPISupported: boolean = false; + { import the necessary stuff from the OS } +(* function DosAllocThreadLocalMemory (Count: cardinal; var P: pointer): cardinal; cdecl; external 'DOSCALLS' index 454; function DosFreeThreadLocalMemory (P: pointer): cardinal; cdecl; external 'DOSCALLS' index 455; +*) function DosCreateThread (var TID: cardinal; Address: pointer; (* TThreadFunc *) @@ -177,16 +195,24 @@ function DosQuerySysState (EntityList, EntityLevel, PID, TID: cardinal; *****************************************************************************} const - ThreadVarBlockSize: dword = 0; + ThreadVarBlockSize: dword = 0; const (* Pointer to an allocated dword space within the local thread *) (* memory area. Pointer to the real memory block allocated for *) (* thread vars in this block is then stored in this dword. *) - DataIndex: PPointer = nil; + DataIndex: PPointer = nil; +type +(* If Thread Local Memory Area (TLMA) and the respective API functions are *) +(* not available (OS/2 version 2.x) then handle the memory using array *) +(* of pointers indexed by Thread ID - pointer to this array is then stored *) +(* in DataIndex (typecasted using the following types). *) + TTLSPointers = array [0..4095] of pointer; + PTLSPointers = ^TTLSPointers; + procedure SysInitThreadvar (var Offset: dword; Size: dword); begin Offset := ThreadVarBlockSize; @@ -195,36 +221,67 @@ end; procedure SysAllocateThreadVars; +var + RC: cardinal; begin { we've to allocate the memory from the OS } { because the FPC heap management uses } { exceptions which use threadvars but } { these aren't allocated yet ... } { allocate room on the heap for the thread vars } - if DosAllocMem (DataIndex^, ThreadVarBlockSize, pag_Read or pag_Write - or pag_Commit) <> 0 then - HandleError (8); + if TLSAPISupported then + RC := DosAllocMem (DataIndex^, ThreadVarBlockSize, pag_Read or pag_Write + or pag_Commit) + else + begin + if PTLSPointers (DataIndex)^ [ThreadID] <> nil then + begin + RC := DosFreeMem (PTLSPointers (DataIndex)^ [ThreadID]); + if RC <> 0 then + OSErrorWatch (RC); + end; + RC := DosAllocMem (PTLSPointers (DataIndex)^ [ThreadID], ThreadVarBlockSize, + pag_Read or pag_Write or pag_Commit); + end; + if RC <> 0 then + begin + OSErrorWatch (RC); + HandleError (8); + end; { The Windows API apparently provides a way to fill the allocated memory with } { zeros; we probably need to do it ourselves for compatibility. } FillChar (DataIndex^^, 0, ThreadVarBlockSize); end; - function SysRelocateThreadVar (Offset: dword): pointer; begin { DataIndex itself not checked for not being nil - expected that this should } { not be necessary because the equivalent check (i.e. TlsKey not being set) } -{ is note performed by the Windows implementation. } - if DataIndex^ = nil then +{ is not performed by the Windows implementation. } + if PTLSPointers (DataIndex)^ [ThreadID] = nil then begin SysAllocateThreadVars; InitThread ($1000000); end; - SysRelocateThreadVar := DataIndex^ + Offset; + SysRelocateThreadVar := PTLSPointers (DataIndex)^ [ThreadID] + Offset; end; +function OS2RelocateThreadVar (Offset: dword): pointer; +begin +{ DataIndex itself not checked for not being nil - expected that this should } +{ not be necessary because the equivalent check (i.e. TlsKey not being set) } +{ is not performed by the Windows implementation. } + if DataIndex^ = nil then + begin + SysAllocateThreadVars; + InitThread ($1000000); + end; + OS2RelocateThreadVar := DataIndex^ + Offset; +end; procedure SysInitMultithreading; +var + RC: cardinal; begin { do not check IsMultiThread, as program could have altered it, out of Delphi habit } @@ -232,20 +289,49 @@ begin if DataIndex = nil then begin { We're still running in single thread mode, setup the TLS } - if DosAllocThreadLocalMemory (1, DataIndex) <> 0 then RunError (8); - InitThreadVars (@SysRelocateThreadvar); + RC := DosAllocThreadLocalMemory (1, DataIndex); + if RC = 0 then + begin +(* Avoid the need for checking TLSAPISupported on every call *) +(* to RelocateThreadVar - ensure using the right version. *) + OS2ThreadManager.RelocateThreadVar := @OS2RelocateThreadVar; + CurrentTM.RelocateThreadVar := @OS2RelocateThreadVar; + InitThreadVars (@OS2RelocateThreadvar); + end + else + begin + OSErrorWatch (RC); +(* We can still try using the internal solution for older OS/2 versions... *) + TLSAPISupported := false; + RC := DosAllocMem (DataIndex, SizeOf (TTLSPointers), + pag_Read or pag_Write or pag_Commit); + if RC = 0 then + InitThreadVars (@SysRelocateThreadvar) + else + begin + OSErrorWatch (RC); + RunError (8); + end; + end; IsMultiThread := true; end; end; procedure SysFiniMultithreading; +var + RC: cardinal; begin if IsMultiThread then begin - if DosFreeThreadLocalMemory (DataIndex) <> 0 then + if TLSAPISupported then + RC := DosFreeThreadLocalMemory (DataIndex) + else + RC := DosFreeMem (DataIndex); + if RC <> 0 then begin {??? What to do if releasing fails?} + OSErrorWatch (RC); end; DataIndex := nil; end; @@ -253,9 +339,25 @@ end; procedure SysReleaseThreadVars; -begin - DosFreeMem (DataIndex^); - DataIndex^ := nil; +var + RC: cardinal; +(* TID serves for storing ThreadID before freeing the memory allocated *) +(* to threadvars to avoid accessing a threadvar ThreadID afterwards. *) + TID: cardinal; +begin + if TLSAPISupported then + begin + RC := DosFreeMem (DataIndex^); + DataIndex^ := nil; + end + else + begin + TID := ThreadID; + RC := DosFreeMem (PTLSPointers (DataIndex)^ [TID]); + PTLSPointers (DataIndex)^ [TID] := nil; + end; + if RC <> 0 then + OSErrorWatch (RC); end; @@ -334,6 +436,7 @@ function SysBeginThread (SA: pointer; StackSize : PtrUInt; CreationFlags: cardinal; var ThreadId: TThreadID): DWord; var TI: PThreadInfo; + RC: cardinal; begin { WriteLn is not a good idea before thread initialization... $ifdef DEBUG_MT @@ -351,8 +454,9 @@ begin {$ifdef DEBUG_MT} WriteLn ('Starting new thread'); {$endif DEBUG_MT} - if DosCreateThread (cardinal (ThreadID), @ThreadMain, TI, - CreationFlags, StackSize) = 0 then + RC := DosCreateThread (cardinal (ThreadID), @ThreadMain, TI, + CreationFlags, StackSize); + if RC = 0 then SysBeginThread := ThreadID else begin @@ -361,6 +465,7 @@ begin WriteLn ('Thread creation failed'); {$ENDIF DEBUG_MT} Dispose (TI); + OSErrorWatch (RC); end; end; @@ -379,40 +484,62 @@ end; function SysSuspendThread (ThreadHandle: dword): dword; +var + RC: cardinal; begin {$WARNING Check expected return value} - SysSuspendThread := DosSuspendThread (ThreadHandle); + RC := DosSuspendThread (ThreadHandle); + SysSuspendThread := RC; + if RC <> 0 then + OSErrorWatch (RC); end; function SysResumeThread (ThreadHandle: dword): dword; +var + RC: cardinal; begin {$WARNING Check expected return value} - SysResumeThread := DosResumeThread (ThreadHandle); + RC := DosResumeThread (ThreadHandle); + SysResumeThread := RC; + if RC <> 0 then + OSErrorWatch (RC); end; function SysKillThread (ThreadHandle: dword): dword; +var + RC: cardinal; begin - SysKillThread := DosKillThread (ThreadHandle); + RC := DosKillThread (ThreadHandle); + SysKillThread := RC; + if RC <> 0 then + OSErrorWatch (RC); end; +{$PUSH} +{$WARNINGS OFF} function SysCloseThread (ThreadHandle: TThreadID): dword; begin { Probably not relevant under OS/2? } // SysCloseThread:=CloseHandle(threadHandle); end; +{$POP} function SysWaitForThreadTerminate (ThreadHandle: dword; TimeoutMs: longint): dword; var - RC: cardinal; + RC, RC2: cardinal; const { Wait at most 100 ms before next check for thread termination } WaitTime = 100; begin if TimeoutMs = 0 then - RC := DosWaitThread (ThreadHandle, dcWW_Wait) + begin + RC := DosWaitThread (ThreadHandle, dcWW_Wait); + if RC <> 0 then + OSErrorWatch (RC); + end else repeat RC := DosWaitThread (ThreadHandle, dcWW_NoWait); @@ -423,10 +550,14 @@ begin else begin DosSleep (TimeoutMs); - DosWaitThread (ThreadHandle, dcWW_NoWait); + RC2 := DosWaitThread (ThreadHandle, dcWW_NoWait); + if RC2 <> 0 then + OSErrorWatch (RC2); end; Dec (TimeoutMs, WaitTime); - end; + end + else if RC <> 0 then + OSErrorWatch (RC); until (RC <> 294) or (TimeoutMs <= 0); SysWaitForThreadTerminate := RC; end; @@ -451,7 +582,9 @@ begin else begin RC := DosQuerySysState (qs_Process, 0, ProcessID, 0, PPtrRec^, BufSize); - if (RC = 0) and (PPtrRec^.PProcRec <> nil) + if RC <> 0 then + OSErrorWatch (RC) + else if (PPtrRec^.PProcRec <> nil) and (PPtrRec^.PProcRec^.PThrdRec <> nil) then begin BufEnd := PtrUInt (PPtrRec) + BufSize; @@ -480,6 +613,7 @@ function SysThreadSetPriority (ThreadHandle: dword; Prio: longint): boolean; var Delta: longint; Priority: cardinal; + RC: cardinal; begin Priority := GetOS2ThreadPriority (ThreadHandle); if Priority > High (word) then @@ -491,8 +625,10 @@ begin Delta := - TPrio (Priority).PrioLevel else if Delta + TPrio (Priority).PrioLevel > 31 then Delta := 31 - TPrio (Priority).PrioLevel; - SysThreadSetPriority := - DosSetPriority (dpThread, dpSameClass, Delta, ThreadHandle) = 0; + RC := DosSetPriority (dpThread, dpSameClass, Delta, ThreadHandle); + if RC <> 0 then + OSErrorWatch (RC); + SysThreadSetPriority := RC = 0; end; end; @@ -529,25 +665,43 @@ end; *****************************************************************************} procedure SysInitCriticalSection (var CS); +var + RC: cardinal; begin - if DosCreateMutExSem (nil, THandle (CS), 0, 0) <> 0 then - FPC_ThreadError; + RC := DosCreateMutExSem (nil, THandle (CS), 0, 0); + if RC <> 0 then + begin + OSErrorWatch (RC); + FPC_ThreadError; + end; end; procedure SysDoneCriticalSection (var CS); +var + RC: cardinal; begin (* Trying to release first since this might apparently be the expected *) (* behaviour in Delphi according to comment in the Unix implementation. *) repeat until DosReleaseMutExSem (THandle (CS)) <> 0; - if DosCloseMutExSem (THandle (CS)) <> 0 then - FPC_ThreadError; + RC := DosCloseMutExSem (THandle (CS)); + if RC <> 0 then + begin + OSErrorWatch (RC); + FPC_ThreadError; + end; end; procedure SysEnterCriticalSection (var CS); +var + RC: cardinal; begin - if DosRequestMutExSem (THandle (CS), cardinal (-1)) <> 0 then - FPC_ThreadError; + RC := DosRequestMutExSem (THandle (CS), cardinal (-1)); + if RC <> 0 then + begin + OSErrorWatch (RC); + FPC_ThreadError; + end; end; function SysTryEnterCriticalSection (var CS): longint; @@ -559,9 +713,15 @@ begin end; procedure SysLeaveCriticalSection (var CS); +var + RC: cardinal; begin - if DosReleaseMutExSem (THandle (CS)) <> 0 then - FPC_ThreadError; + RC := DosReleaseMutExSem (THandle (CS)); + if RC <> 0 then + begin + OSErrorWatch (RC); + FPC_ThreadError; + end; end; @@ -607,18 +767,23 @@ begin if RC <> 0 then begin Dispose (PLocalEventRec (Result)); + OSErrorWatch (RC); FPC_ThreadError; end; end; procedure SysBasicEventDestroy (State: PEventState); +var + RC: cardinal; begin if State = nil then FPC_ThreadError else begin - DosCloseEventSem (PLocalEventRec (State)^.FHandle); + RC := DosCloseEventSem (PLocalEventRec (State)^.FHandle); + if RC <> 0 then + OSErrorWatch (RC); Dispose (PLocalEventRec (State)); end; end; @@ -627,22 +792,33 @@ end; procedure SysBasicEventResetEvent (State: PEventState); var PostCount: cardinal; + RC: cardinal; begin if State = nil then FPC_ThreadError else + begin (* In case of later addition of error checking: *) (* RC 300 = Error_Already_Reset which would be OK. *) - DosResetEventSem (PLocalEventRec (State)^.FHandle, PostCount); + RC := DosResetEventSem (PLocalEventRec (State)^.FHandle, PostCount); + if (RC <> 0) and (RC <> 300) then + OSErrorWatch (RC); + end; end; procedure SysBasicEventSetEvent (State: PEventState); +var + RC: cardinal; begin if State = nil then FPC_ThreadError else - DosPostEventSem (PLocalEventRec (State)^.FHandle); + begin + RC := DosPostEventSem (PLocalEventRec (State)^.FHandle); + if RC <> 0 then + OSErrorWatch (RC); + end; end; @@ -661,6 +837,7 @@ begin else begin Result := wrError; + OSErrorWatch (RC); PLocalEventRec (State)^.FLastError := RC; end; end; @@ -669,41 +846,64 @@ end; function SysRTLEventCreate: PRTLEvent; +var + RC: cardinal; begin Result := PRTLEvent (-1); - DosCreateEventSem (nil, THandle (Result), dce_AutoReset, 0); + RC := DosCreateEventSem (nil, THandle (Result), dce_AutoReset, 0); + if RC <> 0 then + OSErrorWatch (RC); end; procedure SysRTLEventDestroy (AEvent: PRTLEvent); +var + RC: cardinal; begin - DosCloseEventSem (THandle (AEvent)); + RC := DosCloseEventSem (THandle (AEvent)); + if RC <> 0 then + OSErrorWatch (RC); end; procedure SysRTLEventSetEvent (AEvent: PRTLEvent); +var + RC: cardinal; begin - DosPostEventSem (THandle (AEvent)); + RC := DosPostEventSem (THandle (AEvent)); + if RC <> 0 then + OSErrorWatch (RC); end; procedure SysRTLEventWaitFor (AEvent: PRTLEvent); +var + RC: cardinal; begin - DosWaitEventSem (THandle (AEvent), cardinal (-1)); + RC := DosWaitEventSem (THandle (AEvent), cardinal (-1)); + if RC <> 0 then + OSErrorWatch (RC); end; procedure SysRTLEventWaitForTimeout (AEvent: PRTLEvent; Timeout: longint); +var + RC: cardinal; begin - DosWaitEventSem (THandle (AEvent), Timeout); + RC := DosWaitEventSem (THandle (AEvent), Timeout); + if RC <> 0 then + OSErrorWatch (RC); end; procedure SysRTLEventResetEvent (AEvent: PRTLEvent); var PostCount: cardinal; + RC: cardinal; begin - DosResetEventSem (THandle (AEvent), PostCount); + RC := DosResetEventSem (THandle (AEvent), PostCount); + if RC <> 0 then + OSErrorWatch (RC); end; @@ -713,18 +913,18 @@ const svNumProcessors = 26; var ProcNum: cardinal; + RC: cardinal; begin GetCPUCount := 1; - if DosQuerySysInfo (svNumProcessors, svNumProcessors, ProcNum, - SizeOf (ProcNum)) = 0 then - GetCPUCount := ProcNum; + RC := DosQuerySysInfo (svNumProcessors, svNumProcessors, ProcNum, + SizeOf (ProcNum)); + if RC = 0 then + GetCPUCount := ProcNum + else + OSErrorWatch (RC); end; -var - OS2ThreadManager: TThreadManager; - - procedure InitSystemThreads; begin with OS2ThreadManager do diff --git a/rtl/os2/sysucode.inc b/rtl/os2/sysucode.inc new file mode 100644 index 0000000000..422a3d1ea7 --- /dev/null +++ b/rtl/os2/sysucode.inc @@ -0,0 +1,1654 @@ +{ + This file is part of the Free Pascal run time library. + Copyright (c) 2014-2015 by Tomas Hajny and other members + of the Free Pascal development team. + + OS/2 UnicodeStrings support + + 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. + + **********************************************************************} + +(* The implementation is based on native Unicode support available under + OS/2 Warp 4 and above; if running under OS/2 Warp 3 and UCONV.DLL + library is not available, this implementation will resort to dummy + routines. This still allows providing 3rd party implementation based + e.g. on the ICONV library as an external unit. +*) + +const + MaxSpecialCPTranslation = 2; + MaxNonEqualCPMapping = 35; + MaxCPMapping = 76; + CpxAll = 0; + CpxSpecial = 1; + CpxMappingOnly = 2; + Uls_Success = 0; + Uls_API_Error_Base = $20400; + Uls_Other = $20401; + Uls_IllegalSequence = $20402; + Uls_MaxFilesPerProc = $20403; + Uls_MaxFiles = $20404; + Uls_NoOp = $20405; + Uls_TooManyKbd = $20406; + Uls_KbdNotFound = $20407; + Uls_BadHandle = $204008; + Uls_NoDead = $20409; + Uls_NoScan = $2040A; + Uls_InvalidScan = $2040B; + Uls_NotImplemented = $2040C; + Uls_NoMemory = $2040D; + Uls_Invalid = $2040E; + Uls_BadObject = $2040F; + Uls_NoToken = $20410; + Uls_NoMatch = $20411; + Uls_BufferFull = $20412; + Uls_Range = $20413; + Uls_Unsupported = $20414; + Uls_BadAttr = $20415; + Uls_Version = $20416; + UConvName: array [0..5] of char = 'UCONV'#0; + OrdUniCreateUconvObject = 1; + OrdUniUconvToUcs = 2; + OrdUniUconvFromUcs = 3; + OrdUniFreeUconvObject = 4; + OrdUniQueryUconvObject = 7; + OrdUniSetUconvObject = 8; + OrdUniQueryUconvCp = 9; + OrdUniMapCpToUcsCp = 10; + OrdUniStrFromUcs = 11; + OrdUniStrToUcs = 12; + Ord_UniMalloc = 13; + Ord_UniFree = 14; + LibUniName: array [0..6] of char = 'LIBUNI'#0; + OrdUniQueryXdigit = 1; + OrdUniQuerySpace = 2; + OrdUniQueryPrint = 3; + OrdUniQueryGraph = 4; + OrdUniQueryCntrl = 5; + OrdUniQueryAlpha = 6; + OrdUniFreeAttrObject = 7; + OrdUniQueryCharAttr = 8; + OrdUniQueryUpper = 9; + OrdUniQueryPunct = 10; + OrdUniQueryLower = 11; + OrdUniQueryDigit = 12; + OrdUniQueryBlank = 13; + OrdUniQueryAlnum = 14; + OrdUniScanForAttr = 15; + OrdUniCreateAttrObject = 16; + OrdUniCreateTransformObject = 17; + OrdUniFreeTransformObject = 18; + OrdUniQueryLocaleObject = 19; + OrdUniCreateLocaleObject = 20; + OrdUniFreeLocaleObject = 21; + OrdUniFreeMem = 22; + OrdUniFreeLocaleInfo = 28; + OrdUniQueryLocaleInfo = 29; + OrdUniQueryLocaleItem = 30; + OrdUniStrcat = 31; + OrdUniStrchr = 32; + OrdUniStrcmp = 33; + OrdUniStrcmpi = 34; + OrdUniStrColl = 35; + OrdUniStrcpy = 36; + OrdUniStrcspn = 37; + OrdUniStrfmon = 38; + OrdUniStrftime = 39; + OrdUniStrlen = 40; + OrdUniStrncat = 41; + OrdUniStrncmp = 42; + OrdUniStrncmpi = 43; + OrdUniStrncpy = 44; + OrdUniStrpbrk = 45; + OrdUniStrptime = 46; + OrdUniStrrchr = 47; + OrdUniStrspn = 48; + OrdUniStrstr = 49; + OrdUniStrtod = 50; + OrdUniStrtol = 51; + OrdUniStrtoul = 52; + OrdUniStrxfrm = 53; + OrdUniLocaleStrToToken = 54; + OrdUniLocaleTokenToStr = 55; + OrdUniTransformStr = 56; + OrdUniTransLower = 57; + OrdUniTransUpper = 58; + OrdUniTolower = 59; + OrdUniToupper = 60; + OrdUniStrupr = 61; + OrdUniStrlwr = 62; + OrdUniStrtok = 63; + OrdUniMapCtryToLocale = 67; + OrdUniMakeKey = 70; + OrdUniQueryChar = 71; + OrdUniGetOverride = 72; + OrdUniGetColval = 73; + OrdUniQueryAttr = 74; + OrdUniQueryStringType = 75; + OrdUniQueryCharType = 76; + OrdUniQueryNumericValue = 77; + OrdUniQueryCharTypeTable = 78; + OrdUniProcessUconv = 80; + OrdLocale = 151; + OrdUniMakeUserLocale = 152; + OrdUniSetUserLocaleItem = 153; + OrdUniDeleteUserLocale = 154; + OrdUniCompleteUserLocale = 155; + OrdUniQueryLocaleValue = 156; + OrdUniQueryLocaleList = 157; + OrdUniQueryLanguageName = 158; + OrdUniQueryCountryName = 159; + Uni_Token_Pointer = 1; + Uni_MBS_String_Pointer = 2; + Uni_UCS_String_Pointer = 3; + Uni_System_Locales = 1; + Uni_User_Locales = 2; + WNull: WideChar = #0; + + + +type +(* CP_UTF16 should be in exceptions too, because OS/2 supports only UCS2 *) +(* rather than UTF-16 - ignored at least for now. *) +(* ExceptionWinCodepages = (CP_UTF16BE, CP_UTF7, 12000 {UTF32}, 12001 {UTF32BE}); + SpecialWinCodepages = (CP_UTF8, CP_ASCII);*) + TCpRec = record + WinCP: TSystemCodepage; + OS2CP: word; + UConvObj: TUConvObject; + end; + TCpXList = array [1..MaxCPMapping] of TCpRec; + TDummyUConvObject = record + CP: cardinal; + CPNameLen: byte; + CPName: record end; + end; + PDummyUConvObject = ^TDummyUConvObject; + + +var + DBCSLeadRanges: array [0..11] of char; + CollationSequence: array [char] of char; + + +const + DefCpRec: TCpRec = (WinCP: 0; OS2CP: 0; UConvObj: nil); + InInitDefaultCP: int64 = -1; (* Range is bigger than TThreadID to avoid conflict *) + DefLocObj: TLocaleObject = nil; + IBMPrefix: packed array [1..4] of WideChar = 'IBM-'; + CachedDefFSCodepage: TSystemCodepage = 0; + EmptyCC: TCountryCode = (Country: 0; Codepage: 0); (* Empty = current *) + (* 819 = IBM codepage number for ISO 8859-1 used in FPC default *) + (* dummy translation between UnicodeString and AnsiString. *) + IsoCC: TCountryCode = (Country: 1; Codepage: 819); (* Empty = current *) + (* The following two arrays are initialized on startup in case that *) + (* Dummy* routines must be used. First for current codepage... *) + DBCSLeadRangesEnd: byte = 0; + LowerChars: array [char] of char = + (#0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15, #16, + #17, #18, #19, #20, #21, #22, #23, #24, #25, #26, #27, #28, #29, #30, #31, + #32, #33, #34, #35, #36, #37, #38, #39, #40, #41, #42, #43, #44, #45, #46, + #47, #48, #49, #50, #51, #52, #53, #54, #55, #56, #57, #58, #59, #60, #61, + #62, #63, #64, #65, #66, #67, #68, #69, #70, #71, #72, #73, #74, #75, #76, + #77, #78, #79, #80, #81, #82, #83, #84, #85, #86, #87, #88, #89, #90, #91, + #92, #93, #94, #95, #96, #97, #98, #99, #100, #101, #102, #103, #104, #105, + #106, #107, #108, #109, #110, #111, #112, #113, #114, #115, #116, #117, + #118, #119, #120, #121, #122, #123, #124, #125, #126, #127, #128, #129, + #130, #131, #132, #133, #134, #135, #136, #137, #138, #139, #140, #141, + #142, #143, #144, #145, #146, #147, #148, #149, #150, #151, #152, #153, + #154, #155, #156, #157, #158, #159, #160, #161, #162, #163, #164, #165, + #166, #167, #168, #169, #170, #171, #172, #173, #174, #175, #176, #177, + #178, #179, #180, #181, #182, #183, #184, #185, #186, #187, #188, #189, + #190, #191, #192, #193, #194, #195, #196, #197, #198, #199, #200, #201, + #202, #203, #204, #205, #206, #207, #208, #209, #210, #211, #212, #213, + #214, #215, #216, #217, #218, #219, #220, #221, #222, #223, #224, #225, + #226, #227, #228, #229, #230, #231, #232, #233, #234, #235, #236, #237, + #238, #239, #240, #241, #242, #243, #244, #245, #246, #247, #248, #249, + #250, #251, #252, #253, #254, #255); + (* ...and now for ISO 8859-1 aka IBM codepage 819 *) + LowerCharsISO88591: array [char] of char = + (#0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15, #16, + #17, #18, #19, #20, #21, #22, #23, #24, #25, #26, #27, #28, #29, #30, #31, + #32, #33, #34, #35, #36, #37, #38, #39, #40, #41, #42, #43, #44, #45, #46, + #47, #48, #49, #50, #51, #52, #53, #54, #55, #56, #57, #58, #59, #60, #61, + #62, #63, #64, #65, #66, #67, #68, #69, #70, #71, #72, #73, #74, #75, #76, + #77, #78, #79, #80, #81, #82, #83, #84, #85, #86, #87, #88, #89, #90, #91, + #92, #93, #94, #95, #96, #97, #98, #99, #100, #101, #102, #103, #104, #105, + #106, #107, #108, #109, #110, #111, #112, #113, #114, #115, #116, #117, + #118, #119, #120, #121, #122, #123, #124, #125, #126, #127, #128, #129, + #130, #131, #132, #133, #134, #135, #136, #137, #138, #139, #140, #141, + #142, #143, #144, #145, #146, #147, #148, #149, #150, #151, #152, #153, + #154, #155, #156, #157, #158, #159, #160, #161, #162, #163, #164, #165, + #166, #167, #168, #169, #170, #171, #172, #173, #174, #175, #176, #177, + #178, #179, #180, #181, #182, #183, #184, #185, #186, #187, #188, #189, + #190, #191, #192, #193, #194, #195, #196, #197, #198, #199, #200, #201, + #202, #203, #204, #205, #206, #207, #208, #209, #210, #211, #212, #213, + #214, #215, #216, #217, #218, #219, #220, #221, #222, #223, #224, #225, + #226, #227, #228, #229, #230, #231, #232, #233, #234, #235, #236, #237, + #238, #239, #240, #241, #242, #243, #244, #245, #246, #247, #248, #249, + #250, #251, #252, #253, #254, #255); + NoIso88591Support: boolean = false; + + +threadvar +(* Temporary allocations may be performed in parallel in different threads *) + TempCpRec: TCpRec; + + +function OS2GetStandardCodePage (const stdcp: TStandardCodePageEnum): TSystemCodePage; +var + RC, C, RetSize: cardinal; + NoUConvObject: TUConvObject; +begin + RC := DosQueryCP (SizeOf (C), @C, RetSize); + if (RC <> 0) and (RC <> 473) then + begin + OSErrorWatch (RC); + C := 850; + end + else + if RetSize < SizeOf (C) then + C := 850; + OS2GetStandardCodePage := OS2CpToRtlCp (C, cpxMappingOnly, NoUConvObject); +end; + + +function DummyUniCreateUConvObject (const CpName: PWideChar; + var UConv_Object: TUConvObject): longint; cdecl; +var + P: pointer; + PW, PCPN: PWideChar; + S: string [20]; + C: cardinal; + L: PtrInt; + I: longint; + A: array [0..7] of char; + CPN2: UnicodeString; + RC, RetSize: cardinal; +begin + UConv_Object := nil; + if (CpName = nil) or (CpName^ = #0) then + begin + RC := DosQueryCP (SizeOf (C), @C, RetSize); + if (RC <> 0) and (RC <> 473) then + begin + C := 850; + OSErrorWatch (RC); + end; + Str (C, CPN2); (* Str should hopefully not use this function recurrently *) + L := Length (CPN2); + Insert (IBMPrefix, CPN2, 1); + PCPN := @CPN2 [1]; + end + else + begin + PCPN := CpName; + for I := 0 to 7 do + if I mod 2 = 0 then + A [I] := UpCase (PChar (@PCPN [0]) [I]) + else + A [I] := PChar (@PCPN [0]) [I]; + if PQWord (@A)^ <> PQWord (@IBMPrefix)^ then + begin + DummyUniCreateUConvObject := Uls_Invalid; + Exit; + end; + L := 0; + PW := PCPN + 4; + while ((PW + L)^ <> #0) and (L <= SizeOf (S)) do + begin + S [Succ (L)] := char (Ord ((PW + L)^)); + Inc (L); + end; + if L > SizeOf (S) then + begin + DummyUniCreateUConvObject := Uls_Other; + Exit; + end; + SetLength (S, L); + Val (S, C, I); + if I <> 0 then + begin + DummyUniCreateUConvObject := Uls_Invalid; + Exit; + end; + end; + Inc (L); + GetMem (P, SizeOf (TDummyUConvObject) + (L + 4) * 2); + if P = nil then + DummyUniCreateUConvObject := Uls_NoMemory + else + begin + DummyUniCreateUConvObject := Uls_Success; + PDummyUConvObject (P)^.CP := C; + PDummyUConvObject (P)^.CpNameLen := Pred (L) + 4; + Move (PCPN [0], PDummyUConvObject (P)^.CpName, (L + 4) * 2); + UConv_Object := TUConvObject (P); + end; +end; + + +function DummyUniFreeUConvObject (UConv_Object: TUConvObject): longint; cdecl; +begin + if UConv_Object <> nil then + FreeMem (UConv_Object, SizeOf (TDummyUConvObject) + + Succ (PDummyUConvObject (UConv_Object)^.CpNameLen) * 2); + DummyUniFreeUConvObject := Uls_Success; +end; + + +function DummyUniMapCpToUcsCp (const Codepage: cardinal; + CodepageName: PWideChar; const N: cardinal): longint; cdecl; +var + S: UnicodeString; + RC, CP, RetSize: cardinal; +begin + if Codepage = 0 then + begin + RC := DosQueryCP (SizeOf (CP), @CP, RetSize); + if (RC <> 0) and (RC <> 473) then + begin + CP := 850; + OSErrorWatch (RC); + end; + Str (CP, S); + end + else + Str (Codepage, S); + if (N <= Length (S) + 4) or (CodepageName = nil) then + DummyUniMapCptoUcsCp := Uls_Invalid + else + begin + Move (IBMPrefix, CodepageName^, SizeOf (IBMPrefix)); + Move (S [1], CodepageName [4], Length (S) * SizeOf (WideChar)); + CodepageName [Length (S) + 4] := #0; + DummyUniMapCpToUcsCp := Uls_Success; + end; +end; + + +function DummyUniUConvFromUcs (UConv_Object: TUConvObject; + var UcsBuf: PWideChar; var UniCharsLeft: longint; var OutBuf: PChar; + var OutBytesLeft: longint; var NonIdentical: longint): longint; cdecl; +var + Dest, Dest2: RawByteString; + NoUConvObj: TUConvObject; + RtlCp: TSystemCodepage; + UcsLen: PtrInt; +begin + if UConv_Object = nil then + RtlCp := OS2GetStandardCodePage (scpAnsi) + else + RtlCp := OS2CpToRtlCp (PDummyUConvObject (UConv_Object)^.CP, cpxMappingOnly, + NoUConvObj); + DefaultUnicode2AnsiMove (UcsBuf, Dest, RtlCp, UniCharsLeft); + NonIdentical := 1; { Assume at least one substitution with dummy implementation } + if Length (Dest) > OutBytesLeft then + begin + UcsLen := 1; + repeat + DefaultUnicode2AnsiMove (UcsBuf, Dest2, RtlCp, UcsLen); + if Length (Dest2) <= OutBytesLeft then + begin + Dest := Dest2; + end; + Inc (UcsLen); + until Length (Dest2) > OutBytesLeft; + Dec (UcsLen); + Inc (UcsBuf, UcsLen); + Dec (UniCharsLeft, UcsLen); + DummyUniUConvFromUcs := Uls_BufferFull; + end + else + begin + Inc (UcsBuf, UniCharsLeft); + UniCharsLeft := 0; + DummyUniUConvFromUcs := Uls_Success; + end; + Move (Dest [1], OutBuf^, Length (Dest)); + Inc (OutBuf, Length (Dest)); + Dec (OutBytesLeft, Length (Dest)); +end; + + +function DummyUniUConvToUcs (UConv_Object: TUConvObject; var InBuf: PChar; + var InBytesLeft: longint; var UcsBuf: PWideChar; var UniCharsLeft: longint; + var NonIdentical: longint): longint; cdecl; +var + Dest, Dest2: UnicodeString; + NoUConvObj: TUConvObject; + RtlCp: TSystemCodepage; + SrcLen: PtrInt; +begin + if UConv_Object = nil then + RtlCp := OS2GetStandardCodePage (scpAnsi) + else + RtlCp := OS2CpToRtlCp (PDummyUConvObject (UConv_Object)^.CP, cpxMappingOnly, + NoUConvObj); + DefaultAnsi2UnicodeMove (InBuf, RtlCp, Dest, InBytesLeft); + NonIdentical := 0; { Assume no need for substitutions in this direction } + if Length (Dest) > UniCharsLeft then + begin + SrcLen := 1; + repeat + DefaultAnsi2UnicodeMove (InBuf, RtlCp, Dest2, SrcLen); + if Length (Dest2) <= UniCharsLeft then + begin + Dest := Dest2; + end; + Inc (SrcLen); + until Length (Dest2) > UniCharsLeft; + Dec (SrcLen); + Inc (InBuf, SrcLen); + Dec (InBytesLeft, SrcLen); + DummyUniUConvToUcs := Uls_BufferFull; { According to IBM documentation Uls_Invalid and not Uls_BufferFull as returned by UniUConvFromUcs?! } + end + else + begin + Inc (InBuf, InBytesLeft); { Shall it be increased in case of success too??? } + InBytesLeft := 0; + DummyUniUConvToUcs := Uls_Success; + end; + Move (Dest [1], UcsBuf^, Length (Dest) * 2); + Inc (UcsBuf, Length (Dest)); { Shall it be increased in case of success too??? } + Dec (UniCharsLeft, Length (Dest)); +end; + + +procedure InitDBCSLeadRanges; +var + RC: cardinal; +begin + RC := DosQueryDBCSEnv (SizeOf (DBCSLeadRanges), EmptyCC, + @DBCSLeadRanges [0]); + DBCSLeadRangesEnd := 0; + if RC <> 0 then + while (DBCSLeadRangesEnd < SizeOf (DBCSLeadRanges)) and + ((DBCSLeadRanges [DBCSLeadRangesEnd] <> #0) or + (DBCSLeadRanges [Succ (DBCSLeadRangesEnd)] <> #0)) do + Inc (DBCSLeadRangesEnd, 2); +end; + + +procedure InitDummyAnsiSupport; +var + C: char; + AllChars: array [char] of char; + RetSize: cardinal; +begin + if DosQueryCollate (SizeOf (CollationSequence), EmptyCC, @CollationSequence, + RetSize) <> 0 then + Move (LowerChars, CollationSequence, SizeOf (CollationSequence)); + Move (LowerChars, AllChars, SizeOf (AllChars)); + if DosMapCase (SizeOf (AllChars), IsoCC, @AllChars [#0]) <> 0 then +(* Codepage 819 may not be supported in all old OS/2 versions. *) + begin + Move (LowerCharsIso88591, AllChars, SizeOf (AllChars)); + DosMapCase (SizeOf (AllChars), EmptyCC, @AllChars [#0]); + NoIso88591Support := true; + end; + for C := Low (char) to High (char) do + if AllChars [C] <> C then + LowerCharsIso88591 [AllChars [C]] := C; + if NoIso88591Support then + Move (LowerCharsIso88591, LowerChars, SizeOf (LowerChars)) + else + begin + Move (LowerChars, AllChars, SizeOf (AllChars)); + DosMapCase (SizeOf (AllChars), EmptyCC, @AllChars [#0]); + for C := Low (char) to High (char) do + if AllChars [C] <> C then + LowerChars [AllChars [C]] := C; + end; + InitDBCSLeadRanges; +end; + + +procedure ReInitDummyAnsiSupport; +var + C: char; + AllChars: array [char] of char; + RetSize: cardinal; +begin + for C := Low (char) to High (char) do + AllChars [C] := C; + if DosQueryCollate (SizeOf (CollationSequence), EmptyCC, @CollationSequence, + RetSize) <> 0 then + Move (AllChars, CollationSequence, SizeOf (CollationSequence)); + DosMapCase (SizeOf (AllChars), EmptyCC, @AllChars [#0]); + for C := Low (char) to High (char) do + if AllChars [C] <> C then + LowerChars [AllChars [C]] := C; + InitDBCSLeadRanges; +end; + + +function DummyUniToLower (UniCharIn: WideChar): WideChar; cdecl; +var + C: char; +begin + C := UniCharIn; + DummyUniToLower := LowerCharsIso88591 [C]; +end; + + +function DummyUniToUpper (UniCharIn: WideChar): WideChar; cdecl; +var + C: char; +begin + DummyUniToUpper := UniCharIn; + C := UniCharIn; + if NoIso88591Support then + begin + if DosMapCase (1, EmptyCC, @C) = 0 then + DummyUniToUpper := C; + end + else + if DosMapCase (1, IsoCC, @C) = 0 then + DummyUniToUpper := C +end; + + +function DummyUniStrColl (Locale_Object: TLocaleObject; + const UCS1, UCS2: PWideChar): longint; cdecl; +var + S1, S2: ansistring; +begin + S1 := UCS1; + S2 := UCS2; + if S1 = S2 then + DummyUniStrColl := 0 + else if S1 < S2 then + DummyUniStrColl := -1 + else + DummyUniStrColl := 1; +end; + + +function DummyUniCreateLocaleObject (LocaleSpecType: longint; + const LocaleSpec: pointer; var Locale_Object: TLocaleObject): longint; cdecl; +begin + DummyUniCreateLocaleObject := ULS_Unsupported; +end; + + +function DummyUniFreeLocaleObject (Locale_Object: TLocaleObject): longint; + cdecl; +begin + DummyUniFreeLocaleObject := ULS_BadObject; +end; + + + +const + CpXList: TCpXList = ( + (WinCP: CP_UTF8; OS2CP: 1208; UConvObj: nil), + (WinCP: CP_ASCII; OS2CP: 367; UConvObj: nil), + (WinCP: 28597; OS2CP: 813; UConvObj: nil), + (WinCP: 28591; OS2CP: 819; UConvObj: nil), + (WinCP: 28592; OS2CP: 912; UConvObj: nil), + (WinCP: 28593; OS2CP: 913; UConvObj: nil), + (WinCP: 28594; OS2CP: 914; UConvObj: nil), + (WinCP: 28595; OS2CP: 915; UConvObj: nil), + (WinCP: 28598; OS2CP: 916; UConvObj: nil), + (WinCP: 28599; OS2CP: 920; UConvObj: nil), + (WinCP: 28603; OS2CP: 921; UConvObj: nil), + (WinCP: 28605; OS2CP: 923; UConvObj: nil), + (WinCP: 10000; OS2CP: 1275; UConvObj: nil), + (WinCP: 10006; OS2CP: 1280; UConvObj: nil), + (WinCP: 10081; OS2CP: 1281; UConvObj: nil), + (WinCP: 10029; OS2CP: 1282; UConvObj: nil), + (WinCP: 10007; OS2CP: 1283; UConvObj: nil), + (WinCP: 20273; OS2CP: 273; UConvObj: nil), + (WinCP: 20277; OS2CP: 277; UConvObj: nil), + (WinCP: 20278; OS2CP: 278; UConvObj: nil), + (WinCP: 20280; OS2CP: 280; UConvObj: nil), + (WinCP: 20284; OS2CP: 284; UConvObj: nil), + (WinCP: 20285; OS2CP: 285; UConvObj: nil), + (WinCP: 20290; OS2CP: 290; UConvObj: nil), + (WinCP: 20297; OS2CP: 297; UConvObj: nil), + (WinCP: 20420; OS2CP: 420; UConvObj: nil), + (WinCP: 20424; OS2CP: 424; UConvObj: nil), + (WinCP: 20833; OS2CP: 833; UConvObj: nil), + (WinCP: 20838; OS2CP: 838; UConvObj: nil), + (WinCP: 20866; OS2CP: 878; UConvObj: nil), + (WinCP: 737; OS2CP: 851; UConvObj: nil), + (WinCP: 20924; OS2CP: 924; UConvObj: nil), + (WinCP: 20932; OS2CP: 932; UConvObj: nil), + (WinCP: 20936; OS2CP: 936; UConvObj: nil), + (WinCP: 21025; OS2CP: 1025; UConvObj: nil), + (WinCP: CP_UTF16; OS2CP: CP_UTF16; UConvObj: nil), + (WinCP: 37; OS2CP: 37; UConvObj: nil), + (WinCP: 437; OS2CP: 437; UConvObj: nil), + (WinCP: 500; OS2CP: 500; UConvObj: nil), + (WinCP: 850; OS2CP: 850; UConvObj: nil), + (WinCP: 852; OS2CP: 852; UConvObj: nil), + (WinCP: 855; OS2CP: 855; UConvObj: nil), + (WinCP: 857; OS2CP: 857; UConvObj: nil), + (WinCP: 860; OS2CP: 860; UConvObj: nil), + (WinCP: 861; OS2CP: 861; UConvObj: nil), + (WinCP: 862; OS2CP: 862; UConvObj: nil), + (WinCP: 863; OS2CP: 863; UConvObj: nil), + (WinCP: 864; OS2CP: 864; UConvObj: nil), + (WinCP: 865; OS2CP: 865; UConvObj: nil), + (WinCP: 866; OS2CP: 866; UConvObj: nil), + (WinCP: 869; OS2CP: 869; UConvObj: nil), + (WinCP: 870; OS2CP: 870; UConvObj: nil), + (WinCP: 874; OS2CP: 874; UConvObj: nil), + (WinCP: 875; OS2CP: 875; UConvObj: nil), + (WinCP: 949; OS2CP: 949; UConvObj: nil), + (WinCP: 950; OS2CP: 950; UConvObj: nil), + (WinCP: 1026; OS2CP: 1026; UConvObj: nil), + (WinCP: 1047; OS2CP: 1047; UConvObj: nil), + (WinCP: 1140; OS2CP: 1140; UConvObj: nil), + (WinCP: 1141; OS2CP: 1141; UConvObj: nil), + (WinCP: 1142; OS2CP: 1142; UConvObj: nil), + (WinCP: 1143; OS2CP: 1143; UConvObj: nil), + (WinCP: 1144; OS2CP: 1144; UConvObj: nil), + (WinCP: 1145; OS2CP: 1145; UConvObj: nil), + (WinCP: 1146; OS2CP: 1146; UConvObj: nil), + (WinCP: 1147; OS2CP: 1147; UConvObj: nil), + (WinCP: 1148; OS2CP: 1148; UConvObj: nil), + (WinCP: 1149; OS2CP: 1149; UConvObj: nil), + (WinCP: 1250; OS2CP: 1250; UConvObj: nil), + (WinCP: 1251; OS2CP: 1251; UConvObj: nil), + (WinCP: 1252; OS2CP: 1252; UConvObj: nil), + (WinCP: 1253; OS2CP: 1253; UConvObj: nil), + (WinCP: 1254; OS2CP: 1254; UConvObj: nil), + (WinCP: 1255; OS2CP: 1255; UConvObj: nil), + (WinCP: 1256; OS2CP: 1256; UConvObj: nil), + (WinCP: 1257; OS2CP: 1257; UConvObj: nil) + ); + +(* Possibly add index tables for both directions and binary search??? *) + +{ +function GetRtlCpFromCpRec (const CpRec: TCpRec): TSystemCodepage; inline; +begin + if RtlUsesWinCp then + GetRtlCp := CpRec.WinCP + else + GetRtlCp := TSystemCodepage (CpRec.Os2Cp); +end; +} + +function UConvObjectForCP (CP: cardinal; var UConvObj: TUConvObject): longint; +var + RC: longint; + A: array [0..12] of WideChar; +begin + UConvObj := nil; + RC := Sys_UniMapCpToUcsCp (CP, @A, 12); + if RC = 0 then + RC := Sys_UniCreateUconvObject (@A, UConvObj); +{$WARNING: TODO: Deallocate some previously allocated UConvObj and try again if failed} + UConvObjectForCP := RC; + if RC <> 0 then + OSErrorWatch (RC); +end; + + +procedure InitDefaultCP; +var + OS2CP, I: cardinal; + NoUConvObj: TUConvObject; + RCI: longint; + RC: cardinal; + CPArr: TCPArray; + ReturnedSize: cardinal; +begin + if InInitDefaultCP <> -1 then + begin + repeat + DosSleep (5); + until InInitDefaultCP <> -1; + Exit; + end; + InInitDefaultCP := ThreadID; + if DefCpRec.UConvObj <> nil then + begin +(* Do not free the UConv object from DefCpRec, because it is also stored in + the respective CPXList record! *) +{ + RCI := Sys_UniFreeUConvObject (DefCpRec.UConvObj); + if RCI <> 0 then + OSErrorWatch (cardinal (RCI)); +} + DefCpRec.UConvObj := nil; + end; + RC := DosQueryCP (SizeOf (CPArr), @CPArr, ReturnedSize); + if (RC <> 0) and (RC <> 473) then + begin + OSErrorWatch (RC); + CPArr [0] := 850; + end + else if (ReturnedSize < 4) then + CPArr [0] := 850; + DefaultFileSystemCodePage := OS2CPtoRtlCP (CPArr [0], cpxAll, + DefCpRec.UConvObj); + CachedDefFSCodepage := DefaultFileSystemCodePage; + DefCpRec.OS2CP := CPArr [0]; +(* Find out WinCP _without_ considering RtlUsesWinCP *) + I := 1; + while (I <= MaxNonEqualCPMapping) and (CpXList [I].OS2CP <> OS2CP) do + Inc (I); + if CpXList [I].OS2CP = CPArr [0] then + DefCpRec.WinCP := CpXList [I].WinCP + else + DefCpRec.WinCP := CPArr [0]; + + if DefLocObj <> nil then + begin + RCI := Sys_UniFreeLocaleObject (DefLocObj); + if RCI <> 0 then + OSErrorWatch (cardinal (RCI)); + end; + RCI := Sys_UniCreateLocaleObject (Uni_UCS_String_Pointer, @WNull, DefLocObj); + if RCI <> 0 then + OSErrorWatch (cardinal (RCI)); + if not (UniAPI) then + ReInitDummyAnsiSupport; + InInitDefaultCP := -1; +end; + + +function OS2CPtoRtlCP (CP: cardinal; ReqFlags: byte; + var UConvObj: TUConvObject): TSystemCodepage; +var + I, I2: cardinal; + RCI: longint; + + function CheckDefaultOS2CP: boolean; + begin + if CP = DefCpRec.OS2CP then + begin + CheckDefaultOS2CP := true; + if RTLUsesWinCP then + OS2CPtoRtlCP := DefCpRec.WinCP; + if ReqFlags and CpxMappingOnly = 0 then + UConvObj := DefCpRec.UConvObj; + end + else + CheckDefaultOS2CP := false; + end; + +begin + OS2CPtoRtlCP := TSystemCodePage (CP); + UConvObj := nil; + if not UniAPI then (* No UniAPI => no need for UConvObj *) + ReqFlags := ReqFlags or CpxMappingOnly; + if CheckDefaultOS2CP then + Exit; + if (CachedDefFSCodepage <> DefaultFileSystemCodePage) and + (InInitDefaultCP <> ThreadID) then +(* InInitDefaultCP = ThreadID -> this thread is already re-initializing the cached information *) + begin + if InInitDefaultCP <> -1 then + repeat + DosSleep (5) (* Let's wait until the other thread finishes re-initialization of the cache *) + until InInitDefaultCP = -1 + else + InitDefaultCP; + if CheckDefaultOS2CP then + Exit; + end; + I := 1; + if ReqFlags and CpxSpecial = CpxSpecial then + I2 := 2 + else + if ReqFlags and CpxMappingOnly = CpxMappingOnly then + I2 := MaxNonEqualCPMapping + else + I2 := MaxCPMapping; + while I <= I2 do + begin + if CP = CpXList [I].OS2CP then + begin + if RTLUsesWinCP then + OS2CPtoRtlCP := CpXList [I].WinCP; + if ReqFlags and CpxMappingOnly = 0 then + begin + if CpXList [I].UConvObj = nil then + begin + if UConvObjectForCP (CpXList [I].OS2CP, UConvObj) = Uls_Success then + CpXList [I].UConvObj := UConvObj + else + UConvObj := nil; + end + else + UConvObj := CpXList [I].UConvObj; + end; + Exit; + end; + Inc (I); + end; +(* If codepage was not found in the translation table and UConvObj is + requested, allocate one in the temporary record. *) + if ReqFlags and CpxMappingOnly = 0 then + begin + if TempCpRec.OS2CP = CP then + UConvObj := TempCpRec.UConvObj + else + begin + if TempCpRec.UConvObj <> nil then + begin + RCI := Sys_UniFreeUConvObject (TempCpRec.UConvObj); + if RCI <> 0 then + OSErrorWatch (cardinal (RCI)); + end; + if UConvObjectForCP (CP, UConvObj) = Uls_Success then + begin + TempCpRec.UConvObj := UConvObj; + TempCpRec.OS2CP := CP; + end + else + UConvObj := nil; + end; + end; +end; + + +function RtlCPtoOS2CP (RtlCP: TSystemCodepage; ReqFlags: byte; + var UConvObj: TUConvObject): cardinal; +var + I, I2: cardinal; + + function CheckDefaultWinCP: boolean; + begin + if RtlCP = DefCpRec.WinCP then + begin + CheckDefaultWinCP := true; + RtlCPtoOS2CP := DefCpRec.WinCP; + if ReqFlags and CpxMappingOnly = 0 then + UConvObj := DefCpRec.UConvObj; + end + else + CheckDefaultWinCP := false; + end; + +begin + RtlCPtoOS2CP := RtlCP; + UConvObj := nil; + if not UniAPI then (* No UniAPI => no need for UConvObj *) + ReqFlags := ReqFlags or CpxMappingOnly; + if not (RTLUsesWinCP) then + begin + if ReqFlags and CpxMappingOnly = 0 then + OS2CPtoRtlCP (cardinal (RtlCp), ReqFlags, UConvObj); + end + else if CheckDefaultWinCp then + Exit + else + begin + if (CachedDefFSCodepage <> DefaultFileSystemCodePage) and + (InInitDefaultCP <> ThreadID) then +(* InInitDefaultCP = ThreadID -> this thread is already re-initializing the cached information *) + begin + if InInitDefaultCP <> -1 then + repeat +(* Let's wait until the other thread finishes re-initialization of the cache *) + DosSleep (5) + until InInitDefaultCP = -1 + else + InitDefaultCP; + if CheckDefaultWinCP then + Exit; + end; + I := 1; + if ReqFlags and CpxSpecial = CpxSpecial then + I2 := 2 + else + if ReqFlags and CpxMappingOnly = CpxMappingOnly then + I2 := MaxNonEqualCPMapping + else + I2 := MaxCPMapping; + while I <= I2 do + begin + if RtlCP = CpXList [I].WinCP then + begin + RtlCPtoOS2CP := CpXList [I].OS2CP; + if ReqFlags and CpxMappingOnly = 0 then + begin + begin + if UConvObjectForCP (CpXList [I].OS2CP, UConvObj) = Uls_Success then + CpXList [I].UConvObj := UConvObj + else + UConvObj := nil; + end + end; + Exit; + end; + Inc (I); + end; +(* +Special processing for + ExceptionWinCodepages = (CP_UTF16BE, CP_UTF7, 12000 {UTF32}, 12001 {UTF32BE}) +might be added here...or not ;-) + + if (TempCpRec.OS2CP <> High (TempCpRec.OS2CP)) or + (TempCpRec.WinCP <> RtlCp) then + begin + if TempCpRec.UConvObj <> nil then + begin + RCI := Sys_UniFreeUConvObject (TempCpRec.UConvObj); + if RCI <> 0 then + OSErrorWatch (cardinal (RCI)); + end; + TempCpRec.OS2CP := High (TempCpRec.OS2CP); + TempCpRec.WinCP := RtlCp; + end; + + Map to CP_ASCII aka OS2CP=367 if RtlCP not recognized and UConvObject + is requested??? +*) + +(* Signalize unrecognized (untranslatable) MS Windows codepage *) + OSErrorWatch (Uls_Invalid); + end; +end; + + +function OS2CPtoRtlCP (CP: cardinal; ReqFlags: byte): TSystemCodepage; +var + NoUConvObj: TUConvObject; +begin + if RtlUsesWinCP then + OS2CPtoRtlCP := OS2CPtoRtlCP (CP, ReqFlags or CpxMappingOnly, NoUConvObj) + else + OS2CPtoRtlCP := TSystemCodepage (CP); +end; + + +function RtlCPtoOS2CP (RtlCP: TSystemCodepage; ReqFlags: byte): cardinal; +var + NoUConvObj: TUConvObject; +begin + if RtlUsesWinCP then + RtlCPtoOS2CP := RtlCPtoOS2CP (RtlCP, ReqFlags or CpxMappingOnly, NoUConvObj) + else + RtlCPtoOS2CP := RtlCP; +end; + + +procedure OS2Unicode2AnsiMove (Source: PUnicodeChar; var Dest: RawByteString; + CP: TSystemCodePage; Len: SizeInt); +var + RCI: longint; + UConvObj: TUConvObject; + OS2CP: cardinal; + Src2: PUnicodeChar; + Len2, LenOut, OutOffset, NonIdentical: longint; + Dest2: PChar; +begin + OS2CP := RtlCpToOS2CP (CP, CpxAll, UConvObj); +{ if UniAPI and (UConvObj = nil) then - OS2Unicode2AnsiMove should be never called if not UniAPI } + if UConvObj = nil then + begin +{$WARNING Special cases like UTF-7 should be handled here, otherwise signalize error - how???} + + DefaultUnicode2AnsiMove (Source, Dest, CP, Len); + Exit; + end; + LenOut := Succ (Len); (* Standard OS/2 CP is a SBCS *) + SetLength (Dest, LenOut); + SetCodePage (Dest, CP, false); + Src2 := Source; + Len2 := Len; + Dest2 := PChar (Dest); + RCI := Sys_UniUConvFromUcs (UConvObj, Src2, Len2, Dest2, LenOut, + NonIdentical); + repeat + case RCI of + Uls_Success: + begin + if LenOut > 0 then + SetLength (Dest, Length (Dest) - LenOut); + Break; + end; + Uls_IllegalSequence: + begin + OSErrorWatch (Uls_IllegalSequence); + { skip and set to '?' } + Inc (Src2); + Dec (Len2); + Dest2^ := '?'; + Inc (Dest2); + Dec (LenOut); + end; + Uls_BufferFull: + begin + OutOffset := Dest2 - PChar (Dest); +(* Use Len2 or Len decreased by difference between Source and Src2? *) +(* Extend more this time - target is probably a DBCS or UTF-8 *) + SetLength (Dest, Length (Dest) + Succ (Len2 * 2)); + { string could have been moved } + Dest2 := PChar (Dest) + OutOffset; + Inc (LenOut, Succ (Len2 * 2)); + end + else + begin + SetLength (Dest, 0); + OSErrorWatch (cardinal (RCI)); + { Break } + RunError (231); + end; + end; + RCI := Sys_UniUConvFromUcs (UConvObj, Src2, Len2, Dest2, LenOut, + NonIdentical); + until false; +end; + + +procedure OS2Ansi2UnicodeMove (Source: PChar; CP: TSystemCodePage; + var Dest: UnicodeString; Len: SizeInt); +var + RCI: longint; + UConvObj: TUConvObject; + OS2CP: cardinal; + Src2: PChar; + Len2, LenOut, OutOffset, NonIdentical: longint; + Dest2: PWideChar; +begin + OS2CP := RtlCpToOS2CP (CP, CpxAll, UConvObj); +{ if UniAPI and (UConvObj = nil) then - OS2Unicode2AnsiMove should be never called if not UniAPI } + if UConvObj = nil then + begin +{$WARNING Special cases like UTF-7 should be handled here, otherwise signalize error - how???} + + DefaultAnsi2UnicodeMove (Source, CP, Dest, Len); + Exit; + end; + + LenOut := Succ (Len); (* Standard OS/2 CP is a SBCS *) + SetLength (Dest, LenOut); + Src2 := Source; + Len2 := Len; + Dest2 := PWideChar (Dest); + + RCI := Sys_UniUConvToUcs (UConvObj, Src2, Len2, Dest2, LenOut, NonIdentical); + repeat + case RCI of + Uls_Success: + begin + if LenOut > 0 then + SetLength (Dest, Length (Dest) - LenOut); + Break; + end; + Uls_IllegalSequence: + begin + OSErrorWatch (Uls_IllegalSequence); + { skip and set to '?' } + Inc (Src2); + Dec (Len2); + Dest2^ := '?'; + Inc (Dest2); + Dec (LenOut); + end; + Uls_BufferFull: + begin + OutOffset := Dest2 - PWideChar (Dest); +(* Use Len2 or Len decreased by difference between Source and Src2? *) + SetLength (Dest, Length (Dest) + Succ (Len2)); + { string could have been moved } + Dest2 := PWideChar (Dest) + OutOffset; + Inc (LenOut, Succ (Len2)); + end + else + begin + SetLength (Dest, 0); + OSErrorWatch (cardinal (RCI)); + { Break } + RunError (231); + end; + end; + RCI := Sys_UniUConvToUcs (UConvObj, Src2, Len2, Dest2, LenOut, + NonIdentical); + until false; +end; + + +function RtlChangeCP (CP: TSystemCodePage): longint; +var + OS2CP, I: cardinal; + NoUConvObj: TUConvObject; + RCI: longint; +begin + OS2CP := RtlCpToOS2Cp (CP, cpxMappingOnly, NoUConvObj); + RtlChangeCP := longint (DosSetProcessCP (OS2CP)); + if RtlChangeCP <> 0 then + OSErrorWatch (RtlChangeCP) + else + begin + DefaultSystemCodePage := CP; + DefaultRTLFileSystemCodePage := DefaultSystemCodePage; + DefaultFileSystemCodePage := DefaultSystemCodePage; + + if OS2CP <> DefCpRec.OS2CP then + begin + if DefCpRec.UConvObj <> nil then + begin +(* Do not free the UConv object from DefCpRec, because it is also stored in + the respective CpXList record! *) +{ + RCI := Sys_UniFreeUConvObject (DefCpRec.UConvObj); + if RCI <> 0 then + OSErrorWatch (cardinal (RCI)); +} + DefCpRec.UConvObj := nil; + end; + DefCPRec.OS2CP := OS2CP; + RCI := Sys_UniCreateUConvObject (@WNull, DefCpRec.UConvObj); + if RCI <> 0 then + OSErrorWatch (cardinal (RCI)); +(* Find out WinCP _without_ considering RtlUsesWinCP *) + I := 1; + while (I <= MaxNonEqualCPMapping) and (CpXList [I].OS2CP <> OS2CP) do + Inc (I); + if CpXList [I].OS2CP = OS2CP then + DefCpRec.WinCP := CpXList [I].WinCP + else + DefCpRec.WinCP := OS2CP; + end; + end; +end; + + +function OS2UpperUnicodeString (const S: UnicodeString): UnicodeString; +var + I: cardinal; +begin + SetLength (Result, Length (S)); + for I := 0 to Pred (Length (S)) do + PWideChar (Result) [I] := Sys_UniToUpper (S [Succ (I)]); +end; + + +function OS2LowerUnicodeString (const S: UnicodeString): UnicodeString; +var + I: cardinal; +begin + SetLength (Result, Length (S)); + for I := 0 to Pred (Length (S)) do + PWideChar (Result) [I] := Sys_UniToLower (S [Succ (I)]); +end; + + +function NoNullsUnicodeString (const S: UnicodeString): UnicodeString; +var + I: cardinal; +begin + Result := S; + UniqueString (Result); + for I := 1 to Length (S) do + if Result [I] = WNull then + Result [I] := ' '; +end; + + +function OS2CompareUnicodeString (const S1, S2: UnicodeString): PtrInt; +var + HS1, HS2: UnicodeString; +begin + { UniStrColl interprets null chars as end-of-string -> filter out } + HS1 := NoNullsUnicodeString (S1); + HS2 := NoNullsUnicodeString (S2); + Result := Sys_UniStrColl (DefLocObj, PWideChar (HS1), PWideChar (HS2)); + if Result < -1 then + Result := -1 + else if Result > 1 then + Result := 1; +end; + + +function OS2CompareTextUnicodeString (const S1, S2: UnicodeString): PtrInt; +begin + Result := OS2CompareUnicodeString (OS2UpperUnicodeString (S1), + OS2UpperUnicodeString (S2)); +{$WARNING Language independent uppercase routine may not be appropriate for language dependent case insensitive comparison!} +end; + + +function OS2UpperAnsiString (const S: AnsiString): AnsiString; +var + RC: cardinal; +begin + Result := S; + UniqueString (Result); + FillChar (EmptyCC, SizeOf (EmptyCC), 0); + RC := DosMapCase (Length (Result), EmptyCC, PChar (Result)); +{ What to do in case of a failure??? } + if RC <> 0 then + Result := UpCase (S); { Use a fallback? } +end; + + +function OS2LowerAnsiString (const S: AnsiString): AnsiString; +var + I: PtrUInt; + + function IsDBCSLeadChar (C: char): boolean; + var + D: byte; + begin + IsDBCSLeadChar := false; + D := 0; + while D < DBCSLeadRangesEnd do + begin + if (C >= DBCSLeadRanges [D]) and (C <= DBCSLeadRanges [Succ (D)]) then + begin + IsDBCSLeadChar := true; + Exit; + end; + Inc (D, 2); + end; + end; + +begin +(* + OS/2 provides no direct solution for lowercase conversion of MBCS strings. + If Unicode support is available, using Unicode routines is the best solution. + If not, we use a translation table built at startup by translating the full + character set to uppercase and using that for creation of a lookup table + (as already done in sysutils). However, we need to check for DBCS (MBCS) + codepages and avoid translating the DBCS lead bytes and the following + character. +*) + if UniAPI then + Result := OS2LowerUnicodeString (S) +{ Two implicit conversions... ;-) } + else + begin + Result := S; + if Length (Result) > 0 then + begin + UniqueString (Result); + if DBCSLeadRangesEnd > 0 then + begin + I := 1; + while I <= Length (Result) do + begin + if IsDBCSLeadChar (Result [I]) then + Inc (I, 2) + else + begin + Result [I] := LowerChars [Result [I]]; + Inc (I); + end; + end; + end + else + for I := 1 to Length (Result) do + Result [I] := LowerChars [Result [I]]; + end; + end; +end; + + +function OS2CompareStrAnsiString (const S1, S2: AnsiString): PtrInt; +var + I, MaxLen: PtrUInt; +begin + if UniAPI then + Result := OS2CompareUnicodeString (S1, S2) (* implicit conversions *) + else +(* Older OS/2 versions without Unicode support do not provide direct means *) +(* for case sensitive and codepage and language-aware string comparison. *) +(* We have to resort to manual comparison of the original strings together *) +(* with strings translated using the case insensitive collation sequence. *) + begin + if Length (S1) = 0 then + begin + if Length (S2) = 0 then + Result := 0 + else + Result := -1; + Exit; + end + else + if Length (S2) = 0 then + begin + Result := 1; + Exit; + end; + I := 1; + MaxLen := Length (S1); + if Length (S2) < MaxLen then + MaxLen := Length (S2); + repeat + if CollationSequence [S1 [I]] = CollationSequence [S2 [I]] then + begin + if S1 [I] < S2 [I] then + begin + Result := -1; + Exit; + end + else if S1 [I] > S2 [I] then + begin + Result := 1; + Exit; + end; + end + else + begin + if CollationSequence [S1 [I]] < CollationSequence [S2 [I]] then + Result := -1 + else + Result := 1; + Exit; + end; + Inc (I); + until (I > MaxLen); + if Length (S2) > MaxLen then + Result := -1 + else if Length (S1) > MaxLen then + Result := 1 + else + Result := 0; + end; +end; + + +function OS2StrCompAnsiString (S1, S2: PChar): PtrInt; +var + HSA1, HSA2: AnsiString; + HSU1, HSU2: UnicodeString; +begin +(* Do not call OS2CompareUnicodeString to skip scanning for #0. *) + HSA1 := AnsiString (S1); + HSA2 := AnsiString (S2); + if UniApi then + begin + HSU1 := HSA1; (* implicit conversion *) + HSU2 := HSA2; (* implicit conversion *) + Result := Sys_UniStrColl (DefLocObj, PWideChar (HSU1), PWideChar (HSU2)); + if Result < -1 then + Result := -1 + else if Result > 1 then + Result := 1; + end + else + Result := OS2CompareStrAnsiString (HSA1, HSA2); +end; + + +function OS2CompareTextAnsiString (const S1, S2: AnsiString): PtrInt; +var + HSA1, HSA2: AnsiString; + I: PtrUInt; +begin + if UniAPI then + Result := OS2CompareTextUnicodeString (S1, S2) (* implicit conversions *) + else + begin +(* Let's use collation strings here as a fallback *) + SetLength (HSA1, Length (S1)); + if Length (HSA1) > 0 then +(* Using assembler would be much faster, but never mind... *) + for I := 1 to Length (HSA1) do + HSA1 [I] := CollationSequence [S1 [I]]; +{$WARNING Results of using collation sequence with DBCS not known/tested!} + SetLength (HSA2, Length (S2)); + if Length (HSA2) > 0 then + for I := 1 to Length (HSA2) do + HSA2 [I] := CollationSequence [S2 [I]]; + if HSA1 = HSA2 then + Result := 0 + else if HSA1 < HSA2 then + Result := -1 + else + Result := 1; + end; +end; + + +function OS2StrICompAnsiString (S1, S2: PChar): PtrInt; +begin + Result := OS2CompareTextAnsiString (AnsiString (S1), AnsiString (S2)); +end; + + +function OS2StrLCompAnsiString (S1, S2: PChar; MaxLen: PtrUInt): PtrInt; +var + A, B: AnsiString; +begin + if (MaxLen = 0) then + Exit (0); + SetLength (A, MaxLen); + Move (S1^, A [1], MaxLen); + SetLength (B, MaxLen); + Move (S2^, B [1], MaxLen); + Result := OS2CompareStrAnsiString (A, B); +end; + + +function OS2StrLICompAnsiString (S1, S2: PChar; MaxLen: PtrUInt): PtrInt; +var + A, B: AnsiString; +begin + if (MaxLen = 0) then + Exit (0); + SetLength (A, MaxLen); + Move (S1^, A [1], MaxLen); + SetLength (B, MaxLen); + Move (S2^, B [1], MaxLen); + Result := OS2CompareTextAnsiString (A, B); +end; + + +procedure FPC_RangeError; [external name 'FPC_RANGEERROR']; + + +procedure Ansi2PChar (const S: AnsiString; const OrgP: PChar; out P: Pchar); +var + NewLen: SizeUInt; +begin + NewLen := Length (S); + if NewLen > StrLen (OrgP) then + FPC_RangeError; + P := OrgP; + if (NewLen > 0) then + Move (S [1], P [0], NewLen); + P [NewLen] := #0; +end; + + +function OS2StrUpperAnsiString (Str: PChar): PChar; +var + Temp: AnsiString; +begin + Temp := OS2UpperAnsiString (Str); + Ansi2PChar (Temp, Str, Result); +end; + + +function OS2StrLowerAnsiString (Str: PChar): PChar; +var + Temp: AnsiString; +begin + Temp := OS2LowerAnsiString (Str); + Ansi2PChar (Temp, Str, Result); +end; + + +(* +CWSTRING: +{ return value: number of code points in the string. Whenever an invalid + code point is encountered, all characters part of this invalid code point + are considered to form one "character" and the next character is + considered to be the start of a new (possibly also invalid) code point } +function CharLengthPChar(const Str: PChar): PtrInt; + var + nextlen: ptrint; + s: pchar; +{$ifndef beos} + mbstate: mbstate_t; +{$endif not beos} + begin + result:=0; + s:=str; +{$ifndef beos} + fillchar(mbstate,sizeof(mbstate),0); +{$endif not beos} + repeat +{$ifdef beos} + nextlen:=ptrint(mblen(s,MB_CUR_MAX)); +{$else beos} + nextlen:=ptrint(mbrlen(s,MB_CUR_MAX,@mbstate)); +{$endif beos} + { skip invalid/incomplete sequences } + if (nextlen<0) then + nextlen:=1; + inc(result,1); + inc(s,nextlen); + until (nextlen=0); + end; + + +function CodePointLength(const Str: PChar; maxlookahead: ptrint): PtrInt; + var + nextlen: ptrint; +{$ifndef beos} + mbstate: mbstate_t; +{$endif not beos} + begin +{$ifdef beos} + result:=ptrint(mblen(str,maxlookahead)); +{$else beos} + fillchar(mbstate,sizeof(mbstate),0); + result:=ptrint(mbrlen(str,maxlookahead,@mbstate)); + { mbrlen can also return -2 for "incomplete but potially valid character + and data has been processed" } + if result<0 then + result:=-1; +{$endif beos} + end; +*) + +procedure InitOS2WideStringManager; inline; +var + RC: cardinal; + ErrName: array [0..MaxPathLen] of char; + P: pointer; +begin + RC := DosLoadModule (@ErrName [0], SizeOf (ErrName), @UConvName [0], + UConvHandle); + if RC = 0 then + begin + RC := DosQueryProcAddr (UConvHandle, OrdUniCreateUConvObject, nil, P); + if RC = 0 then + begin + Sys_UniCreateUConvObject := TUniCreateUConvObject (P); + RC := DosQueryProcAddr (UConvHandle, OrdUniMapCpToUcsCp, nil, P); + if RC = 0 then + begin + Sys_UniMapCpToUcsCp := TUniMapCpToUcsCp (P); + RC := DosQueryProcAddr (UConvHandle, OrdUniFreeUConvObject, nil, P); + if RC = 0 then + begin + Sys_UniFreeUConvObject := TUniFreeUConvObject (P); + RC := DosQueryProcAddr (UConvHandle, OrdUniUConvFromUcs, nil, P); + if RC = 0 then + begin + Sys_UniUConvFromUcs := TUniUConvFromUcs (P); + RC := DosQueryProcAddr (UConvHandle, OrdUniUConvToUcs, nil, P); + if RC = 0 then + begin + Sys_UniUConvToUcs := TUniUConvToUcs (P); + + RC := DosLoadModule (@ErrName [0], SizeOf (ErrName), + @LibUniName [0], LibUniHandle); + if RC = 0 then + begin + RC := DosQueryProcAddr (LibUniHandle, OrdUniToLower, nil, P); + if RC = 0 then + begin + Sys_UniToLower := TUniToLower (P); + RC := DosQueryProcAddr (LibUniHandle, OrdUniToUpper, nil, P); + if RC = 0 then + begin + Sys_UniToUpper := TUniToUpper (P); + RC := DosQueryProcAddr (LibUniHandle, OrdUniStrColl, nil, + P); + if RC = 0 then + begin + Sys_UniStrColl := TUniStrColl (P); + RC := DosQueryProcAddr (LibUniHandle, + OrdUniCreateLocaleObject, nil, P); + if RC = 0 then + begin + Sys_UniCreateLocaleObject := TUniCreateLocaleObject + (P); + RC := DosQueryProcAddr (LibUniHandle, + OrdUniFreeLocaleObject, nil, P); + if RC = 0 then + begin + Sys_UniFreeLocaleObject := TUniFreeLocaleObject (P); + + UniAPI := true; + end; + end; + end; + end; + end; + end; + end; + end; + end; + end; + end; + end; + if RC <> 0 then + OSErrorWatch (RC); + if not (UniAPI) then + begin + Sys_UniCreateUConvObject := @DummyUniCreateUConvObject; + Sys_UniMapCpToUcsCp := @DummyUniMapCpToUcsCp; + Sys_UniFreeUConvObject := @DummyUniFreeUConvObject; + Sys_UniUConvFromUcs := @DummyUniUConvFromUcs; + Sys_UniUConvToUcs := @DummyUniUConvToUcs; + Sys_UniToLower := @DummyUniToLower; + Sys_UniToUpper := @DummyUniToUpper; + Sys_UniStrColl := @DummyUniStrColl; + Sys_UniCreateLocaleObject := @DummyUniCreateLocaleObject; + Sys_UniFreeLocaleObject := @DummyUniFreeLocaleObject; + InitDummyAnsiSupport; + end; + + { Widestring } + WideStringManager.Wide2AnsiMoveProc := @OS2Unicode2AnsiMove; + WideStringManager.Ansi2WideMoveProc := @OS2Ansi2UnicodeMove; + WideStringManager.UpperWideStringProc := @OS2UpperUnicodeString; + WideStringManager.LowerWideStringProc := @OS2LowerUnicodeString; + WideStringManager.CompareWideStringProc := @OS2CompareUnicodeString; + WideStringManager.CompareTextWideStringProc := @OS2CompareTextUnicodeString; + { Unicode } + WideStringManager.Unicode2AnsiMoveProc := @OS2Unicode2AnsiMove; + WideStringManager.Ansi2UnicodeMoveProc := @OS2Ansi2UnicodeMove; + WideStringManager.UpperUnicodeStringProc := @OS2UpperUnicodeString; + WideStringManager.LowerUnicodeStringProc := @OS2LowerUnicodeString; + WideStringManager.CompareUnicodeStringProc := @OS2CompareUnicodeString; + WideStringManager.CompareTextUnicodeStringProc := + @OS2CompareTextUnicodeString; + { Codepage } + WideStringManager.GetStandardCodePageProc := @OS2GetStandardCodePage; +(* + CharLengthPCharProc:=@CharLengthPChar; + CodePointLengthProc:=@CodePointLength; +*) + WideStringManager.UpperAnsiStringProc := @OS2UpperAnsiString; + WideStringManager.LowerAnsiStringProc := @OS2LowerAnsiString; + WideStringManager.CompareStrAnsiStringProc := @OS2CompareStrAnsiString; + WideStringManager.CompareTextAnsiStringProc := @OS2CompareTextAnsiString; + WideStringManager.StrCompAnsiStringProc := @OS2StrCompAnsiString; + WideStringManager.StrICompAnsiStringProc := @OS2StrICompAnsiString; + WideStringManager.StrLCompAnsiStringProc := @OS2StrLCompAnsiString; + WideStringManager.StrLICompAnsiStringProc := @OS2StrLICompAnsiString; + WideStringManager.StrLowerAnsiStringProc := @OS2StrLowerAnsiString; + WideStringManager.StrUpperAnsiStringProc := @OS2StrUpperAnsiString; +end; diff --git a/rtl/os2/sysutils.pp b/rtl/os2/sysutils.pp index 20bb39b516..80a94a4119 100644 --- a/rtl/os2/sysutils.pp +++ b/rtl/os2/sysutils.pp @@ -23,6 +23,7 @@ interface {$H+} {$DEFINE HAS_SLEEP} +{$DEFINE HAS_OSERROR} { used OS file system APIs use ansistring } {$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL} @@ -43,6 +44,9 @@ type (* Necessary here due to a different definition of TDateTime in DosCalls. *) TDateTime = System.TDateTime; +threadvar + LastOSError: cardinal; + {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *) {$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *) {$DEFINE FPC_FEXPAND_GETENV_PCHAR} @@ -83,8 +87,11 @@ begin If Rc=0 then FileOpen:=Handle else + begin FileOpen:=feInvalidHandle; //FileOpen:=-RC; //should return feInvalidHandle(=-1) if fail, other negative returned value are no more errors + OSErrorWatch (RC); + end; end; function FileCreate (const FileName: RawByteString): THandle; @@ -115,56 +122,84 @@ begin if RC = 0 then FileCreate := Handle else - FileCreate := feInvalidHandle; + begin + FileCreate := feInvalidHandle; + OSErrorWatch (RC); + end; End; function FileRead (Handle: THandle; Out Buffer; Count: longint): longint; Var T: cardinal; + RC: cardinal; begin - DosRead(Handle, Buffer, Count, T); + RC := DosRead (Handle, Buffer, Count, T); FileRead := longint (T); + if RC <> 0 then + OSErrorWatch (RC); end; function FileWrite (Handle: THandle; const Buffer; Count: longint): longint; Var T: cardinal; + RC: cardinal; begin - DosWrite (Handle, Buffer, Count, T); + RC := DosWrite (Handle, Buffer, Count, T); FileWrite := longint (T); + if RC <> 0 then + OSErrorWatch (RC); end; function FileSeek (Handle: THandle; FOffset, Origin: longint): longint; var NPos: int64; + RC: cardinal; begin - if (Sys_DosSetFilePtrL (Handle, FOffset, Origin, NPos) = 0) - and (NPos < high (longint)) then + RC := Sys_DosSetFilePtrL (Handle, FOffset, Origin, NPos); + if (RC = 0) and (NPos < high (longint)) then FileSeek:= longint (NPos) else + begin FileSeek:=-1; + OSErrorWatch (RC); + end; end; function FileSeek (Handle: THandle; FOffset: Int64; Origin: Longint): Int64; var NPos: int64; + RC: cardinal; begin - if Sys_DosSetFilePtrL (Handle, FOffset, Origin, NPos) = 0 then + RC := Sys_DosSetFilePtrL (Handle, FOffset, Origin, NPos); + if RC = 0 then FileSeek:= NPos else + begin FileSeek:=-1; + OSErrorWatch (RC); + end; end; procedure FileClose (Handle: THandle); +var + RC: cardinal; begin - DosClose(Handle); + RC := DosClose (Handle); + if RC <> 0 then + OSErrorWatch (RC); end; function FileTruncate (Handle: THandle; Size: Int64): boolean; +var + RC: cardinal; begin - FileTruncate:=Sys_DosSetFileSizeL(Handle, Size)=0; - FileSeek(Handle, 0, 2); + RC := Sys_DosSetFileSizeL(Handle, Size); + FileTruncate := RC = 0; + if RC = 0 then + FileSeek(Handle, 0, 2) + else + OSErrorWatch (RC); end; function FileAge (const FileName: RawByteString): longint; @@ -222,7 +257,9 @@ begin else Err := DosFindFirst (PChar (SystemEncodedPath), Rslt.FindHandle, Attr and FindResvdMask, FStat, SizeOf (FStat^), Count, ilStandard); - if (Err = 0) and (Count = 0) then + if Err <> 0 then + OSErrorWatch (Err) + else if Count = 0 then Err := 18; InternalFindFirst := -Err; if Err = 0 then @@ -261,7 +298,9 @@ begin New (FStat); Count := 1; Err := DosFindNext (Rslt.FindHandle, FStat, SizeOf (FStat^), Count); - if (Err = 0) and (Count = 0) then + if Err <> 0 then + OSErrorWatch (Err) + else if Count = 0 then Err := 18; InternalFindNext := -Err; if Err = 0 then @@ -290,9 +329,12 @@ end; Procedure InternalFindClose(var Handle: THandle); var SR: PSearchRec; + RC: cardinal; begin - DosFindClose (Handle); + RC := DosFindClose (Handle); Handle := 0; + if RC <> 0 then + OSErrorWatch (RC); end; function FileGetDate (Handle: THandle): longint; @@ -308,7 +350,10 @@ begin if Time = 0 then Time := FStat.TimeCreation + longint (FStat.DateCreation) shl 16; end else + begin Time:=0; + OSErrorWatch (RC); + end; FileGetDate:=Time; end; @@ -320,19 +365,25 @@ begin New (FStat); RC := DosQueryFileInfo (Handle, ilStandard, FStat, SizeOf (FStat^)); if RC <> 0 then - FileSetDate := -1 + begin + FileSetDate := -1; + OSErrorWatch (RC); + end else - begin + begin FStat^.DateLastAccess := Hi (Age); FStat^.DateLastWrite := Hi (Age); FStat^.TimeLastAccess := Lo (Age); FStat^.TimeLastWrite := Lo (Age); RC := DosSetFileInfo (Handle, ilStandard, FStat, SizeOf (FStat^)); if RC <> 0 then - FileSetDate := -1 + begin + FileSetDate := -1; + OSErrorWatch (RC); + end else - FileSetDate := 0; - end; + FileSetDate := 0; + end; Dispose (FStat); end; @@ -340,11 +391,18 @@ function FileGetAttr (const FileName: RawByteString): longint; var FS: PFileStatus3; SystemFileName: RawByteString; + RC: cardinal; begin SystemFileName:=ToSingleByteFileSystemEncodedFileName(Filename); New(FS); - Result:=-DosQueryPathInfo(PChar (SystemFileName), ilStandard, FS, SizeOf(FS^)); - If Result=0 Then Result:=FS^.attrFile; + RC := DosQueryPathInfo(PChar (SystemFileName), ilStandard, FS, SizeOf(FS^)); + if RC = 0 then + Result := FS^.AttrFile + else + begin + Result := - longint (RC); + OSErrorWatch (RC); + end; Dispose(FS); end; @@ -352,12 +410,16 @@ function FileSetAttr (const Filename: RawByteString; Attr: longint): longint; Var FS: PFileStatus3; SystemFileName: RawByteString; + RC: cardinal; Begin SystemFileName:=ToSingleByteFileSystemEncodedFileName(Filename); New(FS); FillChar(FS, SizeOf(FS^), 0); FS^.AttrFile:=Attr; - Result:=-DosSetPathInfo(PChar (SystemFileName), ilStandard, FS, SizeOf(FS^), 0); + RC := DosSetPathInfo(PChar (SystemFileName), ilStandard, FS, SizeOf(FS^), 0); + if RC <> 0 then + OSErrorWatch (RC); + Result := - longint (RC); Dispose(FS); end; @@ -365,18 +427,34 @@ end; function DeleteFile (const FileName: RawByteString): boolean; var SystemFileName: RawByteString; + RC: cardinal; Begin SystemFileName:=ToSingleByteFileSystemEncodedFileName(Filename); - Result:=(DosDelete(PChar (SystemFileName))=0); + RC := DosDelete (PChar (SystemFileName)); + if RC <> 0 then + begin + Result := false; + OSErrorWatch (RC); + end + else + Result := true; End; function RenameFile (const OldName, NewName: RawByteString): boolean; var OldSystemFileName, NewSystemFileName: RawByteString; + RC: cardinal; Begin OldSystemFileName:=ToSingleByteFileSystemEncodedFileName(OldName); NewSystemFileName:=ToSingleByteFileSystemEncodedFileName(NewName); - Result:=(DosMove(PChar (OldSystemFileName), PChar (NewSystemFileName))=0); + RC := DosMove (PChar (OldSystemFileName), PChar (NewSystemFileName)); + if RC <> 0 then + begin + Result := false; + OSErrorWatch (RC); + end + else + Result := true; End; {**************************************************************************** @@ -389,13 +467,16 @@ var FI: TFSinfo; RC: cardinal; begin - {In OS/2, we use the filesystem information.} - RC := DosQueryFSInfo (Drive, 1, FI, SizeOf (FI)); - if RC = 0 then - DiskFree := int64 (FI.Free_Clusters) * + {In OS/2, we use the filesystem information.} + RC := DosQueryFSInfo (Drive, 1, FI, SizeOf (FI)); + if RC = 0 then + DiskFree := int64 (FI.Free_Clusters) * int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector) - else - DiskFree := -1; + else + begin + DiskFree := -1; + OSErrorWatch (RC); + end; end; function DiskSize (Drive: byte): int64; @@ -404,13 +485,16 @@ var FI: TFSinfo; RC: cardinal; begin - {In OS/2, we use the filesystem information.} - RC := DosQueryFSinfo (Drive, 1, FI, SizeOf (FI)); - if RC = 0 then - DiskSize := int64 (FI.Total_Clusters) * + {In OS/2, we use the filesystem information.} + RC := DosQueryFSinfo (Drive, 1, FI, SizeOf (FI)); + if RC = 0 then + DiskSize := int64 (FI.Total_Clusters) * int64 (FI.Sectors_Per_Cluster) * int64 (FI.Bytes_Per_Sector) - else - DiskSize := -1; + else + begin + DiskSize := -1; + OSErrorWatch (RC); + end; end; @@ -469,17 +553,21 @@ end; procedure sysbeep; begin - // Maybe implement later on ? - + DosBeep (800, 250); end; {**************************************************************************** Locale Functions ****************************************************************************} +var + Country: TCountryCode; + CtryInfo: TCountryInfo; + procedure InitAnsi; -var I: byte; - Country: TCountryCode; +var + I: byte; + RC: cardinal; begin for I := 0 to 255 do UpperCaseTable [I] := Chr (I); @@ -493,46 +581,63 @@ end; procedure InitInternational; -var Country: TCountryCode; - CtryInfo: TCountryInfo; - Size: cardinal; - RC: cardinal; +var + Size: cardinal; + RC: cardinal; begin - Size := 0; - FillChar (Country, SizeOf (Country), 0); - FillChar (CtryInfo, SizeOf (CtryInfo), 0); - RC := DosQueryCtryInfo (SizeOf (CtryInfo), Country, CtryInfo, Size); - if RC = 0 then - begin - DateSeparator := CtryInfo.DateSeparator; - case CtryInfo.DateFormat of - 1: begin - ShortDateFormat := 'd/m/y'; - LongDateFormat := 'dd" "mmmm" "yyyy'; - end; - 2: begin - ShortDateFormat := 'y/m/d'; - LongDateFormat := 'yyyy" "mmmm" "dd'; - end; - 3: begin - ShortDateFormat := 'm/d/y'; - LongDateFormat := 'mmmm" "dd" "yyyy'; - end; - end; - TimeSeparator := CtryInfo.TimeSeparator; - DecimalSeparator := CtryInfo.DecimalSeparator; - ThousandSeparator := CtryInfo.ThousandSeparator; - CurrencyFormat := CtryInfo.CurrencyFormat; - CurrencyString := PChar (CtryInfo.CurrencyUnit); + Size := 0; + FillChar (Country, SizeOf (Country), 0); + FillChar (CtryInfo, SizeOf (CtryInfo), 0); + RC := DosQueryCtryInfo (SizeOf (CtryInfo), Country, CtryInfo, Size); + if RC = 0 then + begin + DateSeparator := CtryInfo.DateSeparator; + case CtryInfo.DateFormat of + 1: begin + ShortDateFormat := 'd/m/y'; + LongDateFormat := 'dd" "mmmm" "yyyy'; + end; + 2: begin + ShortDateFormat := 'y/m/d'; + LongDateFormat := 'yyyy" "mmmm" "dd'; end; - InitAnsi; - InitInternationalGeneric; + 3: begin + ShortDateFormat := 'm/d/y'; + LongDateFormat := 'mmmm" "dd" "yyyy'; + end; + end; + TimeSeparator := CtryInfo.TimeSeparator; + DecimalSeparator := CtryInfo.DecimalSeparator; + ThousandSeparator := CtryInfo.ThousandSeparator; + CurrencyFormat := CtryInfo.CurrencyFormat; + CurrencyString := PChar (CtryInfo.CurrencyUnit); + end + else + OSErrorWatch (RC); + InitAnsi; + InitInternationalGeneric; end; function SysErrorMessage(ErrorCode: Integer): String; - +const + SysMsgFile: array [0..10] of char = 'OSO001.MSG'#0; +var + OutBuf: array [0..999] of char; + RetMsgSize: cardinal; + RC: cardinal; begin - Result:=Format(SUnknownErrorCode,[ErrorCode]); + RC := DosGetMessage (nil, 0, @OutBuf [0], SizeOf (OutBuf), + ErrorCode, @SysMsgFile [0], RetMsgSize); + if RC = 0 then + begin + SetLength (Result, RetMsgSize); + Move (OutBuf [0], Result [1], RetMsgSize); + end + else + begin + Result:=Format(SUnknownErrorCode,[ErrorCode]); + OSErrorWatch (RC); + end; end; @@ -648,9 +753,10 @@ var ObjName: shortstring; RC: cardinal; ExecAppType: cardinal; + MaxArgsSize: PtrUInt; (* Amount of memory reserved for arguments in bytes. *) + MaxArgsSizeInc: word; const - MaxArgsSize = 3072; (* Amount of memory reserved for arguments in bytes. *) ObjBufSize = 512; function StartSession: cardinal; @@ -687,7 +793,10 @@ begin SD.ObjectBuffLen := ObjBufSize; RC := DosCreateQueue (HQ, quFIFO or quConvert_Address, @QName [1]); if RC <> 0 then - Move (QName [1], ObjNameBuf^, Length (QName)) + begin + Move (QName [1], ObjNameBuf^, Length (QName)); + OSErrorWatch (RC); + end else begin RC := DosStartSession (SD, SID, PID); @@ -697,15 +806,28 @@ begin if RC = 0 then begin Result := PCI^.Return; - DosCloseQueue (HQ); - DosFreeMem (PCI); + RC := DosCloseQueue (HQ); + if RC <> 0 then + OSErrorWatch (RC); + RC := DosFreeMem (PCI); + if RC <> 0 then + OSErrorWatch (RC); FreeMem (ObjNameBuf, ObjBufSize); end else - DosCloseQueue (HQ); + begin + OSErrorWatch (RC); + RC := DosCloseQueue (HQ); + OSErrorWatch (RC); + end; end else - DosCloseQueue (HQ); + begin + OSErrorWatch (RC); + RC := DosCloseQueue (HQ); + if RC <> 0 then + OSErrorWatch (RC); + end; end; end; @@ -715,52 +837,68 @@ begin GetMem (ObjNameBuf, ObjBufSize); FillChar (ObjNameBuf^, ObjBufSize, 0); - if (DosQueryAppType (PChar (Path), ExecAppType) = 0) and - (ApplicationType and 3 = ExecAppType and 3) then -(* DosExecPgm should work... *) + RC := DosQueryAppType (PChar (Path), ExecAppType); + if RC <> 0 then begin - if ComLine = '' then - begin - Args0 := nil; - Args := nil; - end - else + OSErrorWatch (RC); + if (RC = 190) or (RC = 191) then + Result := StartSession; + end + else + begin + if (ApplicationType and 3 = ExecAppType and 3) then +(* DosExecPgm should work... *) begin - GetMem (Args0, MaxArgsSize); - Args := Args0; + MaxArgsSize := Length (ComLine) + Length (Path) + 256; (* More than enough *) + if MaxArgsSize > high (word) then + Exit; + if ComLine = '' then + begin + Args0 := nil; + Args := nil; + end + else + begin + GetMem (Args0, MaxArgsSize); + Args := Args0; (* Work around a bug in OS/2 - argument to DosExecPgm *) (* should not cross 64K boundary. *) - if ((PtrUInt (Args) + 1024) and $FFFF) < 1024 then - Inc (pointer (Args), 1024); - ArgSize := 0; - Move (Path [1], Args^ [ArgSize], Length (Path)); - Inc (ArgSize, Length (Path)); - Args^ [ArgSize] := 0; - Inc (ArgSize); - {Now do the real arguments.} - Move (ComLine [1], Args^ [ArgSize], Length (ComLine)); - Inc (ArgSize, Length (ComLine)); - Args^ [ArgSize] := 0; - Inc (ArgSize); - Args^ [ArgSize] := 0; - end; - Res.ExitCode := $FFFFFFFF; - RC := DosExecPgm (ObjNameBuf, ObjBufSize, 0, Args, nil, Res, PChar (Path)); - if Args0 <> nil then - FreeMem (Args0, MaxArgsSize); - if RC = 0 then - begin - Result := Res.ExitCode; - FreeMem (ObjNameBuf, ObjBufSize); + while ((PtrUInt (Args) + MaxArgsSize) and $FFFF) < MaxArgsSize do + begin + MaxArgsSizeInc := MaxArgsSize - + ((PtrUInt (Args) + MaxArgsSize) and $FFFF); + Inc (MaxArgsSize, MaxArgsSizeInc); + if MaxArgsSize > high (word) then + Exit; + ReallocMem (Args0, MaxArgsSize); + Inc (pointer (Args), MaxArgsSizeInc); + end; + ArgSize := 0; + Move (Path [1], Args^ [ArgSize], Length (Path)); + Inc (ArgSize, Length (Path)); + Args^ [ArgSize] := 0; + Inc (ArgSize); + {Now do the real arguments.} + Move (ComLine [1], Args^ [ArgSize], Length (ComLine)); + Inc (ArgSize, Length (ComLine)); + Args^ [ArgSize] := 0; + Inc (ArgSize); + Args^ [ArgSize] := 0; + end; + Res.ExitCode := $FFFFFFFF; + RC := DosExecPgm (ObjNameBuf, ObjBufSize, 0, Args, nil, Res, + PChar (Path)); + if RC <> 0 then + OSErrorWatch (RC); + if Args0 <> nil then + FreeMem (Args0, MaxArgsSize); + if RC = 0 then + begin + Result := Res.ExitCode; + FreeMem (ObjNameBuf, ObjBufSize); + end end - else - begin - if (RC = 190) or (RC = 191) then - Result := StartSession; - end; - end - else - Result := StartSession; + end; if RC <> 0 then begin ObjName := StrPas (ObjNameBuf); @@ -805,16 +943,30 @@ begin GetTickCount := L; end; - function GetTickCount64: QWord; var - L: cardinal; + Freq2: cardinal; + T: QWord; begin - DosQuerySysInfo (svMsCount, svMsCount, L, 4); - GetTickCount64 := L; + DosTmrQueryFreq (Freq2); + DosTmrQueryTime (T); + GetTickCount64 := T div (QWord (Freq2) div 1000); +{$NOTE GetTickCount64 takes 20 microseconds on 1GHz CPU, GetTickCount not measurable} end; +const + OrigOSErrorWatch: TOSErrorWatch = nil; + +procedure TrackLastOSError (Error: cardinal); +begin + LastOSError := Error; + OrigOSErrorWatch (Error); +end; +function GetLastOSError: Integer; +begin + GetLastOSError := Integer (LastOSError); +end; {**************************************************************************** Initialization code @@ -824,6 +976,8 @@ Initialization InitExceptions; { Initialize exceptions. OS independent } InitInternational; { Initialize internationalization settings } OnBeep:=@SysBeep; + LastOSError := 0; + OrigOSErrorWatch := TOSErrorWatch (SetOSErrorTracking (@TrackLastOSError)); Finalization DoneExceptions; end. diff --git a/rtl/os2/tthread.inc b/rtl/os2/tthread.inc index 7cc4c751fc..ece7c3dc49 100644 --- a/rtl/os2/tthread.inc +++ b/rtl/os2/tthread.inc @@ -166,13 +166,16 @@ procedure TThread.SetPriority(Value: TThreadPriority); var PTIB: PThreadInfoBlock; PPIB: PProcessInfoBlock; + RC: cardinal; begin DosGetInfoBlocks (@PTIB, @PPIB); (* PTIB^.TIB2^.Priority := Priorities [Value]; *) - DosSetPriority (2, High (Priorities [Value]), + RC := DosSetPriority (2, High (Priorities [Value]), Low (Priorities [Value]) - PTIB^.TIB2^.Priority, FHandle); + if RC <> 0 then + OSErrorWatch (RC); end; @@ -213,9 +216,13 @@ end; function TThread.WaitFor: Integer; var FH: cardinal; + RC: cardinal; begin if GetCurrentThreadID = MainThreadID then while not (FFinished) do CheckSynchronize (1000); - WaitFor := DosWaitThread (FH, dtWait); + RC := DosWaitThread (FH, dtWait); + if RC <> 0 then + OSErrorWatch (RC); + WaitFor := RC; end; |