Explorar o código

* synchronised with trunk till r41907

git-svn-id: branches/debug_eh@41908 -
Jonas Maebe %!s(int64=6) %!d(string=hai) anos
pai
achega
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/base/windows.ico -text
 packages/ptc/src/win32/directx/p_ddraw.pp svneol=native#text/plain
 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/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/win32directxcheck.inc svneol=native#text/plain
 packages/ptc/src/win32/directx/win32directxconsoled.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
 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);
              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;
 
 

+ 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);

+ 28 - 5
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
@@ -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;

+ 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

@@ -169,7 +169,9 @@ interface
             { use PSABI/Dwarf-based "zero cost" exception handling }
             { use PSABI/Dwarf-based "zero cost" exception handling }
             tf_use_psabieh,
             tf_use_psabieh,
             { use high level cfi directives to generate call frame information }
             { 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;
        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,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;
             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';
@@ -1016,7 +1016,7 @@ unit i_bsd;
             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,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_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;
             cpu          : cpu_x86_64;
             unit_env     : 'BSDUNITS';
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
             extradefines : 'UNIX;BSD;HASUNIX';
@@ -1150,7 +1150,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';
@@ -1218,7 +1218,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
@@ -3828,7 +3840,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
@@ -3914,7 +3930,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');

+ 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 () {',

+ 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}
 {$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.

+ 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 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';

+ 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';

+ 3 - 3
utils/h2pas/h2paschk.pas

@@ -131,15 +131,15 @@ procedure TH2PasCheckerCodeGen.StartRecord(RecordID: TIdentifier);
 begin
 begin
   FCurrentRecord := RecordID;
   FCurrentRecord := RecordID;
   Writeln(FLangOutput[lPascal], '  Writeln(''SizeOf(', RecordID[CommLangID], ')='',SizeOf(', RecordID[lPascal], '));');
   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;
 end;
 
 
 procedure TH2PasCheckerCodeGen.ProcessField(FieldID: TIdentifier);
 procedure TH2PasCheckerCodeGen.ProcessField(FieldID: TIdentifier);
 begin
 begin
   Writeln(FLangOutput[lPascal], '  Writeln(''SizeOf(', FCurrentRecord[CommLangID], '.', FieldID[CommLangID], ')='',SizeOf(', FCurrentRecord[lPascal], '.', FieldID[lPascal], '));');
   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[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;
 end;
 
 
 destructor TH2PasCheckerCodeGen.Destroy;
 destructor TH2PasCheckerCodeGen.Destroy;