Prechádzať zdrojové kódy

* synchronised with trunk till r41907

git-svn-id: branches/debug_eh@41908 -
Jonas Maebe 6 rokov pred
rodič
commit
2923e484fd

+ 2 - 0
.gitattributes

@@ -7327,6 +7327,8 @@ packages/ptc/src/win32/base/win32windowd.inc svneol=native#text/plain
 packages/ptc/src/win32/base/windows.ico -text
 packages/ptc/src/win32/directx/p_ddraw.pp svneol=native#text/plain
 packages/ptc/src/win32/directx/p_dinput.pp svneol=native#text/plain
+packages/ptc/src/win32/directx/t_ddraw.h2paschk svneol=native#text/plain
+packages/ptc/src/win32/directx/t_dinput.h2paschk svneol=native#text/plain
 packages/ptc/src/win32/directx/win32directxcheck.inc svneol=native#text/plain
 packages/ptc/src/win32/directx/win32directxconsoled.inc svneol=native#text/plain
 packages/ptc/src/win32/directx/win32directxconsolei.inc svneol=native#text/plain

+ 1 - 0
compiler/aasmcnst.pas

@@ -1115,6 +1115,7 @@ implementation
              secname:=make_mangledname(basename,st,'2_'+itemname);
            exclude(options,tcalo_vectorized_dead_strip_item);
          end;
+       current_module.linkorderedsymbols.concat(sym.Name);
        finalize_asmlist(sym,def,sectype,secname,alignment,options);
      end;
 

+ 3 - 1
compiler/avr/ccpuinnr.inc

@@ -16,4 +16,6 @@
   in_avr_sei = fpc_in_cpu_first+1,
   in_avr_wdr = fpc_in_cpu_first+2,
   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,
       aasmcpu,
       symdef,
-      cgbase,
+      hlcgobj,
+      pass_2,
+      cgbase, cgobj, cgutils,
       cpubase;
 
     function tavrinlinenode.pass_typecheck_cpu : tnode;
@@ -58,6 +60,16 @@ unit navrinl;
               CheckParameters(0);
               resultdef:=voidtype;
             end;
+          in_avr_save:
+            begin
+              CheckParameters(0);
+              resultdef:=u8inttype;
+            end;
+          in_avr_restore:
+            begin
+              CheckParameters(1);
+              resultdef:=voidtype;
+            end;
           else
             Result:=inherited pass_typecheck_cpu;
         end;
@@ -72,11 +84,17 @@ unit navrinl;
           in_avr_sleep,
           in_avr_sei,
           in_avr_wdr,
-          in_avr_cli:
+          in_avr_cli,
+          in_avr_restore:
             begin
               expectloc:=LOC_VOID;
               resultdef:=voidtype;
             end;
+          in_avr_save:
+            begin
+              expectloc:=LOC_REGISTER;
+              resultdef:=u8inttype;
+            end;
           else
             Result:=inherited first_cpu;
         end;
@@ -96,6 +114,20 @@ unit navrinl;
             current_asmdata.CurrAsmList.concat(taicpu.op_none(A_WDR));
           in_avr_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
             inherited pass_generate_code_cpu;
         end;

+ 1 - 7
compiler/cclasses.pas

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

+ 28 - 5
compiler/entfile.pas

@@ -120,6 +120,7 @@ const
   ibwpofile         = 84;
   ibmoduleoptions   = 85;
   ibunitimportsyms  = 86;
+  iborderedsymbols  = 87;
 
   ibmainname       = 90;
   ibsymtableoptions = 91;
@@ -236,6 +237,7 @@ type
     procedure resetfile;virtual;abstract;
     function getheadersize:longint;virtual;abstract;
     function getheaderaddr:pentryheader;virtual;abstract;
+    procedure RaiseAssertion(Code: Longint); virtual;
   public
     entrytyp : byte;
     size             : integer;
@@ -384,6 +386,13 @@ begin
 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;
 begin
   if mode<>0 then
@@ -744,12 +753,16 @@ begin
       result:=0;
     end;
 {$else not generic_cpu}
-  result:=4;
   case sizeof(aint) of
     8: result:=getint64;
     4: result:=getlongint;
     2: result:=smallint(getword);
     1: result:=shortint(getbyte);
+  else
+    begin
+      RaiseAssertion(2019041801);
+      result:=0;
+    end;
   end;
 {$endif not generic_cpu}
 end;
@@ -788,9 +801,12 @@ begin
     4: result:=asizeint(getlongint);
     2: result:=asizeint(getword);
     1: result:=asizeint(getbyte);
-    else
+  else
+    begin
+      RaiseAssertion(2019041802);
       result:=0;
-end;
+    end;
+  end;
 {$endif not generic_cpu}
 end;
 
@@ -821,7 +837,10 @@ begin
     2: result:=getword;
     1: result:=getbyte;
   else
-    result:=0;
+    begin
+      RaiseAssertion(2019041803);
+      result:=0;
+    end;
   end;
 {$endif not generic_cpu}
 end;
@@ -870,12 +889,16 @@ begin
       result:=0;
     end;
 {$else not generic_cpu}
-  result:=4;
   case sizeof(aword) of
     8: result:=getqword;
     4: result:=getdword;
     2: result:=getword;
     1: result:=getbyte;
+  else
+    begin
+      RaiseAssertion(2019041804);
+      result:=0;
+    end;
   end;
 {$endif not generic_cpu}
 end;

+ 6 - 1
compiler/fmodule.pas

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

+ 26 - 0
compiler/fppu.pas

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

+ 15 - 1
compiler/link.pas

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

+ 7 - 0
compiler/pcp.pas

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

+ 1 - 1
compiler/pdecsub.pas

@@ -2542,7 +2542,7 @@ const
       mutexclpo     : []
     ),(
       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;
       pocall   : pocall_internproc;
       pooption : [];

+ 6 - 0
compiler/symtype.pas

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

+ 3 - 1
compiler/systems.pas

@@ -169,7 +169,9 @@ interface
             { use PSABI/Dwarf-based "zero cost" exception handling }
             tf_use_psabieh,
             { use high level cfi directives to generate call frame information }
-            tf_use_hlcfi
+            tf_use_hlcfi,
+            { supports symbol order file (to ensure symbols in vectorised sections are kept in the correct order) }
+            tf_supports_symbolorderfile
        );
 
        psysteminfo = ^tsysteminfo;

+ 5 - 5
compiler/systems/i_bsd.pas

@@ -811,7 +811,7 @@ unit i_bsd;
             system       : system_i386_darwin;
             name         : 'Darwin for i386';
             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,tf_use_hlcfi];
+            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_use_hlcfi,tf_supports_symbolorderfile];
             cpu          : cpu_i386;
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
@@ -947,7 +947,7 @@ unit i_bsd;
             system       : system_powerpc64_darwin;
             name         : 'Darwin for PowerPC64';
             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;
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
@@ -1016,7 +1016,7 @@ unit i_bsd;
             name         : 'Darwin for x86_64';
             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,tf_use_hlcfi
-                            {$ifdef llvm},tf_use_psabieh{$endif}];
+                            {$ifdef llvm},tf_use_psabieh{$endif},tf_supports_symbolorderfile];
             cpu          : cpu_x86_64;
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
@@ -1150,7 +1150,7 @@ unit i_bsd;
             system       : system_arm_darwin;
             name         : 'Darwin for ARM';
             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;
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX;CPUARMEL';
@@ -1218,7 +1218,7 @@ unit i_bsd;
             system       : system_aarch64_darwin;
             name         : 'Darwin for AArch64';
             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;
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';

+ 65 - 9
compiler/systems/t_bsd.pas

@@ -66,6 +66,7 @@ implementation
       Function  WriteResponseFile(isdll:boolean) : Boolean;
       function GetDarwinCrt1ObjName(isdll: boolean): TCmdStr;
       Function GetDarwinPrtobjName(isdll: boolean): TCmdStr;
+      Function WriteSymbolOrderFile: TCmdStr;
     public
       constructor Create;override;
       procedure SetDefaultInfo;override;
@@ -173,8 +174,8 @@ begin
        begin
          if not(target_info.system in systems_darwin) then
            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
          else
            begin
@@ -193,22 +194,22 @@ begin
                programs with problems that require Valgrind will have more
                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
                ExeCmd[1]:=ExeCmd[1]+' -pagezero_size 0x10000';
 {$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}
              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
-               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
      else
        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;
      if not(target_info.system in systems_darwin) then
        DllCmd[2]:='strip --strip-unneeded $EXE'
@@ -467,6 +468,30 @@ begin
 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;
 Var
   linkres      : TLinkRes;
@@ -777,7 +802,8 @@ var
   targetstr,
   emulstr,
   extdbgbinstr,
-  extdbgcmdstr: TCmdStr;
+  extdbgcmdstr,
+  ordersymfile: TCmdStr;
   linkscript: TAsmScript;
   DynLinkStr : string[60];
   GCSectionsStr,
@@ -861,6 +887,9 @@ begin
 { Write used files and libraries }
   WriteResponseFile(false);
 
+{ Write symbol order file }
+  ordersymfile:=WriteSymbolOrderFile;
+
 { Call linker }
   SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
   Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
@@ -870,6 +899,16 @@ begin
   Replace(cmdstr,'$MAP',mapstr);
   Replace(cmdstr,'$CATRES',CatFileContent(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
     Replace(cmdstr,'$FILELIST','-filelist '+maybequoted(outputexedir+'linkfiles.res'))
   else
@@ -922,6 +961,8 @@ begin
   if (success) and not(cs_link_nolink in current_settings.globalswitches) then
    begin
      DeleteFile(outputexedir+Info.ResName);
+     if ordersymfile<>'' then
+       DeleteFile(ordersymfile);
      if LdSupportsNoResponseFile Then
        begin
          DeleteFile(linkscript.fn);
@@ -946,6 +987,7 @@ var
   binstr,
   cmdstr,
   mapstr,
+  ordersymfile,
   targetstr,
   emulstr,
   extdbgbinstr,
@@ -964,6 +1006,9 @@ begin
 { Write used files and libraries }
   WriteResponseFile(true);
 
+{ Write symbol order file }
+  ordersymfile:=WriteSymbolOrderFile;
+
   if (cs_link_smart in current_settings.globalswitches) and
      (tf_smartlink_sections in target_info.flags) then
     if not(target_info.system in systems_darwin) then
@@ -1014,6 +1059,15 @@ begin
   Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
   Replace(cmdstr,'$SONAME',SoNameStr);
   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
     Replace(cmdstr,'$PRTOBJ',GetDarwinPrtobjName(true));
   BinStr:=FindUtil(utilsprefix+BinStr);
@@ -1080,6 +1134,8 @@ begin
   if (success) and not(cs_link_nolink in current_settings.globalswitches) then
     begin
       DeleteFile(outputexedir+Info.ResName);
+      if ordersymfile<>'' then
+        DeleteFile(ordersymfile);
       if LdSupportsNoResponseFile Then
         begin
           DeleteFile(linkscript.fn);

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

@@ -215,8 +215,14 @@ type
     ModuleFlags: tmoduleflags;
   end;
 
+type
+  tppudumpfile = class(tppufile)
+  protected
+    procedure RaiseAssertion(Code: Longint); override;
+  end;
+
 var
-  ppufile     : tppufile;
+  ppufile     : tppudumpfile;
   ppuversion  : dword;
   space       : string;
   verbose     : longint;
@@ -334,6 +340,12 @@ Begin
   SetHasErrors;
 End;
 
+procedure tppudumpfile.RaiseAssertion(Code: Longint);
+begin
+  WriteError('Internal Error ' + ToStr(Code));
+  inherited RaiseAssertion(Code);
+end;
+
 Procedure WriteWarning(const S : string);
 var
   ss: string;
@@ -763,7 +775,7 @@ end;
 
 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
 }
 begin
@@ -3828,7 +3840,11 @@ begin
 
          ibresources :
            if not silent then
-             ReadLinkContainer('Resource file: ');
+             ReadContainer('Resource file: ');
+
+         iborderedsymbols:
+           if not silent then
+             ReadContainer('Ordered symbol: ');
 
          iberror :
            begin
@@ -3914,7 +3930,7 @@ begin
 { fix filename }
   if pos('.',filename)=0 then
    filename:=filename+'.ppu';
-  ppufile:=tppufile.create(filename);
+  ppufile:=tppudumpfile.create(filename);
   if not ppufile.openfile then
    begin
      WriteError('IO-Error when opening : '+filename+', Skipping');

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

@@ -2556,6 +2556,13 @@ var
     Result:=false;
   end;
 
+  procedure HandleEscape;
+  begin
+    inc(MyTokenPos);
+    if (MyTokenPos<=l) and (s[MyTokenPos]>#31) then
+      inc(MyTokenPos);
+  end;
+
 begin
   SetCurTokenString('');
   s:=CurLine;
@@ -2574,6 +2581,8 @@ begin
     if MyTokenPos>l then
       if DoEndOfLine then exit;
     case s[MyTokenPos] of
+    '\':
+      HandleEscape;
     '''':
       begin
       inc(MyTokenPos);
@@ -2581,6 +2590,8 @@ begin
         if MyTokenPos>l then
           Error(nErrOpenString,SErrOpenString);
         case s[MyTokenPos] of
+        '\':
+          HandleEscape;
         '''':
           begin
           inc(MyTokenPos);
@@ -2603,6 +2614,8 @@ begin
         if MyTokenPos>l then
           Error(nErrOpenString,SErrOpenString);
         case s[MyTokenPos] of
+        '\':
+          HandleEscape;
         '"':
           begin
           inc(MyTokenPos);
@@ -2618,6 +2631,31 @@ begin
         end;
       until false;
       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
       inc(MyTokenPos);

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

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

+ 497 - 0
packages/ptc/src/win32/directx/t_ddraw.h2paschk

@@ -0,0 +1,497 @@
+@Pascal uses p_ddraw;
+@Pascal begin
+
+@C #include <ddraw.h>
+@C #include <stdio.h>
+@C #include <stddef.h>
+@C #include <tchar.h>
+@C int _tmain(int argc, _TCHAR* argv[])
+@C {
+
+@record TDDARGB,DDARGB
+.blue
+.green
+.red
+.alpha
+
+@record TDDRGBA,DDRGBA
+.red
+.green
+.blue
+.alpha
+
+@record TDDCOLORKEY,DDCOLORKEY
+.dwColorSpaceLowValue
+.dwColorSpaceHighValue
+
+@record TDDBLTFX,DDBLTFX
+.dwSize
+.dwDDFX
+.dwROP
+.dwDDROP
+.dwRotationAngle
+.dwZBufferOpCode
+.dwZBufferLow
+.dwZBufferHigh
+.dwZBufferBaseDest
+.dwZDestConstBitDepth
+.dwZDestConst
+.lpDDSZBufferDest
+.dwZSrcConstBitDepth
+.dwZSrcConst
+.lpDDSZBufferSrc
+.dwAlphaEdgeBlendBitDepth
+.dwAlphaEdgeBlend
+.dwReserved
+.dwAlphaDestConstBitDepth
+.dwAlphaDestConst
+.lpDDSAlphaDest
+.dwAlphaSrcConstBitDepth
+.dwAlphaSrcConst
+.lpDDSAlphaSrc
+.dwFillColor
+.dwFillDepth
+.dwFillPixel
+.lpDDSPattern
+.ddckDestColorkey
+.ddckSrcColorkey
+
+@record TDDSCAPS,DDSCAPS
+.dwCaps
+
+@record TDDOSCAPS,DDOSCAPS
+.dwCaps
+
+@record TDDSCAPSEX,DDSCAPSEX
+.dwCaps2
+.dwCaps3
+.dwCaps4
+.dwVolumeDepth
+
+@record TDDSCAPS2,DDSCAPS2
+.dwCaps
+.dwCaps2
+.dwCaps3
+.dwCaps4
+.dwVolumeDepth
+
+@record TDDCAPS_DX1,DDCAPS_DX1
+.dwSize
+.dwCaps
+.dwCaps2
+.dwCKeyCaps
+.dwFXCaps
+.dwFXAlphaCaps
+.dwPalCaps
+.dwSVCaps
+.dwAlphaBltConstBitDepths
+.dwAlphaBltPixelBitDepths
+.dwAlphaBltSurfaceBitDepths
+.dwAlphaOverlayConstBitDepths
+.dwAlphaOverlayPixelBitDepths
+.dwAlphaOverlaySurfaceBitDepths
+.dwZBufferBitDepths
+.dwVidMemTotal
+.dwVidMemFree
+.dwMaxVisibleOverlays
+.dwCurrVisibleOverlays
+.dwNumFourCCCodes
+.dwAlignBoundarySrc
+.dwAlignSizeSrc
+.dwAlignBoundaryDest
+.dwAlignSizeDest
+.dwAlignStrideAlign
+.dwRops
+.ddsCaps
+.dwMinOverlayStretch
+.dwMaxOverlayStretch
+.dwMinLiveVideoStretch
+.dwMaxLiveVideoStretch
+.dwMinHwCodecStretch
+.dwMaxHwCodecStretch
+.dwReserved1
+.dwReserved2
+.dwReserved3
+
+@record TDDCAPS_DX3,DDCAPS_DX3
+.dwSize
+.dwCaps
+.dwCaps2
+.dwCKeyCaps
+.dwFXCaps
+.dwFXAlphaCaps
+.dwPalCaps
+.dwSVCaps
+.dwAlphaBltConstBitDepths
+.dwAlphaBltPixelBitDepths
+.dwAlphaBltSurfaceBitDepths
+.dwAlphaOverlayConstBitDepths
+.dwAlphaOverlayPixelBitDepths
+.dwAlphaOverlaySurfaceBitDepths
+.dwZBufferBitDepths
+.dwVidMemTotal
+.dwVidMemFree
+.dwMaxVisibleOverlays
+.dwCurrVisibleOverlays
+.dwNumFourCCCodes
+.dwAlignBoundarySrc
+.dwAlignSizeSrc
+.dwAlignBoundaryDest
+.dwAlignSizeDest
+.dwAlignStrideAlign
+.dwRops
+.ddsCaps
+.dwMinOverlayStretch
+.dwMaxOverlayStretch
+.dwMinLiveVideoStretch
+.dwMaxLiveVideoStretch
+.dwMinHwCodecStretch
+.dwMaxHwCodecStretch
+.dwReserved1
+.dwReserved2
+.dwReserved3
+.dwSVBCaps
+.dwSVBCKeyCaps
+.dwSVBFXCaps
+.dwSVBRops
+.dwVSBCaps
+.dwVSBCKeyCaps
+.dwVSBFXCaps
+.dwVSBRops
+.dwSSBCaps
+.dwSSBCKeyCaps
+.dwSSBFXCaps
+.dwSSBRops
+.dwReserved4
+.dwReserved5
+.dwReserved6
+
+@record TDDCAPS_DX5,DDCAPS_DX5
+.dwSize
+.dwCaps
+.dwCaps2
+.dwCKeyCaps
+.dwFXCaps
+.dwFXAlphaCaps
+.dwPalCaps
+.dwSVCaps
+.dwAlphaBltConstBitDepths
+.dwAlphaBltPixelBitDepths
+.dwAlphaBltSurfaceBitDepths
+.dwAlphaOverlayConstBitDepths
+.dwAlphaOverlayPixelBitDepths
+.dwAlphaOverlaySurfaceBitDepths
+.dwZBufferBitDepths
+.dwVidMemTotal
+.dwVidMemFree
+.dwMaxVisibleOverlays
+.dwCurrVisibleOverlays
+.dwNumFourCCCodes
+.dwAlignBoundarySrc
+.dwAlignSizeSrc
+.dwAlignBoundaryDest
+.dwAlignSizeDest
+.dwAlignStrideAlign
+.dwRops
+.ddsCaps
+.dwMinOverlayStretch
+.dwMaxOverlayStretch
+.dwMinLiveVideoStretch
+.dwMaxLiveVideoStretch
+.dwMinHwCodecStretch
+.dwMaxHwCodecStretch
+.dwReserved1
+.dwReserved2
+.dwReserved3
+.dwSVBCaps
+.dwSVBCKeyCaps
+.dwSVBFXCaps
+.dwSVBRops
+.dwVSBCaps
+.dwVSBCKeyCaps
+.dwVSBFXCaps
+.dwVSBRops
+.dwSSBCaps
+.dwSSBCKeyCaps
+.dwSSBFXCaps
+.dwSSBRops
+.dwMaxVideoPorts
+.dwCurrVideoPorts
+.dwSVBCaps2
+.dwNLVBCaps
+.dwNLVBCaps2
+.dwNLVBCKeyCaps
+.dwNLVBFXCaps
+.dwNLVBRops
+
+@record TDDCAPS_DX6,DDCAPS_DX6
+.dwSize
+.dwCaps
+.dwCaps2
+.dwCKeyCaps
+.dwFXCaps
+.dwFXAlphaCaps
+.dwPalCaps
+.dwSVCaps
+.dwAlphaBltConstBitDepths
+.dwAlphaBltPixelBitDepths
+.dwAlphaBltSurfaceBitDepths
+.dwAlphaOverlayConstBitDepths
+.dwAlphaOverlayPixelBitDepths
+.dwAlphaOverlaySurfaceBitDepths
+.dwZBufferBitDepths
+.dwVidMemTotal
+.dwVidMemFree
+.dwMaxVisibleOverlays
+.dwCurrVisibleOverlays
+.dwNumFourCCCodes
+.dwAlignBoundarySrc
+.dwAlignSizeSrc
+.dwAlignBoundaryDest
+.dwAlignSizeDest
+.dwAlignStrideAlign
+.dwRops
+.ddsOldCaps
+.dwMinOverlayStretch
+.dwMaxOverlayStretch
+.dwMinLiveVideoStretch
+.dwMaxLiveVideoStretch
+.dwMinHwCodecStretch
+.dwMaxHwCodecStretch
+.dwReserved1
+.dwReserved2
+.dwReserved3
+.dwSVBCaps
+.dwSVBCKeyCaps
+.dwSVBFXCaps
+.dwSVBRops
+.dwVSBCaps
+.dwVSBCKeyCaps
+.dwVSBFXCaps
+.dwVSBRops
+.dwSSBCaps
+.dwSSBCKeyCaps
+.dwSSBFXCaps
+.dwSSBRops
+.dwMaxVideoPorts
+.dwCurrVideoPorts
+.dwSVBCaps2
+.dwNLVBCaps
+.dwNLVBCaps2
+.dwNLVBCKeyCaps
+.dwNLVBFXCaps
+.dwNLVBRops
+.ddsCaps
+
+@record TDDCAPS_DX7,DDCAPS_DX7
+.dwSize
+.dwCaps
+.dwCaps2
+.dwCKeyCaps
+.dwFXCaps
+.dwFXAlphaCaps
+.dwPalCaps
+.dwSVCaps
+.dwAlphaBltConstBitDepths
+.dwAlphaBltPixelBitDepths
+.dwAlphaBltSurfaceBitDepths
+.dwAlphaOverlayConstBitDepths
+.dwAlphaOverlayPixelBitDepths
+.dwAlphaOverlaySurfaceBitDepths
+.dwZBufferBitDepths
+.dwVidMemTotal
+.dwVidMemFree
+.dwMaxVisibleOverlays
+.dwCurrVisibleOverlays
+.dwNumFourCCCodes
+.dwAlignBoundarySrc
+.dwAlignSizeSrc
+.dwAlignBoundaryDest
+.dwAlignSizeDest
+.dwAlignStrideAlign
+.dwRops
+.ddsOldCaps
+.dwMinOverlayStretch
+.dwMaxOverlayStretch
+.dwMinLiveVideoStretch
+.dwMaxLiveVideoStretch
+.dwMinHwCodecStretch
+.dwMaxHwCodecStretch
+.dwReserved1
+.dwReserved2
+.dwReserved3
+.dwSVBCaps
+.dwSVBCKeyCaps
+.dwSVBFXCaps
+.dwSVBRops
+.dwVSBCaps
+.dwVSBCKeyCaps
+.dwVSBFXCaps
+.dwVSBRops
+.dwSSBCaps
+.dwSSBCKeyCaps
+.dwSSBFXCaps
+.dwSSBRops
+.dwMaxVideoPorts
+.dwCurrVideoPorts
+.dwSVBCaps2
+.dwNLVBCaps
+.dwNLVBCaps2
+.dwNLVBCKeyCaps
+.dwNLVBFXCaps
+.dwNLVBRops
+.ddsCaps
+
+@record TDDPIXELFORMAT,DDPIXELFORMAT
+.dwSize
+.dwFlags
+.dwFourCC
+.dwRGBBitCount
+.dwYUVBitCount
+.dwZBufferBitDepth
+.dwAlphaBitDepth
+.dwLuminanceBitCount
+.dwBumpBitCount
+.dwPrivateFormatBitCount
+.dwRBitMask
+.dwYBitMask
+.dwStencilBitDepth
+.dwLuminanceBitMask
+.dwBumpDuBitMask
+.dwOperations
+.dwGBitMask
+.dwUBitMask
+.dwZBitMask
+.dwBumpDvBitMask
+.MultiSampleCaps
+.MultiSampleCaps.wFlipMSTypes
+.MultiSampleCaps.wBltMSTypes
+.dwBBitMask
+.dwVBitMask
+.dwStencilBitMask
+.dwBumpLuminanceBitMask
+.dwRGBAlphaBitMask
+.dwYUVAlphaBitMask
+.dwLuminanceAlphaBitMask
+.dwRGBZBitMask
+.dwYUVZBitMask
+
+@record TDDOVERLAYFX,DDOVERLAYFX
+.dwSize
+.dwAlphaEdgeBlendBitDepth
+.dwAlphaEdgeBlend
+.dwReserved
+.dwAlphaDestConstBitDepth
+.dwAlphaDestConst
+.lpDDSAlphaDest
+.dwAlphaSrcConstBitDepth
+.dwAlphaSrcConst
+.lpDDSAlphaSrc
+.dckDestColorkey
+.dckSrcColorkey
+.dwDDFX
+.dwFlags
+
+@record TDDBLTBATCH,DDBLTBATCH
+.lprDest
+.lpDDSSrc
+.lprSrc
+.dwFlags
+.lpDDBltFx
+
+@record TDDGAMMARAMP,DDGAMMARAMP
+.red
+.green
+.blue
+
+@record TDDDEVICEIDENTIFIER,DDDEVICEIDENTIFIER
+.szDriver
+.szDescription
+.liDriverVersion
+.dwVendorId
+.dwDeviceId
+.dwSubSysId
+.dwRevision
+.guidDeviceIdentifier
+
+@record TDDDEVICEIDENTIFIER2,DDDEVICEIDENTIFIER2
+.szDriver
+.szDescription
+.liDriverVersion
+.dwVendorId
+.dwDeviceId
+.dwSubSysId
+.dwRevision
+.guidDeviceIdentifier
+.dwWHQLLevel
+
+@record TDDSURFACEDESC,DDSURFACEDESC
+.dwSize
+.dwFlags
+.dwHeight
+.dwWidth
+.lPitch
+.dwLinearSize
+.dwBackBufferCount
+.dwMipMapCount
+.dwZBufferBitDepth
+.dwRefreshRate
+.dwAlphaBitDepth
+.dwReserved
+.lpSurface
+.ddckCKDestOverlay
+.ddckCKDestBlt
+.ddckCKSrcOverlay
+.ddckCKSrcBlt
+.ddpfPixelFormat
+.ddsCaps
+
+@record TDDSURFACEDESC2,DDSURFACEDESC2
+.dwSize
+.dwFlags
+.dwHeight
+.dwWidth
+.lPitch
+.dwLinearSize
+.dwBackBufferCount
+.dwDepth
+.dwMipMapCount
+.dwRefreshRate
+.dwSrcVBHandle
+.dwAlphaBitDepth
+.dwReserved
+.lpSurface
+.dwEmptyFaceColor
+.ddckCKDestOverlay
+.ddckCKDestBlt
+.ddckCKSrcOverlay
+.ddckCKSrcBlt
+.dwFVF
+.ddpfPixelFormat
+.ddsCaps
+.dwTextureStage
+
+@record TDDOPTSURFACEDESC,DDOPTSURFACEDESC
+.dwSize
+.dwFlags
+.ddSCaps
+.ddOSCaps
+.guid
+.dwCompressionRatio
+
+@record TDDCOLORCONTROL,DDCOLORCONTROL
+.dwSize
+.dwFlags
+.lBrightness
+.lContrast
+.lHue
+.lSaturation
+.lSharpness
+.lGamma
+.lColorEnable
+.dwReserved1
+
+@C   return 0;
+@C }
+
+@Pascal end.

+ 475 - 0
packages/ptc/src/win32/directx/t_dinput.h2paschk

@@ -0,0 +1,475 @@
+@Pascal uses p_dinput;
+@Pascal begin
+
+@C #include <dinput.h>
+@C #include <stdio.h>
+@C #include <stddef.h>
+@C #include <tchar.h>
+@C int _tmain(int argc, _TCHAR* argv[])
+@C {
+
+@record TDICONSTANTFORCE,DICONSTANTFORCE
+.lMagnitude
+
+@record TDIRAMPFORCE,DIRAMPFORCE
+.lStart
+.lEnd
+
+@record TDIPERIODIC,DIPERIODIC
+.dwMagnitude
+.lOffset
+.dwPhase
+.dwPeriod
+
+@record TDICONDITION,DICONDITION
+.lOffset
+.lPositiveCoefficient
+.lNegativeCoefficient
+.dwPositiveSaturation
+.dwNegativeSaturation
+.lDeadBand
+
+@record TDICUSTOMFORCE,DICUSTOMFORCE
+.cChannels
+.dwSamplePeriod
+.cSamples
+.rglForceData
+
+@record TDIENVELOPE,DIENVELOPE
+.dwSize
+.dwAttackLevel
+.dwAttackTime
+.dwFadeLevel
+.dwFadeTime
+
+@record TDIEFFECT_DX5,DIEFFECT_DX5
+.dwSize
+.dwFlags
+.dwDuration
+.dwSamplePeriod
+.dwGain
+.dwTriggerButton
+.dwTriggerRepeatInterval
+.cAxes
+.rgdwAxes
+.rglDirection
+.lpEnvelope
+.cbTypeSpecificParams
+.lpvTypeSpecificParams
+
+@record TDIEFFECT,DIEFFECT
+.dwSize
+.dwFlags
+.dwDuration
+.dwSamplePeriod
+.dwGain
+.dwTriggerButton
+.dwTriggerRepeatInterval
+.cAxes
+.rgdwAxes
+.rglDirection
+.lpEnvelope
+.cbTypeSpecificParams
+.lpvTypeSpecificParams
+.dwStartDelay
+
+@record TDIFILEEFFECT,DIFILEEFFECT
+.dwSize
+.GuidEffect
+.lpDiEffect
+.szFriendlyName
+
+@record TDIEFFESCAPE,DIEFFESCAPE
+.dwSize
+.dwCommand
+.lpvInBuffer
+.cbInBuffer
+.lpvOutBuffer
+.cbOutBuffer
+
+@record TDIDEVCAPS_DX3,DIDEVCAPS_DX3
+.dwSize
+.dwFlags
+.dwDevType
+.dwAxes
+.dwButtons
+.dwPOVs
+
+@record TDIDEVCAPS,DIDEVCAPS
+.dwSize
+.dwFlags
+.dwDevType
+.dwAxes
+.dwButtons
+.dwPOVs
+.dwFFSamplePeriod
+.dwFFMinTimeResolution
+.dwFirmwareRevision
+.dwHardwareRevision
+.dwFFDriverVersion
+
+@record TDIOBJECTDATAFORMAT,DIOBJECTDATAFORMAT
+.pguid
+.dwOfs
+.dwType
+.dwFlags
+
+@record TDIDATAFORMAT,DIDATAFORMAT
+.dwSize
+.dwObjSize
+.dwFlags
+.dwDataSize
+.dwNumObjs
+.rgodf
+
+@record TDIACTIONA,DIACTIONA
+.uAppData
+.dwSemantic
+.dwFlags
+.lptszActionName
+.guidInstance
+.dwObjID
+.dwHow
+.uResIdString
+
+@record TDIACTIONW,DIACTIONW
+.uAppData
+.dwSemantic
+.dwFlags
+.lptszActionName
+.guidInstance
+.dwObjID
+.dwHow
+.uResIdString
+
+@record TDIACTIONFORMATA,DIACTIONFORMATA
+.dwSize
+.dwActionSize
+.dwDataSize
+.dwNumActions
+.rgoAction
+.guidActionMap
+.dwGenre
+.dwBufferSize
+.lAxisMin
+.lAxisMax
+.hInstString
+.ftTimeStamp
+.dwCRC
+.tszActionMap
+
+@record TDIACTIONFORMATW,DIACTIONFORMATW
+.dwSize
+.dwActionSize
+.dwDataSize
+.dwNumActions
+.rgoAction
+.guidActionMap
+.dwGenre
+.dwBufferSize
+.lAxisMin
+.lAxisMax
+.hInstString
+.ftTimeStamp
+.dwCRC
+.tszActionMap
+
+@record TDICOLORSET,DICOLORSET
+.dwSize
+.cTextFore
+.cTextHighlight
+.cCalloutLine
+.cCalloutHighlight
+.cBorder
+.cControlFill
+.cHighlightFill
+.cAreaFill
+
+@record TDICONFIGUREDEVICESPARAMSA,DICONFIGUREDEVICESPARAMSA
+.dwSize
+.dwcUsers
+.lptszUserNames
+.dwcFormats
+.lprgFormats
+.hwnd
+.dics
+.lpUnkDDSTarget
+
+@record TDICONFIGUREDEVICESPARAMSW,DICONFIGUREDEVICESPARAMSW
+.dwSize
+.dwcUsers
+.lptszUserNames
+.dwcFormats
+.lprgFormats
+.hwnd
+.dics
+.lpUnkDDSTarget
+
+@record TDIDEVICEIMAGEINFOA,DIDEVICEIMAGEINFOA
+.tszImagePath
+.dwFlags
+.dwViewID
+.rcOverlay
+.dwObjID
+.dwcValidPts
+.rgptCalloutLine
+.rcCalloutRect
+.dwTextAlign
+
+@record TDIDEVICEIMAGEINFOW,DIDEVICEIMAGEINFOW
+.tszImagePath
+.dwFlags
+.dwViewID
+.rcOverlay
+.dwObjID
+.dwcValidPts
+.rgptCalloutLine
+.rcCalloutRect
+.dwTextAlign
+
+@record TDIDEVICEIMAGEINFOHEADERA,DIDEVICEIMAGEINFOHEADERA
+.dwSize
+.dwSizeImageInfo
+.dwcViews
+.dwcButtons
+.dwcAxes
+.dwcPOVs
+.dwBufferSize
+.dwBufferUsed
+.lprgImageInfoArray
+
+@record TDIDEVICEIMAGEINFOHEADERW,DIDEVICEIMAGEINFOHEADERW
+.dwSize
+.dwSizeImageInfo
+.dwcViews
+.dwcButtons
+.dwcAxes
+.dwcPOVs
+.dwBufferSize
+.dwBufferUsed
+.lprgImageInfoArray
+
+@record TDIDEVICEOBJECTINSTANCE_DX3A,DIDEVICEOBJECTINSTANCE_DX3A
+.dwSize
+.guidType
+.dwOfs
+.dwType
+.dwFlags
+.tszName
+
+@record TDIDEVICEOBJECTINSTANCE_DX3W,DIDEVICEOBJECTINSTANCE_DX3W
+.dwSize
+.guidType
+.dwOfs
+.dwType
+.dwFlags
+.tszName
+
+@record TDIDEVICEOBJECTINSTANCEA,DIDEVICEOBJECTINSTANCEA
+.dwSize
+.guidType
+.dwOfs
+.dwType
+.dwFlags
+.tszName
+.dwFFMaxForce
+.dwFFForceResolution
+.wCollectionNumber
+.wDesignatorIndex
+.wUsagePage
+.wUsage
+.dwDimension
+.wExponent
+.wReportId
+
+@record TDIDEVICEOBJECTINSTANCEW,DIDEVICEOBJECTINSTANCEW
+.dwSize
+.guidType
+.dwOfs
+.dwType
+.dwFlags
+.tszName
+.dwFFMaxForce
+.dwFFForceResolution
+.wCollectionNumber
+.wDesignatorIndex
+.wUsagePage
+.wUsage
+.dwDimension
+.wExponent
+.wReportId
+
+@record TDIPROPHEADER,DIPROPHEADER
+.dwSize
+.dwHeaderSize
+.dwObj
+.dwHow
+
+@record TDIPROPDWORD,DIPROPDWORD
+.diph
+.dwData
+
+@record TDIPROPPOINTER,DIPROPPOINTER
+.diph
+.uData
+
+@record TDIPROPRANGE,DIPROPRANGE
+.diph
+.lMin
+.lMax
+
+@record TDIPROPCAL,DIPROPCAL
+.diph
+.lMin
+.lCenter
+.lMax
+
+@record TDIPROPCALPOV,DIPROPCALPOV
+.diph
+.lMin
+.lMax
+
+@record TDIPROPGUIDANDPATH,DIPROPGUIDANDPATH
+.diph
+.guidClass
+.wszPath
+
+@record TDIPROPSTRING,DIPROPSTRING
+.diph
+.wsz
+
+@record TCPOINT,CPOINT
+.lP
+.dwLog
+
+@record TDIPROPCPOINTS,DIPROPCPOINTS
+.diph
+.dwCPointsNum
+.cp
+
+@record TDIDEVICEOBJECTDATA_DX3,DIDEVICEOBJECTDATA_DX3
+.dwOfs
+.dwData
+.dwTimeStamp
+.dwSequence
+
+@record TDIDEVICEOBJECTDATA,DIDEVICEOBJECTDATA
+.dwOfs
+.dwData
+.dwTimeStamp
+.dwSequence
+.uAppData
+
+@record TDIDEVICEINSTANCE_DX3A,DIDEVICEINSTANCE_DX3A
+.dwSize
+.guidInstance
+.guidProduct
+.dwDevType
+.tszInstanceName
+.tszProductName
+
+@record TDIDEVICEINSTANCE_DX3W,DIDEVICEINSTANCE_DX3W
+.dwSize
+.guidInstance
+.guidProduct
+.dwDevType
+.tszInstanceName
+.tszProductName
+
+@record TDIDEVICEINSTANCEA,DIDEVICEINSTANCEA
+.dwSize
+.guidInstance
+.guidProduct
+.dwDevType
+.tszInstanceName
+.tszProductName
+.guidFFDriver
+.wUsagePage
+.wUsage
+
+@record TDIDEVICEINSTANCEW,DIDEVICEINSTANCEW
+.dwSize
+.guidInstance
+.guidProduct
+.dwDevType
+.tszInstanceName
+.tszProductName
+.guidFFDriver
+.wUsagePage
+.wUsage
+
+@record TDIEFFECTINFOA,DIEFFECTINFOA
+.dwSize
+.guid
+.dwEffType
+.dwStaticParams
+.dwDynamicParams
+.tszName
+
+@record TDIEFFECTINFOW,DIEFFECTINFOW
+.dwSize
+.guid
+.dwEffType
+.dwStaticParams
+.dwDynamicParams
+.tszName
+
+@record TDIMOUSESTATE,DIMOUSESTATE
+.lX
+.lY
+.lZ
+.rgbButtons
+
+@record TDIMOUSESTATE2,DIMOUSESTATE2
+.lX
+.lY
+.lZ
+.rgbButtons
+
+@record TDIJOYSTATE,DIJOYSTATE
+.lX
+.lY
+.lZ
+.lRx
+.lRy
+.lRz
+.rglSlider
+.rgdwPOV
+.rgbButtons
+
+@record TDIJOYSTATE2,DIJOYSTATE2
+.lX
+.lY
+.lZ
+.lRx
+.lRy
+.lRz
+.rglSlider
+.rgdwPOV
+.rgbButtons
+.lVX
+.lVY
+.lVZ
+.lVRx
+.lVRy
+.lVRz
+.rglVSlider
+.lAX
+.lAY
+.lAZ
+.lARx
+.lARy
+.lARz
+.rglASlider
+.lFX
+.lFY
+.lFZ
+.lFRx
+.lFRy
+.lFRz
+.rglFSlider
+
+@C   return 0;
+@C }
+
+@Pascal end.

+ 44 - 105
rtl/avr/avr.inc

@@ -17,6 +17,15 @@
 
 {$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}
   begin
   end;
@@ -84,19 +93,19 @@ function get_frame:pointer;assembler;nostackframe;
 
 
 {$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
   end;
 
 
 {$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
   end;
 
 
 {$define FPC_SYSTEM_HAS_SPTR}
-Function Sptr : pointer;assembler;
+Function Sptr : pointer;assembler;nostackframe;
   asm
   end;
 
@@ -106,20 +115,13 @@ function InterLockedDecrement (var Target: longint) : longint;
     temp_sreg : byte;
   begin
     { 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 }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -128,20 +130,13 @@ function InterLockedIncrement (var Target: longint) : longint;
     temp_sreg : byte;
   begin
     { 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 }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -150,20 +145,13 @@ function InterLockedExchange (var Target: longint;Source : longint) : longint;
     temp_sreg : byte;
   begin
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
     Result:=Target;
     Target:=Source;
 
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -172,21 +160,14 @@ function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comp
     temp_sreg : byte;
   begin
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
     Result:=Target;
-    if Target=Comperand then
+    if Result=Comperand then
       Target:=NewValue;
 
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -195,20 +176,13 @@ function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint
     temp_sreg : byte;
   begin
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
     Result:=Target;
-    inc(Target,Source);
+    Target:=Result+Source;
 
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -217,20 +191,13 @@ function InterLockedDecrement (var Target: smallint) : smallint;
     temp_sreg : byte;
   begin
     { 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 }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -239,20 +206,13 @@ function InterLockedIncrement (var Target: smallint) : smallint;
     temp_sreg : byte;
   begin
     { 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 }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -261,20 +221,13 @@ function InterLockedExchange (var Target: smallint;Source : smallint) : smallint
     temp_sreg : byte;
   begin
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
     Result:=Target;
     Target:=Source;
 
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -283,21 +236,14 @@ function InterlockedCompareExchange(var Target: smallint; NewValue: smallint; Co
     temp_sreg : byte;
   begin
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
     Result:=Target;
-    if Target=Comperand then
+    if Result=Comperand then
       Target:=NewValue;
 
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 
 
@@ -306,19 +252,12 @@ function InterLockedExchangeAdd (var Target: smallint;Source : smallint) : small
     temp_sreg : byte;
   begin
     { block interrupts }
-    asm
-      in r0,0x3f
-      std temp_sreg,r0
-      cli
-    end;
+    temp_sreg:=avr_save();
 
     Result:=Target;
-    inc(Target,Source);
+    Target:=Result+Source;
 
     { release interrupts }
-    asm
-      ldd r0,temp_sreg
-      out 0x3f,r0
-    end;
+    avr_restore(temp_sreg);
   end;
 

+ 2 - 0
rtl/avr/cpuinnr.inc

@@ -17,3 +17,5 @@
   in_avr_wdr = fpc_in_cpu_first+2;
   in_avr_sleep = fpc_in_cpu_first+3;
   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_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
 
 end.

+ 5 - 1
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 GetAspectRatioFilterEx(_para1:HDC; _para2:LPSIZE):WINBOOL; external 'gdi32' name 'GetAspectRatioFilterEx';
 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 GetBitmapBits(_para1:HBITMAP; _para2:LONG; _para3:LPVOID):LONG; external 'gdi32' name 'GetBitmapBits';
 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 SelectPalette(_para1:HDC; _para2:HPALETTE; _para3:WINBOOL):HPALETTE; external 'gdi32' name 'SelectPalette';
 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 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';
@@ -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 GetWorldTransform(_para1:HDC; _para2:LPXFORM):WINBOOL; external 'gdi32' name 'GetWorldTransform';
 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 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';

+ 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 MessageBoxIndirectA(const MsgBoxParams: TMsgBoxParamsA): BOOL; external 'user32' name 'MessageBoxIndirectA';
 //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';
 {$ifndef NO_SMART_LINK}
 function MsgWaitForMultipleObjectsEx(nCount: DWORD; var pHandles; dwMilliseconds, dwWakeMask, dwFlags: DWORD): DWORD;external 'user32' name 'MsgWaitForMultipleObjectsEx';

+ 3 - 3
utils/h2pas/h2paschk.pas

@@ -131,15 +131,15 @@ procedure TH2PasCheckerCodeGen.StartRecord(RecordID: TIdentifier);
 begin
   FCurrentRecord := RecordID;
   Writeln(FLangOutput[lPascal], '  Writeln(''SizeOf(', RecordID[CommLangID], ')='',SizeOf(', RecordID[lPascal], '));');
-  Writeln(FLangOutput[lC], '  printf("SizeOf(', RecordID[CommLangID], ')=%u\n",sizeof(', RecordID[lC], '));');
+  Writeln(FLangOutput[lC], '  printf("SizeOf(', RecordID[CommLangID], ')=%lu\n",sizeof(', RecordID[lC], '));');
 end;
 
 procedure TH2PasCheckerCodeGen.ProcessField(FieldID: TIdentifier);
 begin
   Writeln(FLangOutput[lPascal], '  Writeln(''SizeOf(', FCurrentRecord[CommLangID], '.', FieldID[CommLangID], ')='',SizeOf(', FCurrentRecord[lPascal], '.', FieldID[lPascal], '));');
   Writeln(FLangOutput[lPascal], '  Writeln(''OffsetOf(', FCurrentRecord[CommLangID], ',', FieldID[CommLangID], ')='',PtrUInt(@', FCurrentRecord[lPascal], '(nil^).', FieldID[lPascal], '));');
-  Writeln(FLangOutput[lC], '  printf("SizeOf(', FCurrentRecord[CommLangID], '.', FieldID[CommLangID], ')=%u\n",sizeof(((', FCurrentRecord[lC], '*)0)->', FieldID[lC], '));');
-  Writeln(FLangOutput[lC], '  printf("OffsetOf(', FCurrentRecord[CommLangID], ',', FieldID[CommLangID], ')=%u\n",offsetof(', FCurrentRecord[lC], ',', FieldID[lC], '));');
+  Writeln(FLangOutput[lC], '  printf("SizeOf(', FCurrentRecord[CommLangID], '.', FieldID[CommLangID], ')=%lu\n",sizeof(((', FCurrentRecord[lC], '*)0)->', FieldID[lC], '));');
+  Writeln(FLangOutput[lC], '  printf("OffsetOf(', FCurrentRecord[CommLangID], ',', FieldID[CommLangID], ')=%lu\n",offsetof(', FCurrentRecord[lC], ',', FieldID[lC], '));');
 end;
 
 destructor TH2PasCheckerCodeGen.Destroy;