Browse Source

* synchronize with trunk

git-svn-id: branches/unicodekvm@42020 -
nickysn 6 years ago
parent
commit
4ed09b4cf0
88 changed files with 2432 additions and 624 deletions
  1. 3 0
      .gitattributes
  2. 0 108
      compiler/aasmbase.pas
  3. 11 12
      compiler/aasmcnst.pas
  4. 37 0
      compiler/avr/aoptcpu.pas
  5. 3 1
      compiler/avr/ccpuinnr.inc
  6. 34 2
      compiler/avr/navrinl.pas
  7. 1 7
      compiler/cclasses.pas
  8. 90 0
      compiler/cutils.pas
  9. 30 7
      compiler/entfile.pas
  10. 6 1
      compiler/fmodule.pas
  11. 26 0
      compiler/fppu.pas
  12. 15 1
      compiler/link.pas
  13. 1 1
      compiler/llvm/llvmtype.pas
  14. 6 9
      compiler/llvm/nllvmtcon.pas
  15. 7 0
      compiler/pcp.pas
  16. 1 1
      compiler/pdecsub.pas
  17. 6 0
      compiler/symtype.pas
  18. 3 1
      compiler/systems.pas
  19. 5 5
      compiler/systems/i_bsd.pas
  20. 65 9
      compiler/systems/t_bsd.pas
  21. 20 4
      compiler/utils/ppuutils/ppudump.pp
  22. 8 9
      packages/amunits/src/coreunits/agraphics.pas
  23. 1 1
      packages/amunits/src/coreunits/clipboard.pas
  24. 4 4
      packages/amunits/src/coreunits/intuition.pas
  25. 13 13
      packages/arosunits/src/agraphics.pas
  26. 2 43
      packages/arosunits/src/amigados.pas
  27. 1 1
      packages/arosunits/src/datatypes.pas
  28. 4 4
      packages/arosunits/src/intuition.pas
  29. 0 1
      packages/arosunits/src/locale.pas
  30. 0 1
      packages/arosunits/src/serial.pas
  31. 6 4
      packages/arosunits/src/workbench.pas
  32. 6 9
      packages/fcl-db/src/sqldb/odbc/odbcconn.pas
  33. 14 10
      packages/fcl-registry/src/winreg.inc
  34. 2 1
      packages/fcl-web/src/base/fphttpclient.pp
  35. 2 2
      packages/fcl-web/src/base/restbase.pp
  36. 3 2
      packages/fcl-web/src/restbridge/sqldbrestbridge.pp
  37. 10 10
      packages/fcl-web/src/restbridge/sqldbrestini.pp
  38. 18 5
      packages/fcl-web/src/restbridge/sqldbrestschema.pp
  39. 30 0
      packages/fpmkunit/src/fpmkunit.pp
  40. 29 7
      packages/morphunits/src/agraphics.pas
  41. 2 2
      packages/morphunits/src/amigados.pas
  42. 7 0
      packages/morphunits/src/datatypes.pas
  43. 2 2
      packages/morphunits/src/exec.pas
  44. 1 3
      packages/morphunits/src/intuition.pas
  45. 2 2
      packages/morphunits/src/utility.pas
  46. 38 0
      packages/pastojs/src/fppas2js.pp
  47. 10 0
      packages/pastojs/tests/tcmodules.pas
  48. 258 0
      packages/rtl-objpas/src/inc/dateutil.inc
  49. 44 105
      rtl/avr/avr.inc
  50. 2 0
      rtl/avr/cpuinnr.inc
  51. 5 0
      rtl/avr/intrinsics.pp
  52. 53 0
      rtl/bsd/ostypes.inc
  53. 2 8
      rtl/embedded/Makefile
  54. 7 8
      rtl/embedded/Makefile.fpc
  55. 3 7
      rtl/freebsd/ptypes.inc
  56. 2 1
      rtl/inc/dos.inc
  57. 2 1
      rtl/inc/fexpand.inc
  58. 2 1
      rtl/inc/ustrings.inc
  59. 62 17
      rtl/linux/i386/sysnr.inc
  60. 1 0
      rtl/linux/powerpc/stat.inc
  61. 77 8
      rtl/linux/powerpc/sysnr.inc
  62. 4 2
      rtl/linux/ptypes.inc
  63. 78 31
      rtl/linux/sparcgen/sysnr.inc
  64. 151 0
      rtl/linux/t_linux.h2paschk
  65. 49 1
      rtl/linux/x86_64/sysnr.inc
  66. 2 1
      rtl/objpas/classes/streams.inc
  67. 3 3
      rtl/objpas/fgl.pp
  68. 45 1
      rtl/objpas/sysutils/sysencoding.inc
  69. 3 0
      rtl/objpas/sysutils/sysencodingh.inc
  70. 6 3
      rtl/openbsd/ptypes.inc
  71. 123 0
      rtl/openbsd/t_openbsd.h2paschk
  72. 213 0
      rtl/unix/scripts/check_rtl_types.sh
  73. 356 38
      rtl/unix/scripts/check_sys.sh
  74. 1 0
      rtl/win/wininc/ascdef.inc
  75. 1 0
      rtl/win/wininc/ascfun.inc
  76. 23 15
      rtl/win/wininc/defines.inc
  77. 12 2
      rtl/win/wininc/func.inc
  78. 16 16
      rtl/win/wininc/messages.inc
  79. 1 1
      rtl/win/wininc/redef.inc
  80. 1 0
      rtl/win/wininc/unidef.inc
  81. 1 0
      rtl/win/wininc/unifun.inc
  82. 4 4
      tests/Makefile
  83. 4 4
      tests/Makefile.fpc
  84. 29 0
      tests/tbs/tb0657.pp
  85. 13 0
      tests/test/cg/tcalext6.pp
  86. 4 0
      tests/test/cg/tcppcl2.pp
  87. 4 1
      tests/utils/testsuite/utests.pp
  88. 180 40
      utils/h2pas/h2paschk.pas

+ 3 - 0
.gitattributes

@@ -9877,6 +9877,7 @@ rtl/linux/sysnr-gen.inc svneol=native#text/plain
 rtl/linux/sysos.inc svneol=native#text/plain
 rtl/linux/sysos.inc svneol=native#text/plain
 rtl/linux/sysosh.inc svneol=native#text/plain
 rtl/linux/sysosh.inc svneol=native#text/plain
 rtl/linux/system.pp svneol=native#text/plain
 rtl/linux/system.pp svneol=native#text/plain
+rtl/linux/t_linux.h2paschk svneol=native#text/plain
 rtl/linux/termio.pp svneol=native#text/plain
 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
@@ -10633,6 +10634,7 @@ rtl/unix/scripts/README svneol=native#text/plain
 rtl/unix/scripts/check_consts.sh svneol=native#text/plain
 rtl/unix/scripts/check_consts.sh svneol=native#text/plain
 rtl/unix/scripts/check_errno.sh svneol=native#text/plain
 rtl/unix/scripts/check_errno.sh svneol=native#text/plain
 rtl/unix/scripts/check_errnostr.sh svneol=native#text/plain
 rtl/unix/scripts/check_errnostr.sh svneol=native#text/plain
+rtl/unix/scripts/check_rtl_types.sh svneol=native#text/plain
 rtl/unix/scripts/check_sys.sh svneol=native#text/plain
 rtl/unix/scripts/check_sys.sh svneol=native#text/plain
 rtl/unix/settimeo.inc svneol=native#text/plain
 rtl/unix/settimeo.inc svneol=native#text/plain
 rtl/unix/syscall.pp svneol=native#text/plain
 rtl/unix/syscall.pp svneol=native#text/plain
@@ -11864,6 +11866,7 @@ tests/tbs/tb0653.pp svneol=native#text/plain
 tests/tbs/tb0654.pp svneol=native#text/plain
 tests/tbs/tb0654.pp svneol=native#text/plain
 tests/tbs/tb0655.pp svneol=native#text/pascal
 tests/tbs/tb0655.pp svneol=native#text/pascal
 tests/tbs/tb0656.pp svneol=native#text/pascal
 tests/tbs/tb0656.pp svneol=native#text/pascal
+tests/tbs/tb0657.pp svneol=native#text/pascal
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/tb610.pp svneol=native#text/pascal
 tests/tbs/tb610.pp svneol=native#text/pascal
 tests/tbs/tb613.pp svneol=native#text/plain
 tests/tbs/tb613.pp svneol=native#text/plain

+ 0 - 108
compiler/aasmbase.pas

@@ -230,11 +230,6 @@ interface
     function create_smartlink_library:boolean;inline;
     function create_smartlink_library:boolean;inline;
     function create_smartlink:boolean;inline;
     function create_smartlink:boolean;inline;
 
 
-    function LengthUleb128(a: qword) : byte;
-    function LengthSleb128(a: int64) : byte;
-    function EncodeUleb128(a: qword;out buf) : byte;
-    function EncodeSleb128(a: int64;out buf) : byte;
-
     function ReplaceForbiddenAsmSymbolChars(const s: ansistring): ansistring;
     function ReplaceForbiddenAsmSymbolChars(const s: ansistring): ansistring;
 
 
     { dummy default noop callback }
     { dummy default noop callback }
@@ -283,109 +278,6 @@ implementation
       end;
       end;
 
 
 
 
-    function LengthUleb128(a: qword) : byte;
-      begin
-        result:=0;
-        repeat
-          a := a shr 7;
-          inc(result);
-          if a=0 then
-            break;
-        until false;
-      end;
-
-
-    function LengthSleb128(a: int64) : byte;
-      var
-        b, size: byte;
-        asign : int64;
-        neg, more: boolean;
-      begin
-        more := true;
-        neg := a < 0;
-        size := sizeof(a)*8;
-        result:=0;
-        repeat
-          b := a and $7f;
-          a := a shr 7;
-          if neg then
-            begin
-              { Use a variable to be sure that the correct or mask is generated }
-              asign:=1;
-              asign:=asign shl (size - 7);
-              a := a or -asign;
-            end;
-          if (((a = 0) and
-               (b and $40 = 0)) or
-              ((a = -1) and
-               (b and $40 <> 0))) then
-            more := false;
-          inc(result);
-          if not(more) then
-            break;
-        until false;
-      end;
-
-
-    function EncodeUleb128(a: qword;out buf) : byte;
-      var
-        b: byte;
-        pbuf : pbyte;
-      begin
-        result:=0;
-        pbuf:=@buf;
-        repeat
-          b := a and $7f;
-          a := a shr 7;
-          if a<>0 then
-            b := b or $80;
-          pbuf^:=b;
-          inc(pbuf);
-          inc(result);
-          if a=0 then
-            break;
-        until false;
-      end;
-
-
-    function EncodeSleb128(a: int64;out buf) : byte;
-      var
-        b, size: byte;
-        asign : int64;
-        neg, more: boolean;
-        pbuf : pbyte;
-      begin
-        more := true;
-        neg := a < 0;
-        size := sizeof(a)*8;
-        result:=0;
-        pbuf:=@buf;
-        repeat
-          b := a and $7f;
-          a := a shr 7;
-          if neg then
-            begin
-              { Use a variable to be sure that the correct or mask is generated }
-              asign:=1;
-              asign:=asign shl (size - 7);
-              a := a or -asign;
-            end;
-          if (((a = 0) and
-               (b and $40 = 0)) or
-              ((a = -1) and
-               (b and $40 <> 0))) then
-            more := false
-          else
-            b := b or $80;
-          pbuf^:=b;
-          inc(pbuf);
-          inc(result);
-          if not(more) then
-            break;
-        until false;
-      end;
-
-
     function ReplaceForbiddenAsmSymbolChars(const s: ansistring): ansistring;
     function ReplaceForbiddenAsmSymbolChars(const s: ansistring): ansistring;
       var
       var
         i : longint;
         i : longint;

+ 11 - 12
compiler/aasmcnst.pas

@@ -57,7 +57,7 @@ type
     protected
     protected
      fval: tai;
      fval: tai;
     public
     public
-     constructor create(_adetyp: ttypedconstkind; _def: tdef; _val: tai);
+     constructor create(_def: tdef; _val: tai);
      destructor destroy; override;
      destructor destroy; override;
      property val: tai read fval write setval;
      property val: tai read fval write setval;
    end;
    end;
@@ -70,7 +70,7 @@ type
      { iterator to walk over all individual items in the aggregate }
      { iterator to walk over all individual items in the aggregate }
      tadeenumerator = class(tobject)
      tadeenumerator = class(tobject)
       private
       private
-       fvalues: tfplist;
+       fvalues: tfpobjectlist;
        fvaluespos: longint;
        fvaluespos: longint;
        function getcurrent: tai_abstracttypedconst;
        function getcurrent: tai_abstracttypedconst;
       public
       public
@@ -81,7 +81,7 @@ type
      end;
      end;
 
 
     protected
     protected
-     fvalues: tfplist;
+     fvalues: tfpobjectlist;
      fisstring: boolean;
      fisstring: boolean;
 
 
      { converts the existing data to a single tai_string }
      { converts the existing data to a single tai_string }
@@ -93,7 +93,7 @@ type
      procedure addvalue(val: tai_abstracttypedconst);
      procedure addvalue(val: tai_abstracttypedconst);
      function valuecount: longint;
      function valuecount: longint;
      procedure insertvaluebeforepos(val: tai_abstracttypedconst; pos: longint);
      procedure insertvaluebeforepos(val: tai_abstracttypedconst; pos: longint);
-     function replacevalueatpos(val: tai_abstracttypedconst; pos: longint): tai_abstracttypedconst;
+     procedure replacevalueatpos(val: tai_abstracttypedconst; pos: longint);
      { change the type to a record, regardless of how the aggregate was created;
      { change the type to a record, regardless of how the aggregate was created;
        the size of the original type and the record must match }
        the size of the original type and the record must match }
      procedure changetorecord(_def: trecorddef);
      procedure changetorecord(_def: trecorddef);
@@ -640,9 +640,9 @@ implementation
       end;
       end;
 
 
 
 
-   constructor tai_simpletypedconst.create(_adetyp: ttypedconstkind; _def: tdef; _val: tai);
+   constructor tai_simpletypedconst.create(_def: tdef; _val: tai);
      begin
      begin
-       inherited create(_adetyp,_def);
+       inherited create(tck_simple,_def);
        fval:=_val;
        fval:=_val;
      end;
      end;
 
 
@@ -710,7 +710,7 @@ implementation
        { the "nil" def will be replaced with an array def of the appropriate
        { the "nil" def will be replaced with an array def of the appropriate
          size once we're finished adding data, so we don't create intermediate
          size once we're finished adding data, so we don't create intermediate
          arraydefs all the time }
          arraydefs all the time }
-       fvalues.add(tai_simpletypedconst.create(tck_simple,nil,newstr));
+       fvalues.add(tai_simpletypedconst.create(nil,newstr));
      end;
      end;
 
 
    procedure tai_aggregatetypedconst.add_to_string(strtai: tai_string; othertai: tai);
    procedure tai_aggregatetypedconst.add_to_string(strtai: tai_string; othertai: tai);
@@ -744,7 +744,7 @@ implementation
      begin
      begin
        inherited;
        inherited;
        fisstring:=false;
        fisstring:=false;
-       fvalues:=tfplist.create;
+       fvalues:=tfpobjectlist.create(true);
      end;
      end;
 
 
 
 
@@ -794,9 +794,9 @@ implementation
      end;
      end;
 
 
 
 
-   function tai_aggregatetypedconst.replacevalueatpos(val: tai_abstracttypedconst; pos: longint): tai_abstracttypedconst;
+   procedure tai_aggregatetypedconst.replacevalueatpos(val: tai_abstracttypedconst; pos: longint);
      begin
      begin
-       result:=tai_abstracttypedconst(fvalues[pos]);
+       { since fvalues owns its elements, it will automatically free the old value }
        fvalues[pos]:=val;
        fvalues[pos]:=val;
      end;
      end;
 
 
@@ -831,8 +831,6 @@ implementation
      var
      var
        ai: tai_abstracttypedconst;
        ai: tai_abstracttypedconst;
      begin
      begin
-       for ai in self do
-          ai.free;
        fvalues.free;
        fvalues.free;
        inherited destroy;
        inherited destroy;
      end;
      end;
@@ -1115,6 +1113,7 @@ implementation
              secname:=make_mangledname(basename,st,'2_'+itemname);
              secname:=make_mangledname(basename,st,'2_'+itemname);
            exclude(options,tcalo_vectorized_dead_strip_item);
            exclude(options,tcalo_vectorized_dead_strip_item);
          end;
          end;
+       current_module.linkorderedsymbols.concat(sym.Name);
        finalize_asmlist(sym,def,sectype,secname,alignment,options);
        finalize_asmlist(sym,def,sectype,secname,alignment,options);
      end;
      end;
 
 

+ 37 - 0
compiler/avr/aoptcpu.pas

@@ -484,6 +484,43 @@ Implementation
                             result:=true;
                             result:=true;
                           end;
                           end;
                       end;
                       end;
+                A_SBRS,
+                A_SBRC:
+                  begin
+                    {
+                      Turn
+                        in rx, y
+                        sbr* rx, z
+                      Into
+                        sbi* y, z
+                    }
+                    if (taicpu(p).ops=2) and
+                       (taicpu(p).oper[0]^.typ=top_reg) and
+                       assigned(FindRegDeAlloc(taicpu(p).oper[0]^.reg,tai(p.next))) and
+                       GetLastInstruction(p,hp1) and
+                       (hp1.typ=ait_instruction) and
+                       (taicpu(hp1).opcode=A_IN) and
+                       (taicpu(hp1).ops=2) and
+                       (taicpu(hp1).oper[1]^.typ=top_const) and
+                       (taicpu(hp1).oper[1]^.val in [0..31]) and
+                       MatchOperand(taicpu(hp1).oper[0]^,taicpu(p).oper[0]^.reg) and
+                       (not RegModifiedBetween(taicpu(p).oper[0]^.reg, hp1, p)) then
+                      begin
+                        if taicpu(p).opcode=A_SBRS then
+                          taicpu(p).opcode:=A_SBIS
+                        else
+                          taicpu(p).opcode:=A_SBIC;
+
+                        taicpu(p).loadconst(0, taicpu(hp1).oper[1]^.val);
+
+                        DebugMsg('Peephole InSbrx2Sbix performed', p);
+
+                        asml.Remove(hp1);
+                        hp1.free;
+
+                        result:=true;
+                      end;
+                  end;
                 A_ANDI:
                 A_ANDI:
                   begin
                   begin
                     {
                     {

+ 3 - 1
compiler/avr/ccpuinnr.inc

@@ -16,4 +16,6 @@
   in_avr_sei = fpc_in_cpu_first+1,
   in_avr_sei = fpc_in_cpu_first+1,
   in_avr_wdr = fpc_in_cpu_first+2,
   in_avr_wdr = fpc_in_cpu_first+2,
   in_avr_sleep = fpc_in_cpu_first+3,
   in_avr_sleep = fpc_in_cpu_first+3,
-  in_avr_nop = fpc_in_cpu_first+4
+  in_avr_nop = fpc_in_cpu_first+4,
+  in_avr_save = fpc_in_cpu_first+5,
+  in_avr_restore = fpc_in_cpu_first+6

+ 34 - 2
compiler/avr/navrinl.pas

@@ -42,7 +42,9 @@ unit navrinl;
       aasmdata,
       aasmdata,
       aasmcpu,
       aasmcpu,
       symdef,
       symdef,
-      cgbase,
+      hlcgobj,
+      pass_2,
+      cgbase, cgobj, cgutils,
       cpubase;
       cpubase;
 
 
     function tavrinlinenode.pass_typecheck_cpu : tnode;
     function tavrinlinenode.pass_typecheck_cpu : tnode;
@@ -58,6 +60,16 @@ unit navrinl;
               CheckParameters(0);
               CheckParameters(0);
               resultdef:=voidtype;
               resultdef:=voidtype;
             end;
             end;
+          in_avr_save:
+            begin
+              CheckParameters(0);
+              resultdef:=u8inttype;
+            end;
+          in_avr_restore:
+            begin
+              CheckParameters(1);
+              resultdef:=voidtype;
+            end;
           else
           else
             Result:=inherited pass_typecheck_cpu;
             Result:=inherited pass_typecheck_cpu;
         end;
         end;
@@ -72,11 +84,17 @@ unit navrinl;
           in_avr_sleep,
           in_avr_sleep,
           in_avr_sei,
           in_avr_sei,
           in_avr_wdr,
           in_avr_wdr,
-          in_avr_cli:
+          in_avr_cli,
+          in_avr_restore:
             begin
             begin
               expectloc:=LOC_VOID;
               expectloc:=LOC_VOID;
               resultdef:=voidtype;
               resultdef:=voidtype;
             end;
             end;
+          in_avr_save:
+            begin
+              expectloc:=LOC_REGISTER;
+              resultdef:=u8inttype;
+            end;
           else
           else
             Result:=inherited first_cpu;
             Result:=inherited first_cpu;
         end;
         end;
@@ -96,6 +114,20 @@ unit navrinl;
             current_asmdata.CurrAsmList.concat(taicpu.op_none(A_WDR));
             current_asmdata.CurrAsmList.concat(taicpu.op_none(A_WDR));
           in_avr_cli:
           in_avr_cli:
             current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLI));
             current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLI));
+          in_avr_save:
+            begin
+              location_reset(location,LOC_CREGISTER,OS_8);
+              location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_8);
+
+              current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_IN, location.register, NIO_SREG));
+              current_asmdata.CurrAsmList.concat(taicpu.op_none(A_CLI));
+            end;
+          in_avr_restore:
+            begin
+              secondpass(left);
+              hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
+              current_asmdata.CurrAsmList.concat(taicpu.op_const_reg(A_OUT, NIO_SREG, left.location.register));
+            end;
           else
           else
             inherited pass_generate_code_cpu;
             inherited pass_generate_code_cpu;
         end;
         end;

+ 1 - 7
compiler/cclasses.pas

@@ -397,7 +397,7 @@ type
           constructor Create(const s:TCmdStr);
           constructor Create(const s:TCmdStr);
           destructor  Destroy;override;
           destructor  Destroy;override;
           function GetCopy:TLinkedListItem;override;
           function GetCopy:TLinkedListItem;override;
-          function Str:TCmdStr; {$ifdef CCLASSESINLINE}inline;{$endif}
+          property Str: TCmdStr read FPStr;
        end;
        end;
 
 
        { string container }
        { string container }
@@ -2383,12 +2383,6 @@ end;
       end;
       end;
 
 
 
 
-    function TCmdStrListItem.Str:TCmdStr;
-      begin
-        Str:=FPStr;
-      end;
-
-
     function TCmdStrListItem.GetCopy:TLinkedListItem;
     function TCmdStrListItem.GetCopy:TLinkedListItem;
       begin
       begin
         Result:=(inherited GetCopy);
         Result:=(inherited GetCopy);

+ 90 - 0
compiler/cutils.pas

@@ -180,6 +180,11 @@ interface
 
 
     Function nextafter(x,y:double):double;
     Function nextafter(x,y:double):double;
 
 
+    function LengthUleb128(a: qword) : byte;
+    function LengthSleb128(a: int64) : byte;
+    function EncodeUleb128(a: qword;out buf) : byte;
+    function EncodeSleb128(a: int64;out buf) : byte;
+
   { hide Sysutils.ExecuteProcess in units using this one after SysUtils}
   { hide Sysutils.ExecuteProcess in units using this one after SysUtils}
   const
   const
     ExecuteProcess = 'Do not use' deprecated 'Use cfileutil.RequotedExecuteProcess instead, ExecuteProcess cannot deal with single quotes as used by Unix command lines';
     ExecuteProcess = 'Do not use' deprecated 'Use cfileutil.RequotedExecuteProcess instead, ExecuteProcess cannot deal with single quotes as used by Unix command lines';
@@ -1631,6 +1636,91 @@ implementation
     end;
     end;
 
 
 
 
+    function LengthUleb128(a: qword) : byte;
+      begin
+        result:=0;
+        repeat
+          a := a shr 7;
+          inc(result);
+          if a=0 then
+            break;
+        until false;
+      end;
+
+
+    function LengthSleb128(a: int64) : byte;
+      var
+        b, size: byte;
+        more: boolean;
+      begin
+        more := true;
+        size := sizeof(a)*8;
+        result:=0;
+        repeat
+          b := a and $7f;
+          a := SarInt64(a, 7);
+
+          if (
+            ((a = 0) and (b and $40 = 0)) or
+            ((a = -1) and (b and $40 <> 0))
+          ) then
+            more := false;
+          inc(result);
+          if not(more) then
+            break;
+        until false;
+      end;
+
+
+    function EncodeUleb128(a: qword;out buf) : byte;
+      var
+        b: byte;
+        pbuf : pbyte;
+      begin
+        result:=0;
+        pbuf:=@buf;
+        repeat
+          b := a and $7f;
+          a := a shr 7;
+          if a<>0 then
+            b := b or $80;
+          pbuf^:=b;
+          inc(pbuf);
+          inc(result);
+          if a=0 then
+            break;
+        until false;
+      end;
+
+
+    function EncodeSleb128(a: int64;out buf) : byte;
+      var
+        b, size: byte;
+        more: boolean;
+        pbuf : pbyte;
+      begin
+        more := true;
+        size := sizeof(a)*8;
+        result:=0;
+        pbuf:=@buf;
+        repeat
+          b := a and $7f;
+          a := SarInt64(a, 7);
+
+          if (
+            ((a = 0) and (b and $40 = 0)) or
+            ((a = -1) and (b and $40 <> 0))
+          ) then
+            more := false
+          else
+            b := b or $80;
+          pbuf^:=b;
+          inc(pbuf);
+          inc(result);
+        until not more;
+      end;
+
+
 initialization
 initialization
   internalerrorproc:=@defaulterror;
   internalerrorproc:=@defaulterror;
   initupperlower;
   initupperlower;

+ 30 - 7
compiler/entfile.pas

@@ -120,6 +120,7 @@ const
   ibwpofile         = 84;
   ibwpofile         = 84;
   ibmoduleoptions   = 85;
   ibmoduleoptions   = 85;
   ibunitimportsyms  = 86;
   ibunitimportsyms  = 86;
+  iborderedsymbols  = 87;
 
 
   ibmainname       = 90;
   ibmainname       = 90;
   ibsymtableoptions = 91;
   ibsymtableoptions = 91;
@@ -236,6 +237,7 @@ type
     procedure resetfile;virtual;abstract;
     procedure resetfile;virtual;abstract;
     function getheadersize:longint;virtual;abstract;
     function getheadersize:longint;virtual;abstract;
     function getheaderaddr:pentryheader;virtual;abstract;
     function getheaderaddr:pentryheader;virtual;abstract;
+    procedure RaiseAssertion(Code: Longint); virtual;
   public
   public
     entrytyp : byte;
     entrytyp : byte;
     size             : integer;
     size             : integer;
@@ -384,6 +386,13 @@ begin
 end;
 end;
 
 
 
 
+procedure tentryfile.RaiseAssertion(Code: Longint);
+begin
+  { It's down to descendent classes to raise an internal error as desired. [Kit] }
+  error := true;
+end;
+
+
 procedure tentryfile.closefile;
 procedure tentryfile.closefile;
 begin
 begin
   if mode<>0 then
   if mode<>0 then
@@ -600,13 +609,13 @@ end;
 
 
 function tentryfile.getbyte:byte;
 function tentryfile.getbyte:byte;
 begin
 begin
-  if entryidx+1>entry.size then
+  if entryidx>=entry.size then
    begin
    begin
      error:=true;
      error:=true;
      result:=0;
      result:=0;
      exit;
      exit;
    end;
    end;
-  if bufsize-bufidx>=1 then
+  if bufidx<bufsize then
     begin
     begin
       result:=pbyte(@buf[bufidx])^;
       result:=pbyte(@buf[bufidx])^;
       inc(bufidx);
       inc(bufidx);
@@ -744,12 +753,16 @@ begin
       result:=0;
       result:=0;
     end;
     end;
 {$else not generic_cpu}
 {$else not generic_cpu}
-  result:=4;
   case sizeof(aint) of
   case sizeof(aint) of
     8: result:=getint64;
     8: result:=getint64;
     4: result:=getlongint;
     4: result:=getlongint;
     2: result:=smallint(getword);
     2: result:=smallint(getword);
     1: result:=shortint(getbyte);
     1: result:=shortint(getbyte);
+  else
+    begin
+      RaiseAssertion(2019041801);
+      result:=0;
+    end;
   end;
   end;
 {$endif not generic_cpu}
 {$endif not generic_cpu}
 end;
 end;
@@ -788,9 +801,12 @@ begin
     4: result:=asizeint(getlongint);
     4: result:=asizeint(getlongint);
     2: result:=asizeint(getword);
     2: result:=asizeint(getword);
     1: result:=asizeint(getbyte);
     1: result:=asizeint(getbyte);
-    else
+  else
+    begin
+      RaiseAssertion(2019041802);
       result:=0;
       result:=0;
-end;
+    end;
+  end;
 {$endif not generic_cpu}
 {$endif not generic_cpu}
 end;
 end;
 
 
@@ -821,7 +837,10 @@ begin
     2: result:=getword;
     2: result:=getword;
     1: result:=getbyte;
     1: result:=getbyte;
   else
   else
-    result:=0;
+    begin
+      RaiseAssertion(2019041803);
+      result:=0;
+    end;
   end;
   end;
 {$endif not generic_cpu}
 {$endif not generic_cpu}
 end;
 end;
@@ -870,12 +889,16 @@ begin
       result:=0;
       result:=0;
     end;
     end;
 {$else not generic_cpu}
 {$else not generic_cpu}
-  result:=4;
   case sizeof(aword) of
   case sizeof(aword) of
     8: result:=getqword;
     8: result:=getqword;
     4: result:=getdword;
     4: result:=getdword;
     2: result:=getword;
     2: result:=getword;
     1: result:=getbyte;
     1: result:=getbyte;
+  else
+    begin
+      RaiseAssertion(2019041804);
+      result:=0;
+    end;
   end;
   end;
 {$endif not generic_cpu}
 {$endif not generic_cpu}
 end;
 end;

+ 6 - 1
compiler/fmodule.pas

@@ -169,7 +169,8 @@ interface
         loaded_from   : tmodule;
         loaded_from   : tmodule;
         _exports      : tlinkedlist;
         _exports      : tlinkedlist;
         dllscannerinputlist : TFPHashList;
         dllscannerinputlist : TFPHashList;
-        resourcefiles : TCmdStrList;
+        resourcefiles,
+        linkorderedsymbols : TCmdStrList;
         linkunitofiles,
         linkunitofiles,
         linkunitstaticlibs,
         linkunitstaticlibs,
         linkunitsharedlibs,
         linkunitsharedlibs,
@@ -564,6 +565,7 @@ implementation
         used_units:=TLinkedList.Create;
         used_units:=TLinkedList.Create;
         dependent_units:=TLinkedList.Create;
         dependent_units:=TLinkedList.Create;
         resourcefiles:=TCmdStrList.Create;
         resourcefiles:=TCmdStrList.Create;
+        linkorderedsymbols:=TCmdStrList.Create;
         linkunitofiles:=TLinkContainer.Create;
         linkunitofiles:=TLinkContainer.Create;
         linkunitstaticlibs:=TLinkContainer.Create;
         linkunitstaticlibs:=TLinkContainer.Create;
         linkunitsharedlibs:=TLinkContainer.Create;
         linkunitsharedlibs:=TLinkContainer.Create;
@@ -685,6 +687,7 @@ implementation
         used_units.free;
         used_units.free;
         dependent_units.free;
         dependent_units.free;
         resourcefiles.Free;
         resourcefiles.Free;
+        linkorderedsymbols.Free;
         linkunitofiles.Free;
         linkunitofiles.Free;
         linkunitstaticlibs.Free;
         linkunitstaticlibs.Free;
         linkunitsharedlibs.Free;
         linkunitsharedlibs.Free;
@@ -841,6 +844,8 @@ implementation
         dependent_units:=TLinkedList.Create;
         dependent_units:=TLinkedList.Create;
         resourcefiles.Free;
         resourcefiles.Free;
         resourcefiles:=TCmdStrList.Create;
         resourcefiles:=TCmdStrList.Create;
+        linkorderedsymbols.Free;
+        linkorderedsymbols:=TCmdStrList.Create;;
         pendingspecializations.free;
         pendingspecializations.free;
         pendingspecializations:=tfphashobjectlist.create(false);
         pendingspecializations:=tfphashobjectlist.create(false);
         if assigned(waitingforunit) and
         if assigned(waitingforunit) and

+ 26 - 0
compiler/fppu.pas

@@ -96,6 +96,7 @@ interface
           procedure writederefdata;
           procedure writederefdata;
           procedure writeImportSymbols;
           procedure writeImportSymbols;
           procedure writeResources;
           procedure writeResources;
+          procedure writeOrderedSymbols;
           procedure writeunitimportsyms;
           procedure writeunitimportsyms;
           procedure writeasmsyms(kind:tunitasmlisttype;list:tfphashobjectlist);
           procedure writeasmsyms(kind:tunitasmlisttype;list:tfphashobjectlist);
           procedure writeextraheader;
           procedure writeextraheader;
@@ -106,6 +107,7 @@ interface
           procedure readderefdata;
           procedure readderefdata;
           procedure readImportSymbols;
           procedure readImportSymbols;
           procedure readResources;
           procedure readResources;
+          procedure readOrderedSymbols;
           procedure readwpofile;
           procedure readwpofile;
           procedure readunitimportsyms;
           procedure readunitimportsyms;
           procedure readasmsyms;
           procedure readasmsyms;
@@ -946,6 +948,20 @@ var
       end;
       end;
 
 
 
 
+    procedure tppumodule.writeOrderedSymbols;
+      var
+        res : TCmdStrListItem;
+      begin
+        res:=TCmdStrListItem(linkorderedsymbols.First);
+        while res<>nil do
+          begin
+            ppufile.putstring(res.FPStr);
+            res:=TCmdStrListItem(res.Next);
+          end;
+        ppufile.writeentry(iborderedsymbols);
+      end;
+
+
     procedure tppumodule.writeunitimportsyms;
     procedure tppumodule.writeunitimportsyms;
       var
       var
         i : longint;
         i : longint;
@@ -1284,6 +1300,13 @@ var
       end;
       end;
 
 
 
 
+    procedure tppumodule.readOrderedSymbols;
+      begin
+        while not ppufile.endofentry do
+          linkorderedsymbols.Concat(ppufile.getstring);
+      end;
+
+
     procedure tppumodule.readwpofile;
     procedure tppumodule.readwpofile;
       var
       var
         orgwpofilename: string;
         orgwpofilename: string;
@@ -1430,6 +1453,8 @@ var
                readderefdata;
                readderefdata;
              ibresources:
              ibresources:
                readResources;
                readResources;
+             iborderedsymbols:
+               readOrderedSymbols;
              ibwpofile:
              ibwpofile:
                readwpofile;
                readwpofile;
              ibendinterface :
              ibendinterface :
@@ -1550,6 +1575,7 @@ var
          writelinkcontainer(linkotherframeworks,iblinkotherframeworks,true);
          writelinkcontainer(linkotherframeworks,iblinkotherframeworks,true);
          writeImportSymbols;
          writeImportSymbols;
          writeResources;
          writeResources;
+         writeOrderedSymbols;
          ppufile.do_crc:=true;
          ppufile.do_crc:=true;
 
 
          { generate implementation deref data, the interface deref data is
          { generate implementation deref data, the interface deref data is

+ 15 - 1
compiler/link.pas

@@ -55,7 +55,8 @@ interface
          ObjectFiles,
          ObjectFiles,
          SharedLibFiles,
          SharedLibFiles,
          StaticLibFiles,
          StaticLibFiles,
-         FrameworkFiles  : TCmdStrList;
+         FrameworkFiles,
+         OrderedSymbols: TCmdStrList;
          Constructor Create;virtual;
          Constructor Create;virtual;
          Destructor Destroy;override;
          Destructor Destroy;override;
          procedure AddModuleFiles(hp:tmodule);
          procedure AddModuleFiles(hp:tmodule);
@@ -65,6 +66,7 @@ interface
          Procedure AddStaticCLibrary(const S : TCmdStr);
          Procedure AddStaticCLibrary(const S : TCmdStr);
          Procedure AddSharedCLibrary(S : TCmdStr);
          Procedure AddSharedCLibrary(S : TCmdStr);
          Procedure AddFramework(S : TCmdStr);
          Procedure AddFramework(S : TCmdStr);
+         Procedure AddOrderedSymbol(const s: TCmdStr);
          procedure AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);virtual;
          procedure AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);virtual;
          Procedure InitSysInitUnitName;virtual;
          Procedure InitSysInitUnitName;virtual;
          Function  MakeExecutable:boolean;virtual;
          Function  MakeExecutable:boolean;virtual;
@@ -353,6 +355,7 @@ Implementation
         SharedLibFiles:=TCmdStrList.Create_no_double;
         SharedLibFiles:=TCmdStrList.Create_no_double;
         StaticLibFiles:=TCmdStrList.Create_no_double;
         StaticLibFiles:=TCmdStrList.Create_no_double;
         FrameworkFiles:=TCmdStrList.Create_no_double;
         FrameworkFiles:=TCmdStrList.Create_no_double;
+        OrderedSymbols:=TCmdStrList.Create;
       end;
       end;
 
 
 
 
@@ -362,6 +365,8 @@ Implementation
         SharedLibFiles.Free;
         SharedLibFiles.Free;
         StaticLibFiles.Free;
         StaticLibFiles.Free;
         FrameworkFiles.Free;
         FrameworkFiles.Free;
+        OrderedSymbols.Free;
+        inherited;
       end;
       end;
 
 
 
 
@@ -371,6 +376,7 @@ Implementation
         i,j  : longint;
         i,j  : longint;
         ImportLibrary : TImportLibrary;
         ImportLibrary : TImportLibrary;
         ImportSymbol  : TImportSymbol;
         ImportSymbol  : TImportSymbol;
+        cmdstritem: TCmdStrListItem;
       begin
       begin
         with hp do
         with hp do
          begin
          begin
@@ -468,6 +474,8 @@ Implementation
                      ImportSymbol.MangledName,ImportSymbol.OrdNr,ImportSymbol.IsVar);
                      ImportSymbol.MangledName,ImportSymbol.OrdNr,ImportSymbol.IsVar);
                  end;
                  end;
              end;
              end;
+           { ordered symbols }
+           OrderedSymbols.concatList(linkorderedsymbols);
          end;
          end;
       end;
       end;
 
 
@@ -536,6 +544,12 @@ Implementation
       end;
       end;
 
 
 
 
+    procedure TLinker.AddOrderedSymbol(const s: TCmdStr);
+      begin
+        OrderedSymbols.Concat(s);
+      end;
+
+
     Procedure TLinker.AddStaticCLibrary(const S:TCmdStr);
     Procedure TLinker.AddStaticCLibrary(const S:TCmdStr);
       var
       var
         ns : TCmdStr;
         ns : TCmdStr;

+ 1 - 1
compiler/llvm/llvmtype.pas

@@ -370,7 +370,7 @@ implementation
                       symdef:=cpointerdef.getreusable(symdef);
                       symdef:=cpointerdef.getreusable(symdef);
                       if not equal_llvm_defs(symdef,p.def) then
                       if not equal_llvm_defs(symdef,p.def) then
                         begin
                         begin
-                          cnv:=taillvm.op_reg_tai_size(la_bitcast,NR_NO,tai_simpletypedconst.create(tck_simple,symdef,tai_simpletypedconst(p).val),p.def);
+                          cnv:=taillvm.op_reg_tai_size(la_bitcast,NR_NO,tai_simpletypedconst.create(symdef,tai_simpletypedconst(p).val),p.def);
                           tai_simpletypedconst(p).val:=cnv;
                           tai_simpletypedconst(p).val:=cnv;
                         end;
                         end;
                     end;
                     end;

+ 6 - 9
compiler/llvm/nllvmtcon.pas

@@ -163,15 +163,12 @@ implementation
 
 
 
 
   procedure tllvmtypedconstplaceholder.replace(ai: tai; d: tdef);
   procedure tllvmtypedconstplaceholder.replace(ai: tai; d: tdef);
-    var
-      oldconst: tai_abstracttypedconst;
     begin
     begin
       if d<>def then
       if d<>def then
         internalerror(2015091002);
         internalerror(2015091002);
-      oldconst:=agginfo.aggai.replacevalueatpos(
-        tai_simpletypedconst.create(tck_simple,d,ai),pos
+      agginfo.aggai.replacevalueatpos(
+        tai_simpletypedconst.create(d,ai),pos
       );
       );
-      oldconst.free;
     end;
     end;
 
 
 
 
@@ -256,7 +253,7 @@ implementation
 
 
   function tllvmtai_typedconstbuilder.wrap_with_type(p: tai; def: tdef): tai;
   function tllvmtai_typedconstbuilder.wrap_with_type(p: tai; def: tdef): tai;
     begin
     begin
-      result:=tai_simpletypedconst.create(tck_simple,def,p);
+      result:=tai_simpletypedconst.create(def,p);
     end;
     end;
 
 
 
 
@@ -293,7 +290,7 @@ implementation
         begin
         begin
           kind:=tck_simple;
           kind:=tck_simple;
           { finalise the queued expression }
           { finalise the queued expression }
-          ai:=tai_simpletypedconst.create(kind,def,p);
+          ai:=tai_simpletypedconst.create(def,p);
           { set the new index to -1, so we internalerror should we try to
           { set the new index to -1, so we internalerror should we try to
             add anything further }
             add anything further }
           update_queued_tai(def,ai,ai,-1);
           update_queued_tai(def,ai,ai,-1);
@@ -304,7 +301,7 @@ implementation
           fqueued_tai:=nil;
           fqueued_tai:=nil;
         end
         end
       else
       else
-        stc:=tai_simpletypedconst.create(tck_simple,def,p);
+        stc:=tai_simpletypedconst.create(def,p);
       info:=tllvmaggregateinformation(curagginfo);
       info:=tllvmaggregateinformation(curagginfo);
       { these elements can be aggregates themselves, e.g. a shortstring can
       { these elements can be aggregates themselves, e.g. a shortstring can
         be emitted as a series of bytes and string data arrays }
         be emitted as a series of bytes and string data arrays }
@@ -358,7 +355,7 @@ implementation
       fillbytes:=info.prepare_next_field(def);
       fillbytes:=info.prepare_next_field(def);
       while fillbytes>0 do
       while fillbytes>0 do
         begin
         begin
-          info.aggai.insertvaluebeforepos(tai_simpletypedconst.create(tck_simple,u8inttype,tai_const.create_8bit(0)),info.anonrecalignpos);
+          info.aggai.insertvaluebeforepos(tai_simpletypedconst.create(u8inttype,tai_const.create_8bit(0)),info.anonrecalignpos);
           dec(fillbytes);
           dec(fillbytes);
         end;
         end;
     end;
     end;

+ 7 - 0
compiler/pcp.pas

@@ -61,6 +61,7 @@ interface
       procedure newheader;override;
       procedure newheader;override;
       function readheader:longint;override;
       function readheader:longint;override;
       procedure resetfile;override;
       procedure resetfile;override;
+      procedure RaiseAssertion(Code: Longint); override;
     public
     public
       procedure writeheader;override;
       procedure writeheader;override;
       function checkpcpid:boolean;
       function checkpcpid:boolean;
@@ -84,6 +85,12 @@ uses
       result:=@header;
       result:=@header;
     end;
     end;
 
 
+  procedure tpcpfile.RaiseAssertion(Code: Longint);
+    begin
+      // InternalError(nb);
+      inherited RaiseAssertion(Code);
+    end;
+
   procedure tpcpfile.newheader;
   procedure tpcpfile.newheader;
     var
     var
       s : string;
       s : string;

+ 1 - 1
compiler/pdecsub.pas

@@ -2542,7 +2542,7 @@ const
       mutexclpo     : []
       mutexclpo     : []
     ),(
     ),(
       idtok:_INTERNPROC;
       idtok:_INTERNPROC;
-      pd_flags : [pd_interface,pd_notobject,pd_notobjintf,pd_notrecord,pd_nothelper];
+      pd_flags : [pd_interface,pd_implemen,pd_notobject,pd_notobjintf,pd_notrecord,pd_nothelper];
       handler  : @pd_internproc;
       handler  : @pd_internproc;
       pocall   : pocall_internproc;
       pocall   : pocall_internproc;
       pooption : [];
       pooption : [];

+ 6 - 0
compiler/symtype.pas

@@ -206,6 +206,8 @@ interface
          procedure putderef(const d:tderef);
          procedure putderef(const d:tderef);
          procedure putpropaccesslist(p:tpropaccesslist);
          procedure putpropaccesslist(p:tpropaccesslist);
          procedure putasmsymbol(s:tasmsymbol);
          procedure putasmsymbol(s:tasmsymbol);
+       protected
+         procedure RaiseAssertion(Code: Longint); override;
        end;
        end;
 
 
 {$ifdef MEMDEBUG}
 {$ifdef MEMDEBUG}
@@ -887,6 +889,10 @@ implementation
          Message(unit_f_ppu_read_error);
          Message(unit_f_ppu_read_error);
       end;
       end;
 
 
+    procedure tcompilerppufile.RaiseAssertion(Code: Longint);
+      begin
+        InternalError(Code);
+      end;
 
 
     procedure tcompilerppufile.getguid(var g: tguid);
     procedure tcompilerppufile.getguid(var g: tguid);
       begin
       begin

+ 3 - 1
compiler/systems.pas

@@ -165,7 +165,9 @@ interface
             tf_x86_far_procs_push_odd_bp,
             tf_x86_far_procs_push_odd_bp,
             { indicates that this target can use dynamic packages otherwise an
             { indicates that this target can use dynamic packages otherwise an
               error will be generated if a package file is compiled }
               error will be generated if a package file is compiled }
-            tf_supports_packages
+            tf_supports_packages,
+            { supports symbol order file (to ensure symbols in vectorised sections are kept in the correct order) }
+            tf_supports_symbolorderfile
        );
        );
 
 
        psysteminfo = ^tsysteminfo;
        psysteminfo = ^tsysteminfo;

+ 5 - 5
compiler/systems/i_bsd.pas

@@ -811,7 +811,7 @@ unit i_bsd;
             system       : system_i386_darwin;
             system       : system_i386_darwin;
             name         : 'Darwin for i386';
             name         : 'Darwin for i386';
             shortname    : 'Darwin';
             shortname    : 'Darwin';
-            flags        : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_uses_got,tf_pic_default,tf_has_winlike_resources];
+            flags        : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_uses_got,tf_pic_default,tf_has_winlike_resources,tf_supports_symbolorderfile];
             cpu          : cpu_i386;
             cpu          : cpu_i386;
             unit_env     : 'BSDUNITS';
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
             extradefines : 'UNIX;BSD;HASUNIX';
@@ -947,7 +947,7 @@ unit i_bsd;
             system       : system_powerpc64_darwin;
             system       : system_powerpc64_darwin;
             name         : 'Darwin for PowerPC64';
             name         : 'Darwin for PowerPC64';
             shortname    : 'Darwin';
             shortname    : 'Darwin';
-            flags        : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources];
+            flags        : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources,tf_supports_symbolorderfile];
             cpu          : cpu_powerpc64;
             cpu          : cpu_powerpc64;
             unit_env     : 'BSDUNITS';
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
             extradefines : 'UNIX;BSD;HASUNIX';
@@ -1015,7 +1015,7 @@ unit i_bsd;
             system       : system_x86_64_darwin;
             system       : system_x86_64_darwin;
             name         : 'Darwin for x86_64';
             name         : 'Darwin for x86_64';
             shortname    : 'Darwin';
             shortname    : 'Darwin';
-            flags        : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources];
+            flags        : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources,tf_supports_symbolorderfile];
             cpu          : cpu_x86_64;
             cpu          : cpu_x86_64;
             unit_env     : 'BSDUNITS';
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
             extradefines : 'UNIX;BSD;HASUNIX';
@@ -1149,7 +1149,7 @@ unit i_bsd;
             system       : system_arm_darwin;
             system       : system_arm_darwin;
             name         : 'Darwin for ARM';
             name         : 'Darwin for ARM';
             shortname    : 'Darwin';
             shortname    : 'Darwin';
-            flags        : [tf_p_ext_support,tf_requires_proper_alignment,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_has_winlike_resources,tf_pic_default];
+            flags        : [tf_p_ext_support,tf_requires_proper_alignment,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_has_winlike_resources,tf_pic_default,tf_supports_symbolorderfile];
             cpu          : cpu_arm;
             cpu          : cpu_arm;
             unit_env     : 'BSDUNITS';
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX;CPUARMEL';
             extradefines : 'UNIX;BSD;HASUNIX;CPUARMEL';
@@ -1217,7 +1217,7 @@ unit i_bsd;
             system       : system_aarch64_darwin;
             system       : system_aarch64_darwin;
             name         : 'Darwin for AArch64';
             name         : 'Darwin for AArch64';
             shortname    : 'Darwin';
             shortname    : 'Darwin';
-            flags        : [tf_p_ext_support,tf_requires_proper_alignment,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources];
+            flags        : [tf_p_ext_support,tf_requires_proper_alignment,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources,tf_supports_symbolorderfile];
             cpu          : cpu_aarch64;
             cpu          : cpu_aarch64;
             unit_env     : 'BSDUNITS';
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
             extradefines : 'UNIX;BSD;HASUNIX';

+ 65 - 9
compiler/systems/t_bsd.pas

@@ -66,6 +66,7 @@ implementation
       Function  WriteResponseFile(isdll:boolean) : Boolean;
       Function  WriteResponseFile(isdll:boolean) : Boolean;
       function GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
       function GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
       Function GetDarwinPrtobjName(isdll: boolean): TCmdStr;
       Function GetDarwinPrtobjName(isdll: boolean): TCmdStr;
+      Function WriteSymbolOrderFile: TCmdStr;
     public
     public
       constructor Create;override;
       constructor Create;override;
       procedure SetDefaultInfo;override;
       procedure SetDefaultInfo;override;
@@ -173,8 +174,8 @@ begin
        begin
        begin
          if not(target_info.system in systems_darwin) then
          if not(target_info.system in systems_darwin) then
            begin
            begin
-             ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -L. -o $EXE $CATRES $FILELIST';
-             DllCmd[1]:='ld $TARGET $EMUL $OPT $MAP -shared -L. -o $EXE $CATRES $FILELIST'
+             ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -L. -o $EXE $CATRES $FILELIST';
+             DllCmd[1]:='ld $TARGET $EMUL $OPT $MAP $ORDERSYMS -shared -L. -o $EXE $CATRES $FILELIST'
            end
            end
          else
          else
            begin
            begin
@@ -193,22 +194,22 @@ begin
                programs with problems that require Valgrind will have more
                programs with problems that require Valgrind will have more
                than 60KB of data (first 4KB of address space is always invalid)
                than 60KB of data (first 4KB of address space is always invalid)
              }
              }
-               ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
+               ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
              if not(cs_gdb_valgrind in current_settings.globalswitches) then
              if not(cs_gdb_valgrind in current_settings.globalswitches) then
                ExeCmd[1]:=ExeCmd[1]+' -pagezero_size 0x10000';
                ExeCmd[1]:=ExeCmd[1]+' -pagezero_size 0x10000';
 {$else ndef cpu64bitaddr}
 {$else ndef cpu64bitaddr}
-             ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
+             ExeCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST';
 {$endif ndef cpu64bitaddr}
 {$endif ndef cpu64bitaddr}
              if (apptype<>app_bundle) then
              if (apptype<>app_bundle) then
-               DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP -dynamic -dylib -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
+               DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP $ORDERSYMS -dynamic -dylib -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
              else
              else
-               DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP -dynamic -bundle -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
+               DllCmd[1]:='ld $PRTOBJ $TARGET $EMUL $OPT $GCSECTIONS $MAP $ORDERSYMS -dynamic -bundle -multiply_defined suppress -L. -o $EXE $CATRES $FILELIST'
            end
            end
        end
        end
      else
      else
        begin
        begin
-         ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC  $GCSECTIONS $STRIP $MAP -L. -o $EXE $RES';
-         DllCmd[1]:='ld $TARGET $EMUL $OPT $INIT $FINI $SONAME $MAP -shared -L. -o $EXE $RES';
+         ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP $MAP $ORDERSYMS -L. -o $EXE $RES';
+         DllCmd[1]:='ld $TARGET $EMUL $OPT $INIT $FINI $SONAME $MAP $ORDERSYMS -shared -L. -o $EXE $RES';
        end;
        end;
      if not(target_info.system in systems_darwin) then
      if not(target_info.system in systems_darwin) then
        DllCmd[2]:='strip --strip-unneeded $EXE'
        DllCmd[2]:='strip --strip-unneeded $EXE'
@@ -467,6 +468,30 @@ begin
 end;
 end;
 
 
 
 
+function tlinkerbsd.WriteSymbolOrderFile: TCmdStr;
+  var
+    item: TCmdStrListItem;
+    symfile: TScript;
+  begin
+    result:='';
+    { only for darwin for now; can also enable for other platforms when using
+      the LLVM linker }
+    if (OrderedSymbols.Empty) or
+       not(tf_supports_symbolorderfile in target_info.flags) then
+      exit;
+    symfile:=TScript.Create(outputexedir+'symbol_order.fpc');
+    item:=TCmdStrListItem(OrderedSymbols.First);
+    while assigned(item) do
+      begin
+        symfile.add(item.str);
+        item:=TCmdStrListItem(item.next);
+      end;
+    symfile.WriteToDisk;
+    result:=symfile.fn;
+    symfile.Free;
+  end;
+
+
 Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
 Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
 Var
 Var
   linkres      : TLinkRes;
   linkres      : TLinkRes;
@@ -777,7 +802,8 @@ var
   targetstr,
   targetstr,
   emulstr,
   emulstr,
   extdbgbinstr,
   extdbgbinstr,
-  extdbgcmdstr: TCmdStr;
+  extdbgcmdstr,
+  ordersymfile: TCmdStr;
   linkscript: TAsmScript;
   linkscript: TAsmScript;
   DynLinkStr : string[60];
   DynLinkStr : string[60];
   GCSectionsStr,
   GCSectionsStr,
@@ -861,6 +887,9 @@ begin
 { Write used files and libraries }
 { Write used files and libraries }
   WriteResponseFile(false);
   WriteResponseFile(false);
 
 
+{ Write symbol order file }
+  ordersymfile:=WriteSymbolOrderFile;
+
 { Call linker }
 { Call linker }
   SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
   SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
   Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
   Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
@@ -870,6 +899,16 @@ begin
   Replace(cmdstr,'$MAP',mapstr);
   Replace(cmdstr,'$MAP',mapstr);
   Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
   Replace(cmdstr,'$CATRES',CatFileContent(outputexedir+Info.ResName));
   Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
   Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
+  if ordersymfile<>'' then
+    begin
+      if target_info.system in systems_darwin then
+        Replace(cmdstr,'$ORDERSYMS','-order_file '+maybequoted(ordersymfile))
+      else
+        Replace(cmdstr,'$ORDERSYMS','--symbol-ordering-file '+maybequoted(ordersymfile))
+    end
+  else
+    Replace(cmdstr,'$ORDERSYMS','');
+
   if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
   if (LdSupportsNoResponseFile) and (source_info.system in systems_all_windows) then
     Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
     Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
   else
   else
@@ -922,6 +961,8 @@ begin
   if (success) and not(cs_link_nolink in current_settings.globalswitches) then
   if (success) and not(cs_link_nolink in current_settings.globalswitches) then
    begin
    begin
      DeleteFile(outputexedir+Info.ResName);
      DeleteFile(outputexedir+Info.ResName);
+     if ordersymfile<>'' then
+       DeleteFile(ordersymfile);
      if LdSupportsNoResponseFile Then
      if LdSupportsNoResponseFile Then
        begin
        begin
          DeleteFile(linkscript.fn);
          DeleteFile(linkscript.fn);
@@ -946,6 +987,7 @@ var
   binstr,
   binstr,
   cmdstr,
   cmdstr,
   mapstr,
   mapstr,
+  ordersymfile,
   targetstr,
   targetstr,
   emulstr,
   emulstr,
   extdbgbinstr,
   extdbgbinstr,
@@ -964,6 +1006,9 @@ begin
 { Write used files and libraries }
 { Write used files and libraries }
   WriteResponseFile(true);
   WriteResponseFile(true);
 
 
+{ Write symbol order file }
+  ordersymfile:=WriteSymbolOrderFile;
+
   if (cs_link_smart in current_settings.globalswitches) and
   if (cs_link_smart in current_settings.globalswitches) and
      (tf_smartlink_sections in target_info.flags) then
      (tf_smartlink_sections in target_info.flags) then
     if not(target_info.system in systems_darwin) then
     if not(target_info.system in systems_darwin) then
@@ -1014,6 +1059,15 @@ begin
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$SONAME',SoNameStr);
   Replace(cmdstr,'$SONAME',SoNameStr);
   Replace(cmdstr,'$MAP',mapstr);
   Replace(cmdstr,'$MAP',mapstr);
+  if ordersymfile<>'' then
+    begin
+      if target_info.system in systems_darwin then
+        Replace(cmdstr,'$ORDERSYMS','-order_file '+maybequoted(ordersymfile))
+      else
+        Replace(cmdstr,'$ORDERSYMS','--symbol-ordering-file '+maybequoted(ordersymfile))
+    end
+  else
+    Replace(cmdstr,'$ORDERSYMS','');
   if (target_info.system in systems_darwin) then
   if (target_info.system in systems_darwin) then
     Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
     Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
   BinStr:=FindUtil(utilsprefix+BinStr);
   BinStr:=FindUtil(utilsprefix+BinStr);
@@ -1080,6 +1134,8 @@ begin
   if (success) and not(cs_link_nolink in current_settings.globalswitches) then
   if (success) and not(cs_link_nolink in current_settings.globalswitches) then
     begin
     begin
       DeleteFile(outputexedir+Info.ResName);
       DeleteFile(outputexedir+Info.ResName);
+      if ordersymfile<>'' then
+        DeleteFile(ordersymfile);
       if LdSupportsNoResponseFile Then
       if LdSupportsNoResponseFile Then
         begin
         begin
           DeleteFile(linkscript.fn);
           DeleteFile(linkscript.fn);

+ 20 - 4
compiler/utils/ppuutils/ppudump.pp

@@ -215,8 +215,14 @@ type
     ModuleFlags: tmoduleflags;
     ModuleFlags: tmoduleflags;
   end;
   end;
 
 
+type
+  tppudumpfile = class(tppufile)
+  protected
+    procedure RaiseAssertion(Code: Longint); override;
+  end;
+
 var
 var
-  ppufile     : tppufile;
+  ppufile     : tppudumpfile;
   ppuversion  : dword;
   ppuversion  : dword;
   space       : string;
   space       : string;
   verbose     : longint;
   verbose     : longint;
@@ -334,6 +340,12 @@ Begin
   SetHasErrors;
   SetHasErrors;
 End;
 End;
 
 
+procedure tppudumpfile.RaiseAssertion(Code: Longint);
+begin
+  WriteError('Internal Error ' + ToStr(Code));
+  inherited RaiseAssertion(Code);
+end;
+
 Procedure WriteWarning(const S : string);
 Procedure WriteWarning(const S : string);
 var
 var
   ss: string;
   ss: string;
@@ -763,7 +775,7 @@ end;
 
 
 Procedure ReadContainer(const prefix:string);
 Procedure ReadContainer(const prefix:string);
 {
 {
-  Read a serie of strings and write to the screen starting every line
+  Read a series of strings and write to the screen starting every line
   with prefix
   with prefix
 }
 }
 begin
 begin
@@ -3826,7 +3838,11 @@ begin
 
 
          ibresources :
          ibresources :
            if not silent then
            if not silent then
-             ReadLinkContainer('Resource file: ');
+             ReadContainer('Resource file: ');
+
+         iborderedsymbols:
+           if not silent then
+             ReadContainer('Ordered symbol: ');
 
 
          iberror :
          iberror :
            begin
            begin
@@ -3912,7 +3928,7 @@ begin
 { fix filename }
 { fix filename }
   if pos('.',filename)=0 then
   if pos('.',filename)=0 then
    filename:=filename+'.ppu';
    filename:=filename+'.ppu';
-  ppufile:=tppufile.create(filename);
+  ppufile:=tppudumpfile.create(filename);
   if not ppufile.openfile then
   if not ppufile.openfile then
    begin
    begin
      WriteError('IO-Error when opening : '+filename+', Skipping');
      WriteError('IO-Error when opening : '+filename+', Skipping');

+ 8 - 9
packages/amunits/src/coreunits/agraphics.pas

@@ -134,7 +134,6 @@ type
         _p1,
         _p1,
         _p2     : Pointer;    { system reserved }
         _p2     : Pointer;    { system reserved }
         reserved : Longint;     { system use }
         reserved : Longint;     { system use }
-        Flags   : Longint;      { only exists in layer allocation }
     end;
     end;
 
 
     pLayer = ^tLayer;
     pLayer = ^tLayer;
@@ -158,7 +157,7 @@ type
         cr2,
         cr2,
         crnew           : pClipRect;  { used by dedice }
         crnew           : pClipRect;  { used by dedice }
         SuperSaveClipRects : pClipRect; { preallocated cr's }
         SuperSaveClipRects : pClipRect; { preallocated cr's }
-        cliprects      : pClipRect;  { system use during refresh }
+        _cliprects      : pClipRect;  { system use during refresh }
         LayerInfo       : Pointer;      { points to head of the list }
         LayerInfo       : Pointer;      { points to head of the list }
         Lock            : tSignalSemaphore;
         Lock            : tSignalSemaphore;
         BackFill        : pHook;
         BackFill        : pHook;
@@ -391,8 +390,8 @@ type
     pCopList = ^tCopList;
     pCopList = ^tCopList;
     tCopList = record
     tCopList = record
         Next    : pCopList;     { next block for this copper list }
         Next    : pCopList;     { next block for this copper list }
-        CopList : pCopList;    { system use }
-        ViewPort : Pointer;    { system use }
+        _CopList : pCopList;    { system use }
+        _ViewPort : Pointer;    { system use }
         CopIns  : pCopIns;    { start of this block }
         CopIns  : pCopIns;    { start of this block }
         CopPtr  : pCopIns;    { intermediate ptr }
         CopPtr  : pCopIns;    { intermediate ptr }
         CopLStart : psmallint;     { mrgcop fills this in for Long Frame}
         CopLStart : psmallint;     { mrgcop fills this in for Long Frame}
@@ -418,8 +417,8 @@ type
         fm0      : array [0..1] of word;
         fm0      : array [0..1] of word;
         diwstart : array [0..9] of word;
         diwstart : array [0..9] of word;
         bplcon2  : array [0..1] of word;
         bplcon2  : array [0..1] of word;
-        sprfix   : array [0..(2*8)] of word;
-        sprstrtup : Array [0..(2*8*2)] of Word;
+        sprfix   : array [0..(2*8-1)] of word;
+        sprstrtup : Array [0..(2*8*2-1)] of Word;
         wait14    : array [0..1] of word;
         wait14    : array [0..1] of word;
         norm_hblank : array [0..1] of word;
         norm_hblank : array [0..1] of word;
         jump        : array [0..1] of word;
         jump        : array [0..1] of word;
@@ -1147,7 +1146,7 @@ Type
     pColorMap = ^tColorMap;
     pColorMap = ^tColorMap;
     tColorMap = record
     tColorMap = record
         Flags   : Byte;
         Flags   : Byte;
-        CType   : Byte;         { This is "Type" in C includes }
+        Type_   : Byte;         { This is "Type" in C includes }
         Count   : Word;
         Count   : Word;
         ColorTable      : Pointer;
         ColorTable      : Pointer;
         cm_vpe  : pViewPortExtra;
         cm_vpe  : pViewPortExtra;
@@ -1739,7 +1738,7 @@ Type
 
 
   pQueryHeader = ^tQueryHeader;
   pQueryHeader = ^tQueryHeader;
   tQueryHeader = record
   tQueryHeader = record
-   tructID,                    { datachunk type identifier }
+   StructID,                    { datachunk type identifier }
    DisplayID,                  { copy of display record key   }
    DisplayID,                  { copy of display record key   }
    SkipID,                     { TAG_SKIP -- see tagitems.h }
    SkipID,                     { TAG_SKIP -- see tagitems.h }
    Length  :  ULONG;         { length of local data in double-longwords }
    Length  :  ULONG;         { length of local data in double-longwords }
@@ -1878,7 +1877,7 @@ Type
         Header  : tQueryHeader;
         Header  : tQueryHeader;
         Vec     : Pointer;
         Vec     : Pointer;
         Data    : Pointer;
         Data    : Pointer;
-        vi_Type : WORD;               { Type in C Includes }
+        Type_ : WORD;               { Type in C Includes }
         pad     : Array[0..2] of WORD;
         pad     : Array[0..2] of WORD;
         reserved : Array[0..1] of ULONG;
         reserved : Array[0..1] of ULONG;
  end;
  end;

+ 1 - 1
packages/amunits/src/coreunits/clipboard.pas

@@ -13,7 +13,7 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 
  **********************************************************************}
  **********************************************************************}
-
+{$PACKRECORDS 2}
 unit clipboard;
 unit clipboard;
 
 
 INTERFACE
 INTERFACE

+ 4 - 4
packages/amunits/src/coreunits/intuition.pas

@@ -2433,7 +2433,7 @@ Type
         ViewInitX,
         ViewInitX,
         ViewInitY       : smallint;        { View initial offset values      }
         ViewInitY       : smallint;        { View initial offset values      }
 
 
-        EnableCLI       : Boolean;      { CLI availability switch }
+        EnableCLI       : WordBool;      { CLI availability switch }
 
 
     { printer configurations }
     { printer configurations }
         PrinterType     : Word;        { printer type                     }
         PrinterType     : Word;        { printer type                     }
@@ -3905,8 +3905,8 @@ Type
    pSGWork = ^tSGWork;
    pSGWork = ^tSGWork;
    tSGWork = record
    tSGWork = record
     { set up when gadget is first activated    }
     { set up when gadget is first activated    }
-    Gad       : pGadget;         { the contestant itself        }   { Gadget in C-Includes }
-    StrInfo   : pStringInfo;     { easy access to sinfo         }   { StrInfo in C-Includes }
+    Gadget     : pGadget;         { the contestant itself        }   { Gadget in C-Includes }
+    StringInfo : pStringInfo;     { easy access to sinfo         }   { StrInfo in C-Includes }
     WorkBuffer : STRPTR;           { intuition's planned result   }
     WorkBuffer : STRPTR;           { intuition's planned result   }
     PrevBuffer : STRPTR;           { what was there before        }
     PrevBuffer : STRPTR;           { what was there before        }
     Modes      : ULONG;          { current mode                 }
     Modes      : ULONG;          { current mode                 }
@@ -3919,7 +3919,7 @@ Type
     Actions    : ULONG;          { what Intuition will do       }
     Actions    : ULONG;          { what Intuition will do       }
     LongInt_   : Longint;          { temp storage for longint     }
     LongInt_   : Longint;          { temp storage for longint     }
 
 
-    GInfo      : pGadgetInfo;    { see cghooks.h                }   { GadgetInfo in C-Includes }
+    GadgetInfo      : pGadgetInfo;    { see cghooks.h                }   { GadgetInfo in C-Includes }
     EditOp     : Word;            { from constants below         }
     EditOp     : Word;            { from constants below         }
    END;
    END;
 
 

+ 13 - 13
packages/arosunits/src/agraphics.pas

@@ -341,7 +341,7 @@ type
    // SYSTEM VARIABLES
    // SYSTEM VARIABLES
     NextVSprite: PVSprite; // GEL linked list forward/backward pointers sorted by y,x value
     NextVSprite: PVSprite; // GEL linked list forward/backward pointers sorted by y,x value
     PrevVSprite: PVSprite;
     PrevVSprite: PVSprite;
-    DrawPath: PVSprite;    // pointer of overlay drawing
+    IntVSprite: PVSprite;    // pointer of overlay drawing
     ClearPath: PVSprite;   // pointer for overlay clearing
     ClearPath: PVSprite;   // pointer for overlay clearing
     OldY, OldX: SmallInt;  // previous position
     OldY, OldX: SmallInt;  // previous position
    // COMMON VARIABLES
    // COMMON VARIABLES
@@ -564,10 +564,10 @@ type
   PShapeHookMsg = ^TShapeHookMsg;
   PShapeHookMsg = ^TShapeHookMsg;
   TShapeHookMsg = record
   TShapeHookMsg = record
     Action: LongInt;
     Action: LongInt;
-    Layer: PLayer;
-    ActualShape: PRegion;
-    NewBounds: TRectangle;
-    OldBounds: TRectangle;
+    NewShape: PRegion;
+    OldShape: PRegion;
+    NewBounds: PRectangle;
+    OldBounds: PRectangle;
   end;
   end;
   // Hook for getting LA_ShapeHook and getting this Msg
   // Hook for getting LA_ShapeHook and getting this Msg
   TShapeHookProc = function(Hook: PHook; Layer: PLayer; Msg: PShapeHookMsg): PRegion; cdecl;
   TShapeHookProc = function(Hook: PHook; Layer: PLayer; Msg: PShapeHookMsg): PRegion; cdecl;
@@ -990,19 +990,19 @@ type
   // Copper structures
   // Copper structures
   PCopIns = ^TCopIns;
   PCopIns = ^TCopIns;
   TCopIns = record
   TCopIns = record
-    OpCode  : smallint; // 0 = move, 1 = wait
+    OpCode: smallint; // 0 = move, 1 = wait
     case SmallInt of
     case SmallInt of
     0:(
     0:(
       NxtList: PCopList;
       NxtList: PCopList;
       );
       );
     1:(
     1:(
-      VWaitPos: SmallInt; // vertical wait position
       DestAddr: SmallInt; // destination Pointer
       DestAddr: SmallInt; // destination Pointer
+      DestData: SmallInt; // data to send      
       );
       );
     2:(
     2:(
-      HWaitPos: SmallInt; // horizontal wait position
-      DestData: SmallInt; // data to send
-      );
+      VWaitPos: SmallInt; // vertical wait position
+      HWaitPos: SmallInt; // horizontal wait position      
+      );  
   end;
   end;
 
 
   TCopList = record
   TCopList = record
@@ -1994,9 +1994,9 @@ type
     VBCounter: ULONG;
     VBCounter: ULONG;
 
 
     HashTableSemaphore: PSignalSemaphore;  // Semaphore for hash_table access, private in fact
     HashTableSemaphore: PSignalSemaphore;  // Semaphore for hash_table access, private in fact
-
-    ChunkyToPlanarPtr: PLongWord;  // HWEmul[0];
-    HWEmul: array[1..8] of PLongWord;
+    case boolean of
+      true: ( ChunkyToPlanarPtr: PLongWord;);  // HWEmul[0];
+      false: (HWEmul: array[0..8] of PLongWord;);
   end;
   end;
 
 
 type
 type

+ 2 - 43
packages/arosunits/src/amigados.pas

@@ -848,12 +848,6 @@ type
     dl_DiskType: LongInt; // 'DOS', etc
     dl_DiskType: LongInt; // 'DOS', etc
     dl_unused: BPTR;
     dl_unused: BPTR;
     dl_Name: BSTR;        // bptr to bcpl name
     dl_Name: BSTR;        // bptr to bcpl name
-{$ifdef aros}
-  {$ifndef AROS_DOS_PACKETS}
-    dl_Reserved: array[0..5] of IPTR;
-    dl_AROS: TDosListAROSExt;
-  {$endif}
-{$endif}
   end;
   end;
 
 
 { device structure (same as the DeviceNode structure in filehandler.h) }
 { device structure (same as the DeviceNode structure in filehandler.h) }
@@ -874,12 +868,6 @@ type
     dvi_GlobVec: BSTR;
     dvi_GlobVec: BSTR;
 {$endif}
 {$endif}
     dvi_Name: BSTR;
     dvi_Name: BSTR;
-{$ifdef aros}
-  {$ifndef AROS_DOS_PACKETS}
-    dvi_Reserved: array[0..5] of IPTR;
-    dvi_AROS: TDosListAROSExt;
-  {$endif}
-{$endif}
   end;
   end;
 
 
 const
 const
@@ -1165,12 +1153,6 @@ type
                              * vector for you.
                              * vector for you.
                              }
                              }
     dn_Name: BSTR;         { the node name, e.g. '\3','D','F','3' }
     dn_Name: BSTR;         { the node name, e.g. '\3','D','F','3' }
-{$ifdef aros}
-  {$ifndef AROS_DOS_PACKETS}
-    dn_Reserved: array[0..5] of IPTR;  // Private extensions Should not be used in user land code.
-    dn_AROS: TDosListAROSExt;
-  {$endif}
-{$endif}
   end;
   end;
 
 
 type
 type
@@ -1518,39 +1500,16 @@ type
   TDosLibrary = record
   TDosLibrary = record
     dl_lib: TLibrary;
     dl_lib: TLibrary;
     dl_Root: PRootNode;      // Pointer to RootNode, described below }
     dl_Root: PRootNode;      // Pointer to RootNode, described below }
-{$ifdef AROS_BINCOMPAT}
+
     dl_GV: APTR;             // Pointer to BCPL global vector       }
     dl_GV: APTR;             // Pointer to BCPL global vector       }
     dl_A2: LongInt;          // Private register dump of DOS        }
     dl_A2: LongInt;          // Private register dump of DOS        }
     dl_A5: LongInt;
     dl_A5: LongInt;
     dl_A6: LongInt;
     dl_A6: LongInt;
-{$endif}
+
     dl_Errors: PErrorString;    // pointer to array of error msgs
     dl_Errors: PErrorString;    // pointer to array of error msgs
     dl_TimeReq: PTimeRequest;   // private pointer to timer request
     dl_TimeReq: PTimeRequest;   // private pointer to timer request
     dl_UtilityBase  : PLibrary; // private ptr to utility library
     dl_UtilityBase  : PLibrary; // private ptr to utility library
     dl_IntuitionBase : PLibrary;
     dl_IntuitionBase : PLibrary;
-{ These were AROS-specific private fields. At the moment they are mostly not used
-  and are present only for binary compatibility with programs that used dl_Flags
-  (Directory Opus for example). Do not try to use them in any way!}
-{$ifdef aros}
-    dl_TimerBase: PDevice;
-    dl_TimerIO: TTimeRequest;
-    dl_DevInfo: PDosList;
-    dl_SysBase: PExecBase;
-    dl_SegList: BPTR;
-    dl_NulHandler: PDevice;
-    dl_NulLock: PUnit;
-  // LDDemon (library loader) private data
-    dl_LDObjectsListSigSem: TSignalSemaphore;
-    dl_LDObjectsList: TList;
-    dl_LDHandler: TInterrupt;
-    dl_LDDemonPort: PMsgPort;
-    dl_LDDemonTask: PProcess;
-    dl_LDReturn: ULONG;
-    //* AROS-specific and private. Can go away in future.
-    dl_SYSLock: BPTR;
-    // The flags are ORed with RootNode^.rn_Flags. See below for definitions.
-    dl_Flags: ULONG;
-{$endif}
   end;
   end;
 
 
 const
 const

+ 1 - 1
packages/arosunits/src/datatypes.pas

@@ -781,8 +781,8 @@ type
   TAnimHeader = record
   TAnimHeader = record
     ah_Operation: Byte;
     ah_Operation: Byte;
     ah_Mask: Byte;
     ah_Mask: Byte;
-    ah_Height: Word;
     ah_Width: Word;
     ah_Width: Word;
+    ah_Height: Word;    
     ah_Left: SmallInt;
     ah_Left: SmallInt;
     ah_Top: SmallInt;
     ah_Top: SmallInt;
     ah_AbsTime: LongWord;
     ah_AbsTime: LongWord;

+ 4 - 4
packages/arosunits/src/intuition.pas

@@ -1471,7 +1471,7 @@ type
     ViewInitX,
     ViewInitX,
     ViewInitY: SmallInt;   // View initial offset values
     ViewInitY: SmallInt;   // View initial offset values
 
 
-    EnableCLI: LongBool;   // CLI availability switch
+    EnableCLI: WordBool;   // CLI availability switch
 
 
   // printer configurations
   // printer configurations
     PrinterType: Word;     // printer type
     PrinterType: Word;     // printer type
@@ -1663,11 +1663,11 @@ type
                             Screens are then maintained in a front to back order using Screen.NextScreen  }
                             Screens are then maintained in a front to back order using Screen.NextScreen  }
     Flags: LongWord;      // see definitions below
     Flags: LongWord;      // see definitions below
 {$ifdef AROS_BINCOMPAT}
 {$ifdef AROS_BINCOMPAT}
-    MouseX,
-    MouseY: SmallInt;      // mouse position relative to View
-{$else}
     MouseY,
     MouseY,
     MouseX: SmallInt;      // mouse position relative to View
     MouseX: SmallInt;      // mouse position relative to View
+{$else}
+    MouseX,
+    MouseY: SmallInt;      // mouse position relative to View
 {$endif}
 {$endif}
 
 
     Seconds: LongWord;     // timestamp of most current input event
     Seconds: LongWord;     // timestamp of most current input event

+ 0 - 1
packages/arosunits/src/locale.pas

@@ -12,7 +12,6 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 
  **********************************************************************}
  **********************************************************************}
-{$PACKRECORDS 2}
 
 
 unit locale;
 unit locale;
 
 

+ 0 - 1
packages/arosunits/src/serial.pas

@@ -17,7 +17,6 @@
 unit serial;
 unit serial;
 
 
 interface
 interface
-{$PACKRECORDS 2}
 
 
 uses
 uses
   exec;
   exec;

+ 6 - 4
packages/arosunits/src/workbench.pas

@@ -237,7 +237,7 @@ type
     ism_Drawer: BPTR;          // Lock on the drawer this object resides in, NULL for Workbench backdrop (devices).
     ism_Drawer: BPTR;          // Lock on the drawer this object resides in, NULL for Workbench backdrop (devices).
     ism_Name: STRPTR;          // Name of the object in question.
     ism_Name: STRPTR;          // Name of the object in question.
     ism_type: Word;            // One of WBDISK, WBDRAWER, WBTOOL, WBPROJECT, WBGARBAGE, WBDEVICE, WBKICK or WBAPPICON.
     ism_type: Word;            // One of WBDISK, WBDRAWER, WBTOOL, WBPROJECT, WBGARBAGE, WBDEVICE, WBKICK or WBAPPICON.
-    ism_Selected: LongBool;    // TRUE if currently selected, FALSE otherwise.
+    ism_Selected: WordBool;    // TRUE if currently selected, FALSE otherwise.
     ism_Tags: PTagItem;        // Pointer to the list of tag items passed to ChangeWorkbenchSelectionA().
     ism_Tags: PTagItem;        // Pointer to the list of tag items passed to ChangeWorkbenchSelectionA().
     ism_DrawerWindow: PWindow; // Pointer to the window attached to this icon, if the icon is a drawer-like object.
     ism_DrawerWindow: PWindow; // Pointer to the window attached to this icon, if the icon is a drawer-like object.
     ism_ParentWindow: PWindow; // Pointer to the window the icon resides in.
     ism_ParentWindow: PWindow; // Pointer to the window the icon resides in.
@@ -536,20 +536,22 @@ type
   TWBHandlerMessage = record
   TWBHandlerMessage = record
     wbhm_Message: TMessage; // Standard message structure.
     wbhm_Message: TMessage; // Standard message structure.
     wbhm_type: TWBHM_type;  // type of message.
     wbhm_type: TWBHM_type;  // type of message.
+    wbhm_Data: record
     case integer of
     case integer of
     0 :
     0 :
     (
     (
       Open: record
       Open: record
-        OpenName: STRPTR;   // Name of the drawer.
+        Name: STRPTR;   // Name of the drawer.
       end;
       end;
     );
     );
     1 :
     1 :
     (
     (
       Update: record
       Update: record
-        UpdateName: STRPTR;  // Mame of the object.
-        Updatetype: LongInt; // type of object (WBDRAWER, WBPROJECT, ...).
+        Name: STRPTR;  // Mame of the object.
+        Type_: LongInt; // type of object (WBDRAWER, WBPROJECT, ...).
       end;
       end;
     );
     );
+    end;
   end;
   end;
 
 
 
 

+ 6 - 9
packages/fcl-db/src/sqldb/odbc/odbcconn.pas

@@ -939,7 +939,7 @@ begin
                      ColNameDefaultLength+1, // and its length; we include the #0 terminating any ansistring of Length > 0 in the buffer
                      ColNameDefaultLength+1, // and its length; we include the #0 terminating any ansistring of Length > 0 in the buffer
                      ColNameLength,          // actual column name length
                      ColNameLength,          // actual column name length
                      DataType,               // the SQL datatype for the column
                      DataType,               // the SQL datatype for the column
-                     ColumnSize,             // column size
+                     ColumnSize,             // column size (in characters)
                      DecimalDigits,          // number of decimal digits
                      DecimalDigits,          // number of decimal digits
                      Nullable),              // SQL_NO_NULLS, SQL_NULLABLE or SQL_NULLABLE_UNKNOWN
                      Nullable),              // SQL_NO_NULLS, SQL_NULLABLE or SQL_NULLABLE_UNKNOWN
       SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get column properties for column %d.',[i]
       SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get column properties for column %d.',[i]
@@ -969,8 +969,8 @@ begin
       SQL_CHAR:          begin FieldType:=ftFixedChar;  FieldSize:=ColumnSize; end;
       SQL_CHAR:          begin FieldType:=ftFixedChar;  FieldSize:=ColumnSize; end;
       SQL_VARCHAR:       begin FieldType:=ftString;     FieldSize:=ColumnSize; end;
       SQL_VARCHAR:       begin FieldType:=ftString;     FieldSize:=ColumnSize; end;
       SQL_LONGVARCHAR:   begin FieldType:=ftMemo;       FieldSize:=BLOB_BUF_SIZE; end; // is a blob
       SQL_LONGVARCHAR:   begin FieldType:=ftMemo;       FieldSize:=BLOB_BUF_SIZE; end; // is a blob
-      SQL_WCHAR:         begin FieldType:=ftFixedWideChar; FieldSize:=ColumnSize*sizeof(Widechar); end;
-      SQL_WVARCHAR:      begin FieldType:=ftWideString; FieldSize:=ColumnSize*sizeof(Widechar); end;
+      SQL_WCHAR:         begin FieldType:=ftFixedWideChar; FieldSize:=ColumnSize; end;
+      SQL_WVARCHAR:      begin FieldType:=ftWideString; FieldSize:=ColumnSize; end;
       SQL_SS_XML,
       SQL_SS_XML,
       SQL_WLONGVARCHAR:  begin FieldType:=ftWideMemo;   FieldSize:=BLOB_BUF_SIZE; end; // is a blob
       SQL_WLONGVARCHAR:  begin FieldType:=ftWideMemo;   FieldSize:=BLOB_BUF_SIZE; end; // is a blob
       SQL_DECIMAL:       begin FieldType:=ftFloat;      FieldSize:=0; end;
       SQL_DECIMAL:       begin FieldType:=ftFloat;      FieldSize:=0; end;
@@ -1120,10 +1120,7 @@ begin
     end;
     end;
 
 
     // add FieldDef
     // add FieldDef
-    with FieldDefs.Add(FieldDefs.MakeNameUnique(ColName), FieldType, FieldSize, (Nullable=SQL_NO_NULLS) and (AutoIncAttr=SQL_FALSE), i) do
-    begin
-      if Updatable = SQL_ATTR_READONLY then Attributes := Attributes + [faReadonly];
-    end;
+    AddFieldDef(FieldDefs, i, ColName, FieldType, FieldSize, -1, False, (Nullable=SQL_NO_NULLS) and (AutoIncAttr=SQL_FALSE), Updatable=SQL_ATTR_READONLY);
   end;
   end;
 end;
 end;
 
 
@@ -1166,9 +1163,9 @@ begin
   // TODO: finish this
   // TODO: finish this
   case FieldDef.DataType of
   case FieldDef.DataType of
     ftWideString,ftFixedWideChar: // mapped to TWideStringField
     ftWideString,ftFixedWideChar: // mapped to TWideStringField
-      Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_WCHAR, buffer, FieldDef.Size+sizeof(WideChar), @StrLenOrInd); //buffer must contain space for the null-termination character
+      Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_WCHAR, buffer, FieldDef.Size*FieldDef.CharSize+sizeof(WideChar), @StrLenOrInd); //buffer must contain space for the null-termination character
     ftGuid, ftFixedChar,ftString: // are mapped to a TStringField (including TGuidField)
     ftGuid, ftFixedChar,ftString: // are mapped to a TStringField (including TGuidField)
-      Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_CHAR, buffer, FieldDef.Size+1, @StrLenOrInd);
+      Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_CHAR, buffer, FieldDef.Size*FieldDef.CharSize+1, @StrLenOrInd);
     ftSmallint:           // mapped to TSmallintField
     ftSmallint:           // mapped to TSmallintField
       Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_SSHORT, buffer, SizeOf(Smallint), @StrLenOrInd);
       Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_SSHORT, buffer, SizeOf(Smallint), @StrLenOrInd);
     ftInteger,ftAutoInc:  // mapped to TLongintField
     ftInteger,ftAutoInc:  // mapped to TLongintField

+ 14 - 10
packages/fcl-registry/src/winreg.inc

@@ -42,6 +42,17 @@ begin
   Result:=(S='') or (S[1]<>'\')
   Result:=(S='') or (S[1]<>'\')
 end;
 end;
 
 
+function RegDataWordToRegDataType(RD: DWORD): TRegDataType;
+begin
+  // Test in ascending because rdString is most commonly used
+  Result := Succ(Low(RegDataWords));
+  repeat
+    if RegDataWords[Result] = RD then
+      Exit;
+    Inc(Result);
+  until Result > High(Result);
+  Result := Low(RegDataWords);
+end;
 
 
 function TRegistry.sysCreateKey(Key: UnicodeString): Boolean;
 function TRegistry.sysCreateKey(Key: UnicodeString): Boolean;
 Var
 Var
@@ -95,9 +106,7 @@ begin
     Result:=-1
     Result:=-1
   else
   else
     begin
     begin
-    RegData:=High(TRegDataType);
-    While (RegData>rdUnknown) and (RD<>RegDataWords[RegData]) do
-      RegData:=Pred(RegData);
+    RegData:=RegDataWordToRegDataType(RD);
     Result:=BufSize;
     Result:=BufSize;
     end;
     end;
 end;
 end;
@@ -110,15 +119,10 @@ Var
 begin
 begin
   With Value do
   With Value do
     begin
     begin
-    FLastError:=RegQueryValueExW(fCurrentKey,PWideChar(ValueName),Nil,lpdword(@RegData),Nil,lpdword(@DataSize));
+    FLastError:=RegQueryValueExW(fCurrentKey,PWideChar(ValueName),Nil,@RD,Nil,lpdword(@DataSize));
     Result:=FLastError=ERROR_SUCCESS;
     Result:=FLastError=ERROR_SUCCESS;
     if Result then
     if Result then
-      begin
-      RD:=DWord(RegData);
-      RegData:=High(TRegDataType);
-      While (RegData>rdUnknown) and (RD<>RegDataWords[RegData]) do
-         RegData:=Pred(RegData);
-      end;
+      RegData:=RegDataWordToRegDataType(RD);
     end;
     end;
   If Not Result Then
   If Not Result Then
     begin
     begin

+ 2 - 1
packages/fcl-web/src/base/fphttpclient.pp

@@ -1480,7 +1480,8 @@ begin
     301,
     301,
     302,
     302,
     303,
     303,
-    307,808 : Result:=True;
+    307,
+    308 : Result:=True;
   else
   else
     Result:=False;
     Result:=False;
   end;
   end;

+ 2 - 2
packages/fcl-web/src/base/restbase.pp

@@ -717,7 +717,7 @@ begin
         TStringArray(AP)[I]:=AValue.Strings[i];
         TStringArray(AP)[I]:=AValue.Strings[i];
         end;
         end;
     else
     else
-      Raise ERESTAPI.CreateFmt('%s: unsupported array element type : ',[ClassName,GetEnumName(TypeInfo(TTypeKind),Ord(ET^.Kind))]);
+      Raise ERESTAPI.CreateFmt('%s: unsupported array element type : %s',[ClassName,GetEnumName(TypeInfo(TTypeKind),Ord(ET^.Kind))]);
     end;
     end;
     end;
     end;
 end;
 end;
@@ -1041,7 +1041,7 @@ begin
     For I:=0 to Length(TStringArray(AP))-1 do
     For I:=0 to Length(TStringArray(AP))-1 do
       A.Add(TJSONString.Create(TStringArray(AP)[I]));
       A.Add(TJSONString.Create(TStringArray(AP)[I]));
   else
   else
-    Raise ERESTAPI.CreateFmt('%s: unsupported array element type : ',[ClassName,GetEnumName(TypeInfo(TTypeKind),Ord(ET^.Kind))]);
+    Raise ERESTAPI.CreateFmt('%s: unsupported array element type : %s',[ClassName,GetEnumName(TypeInfo(TTypeKind),Ord(ET^.Kind))]);
   end;
   end;
 end;
 end;
 
 

+ 3 - 2
packages/fcl-web/src/restbridge/sqldbrestbridge.pp

@@ -19,7 +19,7 @@ unit sqldbrestbridge;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, DB, SqlTypes, SQLDB, httpdefs, httproute, fpjson, sqldbrestschema, sqldbrestio, sqldbrestdata, sqldbrestauth;
+  Classes, SysUtils, DB, SQLDB, httpdefs, httproute, fpjson, sqldbrestschema, sqldbrestio, sqldbrestdata, sqldbrestauth;
 
 
 Type
 Type
   TRestDispatcherOption = (rdoConnectionInURL,     // Route includes connection :Connection/:Resource[/:ID]
   TRestDispatcherOption = (rdoConnectionInURL,     // Route includes connection :Connection/:Resource[/:ID]
@@ -358,7 +358,7 @@ Type
     Property CORSAllowedOrigins: String Read FCORSAllowedOrigins  Write FCORSAllowedOrigins;
     Property CORSAllowedOrigins: String Read FCORSAllowedOrigins  Write FCORSAllowedOrigins;
     // Access-Control-Max-Age header value. Set to zero not to send the header
     // Access-Control-Max-Age header value. Set to zero not to send the header
     Property CORSMaxAge : Integer Read FCORSMaxAge Write FCORSMaxAge;
     Property CORSMaxAge : Integer Read FCORSMaxAge Write FCORSMaxAge;
-    // Access-Control-Allow-Credentials header value. Set to zero not to send the header
+    // Access-Control-Allow-Credentials header value. Set to false not to send the header
     Property CORSAllowCredentials : Boolean Read FCORSAllowCredentials Write FCORSAllowCredentials;
     Property CORSAllowCredentials : Boolean Read FCORSAllowCredentials Write FCORSAllowCredentials;
     // UserIDs of the user(s) that are allowed to see and modify the connection resource.
     // UserIDs of the user(s) that are allowed to see and modify the connection resource.
     Property AdminUserIDs : TStrings Read FAdminUserIDs Write SetAdminUserIDS;
     Property AdminUserIDs : TStrings Read FAdminUserIDs Write SetAdminUserIDS;
@@ -2312,6 +2312,7 @@ begin
     DatabaseName:=C.DatabaseName;
     DatabaseName:=C.DatabaseName;
     ConnectionType:=C.ConnectionType;
     ConnectionType:=C.ConnectionType;
     Port:=C.Port;
     Port:=C.Port;
+    Name:=C.Name;
     SchemaName:=C.SchemaName;
     SchemaName:=C.SchemaName;
     Params.Assign(C.Params);
     Params.Assign(C.Params);
     end
     end

+ 10 - 10
packages/fcl-web/src/restbridge/sqldbrestini.pp

@@ -36,10 +36,10 @@ Type
   Public
   Public
     Procedure LoadFromIni(Const aIni: TCustomIniFile; aOptions : TConnectionIniOptions = []); overload;
     Procedure LoadFromIni(Const aIni: TCustomIniFile; aOptions : TConnectionIniOptions = []); overload;
     Procedure LoadFromIni(Const aIni: TCustomIniFile; ASection : String; aOptions : TConnectionIniOptions); overload;
     Procedure LoadFromIni(Const aIni: TCustomIniFile; ASection : String; aOptions : TConnectionIniOptions); overload;
-    Procedure LoadFromFile(Const aFileName : String; aOptions : TConnectionIniOptions = []); overload;
-    Procedure LoadFromFile(Const aFileName : String; Const ASection : String; aOptions : TConnectionIniOptions); overload;
-    Procedure SaveToFile(Const aFileName : String; aOptions : TConnectionIniOptions = []);overload;
-    Procedure SaveToFile(Const aFileName : String; Const ASection : String; aOptions : TConnectionIniOptions = []);overload;
+    Procedure LoadFromIniFile(Const aFileName : String; aOptions : TConnectionIniOptions = []); overload;
+    Procedure LoadFromIniFile(Const aFileName : String; Const ASection : String; aOptions : TConnectionIniOptions); overload;
+    Procedure SaveToIniFile(Const aFileName : String; aOptions : TConnectionIniOptions = []);overload;
+    Procedure SaveToIniFile(Const aFileName : String; Const ASection : String; aOptions : TConnectionIniOptions = []);overload;
     Procedure SaveToIni(Const aIni: TCustomIniFile; aOptions : TConnectionIniOptions = []); overload;
     Procedure SaveToIni(Const aIni: TCustomIniFile; aOptions : TConnectionIniOptions = []); overload;
     Procedure SaveToIni(Const aIni: TCustomIniFile; ASection : String; aOptions : TConnectionIniOptions); overload;
     Procedure SaveToIni(Const aIni: TCustomIniFile; ASection : String; aOptions : TConnectionIniOptions); overload;
   end;
   end;
@@ -578,14 +578,14 @@ begin
   LoadFromIni(aIni,DefaultConnectionSection,aOptions);
   LoadFromIni(aIni,DefaultConnectionSection,aOptions);
 end;
 end;
 
 
-procedure TSQLDBRestConnectionHelper.LoadFromFile(const aFileName: String; aOptions: TConnectionIniOptions);
+procedure TSQLDBRestConnectionHelper.LoadFromIniFile(const aFileName: String; aOptions: TConnectionIniOptions);
 
 
 
 
 begin
 begin
-  Loadfromfile(aFileName,DefaultConnectionSection,aOptions);
+  LoadfromInifile(aFileName,DefaultConnectionSection,aOptions);
 end;
 end;
 
 
-procedure TSQLDBRestConnectionHelper.LoadFromFile(const aFileName: String; const ASection: String; aOptions: TConnectionIniOptions);
+procedure TSQLDBRestConnectionHelper.LoadFromIniFile(const aFileName: String; const ASection: String; aOptions: TConnectionIniOptions);
 
 
 Var
 Var
   Ini : TCustomIniFile;
   Ini : TCustomIniFile;
@@ -599,12 +599,12 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TSQLDBRestConnectionHelper.SaveToFile(const aFileName: String; aOptions: TConnectionIniOptions);
+procedure TSQLDBRestConnectionHelper.SaveToIniFile(const aFileName: String; aOptions: TConnectionIniOptions);
 begin
 begin
-  SaveToFile(aFileName,DefaultConnectionSection,aOptions);
+  SaveToIniFile(aFileName,DefaultConnectionSection,aOptions);
 end;
 end;
 
 
-procedure TSQLDBRestConnectionHelper.SaveToFile(const aFileName: String; const ASection: String; aOptions: TConnectionIniOptions);
+procedure TSQLDBRestConnectionHelper.SaveToIniFile(const aFileName: String; const ASection: String; aOptions: TConnectionIniOptions);
 Var
 Var
   Ini : TCustomIniFile;
   Ini : TCustomIniFile;
 
 

+ 18 - 5
packages/fcl-web/src/restbridge/sqldbrestschema.pp

@@ -49,6 +49,7 @@ Const
   JSONSchemaRoot = 'schema';
   JSONSchemaRoot = 'schema';
   JSONResourcesRoot = 'resources';
   JSONResourcesRoot = 'resources';
   JSONConnectionsRoot = 'connections';
   JSONConnectionsRoot = 'connections';
+  JSONConnectionName = 'connectionName';
 
 
 Type
 Type
 
 
@@ -200,6 +201,7 @@ Type
     function GetFieldList(aListKind: TFieldListKind; ASep : String = ''): UTF8String;
     function GetFieldList(aListKind: TFieldListKind; ASep : String = ''): UTF8String;
     function GetFieldArray(aListKind: TFieldListKind): TSQLDBRestFieldArray;
     function GetFieldArray(aListKind: TFieldListKind): TSQLDBRestFieldArray;
     Function GetResolvedSQl(aKind : TSQLKind; Const AWhere : UTF8String; Const aOrderBy : UTF8String = ''; aLimit : UTF8String = '') : UTF8String;
     Function GetResolvedSQl(aKind : TSQLKind; Const AWhere : UTF8String; Const aOrderBy : UTF8String = ''; aLimit : UTF8String = '') : UTF8String;
+    Function ProcessSQl(aSQL : String; Const AWhere : UTF8String; Const aOrderBy : UTF8String = ''; aLimit : UTF8String = '') : UTF8String;
     Procedure PopulateFieldsFromFieldDefs(Defs : TFieldDefs; aIndexFields : TStringArray; aProcessIdentifier : TProcessIdentifier; aMinFieldOpts : TRestFieldOptions);
     Procedure PopulateFieldsFromFieldDefs(Defs : TFieldDefs; aIndexFields : TStringArray; aProcessIdentifier : TProcessIdentifier; aMinFieldOpts : TRestFieldOptions);
     Property SQL [aKind : TSQLKind] : TStrings Read GetSQLTyped;
     Property SQL [aKind : TSQLKind] : TStrings Read GetSQLTyped;
     Property BusinessProcessor : TSQLDBRestCustomBusinessProcessor Read FBusinessProcessor;
     Property BusinessProcessor : TSQLDBRestCustomBusinessProcessor Read FBusinessProcessor;
@@ -521,7 +523,7 @@ end;
 function TSQLDBRestSchema.AsJSON(const aPropName: UTF8String): TJSONData;
 function TSQLDBRestSchema.AsJSON(const aPropName: UTF8String): TJSONData;
 
 
 begin
 begin
-  Result:=TJSONObject.Create([JSONResourcesRoot,Resources.AsJSON(),'connectionName',ConnectionName]);
+  Result:=TJSONObject.Create([JSONResourcesRoot,Resources.AsJSON(),JSONConnectionName,ConnectionName]);
   if (aPropName<>'') then
   if (aPropName<>'') then
     Result:=TJSONObject.Create([aPropName,Result]);
     Result:=TJSONObject.Create([aPropName,Result]);
 end;
 end;
@@ -559,8 +561,10 @@ Var
 
 
 begin
 begin
   J:=aData as TJSONObject;
   J:=aData as TJSONObject;
+  if (aPropName<>'') then
+    J:=J.Objects[aPropName];
   Resources.FromJSON(J,JSONResourcesRoot);
   Resources.FromJSON(J,JSONResourcesRoot);
-  ConnectionName:=J.Get(aPropName,'');
+  ConnectionName:=J.Get(JSONConnectionName,'');
   AttachAllProcessors;
   AttachAllProcessors;
 end;
 end;
 
 
@@ -1159,13 +1163,21 @@ function TSQLDBRestResource.GetResolvedSQl(aKind: TSQLKind;
   const AWhere: UTF8String; const aOrderBy: UTF8String; aLimit: UTF8String
   const AWhere: UTF8String; const aOrderBy: UTF8String; aLimit: UTF8String
   ): UTF8String;
   ): UTF8String;
 
 
-Var
-  S : UTF8String;
-
 begin
 begin
   Result:=SQL[aKind].Text;
   Result:=SQL[aKind].Text;
   if (Result='') then
   if (Result='') then
     Result:=GenerateDefaultSQL(aKind);
     Result:=GenerateDefaultSQL(aKind);
+  Result:=ProcessSQL(Result,aWhere,aOrderBy,aLimit);
+end;
+
+function TSQLDBRestResource.ProcessSQl(aSQL: String; const AWhere: UTF8String;
+  const aOrderBy: UTF8String; aLimit: UTF8String): UTF8String;
+
+Var
+  S : UTF8String;
+
+begin
+  Result:=aSQL;
   if (aWhere<>'') then
   if (aWhere<>'') then
     S:='WHERE '+aWhere
     S:='WHERE '+aWhere
   else
   else
@@ -1240,6 +1252,7 @@ begin
       Exclude(O,foFilter);
       Exclude(O,foFilter);
       end;
       end;
     F:=Fields.AddField(FN,RFT,O);
     F:=Fields.AddField(FN,RFT,O);
+    F.NativeFieldType:=FD.DataType;
     if F.FieldType=rftString then
     if F.FieldType=rftString then
       F.MaxLen:=FD.Size;
       F.MaxLen:=FD.Size;
     F.PublicName:=PN;
     F.PublicName:=PN;

+ 30 - 0
packages/fpmkunit/src/fpmkunit.pp

@@ -517,6 +517,8 @@ Type
     Property RequireChecksum : Cardinal Read FRequireChecksum Write FRequireChecksum;
     Property RequireChecksum : Cardinal Read FRequireChecksum Write FRequireChecksum;
   end;
   end;
 
 
+  TResourceFile = Class(TConditionalString);
+
   { TPackageVariant }
   { TPackageVariant }
 
 
   TPackage = Class;
   TPackage = Class;
@@ -587,6 +589,13 @@ Type
     Property Dependencies[Index : Integer] : TDependency Read GetDependency Write SetDependency; default;
     Property Dependencies[Index : Integer] : TDependency Read GetDependency Write SetDependency; default;
   end;
   end;
 
 
+  { TResourceFiles }
+
+  TResourceFiles = Class(TConditionalStrings)
+  public
+    Procedure GetInstallFiles(AList : TStrings; const APrefixU, APrefixB : String; ACPU:TCPU; AOS : TOS); virtual;
+  end;
+
   { TTarget }
   { TTarget }
 
 
   TTarget = Class(TNamedItem)
   TTarget = Class(TNamedItem)
@@ -605,6 +614,7 @@ Type
     FUnitPath,
     FUnitPath,
     FIncludePath : TConditionalStrings;
     FIncludePath : TConditionalStrings;
     FDependencies : TDependencies;
     FDependencies : TDependencies;
+    FResourceFiles : TResourceFiles;
     FCommands : TCommands;
     FCommands : TCommands;
     FDirectory: String;
     FDirectory: String;
     FExtension: String;
     FExtension: String;
@@ -644,6 +654,7 @@ Type
     Procedure GetInstallFiles(List : TStrings; const APrefixU, APrefixB : String; ACPU:TCPU; AOS : TOS); virtual;
     Procedure GetInstallFiles(List : TStrings; const APrefixU, APrefixB : String; ACPU:TCPU; AOS : TOS); virtual;
     Procedure GetArchiveFiles(List : TStrings; ACPU:TCPU; AOS : TOS); virtual;
     Procedure GetArchiveFiles(List : TStrings; ACPU:TCPU; AOS : TOS); virtual;
     Property Dependencies : TDependencies Read FDependencies;
     Property Dependencies : TDependencies Read FDependencies;
+    Property ResourceFiles: TResourceFiles read FResourceFiles;
     Property Commands : TCommands Read FCommands;
     Property Commands : TCommands Read FCommands;
     Property State : TTargetState Read FTargetState;
     Property State : TTargetState Read FTargetState;
     Property TargetType : TTargetType Read FTargetType Write FTargetType;
     Property TargetType : TTargetType Read FTargetType Write FTargetType;
@@ -2817,6 +2828,21 @@ begin
   Result := GPluginManager;
   Result := GPluginManager;
 end;
 end;
 
 
+{ TResourceFiles }
+
+procedure TResourceFiles.GetInstallFiles(AList: TStrings; const APrefixU, APrefixB: String; ACPU: TCPU; AOS: TOS);
+Var
+  I : Integer;
+  R : TResourceFile;
+begin
+  For I:=0 to Count-1 do
+    begin
+    R:=Tobject(Items[I]) as TResourceFile;
+    if (ACPU in R.CPUs) and (AOS in R.OSes) then
+      AList.Add(ConcatPaths([APrefixU, R.Value]));
+    end;
+end;
+
 { TfpmResolvePackagePathsPlugin }
 { TfpmResolvePackagePathsPlugin }
 
 
 procedure TfpmResolvePackagePathsPlugin.ResolveUnitConfigFilenameForBasePath(
 procedure TfpmResolvePackagePathsPlugin.ResolveUnitConfigFilenameForBasePath(
@@ -8558,6 +8584,7 @@ begin
   FIncludePath:=TConditionalStrings.Create(TConditionalString);
   FIncludePath:=TConditionalStrings.Create(TConditionalString);
   FObjectPath:=TConditionalStrings.Create(TConditionalString);
   FObjectPath:=TConditionalStrings.Create(TConditionalString);
   FDependencies:=TDependencies.Create(TDependency);
   FDependencies:=TDependencies.Create(TDependency);
+  FResourceFiles:=TResourceFiles.Create(TResourceFile);
   FCommands:=TCommands.Create(TCommand);
   FCommands:=TCommands.Create(TCommand);
 end;
 end;
 
 
@@ -8568,6 +8595,7 @@ begin
   FreeAndNil(FObjectPath);
   FreeAndNil(FObjectPath);
   FreeAndNil(FIncludePath);
   FreeAndNil(FIncludePath);
   FreeAndNil(FDependencies);
   FreeAndNil(FDependencies);
+  FreeAndNil(FResourceFiles);
   FreeAndNil(FCommands);
   FreeAndNil(FCommands);
   FreeAndNil(Foptions);
   FreeAndNil(Foptions);
   inherited Destroy;
   inherited Destroy;
@@ -8594,6 +8622,7 @@ begin
     DestTarget.FileType := FileType;
     DestTarget.FileType := FileType;
     DestTarget.Directory := Directory;
     DestTarget.Directory := Directory;
     DestTarget.ResourceStrings := ResourceStrings;
     DestTarget.ResourceStrings := ResourceStrings;
+    DestTarget.ResourceFiles.Assign(ResourceFiles);
     DestTarget.Install := Install;
     DestTarget.Install := Install;
     DestTarget.FTargetSourceFileName := fTargetSourceFileName;
     DestTarget.FTargetSourceFileName := fTargetSourceFileName;
     DestTarget.ObjectPath.Assign(ObjectPath);
     DestTarget.ObjectPath.Assign(ObjectPath);
@@ -8844,6 +8873,7 @@ begin
           List.Add(APrefixU + RSTFileName);
           List.Add(APrefixU + RSTFileName);
         end;
         end;
      end;
      end;
+  FResourceFiles.GetInstallFiles(List, APrefixU, APrefixB, ACPU, AOS);
 end;
 end;
 
 
 
 

+ 29 - 7
packages/morphunits/src/agraphics.pas

@@ -129,7 +129,29 @@ type
     _p1,
     _p1,
     _p2     : APTR;       // system reserved
     _p2     : APTR;       // system reserved
     reserved: LongInt;    // system use
     reserved: LongInt;    // system use
-    Flags   : LongInt;    // only exists in layer allocation
+  end;
+  PLayer_Info = ^TLayer_Info;
+  TLayer_Info = record
+    Top_Layer: Player;
+    check_lp: PLayer;
+    Obs: PClipRect;
+    FreeClipRects: PClipRect;
+
+    PrivateReserve1: LongInt;
+    PrivateReserve2: LongInt;
+
+    Lock: TSignalSemaphore;
+    gs_Head: TMinList;
+
+    PrivateReserve3: SmallInt;
+    PrivateReserve4: APTR;
+
+    Flags: Word;               // LIFLG_SUPPORTS_OFFSCREEN_LAYERS
+    fatten_count: ShortInt;
+    LockLayersCount: ShortInt;
+    PrivateReserve5: SmallInt;
+    BlankHook: APTR;
+    LayerInfo_extra: APTR;
   end;
   end;
 
 
 
 
@@ -275,12 +297,12 @@ type
       NxtList: PCopList;
       NxtList: PCopList;
       );
       );
     1:(
     1:(
-      VWaitPos: SmallInt; // vertical wait position
       DestAddr: SmallInt; // destination Pointer
       DestAddr: SmallInt; // destination Pointer
+      DestData: SmallInt; // data to send
       );
       );
     2:(
     2:(
+      VWaitPos: SmallInt; // vertical wait position
       HWaitPos: SmallInt; // horizontal wait position
       HWaitPos: SmallInt; // horizontal wait position
-      DestData: SmallInt; // data to send
       );
       );
   end;
   end;
 
 
@@ -288,7 +310,7 @@ type
   PCprList = ^TCprList;
   PCprList = ^TCprList;
   TCprList = record
   TCprList = record
     Next: PCprList;
     Next: PCprList;
-    Start: Word;         // start of copper list
+    Start: PWord;         // start of copper list
     MaxCount: SmallInt;  // number of long instructions
     MaxCount: SmallInt;  // number of long instructions
   end;
   end;
 
 
@@ -1903,9 +1925,9 @@ type
     VBCounter: LongWord;
     VBCounter: LongWord;
 
 
     HashTableSemaphore: PSignalSemaphore;  // Semaphore for hash_table access, private in fact
     HashTableSemaphore: PSignalSemaphore;  // Semaphore for hash_table access, private in fact
-
-    ChunkyToPlanarPtr: PLongWord;  // HWEmul[0];
-    HWEmul: array[1..8] of PLongWord;
+    case boolean of
+      true: ( ChunkyToPlanarPtr: PLongWord;);  // HWEmul[0];
+      false: (HWEmul: array[0..8] of PLongWord;);
   end;
   end;
 
 
 const
 const

+ 2 - 2
packages/morphunits/src/amigados.pas

@@ -546,7 +546,7 @@ type
   PErrorString = ^TErrorString;
   PErrorString = ^TErrorString;
   TErrorString = packed record
   TErrorString = packed record
     estr_Nums: PLongInt;
     estr_Nums: PLongInt;
-    estr_Byte: PByte;
+    estr_Strings: PByte;
   end;
   end;
 
 
 type
 type
@@ -852,7 +852,7 @@ type
           ap_Reserved  : ShortInt;
           ap_Reserved  : ShortInt;
           ap_Strlen    : SmallInt;
           ap_Strlen    : SmallInt;
           ap_Info      : TFileInfoBlock;
           ap_Info      : TFileInfoBlock;
-          ap_Buf       : Array[0..0] of Char;
+          ap_Buf       : Array[0..1] of Char;
           { * an_Buf continues * }
           { * an_Buf continues * }
         );
         );
   end;
   end;

+ 7 - 0
packages/morphunits/src/datatypes.pas

@@ -629,6 +629,13 @@ Type
     dtd_AttrList         : pTagItem;          { Additional attributes }
     dtd_AttrList         : pTagItem;          { Additional attributes }
  end;
  end;
 
 
+// DTM_RELEASERAWINFO
+  PdtReleaseDrawInfo = ^TdtReleaseDrawInfo;
+  TdtReleaseDrawInfo = record
+    MethodID: PtrUInt;
+    dtr_Handle: APTR; // Handle as returned by DTM_OBTAINDRAWINFO
+  end;
+
 { DTM_WRITE }
 { DTM_WRITE }
  pdtWrite = ^tdtWrite;
  pdtWrite = ^tdtWrite;
  tdtWrite = record
  tdtWrite = record

+ 2 - 2
packages/morphunits/src/exec.pas

@@ -1071,7 +1071,7 @@ type
     lib_Node    : TNode;
     lib_Node    : TNode;
     lib_Flags   : Byte;
     lib_Flags   : Byte;
     lib_pad     : Byte;
     lib_pad     : Byte;
-    lib_MegSize : Word;
+    lib_NegSize : Word;
     lib_PosSize : Word;
     lib_PosSize : Word;
     lib_Version : Word;
     lib_Version : Word;
     lib_Revision: Word;
     lib_Revision: Word;
@@ -1418,7 +1418,7 @@ type
     PortList    : TList;
     PortList    : TList;
     TaskReady   : TList;
     TaskReady   : TList;
     TaskWait    : TList;
     TaskWait    : TList;
-    SoftInts    : Array[0..5] Of TSoftIntList;
+    SoftInts    : Array[0..4] Of TSoftIntList;
     LastAlert   : Array[0..3] Of LongInt;
     LastAlert   : Array[0..3] Of LongInt;
 
 
     VBlankFrequency     : Byte;
     VBlankFrequency     : Byte;

+ 1 - 3
packages/morphunits/src/intuition.pas

@@ -1707,7 +1707,7 @@ type
     ViewInitX,
     ViewInitX,
     ViewInitY: SmallInt;   // View initial offset values
     ViewInitY: SmallInt;   // View initial offset values
 
 
-    EnableCLI: LongBool;   // CLI availability switch
+    EnableCLI: WordBool;   // CLI availability switch
 
 
   // printer configurations
   // printer configurations
     PrinterType: Word;     // printer type
     PrinterType: Word;     // printer type
@@ -2075,8 +2075,6 @@ type
     cl_SubclassCount: LongWord; // number of direct subclasses
     cl_SubclassCount: LongWord; // number of direct subclasses
     cl_ObjectCount: LongWord;   // number of instances
     cl_ObjectCount: LongWord;   // number of instances
     cl_Flags: LongWord;         // Flags (CLF_INLIST)
     cl_Flags: LongWord;         // Flags (CLF_INLIST)
-    cl_ObjectSize: LongWord;    // cl_InstOffset + cl_InstSize + SizeOf(_Object)
-    cl_MemoryPool: APTR;
   end;
   end;
 
 
 const
 const

+ 2 - 2
packages/morphunits/src/utility.pas

@@ -140,8 +140,8 @@ const
 
 
 
 
 type
 type
-  PUtilityBase = ^TUtilityName;
-  TUtilityName = packed record
+  PUtilityBase = ^TUtilityBase;
+  TUtilityBase = packed record
     ub_LibNode : TLibrary;
     ub_LibNode : TLibrary;
     ub_Language: Byte;
     ub_Language: Byte;
     ub_Reserved: Byte;
     ub_Reserved: Byte;

+ 38 - 0
packages/pastojs/src/fppas2js.pp

@@ -2556,6 +2556,13 @@ var
     Result:=false;
     Result:=false;
   end;
   end;
 
 
+  procedure HandleEscape;
+  begin
+    inc(MyTokenPos);
+    if (MyTokenPos<=l) and (s[MyTokenPos]>#31) then
+      inc(MyTokenPos);
+  end;
+
 begin
 begin
   SetCurTokenString('');
   SetCurTokenString('');
   s:=CurLine;
   s:=CurLine;
@@ -2574,6 +2581,8 @@ begin
     if MyTokenPos>l then
     if MyTokenPos>l then
       if DoEndOfLine then exit;
       if DoEndOfLine then exit;
     case s[MyTokenPos] of
     case s[MyTokenPos] of
+    '\':
+      HandleEscape;
     '''':
     '''':
       begin
       begin
       inc(MyTokenPos);
       inc(MyTokenPos);
@@ -2581,6 +2590,8 @@ begin
         if MyTokenPos>l then
         if MyTokenPos>l then
           Error(nErrOpenString,SErrOpenString);
           Error(nErrOpenString,SErrOpenString);
         case s[MyTokenPos] of
         case s[MyTokenPos] of
+        '\':
+          HandleEscape;
         '''':
         '''':
           begin
           begin
           inc(MyTokenPos);
           inc(MyTokenPos);
@@ -2603,6 +2614,8 @@ begin
         if MyTokenPos>l then
         if MyTokenPos>l then
           Error(nErrOpenString,SErrOpenString);
           Error(nErrOpenString,SErrOpenString);
         case s[MyTokenPos] of
         case s[MyTokenPos] of
+        '\':
+          HandleEscape;
         '"':
         '"':
           begin
           begin
           inc(MyTokenPos);
           inc(MyTokenPos);
@@ -2618,6 +2631,31 @@ begin
         end;
         end;
       until false;
       until false;
       end;
       end;
+    '`': // template literal
+      begin
+      inc(MyTokenPos);
+      repeat
+        while MyTokenPos>l do
+          if DoEndOfLine then
+            begin
+            if not StopAtLineEnd then
+              Error(nErrOpenString,SErrOpenString);
+            exit;
+            end;
+        case s[MyTokenPos] of
+        '\':
+          HandleEscape;
+        '`':
+          begin
+          inc(MyTokenPos);
+          break;
+          end;
+        // Note: template literals can span multiple lines
+        else
+          inc(MyTokenPos);
+        end;
+      until false;
+      end;
     '/':
     '/':
       begin
       begin
       inc(MyTokenPos);
       inc(MyTokenPos);

+ 10 - 0
packages/pastojs/tests/tcmodules.pas

@@ -3722,6 +3722,11 @@ begin
   '    // end',
   '    // end',
   '    s = ''end'';',
   '    s = ''end'';',
   '    s = "end";',
   '    s = "end";',
+  '    s = "foo\"bar";',
+  '    s = ''a\''b'';',
+  '    s =  `${expr}\`-"-''-`;',
+  '    s = `multi',
+  'line`;',
   '  end;',
   '  end;',
   'end;',
   'end;',
   'procedure Fly;',
   'procedure Fly;',
@@ -3742,6 +3747,11 @@ begin
     '  // end',
     '  // end',
     '  s = ''end'';',
     '  s = ''end'';',
     '  s = "end";',
     '  s = "end";',
+    '  s = "foo\"bar";',
+    '  s = ''a\''b'';',
+    '  s =  `${expr}\`-"-''-`;',
+    '  s = `multi',
+    'line`;',
     '  return Result;',
     '  return Result;',
     '};',
     '};',
     'this.Fly = function () {',
     'this.Fly = function () {',

+ 258 - 0
packages/rtl-objpas/src/inc/dateutil.inc

@@ -440,6 +440,24 @@ Function LocalTimeToUniversal(LT: TDateTime; TZOffset: Integer): TDateTime;
 function ScanDateTime(const Pattern:string;const s:string;const fmt:TFormatSettings;startpos:integer=1) : tdatetime; overload;
 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;
 function ScanDateTime(const Pattern:string;const s:string;startpos:integer=1) : tdatetime; overload;
 
 
+// ISO date/time
+// YYYYMMDD or YYYY-MM-DD
+function TryISOStrToDate(const aString: string; out outDate: TDateTime): Boolean;
+// HH HH:NN HH:NN:SS HH:NN:SS.ZZZ or HHNN HHNNSS HHNNSS.ZZZ
+function TryISOStrToTime(const aString: string; Out outTime: TDateTime): Boolean;
+// Combination of previous
+function TryISOStrToDateTime(const aString: string; out outDateTime: TDateTime): Boolean;
+// Z +hh:nn -hh:nn
+Function TryISOTZStrToTZOffset(TZ : String; Out TZOffset : Integer) : boolean;
+
+// ISO 8601 Date/Time formatting
+
+function DateToISO8601(const ADate: TDateTime; AInputIsUTC: Boolean = True): string;
+Function ISO8601ToDate(const DateString: string; ReturnUTC : Boolean): TDateTime;
+Function ISO8601ToDateDef(const DateString: string; ReturnUTC : Boolean; aDefault : TDateTime): TDateTime;
+Function TryISO8601ToDate(const DateString: string; ReturnUTC : Boolean;out ADateTime: TDateTime) : Boolean;
+
+
 implementation
 implementation
 
 
 uses sysconst;
 uses sysconst;
@@ -2678,6 +2696,246 @@ begin
     Result := LT;
     Result := LT;
 end;
 end;
 
 
+Const
+  FmtUTC = 'yyyy"-"mm"-"dd"T"hh":"nn":"ss"."zzz';
+  FmtUTCTZ = 'hh":"mm';
+
+function DateToISO8601(const ADate: TDateTime; AInputIsUTC: Boolean = True): string;
+
+const
+  FmtOffset: string = '%.02d:%.02d';
+  Sign: array[Boolean] of Char = ('+', '-');
+
+var
+  Offset: Integer;
+begin
+  Result := FormatDateTime(FmtUTC, ADate);
+  Offset := GetLocalTimeOffset;
+  if AInputIsUTC or (Offset=0) then
+    Result:=Result+'Z'
+  else
+    begin
+    Result:=Result+Sign[Offset>0];
+    Offset := Abs(Offset);
+    Result:= Result+Format(FmtOffset, [Offset div MinsPerHour, Offset mod MinsPerHour]);
+    end;
+end;
+
+function TryISOStrToDate(const aString: string; out outDate: TDateTime): Boolean;
+var
+  xYear, xMonth, xDay: LongInt;
+begin
+  case Length(aString) of
+    8: Result :=
+          TryStrToInt(Copy(aString, 1, 4), xYear) and
+          TryStrToInt(Copy(aString, 5, 2), xMonth) and
+          TryStrToInt(Copy(aString, 7, 2), xDay) and
+          TryEncodeDate(xYear, xMonth, xDay, outDate);
+    10: Result :=
+          TryStrToInt(Copy(aString, 1, 4), xYear) and
+          TryStrToInt(Copy(aString, 6, 2), xMonth) and
+          TryStrToInt(Copy(aString, 9, 2), xDay) and
+          TryEncodeDate(xYear, xMonth, xDay, outDate);
+  else
+    Result := False;
+  end;
+  if not Result then
+    outDate := 0;
+end;
+
+
+function TryISOStrToTime(const aString: string; Out outTime: TDateTime): Boolean;
+var
+  xHour, xMinute, xSecond, xMillisecond, xLength: LongInt;
+begin
+  Result := True;
+  xLength := Length(aString);
+  if (xLength>0) and (aString[xLength] = 'Z') then
+  begin
+    Dec(xLength);
+  end else
+  if (xLength>6) and CharInSet(aString[xLength-5], ['+', '-']) then
+  begin
+    Result :=
+      TryStrToInt(Copy(aString, xLength-4, 2), xHour) and
+      (aString[xLength-2] = ':') and
+      TryStrToInt(Copy(aString, xLength-1, 2), xMinute);
+    Dec(xLength, 6);
+  end else
+  if (xLength>5) and CharInSet(aString[xLength-4], ['+', '-']) then
+  begin
+    Result :=
+      TryStrToInt(Copy(aString, xLength-3, 2), xHour) and
+      TryStrToInt(Copy(aString, xLength-1, 2), xMinute);
+    Dec(xLength, 5);
+  end else
+  if (xLength>3) and CharInSet(aString[xLength-2], ['+', '-']) then
+  begin
+    Result :=
+      TryStrToInt(Copy(aString, xLength-1, 2), xHour);
+    Dec(xLength, 3);
+  end;
+  if not Result then
+  begin
+    outTime := 0;
+    Exit;
+  end;
+
+  case xLength of
+    2: Result :=
+          TryStrToInt(aString, xHour) and
+          TryEncodeTime(xHour, 0, 0, 0, outTime);
+    4: Result :=
+          TryStrToInt(Copy(aString, 1, 2), xHour) and
+          TryStrToInt(Copy(aString, 3, 2), xMinute) and
+          TryEncodeTime(xHour, xMinute, 0, 0, outTime);
+    5: Result :=
+          TryStrToInt(Copy(aString, 1, 2), xHour) and
+          (aString[3] = ':') and
+          TryStrToInt(Copy(aString, 4, 2), xMinute) and
+          TryEncodeTime(xHour, xMinute, 0, 0, outTime);
+    6: Result :=
+          TryStrToInt(Copy(aString, 1, 2), xHour) and
+          TryStrToInt(Copy(aString, 3, 2), xMinute) and
+          TryStrToInt(Copy(aString, 5, 2), xSecond) and
+          TryEncodeTime(xHour, xMinute, xSecond, 0, outTime);
+    8: Result :=
+          TryStrToInt(Copy(aString, 1, 2), xHour) and
+          (aString[3] = ':') and
+          TryStrToInt(Copy(aString, 4, 2), xMinute) and
+          (aString[6] = ':') and
+          TryStrToInt(Copy(aString, 7, 2), xSecond) and
+          TryEncodeTime(xHour, xMinute, xSecond, 0, outTime);
+    10: Result :=
+          TryStrToInt(Copy(aString, 1, 2), xHour) and
+          TryStrToInt(Copy(aString, 3, 2), xMinute) and
+          TryStrToInt(Copy(aString, 5, 2), xSecond) and
+          (aString[7] = '.') and
+          TryStrToInt(Copy(aString, 8, 3), xMillisecond) and
+          TryEncodeTime(xHour, xMinute, xSecond, xMillisecond, outTime);
+    12: Result :=
+          TryStrToInt(Copy(aString, 1, 2), xHour) and
+          (aString[3] = ':') and
+          TryStrToInt(Copy(aString, 4, 2), xMinute) and
+          (aString[6] = ':') and
+          TryStrToInt(Copy(aString, 7, 2), xSecond) and
+          (aString[9] = '.') and
+          TryStrToInt(Copy(aString, 10, 3), xMillisecond) and
+          TryEncodeTime(xHour, xMinute, xSecond, xMillisecond, outTime);
+  else
+    Result := False;
+  end;
+
+  if not Result then
+    outTime := 0;
+end;
+
+function TryISOStrToDateTime(const aString: string; out outDateTime: TDateTime): Boolean;
+var
+  xLength: Integer;
+  sDate,sTime : String;
+  xDate, xTime: TDateTime;
+
+begin
+  xLength := Length(aString);
+  if (xLength>11) and CharInSet(aString[11], [' ', 'T']) then
+    begin
+    sDate:=Copy(aString, 1, 10);
+    sTime:=Copy(aString, 12, Length(aString))
+    end
+  else if (xLength>9) and CharInSet(aString[9], [' ', 'T']) then
+    begin
+    sDate:=Copy(aString, 1, 8);
+    sTime:=Copy(aString, 10, Length(aString));
+    end
+  else
+    exit(False);
+  Result:=TryISOStrToDate(sDate, xDate)  and TryISOStrToTime(sTime, xTime);
+  if Result then
+    outDateTime := xDate+xTime
+  else
+    outDateTime := 0;
+end;
+
+Function TryISOTZStrToTZOffset(TZ : String; Out TZOffset : Integer) : boolean;
+
+Var
+  H,M : LongInt;
+
+begin
+  Result:=(TZ='Z') or (TZ='');
+  if Result then
+    TZOffset:=0
+  else
+    begin
+    Result:=TZ[1] in ['+','-'];
+    if Not Result then
+      Exit;
+    Result:=TryStrToInt(Copy(TZ,2,2),H) and TryStrToInt(Copy(TZ,5,2),M);
+    if not Result then
+      exit;
+    TZOffset:=H*60+M;
+    if (TZ[1]='+') then
+      TZOffset:=-TZOffset;
+    end;
+end;
+
+Function ISOTZStrToTZOffset(TZ : String) : Integer;
+
+begin
+  if not TryISOTZStrToTZOffSet(TZ,Result) then
+    Raise EConvertError.CreateFmt('Invalid ISO timezone string',[TZ]);
+end;
+
+Function TryISO8601ToDate(const DateString: string; ReturnUTC : Boolean;out ADateTime: TDateTime) : Boolean;
+
+
+Var
+  S,TZ : String;
+  L,Offset,TZOffset : Integer;
+
+begin
+  S:=DateString;
+  L:=Length(S);
+  if L=0 then
+    exit(False);
+  if S[L]='Z' then
+    begin
+    TZ:='Z';
+    S:=Copy(S,1,L-1);
+    end
+  else If (L>5) and (S[L-5] in ['+','-']) then
+    begin
+    TZ:=Copy(S,L-5,6);
+    S:=Copy(S,1,L-6);
+    end;
+  Result:=TryIsoStrToDateTime(S,aDateTime) and TryISOTZStrToTZOffset(TZ,TZOffset);
+  if not Result then
+    exit;
+  aDateTime:=IncMinute(aDateTime,TZOffSet);
+  // offset for UTC or not
+  if ReturnUTC then
+    Offset:=0
+  else
+    OffSet:=-GetLocalTimeOffset;
+  aDateTime:=IncMinute(aDateTime,Offset);
+  Result:=True;
+end;
+
+Function ISO8601ToDate(const DateString: string; ReturnUTC : Boolean): TDateTime;
+
+begin
+  if not TryISO8601ToDate(DateString,ReturnUTC,Result) then
+    Raise EConvertError.CreateFmt(SErrInvalidTimeStamp,[DateString]);
+end;
+
+Function ISO8601ToDateDef(const DateString: string; ReturnUTC : Boolean; aDefault : TDateTime): TDateTime;
+
+begin
+  if not TryISO8601ToDate(DateString,ReturnUTC,Result) then
+    Result:=aDefault;
+end;
+
 {$else}
 {$else}
 implementation
 implementation
 {$endif FPUNONE}
 {$endif FPUNONE}

+ 44 - 105
rtl/avr/avr.inc

@@ -17,6 +17,15 @@
 
 
 {$asmmode gas}
 {$asmmode gas}
 
 
+const
+{$i cpuinnr.inc}
+
+{ Reads SREG and then disables interrupts, returns contents of SREG }
+function avr_save: byte;[INTERNPROC: in_avr_save];
+{ Restores SREG }
+procedure avr_restore(old_sreg: byte); [INTERNPROC: in_avr_restore];
+
+
 procedure fpc_cpuinit;{$ifdef SYSTEMINLINE}inline;{$endif}
 procedure fpc_cpuinit;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
   begin
   end;
   end;
@@ -84,19 +93,19 @@ function get_frame:pointer;assembler;nostackframe;
 
 
 
 
 {$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
 {$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
-function get_caller_addr(framebp:pointer;addr:pointer=nil):pointer;assembler;
+function get_caller_addr(framebp:pointer;addr:pointer=nil):pointer;assembler;nostackframe;
   asm
   asm
   end;
   end;
 
 
 
 
 {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
 {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
-function get_caller_frame(framebp:pointer;addr:pointer=nil):pointer;assembler;
+function get_caller_frame(framebp:pointer;addr:pointer=nil):pointer;assembler;nostackframe;
   asm
   asm
   end;
   end;
 
 
 
 
 {$define FPC_SYSTEM_HAS_SPTR}
 {$define FPC_SYSTEM_HAS_SPTR}
-Function Sptr : pointer;assembler;
+Function Sptr : pointer;assembler;nostackframe;
   asm
   asm
   end;
   end;
 
 
@@ -106,20 +115,13 @@ function InterLockedDecrement (var Target: longint) : longint;
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
-    dec(Target);
-    Result:=Target;
+    Result:=Target-1;
+    Target:=Result;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -128,20 +130,13 @@ function InterLockedIncrement (var Target: longint) : longint;
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
-    inc(Target);
-    Result:=Target;
+    Result:=Target+1;
+    Target:=Result;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -150,20 +145,13 @@ function InterLockedExchange (var Target: longint;Source : longint) : longint;
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
     Result:=Target;
     Result:=Target;
     Target:=Source;
     Target:=Source;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -172,21 +160,14 @@ function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comp
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
     Result:=Target;
     Result:=Target;
-    if Target=Comperand then
+    if Result=Comperand then
       Target:=NewValue;
       Target:=NewValue;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -195,20 +176,13 @@ function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
     Result:=Target;
     Result:=Target;
-    inc(Target,Source);
+    Target:=Result+Source;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -217,20 +191,13 @@ function InterLockedDecrement (var Target: smallint) : smallint;
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
-    dec(Target);
-    Result:=Target;
+    Result:=Target-1;
+    Target:=Result;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -239,20 +206,13 @@ function InterLockedIncrement (var Target: smallint) : smallint;
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
-    inc(Target);
-    Result:=Target;
+    Result:=Target+1;
+    Target:=Result;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -261,20 +221,13 @@ function InterLockedExchange (var Target: smallint;Source : smallint) : smallint
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
     Result:=Target;
     Result:=Target;
     Target:=Source;
     Target:=Source;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -283,21 +236,14 @@ function InterlockedCompareExchange(var Target: smallint; NewValue: smallint; Co
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
     Result:=Target;
     Result:=Target;
-    if Target=Comperand then
+    if Result=Comperand then
       Target:=NewValue;
       Target:=NewValue;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 
 
 
@@ -306,19 +252,12 @@ function InterLockedExchangeAdd (var Target: smallint;Source : smallint) : small
     temp_sreg : byte;
     temp_sreg : byte;
   begin
   begin
     { block interrupts }
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
 
     Result:=Target;
     Result:=Target;
-    inc(Target,Source);
+    Target:=Result+Source;
 
 
     { release interrupts }
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
   end;
 
 

+ 2 - 0
rtl/avr/cpuinnr.inc

@@ -17,3 +17,5 @@
   in_avr_wdr = fpc_in_cpu_first+2;
   in_avr_wdr = fpc_in_cpu_first+2;
   in_avr_sleep = fpc_in_cpu_first+3;
   in_avr_sleep = fpc_in_cpu_first+3;
   in_avr_nop = fpc_in_cpu_first+4;
   in_avr_nop = fpc_in_cpu_first+4;
+  in_avr_save = fpc_in_cpu_first+5;
+  in_avr_restore = fpc_in_cpu_first+6;

+ 5 - 0
rtl/avr/intrinsics.pp

@@ -24,6 +24,11 @@ unit intrinsics;
     procedure avr_sleep;[INTERNPROC: in_avr_sleep];
     procedure avr_sleep;[INTERNPROC: in_avr_sleep];
     procedure avr_nop;[INTERNPROC: in_avr_nop];
     procedure avr_nop;[INTERNPROC: in_avr_nop];
 
 
+    { Reads SREG and then disables interrupts, returns contents of SREG }
+    function avr_save: byte;[INTERNPROC: in_avr_save];
+    { Restores SREG }
+    procedure avr_restore(old_sreg: byte); [INTERNPROC: in_avr_restore];
+
   implementation
   implementation
 
 
 end.
 end.

+ 53 - 0
rtl/bsd/ostypes.inc

@@ -107,6 +107,45 @@ TYPE
         st_gen        : cuint32;           // file generation number
         st_gen        : cuint32;           // file generation number
         st_birthtime  : time_t;            // File creation time
         st_birthtime  : time_t;            // File creation time
         st_birthtimensec : clong;          // nsec of file creation time
         st_birthtimensec : clong;          // nsec of file creation time
+{$elseif defined(freebsd)}
+{$ifdef i386}
+{$define __STAT_TIME_T_EXT}
+{$endif}
+        st_dev        : dev_t;             // inode's device
+        st_ino        : ino_t;             // inode's number
+        st_nlink      : nlink_t;           // number of hard links
+        st_mode       : mode_t;            // inode protection mode
+	st_padding0   : cint16;
+        st_uid        : uid_t;             // user ID of the file's owner
+        st_gid        : gid_t;             // group ID of the file's group
+	st_padding1   : cint32;
+        st_rdev       : dev_t;             // device type
+{$ifdef __STAT_TIME_T_EXT}
+        st_atim_ext   : cint32;
+{$endif}
+        st_atime      : time_t;            // time of last access
+        st_atimensec  : clong;             // nsec of last access
+{$ifdef __STAT_TIME_T_EXT}
+        st_mtim_ext   : cint32;
+{$endif}
+        st_mtime      : time_t;            // time of last data modification
+        st_mtimensec  : clong;             // nsec of last data modification
+{$ifdef __STAT_TIME_T_EXT}
+        st_ctim_ext   : cint32;
+{$endif}
+        st_ctime      : time_t;            // time of last file status change
+        st_ctimensec  : clong;             // nsec of last file status change
+{$ifdef __STAT_TIME_T_EXT}
+        st_birthtim_ext   : cint32;
+{$endif}
+        st_birthtime  : time_t;            // File creation time
+        st_birthtimensec : clong;          // nsec of file creation time
+        st_size       : off_t;             // file size, in bytes
+        st_blocks     : cint64;            // blocks allocated for file
+        st_blksize    : cint32;            // optimal blocksize for I/O
+        st_flags      : cuint32;           // user defined flags for file
+        st_gen        : cuint64;           // file generation number
+	st_spare      : array [0..10-1] of cuint64;
 {$else}
 {$else}
         st_dev        : dev_t;             // inode's device
         st_dev        : dev_t;             // inode's device
 {$ifdef darwin_new_iostructs}
 {$ifdef darwin_new_iostructs}
@@ -189,6 +228,17 @@ TYPE
         d_padding     : array[0..3] of cuint8;
         d_padding     : array[0..3] of cuint8;
         d_name        : array[0..(255 + 1)-1] of char;  // name must be no longer than this
         d_name        : array[0..(255 + 1)-1] of char;  // name must be no longer than this
    end;
    end;
+{$elseif defined(freebsd)}
+   dirent  = record
+        d_fileno      : ino_t;
+        d_off         : off_t;
+        d_reclen      : cuint16;                        // length of this record
+        d_type        : cuint8;                         // file type, see below
+	d_pad0        : cuint8;
+        d_namlen      : cuint16;                        // length of string in d_name
+	d_pad1        : cuint16;
+        d_name        : array[0..(255 + 1)-1] of char;  // name must be no longer than this
+   end;
 {$else}
 {$else}
    dirent  = record
    dirent  = record
         d_fileno      : cuint32;                        // file number of entry
         d_fileno      : cuint32;                        // file number of entry
@@ -242,6 +292,9 @@ TYPE
                 l_pid   : pid_t;        { lock owner }
                 l_pid   : pid_t;        { lock owner }
                 l_type  : cshort;       { lock type: read/write, etc. }
                 l_type  : cshort;       { lock type: read/write, etc. }
                 l_whence: cshort;       { type of l_start }
                 l_whence: cshort;       { type of l_start }
+{$ifdef freebsd}
+                l_sysid : cint;
+{$endif}
                 end;
                 end;
    TFlock   = flock;
    TFlock   = flock;
    pFlock   = ^flock;
    pFlock   = ^flock;

+ 2 - 8
rtl/embedded/Makefile

@@ -2804,20 +2804,14 @@ strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
 		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc \
 		   $(SYSTEMUNIT)$(PPUEXT)
 		   $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 	$(COMPILER) $<
-	$(COMPILER) $<
-	$(COMPILER) $<
 consoleio$(PPUEXT) : consoleio.pp $(SYSTEMUNIT)$(PPUEXT)
 consoleio$(PPUEXT) : consoleio.pp $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 	$(COMPILER) $<
 heapmgr$(PPUEXT) : heapmgr.pp $(SYSTEMUNIT)$(PPUEXT)
 heapmgr$(PPUEXT) : heapmgr.pp $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 	$(COMPILER) $<
-dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
-	       $(SYSTEMUNIT)$(PPUEXT)
-	$(COMPILER) $<
+dos$(PPUEXT) : dos.pp $(INC)/fexpand.inc $(INC)/filerec.inc $(INC)/textrec.inc $(INC)/dosh.inc $(INC)/dos.inc objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 	$(COMPILER) $<
 objects$(PPUEXT) : $(INC)/objects.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 objects$(PPUEXT) : $(INC)/objects.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 	$(COMPILER) $<
-	$(COMPILER) $<
-	$(COMPILER) $<
 sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
 sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/sysutils/*.inc) \
 		    objpas$(PPUEXT) sysconst$(PPUEXT) heapmgr$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 		    objpas$(PPUEXT) sysconst$(PPUEXT) heapmgr$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp
 	$(COMPILER) -Fi$(OBJPASDIR)/sysutils sysutils.pp
@@ -2835,7 +2829,7 @@ fmtbcd$(PPUEXT) : $(OBJPASDIR)/fmtbcd.pp objpas$(PPUEXT) sysutils$(PPUEXT) varia
 	$(COMPILER) $(OBJPASDIR)/fmtbcd.pp
 	$(COMPILER) $(OBJPASDIR)/fmtbcd.pp
 types$(PPUEXT) : $(OBJPASDIR)/types.pp math$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 types$(PPUEXT) : $(OBJPASDIR)/types.pp math$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(OBJPASDIR)/types.pp
 	$(COMPILER) $(OBJPASDIR)/types.pp
-rtlconsts$(PPUEXT) : $(OBJPASDIR)/rtlconsts.pp $(SYSTEMUNIT)$(PPUEXT)
+rtlconsts$(PPUEXT) : $(OBJPASDIR)/rtlconsts.pp $(OBJPASDIR)/rtlconst.inc objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(OBJPASDIR)/rtlconsts.pp
 	$(COMPILER) $(OBJPASDIR)/rtlconsts.pp
 sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(OBJPASDIR)/sysconst.pp
 	$(COMPILER) $(OBJPASDIR)/sysconst.pp

+ 7 - 8
rtl/embedded/Makefile.fpc

@@ -227,10 +227,10 @@ strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc \
 #
 #
 
 
 #ports$(PPUEXT) : ports.pas objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 #ports$(PPUEXT) : ports.pas objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-        $(COMPILER) $<
+#        $(COMPILER) $<
 
 
 #doscalls$(PPUEXT) : doscalls.pas strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 #doscalls$(PPUEXT) : doscalls.pas strings$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-        $(COMPILER) $<
+#        $(COMPILER) $<
 
 
 consoleio$(PPUEXT) : consoleio.pp $(SYSTEMUNIT)$(PPUEXT)
 consoleio$(PPUEXT) : consoleio.pp $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 	$(COMPILER) $<
@@ -243,21 +243,20 @@ heapmgr$(PPUEXT) : heapmgr.pp $(SYSTEMUNIT)$(PPUEXT)
 # TP7 Compatible RTL Units
 # TP7 Compatible RTL Units
 #
 #
 
 
-dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
-               $(SYSTEMUNIT)$(PPUEXT)
+dos$(PPUEXT) : dos.pp $(INC)/fexpand.inc $(INC)/filerec.inc $(INC)/textrec.inc $(INC)/dosh.inc $(INC)/dos.inc objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $<
         $(COMPILER) $<
 
 
 #crt$(PPUEXT) : crt.pas $(INC)/textrec.inc $(SYSTEMUNIT)$(PPUEXT)
 #crt$(PPUEXT) : crt.pas $(INC)/textrec.inc $(SYSTEMUNIT)$(PPUEXT)
-        $(COMPILER) $<
+#        $(COMPILER) $<
 
 
 objects$(PPUEXT) : $(INC)/objects.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 objects$(PPUEXT) : $(INC)/objects.pp dos$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $<
         $(COMPILER) $<
 
 
 #printer$(PPUEXT) : printer.pas $(INC)/textrec.inc $(SYSTEMUNIT)$(PPUEXT)
 #printer$(PPUEXT) : printer.pas $(INC)/textrec.inc $(SYSTEMUNIT)$(PPUEXT)
-        $(COMPILER) $<
+#        $(COMPILER) $<
 
 
 #graph$(PPUEXT) : graph.pp
 #graph$(PPUEXT) : graph.pp
-        $(COMPILER) $<
+#        $(COMPILER) $<
 
 
 #
 #
 # Delphi Compatible Units
 # Delphi Compatible Units
@@ -287,7 +286,7 @@ fmtbcd$(PPUEXT) : $(OBJPASDIR)/fmtbcd.pp objpas$(PPUEXT) sysutils$(PPUEXT) varia
 types$(PPUEXT) : $(OBJPASDIR)/types.pp math$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 types$(PPUEXT) : $(OBJPASDIR)/types.pp math$(PPUEXT) objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $(OBJPASDIR)/types.pp
         $(COMPILER) $(OBJPASDIR)/types.pp
 
 
-rtlconsts$(PPUEXT) : $(OBJPASDIR)/rtlconsts.pp $(SYSTEMUNIT)$(PPUEXT)
+rtlconsts$(PPUEXT) : $(OBJPASDIR)/rtlconsts.pp $(OBJPASDIR)/rtlconst.inc objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $(OBJPASDIR)/rtlconsts.pp
         $(COMPILER) $(OBJPASDIR)/rtlconsts.pp
 
 
 sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 sysconst$(PPUEXT) : $(OBJPASDIR)/sysconst.pp objpas$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)

+ 3 - 7
rtl/freebsd/ptypes.inc

@@ -26,7 +26,7 @@ const
     SEM_SAFE=255;
     SEM_SAFE=255;
 type
 type
 
 
-    dev_t    = cuint32;         { used for device numbers      }
+    dev_t    = cuint64;         { used for device numbers      }
     TDev     = dev_t;
     TDev     = dev_t;
     pDev     = ^dev_t;
     pDev     = ^dev_t;
 
 
@@ -35,11 +35,7 @@ type
     pGid     = ^gid_t;
     pGid     = ^gid_t;
     TIOCtlRequest = cuLong;
     TIOCtlRequest = cuLong;
 
 
-    {$ifdef CPU64}
-     ino_t    = cuint32;           { used for file serial numbers }
-    {$else}	
-     ino_t    = clong;           { used for file serial numbers }
-    {$endif}
+    ino_t    = cuint64;           { used for file serial numbers }
     TIno     = ino_t;
     TIno     = ino_t;
     pIno     = ^ino_t;
     pIno     = ^ino_t;
 
 
@@ -47,7 +43,7 @@ type
     TMode    = mode_t;
     TMode    = mode_t;
     pMode    = ^mode_t;
     pMode    = ^mode_t;
 
 
-    nlink_t  = cuint16;         { used for link counts         }
+    nlink_t  = cuint64;         { used for link counts         }
     TnLink   = nlink_t;
     TnLink   = nlink_t;
     pnLink   = ^nlink_t;
     pnLink   = ^nlink_t;
 
 

+ 2 - 1
rtl/inc/dos.inc

@@ -232,6 +232,7 @@ end;
 ****************************************************************************}
 ****************************************************************************}
 
 
 {$IFNDEF HAS_FSPLIT}
 {$IFNDEF HAS_FSPLIT}
+{$push}
 {$warnings off}
 {$warnings off}
 Procedure FSplit (Path: PathStr; var Dir: DirStr; var Name: NameStr; var Ext: ExtStr);
 Procedure FSplit (Path: PathStr; var Dir: DirStr; var Name: NameStr; var Ext: ExtStr);
 var
 var
@@ -275,7 +276,7 @@ begin
   Name := Copy (Path, DirEnd + 1, ExtStart - DirEnd - 1);
   Name := Copy (Path, DirEnd + 1, ExtStart - DirEnd - 1);
   Ext := Copy (Path, ExtStart, Length (Path) - ExtStart + 1);
   Ext := Copy (Path, ExtStart, Length (Path) - ExtStart + 1);
 end;
 end;
-{$warnings on}
+{$pop}
 {$ENDIF HAS_FSPLIT}
 {$ENDIF HAS_FSPLIT}
 
 
 
 

+ 2 - 1
rtl/inc/fexpand.inc

@@ -160,11 +160,12 @@ begin
 {$IFNDEF FPC_FEXPAND_SYSUTILS}
 {$IFNDEF FPC_FEXPAND_SYSUTILS}
 (* Allow both '/' and '\' as directory separators *)
 (* Allow both '/' and '\' as directory separators *)
 (* by converting all to the native one.           *)
 (* by converting all to the native one.           *)
+{$push}
 {$warnings off}
 {$warnings off}
 	  for I := 1 to Length (Pa) do
 	  for I := 1 to Length (Pa) do
 	    if CharInSet(Pa [I], AllowDirectorySeparators)  then
 	    if CharInSet(Pa [I], AllowDirectorySeparators)  then
 	      Pa [I] := DirectorySeparator;
 	      Pa [I] := DirectorySeparator;
-{$warnings on}
+{$pop}
 {$ENDIF not FPC_FEXPAND_SYSUTILS}
 {$ENDIF not FPC_FEXPAND_SYSUTILS}
 
 
 (* PathStart is amount of characters to strip to get beginning *)
 (* PathStart is amount of characters to strip to get beginning *)

+ 2 - 1
rtl/inc/ustrings.inc

@@ -2313,6 +2313,7 @@ function StringCodePage(const S: UnicodeString): TSystemCodePage; overload;
   end;
   end;
 
 
 
 
+{$push}
 {$warnings off}
 {$warnings off}
 function StubUnicodeCase(const s : UnicodeString) : UnicodeString;
 function StubUnicodeCase(const s : UnicodeString) : UnicodeString;
   begin
   begin
@@ -2333,7 +2334,7 @@ function StubCompareWideString(const s1, s2 : WideString; Options : TCompareOpti
   begin
   begin
     unimplementedunicodestring;
     unimplementedunicodestring;
   end;
   end;
-{$warnings on}
+{$pop}
 
 
 procedure initunicodestringmanager;
 procedure initunicodestringmanager;
   begin
   begin

+ 62 - 17
rtl/linux/i386/sysnr.inc

@@ -20,6 +20,7 @@
 }
 }
 
 
 Const
 Const
+        syscall_nr_restart_syscall      =  0;
         syscall_nr_exit                 =  1;
         syscall_nr_exit                 =  1;
         syscall_nr_fork                 =  2;
         syscall_nr_fork                 =  2;
         syscall_nr_read                 =  3;
         syscall_nr_read                 =  3;
@@ -239,10 +240,10 @@ Const
         syscall_nr_pivot_root           = 217;
         syscall_nr_pivot_root           = 217;
         syscall_nr_mincore              = 218;
         syscall_nr_mincore              = 218;
         syscall_nr_madvise              = 219;
         syscall_nr_madvise              = 219;
-        syscall_nr_madvise1             = 219;  { delete when C lib stub is removed }
+        { syscall_nr_madvise1             = 219; not found in C headers }
         syscall_nr_getdents64           = 220;
         syscall_nr_getdents64           = 220;
         syscall_nr_fcntl64              = 221;
         syscall_nr_fcntl64              = 221;
-        syscall_nr_security             = 223;  { syscall for security modules }
+        { syscall_nr_security             = 223; not found in C headers }
         syscall_nr_gettid               = 224;
         syscall_nr_gettid               = 224;
         syscall_nr_readahead            = 225;
         syscall_nr_readahead            = 225;
         syscall_nr_setxattr             = 226;
         syscall_nr_setxattr             = 226;
@@ -270,7 +271,7 @@ Const
         syscall_nr_io_submit             = 248;
         syscall_nr_io_submit             = 248;
         syscall_nr_io_cancel             = 249;
         syscall_nr_io_cancel             = 249;
         syscall_nr_fadvise64             = 250;
         syscall_nr_fadvise64             = 250;
-        syscall_nr_set_zone_reclaim      = 251;
+        { syscall_nr_set_zone_reclaim      = 251; not found in C headers }
         syscall_nr_exit_group            = 252;
         syscall_nr_exit_group            = 252;
         syscall_nr_lookup_dcookie        = 253;
         syscall_nr_lookup_dcookie        = 253;
         syscall_nr_epoll_create          = 254;
         syscall_nr_epoll_create          = 254;
@@ -279,14 +280,14 @@ Const
         syscall_nr_remap_file_pages      = 257;
         syscall_nr_remap_file_pages      = 257;
         syscall_nr_set_tid_address       = 258;
         syscall_nr_set_tid_address       = 258;
         syscall_nr_timer_create          = 259;
         syscall_nr_timer_create          = 259;
-        syscall_nr_timer_settime         = syscall_nr_timer_create+1;
-        syscall_nr_timer_gettime         = syscall_nr_timer_create+2;
-        syscall_nr_timer_getoverrun      = syscall_nr_timer_create+3;
-        syscall_nr_timer_delete          = syscall_nr_timer_create+4;
-        syscall_nr_clock_settime         = syscall_nr_timer_create+5;
-        syscall_nr_clock_gettime         = syscall_nr_timer_create+6;
-        syscall_nr_clock_getres          = syscall_nr_timer_create+7;
-        syscall_nr_clock_nanosleep       = syscall_nr_timer_create+8;
+        syscall_nr_timer_settime         = 260;
+        syscall_nr_timer_gettime         = 261;
+        syscall_nr_timer_getoverrun      = 262;
+        syscall_nr_timer_delete          = 263;
+        syscall_nr_clock_settime         = 264;
+        syscall_nr_clock_gettime         = 265;
+        syscall_nr_clock_getres          = 266;
+        syscall_nr_clock_nanosleep       = 267;
         syscall_nr_statfs64              = 268;
         syscall_nr_statfs64              = 268;
         syscall_nr_fstatfs64             = 269;
         syscall_nr_fstatfs64             = 269;
         syscall_nr_tgkill                = 270;
         syscall_nr_tgkill                = 270;
@@ -297,12 +298,12 @@ Const
         syscall_nr_get_mempolicy         = 275;
         syscall_nr_get_mempolicy         = 275;
         syscall_nr_set_mempolicy         = 276;
         syscall_nr_set_mempolicy         = 276;
         syscall_nr_mq_open               = 277;
         syscall_nr_mq_open               = 277;
-        syscall_nr_mq_unlink             = syscall_nr_mq_open+1;
-        syscall_nr_mq_timedsend          = syscall_nr_mq_open+2;
-        syscall_nr_mq_timedreceive       = syscall_nr_mq_open+3;
-        syscall_nr_mq_notify             = syscall_nr_mq_open+4;
-        syscall_nr_mq_getsetattr         = syscall_nr_mq_open+5;
-        syscall_nr_sys_kexec_load        = 283;
+        syscall_nr_mq_unlink             = 278;
+        syscall_nr_mq_timedsend          = 279;
+        syscall_nr_mq_timedreceive       = 280;
+        syscall_nr_mq_notify             = 281;
+        syscall_nr_mq_getsetattr         = 282;
+        syscall_nr_kexec_load            = 283;
         syscall_nr_waitid                = 284;
         syscall_nr_waitid                = 284;
         {   syscall_sys_nr_setaltroot      285 }
         {   syscall_sys_nr_setaltroot      285 }
         syscall_nr_add_key               = 286;
         syscall_nr_add_key               = 286;
@@ -339,3 +340,47 @@ Const
         syscall_nr_move_pages            = 317;
         syscall_nr_move_pages            = 317;
         syscall_nr_getcpu                = 318;
         syscall_nr_getcpu                = 318;
         syscall_nr_epoll_pwait           = 319;
         syscall_nr_epoll_pwait           = 319;
+        syscall_nr_utimensat             = 320;
+        syscall_nr_signalfd              = 321;
+        syscall_nr_timerfd_create        = 322;
+        syscall_nr_eventfd               = 323;
+        syscall_nr_fallocate             = 324;
+        syscall_nr_timerfd_settime       = 325;
+        syscall_nr_timerfd_gettime       = 326;
+        syscall_nr_signalfd4             = 327;
+        syscall_nr_eventfd2              = 328;
+        syscall_nr_epoll_create1         = 329;
+        syscall_nr_dup3                  = 330;
+        syscall_nr_pipe2                 = 331;
+        syscall_nr_inotify_init1         = 332;
+        syscall_nr_preadv                = 333;
+        syscall_nr_pwritev               = 334;
+        syscall_nr_rt_tgsigqueueinfo     = 335;
+        syscall_nr_perf_event_open       = 336;
+        syscall_nr_recvmmsg              = 337;
+        syscall_nr_fanotify_init         = 338;
+        syscall_nr_fanotify_mark         = 339;
+        syscall_nr_prlimit64             = 340;
+        syscall_nr_name_to_handle_at     = 341;
+        syscall_nr_open_by_handle_at     = 342;
+        syscall_nr_clock_adjtime         = 343;
+        syscall_nr_syncfs                = 344;
+        syscall_nr_sendmmsg              = 345;
+        syscall_nr_setns                 = 346;
+        syscall_nr_process_vm_readv      = 347;
+        syscall_nr_process_vm_writev     = 348;
+        syscall_nr_kcmp                  = 349;
+        syscall_nr_finit_module          = 350;
+        syscall_nr_sched_setattr         = 351;
+        syscall_nr_sched_getattr         = 352;
+        syscall_nr_seccomp               = 354;
+        syscall_nr_getrandom             = 355;
+        syscall_nr_memfd_create          = 356;
+        syscall_nr_bpf                   = 357;
+        syscall_nr_userfaultfd           = 374;
+        syscall_nr_membarrier            = 375;
+        syscall_nr_mlock2                = 376;
+        syscall_nr_copy_file_range       = 377;
+        syscall_nr_pkey_mprotect         = 380;
+        syscall_nr_pkey_alloc            = 381;
+        syscall_nr_pkey_free             = 382;

+ 1 - 0
rtl/linux/powerpc/stat.inc

@@ -43,6 +43,7 @@
         st_mtime  : clong;
         st_mtime  : clong;
         st_mtime_nsec : culong;
         st_mtime_nsec : culong;
         st_ctime  : clong;
         st_ctime  : clong;
+        st_ctime_nsec : culong;
         __unused3_ : culong;
         __unused3_ : culong;
         __unused4_ : culong;
         __unused4_ : culong;
         __unused5_ : culong;
         __unused5_ : culong;

+ 77 - 8
rtl/linux/powerpc/sysnr.inc

@@ -16,6 +16,7 @@
  **********************************************************************}
  **********************************************************************}
 
 
 const
 const
+  syscall_nr_restart_syscall = 0;
   syscall_nr_exit = 1;
   syscall_nr_exit = 1;
   syscall_nr_fork = 2;
   syscall_nr_fork = 2;
   syscall_nr_read = 3;
   syscall_nr_read = 3;
@@ -283,6 +284,11 @@ const
   syscall_nr_fadvise64_64 = 254;
   syscall_nr_fadvise64_64 = 254;
 {$endif}
 {$endif}
   syscall_nr_rtas = 255;
   syscall_nr_rtas = 255;
+  syscall_nr_sys_debug_setcontext = 256;
+  syscall_nr_migrate_pages = 258;
+  syscall_nr_mbind = 259;
+  syscall_nr_get_mempolicy = 260;
+  syscall_nr_set_mempolicy = 261;
   syscall_nr_mq_open = 262;
   syscall_nr_mq_open = 262;
   syscall_nr_mq_unlink = 263;
   syscall_nr_mq_unlink = 263;
   syscall_nr_mq_timedsend = 264;
   syscall_nr_mq_timedsend = 264;
@@ -300,8 +306,8 @@ const
   syscall_nr_inotify_add_watch = 276;
   syscall_nr_inotify_add_watch = 276;
   syscall_nr_inotify_rm_watch = 277;
   syscall_nr_inotify_rm_watch = 277;
   syscall_nr_spu_run          = 278;
   syscall_nr_spu_run          = 278;
-  syscall_nr_spu_create       = 278;
-  syscall_nr_pselect6         = 289;
+  syscall_nr_spu_create       = 279;
+  syscall_nr_pselect6         = 280;
   syscall_nr_ppoll            = 281;
   syscall_nr_ppoll            = 281;
   syscall_nr_unshare          = 282;
   syscall_nr_unshare          = 282;
   syscall_nr_splice           = 283;
   syscall_nr_splice           = 283;
@@ -312,7 +318,11 @@ const
   syscall_nr_mknodat          = 288;
   syscall_nr_mknodat          = 288;
   syscall_nr_fchownat         = 289;
   syscall_nr_fchownat         = 289;
   syscall_nr_futimesat        = 290;
   syscall_nr_futimesat        = 290;
-  syscall_nr_sys_fstatat64    = 291;
+{$ifdef cpu32}
+  syscall_nr_fstatat64        = 291;
+{$else}
+  syscall_nr_newfstatat       = 291;
+{$endif}
   syscall_nr_unlinkat         = 292;
   syscall_nr_unlinkat         = 292;
   syscall_nr_renameat         = 293;
   syscall_nr_renameat         = 293;
   syscall_nr_linkat           = 294;
   syscall_nr_linkat           = 294;
@@ -326,8 +336,67 @@ const
   syscall_nr_getcpu           = 302;
   syscall_nr_getcpu           = 302;
   syscall_nr_epoll_pwait      = 303;
   syscall_nr_epoll_pwait      = 303;
   syscall_nr_utimensat        = 304;
   syscall_nr_utimensat        = 304;
-  syscall_nr_fallocate        = 305;
-  syscall_nr_signalfd         = 306;
-  syscall_nr_timerfd          = 307;
-  syscall_nr_eventfd          = 308;
-  syscall_nr_sync_file_range2 = 309;
+  syscall_nr_signalfd         = 305;
+  syscall_nr_timerfd_create   = 306;
+  syscall_nr_eventfd          = 307;
+  syscall_nr_sync_file_range2 = 308;
+  syscall_nr_fallocate        = 309;
+  syscall_nr_subpage_prot     = 310;
+  syscall_nr_timerfd_settime  = 311;
+  syscall_nr_timerfd_gettime  = 312;
+  syscall_nr_signalfd4        = 313;
+  syscall_nr_eventfd2         = 314;
+  syscall_nr_epoll_create1    = 315;
+  syscall_nr_dup3             = 316;
+  syscall_nr_pipe2            = 317;
+  syscall_nr_inotify_init1    = 318;
+  syscall_nr_perf_event_open  = 319;
+  syscall_nr_preadv           = 320;
+  syscall_nr_pwritev          = 321;
+  syscall_nr_rt_tgsigqueueinfo = 322;
+  syscall_nr_fanotify_init    = 323;
+  syscall_nr_fanotify_mark    = 324;
+  syscall_nr_prlimit64        = 325;
+  syscall_nr_socket           = 326;
+  syscall_nr_bind             = 327;
+  syscall_nr_connect          = 328;
+  syscall_nr_listen           = 329;
+  syscall_nr_accept           = 330;
+  syscall_nr_getsockname      = 331;
+  syscall_nr_getpeername      = 332;
+  syscall_nr_socketpair       = 333;
+  syscall_nr_send             = 334;
+  syscall_nr_sendto           = 335;
+  syscall_nr_recv             = 336;
+  syscall_nr_recvfrom         = 337;
+  syscall_nr_shutdown         = 338;
+  syscall_nr_setsockopt       = 339;
+  syscall_nr_getsockopt       = 340;
+  syscall_nr_sendmsg          = 341;
+  syscall_nr_recvmsg          = 342;
+  syscall_nr_recvmmsg         = 343;
+  syscall_nr_accept4          = 344;
+  syscall_nr_name_to_handle_at = 345;
+  syscall_nr_open_by_handle_at = 346;
+  syscall_nr_clock_adjtime    = 347;
+  syscall_nr_syncfs           = 348;
+  syscall_nr_sendmmsg         = 349;
+  syscall_nr_setns            = 350;
+  syscall_nr_process_vm_readv = 351;
+  syscall_nr_process_vm_writev = 352;
+  syscall_nr_finit_module     = 353;
+  syscall_nr_kcmp             = 354;
+  syscall_nr_sched_setattr    = 355;
+  syscall_nr_sched_getattr    = 356;
+  syscall_nr_renameat2        = 357;
+  syscall_nr_seccomp          = 358;
+  syscall_nr_getrandom        = 359;
+  syscall_nr_memfd_create     = 360;
+  syscall_nr_bpf              = 361;
+  syscall_nr_execveat         = 362;
+  syscall_nr_switch_endian    = 363;
+  syscall_nr_userfaultfd      = 364;
+  syscall_nr_membarrier       = 365;
+  syscall_nr_mlock2           = 378;
+  syscall_nr_copy_file_range  = 379;
+

+ 4 - 2
rtl/linux/ptypes.inc

@@ -195,7 +195,8 @@ Type
     fsid    : array[0..1] of cint;          { File system ID }
     fsid    : array[0..1] of cint;          { File system ID }
     namelen : clong; { Maximum name length in system }
     namelen : clong; { Maximum name length in system }
     frsize  : clong;
     frsize  : clong;
-    spare   : array [0..4] of clong; { For later use }
+    flags   : clong; 
+    spare   : array [0..3] of clong; { For later use }
   end;
   end;
   {$else}
   {$else}
   TStatfs = record
   TStatfs = record
@@ -209,7 +210,8 @@ Type
     fsid    : array[0..1] of cint;          { File system ID }
     fsid    : array[0..1] of cint;          { File system ID }
     namelen,           { Maximum name length in system }
     namelen,           { Maximum name length in system }
     frsize  : cint;
     frsize  : cint;
-    spare   : array [0..4] of cint; { For later use }
+    flags   : cint; 
+    spare   : array [0..3] of cint; { For later use }
   end;
   end;
   {$endif}
   {$endif}
   PStatFS=^TStatFS;
   PStatFS=^TStatFS;

+ 78 - 31
rtl/linux/sparcgen/sysnr.inc

@@ -20,6 +20,7 @@
 }
 }
 
 
 Const
 Const
+      syscall_nr_restart_syscall    = 0 ; // Linux Specific
       syscall_nr_exit               = 1 ; // Common
       syscall_nr_exit               = 1 ; // Common
       syscall_nr_fork               = 2 ; // Common
       syscall_nr_fork               = 2 ; // Common
       syscall_nr_read               = 3 ; // Common
       syscall_nr_read               = 3 ; // Common
@@ -44,17 +45,21 @@ Const
       syscall_nr_capset            = 22 ; // Linux Specific
       syscall_nr_capset            = 22 ; // Linux Specific
       syscall_nr_setuid            = 23 ; // Implemented via setreuid in SunOS
       syscall_nr_setuid            = 23 ; // Implemented via setreuid in SunOS
       syscall_nr_getuid            = 24 ; // Common
       syscall_nr_getuid            = 24 ; // Common
-//       syscall_nr_time alias     = 25    ENOSYS under SunOS
+      syscall_nr_vmsplice          = 25 ; // ENOSYS under SunOS
       syscall_nr_ptrace            = 26 ; // Common
       syscall_nr_ptrace            = 26 ; // Common
       syscall_nr_alarm             = 27 ; // Implemented via setitimer in SunOS
       syscall_nr_alarm             = 27 ; // Implemented via setitimer in SunOS
       syscall_nr_sigaltstack       = 28 ; // Common
       syscall_nr_sigaltstack       = 28 ; // Common
       syscall_nr_pause             = 29 ; // Is sigblock(0)->sigpause() in SunOS
       syscall_nr_pause             = 29 ; // Is sigblock(0)->sigpause() in SunOS
       syscall_nr_utime             = 30 ; // Implemented via utimes() under SunOS
       syscall_nr_utime             = 30 ; // Implemented via utimes() under SunOS
+{$ifndef CPUSPARC64}
       syscall_nr_lchown32          = 31 ; // Linux sparc32 specific
       syscall_nr_lchown32          = 31 ; // Linux sparc32 specific
       syscall_nr_fchown32          = 32 ; // Linux sparc32 specific
       syscall_nr_fchown32          = 32 ; // Linux sparc32 specific
+{$endif ndef CPUSPARC64}
       syscall_nr_access            = 33 ; // Common
       syscall_nr_access            = 33 ; // Common
       syscall_nr_nice              = 34 ; // Implemented via get/setpriority() in SunOS
       syscall_nr_nice              = 34 ; // Implemented via get/setpriority() in SunOS
+{$ifndef CPUSPARC64}
       syscall_nr_chown32           = 35 ; // Linux sparc32 specific
       syscall_nr_chown32           = 35 ; // Linux sparc32 specific
+{$endif ndef CPUSPARC64}
       syscall_nr_sync              = 36 ; // Common
       syscall_nr_sync              = 36 ; // Common
       syscall_nr_kill              = 37 ; // Common
       syscall_nr_kill              = 37 ; // Common
       syscall_nr_stat              = 38 ; // Common
       syscall_nr_stat              = 38 ; // Common
@@ -63,7 +68,9 @@ Const
       syscall_nr_dup               = 41 ; // Common
       syscall_nr_dup               = 41 ; // Common
       syscall_nr_pipe              = 42 ; // Common
       syscall_nr_pipe              = 42 ; // Common
       syscall_nr_times             = 43 ; // Implemented via getrusage() in SunOS
       syscall_nr_times             = 43 ; // Implemented via getrusage() in SunOS
+{$ifndef CPUSPARC64}
       syscall_nr_getuid32          = 44 ; // Linux sparc32 specific
       syscall_nr_getuid32          = 44 ; // Linux sparc32 specific
+{$endif ndef CPUSPARC64}
       syscall_nr_umount2           = 45 ; // Linux Specific
       syscall_nr_umount2           = 45 ; // Linux Specific
       syscall_nr_setgid            = 46 ; // Implemented via setregid() in SunOS
       syscall_nr_setgid            = 46 ; // Implemented via setregid() in SunOS
       syscall_nr_getgid            = 47 ; // Common
       syscall_nr_getgid            = 47 ; // Common
@@ -72,10 +79,14 @@ Const
       syscall_nr_getegid           = 50 ; // SunOS calls getgid()
       syscall_nr_getegid           = 50 ; // SunOS calls getgid()
       syscall_nr_acct              = 51 ; // Common
       syscall_nr_acct              = 51 ; // Common
 //       syscall_nr_memory_ordering= 52    Linux sparc64 specific
 //       syscall_nr_memory_ordering= 52    Linux sparc64 specific
+{$ifndef CPUSPARC64}
       syscall_nr_getgid32          = 53 ; // Linux sparc32 specific
       syscall_nr_getgid32          = 53 ; // Linux sparc32 specific
+{$endif ndef CPUSPARC64}
       syscall_nr_ioctl             = 54 ; // Common
       syscall_nr_ioctl             = 54 ; // Common
       syscall_nr_reboot            = 55 ; // Common
       syscall_nr_reboot            = 55 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_mmap2             = 56 ; // Linux sparc32 Specific
       syscall_nr_mmap2             = 56 ; // Linux sparc32 Specific
+{$endif ndef CPUSPARC64}
       syscall_nr_symlink           = 57 ; // Common
       syscall_nr_symlink           = 57 ; // Common
       syscall_nr_readlink          = 58 ; // Common
       syscall_nr_readlink          = 58 ; // Common
       syscall_nr_execve            = 59 ; // Common
       syscall_nr_execve            = 59 ; // Common
@@ -88,32 +99,50 @@ Const
       syscall_nr_vfork             = 66 ; // Common
       syscall_nr_vfork             = 66 ; // Common
       syscall_nr_pread64           = 67 ; // Linux Specific
       syscall_nr_pread64           = 67 ; // Linux Specific
       syscall_nr_pwrite64          = 68 ; // Linux Specific
       syscall_nr_pwrite64          = 68 ; // Linux Specific
+{$ifndef CPUSPARC64}
       syscall_nr_geteuid32         = 69 ; // Linux sparc32, sbrk under SunOS
       syscall_nr_geteuid32         = 69 ; // Linux sparc32, sbrk under SunOS
       syscall_nr_getegid32         = 70 ; // Linux sparc32, sstk under SunOS
       syscall_nr_getegid32         = 70 ; // Linux sparc32, sstk under SunOS
+{$endif ndef CPUSPARC64}
       syscall_nr_mmap              = 71 ; // Common
       syscall_nr_mmap              = 71 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_setreuid32        = 72 ; // Linux sparc32, vadvise under SunOS
       syscall_nr_setreuid32        = 72 ; // Linux sparc32, vadvise under SunOS
+{$endif ndef CPUSPARC64}
       syscall_nr_munmap            = 73 ; // Common
       syscall_nr_munmap            = 73 ; // Common
       syscall_nr_mprotect          = 74 ; // Common
       syscall_nr_mprotect          = 74 ; // Common
       syscall_nr_madvise           = 75 ; // Common
       syscall_nr_madvise           = 75 ; // Common
       syscall_nr_vhangup           = 76 ; // Common
       syscall_nr_vhangup           = 76 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_truncate64        = 77 ; // Linux sparc32 Specific
       syscall_nr_truncate64        = 77 ; // Linux sparc32 Specific
+{$endif ndef CPUSPARC64}
       syscall_nr_mincore           = 78 ; // Common
       syscall_nr_mincore           = 78 ; // Common
       syscall_nr_getgroups         = 79 ; // Common
       syscall_nr_getgroups         = 79 ; // Common
       syscall_nr_setgroups         = 80 ; // Common
       syscall_nr_setgroups         = 80 ; // Common
       syscall_nr_getpgrp           = 81 ; // Common
       syscall_nr_getpgrp           = 81 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_setgroups32       = 82 ; // Linux sparc32, setpgrp under SunOS
       syscall_nr_setgroups32       = 82 ; // Linux sparc32, setpgrp under SunOS
+{$endif ndef CPUSPARC64}
       syscall_nr_setitimer         = 83 ; // Common
       syscall_nr_setitimer         = 83 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_ftruncate64       = 84 ; // Linux sparc32 Specific
       syscall_nr_ftruncate64       = 84 ; // Linux sparc32 Specific
+{$endif ndef CPUSPARC64}
       syscall_nr_swapon            = 85 ; // Common
       syscall_nr_swapon            = 85 ; // Common
       syscall_nr_getitimer         = 86 ; // Common
       syscall_nr_getitimer         = 86 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_setuid32          = 87 ; // Linux sparc32, gethostname under SunOS
       syscall_nr_setuid32          = 87 ; // Linux sparc32, gethostname under SunOS
+{$endif ndef CPUSPARC64}
       syscall_nr_sethostname       = 88 ; // Common
       syscall_nr_sethostname       = 88 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_setgid32          = 89 ; // Linux sparc32, getdtablesize under SunOS
       syscall_nr_setgid32          = 89 ; // Linux sparc32, getdtablesize under SunOS
+{$endif ndef CPUSPARC64}
       syscall_nr_dup2              = 90 ; // Common
       syscall_nr_dup2              = 90 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_setfsuid32        = 91 ; // Linux sparc32, getdopt under SunOS
       syscall_nr_setfsuid32        = 91 ; // Linux sparc32, getdopt under SunOS
+{$endif ndef CPUSPARC64}
       syscall_nr_fcntl             = 92 ; // Common
       syscall_nr_fcntl             = 92 ; // Common
       syscall_nr_select            = 93 ; // Common
       syscall_nr_select            = 93 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_setfsgid32        = 94 ; // Linux sparc32, setdopt under SunOS
       syscall_nr_setfsgid32        = 94 ; // Linux sparc32, setdopt under SunOS
+{$endif ndef CPUSPARC64}
       syscall_nr_fsync             = 95 ; // Common
       syscall_nr_fsync             = 95 ; // Common
       syscall_nr_setpriority       = 96 ; // Common
       syscall_nr_setpriority       = 96 ; // Common
       syscall_nr_socket            = 97 ; // Common
       syscall_nr_socket            = 97 ; // Common
@@ -127,14 +156,23 @@ Const
       syscall_nr_rt_sigtimedwait  = 105 ; // Linux Specific
       syscall_nr_rt_sigtimedwait  = 105 ; // Linux Specific
       syscall_nr_rt_sigqueueinfo  = 106 ; // Linux Specific
       syscall_nr_rt_sigqueueinfo  = 106 ; // Linux Specific
       syscall_nr_rt_sigsuspend    = 107 ; // Linux Specific
       syscall_nr_rt_sigsuspend    = 107 ; // Linux Specific
+{$ifndef CPUSPARC64}
       syscall_nr_setresuid32      = 108 ; // Linux Specific, sigvec under SunOS
       syscall_nr_setresuid32      = 108 ; // Linux Specific, sigvec under SunOS
       syscall_nr_getresuid32      = 109 ; // Linux Specific, sigblock under SunOS
       syscall_nr_getresuid32      = 109 ; // Linux Specific, sigblock under SunOS
       syscall_nr_setresgid32      = 110 ; // Linux Specific, sigsetmask under SunOS
       syscall_nr_setresgid32      = 110 ; // Linux Specific, sigsetmask under SunOS
       syscall_nr_getresgid32      = 111 ; // Linux Specific, sigpause under SunOS
       syscall_nr_getresgid32      = 111 ; // Linux Specific, sigpause under SunOS
       syscall_nr_setregid32       = 112 ; // Linux sparc32, sigstack under SunOS
       syscall_nr_setregid32       = 112 ; // Linux sparc32, sigstack under SunOS
+{$else}
+      syscall_nr_setresuid        = 108 ; // Linux Specific, sigvec under SunOS
+      syscall_nr_getresuid        = 109 ; // Linux Specific, sigblock under SunOS
+      syscall_nr_setresgid        = 110 ; // Linux Specific, sigsetmask under SunOS
+      syscall_nr_getresgid        = 111 ; // Linux Specific, sigpause under SunOS
+{$endif}
       syscall_nr_recvmsg          = 113 ; // Common
       syscall_nr_recvmsg          = 113 ; // Common
       syscall_nr_sendmsg          = 114 ; // Common
       syscall_nr_sendmsg          = 114 ; // Common
+{$ifndef CPUSPARC64}
       syscall_nr_getgroups32      = 115 ; // Linux sparc32, vtrace under SunOS
       syscall_nr_getgroups32      = 115 ; // Linux sparc32, vtrace under SunOS
+{$endif ndef CPUSPARC64}
       syscall_nr_gettimeofday     = 116 ; // Common
       syscall_nr_gettimeofday     = 116 ; // Common
       syscall_nr_getrusage        = 117 ; // Common
       syscall_nr_getrusage        = 117 ; // Common
       syscall_nr_getsockopt       = 118 ; // Common
       syscall_nr_getsockopt       = 118 ; // Common
@@ -159,9 +197,8 @@ Const
       syscall_nr_rmdir            = 137 ; // Common
       syscall_nr_rmdir            = 137 ; // Common
       syscall_nr_utimes           = 138 ; // SunOS Specific
       syscall_nr_utimes           = 138 ; // SunOS Specific
       syscall_nr_stat64           = 139 ; // Linux sparc32 Specific
       syscall_nr_stat64           = 139 ; // Linux sparc32 Specific
-//       syscall_nr_adjtime       = 140    SunOS Specific
+      syscall_nr_sendfile64       = 140 ; // adjtime under SunOS
       syscall_nr_getpeername      = 141 ; // Common
       syscall_nr_getpeername      = 141 ; // Common
-//       syscall_nr_gethostid     = 142    SunOS Specific
       syscall_nr_futex            = 142 ; // gethostid under SunOS
       syscall_nr_futex            = 142 ; // gethostid under SunOS
       syscall_nr_gettid           = 143 ; // ENOSYS under SunOS
       syscall_nr_gettid           = 143 ; // ENOSYS under SunOS
       syscall_nr_getrlimit        = 144 ; // Common
       syscall_nr_getrlimit        = 144 ; // Common
@@ -175,48 +212,52 @@ Const
       syscall_nr_inotify_add_watch= 152 ; // Linux specific
       syscall_nr_inotify_add_watch= 152 ; // Linux specific
       syscall_nr_poll             = 153 ; // Common
       syscall_nr_poll             = 153 ; // Common
       syscall_nr_getdents64       = 154 ; // Linux specific
       syscall_nr_getdents64       = 154 ; // Linux specific
+{$ifndef CPUSPARC64}
       syscall_nr_fcntl64          = 155 ; // Linux sparc32 Specific
       syscall_nr_fcntl64          = 155 ; // Linux sparc32 Specific
+{$endif ndef CPUSPARC64}
       syscall_nr_inotify_rm_watch = 156 ; // Linux specific
       syscall_nr_inotify_rm_watch = 156 ; // Linux specific
       syscall_nr_statfs           = 157 ; // Common
       syscall_nr_statfs           = 157 ; // Common
       syscall_nr_fstatfs          = 158 ; // Common
       syscall_nr_fstatfs          = 158 ; // Common
       syscall_nr_umount           = 159 ; // Common
       syscall_nr_umount           = 159 ; // Common
-//       syscall_nr_async_daemon  = 160    SunOS Specific
-//       syscall_nr_getfh         = 161    SunOS Specific
+      syscall_nr_sched_set_affinity = 160; // Linux specific, async_daemon under SunOS
+      syscall_nr_sched_get_affinity = 161; // Linux specific, getfh under SunOS
       syscall_nr_getdomainname    = 162 ; // SunOS Specific
       syscall_nr_getdomainname    = 162 ; // SunOS Specific
       syscall_nr_setdomainname    = 163 ; // Common
       syscall_nr_setdomainname    = 163 ; // Common
-//       syscall_nr_ni_syscall    = 164    ENOSYS under SunOS
+{$ifdef CPUSPARC64}
+      syscall_nr_utrap_install    = 164 ; // SYSV ABI/v9 required
+{$endif def CPUSPARC64}
       syscall_nr_quotactl         = 165 ; // Common
       syscall_nr_quotactl         = 165 ; // Common
-//       syscall_nr_exportfs      = 166    SunOS Specific
+      syscall_nr_set_tid_address  = 166 ; // Linux specific, exportfs under SunOS
       syscall_nr_mount            = 167 ; // Common
       syscall_nr_mount            = 167 ; // Common
       syscall_nr_ustat            = 168 ; // Common
       syscall_nr_ustat            = 168 ; // Common
-//       syscall_nr_semsys        = 169    SunOS Specific
-//       syscall_nr_msgsys        = 170    SunOS Specific
-//       syscall_nr_shmsys        = 171    SunOS Specific
-//       syscall_nr_auditsys      = 172    SunOS Specific
-//       syscall_nr_rfssys        = 173    SunOS Specific
+      syscall_nr_setxattr         = 169 ; // SunOS: semsys
+      syscall_nr_lsetxattr        = 170 ; // SunOS: msgsys
+      syscall_nr_fsetxattr        = 171 ; // SunOS: shmsys
+      syscall_nr_getxattr         = 172 ; // SunOS: auditsys
+      syscall_nr_lgetxattr        = 173 ; // SunOS: rfssys
       syscall_nr_getdents         = 174 ; // Common
       syscall_nr_getdents         = 174 ; // Common
       syscall_nr_setsid           = 175 ; // Common
       syscall_nr_setsid           = 175 ; // Common
       syscall_nr_fchdir           = 176 ; // Common
       syscall_nr_fchdir           = 176 ; // Common
-//       syscall_nr_fchroot       = 177    SunOS Specific
-//       syscall_nr_vpixsys       = 178    SunOS Specific
-//       syscall_nr_aioread       = 179    SunOS Specific
-//       syscall_nr_aiowrite      = 180    SunOS Specific
-//       syscall_nr_aiowait       = 181    SunOS Specific
-//       syscall_nr_aiocancel     = 182    SunOS Specific
+      syscall_nr_fgetxattr        = 177 ; // SunOS: fchroot
+      syscall_nr_listxattr        = 178 ; // SunOS: vpixsys
+      syscall_nr_llistxattr       = 179 ; // SunOS: aioread
+      syscall_nr_flistxattr       = 180 ; // SunOS: aiowrite
+      syscall_nr_removexattr      = 181 ; // SunOS: aiowait
+      syscall_nr_lremovexattr     = 182 ; // SunOS: aiocancel
       syscall_nr_sigpending       = 183 ; // Common
       syscall_nr_sigpending       = 183 ; // Common
       syscall_nr_query_module     = 184 ; // Linux Specific
       syscall_nr_query_module     = 184 ; // Linux Specific
       syscall_nr_setpgid          = 185 ; // Common
       syscall_nr_setpgid          = 185 ; // Common
-//       syscall_nr_pathconf      = 186    SunOS Specific
+      syscall_nr_fremovexattr     = 186 ; // SunOS: pathconf
       syscall_nr_tkill            = 187 ; // SunOS: fpathconf
       syscall_nr_tkill            = 187 ; // SunOS: fpathconf
       syscall_nr_exit_group       = 188 ; // SunOS sysconf
       syscall_nr_exit_group       = 188 ; // SunOS sysconf
       syscall_nr_uname            = 189 ; // Linux Specific
       syscall_nr_uname            = 189 ; // Linux Specific
       syscall_nr_init_module      = 190 ; // Linux Specific
       syscall_nr_init_module      = 190 ; // Linux Specific
       syscall_nr_personality      = 191 ; // Linux Specific
       syscall_nr_personality      = 191 ; // Linux Specific
-//       syscall_nr_prof          = 192    Linux Specific
+      syscall_nr_remap_file_pages = 192 ; // Linux Specific
       syscall_nr_epoll_create     = 193 ; // Linux Specific - was break
       syscall_nr_epoll_create     = 193 ; // Linux Specific - was break
       syscall_nr_epoll_ctl        = 194 ; // Linux Specific - was lock
       syscall_nr_epoll_ctl        = 194 ; // Linux Specific - was lock
       syscall_nr_epoll_wait       = 195 ; // Linux Specific - was mpx
       syscall_nr_epoll_wait       = 195 ; // Linux Specific - was mpx
-//       syscall_nr_ulimit        = 196    Linux Specific
+      syscall_nr_ioprio_set       = 196 ; // Linux Specific
       syscall_nr_getppid          = 197 ; // Linux Specific
       syscall_nr_getppid          = 197 ; // Linux Specific
       syscall_nr_sigaction        = 198 ; // Linux Specific
       syscall_nr_sigaction        = 198 ; // Linux Specific
       syscall_nr_sgetmask         = 199 ; // Linux Specific
       syscall_nr_sgetmask         = 199 ; // Linux Specific
@@ -228,17 +269,17 @@ Const
       syscall_nr_readahead        = 205 ; // Linux Specific
       syscall_nr_readahead        = 205 ; // Linux Specific
       syscall_nr_socketcall       = 206 ; // Linux Specific
       syscall_nr_socketcall       = 206 ; // Linux Specific
       syscall_nr_syslog           = 207 ; // Linux Specific
       syscall_nr_syslog           = 207 ; // Linux Specific
-//       syscall_nr_olduname      = 208    Linux Specific
-//       syscall_nr_iopl          = 209    Linux Specific - i386 specific, unused
-//       syscall_nr_idle          = 210    Linux Specific - was sys_idle, now unused
-//       syscall_nr_vm86          = 211    Linux Specific - i386 specific, unused
+      syscall_nr_lookup_dcookie   = 208 ; // Linux Specific
+      syscall_nr_fadvise64        = 209 ; // Linux Specific
+      syscall_nr_fadvise64_64     = 210 ; // Linux Specific
+      syscall_nr_tgkill           = 211 ; // Linux Specific
       syscall_nr_waitpid          = 212 ; // Linux Specific
       syscall_nr_waitpid          = 212 ; // Linux Specific
       syscall_nr_swapoff          = 213 ; // Linux Specific
       syscall_nr_swapoff          = 213 ; // Linux Specific
       syscall_nr_sysinfo          = 214 ; // Linux Specific
       syscall_nr_sysinfo          = 214 ; // Linux Specific
       syscall_nr_ipc              = 215 ; // Linux Specific
       syscall_nr_ipc              = 215 ; // Linux Specific
       syscall_nr_sigreturn        = 216 ; // Linux Specific
       syscall_nr_sigreturn        = 216 ; // Linux Specific
       syscall_nr_clone            = 217 ; // Linux Specific
       syscall_nr_clone            = 217 ; // Linux Specific
-//       syscall_nr_modify_ldt    = 218    Linux Specific - i386 specific, unused
+      syscall_nr_ioprio_get       = 218 ; // Linux Specific
       syscall_nr_adjtimex         = 219 ; // Linux Specific
       syscall_nr_adjtimex         = 219 ; // Linux Specific
       syscall_nr_sigprocmask      = 220 ; // Linux Specific
       syscall_nr_sigprocmask      = 220 ; // Linux Specific
       syscall_nr_create_module    = 221 ; // Linux Specific
       syscall_nr_create_module    = 221 ; // Linux Specific
@@ -251,11 +292,13 @@ Const
       syscall_nr_setfsuid         = 228 ; // Linux Specific
       syscall_nr_setfsuid         = 228 ; // Linux Specific
       syscall_nr_setfsgid         = 229 ; // Linux Specific
       syscall_nr_setfsgid         = 229 ; // Linux Specific
       syscall_nr__newselect       = 230 ; // Linux Specific
       syscall_nr__newselect       = 230 ; // Linux Specific
+{$ifndef CPUSPARC64}
       syscall_nr_time             = 231 ; // Linux Specific
       syscall_nr_time             = 231 ; // Linux Specific
-//       syscall_nr_oldstat       = 232    Linux Specific
+{$endif ndef CPUSPARC64}
+      syscall_nr_splice           = 232 ; // Linux Specific
       syscall_nr_stime            = 233 ; // Linux Specific
       syscall_nr_stime            = 233 ; // Linux Specific
-//       syscall_nr_oldfstat      = 234    Linux Specific
-//       syscall_nr_phys          = 235    Linux Specific
+      syscall_nr_statfs64         = 234 ; // Linux Specific
+      syscall_nr_fstatfs64        = 235 ; // Linux Specific
       syscall_nr__llseek          = 236 ; // Linux Specific
       syscall_nr__llseek          = 236 ; // Linux Specific
       syscall_nr_mlock            = 237;
       syscall_nr_mlock            = 237;
       syscall_nr_munlock          = 238;
       syscall_nr_munlock          = 238;
@@ -287,7 +330,9 @@ Const
       syscall_nr_timer_getoverrun  = 264;
       syscall_nr_timer_getoverrun  = 264;
       syscall_nr_timer_delete      = 265;
       syscall_nr_timer_delete      = 265;
       syscall_nr_timer_create      = 266;
       syscall_nr_timer_create      = 266;
-      { syscall_nr_vserver           267 Reserved for VSERVER }
+{$ifdef VSERVER}
+      syscall_nr_vserver           = 267; //  Reserved for VSERVER
+{$endif def VSERVER}
       syscall_nr_io_setup          = 268;
       syscall_nr_io_setup          = 268;
       syscall_nr_io_destroy        = 269;
       syscall_nr_io_destroy        = 269;
       syscall_nr_io_submit         = 270;
       syscall_nr_io_submit         = 270;
@@ -332,7 +377,7 @@ Const
       syscall_nr_epoll_pwait       = 309;
       syscall_nr_epoll_pwait       = 309;
       syscall_nr_utimensat         = 310;
       syscall_nr_utimensat         = 310;
       syscall_nr_signalfd          = 311;
       syscall_nr_signalfd          = 311;
-      syscall_nr_timerfd           = 312;
+      syscall_nr_timerfd_create    = 312;
       syscall_nr_eventfd           = 313;
       syscall_nr_eventfd           = 313;
       syscall_nr_fallocate         = 314;
       syscall_nr_fallocate         = 314;
       syscall_nr_timerfd_settime   = 315;
       syscall_nr_timerfd_settime   = 315;
@@ -381,3 +426,5 @@ Const
       syscall_nr_preadv2           = 358;
       syscall_nr_preadv2           = 358;
       syscall_nr_pwritev2          = 359;
       syscall_nr_pwritev2          = 359;
       syscall_nr_statx             = 360;
       syscall_nr_statx             = 360;
+      syscall_nr_io_pgetevents     = 361;
+

+ 151 - 0
rtl/linux/t_linux.h2paschk

@@ -0,0 +1,151 @@
+# OpenBSD RTL-to-C structure compatibility checker description file
+#
+# Use
+#   h2paschk t_openbsd.h2paschk
+#
+# ...to generate Pascal and C code, then make sure they both compile and that
+# the Pascal program produces the same output as the C program for each
+# supported architecture.
+
+@Pascal uses baseunix;
+@Pascal begin
+@C #define _LARGEFILE_SOURCE 1
+@C #define _FILE_OFFSET_BITS 64
+## @C #define _USE_FILE_OFFSET64
+
+@C #include <sys/types.h>
+@C #include <sys/stat.h>
+@C #include <sys/statfs.h>
+@C #include <sys/mount.h>
+@C #include <sys/time.h>
+@C #include <sys/times.h>
+@C #include <sys/resource.h>
+@C #include <sys/uio.h>
+@C #include <dirent.h>
+@C #include <poll.h>
+@C #include <utime.h>
+@C #include <fcntl.h>
+@C #include <unistd.h>
+@C #include <stdio.h>
+@C #include <stddef.h>
+@C int main()
+@C {
+
+@record timespec,struct timespec
+.tv_sec
+.tv_nsec
+
+@record stat,struct stat
+.st_dev
+.st_ino
+.st_mode
+#.st_padding0
+.st_nlink
+.st_uid
+.st_gid
+#.st_padding1
+.st_rdev
+.st_size
+.st_blocks
+.st_blksize
+.st_atime,st_atim.tv_sec
+.st_atime_nsec,st_atim.tv_nsec
+.st_mtime,st_mtim.tv_sec
+.st_mtime_nsec,st_mtim.tv_nsec
+.st_ctime,st_ctim.tv_sec
+.st_ctime_nsec,st_ctim.tv_nsec
+@Pascal {$if defined (CPUPOWERPC) or defined(CPUPOWERPC64)}
+@C #ifdef __powerpc__
+.__unused4
+.__unused5
+@Pascal {$ifdef CPU64}
+@C #ifdef __LP64__
+.__unused6
+@C #endif
+@Pascal {$endif CPU64}
+@C #endif
+@Pascal {$endif powerpc}
+#.st_flags
+#.st_gen
+
+@record dirent,struct dirent
+.d_fileno
+.d_off
+.d_reclen
+.d_type
+#.d_pad0
+#.d_namlen
+#.d_pad1
+.d_name
+
+@record TStatFs,struct statfs
+.fstype,f_type
+.bsize,f_bsize
+.blocks,f_blocks
+.bfree,f_bfree
+.bavail,f_bavail
+.files,f_files
+.ffree,f_ffree
+.fsid,f_fsid
+.namelen,f_namelen
+.frsize,f_frsize
+.flags,f_flags
+.spare,f_spare
+
+@record pollfd,struct pollfd
+.fd
+.events
+.revents
+
+@record utimbuf,struct utimbuf
+.actime
+.modtime
+
+@record flock,struct flock
+.l_start
+.l_len
+.l_pid
+.l_type
+.l_whence
+
+@record tms,struct tms
+.tms_utime
+.tms_stime
+.tms_cutime
+.tms_cstime
+
+@record timezone,struct timezone
+.tz_minuteswest
+.tz_dsttime
+
+#@record rusage,struct rusage
+#.ru_utime
+#.ru_stime
+#.ru_maxrss
+#.ru_ixrss
+#.ru_idrss
+#.ru_isrss
+#.ru_minflt
+#.ru_majflt
+#.ru_nswap
+#.ru_inblock
+#.ru_oublock
+#.ru_msgsnd
+#.ru_msgrcv
+#.ru_nsignals
+#.ru_nvcsw
+#.ru_nivcsw
+
+@record TRLimit,struct rlimit
+.rlim_cur
+.rlim_max
+
+@record iovec,struct iovec
+.iov_base
+.iov_len
+
+@C   return 0;
+@C }
+
+@Pascal end.
+

+ 49 - 1
rtl/linux/x86_64/sysnr.inc

@@ -340,4 +340,52 @@ const
   syscall_nr_sync_file_range    = 277;
   syscall_nr_sync_file_range    = 277;
   syscall_nr_vmsplice           = 278;
   syscall_nr_vmsplice           = 278;
   syscall_nr_move_pages         = 279;
   syscall_nr_move_pages         = 279;
-
+  syscall_nr_utimensat          = 280;
+  syscall_nr_epoll_pwait        = 281;
+  syscall_nr_signalfd           = 282;
+  syscall_nr_timerfd_create     = 283;
+  syscall_nr_eventfd            = 284;
+  syscall_nr_fallocate          = 285;
+  syscall_nr_timerfd_settime    = 286;
+  syscall_nr_timerfd_gettime    = 287;
+  syscall_nr_accept4            = 288;
+  syscall_nr_signalfd4          = 289;
+  syscall_nr_eventfd2           = 290;
+  syscall_nr_epoll_create1      = 291;
+  syscall_nr_dup3               = 292;
+  syscall_nr_pipe2              = 293;
+  syscall_nr_inotify_init1      = 294;
+  syscall_nr_preadv             = 295;
+  syscall_nr_pwritev            = 296;
+  syscall_nr_rt_tgsigqueueinfo  = 297;
+  syscall_nr_perf_event_open    = 298;
+  syscall_nr_recvmmsg           = 299;
+  syscall_nr_fanotify_init      = 300;
+  syscall_nr_fanotify_mark      = 301;
+  syscall_nr_prlimit64          = 302;
+  syscall_nr_name_to_handle_at  = 303;
+  syscall_nr_open_by_handle_at  = 304;
+  syscall_nr_clock_adjtime      = 305;
+  syscall_nr_syncfs             = 306;
+  syscall_nr_sendmmsg           = 307;
+  syscall_nr_setns              = 308;
+  syscall_nr_getcpu             = 309;
+  syscall_nr_process_vm_readv   = 310;
+  syscall_nr_process_vm_writev  = 311;
+  syscall_nr_kcmp               = 312;
+  syscall_nr_finit_module       = 313;
+  syscall_nr_sched_setattr      = 314;
+  syscall_nr_sched_getattr      = 315;
+  syscall_nr_renameat2          = 316;
+  syscall_nr_seccomp            = 317;
+  syscall_nr_getrandom          = 318;
+  syscall_nr_memfd_create       = 319;
+  syscall_nr_kexec_file_load    = 320;
+  syscall_nr_bpf                = 321;
+  syscall_nr_userfaultfd        = 323;
+  syscall_nr_membarrier         = 324;
+  syscall_nr_mlock2             = 325;
+  syscall_nr_copy_file_range    = 326;
+  syscall_nr_pkey_mprotect      = 329;
+  syscall_nr_pkey_alloc         = 330;
+  syscall_nr_pkey_free          = 331;

+ 2 - 1
rtl/objpas/classes/streams.inc

@@ -1047,6 +1047,7 @@ begin
   inherited Destroy;
   inherited Destroy;
 end;
 end;
 
 
+{$push}
 {$warnings off}
 {$warnings off}
 function TStreamAdapter.Read(pv: Pointer; cb: DWORD; pcbRead: PDWORD): HResult; stdcall;
 function TStreamAdapter.Read(pv: Pointer; cb: DWORD; pcbRead: PDWORD): HResult; stdcall;
 var
 var
@@ -1267,4 +1268,4 @@ begin
   raise e;
   raise e;
 end;
 end;
 
 
-{$warnings on}
+{$pop}

+ 3 - 3
rtl/objpas/fgl.pp

@@ -900,7 +900,7 @@ end;
 
 
 function TFPGList.GetList: PTypeList;
 function TFPGList.GetList: PTypeList;
 begin
 begin
-  Result := PTypeList(FList);
+  Result := PTypeList(@FList);
 end;
 end;
 
 
 function TFPGList.ItemPtrCompare(Item1, Item2: Pointer): Integer;
 function TFPGList.ItemPtrCompare(Item1, Item2: Pointer): Integer;
@@ -1035,7 +1035,7 @@ end;
 
 
 function TFPGObjectList.GetList: PTypeList;
 function TFPGObjectList.GetList: PTypeList;
 begin
 begin
-  Result := PTypeList(FList);
+  Result := PTypeList(@FList);
 end;
 end;
 
 
 function TFPGObjectList.ItemPtrCompare(Item1, Item2: Pointer): Integer;
 function TFPGObjectList.ItemPtrCompare(Item1, Item2: Pointer): Integer;
@@ -1165,7 +1165,7 @@ end;
 
 
 function TFPGInterfacedObjectList.GetList: PTypeList;
 function TFPGInterfacedObjectList.GetList: PTypeList;
 begin
 begin
-  Result := PTypeList(FList);
+  Result := PTypeList(@FList);
 end;
 end;
 
 
 function TFPGInterfacedObjectList.ItemPtrCompare(Item1, Item2: Pointer): Integer;
 function TFPGInterfacedObjectList.ItemPtrCompare(Item1, Item2: Pointer): Integer;

+ 45 - 1
rtl/objpas/sysutils/sysencoding.inc

@@ -22,7 +22,13 @@ begin
   try
   try
 {$endif}
 {$endif}
     if not Assigned(FStandardEncodings[seAnsi]) then
     if not Assigned(FStandardEncodings[seAnsi]) then
-      FStandardEncodings[seAnsi] := TMBCSEncoding.Create(DefaultSystemCodePage);
+    begin
+      // DefaultSystemCodePage can be set to non-ANSI
+      if Assigned(widestringmanager.GetStandardCodePageProc) then
+        FStandardEncodings[seAnsi] := TMBCSEncoding.Create(widestringmanager.GetStandardCodePageProc(scpAnsi))
+      else
+        FStandardEncodings[seAnsi] := TMBCSEncoding.Create(DefaultSystemCodePage);
+    end;
 {$ifdef FPC_HAS_FEATURE_THREADING}
 {$ifdef FPC_HAS_FEATURE_THREADING}
   finally
   finally
     LeaveCriticalSection(FLock);
     LeaveCriticalSection(FLock);
@@ -91,6 +97,40 @@ begin
   Result := GetANSI;
   Result := GetANSI;
 end;
 end;
 
 
+class function TEncoding.GetSystemEncoding: TEncoding;
+var
+  I: Integer;
+begin
+{$ifdef FPC_HAS_FEATURE_THREADING}
+  EnterCriticalSection(FLock);
+  try
+{$endif}
+    for I := Low(FSystemEncodings) to High(FSystemEncodings) do
+    begin
+      if FSystemEncodings[I].CodePage=DefaultSystemCodePage then
+      begin
+        Result := FSystemEncodings[I];
+        if I<>Low(FSystemEncodings) then // exchange with first position to find it faster the next time
+        begin
+          FSystemEncodings[I] := FSystemEncodings[Low(FSystemEncodings)];
+          FSystemEncodings[Low(FSystemEncodings)] := Result;
+        end;
+        Exit;
+      end;
+    end;
+    // not found - create new encoding at first position
+    Result := TMBCSEncoding.Create(DefaultSystemCodePage);
+    SetLength(FSystemEncodings, Length(FSystemEncodings)+1);
+    if High(FSystemEncodings)<>Low(FSystemEncodings) then
+      FSystemEncodings[High(FSystemEncodings)] := FSystemEncodings[Low(FSystemEncodings)];
+    FSystemEncodings[Low(FSystemEncodings)] := Result;
+{$ifdef FPC_HAS_FEATURE_THREADING}
+  finally
+    LeaveCriticalSection(FLock);
+  end;
+{$endif}
+end;
+
 class function TEncoding.GetUnicode: TEncoding;
 class function TEncoding.GetUnicode: TEncoding;
 begin
 begin
 {$ifdef FPC_HAS_FEATURE_THREADING}
 {$ifdef FPC_HAS_FEATURE_THREADING}
@@ -142,6 +182,7 @@ end;
 class procedure TEncoding.FreeEncodings;
 class procedure TEncoding.FreeEncodings;
 var
 var
   E: TStandardEncoding;
   E: TStandardEncoding;
+  I: Integer;
 begin
 begin
 {$ifdef FPC_HAS_FEATURE_THREADING}
 {$ifdef FPC_HAS_FEATURE_THREADING}
   EnterCriticalSection(FLock);
   EnterCriticalSection(FLock);
@@ -149,6 +190,9 @@ begin
 {$endif}
 {$endif}
     for E := Low(FStandardEncodings) to High(FStandardEncodings) do
     for E := Low(FStandardEncodings) to High(FStandardEncodings) do
       FreeAndNil(FStandardEncodings[E]);
       FreeAndNil(FStandardEncodings[E]);
+    for I := Low(FSystemEncodings) to High(FSystemEncodings) do
+      FSystemEncodings[I].Free;
+    SetLength(FSystemEncodings, 0);
 {$ifdef FPC_HAS_FEATURE_THREADING}
 {$ifdef FPC_HAS_FEATURE_THREADING}
   finally
   finally
     LeaveCriticalSection(FLock);
     LeaveCriticalSection(FLock);

+ 3 - 0
rtl/objpas/sysutils/sysencodingh.inc

@@ -30,12 +30,14 @@ type
         seUTF8);
         seUTF8);
     var
     var
       FStandardEncodings: array[TStandardEncoding] of TEncoding; static;
       FStandardEncodings: array[TStandardEncoding] of TEncoding; static;
+      FSystemEncodings: array of TEncoding; static;
     Class Var
     Class Var
       FLock : TRTLCriticalSection;
       FLock : TRTLCriticalSection;
     class function GetANSI: TEncoding; static;
     class function GetANSI: TEncoding; static;
     class function GetASCII: TEncoding; static;
     class function GetASCII: TEncoding; static;
     class function GetBigEndianUnicode: TEncoding; static;
     class function GetBigEndianUnicode: TEncoding; static;
     class function GetDefault: TEncoding; static;
     class function GetDefault: TEncoding; static;
+    class function GetSystemEncoding: TEncoding; static;
     class function GetUnicode: TEncoding; static;
     class function GetUnicode: TEncoding; static;
     class function GetUTF7: TEncoding; static;
     class function GetUTF7: TEncoding; static;
     class function GetUTF8: TEncoding; static;
     class function GetUTF8: TEncoding; static;
@@ -99,6 +101,7 @@ type
     class property ASCII: TEncoding read GetASCII;
     class property ASCII: TEncoding read GetASCII;
     class property BigEndianUnicode: TEncoding read GetBigEndianUnicode;
     class property BigEndianUnicode: TEncoding read GetBigEndianUnicode;
     class property Default: TEncoding read GetDefault;
     class property Default: TEncoding read GetDefault;
+    class property SystemEncoding: TEncoding read GetSystemEncoding;
     class property Unicode: TEncoding read GetUnicode;
     class property Unicode: TEncoding read GetUnicode;
     class property UTF7: TEncoding read GetUTF7;
     class property UTF7: TEncoding read GetUTF7;
     class property UTF8: TEncoding read GetUTF8;
     class property UTF8: TEncoding read GetUTF8;

+ 6 - 3
rtl/openbsd/ptypes.inc

@@ -61,7 +61,7 @@ type
     pSize    = ^size_t;
     pSize    = ^size_t;
     pSize_t  = ^size_t;
     pSize_t  = ^size_t;
 
 
-    ssize_t  = cint32;          { used by function for returning number of bytes }
+    ssize_t  = clong;          { used by function for returning number of bytes }
     TsSize   = ssize_t;
     TsSize   = ssize_t;
     psSize   = ^ssize_t;
     psSize   = ^ssize_t;
 
 
@@ -107,7 +107,6 @@ type
    pthread_mutexattr_t_rec	= record end;
    pthread_mutexattr_t_rec	= record end;
    pthread_cond_t_rec		= record end;
    pthread_cond_t_rec		= record end;
    pthread_condattr_t_rec	= record end;
    pthread_condattr_t_rec	= record end;
-   pthread_once_t_rec		= record end;
    pthread_rwlock_t_rec   	= record end;
    pthread_rwlock_t_rec   	= record end;
    pthread_rwlockattr_t_rec	= record end;
    pthread_rwlockattr_t_rec	= record end;
 
 
@@ -118,7 +117,11 @@ type
    pthread_cond_t       = ^pthread_cond_t_rec;
    pthread_cond_t       = ^pthread_cond_t_rec;
    pthread_condattr_t   = ^pthread_condattr_t_rec;
    pthread_condattr_t   = ^pthread_condattr_t_rec;
    pthread_key_t        = cint;
    pthread_key_t        = cint;
-   pthread_once_t	= ^pthread_once_t_rec;
+   pthread_once_t_rec		= record
+     state : cint;
+     mutex : pthread_mutex_t;
+   end;
+   pthread_once_t	= pthread_once_t_rec;
    pthread_rwlock_t     = ^pthread_rwlock_t_rec;
    pthread_rwlock_t     = ^pthread_rwlock_t_rec;
    pthread_rwlockattr_t = ^pthread_rwlockattr_t_rec;
    pthread_rwlockattr_t = ^pthread_rwlockattr_t_rec;
 
 

+ 123 - 0
rtl/openbsd/t_openbsd.h2paschk

@@ -8,14 +8,19 @@
 # supported architecture.
 # supported architecture.
 
 
 @Pascal uses baseunix;
 @Pascal uses baseunix;
+@Pascal {$i ptypes.inc}
+@Pascal {$i ostypes.inc}
 @Pascal begin
 @Pascal begin
 
 
+# Adds support for M_PIl constant inside math.h header
+@C #include <sys/mman.h>
 @C #include <sys/types.h>
 @C #include <sys/types.h>
 @C #include <sys/stat.h>
 @C #include <sys/stat.h>
 @C #include <sys/time.h>
 @C #include <sys/time.h>
 @C #include <sys/times.h>
 @C #include <sys/times.h>
 @C #include <sys/resource.h>
 @C #include <sys/resource.h>
 @C #include <sys/uio.h>
 @C #include <sys/uio.h>
+@C #include <sys/wait.h>
 @C #include <dirent.h>
 @C #include <dirent.h>
 @C #include <poll.h>
 @C #include <poll.h>
 @C #include <utime.h>
 @C #include <utime.h>
@@ -23,9 +28,127 @@
 @C #include <unistd.h>
 @C #include <unistd.h>
 @C #include <stdio.h>
 @C #include <stdio.h>
 @C #include <stddef.h>
 @C #include <stddef.h>
+@C #include <fcntl.h>
+@C #include <pthread.h>
+@C #include <netdb.h>
+@C #include <semaphore.h>
+@C #include <wchar.h>
+@C #include <math.h>
 @C int main()
 @C int main()
 @C {
 @C {
 
 
+@type dev_t
+@type gid_t
+@type ino_t
+@type mode_t
+@type nlink_t
+@type off_t
+@type pid_t
+@type size_t
+@type ssize_t
+@type uid_t
+@type wint_t
+@type clock_t
+@type time_t
+@type socklen_t
+
+@record timeval,struct timeval
+.tv_sec
+.tv_usec
+
+@record timespec,struct timespec
+.tv_sec
+.tv_nsec
+
+@type pthread_t
+@type pthread_attr_t
+@type pthread_mutex_t
+@type pthread_mutexattr_t
+@type pthread_cond_t
+@type pthread_condattr_t
+@type pthread_key_t
+@type pthread_rwlock_t
+@type pthread_rwlockattr_t
+@type sem_t
+@type rlim_t
+
+@record pthread_once_t,struct pthread_once
+.state
+.mutex
+
+@constant    F_OK
+@constant    R_OK
+@constant    W_OK
+@constant    X_OK
+@constant    SEEK_SET
+@constant    SEEK_CUR
+@constant    SEEK_END
+@constant O_RDONLY
+@constant O_WRONLY
+@constant O_RDWR
+@constant O_CREAT
+@constant O_EXCL
+@constant O_TRUNC
+@constant O_NOCTTY
+@constant O_APPEND
+@constant O_NONBLOCK
+@constant    S_IRUSR
+@constant    S_IWUSR
+@constant    S_IXUSR
+@constant    S_IRGRP
+@constant    S_IWGRP
+@constant    S_IXGRP
+@constant    S_IROTH
+@constant    S_IWOTH
+@constant    S_IXOTH
+@constant    S_IRWXU
+@constant    S_IRWXG
+@constant    S_IRWXO
+@constant    WNOHANG
+@constant    WUNTRACED
+@constant  F_DUPFD
+@constant  F_GETFD
+@constant  F_SETFD
+@constant  F_GETFL
+@constant  F_SETFL
+@constant  F_GETOWN
+@constant  F_SETOWN
+@constant  F_GETLK
+@constant  F_SETLK
+@constant  F_SETLKW
+@constant  F_DUPFD_CLOEXEC
+@constant  FD_CLOEXEC
+@constant  F_RDLCK
+@constant  F_UNLCK
+@constant  F_WRLCK
+@constant  RLIMIT_CPU
+@constant  RLIMIT_FSIZE
+@constant  RLIMIT_DATA
+@constant  RLIMIT_STACK
+@constant  RLIMIT_CORE
+@constant  RLIMIT_RSS
+@constant  RLIMIT_MEMLOCK
+@constant  RLIMIT_NPROC
+@constant  RLIMIT_NOFILE
+# @constant  RLIMIT_AS alias of RLIMIT_RSS, but not in C headers
+@constant  MAP_PRIVATE
+@constant  MAP_ANONYMOUS
+@constant  POLLIN
+@constant  POLLPRI
+@constant  POLLOUT
+@constant  POLLERR
+@constant  POLLHUP
+@constant  POLLNVAL
+@constant  POLLRDNORM
+@constant  POLLRDBAND
+@constant  POLLWRNORM
+@constant  POLLWRBAND
+
+
+
+
+@floatconstant PI,M_PI
+
 @record stat,struct stat
 @record stat,struct stat
 .st_mode
 .st_mode
 .st_dev
 .st_dev

+ 213 - 0
rtl/unix/scripts/check_rtl_types.sh

@@ -0,0 +1,213 @@
+#!/usr/bin/env bash
+filename="$1"
+shift
+FPC_OPTS="$*"
+
+if [ ! -f "$filename" ] ; then
+  echo "Usage: $0 file.h2paschk"
+  exit
+fi
+
+filebase=${filename/.*/}
+
+filebaseonly=`basename $filebase`
+
+filedir=`dirname $filename`
+if [ -z "$filedir" ] ; then
+  filedir=.
+fi
+
+if [ -z "$MAKE" ] ; then
+  MAKE=`which gmake`
+fi
+
+if [ -z "$MAKE" ] ; then
+  MAKE=`which make`
+fi
+
+if [ -z "$FPC" ] ; then
+  FPC=fpc
+  default_fpc=1
+else
+  default_fpc=0
+fi
+
+if [ -z "$CC" ] ; then
+  CC=`which gcc`
+fi
+
+if [ -z "$CC" ] ; then
+  CC=`which cc`
+fi
+
+if [ -f "{$filebase}.c" ] ; then
+  rm -f ${filebase}.c
+fi
+if [ -f "{$filebase}.pas" ] ; then
+  rm -f ${filebase}.pas
+fi
+
+function check_one ()
+{
+VERSION=$1
+
+echo "Calling h2paschk $filename"
+h2paschk $filename
+res=$?
+if [ $res -ne 0 ] ; then
+  exit
+fi
+
+echo "Calling $CC $CC_OPT -o ${filebase}_c ${filebase}.c"
+$CC $CC_OPT -o ${filebase}_c${VERSION} ${filebase}.c > ${filebase}${VERSION}_c.comp.log 2>&1
+res=$?
+if [ $res -ne 0 ] ; then
+  echo "$CC call failed in $VERSION, res=$res"
+  cat ${filebase}${VERSION}_c.comp.log
+  exit
+fi
+
+./${filebase}_c${VERSION} > ${filebase}_c${VERSION}.out
+res=$?
+if [ $res -ne 0 ] ; then
+  echo "./${filebase}_c${VERSION} failed in $VERSION, res=$res"
+  exit
+fi
+
+echo "Calling $MAKE all OPT=\"-n -gwl $FPC_OPTS\" FPC=$FPC"
+$MAKE all OPT="-n -gwl $FPC_OPTS" FPC=$FPC > ${filebase}${VERSION}_make_all.log 2>&1
+res=$?
+if [ $res -ne 0 ] ; then
+  echo "$MAKE call failed in $VERSION, res=$res"
+  cat ${filebase}${VERSION}_make_all.log
+  exit
+fi
+
+OS_TARGET=`$FPC $FPC_OPTS  -iTO`
+CPU_TARGET=`$FPC $FPC_OPTS -iTP`
+echo "Calling $MAKE -C ${filedir} ${filebaseonly} FPC=$FPC OPT=\"-n -gwl $FPC_OPTS\" -Fu../units/$CPU_TARGET-$OS_TARGET"
+$MAKE -C ${filedir} ${filebaseonly} FPC=$FPC OPT="-n -gwl $FPC_OPTS -Fu../units/$CPU_TARGET-$OS_TARGET" > ${filebase}${VERSION}_pas.comp.log 2>&1
+res=$?
+if [ $res -ne 0 ] ; then
+  echo "$FPC call failed in $VERSION, res=$res"
+  cat ${filebase}${VERSION}_pas.comp.log
+  exit
+fi
+mv -f ${filebase} ${filebase}${VERSION}
+
+./${filebase}${VERSION} > ${filebase}_pas${VERSION}.out
+res=$?
+if [ $res -ne 0 ] ; then
+  echo "./${filebase}${VERSION} call failed in $VERSION, res=$res"
+  exit
+fi
+
+diff ${filebase}_c${VERSION}.out ${filebase}_pas${VERSION}.out > ${filebase}${VERSION}.diffs
+res=$?
+if [ $res -eq 0 ] ; then
+  echo "No difference found!"
+else
+  echo "Diffs for ${VERSION} are:"
+  echo "< C      results"
+  echo "> Pascal results"
+  cat ${filebase}${VERSION}.diffs
+fi
+# Clean up
+rm -f ${filebase}_c${VERSION}
+rm -f ${filebase}${VERSION}
+rm -f ${filebase}_c${VERSION}.out
+rm -f ${filebase}_pas${VERSION}.out
+rm -f ${filebase}${VERSION}_c.comp.log
+rm -f ${filebase}${VERSION}_pas.comp.log
+rm -f ${filebase}${VERSION}_make_all.log
+rm -f ${filebase}.c
+rm -f ${filebase}.pas
+
+}
+
+function check_64 ()
+{
+  if [ "$FPC64" == "ppca64" ] ; then
+    CC_OPT="-Wall"
+  else
+    CC_OPT="-m64 -Wall"
+  fi
+  if [ $default_fpc -eq 1 ] ; then  
+    FPC=$FPC64
+    if [ "$CPU_SOURCE" != "$CPU_TARGET" ] ; then
+      FPC_OPTS="$FPC_OPTS -XP${CPU_TARGET}-${OS_SOURCE}-"
+    fi
+  fi
+  check_one 64bit
+}
+
+function check_32 ()
+{
+  if [ "$CPU_SOURCE" == "aarch64" ] ; then
+    CC=arm-linux-gnueabihf-gcc-4.8
+    export BINUTILSPREFIX=arm-linux-
+  fi
+  if [ "$FPC32" == "ppcarm" ] ; then
+    CC_OPT="-march=armv7-a -Wall"
+  else
+    CC_OPT="-m32 -Wall"
+  fi
+
+  FPC=$FPC32  
+  if [ "$CPU_SOURCE" != "$CPU_TARGET" ] ; then
+    FPC_OPTS="$FPC_OPTS -XP${CPU_TARGET}-${OS_SOURCE}-"
+  fi
+  check_one 32bit
+}
+
+function check_gen32 ()
+{
+  CC_OPT="-m32 -Wall"
+
+  check_one gen32bit
+}
+
+OS_SOURCE=`$FPC $FPC_OPTS  -iSO`
+CPU_SOURCE=`$FPC $FPC_OPTS -iSP`
+CPU_TARGET=`$FPC $FPC_OPTS -iTP`
+case $CPU_SOURCE in
+  arm|aarch64) FPC32=ppcarm; FPC64=ppca64;;
+  i386|x86_64) FPC32=ppc386; FPC64=ppcx64;;
+  powerpc|powerpc64) FPC32=ppcppc; FPC64=ppcppc64;;
+  sparc|sparc64) FPC32=ppcsparc; FPC64=ppcsparc64;;
+  m68k) FPC32=ppc68k; FPC64=;;
+  mips) FPC32=ppcmips; FPC64=;;
+  mipsel) FPC32=ppcmipsel; FPC64=;;
+  riscv32|riscv64) FPC32=ppcrv32; FPC64=ppcrv64;;
+esac
+
+# No i386<->x86_64 cross-compilation on OpeenBSD
+if [ "$OS_SOURCE" == "openbsd" ] ; then
+  if [ "$CPU_SOURCE" == "i386" ] ; then
+    FPC64=
+  else
+    FPC32=
+  fi
+fi
+
+
+if [ $default_fpc -eq 1 ] ; then
+  if [ -n "$FPC64" ] ; then
+    check_64
+  fi
+
+  if [ -n "$FPC32" ] ; then
+    check_32
+  fi
+else
+  if [ "${FPC}" == "$FPC64" ] ; then
+    check_64
+  fi
+
+  if [ "${FPC}" == "$FPC32" ] ; then
+    check_32
+  fi
+fi
+
+
+

+ 356 - 38
rtl/unix/scripts/check_sys.sh

@@ -7,20 +7,82 @@
 syscall_header=/usr/include/syscall.h
 syscall_header=/usr/include/syscall.h
 fpc_sysnr=./sysnr.inc
 fpc_sysnr=./sysnr.inc
 
 
-os=`uname -s`
+i=1
+while [ $i -le "$#" ] ; do
+  arg="${!i}"
+  echo "Handling arg $i, \"$arg\""
+  if [ "${arg//=}" != "$arg" ] ; then
+    echo "Evaluating \"$arg\""
+    arg2="${arg/=*/}=\"${arg/*=/}\""
+    eval "$arg2"
+  elif [ "$arg" == "-v" ] ; then
+    verbose=1
+  else
+    echo "arg not handled!"
+  fi
+  let i++
+done
 
 
-if [ "$os" == "OpenBSD" ] ; then
-  c_syscall_header=sys/syscall.h
-else
-  c_syscall_header=syscall.h
+start_pwd=`pwd`
+start_dir=`basename $start_pwd`
+
+if [ -d "rtl" ] ; then
+  echo "Entering rtl directory"
+  cd rtl
 fi
 fi
 
 
-if ! [ -f $fpc_sysnr ] ; then
-  cpu=`fpc -iTP`
+os=`uname -s | tr [:upper:] [:lower:] `
+os_cpu=`uname -m | tr [:upper:] [:lower:] `
+now_pwd=`pwd`
+now_dir=`basename $now_pwd`
+if [ -d "$os" ] ; then
+  echo "Entering $os directory"
+  cd $os
+fi
+
+case "$os" in
+  freebsd|openbsd|netbsd) c_syscall_header=sys/syscall.h;;
+  *)  c_syscall_header=syscall.h;;
+esac
+
+if [ -z "$FPC" ] ; then
+  FPC=fpc
+fi
+
+if [ ! -f $fpc_sysnr ] ; then
+  cpu=`$FPC -iTP`
+  if [ "${cpu//sparc/}" != "$cpu" ] ; then
+    cpu=sparcgen
+  fi
   fpc_sysnr=./$cpu/sysnr.inc
   fpc_sysnr=./$cpu/sysnr.inc
+  if [ ! -f "$fpc_sysnr" ] ; then
+    fpc_sysnr=`ls -1 ./${cpu}*/sysnr.inc| head -1`
+  fi
+  if [ ! -f "$fpc_sysnr" ] ; then
+    if [ "${cpu//sparc/}" != "$cpu" ] ; then
+      cpu=sparcgen
+    fi
+    fpc_sysnr=./$cpu/sysnr.inc
+    if [ ! -f "$fpc_sysnr" ] ; then
+      echo "sysnr.inc file not found, try again in rtl/$os directory"
+      exit
+    fi
+  fi
 fi
 fi
 
 
-verbose=0
+if [ -f "$fpc_sysnr" ] ; then
+  echo "Checking $fpc_sysnr content for Free Pascal syscall numbers"
+  fpc_sysnr_dir=`dirname $fpc_sysnr `
+  sysnr_includes=`grep -o '{\$i  *[a-z_A-Z0-9/.-]*' $fpc_sysnr | sed 's:.*{\$i *:'$fpc_sysnr_dir/: `
+  if [ -n "$sysnr_includes" ] ; then
+    echo "Found $sysnr_includes include files"
+    fpc_sysnr="$fpc_sysnr $sysnr_includes"
+  fi
+fi
+
+if [ -z "$verbose" ] ; then
+  verbose=0
+fi
 
 
 os=`uname -s`
 os=`uname -s`
 
 
@@ -39,22 +101,80 @@ EOF
 # Can be overwritten by setting CC variable
 # Can be overwritten by setting CC variable
 # But I don't know if other compilers also generate
 # But I don't know if other compilers also generate
 # .i files with --save-temps option
 # .i files with --save-temps option
-if [ "$CC" == "" ] ; then
+if [ -z "$CC" ] ; then
   CC=gcc
   CC=gcc
 fi
 fi
 
 
+cpu=`$FPC -iTP`
+cpu_source=`$FPC -iSP`
+is_16=0
+is_32=0
+is_64=0
+case $cpu in
+  aarch64)   is_64=1;;
+  alpha)     is_32=1;;
+  arm)       is_32=1;;
+  avr)       is_16=1;;
+  i386)      is_32=1;;
+  i8086)     is_16=1;;
+  ia64)      is_64=1;;
+  jvm)       is_32=1;;
+  m68k)      is_32=1;;
+  mips)      is_32=1;;
+  mipsel)    is_32=1;;
+  powerpc)   is_32=1;;
+  powerpc64) is_64=1;;
+  riscv32)   is_32=1;;
+  riscv64)   is_64=1;;
+  sparc)     is_32=1;;
+  sparc64)   is_64=1;;
+  vis)       is_32=1;;
+  x86_64)    is_64=1;;
+esac
+
+if [ $is_64 -eq 1 ] ; then
+  if [ "$os_cpu" == "aarch64" ] ; then
+    CC_OPT="$CC_OPT -Wall"
+  else
+    CC_OPT="$CC_OPT -m64 -Wall"
+  fi
+  CPUBITS=64
+elif [ $is_32 -eq 1 ] ;then
+  if [ "$os_cpu" == "aarch64" ] ; then
+    CC=arm-linux-gnueabihf-gcc-4.8
+    export BINUTILSPREFIX=arm-linux-
+  fi
+  if [ "${FPC/ppcarm/}" != "$FPC" ] ; then
+    CC_OPT="$CC_OPT -march=armv7-a -Wall"
+  elif [ "${os_cpu/arm/}" != "$os_cpu" ] ; then
+    CC_OPT="$CC_OPT -march=armv5 -Wall"
+  else
+    CC_OPT="$CC_OPT -m32 -Wall"
+  fi
+
+  CPUBITS=32
+elif [ $is_16 -eq 1 ] ; then
+  CPUBITS=16
+else
+  CPUBITS=unknown
+fi
+
 # Use gcc with --save-temps option to create .i file
 # Use gcc with --save-temps option to create .i file
-$CC --save-temps -o test-syscall ./test-syscall.c
+echo "Calling $CC $CC_OPT --save-temps -o test-syscall ./test-syscall.c"
+$CC $CC_OPT --save-temps -o ./test-syscall ./test-syscall.c
 res=$?
 res=$?
 if [ $res -ne 0 ] ; then
 if [ $res -ne 0 ] ; then
   echo "Call to $CC failed"
   echo "Call to $CC failed"
   exit
   exit
+else
+  rm -f ./test-syscall.c ./test-syscall
 fi
 fi
 # list of errno.h headers listed
 # list of errno.h headers listed
 syscall_headers=` sed -n "s:.*\"\(.*/.*\.h\)\".*:\1:p" test-syscall.i |sort | uniq`
 syscall_headers=` sed -n "s:.*\"\(.*/.*\.h\)\".*:\1:p" test-syscall.i |sort | uniq`
-echo "Headers found are \"$syscall_headers\""
+rm -f test-syscall.*
+echo "C syscall headers files found are \"$syscall_headers\""
 
 
-if [ "$syscall_headers" != "" ] ; then
+if [ -n "$syscall_headers" ] ; then
   syscall_header="$syscall_headers"
   syscall_header="$syscall_headers"
 fi
 fi
 
 
@@ -70,15 +190,117 @@ fi
 
 
 # You should only need to change the variables above
 # You should only need to change the variables above
 
 
-sed -n "s:^[ \t]*${fpc_syscall_prefix}\\([_a-zA-Z0-9]*\\)[ \t]*=[ \t]*\\([0-9]*\\).*:check_syscall_number ${syscall_prefix}\1 \2:p" ${fpc_sysnr} > check_sys_list.sh
-sed -n "s:^.*define[[:space:]]*${syscall_prefix}\\([_a-zA-Z0-9]*\\)[[:space:]]*\\([0-9]*\\).*:check_syscall_number_reverse ${fpc_syscall_prefix}\1 \2:p" ${syscall_header} > check_sys_list_reverse.sh
+awkfile=preproc.awk
+tmp_fpc_sysnr=tmp-sysnr-${cpu}.inc
+
+c_syscall_source=test-syscall-${cpu}.c
+
+# Test C file to grab all loaded headers
+# must be called with -DSYS_MACRO=$sys
+cat > $c_syscall_source <<EOF
+#include <${c_syscall_header}>
+#include <stdio.h>
+
+int
+main ()
+{
+  printf ("%d\n", (int) SYS_MACRO);
+  return 0;
+}
+EOF
+
+cat > $awkfile <<EOF
+BEGIN {IGNORECASE = 1;
+enable=1;
+macro="";
+incfile="";
+cpu= "cpu" proc;
+cpubits= "cpu" cpubits;
+list_defines=macros " " cpu " " cpubits " ";
+print "// FPC defined macros used " list_defines;
+}
+/\{\\\$i / { incfile=\$2;
+  print "Include file  " incfile " found"; }
+/\{\\\$ifdef / { macro=gensub("[^A-Za-z_0-9].*","",1,\$2) " ";
+  if (list_defines ~ macro) { enable=1;
+    print "// ifdef " macro " found and accepted at line " FNR;
+  } else {enable=0;
+    print "// ifdef " macro " found and rejected at line " FNR;
+  };
+  }
+/\{\\\$ifndef / { macro=gensub("[^A-Za-z_0-9].*","",1,\$2);
+  if (list_defines ~ macro) { enable=0;
+   print "// ifndef " macro " found and rejected at line " FNR;
+ } else {enable=1;
+   print "// ifndef " macro " found and accepted at line " FNR;
+ };
+  }
+/\{\\\$else/ { if (enable == 1) {enable=0;} else {enable = 1;}}
+/.*/ { if (enable == 1) {
+  wholeline=\$0;
+  code=gensub("{.*}","","g",\$0);
+  code=gensub("[(][*].*[*][)]","","g",code);
+  comments=gensub(code,"",1,\$0);
+  comments1=gensub(".*({.*}).*","\1","g",comments);
+  if (comments == comments1)
+    comments1="";
+  comments2=gensub(".*[(][*].*[*][)]).*","\1","g",comments);
+  if (comments == comments2)
+    comments2="";
+  comments3=gensub(".*//","",1,comments);
+  if (comments == comments3)
+    comments3="";
+  all_comments= comments1 comments2 comments3;
+  if (all_comments != "")
+    print code "// " comments1 comments2 comments3 ;
+  else
+    print code;
+  } 
+}
+/\{\\\$endif/ {enable=1;}
+EOF
+
+if [ -z "$AWK" ] ; then
+  AWK=`which gawk 2> /dev/null`
+fi
+
+if [ -z "$AWK" ] ; then
+  AWK=`which awk 2> /dev/null`
+fi
+
+if [ -n "$AWK" ] ; then
+  echo "Preprocessing ${fpc_sysnr} to $tmp_fpc_sysnr"
+  echo "$AWK -v proc=$cpu -v cpubits=$CPUBITS -f $awkfile ${fpc_sysnr} > $tmp_fpc_sysnr"
+  $AWK -v proc=$cpu -v cpubits=$CPUBITS -v macros="$FPC_MACROS" -f $awkfile ${fpc_sysnr} > $tmp_fpc_sysnr
+  fpc_sysnr=$tmp_fpc_sysnr
+fi
+sed -n "s:^\(.*\)*[ \t]*${fpc_syscall_prefix}\\([_a-zA-Z0-9]*\\)[ \t]*=[ \t]*\\(.*\\);\\(.*\\)$:check_c_syscall_number_from_fpc_rtl \2 \"\3\" \"\1 \4\":p" $fpc_sysnr > check_sys_list.sh
+
+
+sed -n "s:^.*#[[:space:]]*define[[:space:]]*${syscall_prefix}\\([_a-zA-Z0-9]*\\)[[:space:]]*\\([0-9]*\\)\\(.*\\)$:check_c_syscall_number_in_fpc_rtl \1 \"\2\" \"\3\":p" ${syscall_header} > check_sys_list_reverse.sh
  
  
+forward_count=0
+forward_ok_count=0
+forward_failure_count=0
 
 
-function check_syscall_number ()
+function check_c_syscall_number_from_fpc_rtl ()
 {
 {
-  sys=$1
-  value=$2
+  bare_sys=$1
+  sys=${syscall_prefix}$bare_sys
+  arg_2=\"$2\"
+  if [ "${2:0:1}" == "$" ] ; then
+    echo "Arg \"$arg_2\" needs Pascal To C hexadecimal conversion"
+    let "value=0x${arg_2:2}"
+  else
+    let "value=$2"
+  fi
+  comment="$3"
+  if [[ ! ( ( -n "$value" ) && ( $value -ge 0 ) ) ]] ; then
+    echo "Computing $2 value"
+    let value=$2
+  fi
   obsolete=0
   obsolete=0
+  let forward_count++
   if [[ "$value" =~ ^[0-9]+$ ]] ; then
   if [[ "$value" =~ ^[0-9]+$ ]] ; then
     eval $sys=\$$value
     eval $sys=\$$value
     if [ $verbose -ne 0 ] ; then
     if [ $verbose -ne 0 ] ; then
@@ -92,11 +314,29 @@ function check_syscall_number ()
   fi
   fi
   # Remember this value for later
   # Remember this value for later
   eval $sys=$value
   eval $sys=$value
-  if [ $verbose -ne 0 ] ; then
-    echo Testing $sys value $value
+  echo -en "Testing $sys value $value                    \r"
+  found=`sed -n "/#[[:space:]]*define[[:space:]]*${sys}[^A-Za-z0-9_]/p" ${syscall_header}`
+  val=`sed -n "s:#[[:space:]]*define[[:space:]]*${sys}[^A-Za-z0-9_][^A-Za-z0-9_]*\([0-9]*\).*:\1:p" ${syscall_header}`
+  $CC $CC_OPT -DSYS_MACRO=${syscall_prefix}${bare_sys} -o ./test_c_${bare_sys} $c_syscall_source > ./test_${bare_sys}.comp-log 2>&1
+  C_COMP_RES=$?
+  if [ $C_COMP_RES -eq 0 ] ; then
+    CC_value=`./test_c_${bare_sys} `
+    if [ "$value" != "$CC_value" ] ; then
+      echo "$CC returns $CC_value, while $value is expected"
+      let forward_failure_count++
+      return
+    else
+      val=$CC_value
+      rm -f ./test_c_${bare_sys}
+    fi
+    rm -f ./test-${bare_sys}.comp-log
+  else
+    echo "$CC failed to compile code containing $sys syscall number $value"
+    echo "$CC $CC_OPT -DSYS_MACRO=${syscall_prefix}${bare_sys} -o ./test_c_${bare_sys} $c_syscall_source > ./test_${bare_sys}.comp-log 2>&1"
+    let forward_failure_count++
+    return
   fi
   fi
-  found=`sed -n "/#define[[:space:]]*${sys}[^A-Za-z0-9_]/p" ${syscall_header}`
-  val=`sed -n "s:#define[[:space:]]*${sys}[^A-Za-z0-9_][^A-Za-z0-9_]*\([0-9]*\).*:\1:p" ${syscall_header}`
+
   if [ $verbose -ne 0 ] ; then
   if [ $verbose -ne 0 ] ; then
     echo Test for $sys found \"${found}\" \"${value}\" \"${val}\"
     echo Test for $sys found \"${found}\" \"${value}\" \"${val}\"
   fi
   fi
@@ -104,34 +344,92 @@ function check_syscall_number ()
     if [ $verbose -ne 0 ] ; then
     if [ $verbose -ne 0 ] ; then
       echo ${sys} value ${val} is correct
       echo ${sys} value ${val} is correct
     fi
     fi
+    let forward_ok_count++
   else
   else
-    if [ "${val}" == "" ] ; then
-      found=`sed -n "/#define.*[^A-Za-z0-9_]${value}$/p" ${syscall_header}`
-      if [ "${found}" == "" ] ; then
+    if [ -z "${val}" ] ; then
+      found=`sed -n ".*define[[:space:]].*[^A-Za-z0-9_][[:space:]]${value}$/p" ${syscall_header}`
+      if [ -z "${found}" ] ; then
         found=`sed -n "s:\/\* ${value} is compa:/* ${value} is compa:p" ${syscall_header}`
         found=`sed -n "s:\/\* ${value} is compa:/* ${value} is compa:p" ${syscall_header}`
-        if [ "$found" != "" ] ; then
+        if [ -n "$found" ] ; then
           obsolete=1
           obsolete=1
         fi
         fi
       fi
       fi
     fi
     fi
-    if [ "$found" == "" ] ; then
+    if [ -z "$found" ] ; then
       found=`grep -n -w $value ${syscall_header}`
       found=`grep -n -w $value ${syscall_header}`
     fi
     fi
     if [ $obsolete -eq 1 ] ; then
     if [ $obsolete -eq 1 ] ; then
-      echo Warning: ${sys} expected ${value}, is obsolete line is \"${found}\"
+      echo Warning: ${bare_sys} expected ${value}, is obsolete line is \"${found}\"
     else
     else
-      echo Problem: ${sys} expected ${value}, line is \"${found}\", val found is \"${val}\"
+      echo Problem: ${bare_sys} expected ${value}, line is \"${found}\", val found is \"${val}\"
     fi
     fi
+    let forward_failure_count++
   fi
   fi
 }
 }
 
 
-function check_syscall_number_reverse ()
+reverse_count=0
+reverse_ok_count=0
+reverse_failure_count=0
+add_file=./add_missing_syscalls.inc
+suggested_addition_count=0
+echo "{ Generated by check_rtl_sys.sh script }" > $add_file
+
+function check_c_syscall_number_in_fpc_rtl ()
 {
 {
-  sys=$1
+  bare_sys=$1
+  sys=${fpc_syscall_prefix}${bare_sys}
+  c_sys=${syscall_prefix}${bare_sys}
   value=$2
   value=$2
+  if [ -z "$value" ] ; then
+    let "value=$3"
+    comment="expression $3"
+  else
+    comment="$3"
+  fi
+  echo -en "Testing $sys value $value                        \r"
+  $CC $CC_OPT -DSYS_MACRO=${c_sys} -o ./test_c_${bare_sys} $c_syscall_source > ./test_${bare_sys}.comp-log 2>&1
+  C_COMP_RES=$?
+  if [ $C_COMP_RES -eq 0 ] ; then
+    rm ./test_${bare_sys}.comp-log
+    CC_value=`./test_c_${bare_sys} `
+    if [ "$value" != "$CC_value" ] ; then
+      echo "For sys=$sys, $CC returns $CC_value, while $value is expected"
+      let reverse_failure_count++
+      return
+    else
+      rm -f ./test_c_$bare_sys
+    fi
+  else
+    # if C syscall is not accepted do nothing
+    #echo "For sys=$sys, $CC compilation failed"
+    #cat ./test_${bare_sys}.comp-log
+    # let reverse_failure_count++
+    rm -f ./test_c_${bare_sys}
+    rm ./test_${bare_sys}.comp-log
+    return
+  fi
+
+  if [ $verbose -ne 0 ] ; then
+    echo "Full comment is \"$comment \""
+  fi
+  if [ "${comment/*\/\*/}" != "$comment" ] ; then
+    comment="${comment/*\/\*/}"
+    if [ $verbose -ne 0 ] ; then
+      echo "comment is \"$comment \""
+    fi
+    comment="${comment/\*\/*/}"
+    if [ $verbose -ne 0 ] ; then
+      echo "comment is \"$comment \""
+    fi
+    comment=`echo $comment | sed 's:^[[:space:]]*\(.*\)[[:space:]]*$:\1' `
+    if [ $verbose -ne 0 ] ; then
+      echo "comment is \"$comment \""
+    fi
+  fi
   if [ $verbose -ne 0 ] ; then
   if [ $verbose -ne 0 ] ; then
     echo Testing syscall header entry $sys value $value
     echo Testing syscall header entry $sys value $value
   fi
   fi
+  let reverse_count++
   found=`sed -n "/.*${sys}/p" ${fpc_sysnr}`
   found=`sed -n "/.*${sys}/p" ${fpc_sysnr}`
   val=`sed -n "s:.*${sys}[ \t]*=[ \t]*\([0-9]*\).*:\1:p" ${fpc_sysnr}`
   val=`sed -n "s:.*${sys}[ \t]*=[ \t]*\([0-9]*\).*:\1:p" ${fpc_sysnr}`
   if [ $verbose -ne 0 ] ; then
   if [ $verbose -ne 0 ] ; then
@@ -141,14 +439,24 @@ function check_syscall_number_reverse ()
     if [ $verbose -ne 0 ] ; then
     if [ $verbose -ne 0 ] ; then
       echo ${sys} value ${val} is correct
       echo ${sys} value ${val} is correct
     fi
     fi
+    let reverse_ok_count++
   else
   else
-    if [ "${val}" == "" ] ; then
-      found=`sed -n "/#define.*[^A-Za-z0-9_]${value}$/p" ${syscall_header}`
-      if [ "${found}" == "" ] ; then
-        found=`sed -n "s:\/\* ${value} is compa: ${value} is compa:p" ${syscall_header}`
+    if [ -z "${val}" ] ; then
+      found=`sed -n "/#[[:space:]]*define.*[^A-Za-z0-9_][[:space:]]*${value}([[:space:]]|$)/p" ${syscall_header}`
+      if [ -z "${found}" ] ; then
+        found=`sed -n "s:\/\*.*i[[:space:]]${value} is compa: ${value} is compa:p" ${syscall_header}`
       fi
       fi
     fi
     fi
-    echo Problem: ${sys} expected ${value}, line is \"${found}\", val found is \"${val}\"
+    echo "Problem: ${bare_sys} expected ${value}, line is \"${found}\", val found is \"${val}\""
+    if [ -n "$comment" ] ; then
+      echo "    ${fpc_syscall_prefix}${bare_sys} = ${value}; { $comment }" >> $add_file
+      echo "Suggest adding:  ${fpc_syscall_prefix}${bare_sys} = ${value}; { $comment }"
+    else
+      echo "    ${fpc_syscall_prefix}${bare_sys} = ${value};" >> $add_file
+      echo "Suggest adding:  ${fpc_syscall_prefix}${bare_sys} = ${value};"
+    fi
+    let suggested_addition_count++
+    let reverse_failure_count++
   fi
   fi
 }
 }
 
 
@@ -157,8 +465,18 @@ function check_syscall_number_reverse ()
 # to system define 
 # to system define 
 set -f
 set -f
 
 
-echo "Checking values from \"${fpc_sysnr}\" in \"${syscall_header}\""
+echo "Checking values from \"${fpc_sysnr}\" in C syscall headers"
 source ./check_sys_list.sh
 source ./check_sys_list.sh
-echo "Checking if values in \"${syscall_header}\" are missing in \"${fpc_sysnr}\""
+echo "Checking if values in C syscall headers are in \"${fpc_sysnr}\""
 source ./check_sys_list_reverse.sh
 source ./check_sys_list_reverse.sh
-
+echo "Forward counts: OK=$forward_ok_count, failures=$forward_failure_count, total=$forward_count"
+echo "Reverse counts: OK=$reverse_ok_count, failures=$reverse_failure_count, total=$reverse_count"
+if [ $suggested_addition_count -gt 0 ] ; then
+  echo "Missing $suggested_addition_count syscall numbers in $add_file"
+else
+ rm $add_file
+fi
+rm ./check_sys_list.sh ./check_sys_list_reverse.sh ./$awkfile
+if [ -f "$tmp_fpc_sysnr" ] ; then
+  echo   rm $tmp_fpc_sysnr
+fi

+ 1 - 0
rtl/win/wininc/ascdef.inc

@@ -480,6 +480,7 @@ function FindFirstFileEx(lpfilename : LPCStr;fInfoLevelId:FINDEX_INFO_LEVELS ;lp
 function FindFirstFileTransacted(lpfilename : LPCStr;fInfoLevelId:FINDEX_INFO_LEVELS ;lpFindFileData:pointer;fSearchOp : FINDEX_SEARCH_OPS;lpSearchFilter:pointer;dwAdditionalFlags:dword;htransaction : HANDLE):Handle; stdcall;
 function FindFirstFileTransacted(lpfilename : LPCStr;fInfoLevelId:FINDEX_INFO_LEVELS ;lpFindFileData:pointer;fSearchOp : FINDEX_SEARCH_OPS;lpSearchFilter:pointer;dwAdditionalFlags:dword;htransaction : HANDLE):Handle; stdcall;
     external 'kernel32' name 'FindFirstFileTransactedA';
     external 'kernel32' name 'FindFirstFileTransactedA';
 function GetComputerNameEx(NameType:COMPUTER_NAME_FORMAT;lpbuffer:LPSTR;nSize:LPDWORD):BOOL;stdcall;external 'kernel32' name 'GetComputerNameExA';
 function GetComputerNameEx(NameType:COMPUTER_NAME_FORMAT;lpbuffer:LPSTR;nSize:LPDWORD):BOOL;stdcall;external 'kernel32' name 'GetComputerNameExA';
+function QueryFullProcessImageName(hProcess:THandle;dwFlags:DWord; lpexename :lpstr;lpdwsize:pdword):BOOL; stdcall; external 'kernel32.dll' name 'QueryFullProcessImageNameA';
 {$endif read_interface}
 {$endif read_interface}
 
 
 
 

+ 1 - 0
rtl/win/wininc/ascfun.inc

@@ -493,6 +493,7 @@ function GetConsoleAliasExesLengthA:DWORD;stdcall;external 'kernel32' name 'GetC
 function GetConsoleAliasesA(AliasBuffer:LPSTR; AliasBufferLength:DWORD; ExeName:LPSTR):DWORD;stdcall;external 'kernel32' name 'GetConsoleAliasesA';
 function GetConsoleAliasesA(AliasBuffer:LPSTR; AliasBufferLength:DWORD; ExeName:LPSTR):DWORD;stdcall;external 'kernel32' name 'GetConsoleAliasesA';
 function GetConsoleAliasExesA(ExeNameBuffer:LPSTR; ExeNameBufferLength:DWORD):DWORD;stdcall;external 'kernel32' name 'GetConsoleAliasExesA';
 function GetConsoleAliasExesA(ExeNameBuffer:LPSTR; ExeNameBufferLength:DWORD):DWORD;stdcall;external 'kernel32' name 'GetConsoleAliasExesA';
 function GetComputerNameExA(NameType:COMPUTER_NAME_FORMAT;lpbuffer:LPSTR;nSize:LPDWORD):BOOL;stdcall;external 'kernel32' name 'GetComputerNameExA';
 function GetComputerNameExA(NameType:COMPUTER_NAME_FORMAT;lpbuffer:LPSTR;nSize:LPDWORD):BOOL;stdcall;external 'kernel32' name 'GetComputerNameExA';
+function QueryFullProcessImageNameA(hProcess:THandle;dwFlags:DWord; lpexename :lpstr;lpdwsize:pdword):BOOL; stdcall; external 'kernel32.dll' name 'QueryFullProcessImageNameA';
 {$endif read_interface}
 {$endif read_interface}
 
 
 
 

+ 23 - 15
rtl/win/wininc/defines.inc

@@ -1162,17 +1162,23 @@
      KEY_WOW64_64KEY = $0100;
      KEY_WOW64_64KEY = $0100;
      KEY_WOW64_32KEY = $0200;
      KEY_WOW64_32KEY = $0200;
      KEY_WRITE = $20006;
      KEY_WRITE = $20006;
-     PROCESS_ALL_ACCESS = $1f0fff;
-     PROCESS_CREATE_PROCESS = 128;
-     PROCESS_CREATE_THREAD = 2;
-     PROCESS_DUP_HANDLE = 64;
-     PROCESS_QUERY_INFORMATION = 1024;
-     PROCESS_SET_INFORMATION = 512;
-     PROCESS_TERMINATE = 1;
-     PROCESS_VM_OPERATION = 8;
-     PROCESS_VM_READ = 16;
-     PROCESS_VM_WRITE = 32;
-     THREAD_ALL_ACCESS = $1f03ff;
+     PROCESS_ALL_ACCESS = $1fFfff;
+     PROCESS_TERMINATE                 = $0001;
+     PROCESS_CREATE_THREAD             = $0002;
+     PROCESS_SET_SESSIONID             = $0004;
+     PROCESS_VM_OPERATION              = $0008;
+     PROCESS_VM_READ                   = $0010;
+     PROCESS_VM_WRITE                  = $0020;
+     PROCESS_DUP_HANDLE                = $0040;
+     PROCESS_CREATE_PROCESS            = $0080;
+     PROCESS_SET_QUOTA                 = $0100;
+     PROCESS_SET_INFORMATION           = $0200;
+     PROCESS_QUERY_INFORMATION         = $0400;
+     PROCESS_SUSPEND_RESUME            = $0800;
+     PROCESS_QUERY_LIMITED_INFORMATION = $1000;
+     PROCESS_SET_LIMITED_INFORMATION   = $2000;
+    
+     THREAD_ALL_ACCESS = $1FFFFF; // vista+, for old systems 0x3FF
      THREAD_DIRECT_IMPERSONATION = 512;
      THREAD_DIRECT_IMPERSONATION = 512;
      THREAD_GET_CONTEXT = 8;
      THREAD_GET_CONTEXT = 8;
      THREAD_IMPERSONATE = 256;
      THREAD_IMPERSONATE = 256;
@@ -1182,6 +1188,10 @@
      THREAD_SET_THREAD_TOKEN = 128;
      THREAD_SET_THREAD_TOKEN = 128;
      THREAD_SUSPEND_RESUME = 2;
      THREAD_SUSPEND_RESUME = 2;
      THREAD_TERMINATE = 1;
      THREAD_TERMINATE = 1;
+     THREAD_SET_LIMITED_INFORMATION   = $0400;
+     THREAD_QUERY_LIMITED_INFORMATION = $0800;
+     THREAD_RESUME                    = $1000;
+
   { EditWordBreakProc  }
   { EditWordBreakProc  }
      WB_ISDELIMITER = 2;
      WB_ISDELIMITER = 2;
      WB_LEFT = 0;
      WB_LEFT = 0;
@@ -2685,7 +2695,6 @@ Type
      CAL_SMONTHNAME13 = 33;
      CAL_SMONTHNAME13 = 33;
      CAL_SSHORTDATE = 5;
      CAL_SSHORTDATE = 5;
   { SetProcessWorkingSetSize  }
   { SetProcessWorkingSetSize  }
-     PROCESS_SET_QUOTA = 256;
   { SetPrinter  }
   { SetPrinter  }
   { SetService  }
   { SetService  }
   { SetStretchBltMode  }
   { SetStretchBltMode  }
@@ -6377,9 +6386,8 @@ const
 
 
 
 
     CONSOLE_FULLSCREEN_MODE = 1;    
     CONSOLE_FULLSCREEN_MODE = 1;    
-    CONSOLE_WINDOWED_MODE = 2;    
-
-
+    CONSOLE_WINDOWED_MODE   = 2;    
+    PROCESS_NAME_NATIVE     = 1;
 
 
 {$endif read_interface}
 {$endif read_interface}
 
 

+ 12 - 2
rtl/win/wininc/func.inc

@@ -722,6 +722,8 @@ function FrameRgn(_para1:HDC; _para2:HRGN; _para3:HBRUSH; _para4:longint; _para5
 function GetROP2(_para1:HDC):longint; external 'gdi32' name 'GetROP2';
 function GetROP2(_para1:HDC):longint; external 'gdi32' name 'GetROP2';
 function GetAspectRatioFilterEx(_para1:HDC; _para2:LPSIZE):WINBOOL; external 'gdi32' name 'GetAspectRatioFilterEx';
 function GetAspectRatioFilterEx(_para1:HDC; _para2:LPSIZE):WINBOOL; external 'gdi32' name 'GetAspectRatioFilterEx';
 function GetBkColor(_para1:HDC):COLORREF; external 'gdi32' name 'GetBkColor';
 function GetBkColor(_para1:HDC):COLORREF; external 'gdi32' name 'GetBkColor';
+function GetDCBrushColor(_para1:HDC):COLORREF; external 'gdi32' name 'GetDCBrushColor';
+function GetDCPenColor(_para1:HDC):COLORREF; external 'gdi32' name 'GetDCPenColor';
 function GetBkMode(_para1:HDC):longint; external 'gdi32' name 'GetBkMode';
 function GetBkMode(_para1:HDC):longint; external 'gdi32' name 'GetBkMode';
 function GetBitmapBits(_para1:HBITMAP; _para2:LONG; _para3:LPVOID):LONG; external 'gdi32' name 'GetBitmapBits';
 function GetBitmapBits(_para1:HBITMAP; _para2:LONG; _para3:LPVOID):LONG; external 'gdi32' name 'GetBitmapBits';
 function GetBitmapDimensionEx(_para1:HBITMAP; _para2:LPSIZE):WINBOOL; external 'gdi32' name 'GetBitmapDimensionEx';
 function GetBitmapDimensionEx(_para1:HBITMAP; _para2:LPSIZE):WINBOOL; external 'gdi32' name 'GetBitmapDimensionEx';
@@ -792,6 +794,8 @@ function SetMetaRgn(_para1:HDC):longint; external 'gdi32' name 'SetMetaRgn';
 function SelectObject(_para1:HDC; _para2:HGDIOBJ):HGDIOBJ; external 'gdi32' name 'SelectObject';
 function SelectObject(_para1:HDC; _para2:HGDIOBJ):HGDIOBJ; external 'gdi32' name 'SelectObject';
 function SelectPalette(_para1:HDC; _para2:HPALETTE; _para3:WINBOOL):HPALETTE; external 'gdi32' name 'SelectPalette';
 function SelectPalette(_para1:HDC; _para2:HPALETTE; _para3:WINBOOL):HPALETTE; external 'gdi32' name 'SelectPalette';
 function SetBkColor(_para1:HDC; _para2:COLORREF):COLORREF; external 'gdi32' name 'SetBkColor';
 function SetBkColor(_para1:HDC; _para2:COLORREF):COLORREF; external 'gdi32' name 'SetBkColor';
+function SetDCBrushColor(_para1:HDC; _para2:COLORREF):COLORREF; external 'gdi32' name 'SetDCBrushColor';
+function SetDCPenColor(_para1:HDC; _para2:COLORREF):COLORREF; external 'gdi32' name 'SetDCPenColor';
 function SetBkMode(_para1:HDC; _para2:longint):longint; external 'gdi32' name 'SetBkMode';
 function SetBkMode(_para1:HDC; _para2:longint):longint; external 'gdi32' name 'SetBkMode';
 function SetBitmapBits(_para1:HBITMAP; _para2:DWORD; _para3:pointer):LONG; external 'gdi32' name 'SetBitmapBits';
 function SetBitmapBits(_para1:HBITMAP; _para2:DWORD; _para3:pointer):LONG; external 'gdi32' name 'SetBitmapBits';
 function SetBoundsRect(_para1:HDC; const _para2:RECT; _para3:UINT):UINT; external 'gdi32' name 'SetBoundsRect';
 function SetBoundsRect(_para1:HDC; const _para2:RECT; _para3:UINT):UINT; external 'gdi32' name 'SetBoundsRect';
@@ -836,7 +840,7 @@ function AngleArc(_para1:HDC; _para2:longint; _para3:longint; _para4:DWORD; _par
 function PolyPolyline(_para1:HDC; var _para2:POINT; var _para3:DWORD; _para4:DWORD):WINBOOL; external 'gdi32' name 'PolyPolyline';
 function PolyPolyline(_para1:HDC; var _para2:POINT; var _para3:DWORD; _para4:DWORD):WINBOOL; external 'gdi32' name 'PolyPolyline';
 function GetWorldTransform(_para1:HDC; _para2:LPXFORM):WINBOOL; external 'gdi32' name 'GetWorldTransform';
 function GetWorldTransform(_para1:HDC; _para2:LPXFORM):WINBOOL; external 'gdi32' name 'GetWorldTransform';
 function SetWorldTransform(_para1:HDC; var _para2:XFORM):WINBOOL; external 'gdi32' name 'SetWorldTransform';
 function SetWorldTransform(_para1:HDC; var _para2:XFORM):WINBOOL; external 'gdi32' name 'SetWorldTransform';
-function ModifyWorldTransform(_para1:HDC; var _para2:XFORM; _para3:DWORD):WINBOOL; external 'gdi32' name 'ModifyWorldTransform';
+function ModifyWorldTransform(_para1:HDC; _para2:PXFORM; _para3:DWORD):WINBOOL; external 'gdi32' name 'ModifyWorldTransform';
 function CombineTransform(_para1:LPXFORM; var _para2:XFORM; var _para3:XFORM):WINBOOL; external 'gdi32' name 'CombineTransform';
 function CombineTransform(_para1:LPXFORM; var _para2:XFORM; var _para3:XFORM):WINBOOL; external 'gdi32' name 'CombineTransform';
 function CreateDIBSection(_para1:HDC; var _para2:BITMAPINFO; _para3:UINT; var _para4:pointer; _para5:HANDLE;_para6:DWORD):HBITMAP; external 'gdi32' name 'CreateDIBSection';
 function CreateDIBSection(_para1:HDC; var _para2:BITMAPINFO; _para3:UINT; var _para4:pointer; _para5:HANDLE;_para6:DWORD):HBITMAP; external 'gdi32' name 'CreateDIBSection';
 function GetDIBColorTable(_para1:HDC; _para2:UINT; _para3:UINT; var _para4:RGBQUAD):UINT; external 'gdi32' name 'GetDIBColorTable';
 function GetDIBColorTable(_para1:HDC; _para2:UINT; _para3:UINT; var _para4:RGBQUAD):UINT; external 'gdi32' name 'GetDIBColorTable';
@@ -1316,7 +1320,13 @@ function CONSOLE_REAL_OUTPUT_HANDLE : HANDLE;
   function GetConsoleWindow:HWND;stdcall;external 'kernel32' name 'GetConsoleWindow';
   function GetConsoleWindow:HWND;stdcall;external 'kernel32' name 'GetConsoleWindow';
   function GetConsoleProcessList(lpdwProcessList:LPDWORD; dwProcessCount:DWORD):DWORD;stdcall;external 'kernel32' name 'GetConsoleProcessList';
   function GetConsoleProcessList(lpdwProcessList:LPDWORD; dwProcessCount:DWORD):DWORD;stdcall;external 'kernel32' name 'GetConsoleProcessList';
   function ReadDirectoryChangesW(hDirectory: HANDLE; lpBuffer: LPVOID;nBufferLength: DWORD; bWatchSubtree: BOOL; dwNotifyFilter: DWORD;lpBytesReturned: LPDWORD;lpOverlapped: LPOVERLAPPED;lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE): BOOL; stdcall; external 'kernel32' name 'ReadDirectoryChangesW';  
   function ReadDirectoryChangesW(hDirectory: HANDLE; lpBuffer: LPVOID;nBufferLength: DWORD; bWatchSubtree: BOOL; dwNotifyFilter: DWORD;lpBytesReturned: LPDWORD;lpOverlapped: LPOVERLAPPED;lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE): BOOL; stdcall; external 'kernel32' name 'ReadDirectoryChangesW';  
-
+  function IsDebuggerPresent : BOOL; stdcall; external 'kernel32.dll' name 'IsDebuggerPresent';
+  function Wow64DisableWow64FsRedirection(RedirectionState : ppointer) : BOOL; stdcall;   external 'kernel32.dll' name 'Wow64DisableWow64FsRedirection';
+  function Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection:BYTE) : BOOL; stdcall;   external 'kernel32.dll' name 'Wow64EnableWow64FsRedirection';
+  function Wow64RevertWow64FsRedirection(RedirectionState : pointer) : BOOL; stdcall; external 'kernel32.dll' name 'Wow64RevertWow64FsRedirection';
+  function IsWow64Process(hProcess:THandle; Wow64Process:PBOOL):BOOL;stdcall; external 'kernel32.dll' name 'IsWow64Process';
+  function GetPhysicallyInstalledSystemMemory(TotalMemoryInKilobytes: PULONGLONG ):BOOL; stdcall; external 'kernel32.dll' name 'GetPhysicallyInstalledSystemMemory';
+  function OpenThread(DesiredAccess : DWORD; InheritHandle : BOOL; ThreadId : DWORD) : THANDLE; stdcall; external 'kernel32.dll' name 'OpenThread';
 {$endif read_interface}
 {$endif read_interface}
 
 
 
 

+ 16 - 16
rtl/win/wininc/messages.inc

@@ -270,22 +270,22 @@
      HDM_HITTEST = 4614;
      HDM_HITTEST = 4614;
      HDM_LAYOUT = 4613;
      HDM_LAYOUT = 4613;
   { Header control notifications  }
   { Header control notifications  }
-     HDN_BEGINTRACKW = -(326);
-     HDN_DIVIDERDBLCLICKW = -(325);
-     HDN_ENDTRACKW = -(327);
-     HDN_ITEMCHANGEDW = -(321);
-     HDN_ITEMCHANGINGW = -(320);
-     HDN_ITEMCLICKW = -(322);
-     HDN_ITEMDBLCLICKW = -(323);
-     HDN_TRACKW = -(328);
-     HDN_BEGINTRACKA = -(306);
-     HDN_DIVIDERDBLCLICKA = -(305);
-     HDN_ENDTRACKA = -(307);
-     HDN_ITEMCHANGEDA = -(301);
-     HDN_ITEMCHANGINGA = -(300);
-     HDN_ITEMCLICKA = -(302);
-     HDN_ITEMDBLCLICKA = -(303);
-     HDN_TRACKA = -(308);
+     HDN_BEGINTRACKW = UINT(-326);
+     HDN_DIVIDERDBLCLICKW = UINT(-325);
+     HDN_ENDTRACKW = UINT(-327);
+     HDN_ITEMCHANGEDW = UINT(-321);
+     HDN_ITEMCHANGINGW = UINT(-320);
+     HDN_ITEMCLICKW = UINT(-322);
+     HDN_ITEMDBLCLICKW = UINT(-323);
+     HDN_TRACKW = UINT(-328);
+     HDN_BEGINTRACKA = UINT(-306);
+     HDN_DIVIDERDBLCLICKA = UINT(-305);
+     HDN_ENDTRACKA = UINT(-307);
+     HDN_ITEMCHANGEDA = UINT(-301);
+     HDN_ITEMCHANGINGA = UINT(-300);
+     HDN_ITEMCLICKA = UINT(-302);
+     HDN_ITEMDBLCLICKA = UINT(-303);
+     HDN_TRACKA = UINT(-308);
 {$ifdef UNICODE}
 {$ifdef UNICODE}
 
 
   const
   const

+ 1 - 1
rtl/win/wininc/redef.inc

@@ -698,7 +698,7 @@ function MapWindowPoints(hWndFrom, hWndTo: HWND; var lpPoints; cPoints: UINT): I
 function MessageBoxIndirect(const MsgBoxParams: TMsgBoxParams): BOOL;external 'user32' name 'MessageBoxIndirectA';
 function MessageBoxIndirect(const MsgBoxParams: TMsgBoxParams): BOOL;external 'user32' name 'MessageBoxIndirectA';
 function MessageBoxIndirectA(const MsgBoxParams: TMsgBoxParamsA): BOOL; external 'user32' name 'MessageBoxIndirectA';
 function MessageBoxIndirectA(const MsgBoxParams: TMsgBoxParamsA): BOOL; external 'user32' name 'MessageBoxIndirectA';
 //function MessageBoxIndirectW(const MsgBoxParams: TMsgBoxParamsW): BOOL; external 'user32' name 'MessageBoxIndirectW';
 //function MessageBoxIndirectW(const MsgBoxParams: TMsgBoxParamsW): BOOL; external 'user32' name 'MessageBoxIndirectW';
-//function ModifyWorldTransform(DC: HDC; const p2: TXForm; p3: DWORD): BOOL; external 'gdi32' name 'ModifyWorldTransform';
+function ModifyWorldTransform(_para1:HDC; var _para2:XFORM; _para3:DWORD):WINBOOL; external 'gdi32' name 'ModifyWorldTransform';
 function MsgWaitForMultipleObjects(nCount: DWORD; var pHandles; fWaitAll: BOOL; dwMilliseconds, dwWakeMask: DWORD): DWORD;external 'user32' name 'MsgWaitForMultipleObjects';
 function MsgWaitForMultipleObjects(nCount: DWORD; var pHandles; fWaitAll: BOOL; dwMilliseconds, dwWakeMask: DWORD): DWORD;external 'user32' name 'MsgWaitForMultipleObjects';
 {$ifndef NO_SMART_LINK}
 {$ifndef NO_SMART_LINK}
 function MsgWaitForMultipleObjectsEx(nCount: DWORD; var pHandles; dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD;external 'user32' name 'MsgWaitForMultipleObjectsEx';
 function MsgWaitForMultipleObjectsEx(nCount: DWORD; var pHandles; dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD;external 'user32' name 'MsgWaitForMultipleObjectsEx';

+ 1 - 0
rtl/win/wininc/unidef.inc

@@ -473,6 +473,7 @@ function FindFirstFileEx(lpfilename : LPCWStr;fInfoLevelId:FINDEX_INFO_LEVELS ;l
 // winver>$0600 
 // winver>$0600 
 function FindFirstFileTransacted(lpfilename : LPCWStr;fInfoLevelId:FINDEX_INFO_LEVELS ;lpFindFileData:pointer;fSearchOp : FINDEX_SEARCH_OPS;lpSearchFilter:pointer;dwAdditionalFlags:dword;htransaction : HANDLE):Handle; stdcall; external 'kernel32' name 'FindFirstFileTransactedW';
 function FindFirstFileTransacted(lpfilename : LPCWStr;fInfoLevelId:FINDEX_INFO_LEVELS ;lpFindFileData:pointer;fSearchOp : FINDEX_SEARCH_OPS;lpSearchFilter:pointer;dwAdditionalFlags:dword;htransaction : HANDLE):Handle; stdcall; external 'kernel32' name 'FindFirstFileTransactedW';
 function GetComputerNameEx(NameType:COMPUTER_NAME_FORMAT;lpbuffer:LPWSTR;nSize:LPDWORD):BOOL;stdcall;external 'kernel32' name 'GetComputerNameExW';
 function GetComputerNameEx(NameType:COMPUTER_NAME_FORMAT;lpbuffer:LPWSTR;nSize:LPDWORD):BOOL;stdcall;external 'kernel32' name 'GetComputerNameExW';
+function QueryFullProcessImageName(hProcess:THandle;dwFlags:DWord; lpexename :lpwstr;lpdwsize:pdword):BOOL; stdcall; external 'kernel32.dll' name 'QueryFullProcessImageNameW';
 {$endif read_interface}
 {$endif read_interface}
 
 
 
 

+ 1 - 0
rtl/win/wininc/unifun.inc

@@ -496,6 +496,7 @@ function GetConsoleAliasExesLengthW:DWORD;stdcall;external 'kernel32' name 'GetC
 function GetConsoleAliasesW(AliasBuffer:LPWSTR; AliasBufferLength:DWORD; ExeName:LPWSTR):DWORD;stdcall;external 'kernel32' name 'GetConsoleAliasesW';
 function GetConsoleAliasesW(AliasBuffer:LPWSTR; AliasBufferLength:DWORD; ExeName:LPWSTR):DWORD;stdcall;external 'kernel32' name 'GetConsoleAliasesW';
 function GetConsoleAliasExesW(ExeNameBuffer:LPWSTR; ExeNameBufferLength:DWORD):DWORD;stdcall;external 'kernel32' name 'GetConsoleAliasExesW';
 function GetConsoleAliasExesW(ExeNameBuffer:LPWSTR; ExeNameBufferLength:DWORD):DWORD;stdcall;external 'kernel32' name 'GetConsoleAliasExesW';
 function GetComputerNameExW(NameType:COMPUTER_NAME_FORMAT;lpbuffer:LPWSTR;nSize:LPDWORD):BOOL;stdcall;external 'kernel32' name 'GetComputerNameExW';
 function GetComputerNameExW(NameType:COMPUTER_NAME_FORMAT;lpbuffer:LPWSTR;nSize:LPDWORD):BOOL;stdcall;external 'kernel32' name 'GetComputerNameExW';
+function QueryFullProcessImageNameW(hProcess:THandle;dwFlags:DWord; lpexename :lpwstr;lpdwsize:pdword):BOOL; stdcall; external 'kernel32.dll' name 'QueryFullProcessImageNameW';
 {$endif read_interface}
 {$endif read_interface}
 
 
 
 

+ 4 - 4
tests/Makefile

@@ -2442,10 +2442,10 @@ ifndef SINGLEDOTESTRUNS
 endif
 endif
 alltests: alltest alltbs alltbf allwebtbs allwebtbf
 alltests: alltest alltbs alltbf allwebtbs allwebtbf
 test_c_objects: testprep
 test_c_objects: testprep
-	$(MAKE) $(patsubst %.pp,%.log, $(wildcard test/cg/cdecl/tcalext*.pp)))
-	$(MAKE) $(patsubst %.pp,%.elg, $(wildcard test/cg/cdecl/tcalext*.pp)))
-	$(MAKE) $(patsubst %.pp,%.log, $(wildcard test/cg/cdecl/tcppcl*.pp)))
-	$(MAKE) $(patsubst %.pp,%.elg, $(wildcard test/cg/cdecl/tcppcl*.pp)))
+	$(MAKE) $(patsubst %.pp,%.log, $(wildcard test/cg/cdecl/tcalext*.pp))
+	$(MAKE) $(patsubst %.pp,%.elg, $(wildcard test/cg/cdecl/tcalext*.pp))
+	$(MAKE) $(patsubst %.pp,%.log, $(wildcard test/cg/cdecl/tcppcl*.pp))
+	$(MAKE) $(patsubst %.pp,%.elg, $(wildcard test/cg/cdecl/tcppcl*.pp))
 ifdef SINGLEDOTESTRUNS
 ifdef SINGLEDOTESTRUNS
 .PHONY: allexectbs allexectbf allexecwebtbs allexecwebtbf allexectest allexectests
 .PHONY: allexectbs allexectbf allexecwebtbs allexecwebtbf allexectest allexectests
 allexectbs: $(addsuffix .tbslog, $(LOGFILES))
 allexectbs: $(addsuffix .tbslog, $(LOGFILES))

+ 4 - 4
tests/Makefile.fpc

@@ -451,10 +451,10 @@ endif
 alltests: alltest alltbs alltbf allwebtbs allwebtbf
 alltests: alltest alltbs alltbf allwebtbs allwebtbf
 
 
 test_c_objects: testprep
 test_c_objects: testprep
-	$(MAKE) $(patsubst %.pp,%.log, $(wildcard test/cg/cdecl/tcalext*.pp)))
-	$(MAKE) $(patsubst %.pp,%.elg, $(wildcard test/cg/cdecl/tcalext*.pp)))
-	$(MAKE) $(patsubst %.pp,%.log, $(wildcard test/cg/cdecl/tcppcl*.pp)))
-	$(MAKE) $(patsubst %.pp,%.elg, $(wildcard test/cg/cdecl/tcppcl*.pp)))
+	$(MAKE) $(patsubst %.pp,%.log, $(wildcard test/cg/cdecl/tcalext*.pp))
+	$(MAKE) $(patsubst %.pp,%.elg, $(wildcard test/cg/cdecl/tcalext*.pp))
+	$(MAKE) $(patsubst %.pp,%.log, $(wildcard test/cg/cdecl/tcppcl*.pp))
+	$(MAKE) $(patsubst %.pp,%.elg, $(wildcard test/cg/cdecl/tcppcl*.pp))
 	
 	
 ################################
 ################################
 # Compile and Run tests
 # Compile and Run tests

+ 29 - 0
tests/tbs/tb0657.pp

@@ -0,0 +1,29 @@
+program tb0657;
+
+{$mode objfpc}
+
+uses
+  fgl;
+
+type
+  TIntList = specialize TFPGList<LongInt>;
+
+const
+  c = 3;
+
+var
+  l: TIntList;
+  i: LongInt;
+begin
+  l := TIntList.Create;
+  try
+    for i := 0 to c do
+      l.Add(i);
+
+    for i := 0 to l.Count - 1 do
+      if l.List^[i] <> i then
+        Halt(i + 1);
+  finally
+    l.Free;
+  end;
+end.

+ 13 - 0
tests/test/cg/tcalext6.pp

@@ -28,9 +28,22 @@ uses ctypes;
 
 
 {$if defined(CPUARMEL) and defined(FPUSOFT)}
 {$if defined(CPUARMEL) and defined(FPUSOFT)}
 { for softfloat calls in the C code }
 { for softfloat calls in the C code }
+  {$define LIBGCC_NEEDED}
+{$endif}
+
+{$ifdef OPENBSD}
+  { OpenBSD GCC uses __guard_local which is defined in crtbegin.o or crtbeginS.o}
+  {$define LIBC_NEEDED}
+{$endif}
+
+{$ifdef LIBGCC_NEEDED}
 {$linklib gcc}
 {$linklib gcc}
 {$endif}
 {$endif}
 
 
+{$ifdef LIBC_NEEDED}
+{$linklib c}
+{$endif}
+
 type
 type
   int8_t = shortint;
   int8_t = shortint;
   pint8_t = ^int8_t;
   pint8_t = ^int8_t;

+ 4 - 0
tests/test/cg/tcppcl2.pp

@@ -4,6 +4,10 @@ program tcppcl2;
 
 
 {$mode objfpc}
 {$mode objfpc}
 {$L cpptcl2.o}
 {$L cpptcl2.o}
+{$ifdef openbsd}
+  {$linklib stdc++}
+  {$linklib c}
+{$endif}
 
 
 type
 type
   TestClass = cppclass external
   TestClass = cppclass external

+ 4 - 1
tests/utils/testsuite/utests.pp

@@ -211,7 +211,10 @@ type
     ver_3_0_3,
     ver_3_0_3,
     ver_3_0_4,
     ver_3_0_4,
     ver_3_0_5,
     ver_3_0_5,
-    ver_3_1_1);
+    ver_3_1_1,
+    ver_3_2_0,
+    ver_3_2_1,
+    ver_3_3_1);
 
 
 const
 const
   ver_trunk = high (known_versions);
   ver_trunk = high (known_versions);

+ 180 - 40
utils/h2pas/h2paschk.pas

@@ -48,6 +48,9 @@ program h2paschk;
 .blue
 .blue
 .alpha
 .alpha
 
 
+@TYPE size_t
+@CONSTANT O_RW
+
 @C   return 0;
 @C   return 0;
 @C }
 @C }
 
 
@@ -91,6 +94,20 @@ type
     procedure DoneLangOutputs;
     procedure DoneLangOutputs;
 
 
     procedure StartRecord(RecordID: TIdentifier);
     procedure StartRecord(RecordID: TIdentifier);
+    procedure HandleType(TypeID: TIdentifier);
+    procedure HandleConstant(ConstantID: TIdentifier;PascalType,PascalHexStrSize,CType,CFormat : string);
+    procedure HandleConstant(ConstantID: TIdentifier);
+    procedure HandleConstantU8(ConstantID: TIdentifier);
+    procedure HandleConstantU16(ConstantID: TIdentifier);
+    procedure HandleConstantU32(ConstantID: TIdentifier);
+    procedure HandleConstantU64(ConstantID: TIdentifier);
+    procedure HandleSignedConstant(ConstantID: TIdentifier;PascalType,CType,CFormat : string);
+    procedure HandleSignedConstant(ConstantID: TIdentifier);
+    procedure HandleConstantS8(ConstantID: TIdentifier);
+    procedure HandleConstantS16(ConstantID: TIdentifier);
+    procedure HandleConstantS32(ConstantID: TIdentifier);
+    procedure HandleConstantS64(ConstantID: TIdentifier);
+    procedure HandleFloatConstant(ConstantID: TIdentifier);
     procedure ProcessField(FieldID: TIdentifier);
     procedure ProcessField(FieldID: TIdentifier);
   public
   public
     destructor Destroy; override;
     destructor Destroy; override;
@@ -127,11 +144,86 @@ begin
     DoneLangOutput(Lang);
     DoneLangOutput(Lang);
 end;
 end;
 
 
+
+procedure TH2PasCheckerCodeGen.HandleType(TypeID: TIdentifier);
+begin
+  Writeln(FLangOutput[lPascal], '  Writeln(''SizeOf(', TypeID[CommLangID], ')='',SizeOf(', TypeID[lPascal], '));');
+  Writeln(FLangOutput[lC], '  printf("SizeOf(', TypeID[CommLangID], ')=%lu\n",sizeof(', TypeID[lC], '));');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstant(ConstantID: TIdentifier;PascalType,PascalHexStrSize,CType,CFormat : string);
+begin
+  Writeln(FLangOutput[lPascal], '  Writeln(''Unsigned value Of(', ConstantID[CommLangID], ')=0x'',hexstr(',PascalType,'(', ConstantID[lPascal], '),',PascalHexStrSize,'));');
+  Writeln(FLangOutput[lC], '  printf("Unsigned value Of(', ConstantID[CommLangID], ')=0x',CFormat,'\n",(',CType,') ', ConstantID[lC], ');');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleSignedConstant(ConstantID: TIdentifier;PascalType,CType,CFormat : string);
+begin
+  Writeln(FLangOutput[lPascal], '  Writeln(''Signed value Of(', ConstantID[CommLangID], ')='',',PascalType,'(', ConstantID[lPascal],'));');
+  Writeln(FLangOutput[lC], '  printf("Signed value Of(', ConstantID[CommLangID], ')=',CFormat,'\n",(',CType,') ', ConstantID[lC],');');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleFloatConstant(ConstantID: TIdentifier);
+begin
+  Writeln(FLangOutput[lPascal], '  Writeln(''Value Of(', ConstantID[CommLangID], ')='',',ConstantID[lPascal],':25:25);');
+  Writeln(FLangOutput[lC], '  printf("Value Of(', ConstantID[CommLangID], ')=%0.25f\n",',ConstantID[lC],');');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstant(ConstantID: TIdentifier);
+begin
+  HandleConstant(ConstantID,'qword','16','unsigned long long','%016llX');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstantU8(ConstantID: TIdentifier);
+begin
+  HandleConstant(ConstantID,'byte','2','unsigned char','%02X');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstantU16(ConstantID: TIdentifier);
+begin
+  HandleConstant(ConstantID,'word','4','unsigned short','%04X');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstantU32(ConstantID: TIdentifier);
+begin
+  HandleConstant(ConstantID,'dword','8','unsigned int','%08X');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstantU64(ConstantID: TIdentifier);
+begin
+  HandleConstant(ConstantID,'qword','16','unsigned int','%016llX');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleSignedConstant(ConstantID: TIdentifier);
+begin
+  HandleSignedConstant(ConstantID,'int64','signed long long','%lld');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstantS8(ConstantID: TIdentifier);
+begin
+  HandleSignedConstant(ConstantID,'int8','signed char','%d');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstantS16(ConstantID: TIdentifier);
+begin
+  HandleSignedConstant(ConstantID,'int16','signed short','%d');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstantS32(ConstantID: TIdentifier);
+begin
+  HandleSignedConstant(ConstantID,'int32','signed int','%d');
+end;
+
+procedure TH2PasCheckerCodeGen.HandleConstantS64(ConstantID: TIdentifier);
+begin
+  HandleSignedConstant(ConstantID,'int64','unsigned int','%lld');
+end;
+
+
 procedure TH2PasCheckerCodeGen.StartRecord(RecordID: TIdentifier);
 procedure TH2PasCheckerCodeGen.StartRecord(RecordID: TIdentifier);
 begin
 begin
   FCurrentRecord := RecordID;
   FCurrentRecord := RecordID;
-  Writeln(FLangOutput[lPascal], '  Writeln(''SizeOf(', RecordID[CommLangID], ')='',SizeOf(', RecordID[lPascal], '));');
-  Writeln(FLangOutput[lC], '  printf("SizeOf(', RecordID[CommLangID], ')=%lu\n",sizeof(', RecordID[lC], '));');
+  HandleType(RecordID);
 end;
 end;
 
 
 procedure TH2PasCheckerCodeGen.ProcessField(FieldID: TIdentifier);
 procedure TH2PasCheckerCodeGen.ProcessField(FieldID: TIdentifier);
@@ -156,6 +248,30 @@ var
   I: Integer;
   I: Integer;
   ID: TIdentifier;
   ID: TIdentifier;
   Lang: TLanguage;
   Lang: TLanguage;
+
+  procedure ReadID;
+  begin
+    if Pos(',', InS) >= 1 then
+    begin
+      for Lang in TLanguage do
+      begin
+        if Pos(',', InS) >= 1 then
+        begin
+          ID[Lang] := Copy(InS, 1, Pos(',', InS) - 1);
+          Delete(InS, 1, Pos(',', InS));
+        end
+        else
+        begin
+          ID[Lang] := InS;
+          InS := '';
+        end;
+      end;
+    end
+    else
+      for Lang in TLanguage do
+        ID[Lang] := InS;
+  end;
+
 begin
 begin
   FInFileName := InFileName;
   FInFileName := InFileName;
   AssignFile(InF, InFileName);
   AssignFile(InF, InFileName);
@@ -192,27 +308,69 @@ begin
                   Writeln(FLangOutput[lPascal], InS);
                   Writeln(FLangOutput[lPascal], InS);
                 '@C':
                 '@C':
                   Writeln(FLangOutput[lC], InS);
                   Writeln(FLangOutput[lC], InS);
+                '@FLOATCONSTANT':
+                  begin
+                    ReadID;
+                    HandleFloatConstant(ID);
+                  end;
+                '@CONSTANT':
+                  begin
+                    ReadID;
+                    HandleConstant(ID);
+                  end;
+                '@CONSTANT_U8':
+                  begin
+                    ReadID;
+                    HandleConstantU8(ID);
+                  end;
+                '@CONSTANT_U16':
+                  begin
+                    ReadID;
+                    HandleConstantU16(ID);
+                  end;
+                '@CONSTANT_U32':
+                  begin
+                    ReadID;
+                    HandleConstantU32(ID);
+                  end;
+                '@CONSTANT_U64':
+                  begin
+                    ReadID;
+                    HandleConstantU64(ID);
+                  end;
+                '@CONSTANT_S':
+                  begin
+                    ReadID;
+                    HandleSignedConstant(ID);
+                  end;
+                '@CONSTANT_S8':
+                  begin
+                    ReadID;
+                    HandleConstantS8(ID);
+                  end;
+                '@CONSTANT_S16':
+                  begin
+                    ReadID;
+                    HandleConstantS16(ID);
+                  end;
+                '@CONSTANT_S32':
+                  begin
+                    ReadID;
+                    HandleConstantU32(ID);
+                  end;
+                '@CONSTANT_S64':
+                  begin
+                    ReadID;
+                    HandleConstantS64(ID);
+                  end;
+                '@TYPE':
+                  begin
+                    ReadID;
+                    HandleType(ID);
+                  end;
                 '@RECORD':
                 '@RECORD':
                   begin
                   begin
-                    if Pos(',', InS) >= 1 then
-                    begin
-                      for Lang in TLanguage do
-                      begin
-                        if Pos(',', InS) >= 1 then
-                        begin
-                          ID[Lang] := Copy(InS, 1, Pos(',', InS) - 1);
-                          Delete(InS, 1, Pos(',', InS));
-                        end
-                        else
-                        begin
-                          ID[Lang] := InS;
-                          InS := '';
-                        end;
-                      end;
-                    end
-                    else
-                      for Lang in TLanguage do
-                        ID[Lang] := InS;
+                    ReadID;
                     StartRecord(ID);
                     StartRecord(ID);
                   end;
                   end;
                 else
                 else
@@ -222,25 +380,7 @@ begin
           '.':
           '.':
             begin
             begin
               Delete(InS, 1, 1);
               Delete(InS, 1, 1);
-              if Pos(',', InS) >= 1 then
-              begin
-                for Lang in TLanguage do
-                begin
-                  if Pos(',', InS) >= 1 then
-                  begin
-                    ID[Lang] := Copy(InS, 1, Pos(',', InS) - 1);
-                    Delete(InS, 1, Pos(',', InS));
-                  end
-                  else
-                  begin
-                    ID[Lang] := InS;
-                    InS := '';
-                  end;
-                end;
-              end
-              else
-                for Lang in TLanguage do
-                  ID[Lang] := InS;
+              ReadID;
               ProcessField(ID);
               ProcessField(ID);
             end;
             end;
         end;
         end;