浏览代码

Merged revisions 8290,8302,8307,8309,8316,8318-8319,8336,8338-8340,8400,8404,8410-8411,8430,8438-8442,8445-8446,8448,8450-8454,8456-8457,8459,8462,8469-8470,8472-8483,8486-8488,8490,8493,8496-8497,8506,8535-8537,8539-8546,8554,8560,8575-8576,8581-8587,8590,8593-8596,8600,8605,8607,8612-8614,8622,8624-8625,8630-8638,8640-8641,8659,8665,8667,8671-8672,8676-8677,8679,8681-8682,8686-8694,8696-8697,8699,8702,8705,8708-8714,8719,8721-8723,8727,8730-8731,8742-8743,8747-8751,8754,8765-8769,8775,8778,8780-8781,8791,8797,8802-8803,8809,8816-8818,8822-8825,8827,8829,8831,8835-8836,8848-8849,8851,8860,8879,8885-8889,8891-8893,8895,8897,8901,8912,8917,8925,8942,8949-8950,8958-8961,8965,8971 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r8290 | Almindor | 2007-08-19 15:35:43 +0200 (Sun, 19 Aug 2007) | 2 lines

* add preliminary UnixSockets with linux implementation
........
r8400 | jonas | 2007-09-08 11:19:13 +0200 (Sat, 08 Sep 2007) | 2 lines

* marked TObject.InitInstance as inline
........
r8497 | florian | 2007-09-16 12:06:00 +0200 (Sun, 16 Sep 2007) | 2 lines

* fixed wrongly named defines
........
r8595 | jonas | 2007-09-21 17:09:08 +0200 (Fri, 21 Sep 2007) | 3 lines

* only print exception backtrace at end of unhandled exception in
tthread in case rtl is compiled with -dDEBUG_MT
........
r8612 | michael | 2007-09-23 12:26:00 +0200 (Sun, 23 Sep 2007) | 1 line

* Fixed carry bug in conversion of currency to string
........
r8613 | florian | 2007-09-23 15:09:24 +0200 (Sun, 23 Sep 2007) | 2 lines

* formatting fixed ;)
........
r8614 | florian | 2007-09-23 15:10:06 +0200 (Sun, 23 Sep 2007) | 2 lines

+ added more FILE_ATTRIBUTE constants, resolves #9669
........
r8622 | florian | 2007-09-23 16:59:22 +0200 (Sun, 23 Sep 2007) | 2 lines

* made SExecuteProcessFailed error message more clear
........
r8624 | marco | 2007-09-23 22:03:12 +0200 (Sun, 23 Sep 2007) | 2 lines

* dateutils.scandatetime, an inverse of formatdatetime
........
r8671 | marco | 2007-09-28 22:24:44 +0200 (Fri, 28 Sep 2007) | 2 lines

* some pchar(pointer(s)) changes (see maillist)
........
r8672 | marco | 2007-09-28 23:57:45 +0200 (Fri, 28 Sep 2007) | 2 lines

* pchar(pointer()) isms that were safe.
........
r8676 | Almindor | 2007-09-29 10:24:23 +0200 (Sat, 29 Sep 2007) | 2 lines

* fix ioCtl differences between BSD and POSIX
........
r8677 | marco | 2007-09-29 11:18:15 +0200 (Sat, 29 Sep 2007) | 2 lines

* fix for 9772
........
r8679 | Almindor | 2007-09-29 16:22:41 +0200 (Sat, 29 Sep 2007) | 2 lines

* use TIOCtlRequest instead of hard ifdefs to remove warnings
........
r8688 | hajny | 2007-09-30 02:51:40 +0200 (Sun, 30 Sep 2007) | 1 line

* missing constants for context flags added
........
r8689 | marco | 2007-09-30 13:23:33 +0200 (Sun, 30 Sep 2007) | 1 line

* fix for 9770
........
r8690 | hajny | 2007-09-30 16:05:00 +0200 (Sun, 30 Sep 2007) | 1 line

* issue sleep while polling keyboard
........
r8691 | hajny | 2007-09-30 16:14:33 +0200 (Sun, 30 Sep 2007) | 1 line

+ infrastructure for CtrlBreakHandler added
........
r8692 | hajny | 2007-09-30 16:15:37 +0200 (Sun, 30 Sep 2007) | 1 line

+ RTL exception handler for OS/2
........
r8693 | hajny | 2007-09-30 16:17:42 +0200 (Sun, 30 Sep 2007) | 1 line

+ Use CtrlBreakHandler infrastructure to allow processing of Ctrl-C in ReadKey (OS/2 implementation)
........
r8694 | micha | 2007-09-30 16:53:54 +0200 (Sun, 30 Sep 2007) | 1 line

+ add i386-linux uclibc process startup code
........
r8696 | hajny | 2007-09-30 17:18:37 +0200 (Sun, 30 Sep 2007) | 1 line

+ common CtrlBreakHandler for unit Keyboard
........
r8697 | hajny | 2007-09-30 17:19:59 +0200 (Sun, 30 Sep 2007) | 1 line

+ make use of the provided CtrlBreakHandler (OS/2)
........
r8699 | hajny | 2007-09-30 18:14:07 +0200 (Sun, 30 Sep 2007) | 1 line

* fix compilation by moving wrongly placed SYSTEMEXCEPTIONDEBUG defines
........
r8708 | hajny | 2007-09-30 23:35:36 +0200 (Sun, 30 Sep 2007) | 1 line

* missing AF_INET added
........
r8709 | hajny | 2007-10-01 01:24:55 +0200 (Mon, 01 Oct 2007) | 1 line

+ stdconvs and fmtbcd now compiled too (the latter needed for fcl-db)
........
r8742 | peter | 2007-10-07 20:36:18 +0200 (Sun, 07 Oct 2007) | 4 lines

* optimized generic implementations to use pointers instead of
array accesses. This also allows better register variable
optimizations
........
r8754 | jonas | 2007-10-09 13:00:15 +0200 (Tue, 09 Oct 2007) | 3 lines

* fixed generic index- and comparebyte/word/dword for limits which
overflow the pointer range (fixes tw3612 regression on sparc/solaris)
........
r8765 | jonas | 2007-10-11 19:10:29 +0200 (Thu, 11 Oct 2007) | 3 lines

* len=0 should not be treated as overflow in comparebyte/word/dword
(further fix to r8754, fixes regresssion of twide4 on sparc/solaris)
........
r8775 | marco | 2007-10-12 22:54:15 +0200 (Fri, 12 Oct 2007) | 2 lines

* Faster overloaded inttobin 32-bit and 64-bit.
........
r8778 | florian | 2007-10-13 21:06:41 +0200 (Sat, 13 Oct 2007) | 3 lines

* fixed Index* for 64 Bit CPUs
* use forward move as much as possible
........
r8780 | marco | 2007-10-13 21:40:16 +0200 (Sat, 13 Oct 2007) | 2 lines

* Spaces version improved.
........
r8781 | micha | 2007-10-13 22:25:46 +0200 (Sat, 13 Oct 2007) | 1 line

* fix initial state of basicevent
........
r8791 | marco | 2007-10-14 13:25:19 +0200 (Sun, 14 Oct 2007) | 3 lines

* turn implicit exceptions off for most strutils routines.
+/-20% decrease in size
........
r8802 | florian | 2007-10-14 20:31:04 +0200 (Sun, 14 Oct 2007) | 3 lines

+ added critical section protection for putmouseevent, just in case
* typo fixed
........
r8803 | florian | 2007-10-14 20:31:32 +0200 (Sun, 14 Oct 2007) | 2 lines

* whitespaces fixed
........
r8809 | florian | 2007-10-14 23:05:44 +0200 (Sun, 14 Oct 2007) | 2 lines

* fixed arm-linux compilation with FPC_USE_LIBC
........
r8816 | jonas | 2007-10-15 15:51:51 +0200 (Mon, 15 Oct 2007) | 4 lines

* moved inclusion of sysos.inc higher up in system.inc, so that
cgeneric.inc can use the C types
* imports of C routines in cgeneric.inc now use C types
........
r8817 | jonas | 2007-10-15 15:58:45 +0200 (Mon, 15 Oct 2007) | 2 lines

* fixed some type casts
........
r8818 | jonas | 2007-10-15 16:02:30 +0200 (Mon, 15 Oct 2007) | 2 lines

* one more typecast fix
........
r8823 | peter | 2007-10-16 19:53:00 +0200 (Tue, 16 Oct 2007) | 2 lines

* fixed alignment leftover in compare
........
r8824 | peter | 2007-10-16 21:12:29 +0200 (Tue, 16 Oct 2007) | 2 lines

* cache inoutres threadvar address
........
r8825 | peter | 2007-10-16 21:13:53 +0200 (Tue, 16 Oct 2007) | 3 lines

* cache stdout threadvar in catchunhandledexception
* retrieve the address of io exception texts instead of assigning to a string
........
r8827 | florian | 2007-10-16 22:32:59 +0200 (Tue, 16 Oct 2007) | 2 lines

* fixed Compare* for CPUs requiring natural alignment
........
r8829 | florian | 2007-10-16 23:14:41 +0200 (Tue, 16 Oct 2007) | 2 lines

* fixed compilation on non sigbusing cpus
........
r8835 | micha | 2007-10-17 22:49:25 +0200 (Wed, 17 Oct 2007) | 1 line

* use sem_timedwait for BasicEventWaitFor if available (linux now)
........
r8836 | jonas | 2007-10-17 23:14:01 +0200 (Wed, 17 Oct 2007) | 2 lines

* initialise timespec.tv_sec again for generic BasicEventWaitFor
........
r8860 | jonas | 2007-10-20 11:25:50 +0200 (Sat, 20 Oct 2007) | 2 lines

- removed double entry for convutils unit reported on irc
........
r8901 | florian | 2007-10-21 21:53:11 +0200 (Sun, 21 Oct 2007) | 2 lines

- removed odd assembler implementation, using the inline variant usually creates better code
........
r8925 | michael | 2007-10-25 09:22:14 +0200 (Thu, 25 Oct 2007) | 1 line

* Fixed TWriter so it streams csSubcomponentt only when streaming its owner; not from all references to it
........
r8949 | micha | 2007-10-26 20:39:04 +0200 (Fri, 26 Oct 2007) | 1 line

* fix loading of exit code in haltproc for armeb, exitcode is 32 bit
........
r8958 | florian | 2007-10-27 22:19:58 +0200 (Sat, 27 Oct 2007) | 1 line

* properties set
........
r8959 | florian | 2007-10-27 22:21:41 +0200 (Sat, 27 Oct 2007) | 1 line

* monster line fixed
........
r8960 | florian | 2007-10-27 22:23:17 +0200 (Sat, 27 Oct 2007) | 1 line

* try to read caller address only when we got a proper base pointer
........
r8961 | florian | 2007-10-27 22:42:48 +0200 (Sat, 27 Oct 2007) | 2 lines

* last commit fixed, the steps are: saving, testing, committing, not testing, saving, commtting ;)
........
r8965 | florian | 2007-10-28 11:24:45 +0100 (Sun, 28 Oct 2007) | 1 line

* properties set
........
r8971 | florian | 2007-10-28 15:46:41 +0100 (Sun, 28 Oct 2007) | 2 lines

* fixes widestring range checking, resolves #10013
........

git-svn-id: branches/fixes_2_2@9006 -

peter 18 年之前
父节点
当前提交
4420e1e72a
共有 62 个文件被更改,包括 2619 次插入1082 次删除
  1. 10 4
      .gitattributes
  2. 2 1
      rtl/arm/arm.inc
  3. 2 0
      rtl/arm/math.inc
  4. 1 1
      rtl/bsd/ossysc.inc
  5. 1 0
      rtl/darwin/ptypes.inc
  6. 1 0
      rtl/freebsd/ptypes.inc
  7. 0 2
      rtl/i386/fastmove.inc
  8. 2 96
      rtl/i386/i386.inc
  9. 18 47
      rtl/inc/cgeneric.inc
  10. 35 1
      rtl/inc/crt.inc
  11. 497 208
      rtl/inc/generic.inc
  12. 3 1
      rtl/inc/heaptrc.pp
  13. 31 0
      rtl/inc/keyboard.inc
  14. 36 30
      rtl/inc/lnfodwrf.pp
  15. 6 6
      rtl/inc/objpas.inc
  16. 1 1
      rtl/inc/objpash.inc
  17. 12 7
      rtl/inc/sstrings.inc
  18. 61 19
      rtl/inc/system.inc
  19. 16 20
      rtl/inc/systemh.inc
  20. 1 1
      rtl/inc/wstrings.inc
  21. 17 3
      rtl/linux/Makefile
  22. 1 1
      rtl/linux/Makefile.fpc
  23. 1 2
      rtl/linux/arm/prt0.as
  24. 114 0
      rtl/linux/i386/si_uc.inc
  25. 1 1
      rtl/linux/ossysc.inc
  26. 2 0
      rtl/linux/ptypes.inc
  27. 26 0
      rtl/linux/si_uc.pp
  28. 2 2
      rtl/linux/system.pp
  29. 34 0
      rtl/linux/unixsockets.inc
  30. 33 0
      rtl/linux/unixsocketsh.inc
  31. 1 0
      rtl/netbsd/ptypes.inc
  32. 300 0
      rtl/objpas/dateutil.inc
  33. 106 25
      rtl/objpas/strutils.pp
  34. 7 1
      rtl/objpas/sysconst.pp
  35. 46 40
      rtl/objpas/sysutils/dati.inc
  36. 16 14
      rtl/objpas/sysutils/sysstr.inc
  37. 24 22
      rtl/objpas/sysutils/sysutils.inc
  38. 1 0
      rtl/openbsd/ptypes.inc
  39. 110 105
      rtl/os2/Makefile
  40. 10 3
      rtl/os2/Makefile.fpc
  41. 58 43
      rtl/os2/crt.pas
  42. 60 50
      rtl/os2/doscalls.pas
  43. 3 2
      rtl/os2/keyboard.pp
  44. 9 0
      rtl/os2/prt0.as
  45. 1 0
      rtl/os2/sockets.pas
  46. 220 161
      rtl/os2/sysos.inc
  47. 460 77
      rtl/os2/system.pas
  48. 1 0
      rtl/solaris/ptypes.inc
  49. 1 0
      rtl/unix/aliasptp.inc
  50. 1 1
      rtl/unix/bunxh.inc
  51. 39 1
      rtl/unix/cthreads.pp
  52. 1 1
      rtl/unix/oscdeclh.inc
  53. 17 17
      rtl/unix/sysutils.pp
  54. 4 0
      rtl/unix/tthread.inc
  55. 19 0
      rtl/unix/unixsockets.pas
  56. 5 6
      rtl/win/crt.pp
  57. 3 1
      rtl/win/mouse.pp
  58. 0 2
      rtl/win/systhrd.inc
  59. 9 1
      rtl/win/wininc/defines.inc
  60. 68 54
      rtl/win64/Makefile
  61. 1 1
      rtl/win64/Makefile.fpc
  62. 51 0
      tests/webtbs/tw10013.pp

+ 10 - 4
.gitattributes

@@ -4505,8 +4505,8 @@ rtl/darwin/Makefile.fpc svneol=native#text/plain
 rtl/darwin/console.pp svneol=native#text/plain
 rtl/darwin/console.pp svneol=native#text/plain
 rtl/darwin/errno.inc svneol=native#text/plain
 rtl/darwin/errno.inc svneol=native#text/plain
 rtl/darwin/errnostr.inc -text
 rtl/darwin/errnostr.inc -text
-rtl/darwin/i386/sig_cpu.inc -text
-rtl/darwin/i386/sighnd.inc -text
+rtl/darwin/i386/sig_cpu.inc svneol=native#text/plain
+rtl/darwin/i386/sighnd.inc svneol=native#text/plain
 rtl/darwin/pmutext.inc svneol=native#text/plain
 rtl/darwin/pmutext.inc svneol=native#text/plain
 rtl/darwin/powerpc/sig_cpu.inc svneol=native#text/plain
 rtl/darwin/powerpc/sig_cpu.inc svneol=native#text/plain
 rtl/darwin/powerpc/sighnd.inc svneol=native#text/plain
 rtl/darwin/powerpc/sighnd.inc svneol=native#text/plain
@@ -4698,7 +4698,7 @@ rtl/inc/keyboard.inc svneol=native#text/plain
 rtl/inc/keybrdh.inc svneol=native#text/plain
 rtl/inc/keybrdh.inc svneol=native#text/plain
 rtl/inc/keyscan.inc svneol=native#text/plain
 rtl/inc/keyscan.inc svneol=native#text/plain
 rtl/inc/lineinfo.pp svneol=native#text/plain
 rtl/inc/lineinfo.pp svneol=native#text/plain
-rtl/inc/lnfodwrf.pp -text
+rtl/inc/lnfodwrf.pp svneol=native#text/plain
 rtl/inc/lstrings.pp svneol=native#text/plain
 rtl/inc/lstrings.pp svneol=native#text/plain
 rtl/inc/macpas.pp svneol=native#text/plain
 rtl/inc/macpas.pp svneol=native#text/plain
 rtl/inc/makefile.inc svneol=native#text/plain
 rtl/inc/makefile.inc svneol=native#text/plain
@@ -4737,7 +4737,7 @@ rtl/inc/threadh.inc svneol=native#text/plain
 rtl/inc/threadvr.inc svneol=native#text/plain
 rtl/inc/threadvr.inc svneol=native#text/plain
 rtl/inc/typefile.inc svneol=native#text/plain
 rtl/inc/typefile.inc svneol=native#text/plain
 rtl/inc/ucomplex.pp svneol=native#text/plain
 rtl/inc/ucomplex.pp svneol=native#text/plain
-rtl/inc/varerror.inc -text
+rtl/inc/varerror.inc svneol=native#text/plain
 rtl/inc/variant.inc svneol=native#text/plain
 rtl/inc/variant.inc svneol=native#text/plain
 rtl/inc/varianth.inc svneol=native#text/plain
 rtl/inc/varianth.inc svneol=native#text/plain
 rtl/inc/variants.pp svneol=native#text/plain
 rtl/inc/variants.pp svneol=native#text/plain
@@ -4777,6 +4777,7 @@ rtl/linux/i386/si_c21g.inc svneol=native#text/plain
 rtl/linux/i386/si_dll.inc svneol=native#text/plain
 rtl/linux/i386/si_dll.inc svneol=native#text/plain
 rtl/linux/i386/si_g.inc svneol=native#text/plain
 rtl/linux/i386/si_g.inc svneol=native#text/plain
 rtl/linux/i386/si_prc.inc svneol=native#text/plain
 rtl/linux/i386/si_prc.inc svneol=native#text/plain
+rtl/linux/i386/si_uc.inc svneol=native#text/plain
 rtl/linux/i386/sighnd.inc svneol=native#text/plain
 rtl/linux/i386/sighnd.inc svneol=native#text/plain
 rtl/linux/i386/sighndh.inc svneol=native#text/plain
 rtl/linux/i386/sighndh.inc svneol=native#text/plain
 rtl/linux/i386/stat.inc svneol=native#text/plain
 rtl/linux/i386/stat.inc svneol=native#text/plain
@@ -4837,6 +4838,7 @@ rtl/linux/si_dll.pp svneol=native#text/plain
 rtl/linux/si_g.pp svneol=native#text/plain
 rtl/linux/si_g.pp svneol=native#text/plain
 rtl/linux/si_intf.inc svneol=native#text/plain
 rtl/linux/si_intf.inc svneol=native#text/plain
 rtl/linux/si_prc.pp svneol=native#text/plain
 rtl/linux/si_prc.pp svneol=native#text/plain
+rtl/linux/si_uc.pp svneol=native#text/plain
 rtl/linux/signal.inc svneol=native#text/plain
 rtl/linux/signal.inc svneol=native#text/plain
 rtl/linux/sparc/bsyscall.inc svneol=native#text/plain
 rtl/linux/sparc/bsyscall.inc svneol=native#text/plain
 rtl/linux/sparc/cprt0.as svneol=native#text/plain
 rtl/linux/sparc/cprt0.as svneol=native#text/plain
@@ -4857,6 +4859,8 @@ rtl/linux/termio.pp svneol=native#text/plain
 rtl/linux/termios.inc svneol=native#text/plain
 rtl/linux/termios.inc svneol=native#text/plain
 rtl/linux/termiosproc.inc svneol=native#text/plain
 rtl/linux/termiosproc.inc svneol=native#text/plain
 rtl/linux/unixsock.inc svneol=native#text/plain
 rtl/linux/unixsock.inc svneol=native#text/plain
+rtl/linux/unixsockets.inc svneol=native#text/plain
+rtl/linux/unixsocketsh.inc svneol=native#text/plain
 rtl/linux/unxconst.inc svneol=native#text/plain
 rtl/linux/unxconst.inc svneol=native#text/plain
 rtl/linux/unxfunc.inc svneol=native#text/plain
 rtl/linux/unxfunc.inc svneol=native#text/plain
 rtl/linux/unxsockh.inc svneol=native#text/plain
 rtl/linux/unxsockh.inc svneol=native#text/plain
@@ -5456,6 +5460,7 @@ rtl/unix/timezone.inc svneol=native#text/plain
 rtl/unix/tthread.inc svneol=native#text/plain
 rtl/unix/tthread.inc svneol=native#text/plain
 rtl/unix/ttyname.inc svneol=native#text/plain
 rtl/unix/ttyname.inc svneol=native#text/plain
 rtl/unix/unix.pp svneol=native#text/plain
 rtl/unix/unix.pp svneol=native#text/plain
+rtl/unix/unixsockets.pas svneol=native#text/plain
 rtl/unix/unixtype.pp svneol=native#text/plain
 rtl/unix/unixtype.pp svneol=native#text/plain
 rtl/unix/unixutil.pp svneol=native#text/plain
 rtl/unix/unixutil.pp svneol=native#text/plain
 rtl/unix/unxdeclh.inc svneol=native#text/plain
 rtl/unix/unxdeclh.inc svneol=native#text/plain
@@ -7561,6 +7566,7 @@ tests/webtbs/tw0961.pp svneol=native#text/plain
 tests/webtbs/tw0965.pp svneol=native#text/plain
 tests/webtbs/tw0965.pp svneol=native#text/plain
 tests/webtbs/tw0966.pp svneol=native#text/plain
 tests/webtbs/tw0966.pp svneol=native#text/plain
 tests/webtbs/tw0976.pp svneol=native#text/plain
 tests/webtbs/tw0976.pp svneol=native#text/plain
+tests/webtbs/tw10013.pp svneol=native#text/plain
 tests/webtbs/tw1021.pp svneol=native#text/plain
 tests/webtbs/tw1021.pp svneol=native#text/plain
 tests/webtbs/tw1023.pp svneol=native#text/plain
 tests/webtbs/tw1023.pp svneol=native#text/plain
 tests/webtbs/tw1041.pp svneol=native#text/plain
 tests/webtbs/tw1041.pp svneol=native#text/plain

+ 2 - 1
rtl/arm/arm.inc

@@ -87,6 +87,7 @@ asm
 end ['R0'];
 end ['R0'];
 
 
 
 
+{$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 Procedure FillChar(var x;count:longint;value:byte);assembler;nostackframe;
 Procedure FillChar(var x;count:longint;value:byte);assembler;nostackframe;
 asm
 asm
@@ -136,7 +137,7 @@ asm
         strb r2,[r3],#1
         strb r2,[r3],#1
         mov pc,lr
         mov pc,lr
 end;
 end;
-
+{$endif FPC_SYSTEM_HAS_FILLCHAR}
 
 
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}

+ 2 - 0
rtl/arm/math.inc

@@ -29,6 +29,7 @@
       runerror(207);
       runerror(207);
       result:=0;
       result:=0;
     end;
     end;
+    {$ifndef FPC_SYSTEM_HAS_SQRT}
     {$define FPC_SYSTEM_HAS_SQRT}
     {$define FPC_SYSTEM_HAS_SQRT}
     function fpc_sqrt_real(d : ValReal) : ValReal;compilerproc;
     function fpc_sqrt_real(d : ValReal) : ValReal;compilerproc;
     begin
     begin
@@ -36,6 +37,7 @@
       runerror(207);
       runerror(207);
       result:=0;
       result:=0;
     end;
     end;
+    {$endif FPC_SYSTEM_HAS_SQRT}
 {$endif}
 {$endif}
     (* atn isn't supported by the linux fpe it seems
     (* atn isn't supported by the linux fpe it seems
     {$define FPC_SYSTEM_HAS_ARCTAN}
     {$define FPC_SYSTEM_HAS_ARCTAN}

+ 1 - 1
rtl/bsd/ossysc.inc

@@ -443,7 +443,7 @@ end;
   data is function-dependent.
   data is function-dependent.
 }
 }
 
 
-Function FpIOCtl(Handle:cint;Ndx: culong;Data: Pointer):cint; [public, alias : 'FPC_SYSC_IOCTL'];
+Function FpIOCtl(Handle:cint;Ndx: TIOCtlRequest;Data: Pointer):cint; [public, alias : 'FPC_SYSC_IOCTL'];
 // This was missing here, instead hardcoded in Do_IsDevice
 // This was missing here, instead hardcoded in Do_IsDevice
 begin
 begin
   FpIOCtl:=do_SysCall(syscall_nr_ioctl,handle,Ndx,TSysParam(data));
   FpIOCtl:=do_SysCall(syscall_nr_ioctl,handle,Ndx,TSysParam(data));

+ 1 - 0
rtl/darwin/ptypes.inc

@@ -33,6 +33,7 @@ type
     gid_t    = cuint32;         { used for group IDs           }
     gid_t    = cuint32;         { used for group IDs           }
     TGid     = gid_t;
     TGid     = gid_t;
     pGid     = ^gid_t;
     pGid     = ^gid_t;
+    TIOCtlRequest = cuLong;
 
 
     ino_t    = cuint32;         { used for file serial numbers }
     ino_t    = cuint32;         { used for file serial numbers }
     TIno     = ino_t;
     TIno     = ino_t;

+ 1 - 0
rtl/freebsd/ptypes.inc

@@ -31,6 +31,7 @@ type
     gid_t    = cuint32;         { used for group IDs           }
     gid_t    = cuint32;         { used for group IDs           }
     TGid     = gid_t;
     TGid     = gid_t;
     pGid     = ^gid_t;
     pGid     = ^gid_t;
+    TIOCtlRequest = cuLong;
 
 
     {$ifdef CPU64}
     {$ifdef CPU64}
      ino_t    = cuint32;           { used for file serial numbers }
      ino_t    = cuint32;           { used for file serial numbers }

+ 0 - 2
rtl/i386/fastmove.inc

@@ -831,7 +831,6 @@ const
    fastmoveproc_forward : pointer = @Forwards_IA32_3;
    fastmoveproc_forward : pointer = @Forwards_IA32_3;
    fastmoveproc_backward : pointer = @Backwards_IA32_3;
    fastmoveproc_backward : pointer = @Backwards_IA32_3;
 
 
-{$ifndef INTERNALMOVEFILLCHAR}
 procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE'];assembler;nostackframe;
 procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE'];assembler;nostackframe;
 asm
 asm
   cmp     ecx,SMALLMOVESIZE
   cmp     ecx,SMALLMOVESIZE
@@ -862,7 +861,6 @@ asm
   jmp     dword ptr fastmoveproc_backward {Source/Dest Overlap}
   jmp     dword ptr fastmoveproc_backward {Source/Dest Overlap}
 @Done:
 @Done:
 end;
 end;
-{$endif INTERNALMOVEFILLCHAR}
 
 
 {$asmmode att}
 {$asmmode att}
 {$ifdef FPC_HAS_VALGRINDBOOL}
 {$ifdef FPC_HAS_VALGRINDBOOL}

+ 2 - 96
rtl/i386/i386.inc

@@ -94,10 +94,10 @@ function mmx_support : boolean;
        mmx_support:=false;
        mmx_support:=false;
   end;
   end;
 
 
-{$if not defined(INTERNALMOVEFILLCHAR) and not defined(FPC_SYSTEM_HAS_MOVE)}
+{$ifndef FPC_SYSTEM_HAS_MOVE}
 {$define USE_FASTMOVE}
 {$define USE_FASTMOVE}
 {$i fastmove.inc}
 {$i fastmove.inc}
-{$endif INTERNALMOVEFILLCHAR}
+{$endif FPC_SYSTEM_HAS_MOVE}
 
 
 procedure fpc_cpuinit;
 procedure fpc_cpuinit;
   begin
   begin
@@ -113,80 +113,6 @@ procedure fpc_cpuinit;
 
 
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
-{$ifdef INTERNALMOVEFILLCHAR}
-
-procedure SysMoveForward(const source;var dest;count:SizeInt);assembler;
-var
-  saveesi,saveedi : longint;
-asm
-        movl    %edi,saveedi
-        movl    %esi,saveesi
-        movl    %eax,%esi
-        movl    %edx,%edi
-        movl    %ecx,%edx
-        cld
-        cmpl    $15,%edx
-        jl      .LFMove1
-        movl    %edi,%ecx       { Align on 32bits }
-        negl    %ecx
-        andl    $3,%ecx
-        subl    %ecx,%edx
-        rep
-        movsb
-        movl    %edx,%ecx
-        andl    $3,%edx
-        shrl    $2,%ecx
-        rep
-        movsl
-.LFMove1:
-        movl    %edx,%ecx
-        rep
-        movsb
-        movl    saveedi,%edi
-        movl    saveesi,%esi
-end;
-
-procedure SysMoveBackward(const source;var dest;count:SizeInt);assembler;
-var
-  saveesi,saveedi : longint;
-asm
-        movl    %edi,saveedi
-        movl    %esi,saveesi
-        movl    %eax,%esi
-        movl    %edx,%edi
-        movl    %ecx,%edx
-        std
-        addl    %edx,%esi
-        addl    %edx,%edi
-        movl    %edi,%ecx
-        decl    %esi
-        decl    %edi
-        cmpl    $15,%edx
-        jl      .LBMove1
-        negl    %ecx            { Align on 32bits }
-        andl    $3,%ecx
-        subl    %ecx,%edx
-        rep
-        movsb
-        movl    %edx,%ecx
-        andl    $3,%edx
-        shrl    $2,%ecx
-        subl    $3,%esi
-        subl    $3,%edi
-        rep
-        movsl
-        addl    $3,%esi
-        addl    $3,%edi
-.LBMove1:
-        movl    %edx,%ecx
-        rep
-        movsb
-        cld
-        movl    saveedi,%edi
-        movl    saveesi,%esi
-end;
-
-{$else INTERNALMOVEFILLCHAR}
 
 
 procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE'];assembler;
 procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE'];assembler;
 var
 var
@@ -268,17 +194,12 @@ asm
         movl    saveesi,%esi
         movl    saveesi,%esi
 end;
 end;
 
 
-{$endif INTERNALMOVEFILLCHAR}
 {$endif FPC_SYSTEM_HAS_MOVE}
 {$endif FPC_SYSTEM_HAS_MOVE}
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
-{$ifdef INTERNALMOVEFILLCHAR}
-Procedure SysFillChar(var x;count:SizeInt;value:byte);assembler;
-{$else INTERNALMOVEFILLCHAR}
 Procedure FillChar(var x;count:SizeInt;value:byte);assembler;
 Procedure FillChar(var x;count:SizeInt;value:byte);assembler;
-{$endif INTERNALMOVEFILLCHAR}
 asm
 asm
         {A push is prefered over a local variable because a local
         {A push is prefered over a local variable because a local
          variable causes the compiler to generate a stackframe.}
          variable causes the compiler to generate a stackframe.}
@@ -1006,21 +927,6 @@ asm
 end ['EAX','EDX'];
 end ['EAX','EDX'];
 
 
 
 
-{$define FPC_SYSTEM_HAS_ODD_LONGINT}
-function odd(l:longint):boolean;assembler;nostackframe;{$ifdef SYSTEMINLINE}inline;{$endif}
-asm
-{$ifdef SYSTEMINLINE}
-       movl     l,%eax
-{$else}
-{$ifndef REGCALL}
-       movl     l,%eax
-{$endif}
-{$endif}
-       andl     $1,%eax
-       setnz    %al
-end ['EAX'];
-
-
 {$define FPC_SYSTEM_HAS_SQR_LONGINT}
 {$define FPC_SYSTEM_HAS_SQR_LONGINT}
 function sqr(l:longint):longint;assembler;nostackframe;{$ifdef SYSTEMINLINE}inline;{$endif}
 function sqr(l:longint):longint;assembler;nostackframe;{$ifdef SYSTEMINLINE}inline;{$endif}
 asm
 asm

+ 18 - 47
rtl/inc/cgeneric.inc

@@ -21,7 +21,7 @@
 
 
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
 {$define FPC_SYSTEM_HAS_MOVE}
-procedure bcopy(const source;var dest;count:sizeuint); cdecl; external 'c' name 'bcopy';
+procedure bcopy(const source;var dest;count:size_t); cdecl; external 'c' name 'bcopy';
 
 
 { we need this separate move declaration because we can't add a "public, alias" to the above }
 { we need this separate move declaration because we can't add a "public, alias" to the above }
 procedure Move(const source;var dest;count:sizeint); [public, alias: 'FPC_MOVE'];{$ifdef SYSTEMINLINE}inline;{$endif}
 procedure Move(const source;var dest;count:sizeint); [public, alias: 'FPC_MOVE'];{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -35,7 +35,7 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
 {$define FPC_SYSTEM_HAS_FILLCHAR}
-procedure memset(var x; value: byte; count: sizeuint); cdecl; external 'c';
+procedure memset(var x; value: byte; count: size_t); cdecl; external 'c';
 
 
 Procedure FillChar(var x;count: sizeint;value:byte);{$ifdef SYSTEMINLINE}inline;{$endif}
 Procedure FillChar(var x;count: sizeint;value:byte);{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
@@ -46,23 +46,12 @@ end;
 {$endif FPC_SYSTEM_HAS_FILLCHAR}
 {$endif FPC_SYSTEM_HAS_FILLCHAR}
 
 
 
 
-{$ifndef FPC_SYSTEM_HAS_FILLBYTE}
-{$define FPC_SYSTEM_HAS_FILLBYTE}
-procedure FillByte (var x;count : sizeint;value : byte );{$ifdef SYSTEMINLINE}inline;{$endif}
-begin
-  if count <= 0 then
-    exit;
-  FillChar (X,Count,value);
-end;
-{$endif not FPC_SYSTEM_HAS_FILLBYTE}
-
-
-{$ifndef FPC_SYSTEM_HAS_INDEXCHAR}
-{$define FPC_SYSTEM_HAS_INDEXCHAR}
+{$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
+{$define FPC_SYSTEM_HAS_INDEXBYTE}
 
 
-function memchr(const buf; b: sizeuint; len: cardinal): pointer; cdecl; external 'c';
+function memchr(const buf; b: cint; len: size_t): pointer; cdecl; external 'c';
 
 
-function IndexChar(Const buf;len:sizeint;b:char):sizeint;
+function IndexByte(Const buf;len:sizeint;b:byte):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
 var
 var
   res: pointer;
   res: pointer;
 begin
 begin
@@ -71,29 +60,20 @@ begin
   { simulate assembler implementations behaviour, which is expected }
   { simulate assembler implementations behaviour, which is expected }
   { fpc_pchar_to_ansistr in astrings.inc (interpret values < 0 as   }
   { fpc_pchar_to_ansistr in astrings.inc (interpret values < 0 as   }
   { unsigned)                                                       }
   { unsigned)                                                       }
-  res := memchr(buf,longint(b),cardinal(len));
+  res := memchr(buf,cint(b),size_t(sizeuint(len)));
   if (res <> nil) then
   if (res <> nil) then
-    IndexChar := SizeInt(res-@buf)
+    IndexByte := SizeInt(res-@buf)
   else
   else
-    IndexChar := -1;
-end;
-{$endif not FPC_SYSTEM_HAS_INDEXCHAR}
-
-
-{$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
-{$define FPC_SYSTEM_HAS_INDEXBYTE}
-function IndexByte(Const buf;len:sizeint;b:byte):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
-begin
-  IndexByte:=IndexChar(buf,len,char(b));
+    IndexByte := -1;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_INDEXBYTE}
 {$endif not FPC_SYSTEM_HAS_INDEXBYTE}
 
 
 
 
-{$ifndef FPC_SYSTEM_HAS_COMPARECHAR}
-{$define FPC_SYSTEM_HAS_COMPARECHAR}
-function memcmp_comparechar(Const buf1,buf2;len:sizeuint):longint; cdecl; external 'c' name 'memcmp';
+{$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
+{$define FPC_SYSTEM_HAS_COMPAREBYTE}
+function memcmp_comparechar(Const buf1,buf2;len:size_t):cint; cdecl; external 'c' name 'memcmp';
 
 
-function CompareChar(Const buf1,buf2;len:sizeint):sizeint;
+function CompareByte(Const buf1,buf2;len:sizeint):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
 var
 var
   res: longint;
   res: longint;
 begin
 begin
@@ -101,27 +81,18 @@ begin
     exit(0);
     exit(0);
   res := memcmp_comparechar(buf1,buf2,len);
   res := memcmp_comparechar(buf1,buf2,len);
   if res < 0 then
   if res < 0 then
-    CompareChar := -1
+    CompareByte := -1
   else if res > 0 then
   else if res > 0 then
-    CompareChar := 1
+    CompareByte := 1
   else
   else
-    CompareChar := 0;
-end;
-{$endif not FPC_SYSTEM_HAS_COMPARECHAR}
-
-
-{$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
-{$define FPC_SYSTEM_HAS_COMPAREBYTE}
-function CompareByte(Const buf1,buf2;len:sizeint):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
-begin
-  CompareByte := CompareChar(buf1,buf2,len);
+    CompareByte := 0;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_COMPAREBYTE}
 {$endif not FPC_SYSTEM_HAS_COMPAREBYTE}
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
 {$define FPC_SYSTEM_HAS_COMPARECHAR0}
 {$define FPC_SYSTEM_HAS_COMPARECHAR0}
-function strncmp_comparechar0(Const buf1,buf2;len:sizeuint):longint; cdecl; external 'c' name 'strncmp';
+function strncmp_comparechar0(Const buf1,buf2;len:size_t):longint; cdecl; external 'c' name 'strncmp';
 
 
 function CompareChar0(Const buf1,buf2;len:sizeint):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
 function CompareChar0(Const buf1,buf2;len:sizeint):sizeint;{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
@@ -137,7 +108,7 @@ end;
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
 
 
-function libc_pchar_length(p:pchar):sizeuint; cdecl; external 'c' name 'strlen';
+function libc_pchar_length(p:pchar):size_t; cdecl; external 'c' name 'strlen';
 
 
 function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
 function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; compilerproc;
 begin
 begin

+ 35 - 1
rtl/inc/crt.inc

@@ -15,6 +15,10 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
+var
+  ScanCode: byte;
+  SpecialKey: boolean;
+
 procedure GotoXY (X: byte; Y: byte);
 procedure GotoXY (X: byte; Y: byte);
 begin
 begin
  GotoXY32 (X, Y);
  GotoXY32 (X, Y);
@@ -381,6 +385,31 @@ end;
 {$ENDIF HAS_NOSOUND}
 {$ENDIF HAS_NOSOUND}
 
 
 
 
+var
+  PrevCtrlBreakHandler: TCtrlBreakHandler;
+
+
+function CrtCtrlBreakHandler (CtrlBreak: boolean): boolean;
+begin
+(* Earlier registered handlers (e.g. FreeVision) have priority. *)
+  if Assigned (PrevCtrlBreakHandler) then
+    if PrevCtrlBreakHandler (CtrlBreak) then
+      begin
+        CrtCtrlBreakHandler := true;
+        Exit;
+      end;
+(* If Ctrl-Break was pressed, either ignore it or allow default processing. *)
+  if CtrlBreak then
+    CrtCtrlBreakHandler := not (CheckBreak)
+  else (* Ctrl-C pressed *)
+    begin
+      if not (SpecialKey) and (ScanCode = 0) then
+        ScanCode := 3;
+      CrtCtrlBreakHandler := true;
+    end;
+end;
+
+
 procedure CrtInit;
 procedure CrtInit;
 (* Common part of unit initialization. *)
 (* Common part of unit initialization. *)
 begin
 begin
@@ -396,9 +425,14 @@ begin
   WindMax := WindMax or $FF00
   WindMax := WindMax or $FF00
  else
  else
   WindMax := WindMax or (WindMaxY shl 8);
   WindMax := WindMax or (WindMaxY shl 8);
- ExtKeyCode := #0;
+ ScanCode := 0;
+ SpecialKey := false;
  AssignCrt (Input);
  AssignCrt (Input);
  Reset (Input);
  Reset (Input);
  AssignCrt (Output);
  AssignCrt (Output);
  Rewrite (Output);
  Rewrite (Output);
+ PrevCtrlBreakHandler := SysSetCtrlBreakHandler (@CrtCtrlBreakHandler);
+ if PrevCtrlBreakHandler = TCtrlBreakHandler (pointer (-1)) then
+   PrevCtrlBreakHandler := nil;
+ CheckBreak := true;
 end;
 end;

+ 497 - 208
rtl/inc/generic.inc

@@ -23,22 +23,89 @@ type
 
 
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 {$ifndef FPC_SYSTEM_HAS_MOVE}
 procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE'];
 procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE'];
-type
-  bytearray    = array [0..high(sizeint)-1] of byte;
 var
 var
-  i:longint;
+  aligncount : sizeint;
+  pdest,psrc,pend : pbyte;
 begin
 begin
-  if count <= 0 then exit;
-  Dec(count);
-  if @source<@dest then
+  if (@dest=@source) or (count<=0) then
+    exit;
+  if (@dest<@source) or (@source+count<@dest) then
     begin
     begin
-      for i:=count downto 0 do
-        bytearray(dest)[i]:=bytearray(source)[i];
+      { Forward Move }
+      psrc:=@source;
+      pdest:=@dest;
+      if (Count>4*sizeof(ptruint)-11)
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
+        and ((PtrUInt(pdest) and (sizeof(PtrUInt)-1))=(PtrUInt(psrc) and (sizeof(PtrUInt)-1)))
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+        then
+        begin
+          { Align on native pointer size }
+          aligncount:=(PtrUInt(pdest) and (sizeof(PtrUInt)-1));
+          dec(count,aligncount);
+          pend:=psrc+aligncount;
+          while psrc<pend do
+            begin
+              pdest^:=psrc^;
+              inc(pdest);
+              inc(psrc);
+            end;
+          { use sizeuint typecast to force shr optimization }
+          pptruint(pend):=pptruint(psrc)+(sizeuint(count) div sizeof(ptruint));
+          while psrc<pend do
+            begin
+              pptruint(pdest)^:=pptruint(psrc)^;
+              inc(pptruint(pdest));
+              inc(pptruint(psrc));
+            end;
+          count:=count and (sizeof(PtrUInt)-1);
+        end;
+      pend:=psrc+count;
+      while psrc<pend do
+        begin
+          pdest^:=psrc^;
+          inc(pdest);
+          inc(psrc);
+        end;
     end
     end
   else
   else
     begin
     begin
-      for i:=0 to count do
-        bytearray(dest)[i]:=bytearray(source)[i];
+      { Backward Move }
+      psrc:=@source+count;
+      pdest:=@dest+count;
+      if (Count>4*sizeof(ptruint)-11)
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
+        and ((PtrUInt(pdest) and (sizeof(PtrUInt)-1))=(PtrUInt(psrc) and (sizeof(PtrUInt)-1)))
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+        then
+        begin
+          { Align on native pointer size }
+          aligncount:=(PtrUInt(pdest) and (sizeof(PtrUInt)-1));
+          dec(count,aligncount);
+          pend:=psrc-aligncount;
+          while psrc>pend do
+            begin
+              dec(pdest);
+              dec(psrc);
+              pdest^:=psrc^;
+            end;
+          { use sizeuint typecast to force shr optimization }
+          pptruint(pend):=pptruint(psrc)-(sizeuint(count) div sizeof(ptruint));
+          while psrc>pend do
+            begin
+              dec(pptruint(pdest));
+              dec(pptruint(psrc));
+              pptruint(pdest)^:=pptruint(psrc)^;
+            end;
+          count:=count and (sizeof(PtrUInt)-1);
+        end;
+      pend:=psrc-count;
+      while psrc>pend do
+        begin
+          dec(pdest);
+          dec(psrc);
+          pdest^:=psrc^;
+        end;
     end;
     end;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_MOVE}
 {$endif not FPC_SYSTEM_HAS_MOVE}
@@ -46,244 +113,461 @@ end;
 
 
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
 Procedure FillChar(var x;count:SizeInt;value:byte);
 Procedure FillChar(var x;count:SizeInt;value:byte);
-type
-  longintarray = array [0..high(sizeint) div 4-1] of longint;
-  bytearray    = array [0..high(sizeint)-1] of byte;
 var
 var
-  i,v : longint;
+  aligncount : sizeint;
+  pdest,pend : pbyte;
+  v : ptruint;
 begin
 begin
-  if count <= 0 then exit;
-  v := 0;
-  { aligned? }
-  if (PtrUInt(@x) mod sizeof(PtrUInt))<>0 then
+  if count <= 0 then
+    exit;
+  pdest:=@x;
+  if Count>4*sizeof(ptruint)-1 then
     begin
     begin
-      for i:=0 to count-1 do
-        bytearray(x)[i]:=value;
-    end
-  else
+      v:=(value shl 8) or value;
+      v:=(v shl 16) or v;
+      if sizeof(ptruint)=8 then
+        v:=(v shl 32) or v;
+      { Align on native pointer size }
+      aligncount:=(PtrUInt(pdest) and (sizeof(PtrUInt)-1));
+      dec(count,aligncount);
+      pend:=pdest+aligncount;
+      while pdest<pend do
+        begin
+          pdest^:=value;
+          inc(pdest);
+        end;
+      { use sizeuint typecast to force shr optimization }
+      pptruint(pend):=pptruint(pdest)+(sizeuint(count) div sizeof(ptruint));
+      while pdest<pend do
+        begin
+          pptruint(pdest)^:=v;
+          inc(pptruint(pdest));
+        end;
+      count:=count and (sizeof(ptruint)-1);
+    end;
+  pend:=pdest+count;
+  while pdest<pend do
     begin
     begin
-      v:=(value shl 8) or (value and $FF);
-      v:=(v shl 16) or (v and $ffff);
-      for i:=0 to (count div 4)-1 do
-        longintarray(x)[i]:=v;
-      for i:=(count div 4)*4 to count-1 do
-        bytearray(x)[i]:=value;
+      pdest^:=value;
+      inc(pdest);
     end;
     end;
 end;
 end;
 {$endif FPC_SYSTEM_HAS_FILLCHAR}
 {$endif FPC_SYSTEM_HAS_FILLCHAR}
 
 
 
 
-{$ifndef INTERNALMOVEFILLCHAR}
-{$ifndef FPC_SYSTEM_HAS_FILLBYTE}
-procedure FillByte (var x;count : SizeInt;value : byte );
-begin
-  FillChar (X,Count,CHR(VALUE));
-end;
-{$endif not FPC_SYSTEM_HAS_FILLBYTE}
-{$endif INTERNALMOVEFILLCHAR}
-
-
 {$ifndef FPC_SYSTEM_HAS_FILLWORD}
 {$ifndef FPC_SYSTEM_HAS_FILLWORD}
 procedure fillword(var x;count : SizeInt;value : word);
 procedure fillword(var x;count : SizeInt;value : word);
-type
-  longintarray = array [0..high(sizeint) div 4-1] of longint;
-  wordarray    = array [0..high(sizeint) div 2-1] of word;
 var
 var
-  i,v : longint;
+  aligncount : sizeint;
+  pdest,pend : pword;
+  v : ptruint;
 begin
 begin
-  if Count <= 0 then exit;
-  { aligned? }
-  if (PtrUInt(@x) mod sizeof(PtrUInt))<>0 then
+  if count <= 0 then
+    exit;
+  pdest:=@x;
+  if Count>4*sizeof(ptruint)-1 then
     begin
     begin
-      for i:=0 to count-1 do
-        wordarray(x)[i]:=value;
-    end
-  else
+      v:=(value shl 16) or value;
+      if sizeof(ptruint)=8 then
+        v:=(v shl 32) or v;
+      { Align on native pointer size }
+      aligncount:=(PtrUInt(pdest) and (sizeof(PtrUInt)-1)) shr 1;
+      dec(count,aligncount);
+      pend:=pdest+aligncount;
+      while pdest<pend do
+        begin
+          pdest^:=value;
+          inc(pdest);
+        end;
+      { use sizeuint typecast to force shr optimization }
+      pptruint(pend):=pptruint(pdest)+((sizeuint(count)*2) div sizeof(ptruint));
+      while pdest<pend do
+        begin
+          pptruint(pdest)^:=v;
+          inc(pptruint(pdest));
+        end;
+      count:=((count*2) and (sizeof(ptruint)-1)) shr 1;
+    end;
+  pend:=pdest+count;
+  while pdest<pend do
     begin
     begin
-      v:=value*$10000+value;
-      for i:=0 to (count div 2) -1 do
-        longintarray(x)[i]:=v;
-      for i:=(count div 2)*2 to count-1 do
-        wordarray(x)[i]:=value;
+      pdest^:=value;
+      inc(pdest);
     end;
     end;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_FILLWORD}
 {$endif not FPC_SYSTEM_HAS_FILLWORD}
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_FILLDWORD}
 {$ifndef FPC_SYSTEM_HAS_FILLDWORD}
-procedure FillDWord(var x;count : SizeInt;value : DWord);
-type
-  longintarray = array [0..high(sizeint) div 4-1] of longint;
+procedure filldword(var x;count : SizeInt;value : dword);
+var
+  aligncount : sizeint;
+  pdest,pend : pdword;
+  v : ptruint;
 begin
 begin
-  if count <= 0 then exit;
-  while Count<>0 do
-   begin
-     { range checking must be disabled here }
-     longintarray(x)[count-1]:=longint(value);
-     Dec(count);
-   end;
+  if count <= 0 then
+    exit;
+  pdest:=@x;
+  if Count>4*sizeof(ptruint)-1 then
+    begin
+      v:=value;
+      if sizeof(ptruint)=8 then
+        v:=(v shl 32) or v;
+      { Align on native pointer size }
+      aligncount:=(PtrUInt(pdest) and (sizeof(PtrUInt)-1)) shr 2;
+      dec(count,aligncount);
+      pend:=pdest+aligncount;
+      while pdest<pend do
+        begin
+          pdest^:=value;
+          inc(pdest);
+        end;
+      { use sizeuint typecast to force shr optimization }
+      pptruint(pend):=pptruint(pdest)+((sizeuint(count)*4) div sizeof(ptruint));
+      while pdest<pend do
+        begin
+          pptruint(pdest)^:=v;
+          inc(pptruint(pdest));
+        end;
+      count:=((count*4) and (sizeof(ptruint)-1)) shr 2;
+    end;
+  pend:=pdest+count;
+  while pdest<pend do
+    begin
+      pdest^:=value;
+      inc(pdest);
+    end;
 end;
 end;
 {$endif FPC_SYSTEM_HAS_FILLDWORD}
 {$endif FPC_SYSTEM_HAS_FILLDWORD}
 
 
 
 
-{$ifndef FPC_SYSTEM_HAS_INDEXCHAR}
-function IndexChar(Const buf;len:SizeInt;b:char):SizeInt;
-begin
-  IndexChar:=IndexByte(Buf,Len,byte(B));
-end;
-{$endif not FPC_SYSTEM_HAS_INDEXCHAR}
-
-
 {$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
 {$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
 function IndexByte(Const buf;len:SizeInt;b:byte):SizeInt;
 function IndexByte(Const buf;len:SizeInt;b:byte):SizeInt;
-type
-  bytearray    = array [0..high(sizeint)-1] of byte;
 var
 var
-  I : longint;
+  psrc,pend : pbyte;
 begin
 begin
-  I:=0;
+  psrc:=@buf;
   { simulate assembler implementations behaviour, which is expected }
   { simulate assembler implementations behaviour, which is expected }
   { fpc_pchar_to_ansistr in astrings.inc                            }
   { fpc_pchar_to_ansistr in astrings.inc                            }
-  if (len < 0) then
-    len := high(longint);
-  while (I<Len) and (bytearray(buf)[I]<>b) do
-   inc(I);
-  if (i=Len) then
-   i:=-1;                      {Can't use 0, since it is a possible value}
-  IndexByte:=I;
+  if (len < 0) or
+     (psrc+len < psrc) then
+    pend:=pbyte(high(PtrUInt)-sizeof(byte))
+  else
+    pend:=psrc+len;
+  while (psrc<pend) do
+    begin
+      if psrc^=b then
+        begin
+          result:=psrc-pbyte(@buf);
+          exit;
+        end;
+      inc(psrc);
+    end;
+  result:=-1;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_INDEXBYTE}
 {$endif not FPC_SYSTEM_HAS_INDEXBYTE}
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_INDEXWORD}
 {$ifndef FPC_SYSTEM_HAS_INDEXWORD}
 function Indexword(Const buf;len:SizeInt;b:word):SizeInt;
 function Indexword(Const buf;len:SizeInt;b:word):SizeInt;
-type
-  wordarray    = array [0..high(sizeint) div 2-1] of word;
 var
 var
-  I : longint;
+  psrc,pend : pword;
 begin
 begin
-  I:=0;
-  if (len < 0) then
-    len := high(longint);
-  while (I<Len) and (wordarray(buf)[I]<>b) do
-   inc(I);
-  if (i=Len) then
-   i:=-1;           {Can't use 0, since it is a possible value for index}
-  Indexword:=I;
+  psrc:=@buf;
+  { simulate assembler implementations behaviour, which is expected }
+  { fpc_pchar_to_ansistr in astrings.inc                            }
+  if (len < 0) or
+     { is this ever true? }
+     (len > high(PtrInt)) or
+     (psrc+len < psrc) then
+    pend:=pword(high(PtrUInt)-sizeof(word))
+  else
+    pend:=psrc+len;
+  while psrc<pend do
+    begin
+      if psrc^=b then
+        begin
+          result:=psrc-pword(@buf);
+          exit;
+        end;
+      inc(psrc);
+    end;
+  result:=-1;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_INDEXWORD}
 {$endif not FPC_SYSTEM_HAS_INDEXWORD}
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_INDEXDWORD}
 {$ifndef FPC_SYSTEM_HAS_INDEXDWORD}
 function IndexDWord(Const buf;len:SizeInt;b:DWord):SizeInt;
 function IndexDWord(Const buf;len:SizeInt;b:DWord):SizeInt;
-type
-  dwordarray = array [0..high(sizeint) div 4-1] of dword;
 var
 var
-  I : longint;
+  psrc,pend : pdword;
 begin
 begin
-  I:=0;
-  if (len < 0) then
-    len := high(longint);
-  while (I<Len) and (dwordarray(buf)[I]<>b) do
-    inc(I);
-  if (i=Len) then
-   i:=-1;           {Can't use 0, since it is a possible value for index}
-  IndexDWord:=I;
+  psrc:=@buf;
+  { simulate assembler implementations behaviour, which is expected }
+  { fpc_pchar_to_ansistr in astrings.inc                            }
+  if (len < 0) or
+     (len > high(PtrInt) div 2) or
+     (psrc+len < psrc) then
+    pend:=pdword(high(PtrUInt)-sizeof(dword))
+  else
+    pend:=psrc+len;
+  while psrc<pend do
+    begin
+      if psrc^=b then
+        begin
+          result:=psrc-pdword(@buf);
+          exit;
+        end;
+      inc(psrc);
+    end;
+  result:=-1;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_INDEXDWORD}
 {$endif not FPC_SYSTEM_HAS_INDEXDWORD}
 
 
 
 
-{$ifndef FPC_SYSTEM_HAS_COMPARECHAR}
-function CompareChar(Const buf1,buf2;len:SizeInt):SizeInt;
-begin
-  CompareChar:=CompareByte(buf1,buf2,len);
-end;
-{$endif not FPC_SYSTEM_HAS_COMPARECHAR}
-
-
 {$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
 {$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
 function CompareByte(Const buf1,buf2;len:SizeInt):SizeInt;
 function CompareByte(Const buf1,buf2;len:SizeInt):SizeInt;
-type
-  bytearray = array [0..high(sizeint)-1] of byte;
 var
 var
-  I : longint;
+  aligncount : sizeint;
+  psrc,pdest,pend : pbyte;
+  b : ptrint;
 begin
 begin
-  I:=0;
-  if (Len<>0) and (@Buf1<>@Buf2) then
-   begin
-     while (bytearray(Buf1)[I]=bytearray(Buf2)[I]) and (I<Len) do
-      inc(I);
-     if I=Len then  {No difference}
-      I:=0
-     else
-      begin
-        I:=bytearray(Buf1)[I]-bytearray(Buf2)[I];
-        if I>0 then
-         I:=1
-        else
-         if I<0 then
-          I:=-1;
-      end;
-   end;
-  CompareByte:=I;
+  b:=0;
+  psrc:=@buf1;
+  pdest:=@buf2;
+  if (len>4*sizeof(ptruint)-1)
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
+    and ((PtrUInt(pdest) and (sizeof(PtrUInt)-1))=(PtrUInt(psrc) and (sizeof(PtrUInt)-1)))
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+    then
+    begin
+      { Align on native pointer size }
+      aligncount:=(sizeof(PtrUInt)-(PtrUInt(pdest) and (sizeof(PtrUInt)-1))) and (sizeof(PtrUInt)-1);
+      dec(len,aligncount);
+      pend:=psrc+aligncount;
+      while psrc<pend do
+        begin
+          b:=(ptrint(psrc^)-ptrint(pdest^));
+          if b<>0 then
+            begin
+              if b<0 then
+                exit(-1)
+              else
+                exit(1);
+            end;
+          inc(pdest);
+          inc(psrc);
+        end;
+      { use sizeuint typecast to force shr optimization }
+      pptruint(pend):=pptruint(psrc)+(sizeuint(len) div sizeof(ptruint));
+      len:=len and (sizeof(PtrUInt)-1);
+      while psrc<pend do
+        begin
+          b:=(pptrint(psrc)^-pptrint(pdest)^);
+          if b<>0 then
+            begin
+              len:=sizeof(ptruint);
+              break;
+            end;
+          inc(pptruint(pdest));
+          inc(pptruint(psrc));
+        end;
+    end;
+  if (psrc+len >= psrc) then
+    pend:=psrc+len
+  else
+    pend:=pbyte(high(ptruint)-1);
+  while psrc<pend do
+    begin
+      b:=(ptrint(psrc^)-ptrint(pdest^));
+      if b<>0 then
+        begin
+          if b<0 then
+            exit(-1)
+          else
+            exit(1);
+        end;
+      inc(pdest);
+      inc(psrc);
+    end;
+  result:=0;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_COMPAREBYTE}
 {$endif not FPC_SYSTEM_HAS_COMPAREBYTE}
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_COMPAREWORD}
 {$ifndef FPC_SYSTEM_HAS_COMPAREWORD}
 function CompareWord(Const buf1,buf2;len:SizeInt):SizeInt;
 function CompareWord(Const buf1,buf2;len:SizeInt):SizeInt;
-type
-  wordarray = array [0..high(sizeint) div 2-1] of word;
 var
 var
-  I : longint;
+  aligncount : sizeint;
+  psrc,pdest,pend : pword;
+  b : ptrint;
 begin
 begin
-  I:=0;
-  if (Len<>0) and (@Buf1<>@Buf2) then
-   begin
-     while (wordarray(Buf1)[I]=wordarray(Buf2)[I]) and (I<Len) do
-      inc(I);
-     if I=Len then  {No difference}
-      I:=0
-     else
+  b:=0;
+  psrc:=@buf1;
+  pdest:=@buf2;
+  if (len>4*sizeof(ptruint)-1)
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
+    and ((PtrUInt(pdest) and (sizeof(PtrUInt)-1))=(PtrUInt(psrc) and (sizeof(PtrUInt)-1)))
+    and (((PtrUInt(pdest) and 1) or (PtrUInt(psrc) and 1))=0)
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+    then
+     begin
+      { Align on native pointer size }
+      aligncount:=((sizeof(PtrUInt)-(PtrUInt(pdest) and (sizeof(PtrUInt)-1))) and (sizeof(PtrUInt)-1)) shr 1;
+      dec(len,aligncount);
+      pend:=psrc+aligncount;
+      while psrc<pend do
+        begin
+          b:=(ptrint(psrc^)-ptrint(pdest^));
+          if b<>0 then
+            begin
+              if b<0 then
+                exit(-1)
+              else
+                exit(1);
+            end;
+          inc(pdest);
+          inc(psrc);
+        end;
+      { use sizeuint typecast to force shr optimization }
+      pptruint(pend):=pptruint(psrc)+(sizeuint(len)*2 div sizeof(ptruint));
+      len:=((len*2) and (sizeof(PtrUInt)-1)) shr 1;
+      while psrc<pend do
+        begin
+          b:=(pptrint(psrc)^-pptrint(pdest)^);
+          if b<>0 then
+            begin
+              len:=sizeof(ptruint) shr 1;
+              break;
+            end;
+          inc(pptruint(pdest));
+          inc(pptruint(psrc));
+        end;
+    end;
+  if (len <= high(ptruint) div 2) and
+     (psrc+len >= psrc) then
+    pend:=psrc+len
+  else
+    pend:=pword(high(ptruint)-2);
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
+  if ((PtrUInt(pdest) and 1) or (PtrUInt(psrc) and 1))<>0 then
+    while psrc<pend do
       begin
       begin
-        I:=wordarray(Buf1)[I]-wordarray(Buf2)[I];
-        if I>0 then
-         I:=1
-        else
-         if I<0 then
-          I:=-1;
+        b:=(ptrint(unaligned(psrc^))-ptrint(unaligned(pdest^)));
+        if b<>0 then
+          begin
+            if b<0 then
+              exit(-1)
+            else
+              exit(1);
+          end;
+        inc(pdest);
+        inc(psrc);
+      end
+  else
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+    while psrc<pend do
+      begin
+        b:=(ptrint(psrc^)-ptrint(pdest^));
+        if b<>0 then
+          begin
+            if b<0 then
+              exit(-1)
+            else
+              exit(1);
+          end;
+        inc(pdest);
+        inc(psrc);
       end;
       end;
-   end;
-  CompareWord:=I;
+  result:=0;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_COMPAREWORD}
 {$endif not FPC_SYSTEM_HAS_COMPAREWORD}
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_COMPAREDWORD}
 {$ifndef FPC_SYSTEM_HAS_COMPAREDWORD}
 function CompareDWord(Const buf1,buf2;len:SizeInt):SizeInt;
 function CompareDWord(Const buf1,buf2;len:SizeInt):SizeInt;
-type
-  cardinalarray = array [0..high(sizeint) div 4-1] of cardinal;
 var
 var
-  I : int64;
+  aligncount : sizeint;
+  psrc,pdest,pend : pdword;
+  b : ptruint;
 begin
 begin
-  I:=0;
-  if (Len<>0) and (@Buf1<>@Buf2) then
-   begin
-     while (cardinalarray(Buf1)[I]=cardinalarray(Buf2)[I]) and (I<Len) do
-      inc(I);
-     if I=Len then  {No difference}
-      I:=0
-     else
+  b:=0;
+  psrc:=@buf1;
+  pdest:=@buf2;
+  if (len>4*sizeof(ptruint)-11)
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
+    and (((PtrUInt(pdest) and 3) or (PtrUInt(psrc) and 3))=0)
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+    then
+    begin
+      { Align on native pointer size }
+      aligncount:=((sizeof(PtrUInt)-(PtrUInt(pdest) and (sizeof(PtrUInt)-1))) and (sizeof(PtrUInt)-1)) shr 2;
+      dec(len,aligncount);
+      pend:=psrc+aligncount;
+      while psrc<pend do
+        begin
+          b:=(ptrint(psrc^)-ptrint(pdest^));
+          if b<>0 then
+            begin
+              if b<0 then
+                exit(-1)
+              else
+                exit(1);
+            end;
+          inc(pdest);
+          inc(psrc);
+        end;
+      { use sizeuint typecast to force shr optimization }
+      pptruint(pend):=pptruint(psrc)+(sizeuint(len)*4 div sizeof(ptruint));
+      len:=((len*4) and (sizeof(PtrUInt)-1)) shr 2;
+      while psrc<pend do
+        begin
+          b:=(pptrint(psrc)^-pptrint(pdest)^);
+          if b<>0 then
+            begin
+              len:=sizeof(ptruint) shr 2;
+              break;
+            end;
+          inc(pptruint(pdest));
+          inc(pptruint(psrc));
+        end;
+    end;
+  if (len <= high(ptruint) div 4) and
+     (psrc+len >= psrc) then
+    pend:=psrc+len
+  else
+    pend:=pdword(high(ptruint)-4);
+{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
+  if ((PtrUInt(pdest) and 3) or (PtrUInt(psrc) and 3))<>0 then
+    while psrc<pend do
       begin
       begin
-        I:=int64(cardinalarray(Buf1)[I])-int64(cardinalarray(Buf2)[I]);
-        if I>0 then
-         I:=1
-        else
-         if I<0 then
-          I:=-1;
+        b:=(ptruint(unaligned(psrc^))-ptruint(unaligned(pdest^)));
+        if b<>0 then
+          begin
+            if b<0 then
+              exit(-1)
+            else
+              exit(1);
+          end;
+        inc(pdest);
+        inc(psrc);
+      end
+  else
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
+    while psrc<pend do
+      begin
+        b:=(ptruint(psrc^)-ptruint(pdest^));
+        if b<>0 then
+          begin
+            if b<0 then
+              exit(-1)
+            else
+              exit(1);
+          end;
+        inc(pdest);
+        inc(psrc);
       end;
       end;
-   end;
-  CompareDWord:=I;
+  result:=0;
 end;
 end;
 {$endif ndef FPC_SYSTEM_HAS_COMPAREDWORD}
 {$endif ndef FPC_SYSTEM_HAS_COMPAREDWORD}
 
 
@@ -291,9 +575,10 @@ end;
 {$ifndef FPC_SYSTEM_HAS_MOVECHAR0}
 {$ifndef FPC_SYSTEM_HAS_MOVECHAR0}
 procedure MoveChar0(Const buf1;var buf2;len:SizeInt);
 procedure MoveChar0(Const buf1;var buf2;len:SizeInt);
 var
 var
-  I : longint;
+  I : SizeInt;
 begin
 begin
-  if Len = 0 then exit;
+  if Len = 0 then
+    exit;
   I:=IndexByte(Buf1,Len,0);
   I:=IndexByte(Buf1,Len,0);
   if I<>-1 then
   if I<>-1 then
     Move(Buf1,Buf2,I)
     Move(Buf1,Buf2,I)
@@ -306,50 +591,54 @@ end;
 {$ifndef FPC_SYSTEM_HAS_INDEXCHAR0}
 {$ifndef FPC_SYSTEM_HAS_INDEXCHAR0}
 function IndexChar0(Const buf;len:SizeInt;b:Char):SizeInt;
 function IndexChar0(Const buf;len:SizeInt;b:Char):SizeInt;
 var
 var
-  I : longint;
+  psrc,pend : pbyte;
 begin
 begin
-  if Len<>0 then
-   begin
-     I:=IndexByte(Buf,Len,0);
-     If (I=-1) then
-       I:=Len;
-     IndexChar0:=IndexByte(Buf,I,byte(b));
-   end
+  psrc:=@buf;
+  { simulate assembler implementations behaviour, which is expected }
+  { fpc_pchar_to_ansistr in astrings.inc                            }
+  if (len < 0) then
+    pend:=pbyte(high(PtrUInt)-sizeof(byte))
   else
   else
-   IndexChar0:=0;
+    pend:=psrc+len;
+  while (psrc<pend) and (psrc^<>0) do
+    begin
+      if (psrc^=byte(b)) then
+        begin
+          result:=psrc-pbyte(@buf);
+          exit;
+        end;
+      inc(psrc);
+    end;
+  result:=-1;
 end;
 end;
 {$endif ndef FPC_SYSTEM_HAS_INDEXCHAR0}
 {$endif ndef FPC_SYSTEM_HAS_INDEXCHAR0}
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
 {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
 function CompareChar0(Const buf1,buf2;len:SizeInt):SizeInt;
 function CompareChar0(Const buf1,buf2;len:SizeInt):SizeInt;
-type
-  bytearray = array [0..high(sizeint)-1] of byte;
 var
 var
-  i : longint;
+  aligncount : sizeint;
+  psrc,pdest,pend : pbyte;
+  b : ptrint;
 begin
 begin
-  I:=0;
-  if (Len<>0) and (@Buf1<>@Buf2) then
-   begin
-     while (I<Len) And
-           ((Pbyte(@Buf1)[i]<>0) and (PByte(@buf2)[i]<>0)) and
-           (pbyte(@Buf1)[I]=pbyte(@Buf2)[I])  do
-      inc(I);
-     if (I=Len) or
-        (PByte(@Buf1)[i]=0) or
-        (PByte(@buf2)[I]=0) then  {No difference or 0 reached }
-      I:=0
-     else
-      begin
-        I:=bytearray(Buf1)[I]-bytearray(Buf2)[I];
-        if I>0 then
-         I:=1
-        else
-         if I<0 then
-          I:=-1;
-      end;
-   end;
-  CompareChar0:=I;
+  b:=0;
+  psrc:=@buf1;
+  pdest:=@buf2;
+  pend:=psrc+len;
+  while psrc<pend do
+    begin
+      b:=(ptrint(psrc^)-ptrint(pdest^));
+      if (b<>0) or (psrc^=0) or (pdest^=0) then
+        begin
+          if b<0 then
+            exit(-1)
+          else
+            exit(1);
+        end;
+      inc(pdest);
+      inc(psrc);
+    end;
+  result:=0;
 end;
 end;
 {$endif not FPC_SYSTEM_HAS_COMPARECHAR0}
 {$endif not FPC_SYSTEM_HAS_COMPARECHAR0}
 
 

+ 3 - 1
rtl/inc/heaptrc.pp

@@ -424,7 +424,9 @@ begin
   bp:=get_caller_frame(get_frame);
   bp:=get_caller_frame(get_frame);
   for i:=1 to tracesize do
   for i:=1 to tracesize do
    begin
    begin
-     pp^.calls[i]:=get_caller_addr(bp);
+     { valid bp? }
+     if (bp>=StackBottom) and (bp<(StackBottom + StackLength)) then
+       pp^.calls[i]:=get_caller_addr(bp);
      oldbp:=bp;
      oldbp:=bp;
      bp:=get_caller_frame(bp);
      bp:=get_caller_frame(bp);
      if (bp<oldbp) or (bp>(StackBottom + StackLength)) then
      if (bp<oldbp) or (bp>(StackBottom + StackLength)) then

+ 31 - 0
rtl/inc/keyboard.inc

@@ -293,3 +293,34 @@ begin
 end;
 end;
 
 
 
 
+const
+  PrevCtrlBreakHandler: TCtrlBreakHandler = nil;
+
+function KbdCtrlBreakHandler (CtrlBreak: boolean): boolean;
+begin
+(* Earlier registered handlers (user specific) have priority. *)
+  if Assigned (PrevCtrlBreakHandler) then
+    if PrevCtrlBreakHandler (CtrlBreak) then
+      begin
+        KbdCtrlBreakHandler := true;
+        Exit;
+      end;
+(* If Ctrl-Break was pressed, either ignore it or allow default processing. *)
+  if CtrlBreak then
+    KbdCtrlBreakHandler := false
+  else (* Ctrl-C pressed or not possible to distinguish *)
+    begin
+      PutKeyEvent ((kbCtrl shl 16) or 3);
+      KbdCtrlBreakHandler := true;
+    end;
+end;
+
+
+procedure SetKbdCtrlBreakHandler;
+begin
+  PrevCtrlBreakHandler := SysSetCtrlBreakHandler (@KbdCtrlBreakHandler);
+  if PrevCtrlBreakHandler = TCtrlBreakHandler (pointer (-1)) then
+    PrevCtrlBreakHandler := nil;
+end;
+
+

+ 36 - 30
rtl/inc/lnfodwrf.pp

@@ -29,14 +29,14 @@ implementation
 { Note to implementors of other OS loaders:
 { Note to implementors of other OS loaders:
 
 
   - add a LoadXXX() function which has no parameters and returns a Boolean
   - add a LoadXXX() function which has no parameters and returns a Boolean
-   in the "OS loaders section" enclosing it using the OS specific define. 
+   in the "OS loaders section" enclosing it using the OS specific define.
    This method should set the
    This method should set the
 
 
-     DwarfOpened, 
-     DwarfOffset and 
-     DwarfSize 
+     DwarfOpened,
+     DwarfOffset and
+     DwarfSize
 
 
-   global variables properly (see comments at variable definition for more 
+   global variables properly (see comments at variable definition for more
    information).
    information).
    Additionally this method should return true if DWARF line info information
    Additionally this method should return true if DWARF line info information
    could be found.
    could be found.
@@ -44,8 +44,8 @@ implementation
    The file variable which can be used for file I/O is the global "infile"
    The file variable which can be used for file I/O is the global "infile"
    variable.
    variable.
 
 
-  - in OpenDwarf(), add a call to this initializer function after the 
-   "run OS specific initializer" comment, again enclosed in the system 
+  - in OpenDwarf(), add a call to this initializer function after the
+   "run OS specific initializer" comment, again enclosed in the system
    specific define.
    specific define.
 }
 }
 
 
@@ -85,11 +85,13 @@ var
 
 
 {$MACRO ON}
 {$MACRO ON}
 
 
-//{$DEFINE DEBUG_DWARF_PARSER} 
+//{$DEFINE DEBUG_DWARF_PARSER}
 {$ifdef DEBUG_DWARF_PARSER}
 {$ifdef DEBUG_DWARF_PARSER}
 {$define DEBUG_WRITELN := WriteLn}
 {$define DEBUG_WRITELN := WriteLn}
+{$define DEBUG_COMMENT :=  }
 {$else}
 {$else}
 {$define DEBUG_WRITELN := //}
 {$define DEBUG_WRITELN := //}
+{$define DEBUG_COMMENT := //}
 {$endif}
 {$endif}
 
 
 {---------------------------------------------------------------------------
 {---------------------------------------------------------------------------
@@ -227,7 +229,7 @@ type
     e_shoff : Elf32_Off; { section header file offset }
     e_shoff : Elf32_Off; { section header file offset }
     e_flags : Elf32_Word; { architecture specific flags }
     e_flags : Elf32_Word; { architecture specific flags }
     e_ehsize : Elf32_Half; { size of ELF header in bytes }
     e_ehsize : Elf32_Half; { size of ELF header in bytes }
-    e_phentsize : Elf32_Half; { size of program header entry } 
+    e_phentsize : Elf32_Half; { size of program header entry }
     e_phnum : Elf32_Half; { number of program header entries }
     e_phnum : Elf32_Half; { number of program header entries }
     e_shentsize : Elf32_Half; { size of section header entry }
     e_shentsize : Elf32_Half; { size of section header entry }
     e_shnum : Elf32_Half; { number of section header entry }
     e_shnum : Elf32_Half; { number of section header entry }
@@ -279,7 +281,7 @@ type
     sh_addralign : Elf64_Xword;
     sh_addralign : Elf64_Xword;
     sh_entsize : Elf64_Xword;
     sh_entsize : Elf64_Xword;
   end;
   end;
-  
+
   TElf_Shdr = {$ifdef cpu32}TElf32_Shdr{$endif}{$ifdef cpu64}TElf64_Shdr{$endif};
   TElf_Shdr = {$ifdef cpu32}TElf32_Shdr{$endif}{$ifdef cpu64}TElf64_Shdr{$endif};
   TElf_Ehdr = {$ifdef cpu32}TElf32_Ehdr{$endif}{$ifdef cpu64}TElf64_Ehdr{$endif};
   TElf_Ehdr = {$ifdef cpu32}TElf32_Ehdr{$endif}{$ifdef cpu64}TElf64_Ehdr{$endif};
 
 
@@ -304,7 +306,7 @@ begin
     exit;
     exit;
   end;
   end;
 
 
-  { more paranoia checks }  
+  { more paranoia checks }
   if ((header.e_ident[EI_MAG0] <> ELFMAG0) or (header.e_ident[EI_MAG1] <> ELFMAG1) or
   if ((header.e_ident[EI_MAG0] <> ELFMAG0) or (header.e_ident[EI_MAG1] <> ELFMAG1) or
     (header.e_ident[EI_MAG2] <> ELFMAG2) or (header.e_ident[EI_MAG3] <> ELFMAG3)) then begin
     (header.e_ident[EI_MAG2] <> ELFMAG2) or (header.e_ident[EI_MAG3] <> ELFMAG3)) then begin
     DEBUG_WRITELN('Invalid ELF magic header. Exiting');
     DEBUG_WRITELN('Invalid ELF magic header. Exiting');
@@ -341,7 +343,7 @@ begin
       DEBUG_WRITELN('Could not read section name');
       DEBUG_WRITELN('Could not read section name');
       exit;
       exit;
     end;
     end;
-    buf[sizeof(buf)-1] := #0;    
+    buf[sizeof(buf)-1] := #0;
 
 
     DEBUG_WRITELN('This section is "', pchar(@buf[0]), '", offset ', cursec_header.sh_offset, ' size ', cursec_header.sh_size);
     DEBUG_WRITELN('This section is "', pchar(@buf[0]), '", offset ', cursec_header.sh_offset, ' size ', cursec_header.sh_size);
     if (pchar(@buf[0]) = '.debug_line') then begin
     if (pchar(@buf[0]) = '.debug_line') then begin
@@ -360,7 +362,7 @@ end;
 
 
  Generic Dwarf lineinfo reader
  Generic Dwarf lineinfo reader
 
 
- The line info reader is based on the information contained in 
+ The line info reader is based on the information contained in
 
 
    DWARF Debugging Information Format Version 3
    DWARF Debugging Information Format Version 3
    Chapter 6.2 "Line Number Information"
    Chapter 6.2 "Line Number Information"
@@ -369,7 +371,7 @@ end;
 
 
    DWARF Debugging Information Format Workgroup.
    DWARF Debugging Information Format Workgroup.
 
 
- For more information on this document see also 
+ For more information on this document see also
 
 
    http://dwarf.freestandards.org/
    http://dwarf.freestandards.org/
 
 
@@ -490,7 +492,7 @@ begin
     append_row := false;
     append_row := false;
   end;
   end;
 end;
 end;
-    
+
 { Reads an unsigned LEB encoded number from the input stream }
 { Reads an unsigned LEB encoded number from the input stream }
 function ReadULEB128() : QWord;
 function ReadULEB128() : QWord;
 var
 var
@@ -538,7 +540,7 @@ begin
   ReadLEB128 := result;
   ReadLEB128 := result;
 end;
 end;
 
 
-{ Reads an address from the current input stream }      
+{ Reads an address from the current input stream }
 function ReadAddress() : PtrUInt;
 function ReadAddress() : PtrUInt;
 var
 var
   result : PtrUInt;
   result : PtrUInt;
@@ -547,7 +549,7 @@ begin
   ReadAddress := result;
   ReadAddress := result;
 end;
 end;
 
 
-{ Reads a zero-terminated string from the current input stream. If the 
+{ Reads a zero-terminated string from the current input stream. If the
   string is larger than 255 chars (maximum allowed number of elements in
   string is larger than 255 chars (maximum allowed number of elements in
   a ShortString, excess characters will be chopped off. }
   a ShortString, excess characters will be chopped off. }
 function ReadString() : ShortString;
 function ReadString() : ShortString;
@@ -621,7 +623,7 @@ begin
     SkipLEB128(); { skip length of file }
     SkipLEB128(); { skip length of file }
   end;
   end;
 end;
 end;
-      
+
 function CalculateAddressIncrement(opcode : Byte; const header : TLineNumberProgramHeader64) : Int64;
 function CalculateAddressIncrement(opcode : Byte; const header : TLineNumberProgramHeader64) : Int64;
 var
 var
   result : Int64;
   result : Int64;
@@ -647,7 +649,7 @@ begin
     dirindex := ReadLEB128(); { read the directory index for the file }
     dirindex := ReadLEB128(); { read the directory index for the file }
     SkipLEB128(); { skip last modification time for file }
     SkipLEB128(); { skip last modification time for file }
     SkipLEB128(); { skip length of file }
     SkipLEB128(); { skip length of file }
-    inc(i); 
+    inc(i);
   end;
   end;
   { if we could not find the file index, exit }
   { if we could not find the file index, exit }
   if (filename = '') then begin
   if (filename = '') then begin
@@ -665,7 +667,7 @@ begin
 
 
   GetFullFilename := directory + filename;
   GetFullFilename := directory + filename;
 end;
 end;
-   
+
 function ParseCompilationUnit(const addr : PtrUInt; const file_offset : QWord;
 function ParseCompilationUnit(const addr : PtrUInt; const file_offset : QWord;
   var source : String; var line : longint; var found : Boolean) : QWord;
   var source : String; var line : longint; var found : Boolean) : QWord;
 var
 var
@@ -675,7 +677,7 @@ var
   header32 : TLineNumberProgramHeader32;
   header32 : TLineNumberProgramHeader32;
 
 
   adjusted_opcode : Int64;
   adjusted_opcode : Int64;
-  
+
   opcode : Int;
   opcode : Int;
   extended_opcode : Byte;
   extended_opcode : Byte;
   extended_opcode_length : Int;
   extended_opcode_length : Int;
@@ -733,13 +735,13 @@ begin
     header64.line_range := header32.line_range;
     header64.line_range := header32.line_range;
     header64.opcode_base := header32.opcode_base;
     header64.opcode_base := header32.opcode_base;
     header_length :=
     header_length :=
-      sizeof(header32.length) + sizeof(header32.version) + 
+      sizeof(header32.length) + sizeof(header32.version) +
       sizeof(header32.unit_length);
       sizeof(header32.unit_length);
   end else begin
   end else begin
     DEBUG_WRITELN('64 bit DWARF detected');
     DEBUG_WRITELN('64 bit DWARF detected');
     ReadNext(header64, sizeof(header64));
     ReadNext(header64, sizeof(header64));
-    header_length := 
-      sizeof(header64.magic) + sizeof(header64.version) + 
+    header_length :=
+      sizeof(header64.magic) + sizeof(header64.version) +
       sizeof(header64.length) + sizeof(header64.unit_length);
       sizeof(header64.length) + sizeof(header64.unit_length);
   end;
   end;
 
 
@@ -856,7 +858,7 @@ begin
           adjusted_opcode := opcode - header64.opcode_base;
           adjusted_opcode := opcode - header64.opcode_base;
           addrIncrement := CalculateAddressIncrement(opcode, header64);
           addrIncrement := CalculateAddressIncrement(opcode, header64);
           inc(state.address, addrIncrement);
           inc(state.address, addrIncrement);
-          lineIncrement := header64.line_base + (adjusted_opcode mod header64.line_range); 
+          lineIncrement := header64.line_base + (adjusted_opcode mod header64.line_range);
           inc(state.line, lineIncrement);
           inc(state.line, lineIncrement);
           DEBUG_WRITELN('Special opcode $', hexstr(opcode, 2), ' address increment: ', addrIncrement, ' new line: ', lineIncrement);
           DEBUG_WRITELN('Special opcode $', hexstr(opcode, 2), ' address increment: ', addrIncrement, ' new line: ', lineIncrement);
           state.basic_block := false;
           state.basic_block := false;
@@ -868,7 +870,11 @@ begin
     end;
     end;
 
 
     if (state.append_row) then begin
     if (state.append_row) then begin
-      DEBUG_WRITELN('Current state : address = ', hexstr(state.address, sizeof(state.address) * 2), ' file_id = ', state.file_id, ' line = ', state.line, ' column = ', state.column, ' is_stmt = ', state.is_stmt, ' basic_block = ', state.basic_block, ' end_sequence = ', state.end_sequence, ' prolouge_end = ', state.prolouge_end, ' epilouge_begin = ', state.epilouge_begin, ' isa = ', state.isa);
+      DEBUG_WRITELN('Current state : address = ', hexstr(state.address, sizeof(state.address) * 2),
+      DEBUG_COMMENT ' file_id = ', state.file_id, ' line = ', state.line, ' column = ', state.column,
+      DEBUG_COMMENT  ' is_stmt = ', state.is_stmt, ' basic_block = ', state.basic_block,
+      DEBUG_COMMENT  ' end_sequence = ', state.end_sequence, ' prolouge_end = ', state.prolouge_end,
+      DEBUG_COMMENT  ' epilouge_begin = ', state.epilouge_begin, ' isa = ', state.isa);
 
 
       if (first_row) then begin
       if (first_row) then begin
         if (state.address > addr) then
         if (state.address > addr) then
@@ -903,13 +909,13 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure GetLineInfo(addr : ptruint; var func, source : string; var line : longint);   
+procedure GetLineInfo(addr : ptruint; var func, source : string; var line : longint);
 var
 var
   current_offset : QWord;
   current_offset : QWord;
   end_offset : QWord;
   end_offset : QWord;
 
 
   found : Boolean;
   found : Boolean;
-  
+
 begin
 begin
   func := '';
   func := '';
   source := '';
   source := '';
@@ -923,9 +929,9 @@ begin
 
 
   while (current_offset < end_offset) and (not found) do begin
   while (current_offset < end_offset) and (not found) do begin
     Init(current_offset, end_offset - current_offset);
     Init(current_offset, end_offset - current_offset);
-    current_offset := ParseCompilationUnit(addr, current_offset, 
+    current_offset := ParseCompilationUnit(addr, current_offset,
       source, line, found);
       source, line, found);
-  end; 
+  end;
 end;
 end;
 
 
 
 

+ 6 - 6
rtl/inc/objpas.inc

@@ -86,7 +86,7 @@
          if assigned(S) then
          if assigned(S) then
            begin
            begin
              if IUnknown(S).QueryInterface(iid,tmp)<>S_OK then
              if IUnknown(S).QueryInterface(iid,tmp)<>S_OK then
-               handleerror(219);  
+               handleerror(219);
              if assigned(D) then
              if assigned(D) then
                IUnknown(D)._Release;
                IUnknown(D)._Release;
              D:=tmp;
              D:=tmp;
@@ -184,7 +184,7 @@
             end;
             end;
         end;
         end;
 
 
-      class function TObject.InitInstance(instance : pointer) : tobject;
+      class function TObject.InitInstance(instance : pointer) : tobject; {$ifdef SYSTEMINLINE} inline; {$ENDIF}
 
 
         begin
         begin
            { the size is saved at offset 0 }
            { the size is saved at offset 0 }
@@ -748,7 +748,7 @@
          if NewInstance<>nil then
          if NewInstance<>nil then
            TInterfacedObject(NewInstance).frefcount:=1;
            TInterfacedObject(NewInstance).frefcount:=1;
       end;
       end;
-      
+
 {****************************************************************************
 {****************************************************************************
                                TAGGREGATEDOBJECT
                                TAGGREGATEDOBJECT
 ****************************************************************************}
 ****************************************************************************}
@@ -778,13 +778,13 @@
 
 
       begin
       begin
          Result := IUnknown(fcontroller)._Release;
          Result := IUnknown(fcontroller)._Release;
-      end;    
-  
+      end;
+
     function TAggregatedObject.GetController : IUnknown;
     function TAggregatedObject.GetController : IUnknown;
 
 
       begin
       begin
          Result := IUnknown(fcontroller);
          Result := IUnknown(fcontroller);
-      end;    
+      end;
 
 
 
 
 {****************************************************************************
 {****************************************************************************

+ 1 - 1
rtl/inc/objpash.inc

@@ -154,7 +154,7 @@
           procedure DefaultHandler(var message);virtual;
           procedure DefaultHandler(var message);virtual;
 
 
           procedure Free;
           procedure Free;
-          class function InitInstance(instance : pointer) : tobject;
+          class function InitInstance(instance : pointer) : tobject; {$ifdef SYSTEMINLINE} inline; {$endif}
           procedure CleanupInstance;
           procedure CleanupInstance;
           class function ClassType : tclass;{$ifdef SYSTEMINLINE}inline;{$endif}
           class function ClassType : tclass;{$ifdef SYSTEMINLINE}inline;{$endif}
           class function ClassInfo : pointer;
           class function ClassInfo : pointer;

+ 12 - 7
rtl/inc/sstrings.inc

@@ -479,7 +479,6 @@ begin
         end;
         end;
       Dec(reslen,r);
       Dec(reslen,r);
     end;
     end;
-
   { rounding string if r > 0 }
   { rounding string if r > 0 }
   if r > 0 then
   if r > 0 then
     begin
     begin
@@ -487,17 +486,23 @@ begin
       k:=0;
       k:=0;
       for j:=0 to r do
       for j:=0 to r do
         begin
         begin
-          buf[i]:=chr(ord(buf[i]) + k);
-          if buf[i] >= '5' then
-            k:=1
+          if (k=1) and (buf[i]='9') then
+            buf[i]:='0'
           else
           else
-            k:=0;
+            begin
+            buf[i]:=chr(ord(buf[i]) + k);
+            if buf[i] >= '5' then
+              k:=1
+            else
+              k:=0;
+            end; 
           Inc(i);
           Inc(i);
-          if i>tlen then
+          if i>tlen  then
             break;
             break;
         end;
         end;
+      If (k=1) and (buf[i-1]='0') then
+        buf[i]:=chr(Ord(buf[i])+1);
     end;
     end;
-
   { preparing result string }
   { preparing result string }
   if reslen<len then
   if reslen<len then
     reslen:=len;
     reslen:=len;

+ 61 - 19
rtl/inc/system.inc

@@ -60,6 +60,21 @@ var
 function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt; forward;
 function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt; forward;
 {$endif FPC_HAS_FEATURE_STACKCHECK}
 {$endif FPC_HAS_FEATURE_STACKCHECK}
 
 
+{*****************************************************************************
+                       OS dependent Helpers/Syscalls
+*****************************************************************************}
+
+{ for some OSes do_isdevice is defined in sysos.inc, but for others (win32)
+  it isn't, and is used before the actual definition is encountered         }
+
+{$ifdef FPC_HAS_FEATURE_FILEIO}
+function do_isdevice(handle:thandle):boolean;forward;
+{$endif FPC_HAS_FEATURE_FILEIO}
+
+
+{$i sysos.inc}
+
+
 {****************************************************************************
 {****************************************************************************
                     Include processor specific routines
                     Include processor specific routines
 ****************************************************************************}
 ****************************************************************************}
@@ -142,17 +157,36 @@ function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt; forward;
   {$define SYSPROCDEFINED}
   {$define SYSPROCDEFINED}
 {$endif cpuarm}
 {$endif cpuarm}
 
 
-{$ifndef INTERNALMOVEFILLCHAR}
+
 procedure fillchar(var x;count : SizeInt;value : boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
 procedure fillchar(var x;count : SizeInt;value : boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
   fillchar(x,count,byte(value));
   fillchar(x,count,byte(value));
 end;
 end;
 
 
+
 procedure fillchar(var x;count : SizeInt;value : char);{$ifdef SYSTEMINLINE}inline;{$endif}
 procedure fillchar(var x;count : SizeInt;value : char);{$ifdef SYSTEMINLINE}inline;{$endif}
 begin
 begin
   fillchar(x,count,byte(value));
   fillchar(x,count,byte(value));
 end;
 end;
-{$endif INTERNALMOVEFILLCHAR}
+
+
+procedure FillByte (var x;count : SizeInt;value : byte ); {$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  FillChar (X,Count,VALUE);
+end;
+
+
+function IndexChar(Const buf;len:SizeInt;b:char):SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  IndexChar:=IndexByte(Buf,Len,byte(B));
+end;
+
+
+function CompareChar(Const buf1,buf2;len:SizeInt):SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  CompareChar:=CompareByte(buf1,buf2,len);
+end;
+
 
 
 { Include generic pascal only routines which are not defined in the processor
 { Include generic pascal only routines which are not defined in the processor
   specific include file }
   specific include file }
@@ -573,20 +607,25 @@ end;
 procedure fpc_iocheck;[public,alias:'FPC_IOCHECK']; compilerproc;
 procedure fpc_iocheck;[public,alias:'FPC_IOCHECK']; compilerproc;
 var
 var
   l : longint;
   l : longint;
+  HInoutRes : PWord;
 begin
 begin
-  if InOutRes<>0 then
+  HInOutRes:=@InoutRes;
+  if HInOutRes^<>0 then
    begin
    begin
-     l:=InOutRes;
-     InOutRes:=0;
+     l:=HInOutRes^;
+     HInOutRes^:=0;
      HandleErrorFrame(l,get_frame);
      HandleErrorFrame(l,get_frame);
    end;
    end;
 end;
 end;
 
 
 
 
 Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function IOResult:Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+var
+  HInoutRes : PWord;
 Begin
 Begin
-  IOResult:=InOutRes;
-  InOutRes:=0;
+  HInoutRes:=@InoutRes;
+  IOResult:=HInOutRes^;
+  HInOutRes^:=0;
 End;
 End;
 
 
 
 
@@ -874,11 +913,6 @@ begin
 end;
 end;
 
 
 
 
-{$ifdef FPC_HAS_FEATURE_FILEIO}
-function do_isdevice(handle:thandle):boolean;forward;
-{$endif FPC_HAS_FEATURE_FILEIO}
-
-
 {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
 {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
 Procedure dump_stack(var f : text;bp : Pointer);
 Procedure dump_stack(var f : text;bp : Pointer);
 var
 var
@@ -1127,13 +1161,6 @@ end;
 {$endif}
 {$endif}
 
 
 
 
-{*****************************************************************************
-                       OS dependent Helpers/Syscalls
-*****************************************************************************}
-
-{$i sysos.inc}
-
-
 {*****************************************************************************
 {*****************************************************************************
                                Heap
                                Heap
 *****************************************************************************}
 *****************************************************************************}
@@ -1204,3 +1231,18 @@ Function FindResource(ModuleHandle: HMODULE; ResourceName, ResourceType: AnsiStr
 begin
 begin
   Result:=FindResource(ModuleHandle,PChar(ResourceName),PChar(ResourceType));
   Result:=FindResource(ModuleHandle,PChar(ResourceName),PChar(ResourceType));
 end;
 end;
+
+const
+  CtrlBreakHandler: TCtrlBreakHandler = nil;
+
+{$IFNDEF FPC_HAS_SETCTRLBREAKHANDLER}
+(* It is possible to provide platform specific implementation performing   *)
+(* special initialization; default implementation just sets the procedural *)
+(* variable to make it available for use from the exception handler.       *)
+function SysSetCtrlBreakHandler (Handler: TCtrlBreakHandler): TCtrlBreakHandler;
+begin
+  (* Return either nil or previous handler *)
+  SysSetCtrlBreakHandler := CtrlBreakHandler;
+  CtrlBreakHandler := Handler;
+end;
+{$ENDIF FPC_HAS_SETCTRLBREAKHANDLER}

+ 16 - 20
rtl/inc/systemh.inc

@@ -316,6 +316,11 @@ type
   TPCharArray = packed array[0..(MaxLongint div SizeOf(PChar))-1] of PChar;
   TPCharArray = packed array[0..(MaxLongint div SizeOf(PChar))-1] of PChar;
   PPCharArray = ^TPCharArray;
   PPCharArray = ^TPCharArray;
 
 
+(* CtrlBreak set to true signalizes Ctrl-Break signal, otherwise Ctrl-C. *)
+(* Return value of true means that the signal has been processed, false  *)
+(* means that default handling should be used. *)
+  TCtrlBreakHandler = function (CtrlBreak: boolean): boolean;
+
 const
 const
 {$ifdef cpui386}
 {$ifdef cpui386}
   { Always i386 or newer }
   { Always i386 or newer }
@@ -401,30 +406,23 @@ ThreadVar
 ****************************************************************************}
 ****************************************************************************}
 
 
 {$ifdef FPC_USE_LIBC}
 {$ifdef FPC_USE_LIBC}
-{$ifdef SYSTEMINLINE}
-{$define INLINEGENERICS}
-{$endif}
+  {$ifdef SYSTEMINLINE}
+    {$define INLINEGENERICS}
+  {$endif}
 {$endif}
 {$endif}
 
 
-{$ifdef INTERNALMOVEFILLCHAR}
-Procedure SysMoveForward(const source;var dest;count:SizeInt);
-Procedure SysMoveBackward(const source;var dest;count:SizeInt);
-Procedure SysFillChar(var x;count:SizeInt;Value:Byte);
-procedure FillByte(var x;count:SizeInt;value:byte);[INTERNPROC: fpc_in_fillchar_x];
-{$else INTERNALMOVEFILLCHAR}
 Procedure Move(const source;var dest;count:SizeInt);{$ifdef INLINEGENERICS}inline;{$endif}
 Procedure Move(const source;var dest;count:SizeInt);{$ifdef INLINEGENERICS}inline;{$endif}
+Procedure FillChar(var x;count:SizeInt;Value:Byte);{$ifdef INLINEGENERICS}inline;{$endif}
 Procedure FillChar(var x;count:SizeInt;Value:Boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
 Procedure FillChar(var x;count:SizeInt;Value:Boolean);{$ifdef SYSTEMINLINE}inline;{$endif}
 Procedure FillChar(var x;count:SizeInt;Value:Char);{$ifdef SYSTEMINLINE}inline;{$endif}
 Procedure FillChar(var x;count:SizeInt;Value:Char);{$ifdef SYSTEMINLINE}inline;{$endif}
-Procedure FillChar(var x;count:SizeInt;Value:Byte);{$ifdef INLINEGENERICS}inline;{$endif}
-procedure FillByte(var x;count:SizeInt;value:byte);{$ifdef INLINEGENERICS}inline;{$endif}
-{$endif INTERNALMOVEFILLCHAR}
+procedure FillByte(var x;count:SizeInt;value:byte);{$ifdef SYSTEMINLINE}inline;{$endif}
 Procedure FillWord(var x;count:SizeInt;Value:Word);
 Procedure FillWord(var x;count:SizeInt;Value:Word);
 procedure FillDWord(var x;count:SizeInt;value:DWord);
 procedure FillDWord(var x;count:SizeInt;value:DWord);
-function  IndexChar(const buf;len:SizeInt;b:char):SizeInt;
+function  IndexChar(const buf;len:SizeInt;b:char):SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function  IndexByte(const buf;len:SizeInt;b:byte):SizeInt;{$ifdef INLINEGENERICS}inline;{$endif}
 function  IndexByte(const buf;len:SizeInt;b:byte):SizeInt;{$ifdef INLINEGENERICS}inline;{$endif}
 function  Indexword(const buf;len:SizeInt;b:word):SizeInt;
 function  Indexword(const buf;len:SizeInt;b:word):SizeInt;
 function  IndexDWord(const buf;len:SizeInt;b:DWord):SizeInt;
 function  IndexDWord(const buf;len:SizeInt;b:DWord):SizeInt;
-function  CompareChar(const buf1,buf2;len:SizeInt):SizeInt;
+function  CompareChar(const buf1,buf2;len:SizeInt):SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function  CompareByte(const buf1,buf2;len:SizeInt):SizeInt;{$ifdef INLINEGENERICS}inline;{$endif}
 function  CompareByte(const buf1,buf2;len:SizeInt):SizeInt;{$ifdef INLINEGENERICS}inline;{$endif}
 function  CompareWord(const buf1,buf2;len:SizeInt):SizeInt;
 function  CompareWord(const buf1,buf2;len:SizeInt):SizeInt;
 function  CompareDWord(const buf1,buf2;len:SizeInt):SizeInt;
 function  CompareDWord(const buf1,buf2;len:SizeInt):SizeInt;
@@ -437,12 +435,6 @@ procedure ReadDependencyBarrier;{$ifdef INLINEGENERICS}inline;{$endif}
 procedure ReadWriteBarrier;{$ifdef INLINEGENERICS}inline;{$endif}
 procedure ReadWriteBarrier;{$ifdef INLINEGENERICS}inline;{$endif}
 procedure WriteBarrier;{$ifdef INLINEGENERICS}inline;{$endif}
 procedure WriteBarrier;{$ifdef INLINEGENERICS}inline;{$endif}
 
 
-{$ifdef INTERNALMOVEFILLCHAR}
-var
-  fpc_moveforward_proc : pointer = @SysMoveForward public name 'FPC_MOVEFORWARD_PROC';
-  fpc_movebackward_proc : pointer = @SysMoveBackward public name 'FPC_MOVEBACKWARD_PROC';
-  fpc_fillchar_proc : pointer = @SysFillChar public name 'FPC_FILLCHAR_PROC';
-{$endif INTERNALMOVEFILLCHAR}
 
 
 {****************************************************************************
 {****************************************************************************
                           Math Routines
                           Math Routines
@@ -820,6 +812,10 @@ Function StringToPPChar(S: PChar;ReserveEntries:integer):ppchar;
 procedure AbstractError;external name 'FPC_ABSTRACTERROR';
 procedure AbstractError;external name 'FPC_ABSTRACTERROR';
 Function  SysBackTraceStr(Addr:Pointer): ShortString;
 Function  SysBackTraceStr(Addr:Pointer): ShortString;
 Procedure SysAssert(const Msg,FName:ShortString;LineNo:Longint;ErrorAddr:Pointer);
 Procedure SysAssert(const Msg,FName:ShortString;LineNo:Longint;ErrorAddr:Pointer);
+(* Supposed to return address of previous CtrlBreakHandler *)
+(* (may be nil), returned value of pointer (-1) means that *)
+(* attempt to setup CtrlBreakHandler wasn't successful.    *)
+function SysSetCtrlBreakHandler (Handler: TCtrlBreakHandler): TCtrlBreakHandler;
 
 
 { Error handlers }
 { Error handlers }
 Type
 Type

+ 1 - 1
rtl/inc/wstrings.inc

@@ -976,7 +976,7 @@ end;
 
 
 Procedure fpc_WideStr_CheckRange(len,index : SizeInt);[Public,Alias : 'FPC_WIDESTR_RANGECHECK']; compilerproc;
 Procedure fpc_WideStr_CheckRange(len,index : SizeInt);[Public,Alias : 'FPC_WIDESTR_RANGECHECK']; compilerproc;
 begin
 begin
-  if (index>len) or (Index<1) then
+  if (index>len div 2) or (Index<1) then
     HandleErrorFrame(201,get_frame);
     HandleErrorFrame(201,get_frame);
 end;
 end;
 
 

+ 17 - 3
rtl/linux/Makefile

@@ -1,11 +1,12 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/10/21]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/10/30]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos 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 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 sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos 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 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 sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 BSDs = freebsd netbsd openbsd darwin
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
 LIMIT83fs = go32v2 os2 emx watcom
+OSNeedsComspecToRunBatch = go32v2 watcom
 FORCE:
 FORCE:
 .PHONY: FORCE
 .PHONY: FORCE
 override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
 override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
@@ -56,6 +57,11 @@ else
 SRCBATCHEXT=.bat
 SRCBATCHEXT=.bat
 endif
 endif
 endif
 endif
+ifdef COMSPEC
+ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),)
+RUNBATCH=$(COMSPEC) /C
+endif
+endif
 ifdef inUnix
 ifdef inUnix
 PATHSEP=/
 PATHSEP=/
 else
 else
@@ -103,7 +109,11 @@ ifndef FPC
 FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
 FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
 ifneq ($(FPCPROG),)
 ifneq ($(FPCPROG),)
 FPCPROG:=$(firstword $(FPCPROG))
 FPCPROG:=$(firstword $(FPCPROG))
+ifneq ($(CPU_TARGET),)
+FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
+else
 FPC:=$(shell $(FPCPROG) -PB)
 FPC:=$(shell $(FPCPROG) -PB)
+endif
 ifneq ($(findstring Error,$(FPC)),)
 ifneq ($(findstring Error,$(FPC)),)
 override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
 override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
 endif
 endif
@@ -249,7 +259,7 @@ else
 override LOADERS+=cprt21 gprt21
 override LOADERS+=cprt21 gprt21
 endif
 endif
 CPU_UNITS=x86 ports cpu mmx
 CPU_UNITS=x86 ports cpu mmx
-SYSINIT_UNITS=si_prc si_c21g si_c21 si_c si_dll
+SYSINIT_UNITS=si_prc si_c21g si_c21 si_c si_dll si_uc
 endif
 endif
 ifeq ($(CPU_TARGET),x86_64)
 ifeq ($(CPU_TARGET),x86_64)
 SYSINIT_UNITS=   # si_prc si_c si_dll
 SYSINIT_UNITS=   # si_prc si_c si_dll
@@ -2114,7 +2124,7 @@ override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
 endif
 endif
 ifndef CROSSBOOTSTRAP
 ifndef CROSSBOOTSTRAP
 ifneq ($(BINUTILSPREFIX),)
 ifneq ($(BINUTILSPREFIX),)
-override FPCOPT+=-XP$(BINUTILSPREFIX) 
+override FPCOPT+=-XP$(BINUTILSPREFIX)
 endif
 endif
 ifneq ($(BINUTILSPREFIX),)
 ifneq ($(BINUTILSPREFIX),)
 override FPCOPT+=-Xr$(RLINKPATH)
 override FPCOPT+=-Xr$(RLINKPATH)
@@ -2246,9 +2256,13 @@ ifeq (,$(findstring -s ,$(COMPILER)))
 EXECPPAS=
 EXECPPAS=
 else
 else
 ifeq ($(FULL_SOURCE),$(FULL_TARGET))
 ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+ifdef RUNBATCH
+EXECPPAS:=@$(RUNBATCH) $(PPAS)
+else
 EXECPPAS:=@$(PPAS)
 EXECPPAS:=@$(PPAS)
 endif
 endif
 endif
 endif
+endif
 .PHONY: fpc_loaders
 .PHONY: fpc_loaders
 ifneq ($(TARGET_LOADERS),)
 ifneq ($(TARGET_LOADERS),)
 override ALLTARGET+=fpc_loaders
 override ALLTARGET+=fpc_loaders

+ 1 - 1
rtl/linux/Makefile.fpc

@@ -67,7 +67,7 @@ else
 override LOADERS+=cprt21 gprt21
 override LOADERS+=cprt21 gprt21
 endif
 endif
 CPU_UNITS=x86 ports cpu mmx
 CPU_UNITS=x86 ports cpu mmx
-SYSINIT_UNITS=si_prc si_c21g si_c21 si_c si_dll
+SYSINIT_UNITS=si_prc si_c21g si_c21 si_c si_dll si_uc
 endif
 endif
 
 
 ifeq ($(CPU_TARGET),x86_64)
 ifeq ($(CPU_TARGET),x86_64)

+ 1 - 2
rtl/linux/arm/prt0.as

@@ -72,8 +72,7 @@ _start:
 	.globl  _haltproc
 	.globl  _haltproc
     .type   _haltproc,#function
     .type   _haltproc,#function
 _haltproc:
 _haltproc:
-	ldr r0,=operatingsystem_result
-	ldrb r0,[r0]
+        /* r0 contains exitcode */
 	swi 0x900001
 	swi 0x900001
 	b _haltproc
 	b _haltproc
 
 

+ 114 - 0
rtl/linux/i386/si_uc.inc

@@ -0,0 +1,114 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
+    & Daniel Mantione, members of the Free Pascal development team.
+
+    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.
+
+ **********************************************************************}
+
+{
+ Linux/uClibc startup code for Free Pascal
+    taken from uClibc/sysdeps/linux/i386/crt1.S
+
+ %edx  Contains a function pointer to be registered with `atexit'.
+       This is how the dynamic linker arranges to have DT_FINI
+       functions called for shared libraries that have been loaded
+       before this code runs.
+   
+
+ Stack layout at program start:
+
+         nil
+         envn
+         ....
+         ....           ENVIRONMENT VARIABLES
+         env1
+         env0
+         nil
+         argn
+         ....
+         ....           COMMAND LINE OPTIONS
+         arg1
+         arg0
+         argc <--- esp
+}
+
+
+procedure libc_init; external name '__uClibc_init';
+procedure libc_fini; external name '__uClibc_fini';
+procedure libc_exit; external name '_exit';
+procedure libc_main; external name '__uClibc_main';
+
+procedure PASCALMAIN; external name 'PASCALMAIN';
+
+{******************************************************************************
+                          C library start/halt
+ ******************************************************************************}
+{$asmmode ATT}
+
+procedure _FPC_libc_start; assembler; nostackframe; public name '_start';
+asm
+  xorl    %ebp,%ebp               { clear outer most frame for backtraces }
+  popl    %esi                    { Get argc in ecx }
+  movl    %esp,%ecx               { Esp now points to the arguments }
+  leal    4(%esp,%esi,4),%eax     { The start of the environment is: esp+4*eax+8 }
+  andl    $0xfffffff0,%esp        { Align stack }
+  pushl   %eax                    { push garbage, so we push 32 bytes in total }
+
+  movl    %eax,operatingsystem_parameter_envp    { save the environment pointer }
+  movl    %esi,operatingsystem_parameter_argc    { save the argument counter    }
+  movl    %ecx,operatingsystem_parameter_argv    { save the argument pointer    }
+  movl    %esp,initialstkptr                     { save initial stack pointer   }
+
+  pushl   %esp            { provide highest stack address to C library }
+  pushl   %edx            { push address of shared library finalization }
+
+{$ifdef PIC}
+  call    .L0
+.L0:
+  pop     %ebx
+  addl    $_GLOBAL_OFFSET_TABLE_+[.-.L0],%ebx
+
+  pushl   _fini@GOT(%ebx) { push address of entry points }
+  pushl   _init@GOT(%ebx)
+
+  pushl   %ecx            { push argv }                                 
+  pushl   %esi            { push argc }
+                                                                       
+  pushl   $PASCALMAIN     { push fpc main procedure }
+  call    libc_main       { let fpc main be called from libc startup }
+{$else}
+  pushl   $libc_fini      { push address of entry points }
+  pushl   $libc_init
+
+  pushl   %ecx            { push argv }
+  pushl   %esi            { push argc }
+
+  pushl   $PASCALMAIN     { push fpc main procedure }
+  call    libc_main       { let fpc main be called from libc startup }
+{$endif}
+end;
+
+procedure _FPC_libc_haltproc; assembler; nostackframe; public name '_haltproc';
+asm
+.Lhaltproc:
+{$if sizeof(ExitCode)=2}
+  movzwl  ExitCode,%ebx
+{$else}
+  mov     ExitCode,%ebx
+{$endif}
+  pushl   %ebx
+  call    libc_exit
+  xorl    %eax,%eax
+  incl    %eax                    { eax=1, exit call }
+  popl    %ebx
+  int     $0x80
+  jmp     .Lhaltproc
+end;
+

+ 1 - 1
rtl/linux/ossysc.inc

@@ -510,7 +510,7 @@ end;
 // prototype is cint __P(cint,culong,....)
 // prototype is cint __P(cint,culong,....)
 // actual meaning of return value depends on request.
 // actual meaning of return value depends on request.
 
 
-Function FpIOCtl(fd:cint;request:culong;Data: Pointer):cint;  [public, alias : 'FPC_SYSC_IOCTL'];
+Function FpIOCtl(fd:cint;request:TIOCtlRequest;Data: Pointer):cint;  [public, alias : 'FPC_SYSC_IOCTL'];
 // This was missing here, instead hardcoded in Do_IsDevice
 // This was missing here, instead hardcoded in Do_IsDevice
 begin
 begin
   FpIOCtl:=do_SysCall(syscall_nr_ioctl,tsysparam(fd),tsysparam(Request),TSysParam(data));
   FpIOCtl:=do_SysCall(syscall_nr_ioctl,tsysparam(fd),tsysparam(Request),TSysParam(data));

+ 2 - 0
rtl/linux/ptypes.inc

@@ -118,6 +118,8 @@ Type
     pUid     = ^uid_t;
     pUid     = ^uid_t;
     TGid     = gid_t;
     TGid     = gid_t;
     pGid     = ^gid_t;
     pGid     = ^gid_t;
+    
+    TIOCtlRequest = cInt;
 
 
 
 
     socklen_t= cuint32;
     socklen_t= cuint32;

+ 26 - 0
rtl/linux/si_uc.pp

@@ -0,0 +1,26 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by Michael Van Canneyt, Peter Vreman,
+    & Daniel Mantione, members of the Free Pascal development team.
+
+    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 si_uc;
+
+interface
+
+{$i si_intf.inc}
+
+implementation
+
+{$i sysnr.inc}
+{$i si_uc.inc}
+
+end.

+ 2 - 2
rtl/linux/system.pp

@@ -19,7 +19,7 @@
 { If you use an aout system, set the conditional AOUT}
 { If you use an aout system, set the conditional AOUT}
 { $Define AOUT}
 { $Define AOUT}
 
 
-{$ifdef i386}
+{$ifdef CPUI386}
 {$DEFINE ELFRES32}
 {$DEFINE ELFRES32}
 {$endif}
 {$endif}
 
 
@@ -52,7 +52,7 @@ property cmdline:Pchar read get_cmdline;
                                  implementation
                                  implementation
 {*****************************************************************************}
 {*****************************************************************************}
 
 
-{$if defined(i386) and not defined(FPC_USE_LIBC)}
+{$if defined(CPUI386) and not defined(FPC_USE_LIBC)}
 var
 var
   sysenter_supported: LongInt = 0;
   sysenter_supported: LongInt = 0;
 {$endif}
 {$endif}

+ 34 - 0
rtl/linux/unixsockets.inc

@@ -0,0 +1,34 @@
+
+function CMSG_FIRSTHDR(mhdr: Pmsghdr): Pcmsghdr;
+begin
+  if mhdr^.msg_controllen >= SizeOf(cmsghdr) then
+    Result:=mhdr^.msg_control
+  else
+    Result:=nil;
+end;
+
+function CMSG_NXTHDR(mhdr: Pmsghdr; cmsg: Pcmsghdr): Pcmsghdr;
+begin
+   Result:=__cmsg_nxthdr(mhdr, cmsg);
+end;
+
+function CMSG_ALIGN(len: size_t): size_t;
+begin
+  Result:=(len+SizeOf(size_t)-1) and (not(SizeOf(size_t)-1));
+end;
+
+function CMSG_SPACE(len: size_t): size_t;
+begin
+  Result:=CMSG_ALIGN(len)+CMSG_ALIGN(SizeOf(cmsghdr));
+end;
+
+function CMSG_LEN(len: size_t): size_t;
+begin
+  Result:=CMSG_ALIGN(SizeOf(cmsghdr))+len;
+end;
+
+function CMSG_DATA(cmsg: Pointer): PByte;
+begin
+  Result:=PByte(Cardinal(cmsg) + SizeOf(Pcmsghdr));
+end;
+

+ 33 - 0
rtl/linux/unixsocketsh.inc

@@ -0,0 +1,33 @@
+const
+  clib = 'c';
+
+type
+  Pmsghdr = ^msghdr;
+  msghdr = record
+     msg_name : pointer;
+     msg_namelen : socklen_t;
+     msg_iov : piovec;
+     msg_iovlen : size_t;
+     msg_control : pointer;
+     msg_controllen : socklen_t;
+     msg_flags : cInt;
+  end;
+
+  Pcmsghdr = ^cmsghdr;
+  cmsghdr = record
+    cmsg_len   : socklen_t;
+    cmsg_level : cInt;
+    cmsg_type  : cInt;
+  end;
+
+  function sendmsg(__fd: cInt; __message: pmsghdr; __flags: cInt): ssize_t; cdecl; external clib name 'sendmsg';
+  function recvmsg(__fd: cInt; __message: pmsghdr; __flags: cInt): ssize_t; cdecl; external clib name 'recvmsg';
+  
+  function CMSG_FIRSTHDR(mhdr: Pmsghdr): Pcmsghdr;
+  function CMSG_NXTHDR(mhdr: Pmsghdr; cmsg: Pcmsghdr): Pcmsghdr;
+  function CMSG_ALIGN(len: size_t): size_t;
+  function CMSG_SPACE(len: size_t): size_t;
+  function CMSG_LEN(len: size_t): size_t;
+  function CMSG_DATA(cmsg : pcmsghdr) : Pbyte;
+
+

+ 1 - 0
rtl/netbsd/ptypes.inc

@@ -31,6 +31,7 @@ type
     gid_t    = cuint32;         { used for group IDs           }
     gid_t    = cuint32;         { used for group IDs           }
     TGid     = gid_t;
     TGid     = gid_t;
     pGid     = ^gid_t;
     pGid     = ^gid_t;
+    TIOCtlRequest = cuLong;
 
 
     ino_t    = clong;           { used for file serial numbers }
     ino_t    = clong;           { used for file serial numbers }
     TIno     = ino_t;
     TIno     = ino_t;

+ 300 - 0
rtl/objpas/dateutil.inc

@@ -407,6 +407,10 @@ Function DateTimeToMac(const AValue: TDateTime): Int64;
 Function MacToDateTime(const AValue: Int64): TDateTime;
 Function MacToDateTime(const AValue: Int64): TDateTime;
 Function MacTimeStampToUnix(const AValue: Int64): Int64;
 Function MacTimeStampToUnix(const AValue: Int64): Int64;
 
 
+{ ScanDateTime is a limited inverse of formatdatetime }
+function ScanDateTime(const Pattern:string;const s:string;const fmt:TFormatSettings;startpos:integer=1) : tdatetime; overload;
+function ScanDateTime(const Pattern:string;const s:string;startpos:integer=1) : tdatetime; overload;
+
 implementation
 implementation
 
 
 uses sysconst;
 uses sysconst;
@@ -2069,5 +2073,301 @@ begin
   Result:=AValue - Epoch;
   Result:=AValue - Epoch;
 end;
 end;
 
 
+{
+  Inverse of formatdatetime, destined for the dateutils unit of FPC.
+
+  Limitations/implementation details:
+  - An inverse of FormatDateTime is not 100% an inverse, simply because one can put e.g. time tokens twice in the format string,
+       and scandatetime wouldn't know which time to pick.
+  - Strings like hn can't be reversed safely. E.g. 1:2 (2 minutes after 1) delivers 12 which is parsed as 12:00 and then
+       misses chars for the "n" part.
+  - trailing characters are ignored.
+  - no support for Eastern Asian formatting characters since they are windows only.
+  - no MBCS support.
+
+  Extensions
+  - #9 eats whitespace.
+  - whitespace at the end of a pattern is optional.
+  - ? matches any char.
+  - Quote the above chars to really match the char.
+}
+
+const whitespace  = [' ',#13,#10];
+      hrfactor    = 1/(24);
+      minfactor   = 1/(24*60);
+      secfactor   = 1/(24*60*60);
+      mssecfactor = 1/(24*60*60*1000);
+
+const AMPMformatting : array[0..2] of string =('am/pm','a/p','ampm');
+
+procedure raiseexception(const s:string);
+
+begin
+  raise EConvertError.Create(s);
+end;
+
+function scandatetime(const pattern:string;const s:string;const fmt:TFormatSettings;startpos:integer=1) : tdatetime;
+
+var len ,ind  : integer;
+    yy,mm,dd  : integer;
+    timeval   : TDateTime;
+    activequote: char;
+
+procedure intscandate(ptrn:pchar;plen:integer;poffs:integer);
+// poffs is the offset to
+
+var
+    pind : integer;
+
+function findimatch(const mnts:array of string;p:pchar):integer;
+var i : integer;
+begin
+  result:=-1;
+  i:=0;
+  while (i<=high(mnts)) and (result=-1) do
+    begin
+      if AnsiStrLIComp(p,@mnts[i][1],length(mnts[i]))=0 then
+        result:=i;
+      inc(i);
+    end;
+end;
+
+procedure arraymatcherror;
+
+begin
+  raiseexception(format(SNoArrayMatch,[pind+1,ind]))
+end;
+
+function findmatch(const mnts : array of string;const s:string):integer;
+
+begin
+  result:=findimatch(mnts,@s[ind]);
+  if result=-1 then
+    arraymatcherror
+  else
+    begin
+      inc(ind,length(mnts[result])+1);
+      inc(pind,length(mnts[result])+1);
+      inc(result); // was 0 based.
+    end;
+end;
+
+var
+    pivot,
+    i     : integer;
+
+function scanfixedint(maxv:integer):integer;
+var c : char;
+    oi:integer;
+begin
+  result:=0;
+  oi:=ind;
+  c:=ptrn[pind];
+  while (pind<plen) and (ptrn[pind]=c) do inc(pind);
+  while (maxv>0) and (ind<=len) and (s[ind] IN ['0'..'9']) do
+    begin
+      result:=result*10+ord(s[ind])-48;
+      inc(ind);
+      dec(maxv);
+    end;
+  if oi=ind then
+    raiseexception(format(SPatternCharMismatch,[c,oi]));
+end;
+
+procedure matchchar(c:char);
+
+begin
+  if (ind>len) or (s[ind]<>c) then
+    raiseexception(format(SNoCharMatch,[s[ind],c,pind+poffs+1,ind]));
+  inc(pind);
+  inc(ind);
+end;
+
+function scanpatlen:integer;
+var c : char;
+    lind : Integer;
+begin
+  result:=pind;
+  lind:=pind;
+  c:=ptrn[lind];
+
+  while (lind<=plen) and (ptrn[lind]=c) do
+      inc(lind);
+  result:=lind-result;
+end;
+
+procedure matchpattern(const lptr:string);
+
+var len:integer;
+begin
+  len:=length(lptr);
+  if len>0 then
+    intscandate(@lptr[1],len,pind+poffs);
+end;
+
+var lasttoken,lch : char;
+
+begin
+  pind:=0;     lasttoken:=' ';
+  while (ind<=len) and (pind<plen) do
+     begin
+       lch:=upcase(ptrn[pind]);
+       if activequote=#0 then
+          begin
+            if (lch='M') and (lasttoken='H') then
+              begin
+                i:=scanpatlen;
+                if i>2 then
+                  raiseexception(format(Shhmmerror,[poffs+pind+1]));
+                timeval:=timeval+scanfixedint(2)* minfactor;
+              end
+            else
+            case lch of
+               'H':  timeval:=timeval+scanfixedint(2)* hrfactor;
+               'D':  begin
+                       i:=scanpatlen;
+                       case i of
+                          1,2 : dd:=scanfixedint(2);
+                          3   : dd:=findmatch(fmt.shortDayNames,s);
+                          4   : dd:=findmatch(fmt.longDayNames,s);
+                          5   : matchpattern(fmt.shortdateformat);
+                          6   : matchpattern(fmt.longdateformat);
+                         end;
+                     end;
+               'N':  timeval:=timeval+scanfixedint(2)* minfactor;
+               'S':  timeval:=timeval+scanfixedint(2)* secfactor;
+               'Z':  timeval:=timeval+scanfixedint(3)* mssecfactor;
+               'Y':  begin
+                       i:=scanpatlen;
+                       yy:=scanfixedint(i);
+                       if i<=2 then
+                         begin
+                           pivot:=YearOf(now)-fmt.TwoDigitYearCenturyWindow;
+                           inc(yy, pivot div 100 * 100);
+                           if (fmt.TwoDigitYearCenturyWindow > 0) and (yy < pivot) then
+                              inc(yy, 100);
+                         end;
+                      end;
+               'M': begin
+                       i:=scanpatlen;
+                       case i of
+                          1,2: mm:=scanfixedint(2);
+                          3:   mm:=findmatch(fmt.ShortMonthNames,s);
+                          4:   mm:=findmatch(fmt.LongMonthNames,s);
+                          end;
+                    end;
+               'T' : begin
+                       i:=scanpatlen;
+                       case i of
+                       1: matchpattern(fmt.shortdateformat);
+                       2: matchpattern(fmt.longtimeformat);
+                       end;
+                     end;
+               'A' : begin
+                            i:=findimatch(AMPMformatting,@ptrn[pind]);
+                            case i of
+                              0: begin
+                                   i:=findimatch(['AM','PM'],@s[ind]);
+                                   case i of
+                                     0: ;
+                                     1: timeval:=timeval+12*hrfactor;
+                                   else
+                                     arraymatcherror
+                                     end;
+                                   inc(pind,length(AMPMformatting[0]));
+                                   inc(ind,2);
+                                 end;
+                              1: begin
+                                    case upcase(s[ind]) of
+                                     'A' : ;
+                                     'P' : timeval:=timeval+12*hrfactor;
+                                   else
+                                     arraymatcherror
+                                     end;
+                                   inc(pind,length(AMPMformatting[1]));
+                                   inc(ind);
+                                 end;
+                               2: begin
+                                    i:=findimatch([fmt.timeamstring,fmt.timepmstring],@s[ind]);
+                                    case i of
+                                     0: inc(ind,length(fmt.timeamstring));
+                                     1: begin
+                                          timeval:=timeval+12*hrfactor;
+                                          inc(ind,length(fmt.timepmstring));
+                                        end;
+                                   else
+                                     arraymatcherror
+                                     end;
+                                   inc(pind,length(AMPMformatting[2]));
+                                   inc(pind,2);
+                                   inc(ind,2);
+                                 end;
+                            else  // no AM/PM match. Assume 'a' is simply a char
+                                matchchar(ptrn[pind]);
+                             end;
+                         end;
+               '/' : matchchar(fmt.dateSeparator);
+               ':' : begin
+                       matchchar(fmt.TimeSeparator);
+                       lch:=lasttoken;
+                     end;
+               #39,'"' : begin
+                           activequote:=lch;
+                           inc(pind);
+                         end;
+               'C' : begin
+                       intscandate(@fmt.shortdateformat[1],length(fmt.ShortDateFormat),pind+poffs);
+                       intscandate(@fmt.longtimeformat[1],length(fmt.longtimeformat),pind+poffs);
+                       inc(pind);
+                     end;
+               '?' : begin
+                       inc(pind);
+                       inc(ind);
+                     end;
+               #9  : begin
+                       while (ind<=len) and (s[ind] in whitespace) do
+                         inc(ind);
+                       inc(pind);
+                     end;
+               else
+                 matchchar(ptrn[pind]);
+             end; {case}
+             lasttoken:=lch;
+            end
+          else
+            begin
+              if activequote=lch then
+                begin
+                  activequote:=#0;
+                  inc(pind);
+                end
+              else
+                matchchar(ptrn[pind]);
+            end;
+     end;
+   if (pind<plen) and (plen>0) and (ptrn[plen-1]<>#9) then  // allow omission of trailing whitespace
+     RaiseException(format(SFullpattern,[poffs+pind+1]));
+end;
+
+var plen:integer;
+
+begin
+  activequote:=#0;
+  yy:=0; mm:=0; dd:=0;
+  timeval:=0.0;
+  len:=length(s); ind:=startpos;
+  plen:=length(pattern);
+  intscandate(@pattern[1],plen,0);
+  result:=timeval;
+  if (yy>0) and (mm>0) and (dd>0) then
+     result:=result+encodedate(yy,mm,dd);
+end;
+
+
+function scandatetime(const pattern:string;const s:string;startpos:integer=1) : tdatetime; overload;
+
+begin
+ result:=scandatetime(pattern,s,defaultformatsettings);
+end;
 
 
 end.
 end.

+ 106 - 25
rtl/objpas/strutils.pp

@@ -165,6 +165,8 @@ function Hex2Dec(const S: string): Longint;
 function Dec2Numb(N: Longint; Len, Base: Byte): string;
 function Dec2Numb(N: Longint; Len, Base: Byte): string;
 function Numb2Dec(S: string; Base: Byte): Longint;
 function Numb2Dec(S: string; Base: Byte): Longint;
 function IntToBin(Value: Longint; Digits, Spaces: Integer): string;
 function IntToBin(Value: Longint; Digits, Spaces: Integer): string;
+function IntToBin(Value: Longint; Digits: Integer): string;
+function intToBin(Value: int64; Digits:integer): string;
 function IntToRoman(Value: Longint): string;
 function IntToRoman(Value: Longint): string;
 function RomanToInt(const S: string): Longint;
 function RomanToInt(const S: string): Longint;
 procedure BinToHex(BinValue, HexValue: PChar; BinBufSize: Integer);
 procedure BinToHex(BinValue, HexValue: PChar; BinBufSize: Integer);
@@ -192,15 +194,38 @@ function TrimSet(const S: String;const CSet:TSysCharSet): String;
 implementation
 implementation
 
 
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
-    Auxiliary functions
+   Possibly Exception raising functions
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
 
 
+
 Procedure NotYetImplemented (FN : String);
 Procedure NotYetImplemented (FN : String);
 
 
 begin
 begin
   Raise Exception.CreateFmt('Function "%s" (strutils) is not yet implemented',[FN]);
   Raise Exception.CreateFmt('Function "%s" (strutils) is not yet implemented',[FN]);
 end;
 end;
 
 
+function Hex2Dec(const S: string): Longint;
+var
+  HexStr: string;
+begin
+  if Pos('$',S)=0 then
+    HexStr:='$'+ S
+  else
+    HexStr:=S;
+  Result:=StrToInt(HexStr);
+end;
+
+{
+  We turn off implicit exceptions, since these routines are tested, and it 
+  saves 20% codesize (and some speed) and don't throw exceptions, except maybe 
+  heap related. If they don't, that is consider a bug.
+
+  In the future, be wary with routines that use strtoint, floating point 
+  and/or format() derivatives. And check every divisor for 0.
+}
+
+{$IMPLICITEXCEPTIONS OFF}
+
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
     Case insensitive search/replace
     Case insensitive search/replace
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
@@ -350,17 +375,22 @@ end;
 Function StuffString(const AText: string; AStart, ALength: Cardinal;  const ASubText: string): string;
 Function StuffString(const AText: string; AStart, ALength: Cardinal;  const ASubText: string): string;
 
 
 var i,j : SizeUInt;
 var i,j : SizeUInt;
+    k   : SizeInt;
 
 
 begin
 begin
   j:=length(ASubText);
   j:=length(ASubText);
   i:=length(AText);
   i:=length(AText);
+  if AStart>i then 
+    aStart:=i+1;
+  k:=i-AStart+1;
+  if ALength> k then
+    ALength:=k;
   SetLength(Result,i+j-ALength);
   SetLength(Result,i+j-ALength);
   move (AText[1],result[1],AStart-1);
   move (AText[1],result[1],AStart-1);
   move (ASubText[1],result[AStart],j);
   move (ASubText[1],result[AStart],j);
   move (AText[AStart+ALength], Result[AStart+j],i+1-AStart-ALength);
   move (AText[AStart+ALength], Result[AStart+j],i+1-AStart-ALength);
 end;
 end;
 
 
-
 Function RandomFrom(const AValues: array of string): string; overload;
 Function RandomFrom(const AValues: array of string): string; overload;
 
 
 begin
 begin
@@ -611,7 +641,7 @@ begin
   if i=nil then
   if i=nil then
     PosEx:=0
     PosEx:=0
   else
   else
-    PosEx:=succ(i-pchar(s));
+    PosEx:=succ(i-pchar(pointer(s)));
 end;
 end;
 
 
 
 
@@ -758,9 +788,9 @@ Var
 begin
 begin
   S:=SoundEx(Atext,4);
   S:=SoundEx(Atext,4);
   Result:=Ord(S[1])-OrdA;
   Result:=Ord(S[1])-OrdA;
-  Result:=Result*26+StrToInt(S[2]);
-  Result:=Result*7+StrToInt(S[3]);
-  Result:=Result*7+StrToInt(S[4]);
+  Result:=Result*26+ord(S[2])-48;
+  Result:=Result*7+ord(S[3])-48;
+  Result:=Result*7+ord(S[4])-48;
 end;
 end;
 
 
 
 
@@ -994,7 +1024,7 @@ var
 
 
 begin
 begin
   Result:=AnsiLowerCase(S);
   Result:=AnsiLowerCase(S);
-  P:=PChar(Result);
+  P:=PChar(pointer(Result));
   PE:=P+Length(Result);
   PE:=P+Length(Result);
   while (P<PE) do
   while (P<PE) do
     begin
     begin
@@ -1014,7 +1044,7 @@ var
 
 
 begin
 begin
   Result:=0;
   Result:=0;
-  P:=Pchar(S);
+  P:=Pchar(pointer(S));
   PE:=P+Length(S);
   PE:=P+Length(S);
   while (P<PE) do
   while (P<PE) do
     begin
     begin
@@ -1036,7 +1066,7 @@ var
 begin
 begin
   Result:=0;
   Result:=0;
   Count:=0;
   Count:=0;
-  PS:=PChar(S);
+  PS:=PChar(pointer(S));
   PE:=PS+Length(S);
   PE:=PS+Length(S);
   P:=PS;
   P:=PS;
   while (P<PE) and (Count<>N) do
   while (P<PE) and (Count<>N) do
@@ -1168,16 +1198,6 @@ begin
     Result:=S;
     Result:=S;
 end;
 end;
 
 
-function Hex2Dec(const S: string): Longint;
-var
-  HexStr: string;
-begin
-  if Pos('$',S)=0 then
-    HexStr:='$'+ S
-  else
-    HexStr:=S;
-  Result:=StrToInt(HexStr);
-end;
 
 
 function Dec2Numb(N: Longint; Len, Base: Byte): string;
 function Dec2Numb(N: Longint; Len, Base: Byte): string;
 
 
@@ -1298,19 +1318,80 @@ begin
 end;
 end;
 
 
 function intToBin(Value: Longint; Digits, Spaces: Integer): string;
 function intToBin(Value: Longint; Digits, Spaces: Integer): string;
+var endpos : integer;
+    p,p2:pchar;
+    k: integer;
 begin
 begin
   Result:='';
   Result:='';
   if (Digits>32) then
   if (Digits>32) then
     Digits:=32;
     Digits:=32;
-  while (Digits>0) do
+  if (spaces=0) then
+   begin
+     result:=inttobin(value,digits);
+     exit;
+   end;
+  endpos:=digits+ (digits-1) div spaces;
+  setlength(result,endpos);
+  p:=@result[endpos];
+  p2:=@result[1];
+  k:=spaces;
+  while (p>=p2) do
     begin
     begin
-    if (Digits mod Spaces)=0 then
-      Result:=Result+' ';
-    Dec(Digits);
-    Result:=Result+intToStr((Value shr Digits) and 1);
+      if k=0 then
+       begin
+         p^:=' ';
+         dec(p);
+         k:=spaces;
+       end;
+      p^:=chr(48+(cardinal(value) and 1));
+      value:=cardinal(value) shr 1;
+      dec(p); 
+      dec(k);
+   end;
+end;
+
+function intToBin(Value: Longint; Digits:integer): string;
+var p,p2 : pchar;
+begin
+  result:='';
+  if digits<=0 then exit;
+  setlength(result,digits);
+  p:=pchar(pointer(@result[digits]));
+  p2:=pchar(pointer(@result[1]));
+  // typecasts because we want to keep intto* delphi compat and take an integer
+  while (p>=p2) and (cardinal(value)>0) do     
+    begin
+       p^:=chr(48+(cardinal(value) and 1));
+       value:=cardinal(value) shr 1;
+       dec(p); 
+    end;
+  digits:=p-p2+1;
+  if digits>0 then
+    fillchar(result[1],digits,#48);
+end;
+
+function intToBin(Value: int64; Digits:integer): string;
+var p,p2 : pchar;
+begin
+  result:='';
+  if digits<=0 then exit;
+  setlength(result,digits);
+  p:=pchar(pointer(@result[digits]));
+  p2:=pchar(pointer(@result[1]));
+  // typecasts because we want to keep intto* delphi compat and take a signed val
+  // and avoid warnings
+  while (p>=p2) and (qword(value)>0) do     
+    begin
+       p^:=chr(48+(cardinal(value) and 1));
+       value:=qword(value) shr 1;
+       dec(p); 
     end;
     end;
+  digits:=p-p2+1;
+  if digits>0 then
+    fillchar(result[1],digits,#48);
 end;
 end;
 
 
+
 function FindPart(const HelpWilds, inputStr: string): Integer;
 function FindPart(const HelpWilds, inputStr: string): Integer;
 var
 var
   i, J: Integer;
   i, J: Integer;
@@ -1644,7 +1725,7 @@ function possetex (const c:TSysCharSet;const s : ansistring;count:Integer ):Inte
 var i,j:Integer;
 var i,j:Integer;
 
 
 begin
 begin
- if pchar(s)=nil then
+ if pchar(pointer(s))=nil then
   j:=0
   j:=0
  else
  else
   begin
   begin

+ 7 - 1
rtl/objpas/sysconst.pp

@@ -43,7 +43,7 @@ resourcestring
   SErrInvalidTimeStamp   = 'Invalid date/timestamp : "%s"';
   SErrInvalidTimeStamp   = 'Invalid date/timestamp : "%s"';
   SExceptionErrorMessage = 'exception at %p';
   SExceptionErrorMessage = 'exception at %p';
   SExceptionStack        = 'Exception stack error';
   SExceptionStack        = 'Exception stack error';
-  SExecuteProcessFailed  = 'Failed to execute %s : %d';
+  SExecuteProcessFailed  = 'Failed to execute "%s", error code: %d';
   SExternalException     = 'External exception %x';
   SExternalException     = 'External exception %x';
   SFileNotAssigned       = 'File not assigned';
   SFileNotAssigned       = 'File not assigned';
   SFileNotFound          = 'File not found';
   SFileNotFound          = 'File not found';
@@ -114,6 +114,12 @@ resourcestring
 
 
   SNoToolserver                 = 'Toolserver is not installed, cannot execute Tool';
   SNoToolserver                 = 'Toolserver is not installed, cannot execute Tool';
 
 
+  SNoArrayMatch                 = 'Can''t match any allowed value at pattern position %d, string position %d.';
+  SNoCharMatch                  = 'Mismatch char "%s" <> "%s" at pattern position %d, string position %d.';
+  SHHMMError                    = 'mm in a sequence hh:mm is interpreted as minutes. No longer versions allowed! (Position : %d).' ;
+  SFullpattern                  = 'Couldn''t match entire pattern string. Input too short at pattern position %d.';
+  SPatternCharMismatch          = 'Pattern mismatch char "%s" at position %d.';
+
   SShortMonthNameJan = 'Jan';
   SShortMonthNameJan = 'Jan';
   SShortMonthNameFeb = 'Feb';
   SShortMonthNameFeb = 'Feb';
   SShortMonthNameMar = 'Mar';
   SShortMonthNameMar = 'Mar';

+ 46 - 40
rtl/objpas/sysutils/dati.inc

@@ -441,7 +441,7 @@ end ;
 
 
 function StrToTime(const s: string): TDateTime;
 function StrToTime(const s: string): TDateTime;
 var
 var
-   Len, Current: integer; PM: boolean;
+   Len, Current: integer; PM: integer;
 
 
    function GetElement: integer;
    function GetElement: integer;
    var
    var
@@ -449,21 +449,26 @@ var
    begin
    begin
    result := -1;
    result := -1;
    Inc(Current);
    Inc(Current);
-   while (result = -1) and (Current < Len) do begin
-      if S[Current] in ['0'..'9'] then begin
-         j := Current;
-         while (Current < Len) and (s[Current + 1] in ['0'..'9']) do
-            Inc(Current);
-         val(copy(S, j, 1 + Current - j), result, c);
-         end
-      else if ((TimeAMString<>'') and (S[Current] = TimeAMString[1])) or (S[Current] in ['a', 'A']) then begin
-         Current := 1 + Len;
-         end
-      else if ((TimePMString<>'') and (S[Current] = TimePMString[1])) or (S[Current] in ['p', 'P']) then begin
-         Current := 1 + Len;
-         PM := True;
+   while (result = -1) and (Current < Len) do 
+     begin
+       if S[Current] in ['0'..'9'] then 
+          begin
+            j := Current;
+            while (Current < Len) and (s[Current + 1] in ['0'..'9']) do
+              Inc(Current);
+            val(copy(S, j, 1 + Current - j), result, c);
+          end
+       else if ((TimeAMString<>'') and (S[Current] = TimeAMString[1])) or (S[Current] in ['a', 'A']) then 
+          begin
+            pm:=1;
+            Current := 1 + Len;
+          end
+       else if ((TimePMString<>'') and (S[Current] = TimePMString[1])) or (S[Current] in ['p', 'P']) then 
+         begin
+           Current := 1 + Len;
+           PM := 2;
          end
          end
-      else if (S[Current] = TimeSeparator) or (S[Current] = ' ') then
+       else if (S[Current] = TimeSeparator) or (S[Current] = ' ') then
          Inc(Current)
          Inc(Current)
       else
       else
         raise EConvertError.Create('Invalid Time format');
         raise EConvertError.Create('Invalid Time format');
@@ -475,30 +480,31 @@ var
    TimeValues: array[0..4] of integer;
    TimeValues: array[0..4] of integer;
 
 
 begin
 begin
-Current := 0;
-Len := length(s);
-PM := False;
-for i:=0 to 4 do
-  timevalues[i]:=0;
-i := 0;
-TimeValues[i] := GetElement;
-while (i < 5) and (TimeValues[i] <> -1) do begin
-   i := i + 1;
-   TimeValues[i] := GetElement;
+  Current := 0;
+  Len := length(s);
+  PM := 0;
+  for i:=0 to 4 do
+    timevalues[i]:=0;
+  i := 0;
+  TimeValues[i] := GetElement;
+  while (i < 5) and (TimeValues[i] <> -1) do 
+    begin
+     i := i + 1;
+     TimeValues[i] := GetElement;
    end ;
    end ;
-If (i<5) and (TimeValues[I]=-1) then
-  TimeValues[I]:=0;
-if PM then
-  begin
-  if (TimeValues[0] <> 12) then
-    Inc(TimeValues[0], 12);
-  end
-else
-  begin
-  if (TimeValues[0]=12) then
-    TimeValues[0]:=0;
-  end;
-result := EncodeTime(TimeValues[0], TimeValues[1], TimeValues[2], TimeValues[3]);
+  If (i<5) and (TimeValues[I]=-1) then
+    TimeValues[I]:=0;
+  if PM=2 then
+    begin
+     if (TimeValues[0] <> 12) then
+       Inc(TimeValues[0], 12);
+    end
+  else
+    begin
+      if (pm=1) and ((TimeValues[0]=12)) then
+        TimeValues[0]:=0;
+    end;
+  result := EncodeTime(TimeValues[0], TimeValues[1], TimeValues[2], TimeValues[3]);
 end ;
 end ;
 
 
 {   StrToDateTime converts the string S to a TDateTime value
 {   StrToDateTime converts the string S to a TDateTime value
@@ -534,7 +540,7 @@ var
    var Len: integer;
    var Len: integer;
    begin
    begin
    Len := Length(Str);
    Len := Length(Str);
-   if ResultLen + Len < SizeOf(ResultBuffer) then begin
+   if ResultLen + Len < SizeOf(ResultBuffer) then begin // strmove not safe
       StrMove(ResultCurrent, pchar(Str), Len);
       StrMove(ResultCurrent, pchar(Str), Len);
       ResultCurrent := ResultCurrent + Len;
       ResultCurrent := ResultCurrent + Len;
       ResultLen := ResultLen + Len;
       ResultLen := ResultLen + Len;
@@ -578,7 +584,7 @@ var
       tmp:integer;
       tmp:integer;
 
 
    begin
    begin
-   FormatCurrent := Pchar(FormatStr);
+   FormatCurrent := Pchar(pointer(FormatStr));
    FormatEnd := FormatCurrent + Length(FormatStr);
    FormatEnd := FormatCurrent + Length(FormatStr);
    Clock12 := false;
    Clock12 := false;
    P := FormatCurrent;
    P := FormatCurrent;

+ 16 - 14
rtl/objpas/sysutils/sysstr.inc

@@ -72,8 +72,9 @@ Var
 
 
 begin
 begin
   Result := S;
   Result := S;
+  if not assigned(pointer(result)) then exit;
   UniqueString(Result);
   UniqueString(Result);
-  P:=Pchar(Result);
+  P:=Pchar(pointer(Result));
   for i := 1 to Length(Result) do
   for i := 1 to Length(Result) do
     begin
     begin
     if (P^ in ['a'..'z']) then P^ := char(byte(p^) - 32);
     if (P^ in ['a'..'z']) then P^ := char(byte(p^) - 32);
@@ -92,8 +93,9 @@ Var
 
 
 begin
 begin
   Result := S;
   Result := S;
+  if not assigned(pointer(result)) then exit;
   UniqueString(Result);
   UniqueString(Result);
-  P:=Pchar(Result);
+  P:=Pchar(pointer(Result));
   for i := 1 to Length(Result) do
   for i := 1 to Length(Result) do
     begin
     begin
     if (P^ in ['A'..'Z']) then P^ := char(byte(p^) + 32);
     if (P^ in ['A'..'Z']) then P^ := char(byte(p^) + 32);
@@ -418,7 +420,7 @@ function AnsiLastChar(const S: string): PChar;
 
 
 begin
 begin
   //!! No multibyte yet, so we return the last one.
   //!! No multibyte yet, so we return the last one.
-  result:=StrEnd(Pchar(S));
+  result:=StrEnd(Pchar(pointer(S)));  // strend checks for nil
   Dec(Result);
   Dec(Result);
 end ;
 end ;
 
 
@@ -970,8 +972,8 @@ end;
 
 
 Function StrToFloat(Const S : String; Const FormatSettings: TFormatSettings) : Extended;
 Function StrToFloat(Const S : String; Const FormatSettings: TFormatSettings) : Extended;
 
 
-Begin
-  If Not TextToFloat(Pchar(S),Result,FormatSettings) then
+Begin // texttofloat handles NIL properly
+  If Not TextToFloat(Pchar(pointer(S)),Result,FormatSettings) then
     Raise EConvertError.createfmt(SInValidFLoat,[S]);
     Raise EConvertError.createfmt(SInValidFLoat,[S]);
 End;
 End;
 
 
@@ -984,7 +986,7 @@ end;
 Function StrToFloatDef(Const S: String; Const Default: Extended; Const FormatSettings: TFormatSettings): Extended;
 Function StrToFloatDef(Const S: String; Const Default: Extended; Const FormatSettings: TFormatSettings): Extended;
 
 
 begin
 begin
-   if not TextToFloat(PChar(S),Result,fvExtended,FormatSettings) then
+   if not TextToFloat(PChar(pointer(S)),Result,fvExtended,FormatSettings) then
      Result:=Default;
      Result:=Default;
 end;
 end;
 
 
@@ -1068,7 +1070,7 @@ end;
 
 
 Function TryStrToFloat(Const S : String; Var Value: Single; Const FormatSettings: TFormatSettings): Boolean;
 Function TryStrToFloat(Const S : String; Var Value: Single; Const FormatSettings: TFormatSettings): Boolean;
 Begin
 Begin
-  Result := TextToFloat(PChar(S), Value, fvSingle,FormatSettings);
+  Result := TextToFloat(PChar(pointer(S)), Value, fvSingle,FormatSettings);
 End;
 End;
 
 
 Function TryStrToFloat(Const S : String; Var Value: Double): Boolean;
 Function TryStrToFloat(Const S : String; Var Value: Double): Boolean;
@@ -1079,7 +1081,7 @@ end;
 
 
 Function TryStrToFloat(Const S : String; Var Value: Double; Const FormatSettings: TFormatSettings): Boolean;
 Function TryStrToFloat(Const S : String; Var Value: Double; Const FormatSettings: TFormatSettings): Boolean;
 Begin
 Begin
-  Result := TextToFloat(PChar(S), Value, fvDouble,FormatSettings);
+  Result := TextToFloat(PChar(pointer(S)), Value, fvDouble,FormatSettings);
 End;
 End;
 
 
 {$ifdef FPC_HAS_TYPE_EXTENDED}
 {$ifdef FPC_HAS_TYPE_EXTENDED}
@@ -1091,7 +1093,7 @@ end;
 
 
 Function TryStrToFloat(Const S : String; Var Value: Extended; Const FormatSettings: TFormatSettings): Boolean;
 Function TryStrToFloat(Const S : String; Var Value: Extended; Const FormatSettings: TFormatSettings): Boolean;
 Begin
 Begin
-  Result := TextToFloat(PChar(S), Value,FormatSettings);
+  Result := TextToFloat(PChar(pointer(S)), Value,FormatSettings);
 End;
 End;
 {$endif FPC_HAS_TYPE_EXTENDED}
 {$endif FPC_HAS_TYPE_EXTENDED}
 
 
@@ -1617,7 +1619,7 @@ function AnsiDequotedStr(const S: string; AQuote: Char): string;
 var p : pchar;
 var p : pchar;
 
 
 begin
 begin
-  p:=pchar(s); // work around CONST
+  p:=pchar(pointer(s)); // work around CONST. Ansiextract is safe for nil
   result:=AnsiExtractquotedStr(p,AQuote);
   result:=AnsiExtractquotedStr(p,AQuote);
   if result='' Then
   if result='' Then
     result:=s;
     result:=s;
@@ -1625,20 +1627,20 @@ end;
 
 
 function StrToCurr(const S: string): Currency;
 function StrToCurr(const S: string): Currency;
 begin
 begin
-  if not TextToFloat(PChar(S), Result, fvCurrency) then
+  if not TextToFloat(PChar(pointer(S)), Result, fvCurrency) then
     Raise EConvertError.createfmt(SInValidFLoat,[S]);
     Raise EConvertError.createfmt(SInValidFLoat,[S]);
 end;
 end;
 
 
 
 
 Function TryStrToCurr(Const S : String; Var Value: Currency): Boolean;
 Function TryStrToCurr(Const S : String; Var Value: Currency): Boolean;
 Begin
 Begin
-  Result := TextToFloat(PChar(S), Value, fvCurrency);
+  Result := TextToFloat(PChar(pointer(S)), Value, fvCurrency);
 End;
 End;
 
 
 
 
 function StrToCurrDef(const S: string; Default : Currency): Currency;
 function StrToCurrDef(const S: string; Default : Currency): Currency;
 begin
 begin
-  if not TextToFloat(PChar(S), Result, fvCurrency) then
+  if not TextToFloat(PChar(pointer(S)), Result, fvCurrency) then
     Result:=Default;
     Result:=Default;
 end;
 end;
 
 
@@ -2318,7 +2320,7 @@ Function FormatFloat(Const Format : String; Value : Extended; Const FormatSettin
 Var
 Var
   buf : Array[0..1024] of char;
   buf : Array[0..1024] of char;
 
 
-Begin
+Begin // not changed to pchar(pointer(). Possibly not safe
   Buf[FloatToTextFmt(@Buf[0],Value,Pchar(Format),FormatSettings)]:=#0;
   Buf[FloatToTextFmt(@Buf[0],Value,Pchar(Format),FormatSettings)]:=#0;
   Result:=StrPas(@Buf[0]);
   Result:=StrPas(@Buf[0]);
 End;
 End;

+ 24 - 22
rtl/objpas/sysutils/sysutils.inc

@@ -229,22 +229,24 @@ Procedure CatchUnhandledException (Obj : TObject; Addr: Pointer; FrameCount: Lon
 Var
 Var
   Message : String;
   Message : String;
   i : longint;
   i : longint;
+  hstdout : ^text;
 begin
 begin
-  Writeln(stdout,'An unhandled exception occurred at $',HexStr(Ptrint(Addr),sizeof(PtrInt)*2),' :');
+  hstdout:=@stdout;
+  Writeln(hstdout^,'An unhandled exception occurred at $',HexStr(Ptrint(Addr),sizeof(PtrInt)*2),' :');
   if Obj is exception then
   if Obj is exception then
    begin
    begin
      Message:=Exception(Obj).ClassName+' : '+Exception(Obj).Message;
      Message:=Exception(Obj).ClassName+' : '+Exception(Obj).Message;
-     Writeln(stdout,Message);
+     Writeln(hstdout^,Message);
    end
    end
   else
   else
-   Writeln(stdout,'Exception object ',Obj.ClassName,' is not of class Exception.');
-  Writeln(stdout,BackTraceStrFunc(Addr));
+   Writeln(hstdout^,'Exception object ',Obj.ClassName,' is not of class Exception.');
+  Writeln(hstdout^,BackTraceStrFunc(Addr));
   if (FrameCount>0) then
   if (FrameCount>0) then
     begin
     begin
       for i:=0 to FrameCount-1 do
       for i:=0 to FrameCount-1 do
-        Writeln(stdout,BackTraceStrFunc(Frames[i]));
+        Writeln(hstdout^,BackTraceStrFunc(Frames[i]));
     end;
     end;
-  Writeln(stdout,'');
+  Writeln(hstdout^,'');
 end;
 end;
 
 
 
 
@@ -255,7 +257,7 @@ Var OutOfMemory : EOutOfMemory;
 Procedure RunErrorToExcept (ErrNo : Longint; Address,Frame : Pointer);
 Procedure RunErrorToExcept (ErrNo : Longint; Address,Frame : Pointer);
 
 
 Var E : Exception;
 Var E : Exception;
-    S : String;
+    HS : PString;
 
 
 begin
 begin
   Case Errno of
   Case Errno of
@@ -264,21 +266,21 @@ begin
    2,3,4,5,6,100,101,102,103,105,106 : { I/O errors }
    2,3,4,5,6,100,101,102,103,105,106 : { I/O errors }
      begin
      begin
      Case Errno of
      Case Errno of
-       2 : S:=SFileNotFound;
-       3 : S:=SInvalidFileName;
-       4 : S:=STooManyOpenFiles;
-       5 : S:=SAccessDenied;
-       6 : S:=SInvalidFileHandle;
-       15 : S:=SInvalidDrive;
-       100 : S:=SEndOfFile;
-       101 : S:=SDiskFull;
-       102 : S:=SFileNotAssigned;
-       103 : S:=SFileNotOpen;
-       104 : S:=SFileNotOpenForInput;
-       105 : S:=SFileNotOpenForOutput;
-       106 : S:=SInvalidInput;
+       2 : HS:=@SFileNotFound;
+       3 : HS:=@SInvalidFileName;
+       4 : HS:=@STooManyOpenFiles;
+       5 : HS:=@SAccessDenied;
+       6 : HS:=@SInvalidFileHandle;
+       15 : HS:=@SInvalidDrive;
+       100 : HS:=@SEndOfFile;
+       101 : HS:=@SDiskFull;
+       102 : HS:=@SFileNotAssigned;
+       103 : HS:=@SFileNotOpen;
+       104 : HS:=@SFileNotOpenForInput;
+       105 : HS:=@SFileNotOpenForOutput;
+       106 : HS:=@SInvalidInput;
      end;
      end;
-     E:=EinOutError.Create (S);
+     E:=EinOutError.Create (HS^);
      EInoutError(E).ErrorCode:=IOresult; // Clears InOutRes !!
      EInoutError(E).ErrorCode:=IOresult; // Clears InOutRes !!
      end;
      end;
   // We don't set abstracterrorhandler, but we do it here.
   // We don't set abstracterrorhandler, but we do it here.
@@ -344,7 +346,7 @@ begin
     S:=SAssertionFailed
     S:=SAssertionFailed
   else
   else
     S:=Msg;
     S:=Msg;
-  Raise EAssertionFailed.Createfmt(SAssertError,[S,Fn,LineNo]); // at Pointer(theAddr);
+  Raise EAssertionFailed.Createfmt(SAssertError,[S,Fn,LineNo]) at Pointer(theAddr);
 end;
 end;
 
 
 {$ifdef STACKCHECK_WAS_ON}
 {$ifdef STACKCHECK_WAS_ON}

+ 1 - 0
rtl/openbsd/ptypes.inc

@@ -31,6 +31,7 @@ type
     gid_t    = cuint32;         { used for group IDs           }
     gid_t    = cuint32;         { used for group IDs           }
     TGid     = gid_t;
     TGid     = gid_t;
     pGid     = ^gid_t;
     pGid     = ^gid_t;
+    TIOCtlRequest = cuLong;
 
 
     ino_t    = clong;           { used for file serial numbers }
     ino_t    = clong;           { used for file serial numbers }
     TIno     = ino_t;
     TIno     = ino_t;

+ 110 - 105
rtl/os2/Makefile

@@ -250,160 +250,160 @@ endif
 OBJPASDIR=$(RTL)/objpas
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph
 GRAPHDIR=$(INC)/graph
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil so32dll sockets
+override TARGET_UNITS+=$(SYSTEMUNIT) ctypes objpas macpas strings ports os2def doscalls moncalls kbdcalls moucalls viocalls pmbitmap pmwin pmgpi pmstddlg pmhelp pmdev pmspl pmshl pmwp pmwsock pmbidi dos crt objects printer matrix sysutils fgl classes math typinfo varutils winsock charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs video mouse keyboard variants types rtlconst sysconst dateutil strutils convutil stdconvs fmtbcd so32dll sockets
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_LOADERS+=prt0
 override TARGET_LOADERS+=prt0
@@ -562,160 +562,160 @@ ifeq ($(FULL_TARGET),powerpc64-embedded)
 override TARGET_LOADERS+=prt0
 override TARGET_LOADERS+=prt0
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil
+override TARGET_RSTS+=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 endif
 endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
@@ -2378,6 +2378,11 @@ convutil$(PPUEXT) : $(OBJPASDIR)/convutil.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUE
 	$(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/convutil.pp
 	$(COMPILER) -Fi$(OBJPASDIR) $(OBJPASDIR)/convutil.pp
 strutils$(PPUEXT) : $(OBJPASDIR)/strutils.pp sysutils$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 strutils$(PPUEXT) : $(OBJPASDIR)/strutils.pp sysutils$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(OBJPASDIR)/strutils.pp
 	$(COMPILER) $(OBJPASDIR)/strutils.pp
+stdconvs$(PPUEXT) : $(OBJPASDIR)/stdconvs.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
+		    sysutils$(PPUEXT)
+	$(COMPILER) $(OBJPASDIR)/stdconvs.pp
+fmtbcd$(PPUEXT) : $(OBJPASDIR)/fmtbcd.pp objpas$(PPUEXT) sysutils$(PPUEXT) variants$(PPUEXT) classes$(PPUEXT) system$(PPUEXT)
+	$(COMPILER) $(OBJPASDIR)/fmtbcd.pp
 macpas$(PPUEXT) : $(INC)/macpas.pp $(SYSTEMUNIT)$(PPUEXT)
 macpas$(PPUEXT) : $(INC)/macpas.pp $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(INC)/macpas.pp $(REDIR)
 	$(COMPILER) $(INC)/macpas.pp $(REDIR)
 ucomplex$(PPUEXT): $(INC)/ucomplex.pp math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 ucomplex$(PPUEXT): $(INC)/ucomplex.pp math$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
@@ -2386,7 +2391,7 @@ mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
 getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) -Sg $(INC)/heaptrc.pp
 	$(COMPILER) -Sg $(INC)/heaptrc.pp
- lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT)
+lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT)
 lnfodwrf$(PPUEXT) : $(INC)/lnfodwrf.pp $(SYSTEMUNIT)$(PPUEXT)
 lnfodwrf$(PPUEXT) : $(INC)/lnfodwrf.pp $(SYSTEMUNIT)$(PPUEXT)
 charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT)
 charset$(PPUEXT) : $(INC)/charset.pp $(SYSTEMUNIT)$(PPUEXT)
 ctypes$(PPUEXT) :  $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
 ctypes$(PPUEXT) :  $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)

+ 10 - 3
rtl/os2/Makefile.fpc

@@ -14,8 +14,8 @@ units=$(SYSTEMUNIT) ctypes objpas macpas strings \
       sysutils fgl classes math typinfo varutils winsock \
       sysutils fgl classes math typinfo varutils winsock \
       charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs \
       charset ucomplex cpu mmx getopts heaptrc lineinfo lnfodwrf dynlibs \
       video mouse keyboard variants types rtlconst sysconst dateutil \
       video mouse keyboard variants types rtlconst sysconst dateutil \
-      strutils convutil so32dll sockets
-rsts=math varutils typinfo variants pmhelp classes sysconst dateutil
+      strutils convutil stdconvs fmtbcd so32dll sockets
+rsts=math varutils typinfo variants pmhelp classes sysconst dateutil stdconvs
 
 
 [require]
 [require]
 nortl=y
 nortl=y
@@ -205,6 +205,13 @@ convutil$(PPUEXT) : $(OBJPASDIR)/convutil.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUE
 strutils$(PPUEXT) : $(OBJPASDIR)/strutils.pp sysutils$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 strutils$(PPUEXT) : $(OBJPASDIR)/strutils.pp sysutils$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $(OBJPASDIR)/strutils.pp
         $(COMPILER) $(OBJPASDIR)/strutils.pp
 
 
+stdconvs$(PPUEXT) : $(OBJPASDIR)/stdconvs.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) \
+                    sysutils$(PPUEXT)
+        $(COMPILER) $(OBJPASDIR)/stdconvs.pp
+
+fmtbcd$(PPUEXT) : $(OBJPASDIR)/fmtbcd.pp objpas$(PPUEXT) sysutils$(PPUEXT) variants$(PPUEXT) classes$(PPUEXT) system$(PPUEXT)
+        $(COMPILER) $(OBJPASDIR)/fmtbcd.pp
+
 #
 #
 # Mac Pascal Model
 # Mac Pascal Model
 #
 #
@@ -227,7 +234,7 @@ getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMUNIT)$(PPUEXT)
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
 heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) -Sg $(INC)/heaptrc.pp
         $(COMPILER) -Sg $(INC)/heaptrc.pp
 
 
- lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT)
+lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMUNIT)$(PPUEXT)
 
 
 lnfodwrf$(PPUEXT) : $(INC)/lnfodwrf.pp $(SYSTEMUNIT)$(PPUEXT)
 lnfodwrf$(PPUEXT) : $(INC)/lnfodwrf.pp $(SYSTEMUNIT)$(PPUEXT)
 
 

+ 58 - 43
rtl/os2/crt.pas

@@ -131,49 +131,6 @@ external 'DOSCALLS' index 286;
 
 
 
 
 
 
-threadvar
-  ExtKeyCode: char;
-
-
-
-function KeyPressed: boolean;
-{Checks if a key is pressed.}
-var
- AKeyRec: TKbdKeyinfo;
-begin
- if ExtKeyCode <> #0 then
-  KeyPressed := true
- else
-  KeyPressed := (KbdPeek (AKeyRec, 0) = 0)
-                                         and ((AKeyRec.fbStatus and $40) <> 0);
-end;
-
-
-function ReadKey: char;
-{Reads the next character from the keyboard.}
-var
- AKeyRec: TKbdKeyInfo;
- C, S: char;
-begin
- if ExtKeyCode <> #0 then
-  begin
-   ReadKey := ExtKeyCode;
-   ExtKeyCode := #0
-  end
- else
-  begin
-   KbdCharIn (AKeyRec, 0, 0);
-   C := AKeyRec.CharCode;
-   S := AKeyRec.ScanCode;
-   if (C = #224) and (S <> #0) then
-    C := #0;
-   if C = #0 then
-    ExtKeyCode := S;
-   ReadKey := C;
-  end;
-end;
-
-
 procedure GetScreenCursor (var X, Y: dword);inline;
 procedure GetScreenCursor (var X, Y: dword);inline;
 (* Return current cursor postion - 0-based. *)
 (* Return current cursor postion - 0-based. *)
 var
 var
@@ -329,6 +286,64 @@ end;
 {$I crt.inc}
 {$I crt.inc}
 
 
 
 
+function KeyPressed: boolean;
+{Checks if a key is pressed.}
+var
+ AKeyRec: TKbdKeyinfo;
+begin
+ if SpecialKey or (ScanCode <> 0) then
+  KeyPressed := true
+ else
+  KeyPressed := (KbdPeek (AKeyRec, 0) = 0)
+                                         and ((AKeyRec.fbStatus and $40) <> 0);
+end;
+
+
+function ReadKey: char;
+{Reads the next character from the keyboard.}
+var
+ AKeyRec: TKbdKeyInfo;
+ C, S: char;
+begin
+ if SpecialKey then
+  begin
+   SpecialKey := false;
+   ReadKey := char (ScanCode);
+   ScanCode := 0;
+  end
+ else
+  if ScanCode <> 0 then
+   begin
+    ReadKey := char (ScanCode);
+    ScanCode := 0;
+   end
+  else
+   begin
+    while ((KbdCharIn (AKeyRec, 1, 0) <> 0)
+                    or (AKeyRec.fbStatus and $41 <> $40)) and (ScanCode = 0) do
+     DosSleep (5);
+    if ScanCode = 0 then
+     begin
+      C := AKeyRec.CharCode;
+      S := AKeyRec.ScanCode;
+      if (C = #224) and (S <> #0) then
+       C := #0;
+      if C = #0 then
+       begin
+        SpecialKey := true;
+        ScanCode := byte (S);
+       end;
+      ReadKey := C;
+     end
+    else
+     begin
+      ReadKey := char (ScanCode);
+      ScanCode := 0;
+     end;
+   end;
+end;
+
+
 {Initialization.}
 {Initialization.}
 
 
 var
 var

+ 60 - 50
rtl/os2/doscalls.pas

@@ -2338,56 +2338,66 @@ function DosSetProcessCP (CP: cardinal): cardinal; cdecl;
 
 
 
 
 {Exception constants.}
 {Exception constants.}
-const       XCPT_Continue_Search            = $00000000;
-            XCPT_Continue_Execution         = $ffffffff;
-            XCPT_Continue_Stop              = $00716668;
-
-            XCPT_Signal_Intr                = $1;
-            XCPT_Signal_KillProc            = $3;
-            XCPT_Signal_Break               = $4;
-
-            XCPT_Fatal_Exception            = $c0000000;
-            XCPT_Severity_Code              = $c0000000;
-            XCPT_Customer_Code              = $20000000;
-            XCPT_Facility_Code              = $1fff0000;
-            XCPT_Exception_Code             = $0000ffff;
-
-            XCPT_Unknown_Access             = $00000000;
-            XCPT_Read_Access                = $00000001;
-            XCPT_Write_Access               = $00000002;
-            XCPT_Execute_Access             = $00000004;
-            XCPT_Space_Access               = $00000008;
-            XCPT_Limit_Access               = $00000010;
-            XCPT_Data_Unknown               = $ffffffff;
-
-            XCPT_Guard_Page_Violation       = $80000001;
-            XCPT_Unable_To_Grow_Stack       = $80010001;
-            XCPT_Access_Violation           = $c0000005;
-            XCPT_In_Page_Error              = $c0000006;
-            XCPT_Illegal_Instruction        = $c000001c;
-            XCPT_Invalid_Lock_Sequence      = $c000001d;
-            XCPT_Noncontinuable_Exception   = $c0000024;
-            XCPT_Invalid_Disposition        = $c0000025;
-            XCPT_Unwind                     = $c0000026;
-            XCPT_Bad_Stack                  = $c0000027;
-            XCPT_Invalid_Unwind_Target      = $c0000028;
-            XCPT_Array_Bounds_Exceeded      = $c0000093;
-            XCPT_Float_Denormal_Operand     = $c0000094;
-            XCPT_Float_Divide_By_Zero       = $c0000095;
-            XCPT_Float_Inexact_Result       = $c0000096;
-            XCPT_Float_Invalid_Operation    = $c0000097;
-            XCPT_Float_Overflow             = $c0000098;
-            XCPT_Float_Stack_Check          = $c0000099;
-            XCPT_Float_Underflow            = $c000009a;
-            XCPT_Integer_Divide_By_Zero     = $c000009b;
-            XCPT_Integer_Overflow           = $c000009c;
-            XCPT_Privileged_Instruction     = $c000009d;
-            XCPT_Datatype_Misalignment      = $c000009e;
-            XCPT_Breakpoint                 = $c000009f;
-            XCPT_Single_Step                = $c00000a0;
-            XCPT_Process_Terminate          = $c0010001;
-            XCPT_Async_Process_Terminate    = $c0010002;
-            XCPT_Signal                     = $c0010003;
+const
+  Xcpt_Continue_Search            = $00000000;
+  Xcpt_Continue_Execution         = $ffffffff;
+  Xcpt_Continue_Stop              = $00716668;
+
+  Xcpt_Signal_Intr                = $1;
+  Xcpt_Signal_KillProc            = $3;
+  Xcpt_Signal_Break               = $4;
+
+  Xcpt_Fatal_Exception            = $c0000000;
+  Xcpt_Severity_Code              = $c0000000;
+  Xcpt_Customer_Code              = $20000000;
+  Xcpt_Facility_Code              = $1fff0000;
+  Xcpt_Exception_Code             = $0000ffff;
+
+  Xcpt_Unknown_Access             = $00000000;
+  Xcpt_Read_Access                = $00000001;
+  Xcpt_Write_Access               = $00000002;
+  Xcpt_Execute_Access             = $00000004;
+  Xcpt_Space_Access               = $00000008;
+  Xcpt_Limit_Access               = $00000010;
+  Xcpt_Data_Unknown               = $ffffffff;
+
+  Xcpt_Guard_Page_Violation       = $80000001;
+  Xcpt_Unable_To_Grow_Stack       = $80010001;
+  Xcpt_Access_Violation           = $c0000005;
+  Xcpt_In_Page_Error              = $c0000006;
+  Xcpt_Illegal_Instruction        = $c000001c;
+  Xcpt_Invalid_Lock_Sequence      = $c000001d;
+  Xcpt_Noncontinuable_Exception   = $c0000024;
+  Xcpt_Invalid_Disposition        = $c0000025;
+  Xcpt_Unwind                     = $c0000026;
+  Xcpt_Bad_Stack                  = $c0000027;
+  Xcpt_Invalid_Unwind_Target      = $c0000028;
+  Xcpt_Array_Bounds_Exceeded      = $c0000093;
+  Xcpt_Float_Denormal_Operand     = $c0000094;
+  Xcpt_Float_Divide_By_Zero       = $c0000095;
+  Xcpt_Float_Inexact_Result       = $c0000096;
+  Xcpt_Float_Invalid_Operation    = $c0000097;
+  Xcpt_Float_Overflow             = $c0000098;
+  Xcpt_Float_Stack_Check          = $c0000099;
+  Xcpt_Float_Underflow            = $c000009a;
+  Xcpt_Integer_Divide_By_Zero     = $c000009b;
+  Xcpt_Integer_Overflow           = $c000009c;
+  Xcpt_Privileged_Instruction     = $c000009d;
+  Xcpt_Datatype_Misalignment      = $c000009e;
+  Xcpt_Breakpoint                 = $c000009f;
+  Xcpt_Single_Step                = $c00000a0;
+  Xcpt_Process_Terminate          = $c0010001;
+  Xcpt_Async_Process_Terminate    = $c0010002;
+  Xcpt_Signal                     = $c0010003;
+
+  Context_Control        = $00000001; { SS:ESP, CS:EIP, EFLAGS and EBP set }
+  Context_Integer        = $00000002; { EAX, EBX, ECX, EDX, ESI and EDI set }
+  Context_Segments       = $00000004; { DS, ES, FS, and GS set }
+  Context_Floating_Point = $00000008; { numeric coprocessor state set }
+  Context_Full           = Context_Control or
+                           Context_Integer or
+                           Context_Segments or
+                           Context_Floating_Point;
 
 
 const
 const
     MaxExceptionParameters = 4;  { Enough for all system exceptions. }
     MaxExceptionParameters = 4;  { Enough for all system exceptions. }

+ 3 - 2
rtl/os2/keyboard.pp

@@ -63,8 +63,8 @@ var
  K: TKbdKeyInfo;
  K: TKbdKeyInfo;
 begin
 begin
   KbdGetFocus (IO_Wait, Handle);
   KbdGetFocus (IO_Wait, Handle);
-  while (KbdCharIn (K, IO_Wait, Handle) <> No_Error)
-        or (K.fbStatus and $40 = 0) do
+  while (KbdCharIn (K, IO_NoWait, Handle) <> No_Error)
+        or (K.fbStatus and $41 <> $40) do
     DosSleep (5);
     DosSleep (5);
   with K do
   with K do
     begin
     begin
@@ -125,4 +125,5 @@ Const
 
 
 begin
 begin
   SetKeyBoardDriver(SysKeyBoardDriver);
   SetKeyBoardDriver(SysKeyBoardDriver);
+  SetKbdCtrlBreakHandler;
 end.
 end.

+ 9 - 0
rtl/os2/prt0.as

@@ -12,6 +12,7 @@
         .globl  __init
         .globl  __init
         .globl  __dos_init
         .globl  __dos_init
         .globl  __dos_syscall
         .globl  __dos_syscall
+        .comm _excptregptr, 4
 
 
         .text
         .text
 
 
@@ -27,8 +28,16 @@ ___SYSCALL:
         .space  6, 0x90
         .space  6, 0x90
 
 
 __init: cld
 __init: cld
+        pushl %eax
+        pushl %eax
+        pushl %eax
+        movl %esp,%eax
+        addl $4,%eax
+        movl %eax, _excptregptr
+        popl %eax
 
 
         call    _main
         call    _main
+
         movb    $0x4c,%ah
         movb    $0x4c,%ah
         call    ___SYSCALL
         call    ___SYSCALL
 2:      jmp     2b
 2:      jmp     2b

+ 1 - 0
rtl/os2/sockets.pas

@@ -29,6 +29,7 @@ Const
   AF_LOCAL       = so32dll.AF_LOCAL;
   AF_LOCAL       = so32dll.AF_LOCAL;
   AF_UNIX        = so32dll.AF_UNIX;
   AF_UNIX        = so32dll.AF_UNIX;
   AF_OS2         = so32dll.AF_OS2;
   AF_OS2         = so32dll.AF_OS2;
+  AF_INET        = so32dll.AF_INET;
   AF_IMPLINK     = so32dll.AF_IMPLINK;     // arpanet imp addresses
   AF_IMPLINK     = so32dll.AF_IMPLINK;     // arpanet imp addresses
   AF_PUP         = so32dll.AF_PUP;         // pup protocols: e.g. BSP
   AF_PUP         = so32dll.AF_PUP;         // pup protocols: e.g. BSP
   AF_CHAOS       = so32dll.AF_CHAOS;       // mit CHAOS protocols
   AF_CHAOS       = so32dll.AF_CHAOS;       // mit CHAOS protocols

+ 220 - 161
rtl/os2/sysos.inc

@@ -15,6 +15,42 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
+type
+  TByteArray = array [0..$FFFF] of byte;
+  PByteArray = ^TByteArray;
+
+  TSysThreadIB = record
+    TID,
+    Priority,
+    Version: cardinal;
+    MCCount,
+    MCForceFlag: word;
+  end;
+  PSysThreadIB = ^TSysThreadIB;
+
+  TThreadInfoBlock = record
+    PExChain,
+    Stack,
+    StackLimit: pointer;
+    TIB2: PSysThreadIB;
+    Version,
+    Ordinal: cardinal;
+  end;
+  PThreadInfoBlock = ^TThreadInfoBlock;
+  PPThreadInfoBlock = ^PThreadInfoBlock;
+
+  TProcessInfoBlock = record
+    PID,
+    ParentPid,
+    Handle: cardinal;
+    Cmd,
+    Env: PByteArray;
+    Status,
+    ProcType: cardinal;
+  end;
+  PProcessInfoBlock = ^TProcessInfoBlock;
+  PPProcessInfoBlock = ^PProcessInfoBlock;
+
 var
 var
   ProcessID: SizeUInt;
   ProcessID: SizeUInt;
 
 
@@ -194,166 +230,189 @@ const
    end;
    end;
 
 
 
 
-{$IFDEF OS2EXCEPTIONS}
-(*
-The operating system defines a class of error conditions called exceptions, and specifies the default actions that are taken when these exceptions occur. The system default action in most cases is to terminate the thread that caused the exception.
-
-Exception values have the following 32-bit format:
-
- 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
- 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-ÚÄÄÄÂÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
-³Sev³C³       Facility          ³               Code            ³
-ÀÄÄÄÁÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Sev Severity code. Possible values are described in the following list:
-
-00 Success
-01 Informational
-10 Warning
-11 Error
-
-C Customer code flag.
-
-Facility Facility code.
-
-Code Facility's status code.
-
-Exceptions that are specific to OS/2 Version 2.X (for example, XCPT_SIGNAL)
-have a facility code of 1.
-
-System exceptions include both synchronous and asynchronous exceptions.
-Synchronous exceptions are caused by events that are internal to a thread's
-execution. For example, synchronous exceptions could be caused by invalid
-parameters, or by a thread's request to end its own execution.
-
-Asynchronous exceptions are caused by events that are external to a thread's
-execution. For example, an asynchronous exception can be caused by a user's
-entering a Ctrl+C or Ctrl+Break key sequence, or by a process' issuing
-DosKillProcess to end the execution of another process.
-
-The Ctrl+Break and Ctrl+C exceptions are also known as signals, or as signal
-exceptions.
-
-The following tables show the symbolic names of system exceptions, their
-numerical values, and related information fields.
-
-Portable, Non-Fatal, Software-Generated Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_GUARD_PAGE_VIOLATION            ³0x80000001³
-³  ExceptionInfo[0] - R/W flag        ³          ³
-³  ExceptionInfo[1] - FaultAddr       ³          ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_UNABLE_TO_GROW_STACK            ³0x80010001³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Portable, Fatal, Hardware-Generated Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³Related Trap ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_ACCESS_VIOLATION                ³0xC0000005³0x09, 0x0B,  ³
-³  ExceptionInfo[0] - Flags           ³          ³0x0C, 0x0D,  ³
-³    XCPT_UNKNOWN_ACCESS  0x0         ³          ³0x0E         ³
-³    XCPT_READ_ACCESS     0x1         ³          ³             ³
-³    XCPT_WRITE_ACCESS    0x2         ³          ³             ³
-³    XCPT_EXECUTE_ACCESS  0x4         ³          ³             ³
-³    XCPT_SPACE_ACCESS    0x8         ³          ³             ³
-³    XCPT_LIMIT_ACCESS    0x10        ³          ³             ³
-³  ExceptionInfo[1] - FaultAddr       ³          ³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INTEGER_DIVIDE_BY_ZERO          ³0xC000009B³0            ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_DIVIDE_BY_ZERO            ³0xC0000095³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_INVALID_OPERATION         ³0xC0000097³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_ILLEGAL_INSTRUCTION             ³0xC000001C³0x06         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_PRIVILEGED_INSTRUCTION          ³0xC000009D³0x0D         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INTEGER_OVERFLOW                ³0xC000009C³0x04         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_OVERFLOW                  ³0xC0000098³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_UNDERFLOW                 ³0xC000009A³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_DENORMAL_OPERAND          ³0xC0000094³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_INEXACT_RESULT            ³0xC0000096³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_FLOAT_STACK_CHECK               ³0xC0000099³0x10         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_DATATYPE_MISALIGNMENT           ³0xC000009E³0x11         ³
-³  ExceptionInfo[0] - R/W flag        ³          ³             ³
-³  ExceptionInfo[1] - Alignment       ³          ³             ³
-³  ExceptionInfo[2] - FaultAddr       ³          ³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_BREAKPOINT                      ³0xC000009F³0x03         ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_SINGLE_STEP                     ³0xC00000A0³0x01         ³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Portable, Fatal, Software-Generated Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³Related Trap ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_IN_PAGE_ERROR                   ³0xC0000006³0x0E         ³
-³  ExceptionInfo[0] - FaultAddr       ³          ³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_PROCESS_TERMINATE               ³0xC0010001³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_ASYNC_PROCESS_TERMINATE         ³0xC0010002³             ³
-³  ExceptionInfo[0] - TID of          ³          ³             ³
-³      terminating thread             ³          ³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_NONCONTINUABLE_EXCEPTION        ³0xC0000024³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INVALID_DISPOSITION             ³0xC0000025³             ³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Non-Portable, Fatal Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³Related Trap ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INVALID_LOCK_SEQUENCE           ³0xC000001D³             ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_ARRAY_BOUNDS_EXCEEDED           ³0xC0000093³0x05         ³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Unwind Operation Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_UNWIND                          ³0xC0000026³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_BAD_STACK                       ³0xC0000027³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_INVALID_UNWIND_TARGET           ³0xC0000028³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
-
-
-Fatal Signal Exceptions
-
-ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
-³Exception Name                       ³Value     ³
-ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
-³XCPT_SIGNAL                          ³0xC0010003³
-³  ExceptionInfo[ 0 ] - Signal        ³          ³
-³      Number                         ³          ³
-ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
-*)
-{$ENDIF OS2EXCEPTIONS}
+(* Types and constants for exception handler support *)
+const
+  deHardErr           = 1;    {Pop-ups for hard errors are enabled, to disable
+                               do not give this switch.}
+  deDisableExceptions = 2;    {Pop-ups for exceptions are disabled, to enable
+                               do not give this switch.}
+  MaxExceptionParameters = 4; {Enough for all system exceptions.}
+
+  Xcpt_Continue_Search            = $00000000;
+  Xcpt_Continue_Execution         = $ffffffff;
+  Xcpt_Continue_Stop              = $00716668;
+
+  Xcpt_Signal_Intr                = 1;
+  Xcpt_Signal_KillProc            = 3;
+  Xcpt_Signal_Break               = 4;
+
+  Xcpt_Fatal_Exception            = $c0000000;
+  Xcpt_Severity_Code              = $c0000000;
+  Xcpt_Customer_Code              = $20000000;
+  Xcpt_Facility_Code              = $1fff0000;
+  Xcpt_Exception_Code             = $0000ffff;
+
+  Xcpt_Unknown_Access             = $00000000;
+  Xcpt_Read_Access                = $00000001;
+  Xcpt_Write_Access               = $00000002;
+  Xcpt_Execute_Access             = $00000004;
+  Xcpt_Space_Access               = $00000008;
+  Xcpt_Limit_Access               = $00000010;
+  Xcpt_Data_Unknown               = $ffffffff;
+
+  Xcpt_Guard_Page_Violation       = $80000001;
+  Xcpt_Unable_To_Grow_Stack       = $80010001;
+  Xcpt_Access_Violation           = $c0000005;
+  Xcpt_In_Page_Error              = $c0000006;
+  Xcpt_Illegal_Instruction        = $c000001c;
+  Xcpt_Invalid_Lock_Sequence      = $c000001d;
+  Xcpt_Noncontinuable_Exception   = $c0000024;
+  Xcpt_Invalid_Disposition        = $c0000025;
+  Xcpt_Unwind                     = $c0000026;
+  Xcpt_Bad_Stack                  = $c0000027;
+  Xcpt_Invalid_Unwind_Target      = $c0000028;
+  Xcpt_Array_Bounds_Exceeded      = $c0000093;
+  Xcpt_Float_Denormal_Operand     = $c0000094;
+  Xcpt_Float_Divide_By_Zero       = $c0000095;
+  Xcpt_Float_Inexact_Result       = $c0000096;
+  Xcpt_Float_Invalid_Operation    = $c0000097;
+  Xcpt_Float_Overflow             = $c0000098;
+  Xcpt_Float_Stack_Check          = $c0000099;
+  Xcpt_Float_Underflow            = $c000009a;
+  Xcpt_Integer_Divide_By_Zero     = $c000009b;
+  Xcpt_Integer_Overflow           = $c000009c;
+  Xcpt_Privileged_Instruction     = $c000009d;
+  Xcpt_Datatype_Misalignment      = $c000009e;
+  Xcpt_Breakpoint                 = $c000009f;
+  Xcpt_Single_Step                = $c00000a0;
+  Xcpt_Process_Terminate          = $c0010001;
+  Xcpt_Async_Process_Terminate    = $c0010002;
+  Xcpt_Signal                     = $c0010003;
+
+  Context_Control        = $00000001; { SS:ESP, CS:EIP, EFLAGS and EBP set }
+  Context_Integer        = $00000002; { EAX, EBX, ECX, EDX, ESI and EDI set }
+  Context_Segments       = $00000004; { DS, ES, FS, and GS set }
+  Context_Floating_Point = $00000008; { numeric coprocessor state set }
+  Context_Full           = Context_Control or
+                           Context_Integer or
+                           Context_Segments or
+                           Context_Floating_Point;
+
+type
+  PExceptionRegistrationRecord = ^TExceptionRegistrationRecord;
+  PExceptionReportRecord = ^TExceptionReportRecord;
+  PContextRecord = ^TContextRecord;
+
+  TExceptionHandler = function (Report: PExceptionReportRecord;
+                                RegRec: PExceptionRegistrationRecord;
+                                Context: PContextRecord;
+                                DispContext: pointer): cardinal; cdecl;
+
+  TExceptionRegistrationRecord = record
+    Prev_Structure: PExceptionRegistrationRecord;
+    ExceptionHandler: TExceptionHandler;
+  end;
+
+  TExceptionReportRecord = record
+    Exception_Num,
+    HandlerFlags: cardinal;
+    Nested_RepRec: PExceptionReportRecord;
+    Address: pointer;
+    ParamCount: cardinal;
+    Parameters: array [0..MaxExceptionParameters] of cardinal;
+  end;
+
+  TContextRecord = packed record
+    ContextFlags: cardinal;
+    Env: array [1..7] of cardinal;
+    FPUStack: array [0..7] of extended;
+    Reg_GS,
+    Reg_FS,
+    Reg_ES,
+    Reg_DS,
+    Reg_EDI,
+    Reg_ESI,
+    Reg_EAX,
+    Reg_EBX,
+    Reg_ECX,
+    Reg_EDX,
+    Reg_EBP,
+    Reg_EIP,
+    Reg_CS,
+    Flags,
+    Reg_ESP,
+    Reg_SS: cardinal;
+  end;
 
 
 
 
+function DosSetExceptionHandler (var RegRec: TExceptionRegistrationRecord):
+                                                               cardinal; cdecl;
+external 'DOSCALLS' index 354;
+
+function DosUnsetExceptionHandler (var RegRec: TExceptionRegistrationRecord):
+                                                               cardinal; cdecl;
+external 'DOSCALLS' index 355;
+
+{Full screen applications can get Ctrl-C and Ctrl-Break focus. For all
+ processes sharing one screen, only one can have Ctrl-C focus.
+ Enable     = 0 = Release focus, 1 = Get focus.
+ Times      = Number of times focus has been get minus number of times it
+              has been released.}
+function DosSetSignalExceptionFocus (Enable: cardinal;
+                                         var Times: cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 378;
+
+{Tell we want further signal exceptions.
+ SignalNum  = Signal number to acknowlegde.}
+function DosAcknowledgeSignalException (SignalNum: cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 418;
+
+function DosError (Error: cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 212;
+
+
+type
+  TWinMessageBox = function (Parent, Owner: cardinal;
+         BoxText, BoxTitle: PChar; Identity, Style: cardinal): cardinal; cdecl;
+  TWinInitialize = function (Options: cardinal): cardinal; cdecl;
+  TWinCreateMsgQueue = function (Handle: cardinal; cmsg: longint): cardinal;
+                                                                         cdecl;
+
+const
+  ErrorBufferLength = 1024;
+  mb_OK = $0000;
+  mb_Error = $0040;
+  mb_Moveable = $4000;
+  MBStyle = mb_OK or mb_Error or mb_Moveable;
+
+  mfPag_Read      = $00001;   {Give read access to memory.}
+  mfPag_Write     = $00002;   {Give write access to memory.}
+  mfPag_Execute   = $00004;   {Allow code execution in memory.}
+  mfPag_Guard     = $00008;   {Used for dynamic memory growing. Create
+                               uncommitted memory and make the first
+                               page guarded. Once it is accessed it
+                               will be made committed, and the next
+                               uncommitted page will be made guarded.}
+  mfPag_Commit    = $00010;   {Make the memory committed.}
+  mfPag_Decommit  = $00020;   {Decommit the page.}
+  mfObj_Tile      = $00040;   {Also allocate 16-bit segments of 64k
+                               which map the memory. (Makes 16<>32 bit
+                               pointer conversion possible.}
+  mfObj_Protected = $00080;
+  mfObj_Gettable  = $00100;
+  mfObj_Giveable  = $00200;
+  mfObj_Any       = $00400;   {Allow using high memory (> 512 MB).}
+  mfPag_Default   = $00400;
+  mfPag_Shared    = $02000;
+  mfPag_Free      = $04000;
+  mfPag_Base      = $10000;
+
+  mfSub_Init      = $00001;   {Use base, if not set, choose a base
+                               address yourself.}
+  mfSub_Grow      = $00002;   {Grow the specified heap, instead of
+                               allocating it. Ignore mfSub_Init.}
+  mfSub_Sparse    = $00004;
+  mfSub_Serialize = $00008;
+
+function DosQueryMem (P: pointer; var Size, Flag: cardinal): cardinal; cdecl;
+external 'DOSCALLS' index 306;

+ 460 - 77
rtl/os2/system.pas

@@ -26,20 +26,10 @@ interface
   {.$define DEBUGARGUMENTS}
   {.$define DEBUGARGUMENTS}
 {$endif SYSTEMDEBUG}
 {$endif SYSTEMDEBUG}
 
 
-{ $DEFINE OS2EXCEPTIONS}
+{$DEFINE OS2EXCEPTIONS}
 
 
 {$I systemh.inc}
 {$I systemh.inc}
 
 
-{$IFDEF OS2EXCEPTIONS}
-(* Types and constants for exception handler support *)
-type
-{x}   PEXCEPTION_FRAME = ^TEXCEPTION_FRAME;
-{x}   TEXCEPTION_FRAME = record
-{x}     next : PEXCEPTION_FRAME;
-{x}     handler : pointer;
-{x}   end;
-
-{$ENDIF OS2EXCEPTIONS}
 
 
 const
 const
   LineEnding = #13#10;
   LineEnding = #13#10;
@@ -54,47 +44,8 @@ const
   
   
 type    Tos=(osDOS,osOS2,osDPMI);
 type    Tos=(osDOS,osOS2,osDPMI);
 
 
-const   os_mode: Tos = osOS2;
-        first_meg: pointer = nil;
-
-{$IFDEF OS2EXCEPTIONS}
-{x}  System_exception_frame : PEXCEPTION_FRAME =nil;
-{$ENDIF OS2EXCEPTIONS}
-
-type    TByteArray = array [0..$ffff] of byte;
-        PByteArray = ^TByteArray;
-
-        TSysThreadIB = record
-            TID,
-            Priority,
-            Version: cardinal;
-            MCCount,
-            MCForceFlag: word;
-        end;
-        PSysThreadIB = ^TSysThreadIB;
-
-        TThreadInfoBlock = record
-            PExChain,
-            Stack,
-            StackLimit: pointer;
-            TIB2: PSysThreadIB;
-            Version,
-            Ordinal: cardinal;
-        end;
-        PThreadInfoBlock = ^TThreadInfoBlock;
-        PPThreadInfoBlock = ^PThreadInfoBlock;
-
-        TProcessInfoBlock = record
-            PID,
-            ParentPid,
-            Handle: cardinal;
-            Cmd,
-            Env: PByteArray;
-            Status,
-            ProcType: cardinal;
-        end;
-        PProcessInfoBlock = ^TProcessInfoBlock;
-        PPProcessInfoBlock = ^PProcessInfoBlock;
+const   OS_Mode: Tos = osOS2;
+        First_Meg: pointer = nil;
 
 
 const   UnusedHandle=-1;
 const   UnusedHandle=-1;
         StdInputHandle=0;
         StdInputHandle=0;
@@ -185,23 +136,431 @@ const
 
 
 implementation
 implementation
 
 
-{$I system.inc}
 
 
+{*****************************************************************************
 
 
-{****************************************************************************
+                        System unit initialization.
 
 
-                    Miscellaneous related routines.
+****************************************************************************}
+
+{$I system.inc}
+
+{*****************************************************************************
+
+                           Exception handling.
 
 
 ****************************************************************************}
 ****************************************************************************}
 
 
+{$IFDEF OS2EXCEPTIONS}
+var
+  { value of the stack segment
+    to check if the call stack can be written on exceptions }
+  _SS : Cardinal;
+
+function Is_Prefetch (P: pointer): boolean;
+  var
+    A: array [0..15] of byte;
+    DoAgain: boolean;
+    InstrLo, InstrHi, OpCode: byte;
+    I: longint;
+    MemSize, MemAttrs: cardinal;
+  begin
+    Is_Prefetch := false;
+
+    MemSize := SizeOf (A);
+    DosQueryMem (P, MemSize, MemAttrs);
+    if (MemAttrs and (mfPag_Free or mfPag_Commit) <> 0)
+                                               and (MemSize >= SizeOf (A)) then
+     Move (P^, A [0], SizeOf (A))
+    else
+     Exit;
+    I := 0;
+    DoAgain := true;
+    while DoAgain and (I < 15) do
+      begin
+        OpCode := A [I];
+        InstrLo := OpCode and $f;
+        InstrHi := OpCode and $f0;
+        case InstrHi of
+          { prefix? }
+          $20, $30:
+            DoAgain := (InstrLo and 7) = 6;
+          $60:
+            DoAgain := (InstrLo and $c) = 4;
+          $f0:
+            DoAgain := InstrLo in [0, 2, 3];
+          $0:
+            begin
+              Is_Prefetch := (InstrLo = $f) and (A [I + 1] in [$D, $18]);
+              Exit;
+            end;
+          else
+            DoAgain := false;
+        end;
+        Inc (I);
+      end;
+  end;
+
+const
+  MaxExceptionLevel = 16;
+  ExceptLevel: byte = 0;
+
+var
+  ExceptEIP: array [0..MaxExceptionLevel - 1] of longint;
+  ExceptError: array [0..MaxExceptionLevel - 1] of byte;
+  ResetFPU: array [0..MaxExceptionLevel - 1] of boolean;
+
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+procedure DebugHandleErrorAddrFrame (Error: longint; Addr, Frame: pointer);
+begin
+ if IsConsole then
+  begin
+   Write (StdErr, ' HandleErrorAddrFrame (error = ', Error);
+   Write (StdErr, ', addr = ', hexstr (PtrUInt (Addr), 8));
+   WriteLn (StdErr, ', frame = ', hexstr (PtrUInt (Frame), 8), ')');
+  end;
+ HandleErrorAddrFrame (Error, Addr, Frame);
+end;
+{$endif SYSTEMEXCEPTIONDEBUG}
+
+procedure JumpToHandleErrorFrame;
+var
+ EIP, EBP, Error: longint;
+begin
+ (* save ebp *)
+ asm
+  movl (%ebp),%eax
+  movl %eax,ebp
+ end;
+ if (ExceptLevel > 0) then
+  Dec (ExceptLevel);
+ EIP := ExceptEIP [ExceptLevel];
+ Error := ExceptError [ExceptLevel];
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+ if IsConsole then
+  WriteLn (StdErr, 'In JumpToHandleErrorFrame error = ', Error);
+{$endif SYSTEMEXCEPTIONDEBUG}
+ if ResetFPU [ExceptLevel] then
+  SysResetFPU;
+ { build a fake stack }
+ asm
+{$ifdef REGCALL}
+  movl   ebp,%ecx
+  movl   eip,%edx
+  movl   error,%eax
+  pushl  eip
+  movl   ebp,%ebp // Change frame pointer
+{$else}
+  movl   ebp,%eax
+  pushl  %eax
+  movl   eip,%eax
+  pushl  %eax
+  movl   error,%eax
+  pushl  %eax
+  movl   eip,%eax
+  pushl  %eax
+  movl   ebp,%ebp // Change frame pointer
+{$endif}
+
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+  jmpl   DebugHandleErrorAddrFrame
+{$else not SYSTEMEXCEPTIONDEBUG}
+  jmpl   HandleErrorAddrFrame
+{$endif SYSTEMEXCEPTIONDEBUG}
+ end;
+end;
+
+
+function System_Exception_Handler (Report: PExceptionReportRecord;
+                                   RegRec: PExceptionRegistrationRecord;
+                                   Context: PContextRecord;
+                                   DispContext: pointer): cardinal; cdecl;
+var
+ Res: cardinal;
+ Err: byte;
+ Must_Reset_FPU: boolean;
+{$IFDEF SYSTEMEXCEPTIONDEBUG}
+ CurSS: cardinal;
+ B: byte;
+{$ENDIF SYSTEMEXCEPTIONDEBUG}
+begin
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+ if IsConsole then
+  begin
+    asm
+      xorl %eax,%eax
+      movw %ss,%ax
+      movl %eax,CurSS
+    end;
+    WriteLn (StdErr, 'In System_Exception_Handler, error = ',
+                                            HexStr (Report^.Exception_Num, 8));
+    WriteLn (StdErr, 'Context SS = ', HexStr (Context^.Reg_SS, 8),
+                                         ', current SS = ', HexStr (CurSS, 8));
+  end;
+{$endif SYSTEMEXCEPTIONDEBUG}
+ Res := Xcpt_Continue_Search;
+ if Context^.Reg_SS = _SS then
+  begin
+   Err := 0;
+   Must_Reset_FPU := true;
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+   if IsConsole then
+    Writeln (StdErr, 'Exception  ', HexStr (Report^.Exception_Num, 8));
+{$endif SYSTEMEXCEPTIONDEBUG}
+   case Report^.Exception_Num of
+    Xcpt_Integer_Divide_By_Zero,
+    Xcpt_Float_Divide_By_Zero:
+      Err := 200;
+    Xcpt_Array_Bounds_Exceeded:
+     begin
+      Err := 201;
+      Must_Reset_FPU := false;
+     end;
+    Xcpt_Unable_To_Grow_Stack:
+     begin
+      Err := 202;
+      Must_Reset_FPU := false;
+     end;
+    Xcpt_Float_Overflow:
+     Err := 205;
+    Xcpt_Float_Denormal_Operand,
+    Xcpt_Float_Underflow:
+     Err := 206;
+    {Context^.FloatSave.StatusWord := Context^.FloatSave.StatusWord and $ffffff00;}
+    Xcpt_Float_Inexact_Result,
+    Xcpt_Float_Invalid_Operation,
+    Xcpt_Float_Stack_Check:
+     Err := 207;
+    Xcpt_Integer_Overflow:
+     begin
+      Err := 215;
+      Must_Reset_FPU := false;
+     end;
+    Xcpt_Illegal_Instruction:
+          { if we're testing sse support, simply set the flag and continue }
+     if SSE_Check then
+      begin
+       OS_Supports_SSE := false;
+          { skip the offending movaps %xmm7, %xmm6 instruction }
+       Inc (Context^.Reg_EIP, 3);
+       Report^.Exception_Num := 0;
+       Res := Xcpt_Continue_Execution;
+      end
+     else
+      Err := 216;
+    Xcpt_Access_Violation:
+     { Athlon prefetch bug? }
+     if Is_Prefetch (pointer (Context^.Reg_EIP)) then
+      begin
+       { if yes, then retry }
+       Report^.Exception_Num := 0;
+       Res := Xcpt_Continue_Execution;
+      end
+     else
+      Err := 216;
+    Xcpt_Signal:
+     case Report^.Parameters [0] of
+      Xcpt_Signal_KillProc:
+       Err := 217;
+      Xcpt_Signal_Break,
+      Xcpt_Signal_Intr:
+       if Assigned (CtrlBreakHandler) then
+        if CtrlBreakHandler (Report^.Parameters [0] = Xcpt_Signal_Break) then
+         begin
+{$IFDEF SYSTEMEXCEPTIONDEBUG}
+          WriteLn (StdErr, 'CtrlBreakHandler returned true');
+{$ENDIF SYSTEMEXCEPTIONDEBUG}
+          Report^.Exception_Num := 0;
+          Res := Xcpt_Continue_Execution;
+          DosAcknowledgeSignalException (Report^.Parameters [0]);
+         end
+        else
+         Err := 217;
+     end;
+    Xcpt_Privileged_Instruction:
+     begin
+      Err := 218;
+      Must_Reset_FPU := false;
+     end;
+    else
+     begin
+      if ((Report^.Exception_Num and Xcpt_Severity_Code)
+                                                   = Xcpt_Fatal_Exception) then
+       Err := 217
+      else
+       Err := 255;
+     end;
+   end;
+
+   if (Err <> 0) and (ExceptLevel < MaxExceptionLevel) then
+    begin
+     ExceptEIP [ExceptLevel] := Context^.Reg_EIP;
+     ExceptError [ExceptLevel] := Err;
+     ResetFPU [ExceptLevel] := Must_Reset_FPU;
+     Inc (ExceptLevel);
+
+     Context^.Reg_EIP := cardinal (@JumpToHandleErrorFrame);
+     Report^.Exception_Num := 0;
+
+     Res := Xcpt_Continue_Execution;
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+     if IsConsole then
+      begin
+       WriteLn (StdErr, 'Exception Continue Exception set at ',
+                                          HexStr (ExceptEIP [ExceptLevel], 8));
+       WriteLn (StdErr, 'EIP changed to ',
+             HexStr (longint (@JumpToHandleErrorFrame), 8), ', error = ', Err);
+      end;
+{$endif SYSTEMEXCEPTIONDEBUG}
+    end;
+  end
+ else
+  if (Report^.Exception_Num = Xcpt_Signal) and
+    (Report^.Parameters [0] and (Xcpt_Signal_Intr or Xcpt_Signal_Break) <> 0)
+                                           and Assigned (CtrlBreakHandler) then
+{$IFDEF SYSTEMEXCEPTIONDEBUG}
+   begin
+    WriteLn (StdErr, 'XCPT_SIGNAL caught, CtrlBreakHandler assigned, Param = ',
+                                                       Report^.Parameters [0]);
+{$ENDIF SYSTEMEXCEPTIONDEBUG}
+   if CtrlBreakHandler (Report^.Parameters [0] = Xcpt_Signal_Break) then
+    begin
+{$IFDEF SYSTEMEXCEPTIONDEBUG}
+     WriteLn (StdErr, 'CtrlBreakHandler returned true');
+{$ENDIF SYSTEMEXCEPTIONDEBUG}
+     Report^.Exception_Num := 0;
+     Res := Xcpt_Continue_Execution;
+     DosAcknowledgeSignalException (Report^.Parameters [0]);
+    end
+   else
+    Err := 217;
+{$IFDEF SYSTEMEXCEPTIONDEBUG}
+   end
+  else
+   if IsConsole then
+    begin
+     WriteLn (StdErr, 'Ctx flags = ', HexStr (Context^.ContextFlags, 8));
+     if Context^.ContextFlags and Context_Floating_Point <> 0 then
+      begin
+       for B := 1 to 6 do
+        Write (StdErr, 'Ctx Env [', B, '] = ', HexStr (Context^.Env [B], 8),
+                                                                         ', ');
+        WriteLn (StdErr, 'Ctx Env [7] = ', HexStr (Context^.Env [7], 8));
+       for B := 0 to 6 do
+        Write (StdErr, 'FPU stack [', B, '] = ', Context^.FPUStack [B], ', ');
+       WriteLn (StdErr, 'FPU stack [7] = ', Context^.FPUStack [7]);
+      end;
+     if Context^.ContextFlags and Context_Segments <> 0 then
+      WriteLn (StdErr, 'GS = ', HexStr (Context^.Reg_GS, 8),
+                     ', FS = ', HexStr (Context^.Reg_FS, 8),
+                     ', ES = ', HexStr (Context^.Reg_ES, 8),
+                     ', DS = ', HexStr (Context^.Reg_DS, 8));
+     if Context^.ContextFlags and Context_Integer <> 0 then
+      begin
+       WriteLn (StdErr, 'EDI = ', HexStr (Context^.Reg_EDI, 8),
+                      ', ESI = ', HexStr (Context^.Reg_ESI, 8));
+       WriteLn (StdErr, 'EAX = ', HexStr (Context^.Reg_EAX, 8),
+                      ', EBX = ', HexStr (Context^.Reg_EBX, 8),
+                      ', ECX = ', HexStr (Context^.Reg_ECX, 8),
+                      ', EDX = ', HexStr (Context^.Reg_EDX, 8));
+      end;
+     if Context^.ContextFlags and Context_Control <> 0 then
+      begin
+       WriteLn (StdErr, 'EBP = ', HexStr (Context^.Reg_EBP, 8),
+                      ', SS = ', HexStr (Context^.Reg_SS, 8),
+                      ', ESP = ', HexStr (Context^.Reg_ESP, 8));
+       WriteLn (StdErr, 'CS = ', HexStr (Context^.Reg_CS, 8),
+                      ', EIP = ', HexStr (Context^.Reg_EIP, 8),
+                      ', EFlags = ', HexStr (Context^.Flags, 8));
+      end;
+    end;
+{$endif SYSTEMEXCEPTIONDEBUG}
+ System_Exception_Handler := Res;
+end;
+
+
+var
+  ExcptReg: PExceptionRegistrationRecord; public name '_excptregptr';
+
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+var
+ OldExceptAddr,
+ NewExceptAddr: PtrUInt;
+{$endif SYSTEMEXCEPTIONDEBUG}
+
+procedure Install_Exception_Handler;
+var
+ T: cardinal;
+begin
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+(* ThreadInfoBlock is located at FS:[0], the first      *)
+(* entry is pointer to head of exception handler chain. *)
+ asm
+  movl $0,%eax
+  movl %fs:(%eax),%eax
+  movl %eax, OldExceptAddr
+ end;
+{$endif SYSTEMEXCEPTIONDEBUG}
+ with ExcptReg^ do
+  begin
+   Prev_Structure := nil;
+   ExceptionHandler := TExceptionHandler (@System_Exception_Handler);
+  end;
+ (* Disable pop-up windows for errors and exceptions *)
+ DosError (deDisableExceptions);
+ DosSetExceptionHandler (ExcptReg^);
+ if IsConsole then
+  begin
+   DosSetSignalExceptionFocus (1, T);
+   DosAcknowledgeSignalException (Xcpt_Signal_Intr);
+   DosAcknowledgeSignalException (Xcpt_Signal_Break);
+  end;
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+ asm
+  movl $0,%eax
+  movl %fs:(%eax),%eax
+  movl %eax, NewExceptAddr
+ end;
+{$endif SYSTEMEXCEPTIONDEBUG}
+end;
+
+procedure Remove_Exception_Handlers;
+begin
+  DosUnsetExceptionHandler (ExcptReg^);
+end;
+{$ENDIF OS2EXCEPTIONS}
 
 
 procedure system_exit;
 procedure system_exit;
 begin
 begin
+(*  if IsLibrary then
+    ExitDLL(ExitCode);
+*)
+(*
+  if not IsConsole then
+   begin
+     Close(stderr);
+     Close(stdout);
+     Close(erroutput);
+     Close(Input);
+     Close(Output);
+   end;
+*)
+{$IFDEF OS2EXCEPTIONS}
+  Remove_Exception_Handlers;
+{$ENDIF OS2EXCEPTIONS}
   DosExit (1{process}, exitcode);
   DosExit (1{process}, exitcode);
 end;
 end;
 
 
 {$ASMMODE ATT}
 {$ASMMODE ATT}
 
 
+
+
+{****************************************************************************
+
+                    Miscellaneous related routines.
+
+****************************************************************************}
+
 function paramcount:longint;assembler;
 function paramcount:longint;assembler;
 asm
 asm
     movl argc,%eax
     movl argc,%eax
@@ -230,32 +589,13 @@ begin
   randseed:=dt.hour+(dt.minute shl 8)+(dt.second shl 16)+(dt.sec100 shl 32);
   randseed:=dt.hour+(dt.minute shl 8)+(dt.second shl 16)+(dt.sec100 shl 32);
 end;
 end;
 
 
-{$ASMMODE ATT}
 
 
 
 
-{*****************************************************************************
-
-                        System unit initialization.
-
-****************************************************************************}
-
 {****************************************************************************
 {****************************************************************************
                     Error Message writing using messageboxes
                     Error Message writing using messageboxes
 ****************************************************************************}
 ****************************************************************************}
 
 
-type
-  TWinMessageBox = function (Parent, Owner: cardinal;
-         BoxText, BoxTitle: PChar; Identity, Style: cardinal): cardinal; cdecl;
-  TWinInitialize = function (Options: cardinal): cardinal; cdecl;
-  TWinCreateMsgQueue = function (Handle: cardinal; cmsg: longint): cardinal;
-                                                                         cdecl;
-
 const
 const
-  ErrorBufferLength = 1024;
-  mb_OK = $0000;
-  mb_Error = $0040;
-  mb_Moveable = $4000;
-  MBStyle = mb_OK or mb_Error or mb_Moveable;
   WinInitialize: TWinInitialize = nil;
   WinInitialize: TWinInitialize = nil;
   WinCreateMsgQueue: TWinCreateMsgQueue = nil;
   WinCreateMsgQueue: TWinCreateMsgQueue = nil;
   WinMessageBox: TWinMessageBox = nil;
   WinMessageBox: TWinMessageBox = nil;
@@ -503,9 +843,10 @@ begin
   envp[env_count]:=nil;
   envp[env_count]:=nil;
 end;
 end;
 
 
+
 var
 var
 (* Initialized by system unit initialization *)
 (* Initialized by system unit initialization *)
-    PIB: PProcessInfoBlock;
+  PIB: PProcessInfoBlock;
 
 
 
 
 procedure InitArguments;
 procedure InitArguments;
@@ -736,14 +1077,43 @@ var TIB: PThreadInfoBlock;
 const
 const
     DosCallsName: array [0..8] of char = 'DOSCALLS'#0;
     DosCallsName: array [0..8] of char = 'DOSCALLS'#0;
 
 
+
+{*var}
+{* ST: pointer;}
+{*}
 begin
 begin
     IsLibrary := FALSE;
     IsLibrary := FALSE;
 
 
-    (* Initialize the amount of file handles *)
-    FileHandleCount := GetFileHandleCount;
+{$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
+     call SysResetFPU
+    end;
+{$ENDIF OS2EXCEPTIONS}
     DosGetInfoBlocks (@TIB, @PIB);
     DosGetInfoBlocks (@TIB, @PIB);
     StackBottom := TIB^.Stack;
     StackBottom := TIB^.Stack;
+{ $IFNDEF OS2EXCEPTIONS}
     StackTop := TIB^.StackLimit;
     StackTop := TIB^.StackLimit;
+{ $ENDIF OS2EXCEPTIONS}
     StackLength := CheckInitialStkLen (InitialStkLen);
     StackLength := CheckInitialStkLen (InitialStkLen);
 
 
     {Set type of application}
     {Set type of application}
@@ -754,6 +1124,13 @@ begin
 
 
     ExitProc := nil;
     ExitProc := nil;
 
 
+{$IFDEF OS2EXCEPTIONS}
+    Install_Exception_Handler;
+{$ENDIF OS2EXCEPTIONS}
+
+    (* Initialize the amount of file handles *)
+    FileHandleCount := GetFileHandleCount;
+
     {Initialize the heap.}
     {Initialize the heap.}
     (* Logic is following:
     (* Logic is following:
        The heap is initially restricted to low address space (< 512 MB).
        The heap is initially restricted to low address space (< 512 MB).
@@ -795,6 +1172,7 @@ begin
 
 
     { ... and exceptions }
     { ... and exceptions }
     SysInitExceptions;
     SysInitExceptions;
+    fpc_cpucodeinit;
 
 
     { ... and I/O }
     { ... and I/O }
     SysInitStdIO;
     SysInitStdIO;
@@ -821,4 +1199,9 @@ begin
 {$IFDEF EXTDUMPGROW}
 {$IFDEF EXTDUMPGROW}
 {    Int_HeapSize := high (cardinal);}
 {    Int_HeapSize := high (cardinal);}
 {$ENDIF EXTDUMPGROW}
 {$ENDIF EXTDUMPGROW}
+{$ifdef SYSTEMEXCEPTIONDEBUG}
+ if IsConsole then
+  WriteLn (StdErr, 'Old exception ', HexStr (OldExceptAddr, 8),
+   ', new exception ', HexStr (NewExceptAddr, 8), ', _SS = ', HexStr (_SS, 8));
+{$endif SYSTEMEXCEPTIONDEBUG}
 end.
 end.

+ 1 - 0
rtl/solaris/ptypes.inc

@@ -44,6 +44,7 @@ Type
     gid_t    = cuint32;         { used for group IDs           }
     gid_t    = cuint32;         { used for group IDs           }
     TGid     = gid_t;
     TGid     = gid_t;
     pGid     = ^gid_t;
     pGid     = ^gid_t;
+    TIOCtlRequest = cInt;
 
 
     ino_t    = clong;           { used for file serial numbers }
     ino_t    = clong;           { used for file serial numbers }
     TIno     = ino_t;
     TIno     = ino_t;

+ 1 - 0
rtl/unix/aliasptp.inc

@@ -23,6 +23,7 @@ type
     pDev     = UnixType.pDev;
     pDev     = UnixType.pDev;
     gid_t    = UnixType.gid_t;
     gid_t    = UnixType.gid_t;
     TGid     = UnixType.TGid;
     TGid     = UnixType.TGid;
+    TIOCtlRequest = UnixType.TIOCtlRequest;
     pGid     = UnixType.pGid;
     pGid     = UnixType.pGid;
     ino_t    = UnixType.ino_t;
     ino_t    = UnixType.ino_t;
     TIno     = UnixType.TIno;
     TIno     = UnixType.TIno;

+ 1 - 1
rtl/unix/bunxh.inc

@@ -90,7 +90,7 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
     Function  FpFtruncate  (fd : cInt; flength : TOff): cInt;  external name 'FPC_SYSC_FTRUNCATE';
     Function  FpFtruncate  (fd : cInt; flength : TOff): cInt;  external name 'FPC_SYSC_FTRUNCATE';
     Function  FPSigaction  (sig: cInt; act : pSigActionRec; oact : pSigActionRec): cint;  external name 'FPC_SYSC_SIGACTION';
     Function  FPSigaction  (sig: cInt; act : pSigActionRec; oact : pSigActionRec): cint;  external name 'FPC_SYSC_SIGACTION';
     Function  FPSelect     (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
     Function  FPSelect     (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
-    Function  FpIOCtl      (Handle:cint;Ndx: culong;Data: Pointer):cint; external name  'FPC_SYSC_IOCTL';
+    Function  FpIOCtl      (Handle:cint;Ndx: TIOCtlRequest; Data: Pointer):cint; external name  'FPC_SYSC_IOCTL';
     Function  FpNanoSleep  (req : ptimespec;rem : ptimespec):cint; external name 'FPC_SYSC_NANOSLEEP';
     Function  FpNanoSleep  (req : ptimespec;rem : ptimespec):cint; external name 'FPC_SYSC_NANOSLEEP';
     Function  fpLstat(path:pchar;Info:pstat):cint;
     Function  fpLstat(path:pchar;Info:pstat):cint;
     Function  fpLstat(Filename: ansistring;Info:pstat):cint;
     Function  fpLstat(Filename: ansistring;Info:pstat):cint;

+ 39 - 1
rtl/unix/cthreads.pp

@@ -36,6 +36,10 @@
 {$endif}
 {$endif}
 {$endif}
 {$endif}
 
 
+{$ifdef linux}
+{$define has_sem_timedwait}
+{$endif}
+
 unit cthreads;
 unit cthreads;
 interface
 interface
 {$S-}
 {$S-}
@@ -451,6 +455,22 @@ begin
 {$endif}
 {$endif}
 end;
 end;
 
 
+{$if defined(has_sem_timedwait)}
+
+function cSemaphoreTimedWait(const FSem: Pointer; const Timeout: ttimespec): cint;
+var
+  res: cint;
+  err: cint;
+begin
+  repeat
+    res:=sem_timedwait(PSemaphore(FSem), @Timeout);
+    if res=0 then exit(0);
+    err:=fpgetCerrno;
+  until err<>ESysEINTR;
+  result:=err;
+end;
+
+{$endif}
 
 
 procedure cSemaphorePost(const FSem: Pointer);
 procedure cSemaphorePost(const FSem: Pointer);
 {$if defined(has_sem_init) or defined(has_sem_open)}
 {$if defined(has_sem_init) or defined(has_sem_open)}
@@ -664,7 +684,7 @@ begin
   plocaleventstate(result)^.FWaiters:=0;
   plocaleventstate(result)^.FWaiters:=0;
   plocaleventstate(result)^.FDestroying:=False;
   plocaleventstate(result)^.FDestroying:=False;
 {$ifdef has_sem_init}
 {$ifdef has_sem_init}
-  plocaleventstate(result)^.FSem:=cIntSemaphoreInit(true);
+  plocaleventstate(result)^.FSem:=cIntSemaphoreInit(initialstate);
   if plocaleventstate(result)^.FSem=nil then
   if plocaleventstate(result)^.FSem=nil then
     begin
     begin
       FreeMem(result);
       FreeMem(result);
@@ -831,6 +851,23 @@ begin
     end
     end
   else
   else
     begin
     begin
+{$ifdef has_sem_timedwait}
+      fpgettimeofday(@timespec,nil);
+      inc(timespec.tv_nsec, (timeout mod 1000) * 1000000);
+      inc(timespec.tv_sec, timeout div 1000);
+      if timespec.tv_nsec > 1000000000 then
+      begin
+        dec(timespec.tv_nsec, 1000000000);
+        inc(timespec.tv_sec);
+      end;
+      nanores := cSemaphoreTimedWait(plocaleventstate(state)^.FSem, timespec);
+      if nanores = 0 then
+        result := wrSignaled
+      else if nanores = ESysETIMEDOUT then
+        result := wrTimeout
+      else
+        result := wrError;
+{$else}
       timespec.tv_sec:=0;
       timespec.tv_sec:=0;
       { 500 miliseconds or less -> wait once for this duration }
       { 500 miliseconds or less -> wait once for this duration }
       if (timeout <= 500) then
       if (timeout <= 500) then
@@ -901,6 +938,7 @@ begin
           if (result<>wrTimeOut) then
           if (result<>wrTimeOut) then
             break;
             break;
         end;
         end;
+{$endif}
     end;
     end;
   
   
   if (result=wrSignaled) then
   if (result=wrSignaled) then

+ 1 - 1
rtl/unix/oscdeclh.inc

@@ -74,7 +74,7 @@ const
     procedure FpExit    (status : cint); cdecl; external clib name '_exit';
     procedure FpExit    (status : cint); cdecl; external clib name '_exit';
     function  fpmmap    (addr:pointer;len:size_t;prot:cint;flags:cint;fd:cint;ofs:off_t):pointer; cdecl; external clib name 'mmap'+suffix64bit;
     function  fpmmap    (addr:pointer;len:size_t;prot:cint;flags:cint;fd:cint;ofs:off_t):pointer; cdecl; external clib name 'mmap'+suffix64bit;
     function  fpmunmap  (addr:pointer;len:size_t):cint; cdecl; external clib name 'munmap';
     function  fpmunmap  (addr:pointer;len:size_t):cint; cdecl; external clib name 'munmap';
-    function  FpIOCtl   (Handle:cint;Ndx: culong;Data: Pointer):cint; cdecl; external clib name 'ioctl';
+    function  FpIOCtl   (Handle:cint;Ndx: TIOCtlRequest;Data: Pointer):cint; cdecl; external clib name 'ioctl';
 {$ifdef beos}
 {$ifdef beos}
     Function  FPSelect  (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint; cdecl; external 'net' name 'select';
     Function  FPSelect  (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint; cdecl; external 'net' name 'select';
 {$else}
 {$else}

+ 17 - 17
rtl/unix/sysutils.pp

@@ -186,7 +186,7 @@ BEGIN
     1 : LinuxFlags:=LinuxFlags or O_WrOnly;
     1 : LinuxFlags:=LinuxFlags or O_WrOnly;
     2 : LinuxFlags:=LinuxFlags or O_RdWr;
     2 : LinuxFlags:=LinuxFlags or O_RdWr;
   end;
   end;
-  FileOpen:=fpOpen (FileName,LinuxFlags);
+  FileOpen:=fpOpen (pointer(FileName),LinuxFlags);
   //!! We need to set locking based on Mode !!
   //!! We need to set locking based on Mode !!
 end;
 end;
 
 
@@ -194,14 +194,14 @@ end;
 Function FileCreate (Const FileName : String) : Longint;
 Function FileCreate (Const FileName : String) : Longint;
 
 
 begin
 begin
-  FileCreate:=fpOpen(FileName,O_RdWr or O_Creat or O_Trunc);
+  FileCreate:=fpOpen(pointer(FileName),O_RdWr or O_Creat or O_Trunc);
 end;
 end;
 
 
 
 
 Function FileCreate (Const FileName : String;Mode : Longint) : Longint;
 Function FileCreate (Const FileName : String;Mode : Longint) : Longint;
 
 
 BEGIN
 BEGIN
-  FileCreate:=fpOpen(FileName,O_RdWr or O_Creat or O_Trunc,Mode);
+  FileCreate:=fpOpen(pointer(FileName),O_RdWr or O_Creat or O_Trunc,Mode);
 end;
 end;
 
 
 
 
@@ -264,7 +264,7 @@ Function FileAge (Const FileName : String): Longint;
 Var Info : Stat;
 Var Info : Stat;
 
 
 begin
 begin
-  If  fpstat (FileName,Info)<0 then
+  If  fpstat (pointer(FileName),Info)<0 then
     exit(-1)
     exit(-1)
   else
   else
     Result:=UnixToWinAge(info.st_mtime);
     Result:=UnixToWinAge(info.st_mtime);
@@ -276,7 +276,7 @@ Function FileExists (Const FileName : String) : Boolean;
 begin
 begin
   // Don't use stat. It fails on files >2 GB.
   // Don't use stat. It fails on files >2 GB.
   // Access obeys the same access rules, so the result should be the same.
   // Access obeys the same access rules, so the result should be the same.
-  FileExists:=fpAccess(filename,F_OK)=0;
+  FileExists:=fpAccess(pointer(filename),F_OK)=0;
 end;
 end;
 
 
 
 
@@ -285,7 +285,7 @@ Function DirectoryExists (Const Directory : String) : Boolean;
 Var Info : Stat;
 Var Info : Stat;
 
 
 begin
 begin
-  DirectoryExists:=(fpstat(Directory,Info)>=0) and fpS_ISDIR(Info.st_mode);
+  DirectoryExists:=(fpstat(pointer(Directory),Info)>=0) and fpS_ISDIR(Info.st_mode);
 end;
 end;
 
 
 
 
@@ -423,9 +423,9 @@ var
   WinAttr : longint;
   WinAttr : longint;
 begin
 begin
   FindGetFileInfo:=false;
   FindGetFileInfo:=false;
-  if not fpstat(s,st)>=0 then
+  if not fpstat(pointer(s),st)>=0 then
    exit;
    exit;
-  WinAttr:=LinuxToWinAttr(PChar(s),st);
+  WinAttr:=LinuxToWinAttr(PChar(pointer(s)),st);
   If (f.FindHandle = nil) or ((WinAttr and Not(PUnixFindData(f.FindHandle)^.searchattr))=0) Then
   If (f.FindHandle = nil) or ((WinAttr and Not(PUnixFindData(f.FindHandle)^.searchattr))=0) Then
    Begin
    Begin
      f.Name:=ExtractFileName(s);
      f.Name:=ExtractFileName(s);
@@ -464,7 +464,7 @@ Begin
         DirName:='./'
         DirName:='./'
       Else
       Else
         DirName:=Copy(UnixFindData^.SearchSpec,1,UnixFindData^.NamePos);
         DirName:=Copy(UnixFindData^.SearchSpec,1,UnixFindData^.NamePos);
-      UnixFindData^.DirPtr := fpopendir(Pchar(DirName));
+      UnixFindData^.DirPtr := fpopendir(Pchar(pointer(DirName)));
     end;
     end;
   SName:=Copy(UnixFindData^.SearchSpec,UnixFindData^.NamePos+1,Length(UnixFindData^.SearchSpec));
   SName:=Copy(UnixFindData^.SearchSpec,UnixFindData^.NamePos+1,Length(UnixFindData^.SearchSpec));
   Found:=False;
   Found:=False;
@@ -554,7 +554,7 @@ Function FileGetAttr (Const FileName : String) : Longint;
 Var Info : Stat;
 Var Info : Stat;
 
 
 begin
 begin
-  If  FpStat (FileName,Info)<0 then
+  If  FpStat (pointer(FileName),Info)<0 then
     Result:=-1
     Result:=-1
   Else
   Else
     Result:=LinuxToWinAttr(Pchar(ExtractFileName(FileName)),Info);
     Result:=LinuxToWinAttr(Pchar(ExtractFileName(FileName)),Info);
@@ -571,20 +571,20 @@ end;
 Function DeleteFile (Const FileName : String) : Boolean;
 Function DeleteFile (Const FileName : String) : Boolean;
 
 
 begin
 begin
-  Result:=fpUnLink (FileName)>=0;
+  Result:=fpUnLink (pointer(FileName))>=0;
 end;
 end;
 
 
 
 
 Function RenameFile (Const OldName, NewName : String) : Boolean;
 Function RenameFile (Const OldName, NewName : String) : Boolean;
 
 
 begin
 begin
-  RenameFile:=BaseUnix.FpRename(OldNAme,NewName)>=0;
+  RenameFile:=BaseUnix.FpRename(pointer(OldNAme),pointer(NewName))>=0;
 end;
 end;
 
 
 Function FileIsReadOnly(const FileName: String): Boolean;
 Function FileIsReadOnly(const FileName: String): Boolean;
 
 
 begin
 begin
-  Result := fpAccess(PChar(FileName),W_OK)<>0;
+  Result := fpAccess(PChar(pointer(FileName)),W_OK)<>0;
 end;
 end;
 
 
 Function FileSetDate (Const FileName : String;Age : Longint) : Longint;
 Function FileSetDate (Const FileName : String;Age : Longint) : Longint;
@@ -596,7 +596,7 @@ begin
   Result := 0;
   Result := 0;
   t.actime := Age;
   t.actime := Age;
   t.modtime := Age;
   t.modtime := Age;
-  if fputime(PChar(FileName), @t) = -1 then
+  if fputime(PChar(pointer(FileName)), @t) = -1 then
     Result := fpgeterrno;
     Result := fpgeterrno;
 end;
 end;
 
 
@@ -830,7 +830,7 @@ end;
 Function GetEnvironmentVariable(Const EnvVar : String) : String;
 Function GetEnvironmentVariable(Const EnvVar : String) : String;
 
 
 begin
 begin
-  Result:=StrPas(BaseUnix.FPGetenv(PChar(EnvVar)));
+  Result:=StrPas(BaseUnix.FPGetenv(PChar(pointer(EnvVar))));
 end;
 end;
 
 
 Function GetEnvironmentVariableCount : Integer;
 Function GetEnvironmentVariableCount : Integer;
@@ -868,7 +868,7 @@ Begin
          string }
          string }
        UniqueString(CommandLine);
        UniqueString(CommandLine);
        cmdline2:=StringtoPPChar(CommandLine,1);
        cmdline2:=StringtoPPChar(CommandLine,1);
-       cmdline2^:=pchar(Path);
+       cmdline2^:=pchar(pointer(Path));
      end
      end
    else
    else
      begin
      begin
@@ -893,7 +893,7 @@ Begin
    begin
    begin
    {The child does the actual exec, and then exits}
    {The child does the actual exec, and then exits}
     {$ifdef FPC_USE_FPEXEC}
     {$ifdef FPC_USE_FPEXEC}
-      fpexecv(pchar(Path),Cmdline2);
+      fpexecv(pchar(pointer(Path)),Cmdline2);
     {$else}
     {$else}
       Execl(CommandLine);
       Execl(CommandLine);
     {$endif}
     {$endif}

+ 4 - 0
rtl/unix/tthread.inc

@@ -85,7 +85,9 @@ end;
 function ThreadFunc(parameter: Pointer): ptrint;
 function ThreadFunc(parameter: Pointer): ptrint;
 var
 var
   LThread: TThread;
   LThread: TThread;
+{$ifdef DEBUG_MT}
   lErrorAddr, lErrorBase: Pointer;
   lErrorAddr, lErrorBase: Pointer;
+{$endif}
 begin
 begin
   WRITE_DEBUG('ThreadFunc is here...');
   WRITE_DEBUG('ThreadFunc is here...');
   LThread := TThread(parameter);
   LThread := TThread(parameter);
@@ -123,6 +125,7 @@ begin
   except
   except
     on e: exception do begin
     on e: exception do begin
       LThread.FFatalException := TObject(AcquireExceptionObject);
       LThread.FFatalException := TObject(AcquireExceptionObject);
+{$ifdef DEBUG_MT}
       lErrorAddr:=ExceptAddr;
       lErrorAddr:=ExceptAddr;
       lErrorBase:=ExceptFrames^;
       lErrorBase:=ExceptFrames^;
       writeln(stderr,'Exception caught in thread $',hexstr(LThread),
       writeln(stderr,'Exception caught in thread $',hexstr(LThread),
@@ -130,6 +133,7 @@ begin
       writeln(stderr,BackTraceStrFunc(lErrorAddr));
       writeln(stderr,BackTraceStrFunc(lErrorAddr));
       dump_stack(stderr,lErrorBase);
       dump_stack(stderr,lErrorBase);
       writeln(stderr);
       writeln(stderr);
+{$endif}
       // not sure if we should really do this...
       // not sure if we should really do this...
       // but .Destroy was called, so why not try FreeOnTerminate?
       // but .Destroy was called, so why not try FreeOnTerminate?
       if e is EThreadDestroyCalled then LThread.FFreeOnTerminate := true;
       if e is EThreadDestroyCalled then LThread.FFreeOnTerminate := true;

+ 19 - 0
rtl/unix/unixsockets.pas

@@ -0,0 +1,19 @@
+unit unixsockets;
+
+{$mode objfpc}{$H+}
+
+{$packrecords C}
+
+interface
+
+uses
+  cTypes, BaseUnix;
+  
+{$unixsocketsh.inc}
+
+implementation
+
+{$unixsockets.inc}
+
+end.
+

+ 5 - 6
rtl/win/crt.pp

@@ -670,7 +670,7 @@ var
 begin
 begin
   OldConsoleOutputCP:=GetConsoleOutputCP;
   OldConsoleOutputCP:=GetConsoleOutputCP;
   SetConsoleOutputCP(GetACP);
   SetConsoleOutputCP(GetACP);
-    
+
   GetScreenCursor(CurrX, CurrY);
   GetScreenCursor(CurrX, CurrY);
   s:='';
   s:='';
   for i:=0 to f.bufpos-1 do
   for i:=0 to f.bufpos-1 do
@@ -688,7 +688,7 @@ begin
   if s<>'' then
   if s<>'' then
     WriteStr(s);
     WriteStr(s);
   SetScreenCursor(CurrX, CurrY);
   SetScreenCursor(CurrX, CurrY);
-  
+
   SetConsoleOutputCP(OldConsoleOutputCP);
   SetConsoleOutputCP(OldConsoleOutputCP);
 
 
   f.bufpos:=0;
   f.bufpos:=0;
@@ -710,11 +710,11 @@ Function CrtRead(Var F: TextRec): Integer;
 
 
 var
 var
   ch : Char;
   ch : Char;
-  OldConsoleOutputCP : Word;  
+  OldConsoleOutputCP : Word;
 Begin
 Begin
   OldConsoleOutputCP:=GetConsoleOutputCP;
   OldConsoleOutputCP:=GetConsoleOutputCP;
   SetConsoleOutputCP(GetACP);
   SetConsoleOutputCP(GetACP);
-    
+
   GetScreenCursor(CurrX,CurrY);
   GetScreenCursor(CurrX,CurrY);
   f.bufpos:=0;
   f.bufpos:=0;
   f.bufend:=0;
   f.bufend:=0;
@@ -791,7 +791,7 @@ Begin
       end;
       end;
       end;
       end;
   until false;
   until false;
-  
+
   SetConsoleOutputCP(OldConsoleOutputCP);
   SetConsoleOutputCP(OldConsoleOutputCP);
 	
 	
   f.bufpos:=0;
   f.bufpos:=0;
@@ -877,4 +877,3 @@ begin
   Reset(Input);
   Reset(Input);
   TextRec(Input).Handle:= GetStdHandle(STD_INPUT_HANDLE);
   TextRec(Input).Handle:= GetStdHandle(STD_INPUT_HANDLE);
 end. { unit Crt }
 end. { unit Crt }
-

+ 3 - 1
rtl/win/mouse.pp

@@ -78,7 +78,7 @@ procedure MouseEventHandler(var ir:INPUT_RECORD);
            begin
            begin
              LastHandlermouseEvent:=e;
              LastHandlermouseEvent:=e;
 
 
-             { what till there is again space in the mouse event queue }
+             { wait till there is again space in the mouse event queue }
              while PendingMouseEvents>=MouseEventBufSize do
              while PendingMouseEvents>=MouseEventBufSize do
                begin
                begin
                  LeaveCriticalSection(ChangeMouseEvents);
                  LeaveCriticalSection(ChangeMouseEvents);
@@ -200,6 +200,7 @@ end;
 
 
 procedure SysPutMouseEvent(const MouseEvent: TMouseEvent);
 procedure SysPutMouseEvent(const MouseEvent: TMouseEvent);
 begin
 begin
+  EnterCriticalSection(ChangeMouseEvents);
   if PendingMouseEvents<MouseEventBufSize then
   if PendingMouseEvents<MouseEventBufSize then
    begin
    begin
      PendingMouseTail^:=MouseEvent;
      PendingMouseTail^:=MouseEvent;
@@ -210,6 +211,7 @@ begin
         so the win32 version do this by hand:}
         so the win32 version do this by hand:}
        inc(PendingMouseEvents);
        inc(PendingMouseEvents);
    end;
    end;
+  LeaveCriticalSection(ChangeMouseEvents);
 end;
 end;
 
 
 
 

+ 0 - 2
rtl/win/systhrd.inc

@@ -86,8 +86,6 @@ CONST
       end;
       end;
 
 
 
 
-
-
     procedure SysAllocateThreadVars;
     procedure SysAllocateThreadVars;
       var
       var
         dataindex : pointer;
         dataindex : pointer;

+ 9 - 1
rtl/win/wininc/defines.inc

@@ -439,14 +439,22 @@
      OPEN_EXISTING = 3;
      OPEN_EXISTING = 3;
      OPEN_ALWAYS = 4;
      OPEN_ALWAYS = 4;
      TRUNCATE_EXISTING = 5;
      TRUNCATE_EXISTING = 5;
+
      FILE_ATTRIBUTE_ARCHIVE = 32;
      FILE_ATTRIBUTE_ARCHIVE = 32;
-     FILE_ATTRIBUTE_COMPRESSED = 2048;
      FILE_ATTRIBUTE_NORMAL = 128;
      FILE_ATTRIBUTE_NORMAL = 128;
      FILE_ATTRIBUTE_DIRECTORY = 16;
      FILE_ATTRIBUTE_DIRECTORY = 16;
      FILE_ATTRIBUTE_HIDDEN = 2;
      FILE_ATTRIBUTE_HIDDEN = 2;
      FILE_ATTRIBUTE_READONLY = 1;
      FILE_ATTRIBUTE_READONLY = 1;
      FILE_ATTRIBUTE_SYSTEM = 4;
      FILE_ATTRIBUTE_SYSTEM = 4;
      FILE_ATTRIBUTE_TEMPORARY = 256;
      FILE_ATTRIBUTE_TEMPORARY = 256;
+     FILE_ATTRIBUTE_SPARSE_FILE = $0200;
+     FILE_ATTRIBUTE_REPARSE_POINT = $0400;
+     FILE_ATTRIBUTE_COMPRESSED = $0800;
+     FILE_ATTRIBUTE_OFFLINE = $1000;
+     FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = $2000;
+     FILE_ATTRIBUTE_ENCRYPTED = $4000;
+     FILE_ATTRIBUTE_VIRTUAL = $20000;
+
      FILE_FLAG_WRITE_THROUGH = $80000000;
      FILE_FLAG_WRITE_THROUGH = $80000000;
      FILE_FLAG_OVERLAPPED = 1073741824;
      FILE_FLAG_OVERLAPPED = 1073741824;
      FILE_FLAG_NO_BUFFERING = 536870912;
      FILE_FLAG_NO_BUFFERING = 536870912;

+ 68 - 54
rtl/win64/Makefile

@@ -1,11 +1,12 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/10/21]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2007/10/30]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos 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 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 sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos 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 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 sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded
 BSDs = freebsd netbsd openbsd darwin
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx
 UNIXs = linux $(BSDs) solaris qnx
 LIMIT83fs = go32v2 os2 emx watcom
 LIMIT83fs = go32v2 os2 emx watcom
+OSNeedsComspecToRunBatch = go32v2 watcom
 FORCE:
 FORCE:
 .PHONY: FORCE
 .PHONY: FORCE
 override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
 override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
@@ -56,6 +57,11 @@ else
 SRCBATCHEXT=.bat
 SRCBATCHEXT=.bat
 endif
 endif
 endif
 endif
+ifdef COMSPEC
+ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),)
+RUNBATCH=$(COMSPEC) /C
+endif
+endif
 ifdef inUnix
 ifdef inUnix
 PATHSEP=/
 PATHSEP=/
 else
 else
@@ -103,7 +109,11 @@ ifndef FPC
 FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
 FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
 ifneq ($(FPCPROG),)
 ifneq ($(FPCPROG),)
 FPCPROG:=$(firstword $(FPCPROG))
 FPCPROG:=$(firstword $(FPCPROG))
+ifneq ($(CPU_TARGET),)
+FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
+else
 FPC:=$(shell $(FPCPROG) -PB)
 FPC:=$(shell $(FPCPROG) -PB)
+endif
 ifneq ($(findstring Error,$(FPC)),)
 ifneq ($(findstring Error,$(FPC)),)
 override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
 override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
 endif
 endif
@@ -402,160 +412,160 @@ ifeq ($(FULL_TARGET),powerpc64-embedded)
 override TARGET_UNITS+=system objpas macpas buildrtl
 override TARGET_UNITS+=system objpas macpas buildrtl
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts convutils stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
+override TARGET_IMPLICITUNITS+=ctypes strings lineinfo lnfodwrf heaptrc matrix dos crt objects messages windows winsock winsock2 cmem dynlibs rtlconsts sysconst sysutils math types strutils convutils dateutils varutils variants typinfo fgl classes getopts stdconvs sockets printer charset ucomplex fmtbcd winevent video mouse keyboard sharemem
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_LOADERS+=$(LOADERS)
 override TARGET_LOADERS+=$(LOADERS)
@@ -1943,7 +1953,7 @@ override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
 endif
 endif
 ifndef CROSSBOOTSTRAP
 ifndef CROSSBOOTSTRAP
 ifneq ($(BINUTILSPREFIX),)
 ifneq ($(BINUTILSPREFIX),)
-override FPCOPT+=-XP$(BINUTILSPREFIX) 
+override FPCOPT+=-XP$(BINUTILSPREFIX)
 endif
 endif
 ifneq ($(BINUTILSPREFIX),)
 ifneq ($(BINUTILSPREFIX),)
 override FPCOPT+=-Xr$(RLINKPATH)
 override FPCOPT+=-Xr$(RLINKPATH)
@@ -2075,9 +2085,13 @@ ifeq (,$(findstring -s ,$(COMPILER)))
 EXECPPAS=
 EXECPPAS=
 else
 else
 ifeq ($(FULL_SOURCE),$(FULL_TARGET))
 ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+ifdef RUNBATCH
+EXECPPAS:=@$(RUNBATCH) $(PPAS)
+else
 EXECPPAS:=@$(PPAS)
 EXECPPAS:=@$(PPAS)
 endif
 endif
 endif
 endif
+endif
 .PHONY: fpc_loaders
 .PHONY: fpc_loaders
 ifneq ($(TARGET_LOADERS),)
 ifneq ($(TARGET_LOADERS),)
 override ALLTARGET+=fpc_loaders
 override ALLTARGET+=fpc_loaders

+ 1 - 1
rtl/win64/Makefile.fpc

@@ -15,7 +15,7 @@ implicitunits=ctypes strings \
       rtlconsts sysconst sysutils math types \
       rtlconsts sysconst sysutils math types \
       strutils convutils dateutils \
       strutils convutils dateutils \
       varutils variants typinfo fgl classes getopts \
       varutils variants typinfo fgl classes getopts \
-      convutils stdconvs sockets printer charset ucomplex fmtbcd \
+      stdconvs sockets printer charset ucomplex fmtbcd \
       winevent video mouse keyboard \
       winevent video mouse keyboard \
       sharemem
       sharemem
 #      fpcmemdll
 #      fpcmemdll

+ 51 - 0
tests/webtbs/tw10013.pp

@@ -0,0 +1,51 @@
+program rcerror;
+
+{$MODE DELPHI} {$H+} {$R+}
+
+uses SysUtils;
+
+var
+  ws: WideString;
+  //wc: WideChar;
+  i: Integer;
+
+begin
+  ws := UTF8Decode('something');
+
+  WriteLn;
+  WriteLn('str: "', UTF8Encode(ws), '"');
+  WriteLn('len (must be 9) : ', Length(ws));
+  WriteLn;
+
+  for i := 1 to Length(ws) * 2 + 1 do
+  begin
+
+    Write('Try to access ws[', i, ']');
+
+    try
+
+      ws[i] := ws[i];
+      //wc := ws[i];
+      //ws[i] := wc;
+
+      if i > Length(ws) then
+        begin
+          writeln(' FAULT');
+          halt(1);
+        end
+      else
+        WriteLn(' OK');
+
+    except
+
+      on e : Exception do
+      begin
+        if (e is ERangeError) and (i > Length(ws)) then
+          WriteLn(' OK (got a range-check error as expected)');
+      end;
+
+    end;
+
+  end;
+end.
+