2
0
Эх сурвалжийг харах

Rebase to Rebase to revision 17273

git-svn-id: branches/svenbarth/collector@17277 -
svenbarth 14 жил өмнө
parent
commit
182a8ef4c4
100 өөрчлөгдсөн 9476 нэмэгдсэн , 1338 устгасан
  1. 53 0
      .gitattributes
  2. 1 1
      compiler/aasmbase.pas
  3. 2 0
      compiler/arm/cgcpu.pas
  4. 3 0
      compiler/cclasses.pas
  5. 21 8
      compiler/cgobj.pas
  6. 3 3
      compiler/comprsrc.pas
  7. 28 8
      compiler/cstreams.pas
  8. 123 0
      compiler/cwindirs.pp
  9. 3 1
      compiler/defcmp.pas
  10. 22 23
      compiler/finput.pas
  11. 2 14
      compiler/fmodule.pas
  12. 10 77
      compiler/globals.pas
  13. 10 28
      compiler/i386/cgcpu.pas
  14. 78 1
      compiler/i386/i386att.inc
  15. 78 1
      compiler/i386/i386atts.inc
  16. 78 1
      compiler/i386/i386int.inc
  17. 1 1
      compiler/i386/i386nop.inc
  18. 78 1
      compiler/i386/i386op.inc
  19. 77 0
      compiler/i386/i386prop.inc
  20. 1270 10
      compiler/i386/i386tab.inc
  21. 4 1
      compiler/link.pas
  22. 1 1
      compiler/msg/errorct.msg
  23. 153 153
      compiler/msg/errord.msg
  24. 1 1
      compiler/msg/errorda.msg
  25. 1 1
      compiler/msg/errordu.msg
  26. 1 1
      compiler/msg/errore.msg
  27. 1 1
      compiler/msg/errores.msg
  28. 1 1
      compiler/msg/errorf.msg
  29. 1 1
      compiler/msg/errorfi.msg
  30. 1 1
      compiler/msg/errorhe.msg
  31. 1 1
      compiler/msg/errorheu.msg
  32. 1 1
      compiler/msg/errorid.msg
  33. 1 1
      compiler/msg/errorn.msg
  34. 1 1
      compiler/msg/errorpl.msg
  35. 1 1
      compiler/msg/errorpli.msg
  36. 1 1
      compiler/msg/errorpt.msg
  37. 1 1
      compiler/msg/errorptu.msg
  38. 1 1
      compiler/msg/errorr.msg
  39. 1 1
      compiler/msg/errorru.msg
  40. 1 1
      compiler/msg/errorues.msg
  41. 1 1
      compiler/msgidx.inc
  42. 71 71
      compiler/msgtxt.inc
  43. 21 1
      compiler/ncal.pas
  44. 10 1
      compiler/ncgcal.pas
  45. 56 141
      compiler/ncgmem.pas
  46. 0 11
      compiler/nset.pas
  47. 7 1
      compiler/ogbase.pas
  48. 1516 0
      compiler/ognlm.pas
  49. 2 2
      compiler/owar.pas
  50. 4 4
      compiler/owbase.pas
  51. 4 2
      compiler/paramgr.pas
  52. 4 3
      compiler/pdecl.pas
  53. 2 1
      compiler/pdecobj.pas
  54. 2 2
      compiler/pdecsub.pas
  55. 6 6
      compiler/pexpr.pas
  56. 40 41
      compiler/ppu.pas
  57. 65 0
      compiler/procinfo.pas
  58. 6 19
      compiler/psub.pas
  59. 55 17
      compiler/ptype.pas
  60. 1 1
      compiler/regvars.pas
  61. 18 9
      compiler/symdef.pas
  62. 1 0
      compiler/symtable.pas
  63. 7 4
      compiler/symtype.pas
  64. 1 0
      compiler/systems.pas
  65. 5 5
      compiler/systems/i_nwm.pas
  66. 432 5
      compiler/systems/t_nwm.pas
  67. 27 521
      compiler/utils/samplecfg
  68. 431 4
      compiler/x86/x86ins.dat
  69. 78 1
      compiler/x86_64/x8664ats.inc
  70. 78 1
      compiler/x86_64/x8664att.inc
  71. 78 1
      compiler/x86_64/x8664int.inc
  72. 1 1
      compiler/x86_64/x8664nop.inc
  73. 78 1
      compiler/x86_64/x8664op.inc
  74. 77 0
      compiler/x86_64/x8664pro.inc
  75. 1291 10
      compiler/x86_64/x8664tab.inc
  76. 45 10
      packages/cdrom/src/cdromlin.inc
  77. 64 0
      packages/cdrom/src/lincd.pp
  78. 2 1
      packages/cocoaint/utils/uikit-skel/src/uikit/UIKit.inc
  79. 11 2
      packages/fcl-base/src/eventlog.pp
  80. 5 1
      packages/fcl-base/src/inifiles.pp
  81. 12 11
      packages/fcl-db/src/base/fields.inc
  82. 41 16
      packages/fcl-db/src/memds/memds.pp
  83. 1 0
      packages/fcl-db/src/sqldb/mysql/mysql50conn.pas
  84. 2 0
      packages/fcl-db/src/sqldb/mysql/mysql51conn.pas
  85. 3 7
      packages/fcl-db/src/sqldb/mysql/mysqlconn.inc
  86. 1 1
      packages/fcl-db/src/sqldb/postgres/pqconnection.pp
  87. 4 6
      packages/fcl-db/tests/sqldbtoolsunit.pas
  88. 10 2
      packages/fcl-db/tests/testfieldtypes.pas
  89. 33 3
      packages/fcl-image/Makefile
  90. 1 0
      packages/fcl-image/Makefile.fpc
  91. 69 0
      packages/fcl-image/src/fpcanvas.inc
  92. 20 1
      packages/fcl-image/src/fpcanvas.pp
  93. 11 0
      packages/fcl-image/src/fpfont.inc
  94. 3 3
      packages/fcl-passrc/src/pastree.pp
  95. 34 14
      packages/fcl-registry/src/regini.inc
  96. 5 2
      packages/fcl-registry/src/registry.pp
  97. 18 16
      packages/fcl-registry/src/xmlreg.pp
  98. 39 4
      packages/fcl-registry/tests/testbasics.pp
  99. 2427 0
      packages/fcl-stl/Makefile
  100. 23 0
      packages/fcl-stl/Makefile.fpc

+ 53 - 0
.gitattributes

@@ -132,6 +132,7 @@ compiler/crefs.pas svneol=native#text/plain
 compiler/cresstr.pas svneol=native#text/plain
 compiler/cstreams.pas svneol=native#text/plain
 compiler/cutils.pas svneol=native#text/plain
+compiler/cwindirs.pp svneol=native#text/plain
 compiler/dbgbase.pas svneol=native#text/plain
 compiler/dbgdwarf.pas svneol=native#text/plain
 compiler/dbgstabs.pas svneol=native#text/plain
@@ -335,6 +336,7 @@ compiler/ogelf.pas svneol=native#text/plain
 compiler/oglx.pas svneol=native#text/plain
 compiler/ogmacho.pas svneol=native#text/plain
 compiler/ogmap.pas svneol=native#text/plain
+compiler/ognlm.pas svneol=native#text/plain
 compiler/optbase.pas svneol=native#text/plain
 compiler/optcse.pas svneol=native#text/plain
 compiler/optdead.pas svneol=native#text/plain
@@ -2293,8 +2295,53 @@ packages/fcl-res/xml/versionconsts.xml svneol=native#text/plain
 packages/fcl-res/xml/versionresource.xml svneol=native#text/plain
 packages/fcl-res/xml/versiontypes.xml svneol=native#text/plain
 packages/fcl-res/xml/winpeimagereader.xml svneol=native#text/plain
+packages/fcl-stl/Makefile svneol=native#text/plain
+packages/fcl-stl/Makefile.fpc svneol=native#text/plain
+packages/fcl-stl/doc/arrayutils.tex svneol=native#text/plain
+packages/fcl-stl/doc/deque.tex svneol=native#text/plain
+packages/fcl-stl/doc/dequeexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/main.tex svneol=native#text/plain
+packages/fcl-stl/doc/makra.tex svneol=native#text/plain
+packages/fcl-stl/doc/map.tex svneol=native#text/plain
+packages/fcl-stl/doc/mapexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/priorityqueue.tex svneol=native#text/plain
+packages/fcl-stl/doc/priorityqueueexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/queue.tex svneol=native#text/plain
+packages/fcl-stl/doc/queueexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/set.tex svneol=native#text/plain
+packages/fcl-stl/doc/setexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/sortingexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/stack.tex svneol=native#text/plain
+packages/fcl-stl/doc/stackexample.pp svneol=native#text/plain
+packages/fcl-stl/doc/util.tex svneol=native#text/plain
+packages/fcl-stl/doc/vector.tex svneol=native#text/plain
+packages/fcl-stl/doc/vectorexample.pp svneol=native#text/plain
+packages/fcl-stl/src/garrayutils.pp svneol=native#text/plain
+packages/fcl-stl/src/gdeque.pp svneol=native#text/plain
+packages/fcl-stl/src/gmap.pp svneol=native#text/plain
+packages/fcl-stl/src/gpriorityqueue.pp svneol=native#text/plain
+packages/fcl-stl/src/gqueue.pp svneol=native#text/plain
+packages/fcl-stl/src/gset.pp svneol=native#text/plain
+packages/fcl-stl/src/gstack.pp svneol=native#text/plain
+packages/fcl-stl/src/gutil.pp svneol=native#text/plain
+packages/fcl-stl/src/gvector.pp svneol=native#text/plain
+packages/fcl-stl/tests/clean svneol=native#text/plain
+packages/fcl-stl/tests/garrayutilstest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gdequetest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gmaptest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gmaptestzal.pp svneol=native#text/plain
+packages/fcl-stl/tests/gpriorityqueuetest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gqueuetest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gsetrefcounttest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gsettest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gstacktest.pp svneol=native#text/plain
+packages/fcl-stl/tests/gvectortest.pp svneol=native#text/plain
+packages/fcl-stl/tests/run-all-tests svneol=native#text/plain
+packages/fcl-stl/tests/suiteconfig.pp svneol=native#text/plain
+packages/fcl-stl/tests/testrunner.pp svneol=native#text/plain
 packages/fcl-web/Makefile svneol=native#text/plain
 packages/fcl-web/Makefile.fpc svneol=native#text/plain
+packages/fcl-web/Makefile.org svneol=native#text/plain
 packages/fcl-web/Makefile_fpmake.fpc svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/README.txt svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/demo.lpi svneol=native#text/plain
@@ -7380,6 +7427,7 @@ rtl/netware/npackon.inc svneol=native#text/plain
 rtl/netware/nwcalls.pp svneol=native#text/plain
 rtl/netware/nwnit.pp svneol=native#text/plain
 rtl/netware/nwpre.as svneol=native#text/plain
+rtl/netware/nwpre.imp svneol=native#text/plain
 rtl/netware/nwpre.pp svneol=native#text/plain
 rtl/netware/nwprot.pp svneol=native#text/plain
 rtl/netware/nwpsrv.imp -text
@@ -7885,6 +7933,7 @@ rtl/win/syswin.inc svneol=native#text/plain
 rtl/win/tthread.inc svneol=native#text/plain
 rtl/win/varutils.pp svneol=native#text/plain
 rtl/win/video.pp svneol=native#text/plain
+rtl/win/windirs.pp svneol=native#text/plain
 rtl/win/winevent.pp svneol=native#text/plain
 rtl/win/wininc/Makefile svneol=native#text/plain
 rtl/win/wininc/ascdef.inc svneol=native#text/plain
@@ -9443,6 +9492,7 @@ tests/test/tabsvr3.pp svneol=native#text/plain
 tests/test/tabsvr4.pp svneol=native#text/plain
 tests/test/tabsvr5.pp svneol=native#text/plain
 tests/test/taddstr1.pp svneol=native#text/plain
+tests/test/taes1.pp svneol=native#text/plain
 tests/test/talign.pp svneol=native#text/plain
 tests/test/talign1.pp svneol=native#text/plain
 tests/test/talign2.pp svneol=native#text/plain
@@ -9456,6 +9506,7 @@ tests/test/tarray5.pp svneol=native#text/plain
 tests/test/tarray6.pp svneol=native#text/plain
 tests/test/tarray7.pp svneol=native#text/plain
 tests/test/tarray8.pp svneol=native#text/plain
+tests/test/tarray9.pp svneol=native#text/plain
 tests/test/tasmread.pp svneol=native#text/plain
 tests/test/tasout.pp svneol=native#text/plain
 tests/test/tassignmentoperator1.pp svneol=native#text/pascal
@@ -9530,6 +9581,8 @@ tests/test/tclass12b.pp svneol=native#text/pascal
 tests/test/tclass12c.pp svneol=native#text/pascal
 tests/test/tclass12d.pp svneol=native#text/plain
 tests/test/tclass13.pp svneol=native#text/pascal
+tests/test/tclass13a.pp svneol=native#text/plain
+tests/test/tclass13b.pp svneol=native#text/plain
 tests/test/tclass14a.pp svneol=native#text/pascal
 tests/test/tclass14b.pp svneol=native#text/pascal
 tests/test/tclass2.pp svneol=native#text/plain

+ 1 - 1
compiler/aasmbase.pas

@@ -40,7 +40,7 @@ interface
        TAsmsymbind=(
          AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL,AB_WEAK_EXTERNAL,
          { global in the current program/library, but not visible outside it }
-         AB_PRIVATE_EXTERN,AB_LAZY);
+         AB_PRIVATE_EXTERN,AB_LAZY,AB_IMPORT);
 
        TAsmsymtype=(
          AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,

+ 2 - 0
compiler/arm/cgcpu.pas

@@ -3479,6 +3479,8 @@ unit cgcpu;
               begin
                 { restore int registers and return }
                 list.concat(taicpu.op_reg_reg(A_MOV, NR_STACK_POINTER_REG, NR_FRAME_POINTER_REG));
+                { Add 4 to SP to make it point to an "imaginary PC" which the paramanager assumes is there(for normal ARM) }
+                list.concat(taicpu.op_reg_const(A_ADD, NR_STACK_POINTER_REG, 4));
 
                 reference_reset(ref,4);
                 ref.index:=NR_STACK_POINTER_REG;

+ 3 - 0
compiler/cclasses.pas

@@ -2208,6 +2208,9 @@ end;
     function TCmdStrListItem.GetCopy:TLinkedListItem;
       begin
         Result:=(inherited GetCopy);
+        { TLinkedListItem.GetCopy performs a "move" to copy all data -> reinit
+          the ansistring, so the refcount is properly increased }
+        Initialize(TCmdStrListItem(Result).FPStr);
         TCmdStrListItem(Result).FPStr:=FPstr;
       end;
 

+ 21 - 8
compiler/cgobj.pas

@@ -3504,6 +3504,8 @@ implementation
           end
          else
           begin
+            if is_open_array(t) then
+              InternalError(201103054);
             reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
             a_loadaddr_ref_cgpara(list,href,cgpara2);
             a_loadaddr_ref_cgpara(list,ref,cgpara1);
@@ -3569,6 +3571,8 @@ implementation
           end
          else
           begin
+            if is_open_array(t) then
+              InternalError(201103053);
             reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
             a_loadaddr_ref_cgpara(list,href,cgpara2);
             a_loadaddr_ref_cgpara(list,ref,cgpara1);
@@ -3596,18 +3600,23 @@ implementation
         paramanager.getintparaloc(pocall_default,3,cgpara3);
 
         reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
-        if highloc.loc in [LOC_REGISTER,LOC_CREGISTER] then
-          hreg:=highloc.register
+        if highloc.loc=LOC_CONSTANT then
+          a_load_const_cgpara(list,OS_INT,highloc.value+1,cgpara3)
         else
           begin
-            hreg:=getintregister(list,OS_INT);
-            a_load_loc_reg(list,OS_INT,highloc,hreg);
+            if highloc.loc in [LOC_REGISTER,LOC_CREGISTER] then
+              hreg:=highloc.register
+            else
+              begin
+                hreg:=getintregister(list,OS_INT);
+                a_load_loc_reg(list,OS_INT,highloc,hreg);
+              end;
+            { increment, converts high(x) to length(x) }
+            lenreg:=getintregister(list,OS_INT);
+            a_op_const_reg_reg(list,OP_ADD,OS_INT,1,hreg,lenreg);
+            a_load_reg_cgpara(list,OS_INT,lenreg,cgpara3);
           end;
-        { increment, converts high(x) to length(x) }
-        lenreg:=getintregister(list,OS_INT);
-        a_op_const_reg_reg(list,OP_ADD,OS_INT,1,hreg,lenreg);
 
-        a_load_reg_cgpara(list,OS_INT,lenreg,cgpara3);
         a_loadaddr_ref_cgpara(list,href,cgpara2);
         a_loadaddr_ref_cgpara(list,ref,cgpara1);
         paramanager.freecgpara(list,cgpara1);
@@ -3639,6 +3648,8 @@ implementation
            a_load_const_ref(list,OS_ADDR,0,ref)
          else
            begin
+              if is_open_array(t) then
+                InternalError(201103052);
               reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
               a_loadaddr_ref_cgpara(list,href,cgpara2);
               a_loadaddr_ref_cgpara(list,ref,cgpara1);
@@ -3672,6 +3683,8 @@ implementation
             end
          else
            begin
+              if is_open_array(t) then
+                InternalError(201103051);
               reference_reset_symbol(href,RTTIWriter.get_rtti_label(t,initrtti),0,sizeof(pint));
               a_loadaddr_ref_cgpara(list,href,cgpara2);
               a_loadaddr_ref_cgpara(list,ref,cgpara1);

+ 3 - 3
compiler/comprsrc.pas

@@ -377,18 +377,18 @@ end;
 
 function CopyResFile(inf,outf : TCmdStr) : boolean;
 var
-  src,dst : TCFileStream;
+  src,dst : TCCustomFileStream;
 begin
   { Copy .res file to units output dir. }
   Result:=false;
-  src:=TCFileStream.Create(inf,fmOpenRead or fmShareDenyNone);
+  src:=CFileStreamClass.Create(inf,fmOpenRead or fmShareDenyNone);
   if CStreamError<>0 then
     begin
       Message1(exec_e_cant_open_resource_file, src.FileName);
       Include(current_settings.globalswitches, cs_link_nolink);
       exit;
     end;
-  dst:=TCFileStream.Create(current_module.outputpath^+outf,fmCreate);
+  dst:=CFileStreamClass.Create(current_module.outputpath^+outf,fmCreate);
   if CStreamError<>0 then
     begin
       Message1(exec_e_cant_write_resource_file, dst.FileName);

+ 28 - 8
compiler/cstreams.pas

@@ -100,23 +100,38 @@ type
     property Size: Longint read GetSize write SetSize;
   end;
 
+{ TCCustomFileStream class }
+
+  TCCustomFileStream = class(TCStream)
+  protected
+    FFileName : String;
+  public
+    constructor Create(const AFileName: string;{shortstring!} Mode: Word); virtual; abstract;
+    function EOF: boolean; virtual; abstract;
+    property FileName : String Read FFilename;
+  end;
+
 { TFileStream class }
 
-  TCFileStream = class(TCStream)
+  TCFileStream = class(TCCustomFileStream)
   Private
-    FFileName : String;
     FHandle: File;
   protected
     procedure SetSize(NewSize: Longint); override;
   public
-    constructor Create(const AFileName: string; Mode: Word);
+    constructor Create(const AFileName: string; Mode: Word); override;
     destructor Destroy; override;
     function Read(var Buffer; Count: Longint): Longint; override;
     function Write(const Buffer; Count: Longint): Longint; override;
     function Seek(Offset: Longint; Origin: Word): Longint; override;
-    property FileName : String Read FFilename;
+    function EOF: boolean; override;
   end;
 
+  TCFileStreamClass = class of TCCustomFileStream;
+var
+  CFileStreamClass: TCFileStreamClass = TCFileStream;
+
+type
 { TCustomMemoryStream abstract class }
 
   TCCustomMemoryStream = class(TCStream)
@@ -441,6 +456,11 @@ begin
   Result:=l;
 end;
 
+function TCFileStream.EOF: boolean;
+begin
+  EOF:=system.eof(FHandle);
+end;
+
 
 {****************************************************************************}
 {*                             TCustomMemoryStream                          *}
@@ -489,11 +509,11 @@ end;
 
 procedure TCCustomMemoryStream.SaveToFile(const FileName: string);
 
-Var S : TCFileStream;
+Var S : TCCustomFileStream;
 
 begin
   Try
-    S:=TCFileStream.Create (FileName,fmCreate);
+    S:=CFileStreamClass.Create (FileName,fmCreate);
     SaveToStream(S);
   finally
     S.free;
@@ -574,11 +594,11 @@ end;
 
 procedure TCMemoryStream.LoadFromFile(const FileName: string);
 
-Var S : TCFileStream;
+Var S : TCCustomFileStream;
 
 begin
   Try
-    S:=TCFileStream.Create (FileName,fmOpenRead);
+    S:=CFileStreamClass.Create (FileName,fmOpenRead);
     LoadFromStream(S);
   finally
     S.free;

+ 123 - 0
compiler/cwindirs.pp

@@ -0,0 +1,123 @@
+{ this unit is temporarily included in the compiler sources till stable releases with
+  windirs from the rtl are shipped
+}
+unit cwindirs;
+
+{$mode objfpc}
+{$H+}
+
+interface
+
+uses
+  windows,
+  strings;
+
+Const
+  CSIDL_PROGRAMS                = $0002; { %SYSTEMDRIVE%\Program Files                                      }
+  CSIDL_PERSONAL                = $0005; { %USERPROFILE%\My Documents                                       }
+  CSIDL_FAVORITES               = $0006; { %USERPROFILE%\Favorites                                          }
+  CSIDL_STARTUP                 = $0007; { %USERPROFILE%\Start menu\Programs\Startup                        }
+  CSIDL_RECENT                  = $0008; { %USERPROFILE%\Recent                                             }
+  CSIDL_SENDTO                  = $0009; { %USERPROFILE%\Sendto                                             }
+  CSIDL_STARTMENU               = $000B; { %USERPROFILE%\Start menu                                         }
+  CSIDL_MYMUSIC                 = $000D; { %USERPROFILE%\Documents\My Music                                 }
+  CSIDL_MYVIDEO                 = $000E; { %USERPROFILE%\Documents\My Videos                                }
+  CSIDL_DESKTOPDIRECTORY        = $0010; { %USERPROFILE%\Desktop                                            }
+  CSIDL_NETHOOD                 = $0013; { %USERPROFILE%\NetHood                                            }
+  CSIDL_TEMPLATES               = $0015; { %USERPROFILE%\Templates                                          }
+  CSIDL_COMMON_STARTMENU        = $0016; { %PROFILEPATH%\All users\Start menu                               }
+  CSIDL_COMMON_PROGRAMS         = $0017; { %PROFILEPATH%\All users\Start menu\Programs                      }
+  CSIDL_COMMON_STARTUP          = $0018; { %PROFILEPATH%\All users\Start menu\Programs\Startup              }
+  CSIDL_COMMON_DESKTOPDIRECTORY = $0019; { %PROFILEPATH%\All users\Desktop                                  }
+  CSIDL_APPDATA                 = $001A; { %USERPROFILE%\Application Data (roaming)                         }
+  CSIDL_PRINTHOOD               = $001B; { %USERPROFILE%\Printhood                                          }
+  CSIDL_LOCAL_APPDATA           = $001C; { %USERPROFILE%\Local Settings\Application Data (non roaming)      }
+  CSIDL_COMMON_FAVORITES        = $001F; { %PROFILEPATH%\All users\Favorites                                }
+  CSIDL_INTERNET_CACHE          = $0020; { %USERPROFILE%\Local Settings\Temporary Internet Files            }
+  CSIDL_COOKIES                 = $0021; { %USERPROFILE%\Cookies                                            }
+  CSIDL_HISTORY                 = $0022; { %USERPROFILE%\Local settings\History                             }
+  CSIDL_COMMON_APPDATA          = $0023; { %PROFILESPATH%\All Users\Application Data                        }
+  CSIDL_WINDOWS                 = $0024; { %SYSTEMROOT%                                                     }
+  CSIDL_SYSTEM                  = $0025; { %SYSTEMROOT%\SYSTEM32 (may be system on 95/98/ME)                }
+  CSIDL_PROGRAM_FILES           = $0026; { %SYSTEMDRIVE%\Program Files                                      }
+  CSIDL_MYPICTURES              = $0027; { %USERPROFILE%\My Documents\My Pictures                           }
+  CSIDL_PROFILE                 = $0028; { %USERPROFILE%                                                    }
+  CSIDL_PROGRAM_FILES_COMMON    = $002B; { %SYSTEMDRIVE%\Program Files\Common                               }
+  CSIDL_COMMON_TEMPLATES        = $002D; { %PROFILEPATH%\All Users\Templates                                }
+  CSIDL_COMMON_DOCUMENTS        = $002E; { %PROFILEPATH%\All Users\Documents                                }
+  CSIDL_COMMON_ADMINTOOLS       = $002F; { %PROFILEPATH%\All Users\Start Menu\Programs\Administrative Tools }
+  CSIDL_ADMINTOOLS              = $0030; { %USERPROFILE%\Start Menu\Programs\Administrative Tools           }
+  CSIDL_COMMON_MUSIC            = $0035; { %PROFILEPATH%\All Users\Documents\my music                       }
+  CSIDL_COMMON_PICTURES         = $0036; { %PROFILEPATH%\All Users\Documents\my pictures                    }
+  CSIDL_COMMON_VIDEO            = $0037; { %PROFILEPATH%\All Users\Documents\my videos                      }
+  CSIDL_CDBURN_AREA             = $003B; { %USERPROFILE%\Local Settings\Application Data\Microsoft\CD Burning }
+  CSIDL_PROFILES                = $003E; { %PROFILEPATH%                                                    }
+
+  CSIDL_FLAG_CREATE             = $8000; { (force creation of requested folder if it doesn't exist yet)     }
+
+Function GetWindowsSpecialDir(ID :  Integer) : String;
+
+implementation
+
+uses
+  sysutils;
+
+Type
+  PFNSHGetFolderPath = Function(Ahwnd: HWND; Csidl: Integer; Token: THandle; Flags: DWord; Path: PChar): HRESULT; stdcall;
+
+
+var
+  SHGetFolderPath : PFNSHGetFolderPath = Nil;
+  CFGDLLHandle : THandle = 0;
+
+Procedure InitDLL;
+
+Var
+  pathBuf: array[0..MAX_PATH-1] of char;
+  pathLength: Integer;
+begin
+  { Load shfolder.dll using a full path, in order to prevent spoofing (Mantis #18185)
+    Don't bother loading shell32.dll because shfolder.dll itself redirects SHGetFolderPath
+    to shell32.dll whenever possible. }
+  pathLength:=GetSystemDirectory(pathBuf, MAX_PATH);
+  if (pathLength>0) and (pathLength<MAX_PATH-14) then { 14=length('\shfolder.dll'#0) }
+  begin
+    StrLCopy(@pathBuf[pathLength],'\shfolder.dll',MAX_PATH-pathLength-1);
+    CFGDLLHandle:=LoadLibrary(pathBuf);
+
+    if (CFGDLLHandle<>0) then
+    begin
+      Pointer(ShGetFolderPath):=GetProcAddress(CFGDLLHandle,'SHGetFolderPathA');
+      If @ShGetFolderPath=nil then
+      begin
+        FreeLibrary(CFGDLLHandle);
+        CFGDllHandle:=0;
+      end;
+    end;
+  end;
+  If (@ShGetFolderPath=Nil) then
+    Raise Exception.Create('Could not determine SHGetFolderPath Function');
+end;
+
+Function GetWindowsSpecialDir(ID :  Integer) : String;
+
+Var
+  APath : Array[0..MAX_PATH] of char;
+
+begin
+  Result:='';
+  if (CFGDLLHandle=0) then
+    InitDLL;
+  If (SHGetFolderPath<>Nil) then
+    begin
+    if SHGetFolderPath(0,ID or CSIDL_FLAG_CREATE,0,0,@APATH[0])=S_OK then
+      Result:=IncludeTrailingPathDelimiter(StrPas(@APath[0]));
+    end;
+end;
+
+Initialization
+Finalization
+  if CFGDLLHandle<>0 then
+   FreeLibrary(CFGDllHandle);
+end.
+

+ 3 - 1
compiler/defcmp.pas

@@ -1260,7 +1260,9 @@ implementation
                    find_real_objcclass_definition(tobjectdef(def_to),false)) then
                  begin
                    doconv:=tc_equal;
-                   eq:=te_equal;
+                   { exact, not equal, because can change between interface
+                     and implementation }
+                   eq:=te_exact;
                  end
                { object pascal objects }
                else if (def_from.typ=objectdef) and

+ 22 - 23
compiler/finput.pas

@@ -26,7 +26,7 @@ unit finput;
 interface
 
     uses
-      cutils,cclasses;
+      cutils,cclasses,cstreams;
 
     const
        InputFileBufSize=32*1024+1;
@@ -91,7 +91,7 @@ interface
          function fileclose: boolean; override;
          procedure filegettime; override;
        private
-         f            : file;       { current file handle }
+         f            : TCCustomFileStream;       { current file handle }
        end;
 
        tinputfilemanager = class
@@ -457,47 +457,46 @@ uses
             exit;
           end;
         { Open file }
-        ofm:=filemode;
-        filemode:=0;
-        Assign(f,filename);
-        {$I-}
-         reset(f,1);
-        {$I+}
-        filemode:=ofm;
-        fileopen:=(ioresult=0);
+        fileopen:=false;
+        try
+          f:=CFileStreamClass.Create(filename,fmOpenRead);
+          fileopen:=true;
+        except
+        end;
       end;
 
 
     function tdosinputfile.fileseek(pos: longint): boolean;
       begin
-        {$I-}
-         seek(f,Pos);
-        {$I+}
-        fileseek:=(ioresult=0);
+        fileseek:=false;
+        try
+          f.position:=Pos;
+          fileseek:=true;
+        except
+        end;
       end;
 
 
     function tdosinputfile.fileread(var databuf; maxsize: longint): longint;
-      var
-        w : longint;
       begin
-        blockread(f,databuf,maxsize,w);
-        fileread:=w;
+        fileread:=f.Read(databuf,maxsize);
       end;
 
 
     function tdosinputfile.fileeof: boolean;
       begin
-        fileeof:=eof(f);
+        fileeof:=f.eof();
       end;
 
 
     function tdosinputfile.fileclose: boolean;
       begin
-        {$I-}
-         system.close(f);
-        {$I+}
-        fileclose:=(ioresult=0);
+        fileclose:=false;
+        try
+          f.Free;
+          fileclose:=true;
+        except
+        end;
       end;
 
 

+ 2 - 14
compiler/fmodule.pas

@@ -544,7 +544,6 @@ implementation
     destructor tmodule.Destroy;
       var
         i : longint;
-        hpi : tprocinfo;
       begin
         if assigned(unitmap) then
           freemem(unitmap);
@@ -582,12 +581,7 @@ implementation
                 current_specializedef:=nil;
               end;
             { release procinfo tree }
-            while assigned(procinfo) do
-             begin
-               hpi:=tprocinfo(procinfo).parent;
-               tprocinfo(procinfo).free;
-               procinfo:=hpi;
-             end;
+            tprocinfo(procinfo).destroy_tree;
           end;
         DoneDebugInfo(self);
         used_units.free;
@@ -642,7 +636,6 @@ implementation
 
     procedure tmodule.reset;
       var
-        hpi : tprocinfo;
         i   : longint;
       begin
         if assigned(scanner) then
@@ -664,12 +657,7 @@ implementation
                 current_specializedef:=nil;
               end;
             { release procinfo tree }
-            while assigned(procinfo) do
-             begin
-               hpi:=tprocinfo(procinfo).parent;
-               tprocinfo(procinfo).free;
-               procinfo:=hpi;
-             end;
+            tprocinfo(procinfo).destroy_tree;
           end;
         if assigned(asmdata) then
           begin

+ 10 - 77
compiler/globals.pas

@@ -476,6 +476,13 @@ implementation
     uses
 {$ifdef macos}
       macutils,
+{$endif}
+{$ifdef mswindows}
+{$ifdef VER2_4}
+      cwindirs,
+{$else VER2_4}
+      windirs,
+{$endif VER2_4}
 {$endif}
       comphook;
 
@@ -718,86 +725,18 @@ implementation
                           Default Macro Handling
 ****************************************************************************}
 
-{$ifdef mswindows}
-{
-  This code is copied from sysutils.pp
-}
-     Type
-       PFNSHGetFolderPath = Function(Ahwnd: HWND; Csidl: Integer; Token: THandle; Flags: DWord; Path: PChar): HRESULT; stdcall;
-
-     var
-       SHGetFolderPath : PFNSHGetFolderPath = Nil;
-       CFGDLLHandle : THandle = 0;
-
-     const
-       CSIDL_PERSONAL                = $0005; { %USERPROFILE%\My Documents                                       }
-       CSIDL_APPDATA                 = $001A; { %USERPROFILE%\Application Data (roaming)                         }
-       CSIDL_LOCAL_APPDATA           = $001C; { %USERPROFILE%\Local Settings\Application Data (non roaming)      }
-       CSIDL_COMMON_APPDATA          = $0023; { %PROFILESPATH%\All Users\Application Data                        }
-       CSIDL_PROGRAM_FILES           = $0026; { %SYSTEMDRIVE%\Program Files                                      }
-       CSIDL_PROFILE                 = $0028; { %USERPROFILE%                                                    }
-       CSIDL_PROGRAM_FILES_COMMON    = $002B; { %SYSTEMDRIVE%\Program Files\Common                               }
-
-       CSIDL_FLAG_CREATE             = $8000; { (force creation of requested folder if it doesn't exist yet)     }
-
-
-     Procedure InitDLL;
-       Var
-         pathBuf: array[0..MAX_PATH-1] of char;
-         pathLength: Integer;
-       begin
-         { Load shfolder.dll using a full path, in order to prevent spoofing (Mantis #18185)
-           Don't bother loading shell32.dll because shfolder.dll itself redirects SHGetFolderPath
-           to shell32.dll whenever possible. }
-         pathLength:=GetSystemDirectory(pathBuf, MAX_PATH);
-         if (pathLength>0) and (pathLength<MAX_PATH-14) then { 14=length('\shfolder.dll'#0) }
-           begin
-             StrLCopy(@pathBuf[pathLength],'\shfolder.dll',MAX_PATH-pathLength-1);
-             CFGDLLHandle:=LoadLibrary(pathBuf);
-             if (CFGDLLHandle<>0) then
-               begin
-                 Pointer(ShGetFolderPath):=GetProcAddress(CFGDLLHandle,'SHGetFolderPathA');
-                 If @ShGetFolderPath=nil then
-                   begin
-                     FreeLibrary(CFGDLLHandle);
-                     CFGDllHandle:=0;
-                   end;
-               end;
-           end;
-         If (@ShGetFolderPath=Nil) then
-           Raise Exception.Create('Could not determine SHGetFolderPath Function');
-       end;
-
-
-     Function GetSpecialDir(ID :  Integer) : String;
-
-       Var
-         APath : Array[0..MAX_PATH] of char;
-
-       begin
-         Result:='';
-         if (CFGDLLHandle=0) then
-           InitDLL;
-         If (SHGetFolderPath<>Nil) then
-           begin
-             if SHGetFolderPath(0,ID or CSIDL_FLAG_CREATE,0,0,@APATH[0])=S_OK then
-               Result:=IncludeTrailingPathDelimiter(StrPas(@APath[0]));
-           end;
-       end;
-{$endif mswindows}
-
 
      procedure DefaultReplacements(var s:ansistring);
-       {$ifdef mswindows}
+{$ifdef mswindows}
        procedure ReplaceSpecialFolder(const MacroName: string; const ID: integer);
          begin
            // Only try to receive the special folders (and thus dynamically
            // load shfolder.dll) when that's needed.
            if pos(MacroName,s)>0 then
-             Replace(s,MacroName,GetSpecialDir(ID));
+             Replace(s,MacroName,GetWindowsSpecialDir(ID));
          end;
 
-       {$endif mswindows}
+{$endif mswindows}
        var
          envstr: string;
          envvalue: pchar;
@@ -1581,10 +1520,4 @@ implementation
         features:=[low(Tfeature)..high(Tfeature)];
      end;
 
-{$ifdef mswindows}
-initialization
-finalization
-  if CFGDLLHandle<>0 then
-    FreeLibrary(CFGDllHandle);
-{$endif mswindows}
 end.

+ 10 - 28
compiler/i386/cgcpu.pas

@@ -371,6 +371,9 @@ unit cgcpu;
         getcpuregister(list,NR_EDI);
         a_load_loc_reg(list,OS_INT,lenloc,NR_EDI);
         list.concat(Taicpu.op_reg(A_INC,S_L,NR_EDI));
+        { Now EDI contains (high+1). Copy it to ECX for later use. }
+        getcpuregister(list,NR_ECX);
+        list.concat(Taicpu.op_reg_reg(A_MOV,S_L,NR_EDI,NR_ECX));
         if (elesize<>1) then
          begin
            if ispowerof2(elesize, power) then
@@ -394,43 +397,22 @@ unit cgcpu;
              a_jmp_always(list,again);
 
              a_label(list,ok);
-             list.concat(Taicpu.op_reg_reg(A_SUB,S_L,NR_EDI,NR_ESP));
-             ungetcpuregister(list,NR_EDI);
-             { now reload EDI }
-             getcpuregister(list,NR_EDI);
-             a_load_loc_reg(list,OS_INT,lenloc,NR_EDI);
-             list.concat(Taicpu.op_reg(A_INC,S_L,NR_EDI));
-
-             if (elesize<>1) then
-              begin
-                if ispowerof2(elesize, power) then
-                  list.concat(Taicpu.op_const_reg(A_SHL,S_L,power,NR_EDI))
-                else
-                  list.concat(Taicpu.op_const_reg(A_IMUL,S_L,elesize,NR_EDI));
-              end;
-          end
-        else
+          end;
 {$endif __NOWINPECOFF__}
-          list.concat(Taicpu.op_reg_reg(A_SUB,S_L,NR_EDI,NR_ESP));
+        { If we were probing pages, EDI=(size mod pagesize) and ESP is decremented
+          by (size div pagesize)*pagesize, otherwise EDI=size.
+          Either way, subtracting EDI from ESP will set ESP to desired final value. }
+        list.concat(Taicpu.op_reg_reg(A_SUB,S_L,NR_EDI,NR_ESP));
         { align stack on 4 bytes }
         list.concat(Taicpu.op_const_reg(A_AND,S_L,aint($fffffff4),NR_ESP));
         { load destination, don't use a_load_reg_reg, that will add a move instruction
           that can confuse the reg allocator }
         list.concat(Taicpu.Op_reg_reg(A_MOV,S_L,NR_ESP,NR_EDI));
 
-        { Allocate other registers }
-        getcpuregister(list,NR_ECX);
+        { Allocate ESI and load it with source }
         getcpuregister(list,NR_ESI);
-
-        { load count }
-        a_load_loc_reg(list,OS_INT,lenloc,NR_ECX);
-
-        { load source }
         a_loadaddr_ref_reg(list,ref,NR_ESI);
 
-        { scheduled .... }
-        list.concat(Taicpu.op_reg(A_INC,S_L,NR_ECX));
-
         { calculate size }
         len:=elesize;
         opsize:=S_B;
@@ -446,7 +428,7 @@ unit cgcpu;
             len:=len shr 1;
           end;
 
-        if len<>0 then
+        if len>1 then
           begin
             if ispowerof2(len, power) then
               list.concat(Taicpu.op_const_reg(A_SHL,S_L,power,NR_ECX))

+ 78 - 1
compiler/i386/i386att.inc

@@ -602,5 +602,82 @@
 'insertq',
 'extrq',
 'lzcnt',
-'popcnt'
+'pabsb',
+'pabsw',
+'pabsd',
+'palignr',
+'phaddw',
+'phaddd',
+'phaddsw',
+'phsubw',
+'phsubd',
+'phsubsw',
+'pmaddubsw',
+'pmulhrsw',
+'pshufb',
+'psignb',
+'psignw',
+'psignd',
+'blendps',
+'blendpd',
+'blendvps',
+'blendvpd',
+'dpps',
+'dppd',
+'extractps',
+'insertps',
+'movntdqa',
+'mpsadbw',
+'packusdw',
+'pblendvb',
+'pblendw',
+'pcmpeqq',
+'pextrb',
+'pextrd',
+'pextrq',
+'phminposuw',
+'pinsrb',
+'pinsrd',
+'pinsrq',
+'pmaxsb',
+'pmaxsd',
+'pmaxud',
+'pmaxuw',
+'pminsb',
+'pminsd',
+'pminuw',
+'pminud',
+'pmovsxbw',
+'pmovsxbd',
+'pmovsxbq',
+'pmovsxwd',
+'pmovsxwq',
+'pmovsxdq',
+'pmovzxbw',
+'pmovzxbd',
+'pmovzxbq',
+'pmovzxwd',
+'pmovzxwq',
+'pmovzxdq',
+'pmuldq',
+'ptest',
+'roundps',
+'roundpd',
+'roundss',
+'roundsd',
+'pcmpestri',
+'pcmpestrm',
+'pcmpistri',
+'pcmpistrm',
+'pcmpgtq',
+'popcnt',
+'aesenc',
+'aesenclast',
+'aesdec',
+'aesdeclast',
+'aesimc',
+'aeskeygen',
+'stosq',
+'lodsq',
+'cmpsq'
 );

+ 78 - 1
compiler/i386/i386atts.inc

@@ -602,5 +602,82 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufINT,
-attsufINT
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufINT,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE
 );

+ 78 - 1
compiler/i386/i386int.inc

@@ -602,5 +602,82 @@
 'insertq',
 'extrq',
 'lzcnt',
-'popcnt'
+'pabsb',
+'pabsw',
+'pabsd',
+'palignr',
+'phaddw',
+'phaddd',
+'phaddsw',
+'phsubw',
+'phsubd',
+'phsubsw',
+'pmaddubsw',
+'pmulhrsw',
+'pshufb',
+'psignb',
+'psignw',
+'psignd',
+'blendps',
+'blendpd',
+'blendvps',
+'blendvpd',
+'dpps',
+'dppd',
+'extractps',
+'insertps',
+'movntdqa',
+'mpsadbw',
+'packusdw',
+'pblendvb',
+'pblendw',
+'pcmpeqq',
+'pextrb',
+'pextrd',
+'pextrq',
+'phminposuw',
+'pinsrb',
+'pinsrd',
+'pinsrq',
+'pmaxsb',
+'pmaxsd',
+'pmaxud',
+'pmaxuw',
+'pminsb',
+'pminsd',
+'pminuw',
+'pminud',
+'pmovsxbw',
+'pmovsxbd',
+'pmovsxbq',
+'pmovsxwd',
+'pmovsxwq',
+'pmovsxdq',
+'pmovzxbw',
+'pmovzxbd',
+'pmovzxbq',
+'pmovzxwd',
+'pmovzxwq',
+'pmovzxdq',
+'pmuldq',
+'ptest',
+'roundps',
+'roundpd',
+'roundss',
+'roundsd',
+'pcmpestri',
+'pcmpestrm',
+'pcmpistri',
+'pcmpistrm',
+'pcmpgtq',
+'popcnt',
+'aesenc',
+'aesenclast',
+'aesdec',
+'aesdeclast',
+'aesimc',
+'aeskeygen',
+'stosq',
+'lodsq',
+'cmpsq'
 );

+ 1 - 1
compiler/i386/i386nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
-1380;
+1560;

+ 78 - 1
compiler/i386/i386op.inc

@@ -602,5 +602,82 @@ A_MOVNTSD,
 A_INSERTQ,
 A_EXTRQ,
 A_LZCNT,
-A_POPCNT
+A_PABSB,
+A_PABSW,
+A_PABSD,
+A_PALIGNR,
+A_PHADDW,
+A_PHADDD,
+A_PHADDSW,
+A_PHSUBW,
+A_PHSUBD,
+A_PHSUBSW,
+A_PMADDUBSW,
+A_PMULHRSW,
+A_PSHUFB,
+A_PSIGNB,
+A_PSIGNW,
+A_PSIGND,
+A_BLENDPS,
+A_BLENDPD,
+A_BLENDVPS,
+A_BLENDVPD,
+A_DPPS,
+A_DPPD,
+A_EXTRACTPS,
+A_INSERTPS,
+A_MOVNTDQA,
+A_MPSADBW,
+A_PACKUSDW,
+A_PBLENDVB,
+A_PBLENDW,
+A_PCMPEQQ,
+A_PEXTRB,
+A_PEXTRD,
+A_PEXTRQ,
+A_PHMINPOSUW,
+A_PINSRB,
+A_PINSRD,
+A_PINSRQ,
+A_PMAXSB,
+A_PMAXSD,
+A_PMAXUD,
+A_PMAXUW,
+A_PMINSB,
+A_PMINSD,
+A_PMINUW,
+A_PMINUD,
+A_PMOVSXBW,
+A_PMOVSXBD,
+A_PMOVSXBQ,
+A_PMOVSXWD,
+A_PMOVSXWQ,
+A_PMOVSXDQ,
+A_PMOVZXBW,
+A_PMOVZXBD,
+A_PMOVZXBQ,
+A_PMOVZXWD,
+A_PMOVZXWQ,
+A_PMOVZXDQ,
+A_PMULDQ,
+A_PTEST,
+A_ROUNDPS,
+A_ROUNDPD,
+A_ROUNDSS,
+A_ROUNDSD,
+A_PCMPESTRI,
+A_PCMPESTRM,
+A_PCMPISTRI,
+A_PCMPISTRM,
+A_PCMPGTQ,
+A_POPCNT,
+A_AESENC,
+A_AESENCLAST,
+A_AESDEC,
+A_AESDECLAST,
+A_AESIMC,
+A_AESKEYGEN,
+A_STOSQ,
+A_LODSQ,
+A_CMPSQ
 );

+ 77 - 0
compiler/i386/i386prop.inc

@@ -602,5 +602,82 @@
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_RRAX, Ch_WMemEDI, Ch_RWRDI)),
+(Ch: (Ch_WRAX, Ch_RWRSI, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None))
 );

+ 1270 - 10
compiler/i386/i386tab.inc

@@ -7796,7 +7796,14 @@
     ops     : 3;
     optypes : (ot_reg32,ot_xmmreg,ot_immediate);
     code    : #1#102#211#2#15#197#72#22;
-    flags   : if_willamette or if_sse2 or if_sb or if_ar2
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRW;
+    ops     : 3;
+    optypes : (ot_memory or ot_bits32,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#211#3#15#58#21#65#22;
+    flags   : if_sse4
   ),
   (
     opcode  : A_PINSRW;
@@ -9608,7 +9615,7 @@
     opcode  : A_MOVNTSD;
     ops     : 2;
     optypes : (ot_memory,ot_xmmreg,ot_none);
-    code    : #192#220#213#211#2#15#43#0#65;
+    code    : #192#220#213#211#2#15#43#65;
     flags   : if_sse4
   ),
   (
@@ -9647,17 +9654,1270 @@
     flags   : if_386 or if_sm or if_sse4
   ),
   (
-    opcode  : A_POPCNT;
+    opcode  : A_PABSB;
     ops     : 2;
-    optypes : (ot_reg16,ot_regmem,ot_none);
-    code    : #208#219#193#211#2#15#184#72;
-    flags   : if_386 or if_sm or if_sse4
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#28#72;
+    flags   : if_sse4
   ),
   (
-    opcode  : A_POPCNT;
+    opcode  : A_PABSB;
     ops     : 2;
-    optypes : (ot_reg32 or ot_bits64,ot_regmem,ot_none);
-    code    : #209#219#193#211#2#15#184#72;
-    flags   : if_386 or if_sm or if_sse4
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#28#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#28#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#28#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#29#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#29#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#29#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#29#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#30#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#30#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#30#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#30#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PALIGNR;
+    ops     : 3;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_immediate);
+    code    : #217#3#15#58#15#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PALIGNR;
+    ops     : 3;
+    optypes : (ot_mmxreg,ot_memory,ot_immediate);
+    code    : #193#217#3#15#58#15#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PALIGNR;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#15#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PALIGNR;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#15#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#1#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#1#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#1#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#1#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#2#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#2#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#2#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#2#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#3#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#3#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#3#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#3#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#5#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#5#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#5#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#5#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#6#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#6#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#6#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#6#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#7#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#7#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#7#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#7#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMADDUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#4#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMADDUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#4#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMADDUBSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#4#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMADDUBSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#4#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULHRSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#11#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULHRSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#11#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULHRSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#11#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULHRSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#11#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSHUFB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#0#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSHUFB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#0#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSHUFB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#0#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSHUFB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#0#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#8#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#8#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#8#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#8#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#9#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#9#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#9#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#9#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGND;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#10#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGND;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#10#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGND;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#10#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGND;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#10#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDPS;
+    ops     : 3;
+    optypes : (ot_xmmreg or ot_signed,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#12#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDPS;
+    ops     : 3;
+    optypes : (ot_xmmreg or ot_signed,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#12#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#2#15#58#253#1#13#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#2#15#58#253#1#13#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDVPS;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#20#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDVPS;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#20#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDVPD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#21#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDVPD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#21#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_DPPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#64#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_DPPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#64#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_DPPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#65#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_DPPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#65#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_EXTRACTPS;
+    ops     : 3;
+    optypes : (ot_memory,ot_xmmreg,ot_immediate);
+    code    : #1#102#213#3#15#58#23#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_EXTRACTPS;
+    ops     : 3;
+    optypes : (ot_reg32 or ot_bits64,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#3#15#58#23#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_INSERTPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#33#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_INSERTPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#33#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_MOVNTDQA;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#42#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_MPSADBW;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#66#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_MPSADBW;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#66#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PACKUSDW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#43#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PACKUSDW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#43#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PBLENDVB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#16#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PBLENDVB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#16#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PBLENDW;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate or ot_signed);
+    code    : #1#102#217#3#15#58#14#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PBLENDW;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate or ot_signed);
+    code    : #1#102#193#217#3#15#58#14#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPEQQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#41#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPEQQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#41#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRB;
+    ops     : 3;
+    optypes : (ot_reg32,ot_xmmreg,ot_immediate);
+    code    : #1#102#211#3#15#58#20#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRB;
+    ops     : 3;
+    optypes : (ot_memory or ot_bits8,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#211#3#15#58#20#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRD;
+    ops     : 3;
+    optypes : (ot_reg32,ot_xmmreg,ot_immediate);
+    code    : #1#102#211#3#15#58#22#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRD;
+    ops     : 3;
+    optypes : (ot_memory or ot_bits32,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#211#3#15#58#22#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRQ;
+    ops     : 3;
+    optypes : (ot_reg64,ot_xmmreg,ot_immediate);
+    code    : #1#102#214#3#15#58#22#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRQ;
+    ops     : 3;
+    optypes : (ot_memory or ot_bits64,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#214#3#15#58#22#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHMINPOSUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#65#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHMINPOSUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#65#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRB;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_reg32,ot_immediate);
+    code    : #1#102#217#3#15#58#32#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRB;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory or ot_bits8,ot_immediate);
+    code    : #1#102#193#217#3#15#58#32#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_reg32,ot_immediate);
+    code    : #1#102#217#3#15#58#34#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory or ot_bits32,ot_immediate);
+    code    : #1#102#193#217#3#15#58#34#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRQ;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_reg64,ot_immediate);
+    code    : #1#102#214#3#15#58#34#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRQ;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory or ot_bits64,ot_immediate);
+    code    : #1#102#193#214#3#15#58#34#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#60#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#60#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#61#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#61#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXUD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#63#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXUD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#63#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#62#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#62#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#56#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#56#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#57#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#57#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#58#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#58#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINUD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#59#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINUD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#59#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#32#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#32#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#33#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#33#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#34#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#34#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXWD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#35#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXWD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#35#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXWQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#36#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXWQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#36#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#37#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#37#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#48#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#48#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#49#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#49#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#50#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#50#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXWD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#51#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXWD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#51#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXWQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#52#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXWQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#52#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#53#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#53#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#40#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#40#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PTEST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#23#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#8#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#8#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#9#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#9#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDSS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#10#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDSS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#10#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDSD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#11#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDSD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#11#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPESTRI;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#97#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPESTRI;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#97#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPESTRM;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#96#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPESTRM;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#96#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPISTRI;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#99#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPISTRI;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#99#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPISTRM;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#98#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPISTRM;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#98#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPGTQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#55#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPGTQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#55#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_POPCNT;
+    ops     : 2;
+    optypes : (ot_reg16,ot_regmem or ot_bits16,ot_none);
+    code    : #1#243#193#208#2#15#184#72;
+    flags   : if_386 or if_sm or if_sse4
+  ),
+  (
+    opcode  : A_POPCNT;
+    ops     : 2;
+    optypes : (ot_reg32,ot_regmem or ot_bits32,ot_none);
+    code    : #1#243#193#208#2#15#184#72;
+    flags   : if_386 or if_sm or if_sse4
+  ),
+  (
+    opcode  : A_POPCNT;
+    ops     : 2;
+    optypes : (ot_reg64,ot_regmem or ot_bits64,ot_none);
+    code    : #1#243#193#208#2#15#184#72;
+    flags   : if_386 or if_sm or if_sse4
+  ),
+  (
+    opcode  : A_AESENC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#220#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESENC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#220#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESENCLAST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#221#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESENCLAST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#221#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESDEC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#222#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESDEC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#222#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESDECLAST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#223#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESDECLAST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#223#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESIMC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#219#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESIMC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#219#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESKEYGEN;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#223#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESKEYGEN;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#223#72#22;
+    flags   : if_sse4
   )
 );

+ 4 - 1
compiler/link.pas

@@ -150,7 +150,7 @@ Implementation
       begin
         result:=0;
         bufsize:=64*1024;
-	      fs:=TCFileStream.Create(fn,fmOpenRead or fmShareDenyNone);
+	      fs:=CFileStreamClass.Create(fn,fmOpenRead or fmShareDenyNone);
 	      if CStreamError<>0 then
 	        begin
 	          fs.Free;
@@ -1051,6 +1051,9 @@ Implementation
         if ErrorCount>0 then
           goto myexit;
 
+        { parse linker options specific for output format }
+        exeoutput.ParseScript (linkscript);
+
         { Create .exe sections and add .o sections }
         ParseScript_Order;
         exeoutput.RemoveUnreferencedSections;

+ 1 - 1
compiler/msg/errorct.msg

@@ -2100,7 +2100,7 @@ option_code_page_not_available=11039_E_La p
 #
 option_logo=11023_[
 Free Pascal Compiler versió $FPCFULLVERSION [$FPCDATE] per $FPCCPU
-Copyright (c) 1993-2010 per Florian Klaempfl
+Copyright (c) 1993-2011 per Florian Klaempfl
 ]
 
 #

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 153 - 153
compiler/msg/errord.msg


+ 1 - 1
compiler/msg/errorda.msg

@@ -2207,7 +2207,7 @@ option_config_is_dir=11040_F_Konfigurationsfilen $1 er et directory
 #
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] til $FPCTARGET
-Copyright (c) 1993-2010 Florian Klaempfl
+Copyright (c) 1993-2011 Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errordu.msg

@@ -2991,7 +2991,7 @@ wpo_cant_create_feedback_file=12019_E_Die angegebene Feedback-Eingabe-Datei "$1"
 #
 option_logo=11023_[
 Free Pascal Compiler Version $FPCFULLVERSION [$FPCDATE] für $FPCTARGET
-Copyright (c) 1993-2010 Florian Klämpfl
+Copyright (c) 1993-2011 Florian Klämpfl und andere
 ]
 
 #

+ 1 - 1
compiler/msg/errore.msg

@@ -2966,7 +2966,7 @@ wpo_cant_create_feedback_file=12019_E_Cannot create specified whole program opti
 #
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl and others
 ]
 
 #

+ 1 - 1
compiler/msg/errores.msg

@@ -2111,7 +2111,7 @@ option_code_page_not_available=11039_E_C
 #
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorf.msg

@@ -1712,7 +1712,7 @@ option_asm_forced=11022_W_"$1" assembler use forced
 #
 option_logo=11023_[
 Compilateur Free Pascal version $FPCFULLVERSION [$FPCDATE] pour $FPCTARGET
-Copyright (c) 1998-2009 by Florian Klaempfl
+Copyright (c) 1998-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorfi.msg

@@ -2258,7 +2258,7 @@ option_config_is_dir=11040_F_Le fichier de configuration $1 est un r
 # Logo (option -l)
 #
 option_logo=11023_[ Compilateur Free Pascal version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010, Florian Klaempfl ]
+Copyright (c) 1993-2011, Florian Klaempfl ]
 #
 # Info (option -i)
 #

+ 1 - 1
compiler/msg/errorhe.msg

@@ -2404,7 +2404,7 @@ option_confict_asm_debug=11041_W_
 #
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorheu.msg

@@ -2404,7 +2404,7 @@ option_confict_asm_debug=11041_W_סוג הפלט של המאסף שנבחר "$1"
 #
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorid.msg

@@ -2421,7 +2421,7 @@ option_confict_asm_debug=11041_W_Output assembler yang dipilih "$1" tidak bisa m
 #
 option_logo=11023_[
 Free Pascal Compiler versi $FPCFULLVERSION [$FPCDATE] untuk $FPCCPU
-Hak Cipta (c) 1993-2010 oleh Florian Klaempfl
+Hak Cipta (c) 1993-2011 oleh Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorn.msg

@@ -2183,7 +2183,7 @@ option_config_is_dir=11040_F_Config bestand $1 is een directorie
 %\end{description}
 option_logo=11023_[
 Free Pascal Compiler versie $FPCFULLVERSION [$FPCDATE] voor $FPCTARGET
-Copyright (c) 1998-2009 door Florian Klaempfl en anderen
+Copyright (c) 1998-2011 door Florian Klaempfl en anderen
 ]
 #
 # Info (option -i)

+ 1 - 1
compiler/msg/errorpl.msg

@@ -2116,7 +2116,7 @@ option_code_page_not_available=11039_E_Nieznana strona kodowa
 #
 option_logo=11023_[
 Free Pascal Compiler wersja $FPCFULLVERSION [$FPCDATE] dla $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorpli.msg

@@ -2116,7 +2116,7 @@ option_code_page_not_available=11039_E_Nieznana strona kodowa
 #
 option_logo=11023_[
 Free Pascal Compiler wersja $FPCFULLVERSION [$FPCDATE] dla $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorpt.msg

@@ -2905,7 +2905,7 @@ wpo_cant_create_feedback_file=12019_E_Imposs
 #
 option_logo=11023_[
 Compilador Free Pascal versÆo $FPCFULLVERSION [$FPCDATE] para $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorptu.msg

@@ -2905,7 +2905,7 @@ wpo_cant_create_feedback_file=12019_E_Impossível criar arquivo retorno otimiza
 #
 option_logo=11023_[
 Compilador Free Pascal versão $FPCFULLVERSION [$FPCDATE] para $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorr.msg

@@ -2503,7 +2503,7 @@ wpo_cant_create_feedback_file=12019_E_
 #
 option_logo=11023_[
 Š®¬¯¨«ïâ®à Free Pascal ¢¥àᨨ $FPCFULLVERSION [$FPCDATE] ¤«ï $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorru.msg

@@ -2503,7 +2503,7 @@ wpo_cant_create_feedback_file=12019_E_Невозможно создать фай
 #
 option_logo=11023_[
 Компилятор Free Pascal версии $FPCFULLVERSION [$FPCDATE] для $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msg/errorues.msg

@@ -2105,7 +2105,7 @@ option_code_page_not_available=11039_E_Código de página desconocido
 #
 option_logo=11023_[
 Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPCCPU
-Copyright (c) 1993-2010 by Florian Klaempfl
+Copyright (c) 1993-2011 by Florian Klaempfl
 ]
 
 #

+ 1 - 1
compiler/msgidx.inc

@@ -882,7 +882,7 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 58686;
+  MsgTxtSize = 58697;
 
   MsgIdxMax : array[1..20] of longint=(
     24,88,305,99,84,54,111,22,202,63,

+ 71 - 71
compiler/msgtxt.inc

@@ -1042,11 +1042,11 @@ const msgtxt : array[0..000244,1..240] of char=(
   'file "$1"'#000+
   '11023_Free Pascal Compiler version $FPCFULLVERSION [$FPCDATE] for $FPC'+
   'CPU'#010+
-  'Copyright (c) 1993-2010 by Florian Klaempfl'#000+
+  'Copyright (c) 1993-2011 by Florian Klaempfl and others'#000+
   '11024_Free Pascal Compiler version $FPCVERSION'#010+
   #010+
   'Compiler Date      : $FPCDATE'#010+
-  'Compiler CPU Target',': $FPCCPU'#010+
+  'Compiler',' CPU Target: $FPCCPU'#010+
   #010+
   'Supported targets:'#010+
   '  $OSTARGETS'#010+
@@ -1061,9 +1061,9 @@ const msgtxt : array[0..000244,1..240] of char=(
   '  $ABITARGETS'#010+
   #010+
   'Supported Optimizations:'#010+
-  '  $OPTIMIZATIONS'#010+
+  '  $OPTIMIZATION','S'#010+
   #010+
-  'Supporte','d Whole Program Optimizations:'#010+
+  'Supported Whole Program Optimizations:'#010+
   '  All'#010+
   '  $WPOPTIMIZATIONS'#010+
   #010+
@@ -1073,37 +1073,37 @@ const msgtxt : array[0..000244,1..240] of char=(
   'This program comes under the GNU General Public Licence'#010+
   'For more information read COPYING.FPC'#010+
   #010+
-  'Report bugs, suggestions, etc. to:'#010,
+  'Report bugs, suggestions',', etc. to:'#010+
   '                 http://bugs.freepascal.org'#010+
   'or'#010+
   '                 [email protected]'#000+
   '11025_**0*_Put + after a boolean switch option to enable it, - to disa'+
   'ble it'#010+
   '**1a_The compiler doesn'#039't delete the generated assembler file'#010+
-  '**2al_List source','code lines in assembler file'#010+
+  '**2al_','List sourcecode lines in assembler file'#010+
   '**2an_List node info in assembler file'#010+
   '*L2ap_Use pipes instead of creating temporary assembler files'#010+
   '**2ar_List register allocation/release info in assembler file'#010+
-  '**2at_List temp allocation/release info in assem','bler file'#010+
+  '**2at_List temp allocation/release in','fo in assembler file'#010+
   '**1A<x>_Output format:'#010+
   '**2Adefault_Use default assembler'#010+
   '3*2Aas_Assemble using GNU AS'#010+
   '3*2Amacho_Mach-O (Darwin, Intel 32 bit) using internal writer'#010+
   '3*2Anasmcoff_COFF (Go32v2) file using Nasm'#010+
-  '3*2Anasmelf_ELF32 (Linux) file using Na','sm'#010+
+  '3*2Anasmelf_ELF32 (Linux) fi','le using Nasm'#010+
   '3*2Anasmwin32_Win32 object file using Nasm'#010+
   '3*2Anasmwdosx_Win32/WDOSX object file using Nasm'#010+
   '3*2Awasm_Obj file using Wasm (Watcom)'#010+
   '3*2Anasmobj_Obj file using Nasm'#010+
   '3*2Amasm_Obj file using Masm (Microsoft)'#010+
-  '3*2Atasm_Obj file using Tasm (Borl','and)'#010+
+  '3*2Atasm_Obj file using',' Tasm (Borland)'#010+
   '3*2Aelf_ELF (Linux) using internal writer'#010+
   '3*2Acoff_COFF (Go32v2) using internal writer'#010+
   '3*2Apecoff_PE-COFF (Win32) using internal writer'#010+
   '4*2Aas_Assemble using GNU AS'#010+
   '6*2Aas_Unix o-file using GNU AS'#010+
-  '6*2Agas_GNU Motorola assembler'#010+
-  '6*2Amit','_MIT Syntax (old GAS)'#010+
+  '6*2Agas_GNU Motorola assemb','ler'#010+
+  '6*2Amit_MIT Syntax (old GAS)'#010+
   '6*2Amot_Standard Motorola assembler'#010+
   'A*2Aas_Assemble using GNU AS'#010+
   'P*2Aas_Assemble using GNU AS'#010+
@@ -1111,37 +1111,37 @@ const msgtxt : array[0..000244,1..240] of char=(
   '**1b_Generate browser info'#010+
   '**2bl_Generate local symbol info'#010+
   '**1B_Build all modules'#010+
-  '**1C<x>_Code',' generation options:'#010+
+  '*','*1C<x>_Code generation options:'#010+
   '**2C3<x>_Turn on ieee error checking for constants'#010+
   '**2Ca<x>_Select ABI, see fpc -i for possible values'#010+
   '**2Cb_Generate big-endian code'#010+
   '**2Cc<x>_Set default calling convention to <x>'#010+
-  '**2CD_Create also dynamic library (not',' supported)'#010+
+  '**2CD_Create also dynamic l','ibrary (not supported)'#010+
   '**2Ce_Compilation with emulated floating point opcodes'#010+
   '**2Cf<x>_Select fpu instruction set to use, see fpc -i for possible va'+
   'lues'#010+
   '**2CF<x>_Minimal floating point constant precision (default, 32, 64)'#010+
-  '**2Cg_Generate PIC code'#010+
-  '**2Ch','<n>_<n> bytes heap (between 1023 and 67107840)'#010+
+  '**2Cg_Generate PIC',' code'#010+
+  '**2Ch<n>_<n> bytes heap (between 1023 and 67107840)'#010+
   '**2Ci_IO-checking'#010+
   '**2Cn_Omit linking stage'#010+
   '**2Co_Check overflow of integer operations'#010+
   '**2CO_Check for possible overflow of integer operations'#010+
-  '**2Cp<x>_Select instruction set, see fpc -i for pos','sible values'#010+
+  '**2Cp<x>_Select instruction set, see fpc',' -i for possible values'#010+
   '**2CP<x>=<y>_ packing settings'#010+
   '**3CPPACKSET=<y>_ <y> set allocation: 0, 1 or DEFAULT or NORMAL, 2, 4 '+
   'and 8'#010+
   '**2Cr_Range checking'#010+
   '**2CR_Verify object method call validity'#010+
   '**2Cs<n>_Set stack checking size to <n>'#010+
-  '**2Ct_Stack checki','ng (for testing only, see manual)'#010+
+  '**2Ct_S','tack checking (for testing only, see manual)'#010+
   '**2CX_Create also smartlinked library'#010+
   '**1d<x>_Defines the symbol <x>'#010+
   '**1D_Generate a DEF file'#010+
   '**2Dd<x>_Set description to <x>'#010+
   '**2Dv<x>_Set DLL version to <x>'#010+
   '*O2Dw_PM application'#010+
-  '**1e<x>_Set path to executa','ble'#010+
+  '**1e<x>_Set path',' to executable'#010+
   '**1E_Same as -Cn'#010+
   '**1fPIC_Same as -Cg'#010+
   '**1F<x>_Set file names and paths:'#010+
@@ -1149,83 +1149,83 @@ const msgtxt : array[0..000244,1..240] of char=(
   'sed'#010+
   '**2Fc<x>_Set input codepage to <x>'#010+
   '**2FC<x>_Set RC compiler binary name to <x>'#010+
-  '**2Fd_Disabl','e the compiler'#039's internal directory cache'#010+
+  '*','*2Fd_Disable the compiler'#039's internal directory cache'#010+
   '**2FD<x>_Set the directory where to search for compiler utilities'#010+
   '**2Fe<x>_Redirect error output to <x>'#010+
   '**2Ff<x>_Add <x> to framework path (Darwin only)'#010+
-  '**2FE<x>_Set exe/unit output path to <x>'#010+
-  '**2F','i<x>_Add <x> to include path'#010+
+  '**2FE<x>_Set exe/unit output path ','to <x>'#010+
+  '**2Fi<x>_Add <x> to include path'#010+
   '**2Fl<x>_Add <x> to library path'#010+
   '**2FL<x>_Use <x> as dynamic linker'#010+
   '**2Fm<x>_Load unicode conversion table from <x>.txt in the compiler di'+
   'r'#010+
   '**2Fo<x>_Add <x> to object path'#010+
-  '**2Fr<x>_Load error message file <x>'#010+
-  '**','2FR<x>_Set resource (.res) linker to <x>'#010+
+  '**2Fr<x>_Load error message ','file <x>'#010+
+  '**2FR<x>_Set resource (.res) linker to <x>'#010+
   '**2Fu<x>_Add <x> to unit path'#010+
   '**2FU<x>_Set unit output path to <x>, overrides -FE'#010+
   '**2FW<x>_Store generated whole-program optimization feedback in <x>'#010+
-  '**2Fw<x>_Load previously stored whole-program opt','imization feedback '+
+  '**2Fw<x>_Load previously stored whole-','program optimization feedback '+
   'from <x>'#010+
   '*g1g_Generate debug information (default format for target)'#010+
   '*g2gc_Generate checks for pointers'#010+
   '*g2gh_Use heaptrace unit (for memory leak/corruption debugging)'#010+
-  '*g2gl_Use line info unit (show more info with backtra','ces)'#010+
+  '*g2gl_Use line info unit (show more info w','ith backtraces)'#010+
   '*g2go<x>_Set debug information options'#010+
   '*g3godwarfsets_ Enable DWARF '#039'set'#039' type debug information (bre'+
   'aks gdb < 6.5)'#010+
   '*g3gostabsabsincludes_ Store absolute/full include file paths in Stabs'+
   #010+
-  '*g3godwarfmethodclassprefix_ Prefix method names',' in DWARF with class'+
+  '*g3godwarfmethodclassprefix_ Prefix m','ethod names in DWARF with class'+
   ' name'#010+
   '*g2gp_Preserve case in stabs symbol names'#010+
   '*g2gs_Generate Stabs debug information'#010+
   '*g2gt_Trash local variables (to detect uninitialized uses)'#010+
   '*g2gv_Generates programs traceable with Valgrind'#010+
-  '*g2gw_Generate DWARFv2 de','bug information (same as -gw2)'#010+
+  '*g2gw_Generate',' DWARFv2 debug information (same as -gw2)'#010+
   '*g2gw2_Generate DWARFv2 debug information'#010+
   '*g2gw3_Generate DWARFv3 debug information'#010+
   '*g2gw4_Generate DWARFv4 debug information (experimental)'#010+
   '**1i_Information'#010+
   '**2iD_Return compiler date'#010+
-  '**2iV_Return short compi','ler version'#010+
+  '**2iV_Return ','short compiler version'#010+
   '**2iW_Return full compiler version'#010+
   '**2iSO_Return compiler OS'#010+
   '**2iSP_Return compiler host processor'#010+
   '**2iTO_Return target OS'#010+
   '**2iTP_Return target processor'#010+
   '**1I<x>_Add <x> to include path'#010+
-  '**1k<x>_Pass <x> to the linker'#010+
-  '**1l_Write ','logo'#010+
+  '**1k<x>_Pass <x> to the linker'#010,
+  '**1l_Write logo'#010+
   '**1M<x>_Set language mode to <x>'#010+
   '**2Mfpc_Free Pascal dialect (default)'#010+
   '**2Mobjfpc_FPC mode with Object Pascal support'#010+
   '**2Mdelphi_Delphi 7 compatibility mode'#010+
   '**2Mtp_TP/BP 7.0 compatibility mode'#010+
-  '**2Mmacpas_Macintosh Pascal dialects compa','tibility mode'#010+
+  '**2Mmacpas_Macintosh Pascal dia','lects compatibility mode'#010+
   '**1n_Do not read the default config files'#010+
   '**1N<x>_Node tree optimizations'#010+
   '**2Nu_Unroll loops'#010+
   '**1o<x>_Change the name of the executable produced to <x>'#010+
   '**1O<x>_Optimizations:'#010+
   '**2O-_Disable optimizations'#010+
-  '**2O1_Level 1 optimizati','ons (quick and debugger friendly)'#010+
+  '**2O1_Level 1',' optimizations (quick and debugger friendly)'#010+
   '**2O2_Level 2 optimizations (-O1 + quick optimizations)'#010+
   '**2O3_Level 3 optimizations (-O2 + slow optimizations)'#010+
   '**2Oa<x>=<y>_Set alignment'#010+
-  '**2Oo[NO]<x>_Enable or disable optimizations, see fpc -i for possibl','e'+
-  ' values'#010+
+  '**2Oo[NO]<x>_Enable or disable optimizations, see fpc -i ','for possibl'+
+  'e values'#010+
   '**2Op<x>_Set target cpu for optimizing, see fpc -i for possible values'+
   #010+
   '**2OW<x>_Generate whole-program optimization feedback for optimization'+
   ' <x>, see fpc -i for possible values'#010+
-  '**2Ow<x>_Perform whole-program optimization <x>, see ','fpc -i for poss'+
+  '**2Ow<x>_Perform whole-program optimizatio','n <x>, see fpc -i for poss'+
   'ible values'#010+
   '**2Os_Optimize for size rather than speed'#010+
   '**1pg_Generate profile code for gprof (defines FPC_PROFILE)'#010+
   '**1R<x>_Assembler reading style:'#010+
   '**2Rdefault_Use default assembler for target'#010+
-  '3*2Ratt_Read AT&T style assembler',#010+
+  '3*2Ratt_Read AT&T styl','e assembler'#010+
   '3*2Rintel_Read Intel style assembler'#010+
   '6*2RMOT_Read motorola style assembler'#010+
   '**1S<x>_Syntax options:'#010+
@@ -1233,44 +1233,44 @@ const msgtxt : array[0..000244,1..240] of char=(
   '**2Sc_Support operators like C (*=,+=,/= and -=)'#010+
   '**2Sa_Turn on assertions'#010+
   '**2Sd_Same as -Mdelphi'#010+
-  '**2Se<x>_Error optio','ns. <x> is a combination of the following:'#010+
+  '**2Se<x>_','Error options. <x> is a combination of the following:'#010+
   '**3*_<n> : Compiler halts after the <n> errors (default is 1)'#010+
   '**3*_w : Compiler also halts after warnings'#010+
   '**3*_n : Compiler also halts after notes'#010+
-  '**3*_h : Compiler also halts after hints'#010+
-  '**2Sg_Ena','ble LABEL and GOTO (default in -Mtp and -Mdelphi)'#010+
+  '**3*_h : Compiler also halts after hint','s'#010+
+  '**2Sg_Enable LABEL and GOTO (default in -Mtp and -Mdelphi)'#010+
   '**2Sh_Use ansistrings by default instead of shortstrings'#010+
   '**2Si_Turn on inlining of procedures/functions declared as "inline"'#010+
   '**2Sk_Load fpcylix unit'#010+
-  '**2SI<x>_Set interface style to <x>'#010+
-  '**3SI','com_COM compatible interface (default)'#010+
+  '**2SI<x>_Set interface style t','o <x>'#010+
+  '**3SIcom_COM compatible interface (default)'#010+
   '**3SIcorba_CORBA compatible interface'#010+
   '**2Sm_Support macros like C (global)'#010+
   '**2So_Same as -Mtp'#010+
   '**2Ss_Constructor name must be init (destructor must be done)'#010+
-  '**2Sx_Enable exception keywords (default in D','elphi/ObjFPC modes)'#010+
+  '**2Sx_Enable exception keywords (d','efault in Delphi/ObjFPC modes)'#010+
   '**1s_Do not call assembler and linker'#010+
   '**2sh_Generate script to link on host'#010+
   '**2st_Generate script to link on target'#010+
   '**2sr_Skip register allocation phase (use with -alr)'#010+
   '**1T<x>_Target operating system:'#010+
-  '3*2Tdarwin_Darwin/','Mac OS X'#010+
+  '3*2Tdar','win_Darwin/Mac OS X'#010+
   '3*2Temx_OS/2 via EMX (including EMX/RSX extender)'#010+
   '3*2Tfreebsd_FreeBSD'#010+
   '3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+
   '3*2Tiphonesim_ iPhoneSimulator from iOS SDK 3.2+ (older versions: -Tda'+
   'rwin)'#010+
   '3*2Tlinux_Linux'#010+
-  '3*2Tnetbsd_NetBSD'#010+
-  '3*2','Tnetware_Novell Netware Module (clib)'#010+
+  '3*2Tnetbsd','_NetBSD'#010+
+  '3*2Tnetware_Novell Netware Module (clib)'#010+
   '3*2Tnetwlibc_Novell Netware Module (libc)'#010+
   '3*2Topenbsd_OpenBSD'#010+
   '3*2Tos2_OS/2 / eComStation'#010+
   '3*2Tsunos_SunOS/Solaris'#010+
   '3*2Tsymbian_Symbian OS'#010+
   '3*2Tsolaris_Solaris'#010+
-  '3*2Twatcom_Watcom compatible DOS extender'#010+
-  '3*2T','wdosx_WDOSX DOS extender'#010+
+  '3*2Twatcom_Watcom compatible DOS ex','tender'#010+
+  '3*2Twdosx_WDOSX DOS extender'#010+
   '3*2Twin32_Windows 32 Bit'#010+
   '3*2Twince_Windows CE'#010+
   '4*2Tdarwin_Darwin/Mac OS X'#010+
@@ -1279,7 +1279,7 @@ const msgtxt : array[0..000244,1..240] of char=(
   '6*2Tamiga_Commodore Amiga'#010+
   '6*2Tatari_Atari ST/STe/TT'#010+
   '6*2Tlinux_Linux'#010+
-  '6*2Tpalmos_PalmOS',#010+
+  '6*2Tpa','lmos_PalmOS'#010+
   'A*2Tdarwin_Darwin/iPhoneOS/iOS'#010+
   'A*2Tlinux_Linux'#010+
   'A*2Twince_Windows CE'#010+
@@ -1290,83 +1290,83 @@ const msgtxt : array[0..000244,1..240] of char=(
   'P*2Tmorphos_MorphOS'#010+
   'S*2Tsolaris_Solaris'#010+
   'S*2Tlinux_Linux'#010+
-  '**1u<x>_Undefines the symbo','l <x>'#010+
+  '**1u<x>_Undefine','s the symbol <x>'#010+
   '**1U_Unit options:'#010+
   '**2Un_Do not check where the unit name matches the file name'#010+
   '**2Ur_Generate release unit files (never automatically recompiled)'#010+
   '**2Us_Compile a system unit'#010+
-  '**1v<x>_Be verbose. <x> is a combination of the following l','etters:'#010+
+  '**1v<x>_Be verbose. <x> is a combination of the ','following letters:'#010+
   '**2*_e : Show errors (default)       0 : Show nothing (except errors)'#010+
   '**2*_w : Show warnings               u : Show unit info'#010+
   '**2*_n : Show notes                  t : Show tried/used files'#010+
-  '**2*_h : Show hints                  c : Sh','ow conditionals'#010+
+  '**2*_h : Show hints             ','     c : Show conditionals'#010+
   '**2*_i : Show general info           d : Show debug info'#010+
   '**2*_l : Show linenumbers            r : Rhide/GCC compatibility mode'#010+
   '**2*_s : Show time stamps            q : Show message numbers'#010+
-  '**2*_a : Show everything           ','  x : Executable info (Win32 only'+
+  '**2*_a : Show everything','             x : Executable info (Win32 only'+
   ')'#010+
   '**2*_b : Write file names messages   p : Write tree.log with parse tre'+
   'e'#010+
   '**2*_    with full path              v : Write fpcdebug.txt with'#010+
-  '**2*_                                    lots of debugging info'#010+
-  '**2*','_m<x>,<y> : Don'#039't show messages numbered <x> and <y>'#010+
+  '**2*_                                    lots of debuggin','g info'#010+
+  '**2*_m<x>,<y> : Don'#039't show messages numbered <x> and <y>'#010+
   '3*1W<x>_Target-specific options (targets)'#010+
   'A*1W<x>_Target-specific options (targets)'#010+
   'P*1W<x>_Target-specific options (targets)'#010+
   'p*1W<x>_Target-specific options (targets)'#010+
-  '3*2Wb_Create a bund','le instead of a library (Darwin)'#010+
+  '3*2Wb_Cr','eate a bundle instead of a library (Darwin)'#010+
   'P*2Wb_Create a bundle instead of a library (Darwin)'#010+
   'p*2Wb_Create a bundle instead of a library (Darwin)'#010+
   '3*2WB_Create a relocatable image (Windows)'#010+
-  'A*2WB_Create a relocatable image (Windows, Symbian)'#010+
-  '3*2WC_Sp','ecify console type application (EMX, OS/2, Windows)'#010+
+  'A*2WB_Create a relocatable image (Windows, Symbia','n)'#010+
+  '3*2WC_Specify console type application (EMX, OS/2, Windows)'#010+
   'A*2WC_Specify console type application (Windows)'#010+
   'P*2WC_Specify console type application (Classic Mac OS)'#010+
   '3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)'#010+
-  'A*2WD_Use DEFFILE to ','export functions of DLL or EXE (Windows)'#010+
+  'A*2WD_Use ','DEFFILE to export functions of DLL or EXE (Windows)'#010+
   '3*2We_Use external resources (Darwin)'#010+
   '4*2We_Use external resources (Darwin)'#010+
   'A*2We_Use external resources (Darwin)'#010+
   'P*2We_Use external resources (Darwin)'#010+
-  'p*2We_Use external resources (Darwin)'#010+
-  '3*2WF_Spe','cify full-screen type application (EMX, OS/2)'#010+
+  'p*2We_Use external resources (Darwin',')'#010+
+  '3*2WF_Specify full-screen type application (EMX, OS/2)'#010+
   '3*2WG_Specify graphic type application (EMX, OS/2, Windows)'#010+
   'A*2WG_Specify graphic type application (Windows)'#010+
   'P*2WG_Specify graphic type application (Classic Mac OS)'#010+
-  '3*2Wi_Use internal resources ','(Darwin)'#010+
+  '3*2Wi_Use internal',' resources (Darwin)'#010+
   'P*2Wi_Use internal resources (Darwin)'#010+
   'p*2Wi_Use internal resources (Darwin)'#010+
   '3*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
   'A*2WN_Do not generate relocation code, needed for debugging (Windows)'#010+
-  '3*2WR_Generate ','relocation code (Windows)'#010+
+  '3*2W','R_Generate relocation code (Windows)'#010+
   'A*2WR_Generate relocation code (Windows)'#010+
   'P*2WT_Specify MPW tool type application (Classic Mac OS)'#010+
   '3*2WX_Enable executable stack (Linux)'#010+
   'A*2WX_Enable executable stack (Linux)'#010+
-  'p*2WX_Enable executable stack (Linux)'#010+
-  'P*','2WX_Enable executable stack (Linux)'#010+
+  'p*2WX_Enable executable stack',' (Linux)'#010+
+  'P*2WX_Enable executable stack (Linux)'#010+
   '**1X_Executable options:'#010+
   '**2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Lin'+
   'ux)'#010+
   '**2Xd_Do not use standard library search path (needed for cross compil'+
   'e)'#010+
-  '**2Xe_Use external linker'#010+
-  '**2Xg_','Create debuginfo in a separate file and add a debuglink sectio'+
-  'n to executable'#010+
+  '**2Xe_Use external li','nker'#010+
+  '**2Xg_Create debuginfo in a separate file and add a debuglink section '+
+  'to executable'#010+
   '**2XD_Try to link units dynamically      (defines FPC_LINK_DYNAMIC)'#010+
   '**2Xi_Use internal linker'#010+
   '**2Xm_Generate link map'#010+
-  '**2XM<x>_Set the name of the '#039'main'#039' program ','routine (default'+
+  '**2XM<x>_Set the name of the '#039'mai','n'#039' program routine (default'+
   ' is '#039'main'#039')'#010+
   '**2XP<x>_Prepend the binutils names with the prefix <x>'#010+
   '**2Xr<x>_Set the linker'#039's rlink-path to <x> (needed for cross comp'+
   'ile, see the ld manual for more information) (BeOS, Linux)'#010+
-  '**2XR<x>_Prepend <x> to all lin','ker search paths (BeOS, Darwin, FreeB'+
+  '**2XR<x>_Prepend <x>',' to all linker search paths (BeOS, Darwin, FreeB'+
   'SD, Linux, Mac OS, Solaris)'#010+
   '**2Xs_Strip all symbols from executable'#010+
   '**2XS_Try to link units statically (default, defines FPC_LINK_STATIC)'#010+
-  '**2Xt_Link with static libraries (-static is passed to linker)'#010+
-  '**','2XX_Try to smartlink units             (defines FPC_LINK_SMART)'#010+
+  '**2Xt_Link with static libraries (-static is passed to',' linker)'#010+
+  '**2XX_Try to smartlink units             (defines FPC_LINK_SMART)'#010+
   '**1*_'#010+
   '**1?_Show this help'#010+
   '**1h_Shows this help without waiting'

+ 21 - 1
compiler/ncal.pas

@@ -201,6 +201,9 @@ interface
           function can_be_inlined: boolean;
 
           property nextpara : tnode read right write right;
+          { third is reused to store the parameter name (only while parsing
+            vardispatch calls, never in real node tree) and copy of 'high'
+            parameter tree when the parameter is an open array of managed type }
           property parametername : tnode read third write third;
 
           { returns whether the evaluation of this parameter involves a
@@ -620,6 +623,8 @@ implementation
          old_array_constructor:=allow_array_constructor;
          allow_array_constructor:=true;
          typecheckpass(left);
+         if assigned(third) then
+           typecheckpass(third);
          allow_array_constructor:=old_array_constructor;
          if codegenerror then
           resultdef:=generrordef
@@ -635,6 +640,8 @@ implementation
         if not assigned(left.resultdef) then
           get_paratype;
         firstpass(left);
+        if assigned(third) then
+          firstpass(third);
         expectloc:=left.expectloc;
       end;
 
@@ -2492,6 +2499,7 @@ implementation
         varargspara,
         currpara : tparavarsym;
         hiddentree : tnode;
+        paradef  : tdef;
       begin
         pt:=tcallparanode(left);
         oldppt:=pcallparanode(@left);
@@ -2527,7 +2535,19 @@ implementation
                   if not assigned(pt) or (i=0) then
                     internalerror(200304081);
                   { we need the information of the previous parameter }
-                  hiddentree:=gen_high_tree(pt.left,tparavarsym(procdefinition.paras[i-1]).vardef);
+                  paradef:=tparavarsym(procdefinition.paras[i-1]).vardef;
+                  hiddentree:=gen_high_tree(pt.left,paradef);
+                  { for open array of managed type, a copy of high parameter is
+                    necessary to properly initialize before the call }
+                  if is_open_array(paradef) and
+                    (tparavarsym(procdefinition.paras[i-1]).varspez=vs_out) and
+                     is_managed_type(tarraydef(paradef).elementdef) then
+                    begin
+                      typecheckpass(hiddentree);
+                      {this eliminates double call to fpc_dynarray_high, if any}
+                      maybe_load_in_temp(hiddentree);
+                      oldppt^.third:=hiddentree.getcopy;
+                    end;
                 end
               else
                 if vo_is_typinfo_para in currpara.varoptions then

+ 10 - 1
compiler/ncgcal.pas

@@ -167,7 +167,16 @@ implementation
                 is_managed_type(left.resultdef) then
                begin
                  location_get_data_ref(current_asmdata.CurrAsmList,left.location,href,false,sizeof(pint));
-                 cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);
+                 if is_open_array(resultdef) then
+                   begin
+                     if third=nil then
+                       InternalError(201103063);
+                     secondpass(third);
+                     cg.g_array_rtti_helper(current_asmdata.CurrAsmList,tarraydef(resultdef).elementdef,
+                       href,third.location,'FPC_DECREF_ARRAY');
+                   end
+                 else
+                   cg.g_decrrefcount(current_asmdata.CurrAsmList,left.resultdef,href);
                end;
 
              paramanager.createtempparaloc(current_asmdata.CurrAsmList,aktcallnode.procdefinition.proccalloption,parasym,not followed_by_stack_tainting_call_cached,tempcgpara);

+ 56 - 141
compiler/ncgmem.pas

@@ -59,6 +59,7 @@ interface
          function get_mul_size : aint;
        private
          procedure rangecheck_array;
+         procedure rangecheck_string;
        protected
          {# This routine is used to calculate the address of the reference.
             On entry reg contains the index in the array,
@@ -635,6 +636,10 @@ implementation
          hreg : tregister;
          paraloc1,paraloc2 : tcgpara;
        begin
+         { omit range checking when this is an array access to a pointer which has been
+           typecasted from an array }
+         if (ado_isconvertedpointer in tarraydef(left.resultdef).arrayoptions) then
+           exit;
          paraloc1.init;
          paraloc2.init;
          if is_open_array(left.resultdef) or
@@ -690,6 +695,45 @@ implementation
          paraloc2.done;
        end;
 
+    procedure tcgvecnode.rangecheck_string;
+      var
+        paraloc1,
+        paraloc2: tcgpara;
+      begin
+        paraloc1.init;
+        paraloc2.init;
+        case tstringdef(left.resultdef).stringtype of
+          { it's the same for ansi- and wide strings }
+          st_unicodestring,
+          st_widestring,
+          st_ansistring:
+            begin
+              paramanager.getintparaloc(pocall_default,1,paraloc1);
+              paramanager.getintparaloc(pocall_default,2,paraloc2);
+              cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,left.location,paraloc1);
+              cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,right.location,paraloc2);
+
+              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
+              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
+              cg.allocallcpuregisters(current_asmdata.CurrAsmList);
+              cg.a_call_name(current_asmdata.CurrAsmList,'FPC_'+upper(tstringdef(left.resultdef).stringtypname)+'_RANGECHECK',false);
+              cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
+            end;
+
+          st_shortstring:
+            begin
+              {!!!!!!!!!!!!!!!!!}
+              { if this one is implemented making use of the high parameter for openshortstrings, update ncgutils.do_get_used_regvars() too (JM) }
+            end;
+
+          st_longstring:
+            begin
+              {!!!!!!!!!!!!!!!!!}
+            end;
+        end;
+        paraloc1.done;
+        paraloc2.done;
+      end;
 
     procedure tcgvecnode.pass_generate_code;
 
@@ -697,7 +741,6 @@ implementation
          offsetdec,
          extraoffset : aint;
          t        : tnode;
-         href     : treference;
          otl,ofl  : tasmlabel;
          newsize  : tcgsize;
          mulsize,
@@ -726,8 +769,7 @@ implementation
 
          { an ansistring needs to be dereferenced }
          if is_ansistring(left.resultdef) or
-            is_widestring(left.resultdef) or
-            is_unicodestring(left.resultdef) then
+            is_wide_or_unicode_string(left.resultdef) then
            begin
               if nf_callunique in flags then
                 internalerror(200304236);
@@ -754,18 +796,6 @@ implementation
                   internalerror(2002032218);
               end;
 
-              { check for a zero length string,
-                we can use the ansistring routine here }
-              if (cs_check_range in current_settings.localswitches) then
-                begin
-                   paramanager.getintparaloc(pocall_default,1,paraloc1);
-                   cg.a_load_reg_cgpara(current_asmdata.CurrAsmList,OS_ADDR,location.reference.base,paraloc1);
-                   paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
-                   cg.allocallcpuregisters(current_asmdata.CurrAsmList);
-                   cg.a_call_name(current_asmdata.CurrAsmList,'FPC_'+upper(tstringdef(left.resultdef).stringtypname)+'_CHECKZERO',false);
-                   cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
-                end;
-
               { in ansistrings/widestrings S[1] is p<w>char(S)[0] !! }
               if is_ansistring(left.resultdef) then
                 offsetdec:=1
@@ -828,84 +858,16 @@ implementation
          if right.nodetype=ordconstn then
            begin
               { offset can only differ from 0 if arraydef }
-              case left.resultdef.typ of
-                arraydef :
-                  begin
-		     { do not do any range checking when this is an array access to a pointer which has been
-		       typecasted from an array }
-		     if (not (ado_isconvertedpointer in tarraydef(left.resultdef).arrayoptions)) then
-		       begin
-                     	if not(is_open_array(left.resultdef)) and
-                           not(is_array_of_const(left.resultdef)) and
-                           not(is_dynamic_array(left.resultdef)) then
-                          begin
-                            if (tordconstnode(right).value.svalue>tarraydef(left.resultdef).highrange) or
-                               (tordconstnode(right).value.svalue<tarraydef(left.resultdef).lowrange) then
-                              begin
-                                { this should be caught in the typecheckpass! (JM) }
-                                if (cs_check_range in current_settings.localswitches) then
-                                  CGMessage(parser_e_range_check_error)
-                                else
-                                  CGMessage(parser_w_range_check_error);
-                              end;
-                           end
-                         else
-                           begin
-                              { range checking for open and dynamic arrays needs
-                                runtime code }
-                              secondpass(right);
-                              if (cs_check_range in current_settings.localswitches) then
-                                rangecheck_array;
-                           end;
-		       end;
+              if cs_check_range in current_settings.localswitches then
+                begin
+                  secondpass(right);
+                  case left.resultdef.typ of
+                    arraydef :
+                      rangecheck_array;
+                    stringdef :
+                      rangecheck_string;
                   end;
-                stringdef :
-                  begin
-                    if (cs_check_range in current_settings.localswitches) then
-                     begin
-                       case tstringdef(left.resultdef).stringtype of
-                         { it's the same for ansi- and wide strings }
-                         st_unicodestring,
-                         st_widestring,
-                         st_ansistring:
-                           begin
-                              paramanager.getintparaloc(pocall_default,1,paraloc1);
-                              paramanager.getintparaloc(pocall_default,2,paraloc2);
-                              cg.a_load_const_cgpara(current_asmdata.CurrAsmList,OS_INT,tordconstnode(right).value.svalue,paraloc2);
-                              href:=location.reference;
-                              if not(tf_winlikewidestring in target_info.flags) or
-                                 (tstringdef(left.resultdef).stringtype<>st_widestring) then
-                                begin
-                                  dec(href.offset,sizeof(pint)-offsetdec);
-                                  cg.a_load_ref_cgpara(current_asmdata.CurrAsmList,OS_ADDR,href,paraloc1);
-                                end
-                              else
-                                begin
-                                  { winlike widestrings have a 4 byte length }
-                                  dec(href.offset,4-offsetdec);
-                                  cg.a_load_ref_cgpara(current_asmdata.CurrAsmList,OS_32,href,paraloc1);
-                                end;
-                              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
-                              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
-                              cg.allocallcpuregisters(current_asmdata.CurrAsmList);
-                              cg.a_call_name(current_asmdata.CurrAsmList,'FPC_'+upper(tstringdef(left.resultdef).stringtypname)+'_RANGECHECK',false);
-                              cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
-                           end;
-
-                         st_shortstring:
-                           begin
-                              {!!!!!!!!!!!!!!!!!}
-                              { if this one is implemented making use of the high parameter for openshortstrings, update ncgutils.do_get_used_regvars() too (JM) }
-                           end;
-
-                         st_longstring:
-                           begin
-                              {!!!!!!!!!!!!!!!!!}
-                           end;
-                       end;
-                     end;
-                   end;
-              end;
+                end;
               if not(is_packed_array(left.resultdef)) or
                  ((mulsize mod 8 = 0) and
                   (ispowerof2(mulsize div 8,temp) or
@@ -1015,56 +977,9 @@ implementation
               if cs_check_range in current_settings.localswitches then
                begin
                  if left.resultdef.typ=arraydef then
-                   begin
-		     { do not do any range checking when this is an array access to a pointer which has been
-		       typecasted from an array }
-		     if (not (ado_isconvertedpointer in tarraydef(left.resultdef).arrayoptions)) then
-                       rangecheck_array
-                   end
+                   rangecheck_array
                  else if (left.resultdef.typ=stringdef) then
-                   begin
-                      case tstringdef(left.resultdef).stringtype of
-                         { it's the same for ansi- and wide strings }
-                         st_unicodestring,
-                         st_widestring,
-                         st_ansistring:
-                           begin
-                              paramanager.getintparaloc(pocall_default,1,paraloc1);
-                              paramanager.getintparaloc(pocall_default,2,paraloc2);
-                              cg.a_load_reg_cgpara(current_asmdata.CurrAsmList,OS_INT,right.location.register,paraloc2);
-                              href:=location.reference;
-                              dec(href.offset,sizeof(pint)-offsetdec);
-
-                              href:=location.reference;
-                              if not(tf_winlikewidestring in target_info.flags) or
-                                 (tstringdef(left.resultdef).stringtype<>st_widestring) then
-                                begin
-                                  dec(href.offset,sizeof(pint)-offsetdec);
-                                  cg.a_load_ref_cgpara(current_asmdata.CurrAsmList,OS_ADDR,href,paraloc1);
-                                end
-                              else
-                                begin
-                                  { winlike widestrings have a 4 byte length }
-                                  dec(href.offset,4-offsetdec);
-                                  cg.a_load_ref_cgpara(current_asmdata.CurrAsmList,OS_32,href,paraloc1);
-                                end;
-
-                              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
-                              paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
-                              cg.allocallcpuregisters(current_asmdata.CurrAsmList);
-                              cg.a_call_name(current_asmdata.CurrAsmList,'FPC_'+upper(tstringdef(left.resultdef).stringtypname)+'_RANGECHECK',false);
-                              cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
-                           end;
-                         st_shortstring:
-                           begin
-                              {!!!!!!!!!!!!!!!!!}
-                           end;
-                         st_longstring:
-                           begin
-                              {!!!!!!!!!!!!!!!!!}
-                           end;
-                      end;
-                   end;
+                   rangecheck_string;
                end;
 
               { insert the register and the multiplication factor in the

+ 0 - 11
compiler/nset.pas

@@ -229,17 +229,6 @@ implementation
              exit;
           end;
 
-         if (right.nodetype=typen) then
-           begin
-             { we need to create a setconstn }
-             pst:=createsetconst(tsetdef(ttypenode(right).resultdef));
-             t:=csetconstnode.create(pst,ttypenode(right).resultdef);
-             dispose(pst);
-             right.free;
-             right:=t;
-             typecheckpass(right);
-           end;
-
          typecheckpass(left);
          set_varstate(left,vs_read,[vsf_must_be_valid]);
          if codegenerror then

+ 7 - 1
compiler/ogbase.pas

@@ -482,6 +482,7 @@ interface
         procedure GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);virtual;
         procedure GenerateDebugLink(const dbgname:string;dbgcrc:cardinal);
         function WriteExeFile(const fn:string):boolean;
+        procedure ParseScript (linkscript:TCmdStrList); virtual;
         property Writer:TObjectWriter read FWriter;
         property ExeSectionList:TFPHashObjectList read FExeSectionList;
         property ObjDataList:TFPObjectList read FObjDataList;
@@ -544,7 +545,7 @@ implementation
 
     procedure TObjSymbol.SetAddress(apass:byte;aobjsec:TObjSection;abind:TAsmsymbind;atyp:Tasmsymtype);
       begin
-        if not(abind in [AB_GLOBAL,AB_LOCAL,AB_COMMON]) then
+        if not(abind in [AB_GLOBAL,AB_LOCAL,AB_COMMON,AB_IMPORT]) then
           internalerror(200603016);
         if not assigned(aobjsec) then
           internalerror(200603017);
@@ -1549,6 +1550,11 @@ implementation
       end;
 
 
+    procedure TExeOutput.ParseScript (linkscript:TCmdStrList);
+      begin
+      end;
+
+
     function  TExeOutput.FindExeSection(const aname:string):TExeSection;
       begin
         result:=TExeSection(ExeSectionList.Find(aname));

+ 1516 - 0
compiler/ognlm.pas

@@ -0,0 +1,1516 @@
+{
+    Copyright (c) 1998-2006 by Peter Vreman
+    Copyright (c) 2011 by Armin Diehl
+
+    Contains the binary netware nlm executable writer
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit ognlm;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+       { common }
+       cclasses,globtype,
+       { target }
+       systems,
+       aasmbase,assemble,link,
+       { output }
+       ogbase,
+       owbase,
+       ogcoff;
+
+{*****************************************************************************
+                    NLM File structures and constants
+*****************************************************************************}
+
+{
+
+LString0 -> 1 byte Length, Text, #0
+LString  -> 1 byte length, Text
+
+Basic NLM File Structure:
+
+FixedHeader
+  nlm32_i386_external_fixed_header     130 bytes
+
+VarHdr1
+  NLM Description: LString0              2+n bytes
+  Stacksize                              4 bytes
+  reserved = 0                           4 bytes
+  ' LONG'                                5 bytes
+  NLM screen name: LString0              2+n bytes
+  NLM thread name: LString0              2+n bytes
+
+Optional Headers beginning with stamp (without '')
+'VeRsIoN#':   nlm32_i386_external_version_header     32 bytes
+'CoPyRiGhT=': LString0                              2+n bytes
+'MeSsAgEs':   nlm32_i386_external_extended_header   124 bytes
+'CuStHeAd':   nlm32_i386_external_custom_header
+'CyGnUsEx':   nlm32_i386_external_cygnus_ext_header 16 bytes
+
+.text
+.data
+.relocs=
+  addr(32),addr(32),...
+  addr and $80000000 > 0 -> FixupToSeg=.text else .data
+  addr and $40000000 > 0 -> FixupInSeg=.text else .data
+.importedSymbols
+  name   LString                                   1+n bytes
+  number of references r                             4 bytes
+  addresses                                        r*4 bytes
+.exportedSymbols
+  name   LString                                   1+n bytes
+  addr                                               4 bytes
+    addr and $80000000 > 0 -> .text else .data
+  ...
+.modules
+
+.nlmdebugrecs
+  type (0=.data,1=.code,2,..=????)                   1 byte
+  addr                                               4 bytes
+  name LString                                     1+n bytes
+  ...
+
+}
+
+
+const NLM_MAX_DESCRIPTION_LENGTH = 127;
+      NLM_MAX_SCREEN_NAME_LENGTH = 71;
+      NLM_MAX_THREAD_NAME_LENGTH = 71;   // some netware docs limit this to 12 ?
+      NLM_OLD_THREAD_NAME_LENGTH = 5;
+      NLM_HEADER_VERSION         = 4;
+      NLM_DEFAULT_STACKSIZE      = (32 * 1024);
+      NLM_VERSION_STAMP          = 'VeRsIoN#';
+      NLM_COPYRIGHT_STAMP        = 'CoPyRiGhT=';
+      NLM_CYGNUS_STAMP           = 'CyGnUsEx';
+      NLM_MESSAGES_STAMP         = 'MeSsAgEs';
+      NLM_CUSTOM_STAMP           = 'CuStHeAd';
+      NLM_SIGNATURE              = 'NetWare Loadable Module'#$1A;
+      NLM_FLAGS_REENTRANT        = 1;
+      NLM_FLAGS_MULTILOAD        = 2;
+      NLM_FLAGS_SYNCHRONIZE      = 4;
+      NLM_FLAGS_PSEUDOPREEMPTION = 8;
+      NLM_FLAGS_OSDOMAIN         = $10;
+      NLM_FLAGS_AUTOUNLOAD       = $40;
+
+
+  type
+    uint32 = longword;
+
+    nlm32_i386_external_fixed_header = packed record
+        signature                  : array[0..23] of char;
+        version                    : uint32;
+        (* The name of the module, which must be a DOS name (1-8 characters followed
+           by a period and a 1-3 character extension).  The first byte is the byte
+           length of the name and the last byte is a null terminator byte.  This
+           field is fixed length, and any unused bytes should be null bytes.  The
+           value is set by the OUTPUT keyword to NLMLINK. *)
+        moduleName                 : string[13]; //array[0..13] of byte;
+        codeImageOffset            : uint32;     // The byte offset of the code image from the start of the file.
+        codeImageSize              : uint32;     // The size of the code image, in bytes.
+        dataImageOffset            : uint32;     // The byte offset of the data image from the start of the file.
+        dataImageSize              : uint32;     // The size of the data image, in bytes.
+        uninitializedDataSize      : uint32;     // The size of the uninitialized data region that the loader has to be
+                                                 // allocated at load time.  Uninitialized data follows the initialized
+                                                 // data in the NLM address space.
+        customDataOffset           : uint32;     // The byte offset of the custom data from the start of the file.  The
+                                                 // custom data is set by the CUSTOM keyword to NLMLINK.  It is possible
+                                                 // for this to be EOF if there is no custom data.
+        customDataSize             : uint32;     // The size of the custom data, in bytes.
+        moduleDependencyOffset     : uint32;     // The byte offset of the module dependencies from the start of the file.
+                                                 // The module dependencies are determined by the MODULE keyword in NLMLINK.
+        numberOfModuleDependencies : uint32;     // he number of module dependencies at the moduleDependencyOffset.
+        relocationFixupOffset      : uint32;     // The byte offset of the relocation fixup data from the start of the file
+        numberOfRelocationFixups   : uint32;
+        externalReferencesOffset   : uint32;
+        numberOfExternalReferences : uint32;
+        publicsOffset              : uint32;
+        numberOfPublics            : uint32;
+        debugInfoOffset            : uint32;     // The byte offset of the internal debug info from the start of the file.
+                                                 // It is possible for this to be EOF if there is no debug info.
+        numberOfDebugRecords       : uint32;
+        codeStartOffset            : uint32;
+        exitProcedureOffset        : uint32;
+        checkUnloadProcedureOffset : uint32;
+        moduleType                 : uint32;
+        flags                      : uint32;
+      end;
+
+
+  { The version header is one of the optional auxiliary headers and
+     follows the fixed length and variable length NLM headers.  }
+  { The header is recognized by "VeRsIoN#" in the stamp field.  }
+
+     nlm32_i386_external_version_header = packed record
+          stamp           : array[0..7] of char;  // VeRsIoN#
+          majorVersion,
+          minorVersion,
+          revision,
+          year,
+          month,
+          day             : uint32;
+       end;
+  { The header is recognized by "MeSsAgEs" in the stamp field.  }
+
+     nlm32_i386_external_extended_header = packed record
+          stamp                        : array[0..7] of char;  // MeSsAgEs
+          languageID                   : uint32;
+          messageFileOffset            : uint32;
+          messageFileLength            : uint32;
+          messageCount                 : uint32;
+          helpFileOffset               : uint32;
+          helpFileLength               : uint32;
+          RPCDataOffset                : uint32;
+          RPCDataLength                : uint32;
+          sharedCodeOffset             : uint32;
+          sharedCodeLength             : uint32;
+          sharedDataOffset             : uint32;
+          sharedDataLength             : uint32;
+          sharedRelocationFixupOffset  : uint32;
+          sharedRelocationFixupCount   : uint32;
+          sharedExternalReferenceOffset: uint32;
+          sharedExternalReferenceCount : uint32;
+          sharedPublicsOffset          : uint32;
+          sharedPublicsCount           : uint32;
+          sharedDebugRecordOffset      : uint32;
+          sharedDebugRecordCount       : uint32;
+          SharedInitializationOffset   : uint32;
+          SharedExitProcedureOffset    : uint32;
+          productID : longint;
+          reserved0 : longint;
+          reserved1 : longint;
+          reserved2 : longint;
+          reserved3 : longint;
+          reserved4 : longint;
+          reserved5 : longint;
+       end;
+
+     nlm32_i386_external_custom_header = packed record
+          stamp       : array[0..7] of char;  // CuStHeAd
+          hdrLength   : uint32;
+          dataOffset  : uint32;
+          dataLength  : uint32;
+          //dataStamp   : array[0..7] of char;
+          //hdr         : uint32;
+       end;
+  { The internal Cygnus header is written out externally as a custom
+     header.  We don't try to replicate that structure here.   }
+  { The header is recognized by "CyGnUsEx" in the stamp field.  }
+  { File location of debugging information.   }
+  { Length of debugging information.   }
+
+     nlm32_i386_external_cygnus_ext_header = packed record
+          stamp       : array[0..7] of char;  // CyGnUsEx
+          offset      : uint32;
+          length      : uint32;
+       end;
+
+
+//------------------
+
+
+       TNLMExeSection = class(TExeSection)
+       public
+         constructor createnw(AList:TFPHashObjectList;const n:string);
+       end;
+
+       TsecType = (Section_text,Section_data,Section_other);
+
+       TNLMexeoutput = class(texeoutput)
+       private
+         FRelocsGenerated,FImportsGenerated : boolean;
+         FNumRelocs         : longword;
+         FNumExternals      : longword;
+         FNumModules        : longword;
+         FNumDebugSymbols   : longword;
+         fSizeWoDebugSyms   : longword;
+         FnumExports        : longword;
+         NlmSymbols         : TDynamicArray;
+         ExeSecsListSize    : longint;
+         nlmImpNames,                            // name of import. module name as import
+         nlmImports         : TFPHashObjectList; // name of import, list of relocs as object
+         headerAlignBytes   : longint;
+         FexportFunctionOffsets:TFPList;    // offsets in .exports for function addresses, an offset of $80000000 is needed
+
+         nlmHeader          : nlm32_i386_external_fixed_header;
+         nlmVersionHeader   : nlm32_i386_external_version_header;
+         nlmExtHeader       : nlm32_i386_external_extended_header;
+         nlmCustHeader      : nlm32_i386_external_custom_header;
+         nlmHelpFileName    : TCmdStr;
+         nlmMessagesFileName: TCmdStr;
+         nlmXdcFileName     : TCmdStr;
+         nlmCopyright       : string;
+         nlmThreadname      : string;
+         nlmScreenname      : string;
+         nlmDescription     : string;
+
+         function  totalheadersize:longword;
+         procedure createNlm_symbol(const name:shortstring;value:longword;secType:TSecType);
+         procedure globalsyms_create_symbol(p:TObject;arg:pointer);
+         procedure ExeSectionList_write_header(p:TObject;arg:pointer);
+         procedure ExeSectionList_calc_size(p:TObject;arg:pointer);
+         procedure ExeSectionList_write_data(p:TObject;arg:pointer);
+         procedure GenerateImports;
+         procedure GenerateExports;
+         procedure GenerateRelocs;
+         procedure ExeSectionList_pass2_header(p:TObject;arg:pointer);
+       protected
+         function writedata:boolean;override;
+       public
+         constructor create; override;
+         destructor destroy; override;
+         procedure MemPos_Header;override;
+         procedure DataPos_Header;override;
+         procedure fillNlmVersionHeader;
+         procedure GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);override;
+         procedure Order_End;override;
+         procedure MemPos_ExeSection(const aname:string);override;
+         procedure DataPos_ExeSection(const aname:string);override;
+         procedure NLMwriteString (const s : string; terminateWithZero : boolean);
+         procedure objNLMwriteString (const s : string; terminateWithZero : boolean);
+         procedure ParseScript (linkscript:TCmdStrList); override;
+       end;
+
+    var
+      {for symbols defined in linker script. To generate a fixup we
+       need to know the segment (.text,.bss or .code) of the symbol
+       Pointer in list is used as TsecType
+       Filled by TInternalLinkerNetware.DefaultLinkScript }
+      nlmSpecialSymbols_Segments : TFPHashList;
+
+    type
+
+      TNLMCoffObjInput = class(TCoffObjInput)
+         constructor create;override;
+       end;
+
+       TNLMCoffassembler = class(tinternalassembler)
+         constructor create(smart:boolean);override;
+       end;
+
+      TNLMCoffObjData = class(TCoffObjData)
+         constructor create(const n:string);override;
+       end;
+
+      TNLMCoffObjOutput = class(TCoffObjOutput)
+         constructor create(AWriter:TObjectWriter);override;
+       end;
+
+      TNLMCoffObjSection = class(TCoffObjSection)
+         constructor create(AList:TFPHashObjectList;const Aname:string;Aalign:shortint;Aoptions:TObjSectionOptions);override;
+       end;
+
+implementation
+
+    uses
+{$ifdef win32}
+       Windows,
+{$endif win32}
+       SysUtils,
+       cutils,verbose,globals,
+       fmodule,aasmdata,
+       ogmap,export
+       ;
+
+
+{****************************************************************************
+                                 Helpers
+****************************************************************************}
+type
+  TStringObj = class (TObject)
+     fValue : string;
+     constructor create (value:string);
+     property value : string read fValue write fValue;
+  end;
+
+  constructor TStringObj.create(value:string);
+  begin
+    inherited create;
+    fValue := value;
+  end;
+
+
+
+function SectionType (aName : string) : TSecType;
+var s : string;
+    seg: ptruint;
+begin
+  s := copy(aName,1,5);
+  if s = '.text' then result := Section_text else
+    if (s = '.data') or (copy(s,1,4)='.bss') then result := Section_data else
+      if s[1] <> '.' then
+        begin
+          seg := ptruint(nlmSpecialSymbols_Segments.Find(aName));
+          if seg <> 0 then
+            result := TSecType(seg)
+          else
+            result := Section_other;
+        end else
+      result := Section_other;
+end;
+
+{****************************************************************************
+                              TNLMexesection
+****************************************************************************}
+
+
+    constructor TNLMExeSection.createnw(AList:TFPHashObjectList;const n:string);
+      begin
+        inherited create(AList,n);
+      end;
+
+
+{****************************************************************************
+                              TNLMexeoutput
+****************************************************************************}
+
+    constructor TNLMexeoutput.create;
+      begin
+        inherited create;
+        CExeSection:=TNLMExeSection;
+        CObjData:=TNLMCoffObjData;
+        MaxMemPos:=$7FFFFFFF;
+        SectionMemAlign:=$0;
+        SectionDataAlign:=0;
+        RelocSection := true;  // always needed for NLM's
+        nlmImports := TFPHashObjectList.create(true);
+        nlmImpNames := TFPHashObjectList.create(false);
+        NlmSymbols := TDynamicArray.create(4096);
+        FexportFunctionOffsets := TFPList.Create;
+      end;
+
+    destructor TNLMexeoutput.destroy;
+      begin
+        if assigned(nlmImports) then
+          nlmImports.Free;
+        if assigned(nlmImpNames) then
+          nlmImpNames.Free;
+        if assigned(nlmSymbols) then
+          nlmSymbols.Free;
+        if assigned(FexportFunctionOffsets) then
+          FexportFunctionOffsets.Free;
+        inherited destroy;
+      end;
+
+    procedure TNLMexeoutput.createNlm_symbol(const name:shortstring;value:longword;secType:TSecType);
+      var
+        b:byte;
+      begin
+        //Comment (V_Debug,'TNLMexeoutput.write_symbol '+name);
+        {  type (0=.data,1=.code,2,..=????)                   1 byte
+           addr                                               4 bytes
+           name LString                                     1+n bytes }
+        case secType of
+          Section_Text : b := 1;
+          Section_Data : b := 0
+        else
+          exit;
+        end;
+        nlmSymbols.write(b,sizeof(b));
+        assert (sizeof(value)<>4);
+        nlmSymbols.write(value,sizeof(value));
+        nlmSymbols.write(name[0],length(name)+1);
+        inc(FNumDebugSymbols);
+      end;
+
+
+    procedure TNLMexeoutput.globalsyms_create_symbol(p:TObject;arg:pointer);
+      var
+        value  : longword;
+        exesec : TExeSection;
+        i : integer;
+        secType : TsecType;
+      begin
+        if not assigned(texesymbol(p).objsymbol) then
+          internalerror(200603053);
+        with texesymbol(p).objsymbol do
+          begin
+            exesec:=TExeSection(objsection.exesection);
+            { There is no exesection defined for special internal symbols
+              like __image_base__ }
+            if assigned(exesec) then
+              begin
+                //secval:=exesec.secsymidx;
+                value:=address-exesec.mempos;
+              end
+            else
+              begin
+                value:=address;
+              end;
+            { reloctype address to the section in the executable }
+            secType := SectionType(objsection.Name);
+            if (secType = Section_Text) or (secType = Section_Data) then
+              begin
+                i := nlmImports.FindIndexOf(texesymbol(p).name);
+                if i < 0 then
+                  createNlm_symbol(name,value,secType);
+              end;
+          end;
+      end;
+
+
+
+(*
+function SecOpts(SecOptions:TObjSectionOptions):string;
+    begin
+      result := '[';
+      if oso_Data in SecOptions then result := result + 'oso_Data ';
+       { Is loaded into memory }
+      if oso_load in SecOptions then result := result + 'oso_load ';
+       { Not loaded into memory }
+      if oso_noload in SecOptions then result := result + 'oso_noload ';
+       { Read only }
+      if oso_readonly in SecOptions then result := result + 'oso_readonly ';
+       { Read/Write }
+      if oso_write in SecOptions then result := result + 'oso_write ';
+       { Contains executable instructions }
+      if oso_executable in SecOptions then result := result + 'oso_executable ';
+       { Never discard section }
+      if oso_keep in SecOptions then result := result + 'oso_keep ';
+       { Special common symbols }
+      if oso_common in SecOptions then result := result + 'oso_common ';
+       { Contains debug info and can be stripped }
+      if oso_debug in SecOptions then result := result + 'oso_debug ';
+       { Contains only strings }
+      if oso_strings in SecOptions then result := result + 'oso_strings ';
+      result := result + ']';
+    end;
+*)
+
+    procedure TNLMexeoutput.ExeSectionList_calc_size(p:TObject;arg:pointer);
+      var
+        objsec : TObjSection;
+        i    : longint;
+      begin
+        with texesection(p) do
+          begin
+            { don't write normal section if writing only debug info }
+            if (ExeWriteMode=ewm_dbgonly) and
+               not(oso_debug in SecOptions) then
+              exit;
+
+            if oso_data in secoptions then
+              begin
+                inc (fSizeWoDebugSyms,(Align(fSizeWoDebugSyms,SectionDataAlign)-fSizeWoDebugSyms));
+                for i:=0 to ObjSectionList.Count-1 do
+                  begin
+                    objsec:=TObjSection(ObjSectionList[i]);
+                    if oso_data in objsec.secoptions then
+                      begin
+                        inc(fSizeWoDebugSyms,objsec.size);
+                        inc(fSizeWoDebugSyms,objsec.dataalignbytes);
+                      end;
+                  end;
+              end;
+          end;
+      end;
+
+
+
+    procedure TNLMexeoutput.ExeSectionList_write_Data(p:TObject;arg:pointer);
+      var
+        objsec : TObjSection;
+        i,j    : longint;
+        b      : byte;
+      begin
+
+        with texesection(p) do
+          begin
+            { don't write normal section if writing only debug info }
+            if (ExeWriteMode=ewm_dbgonly) and
+               not(oso_debug in SecOptions) then
+              exit;
+
+            if oso_data in secoptions then
+              begin
+                //if Align(FWriter.Size,SectionDataAlign)-FWriter.Size>0 then
+                //  writeln (name,' align ',Align(FWriter.Size,SectionDataAlign)-FWriter.Size,' SectionDataAlign:',SectionDataAlign);
+                FWriter.Writezeros(Align(FWriter.Size,SectionDataAlign)-FWriter.Size);
+                for i:=0 to ObjSectionList.Count-1 do
+                  begin
+                    objsec:=TObjSection(ObjSectionList[i]);
+                    if oso_data in objsec.secoptions then
+                      begin
+                        if assigned(exemap) then
+                          if objsec.data.size > 0 then
+                            exemap.Add('  0x'+hexstr(objsec.DataPos,8)+': '+objsec.name);
+                        //writeln ('   ',objsec.name,'  size:',objsec.size,'  relocs:',objsec.ObjRelocations.count,'  DataPos:',objsec.DataPos,' MemPos:',objsec.MemPos);
+                        {for j := 0 to objsec.ObjRelocations.count-1 do
+                          begin
+                            objreloc := TObjRelocation(objsec.ObjRelocations[j]);
+                            with objreloc do
+                            begin
+                              write('        reloc DataOffset: ',DataOffset,'  OrgSize:',OrgSize,' typ:',typ);
+                              if assigned(symbol) then
+                                write(' Name: '#39,symbol.Name,#39' bind:',symbol.bind,' address:',symbol.address,' Size:',symbol.size);
+                              writeln;
+                            end;
+                          end;}
+                        if not assigned(objsec.data) then
+                          internalerror(200603042);
+                        if copy (objsec.Name,1,5) = '.text' then
+                          begin        // write NOP's instead of zero's for .text, makes disassemble possible
+                            b := $90;  // NOP
+                            if objsec.DataAlignBytes > 0 then
+                              for j := 1 to objsec.DataAlignBytes do
+                                FWriter.write(b,1);
+                          end else
+                            FWriter.writezeros(objsec.dataalignbytes);
+                        //if objsec.dataalignbytes>0 then
+                        //  writeln ('  ',name,'  alignbytes: ',objsec.dataalignbytes);
+                        if objsec.DataPos<>FWriter.Size then
+                            internalerror(200602251);
+                        FWriter.writearray(objsec.data);
+                      end else
+                      begin
+                        if assigned(exemap) then //TExeMap
+                          exemap.Add('                  skipping: '+objsec.name);
+                      end;
+                  end;
+              end;
+          end;
+      end;
+
+
+    function TNLMexeoutput.totalheadersize:longword;
+      var
+        varHdrSize,
+        optHdrSize,
+        hdrSize: longword;
+      begin
+        optHdrSize := 0;
+        inc(optHdrSize,2+length(nlmDescription));
+        inc(optHdrSize,8); // Stacksize+reserved
+        inc(optHdrSize,NLM_OLD_THREAD_NAME_LENGTH);
+        inc(optHdrSize,2+length(nlmScreenname));
+        inc(optHdrSize,2+length(nlmThreadname));
+
+        varHdrSize := 0;
+        if nwcopyright <> '' then
+          inc(varHdrSize,sizeof(NLM_COPYRIGHT_STAMP)+2+length(nlmCopyright));
+        hdrSize := sizeof(nlm32_i386_external_fixed_header)+
+                   sizeof(nlm32_i386_external_extended_header)+
+                   sizeof(nlm32_i386_external_custom_header)+
+                   sizeof(nlm32_i386_external_version_header)+     // always
+                   sizeof(nlm32_i386_external_cygnus_ext_header)+  // CyGnUsEx
+                   varHdrSize+optHdrSize+
+                   8;  // empty stamp
+        result := hdrSize;
+      end;
+
+
+    procedure TNLMexeoutput.MemPos_Header;
+      begin
+        { calculate start positions after the headers }
+        currmempos:=0;
+      end;
+
+
+  procedure TNLMexeoutput.ExeSectionList_write_header(p:TObject;arg:pointer);
+  var
+    nam : string;
+    u32,al : longword;
+    alignAmount:longint;
+      begin
+        with tExeSection(p) do
+          begin
+            //comment (v_debug,'ExeSectionList_write_header: '+name);
+            nam := name;
+            alignAmount := 4 - ((length (nam) + 1) MOD 4);
+            FWriter.write(nam[1],length(nam));
+            FWriter.WriteZeros(1+alignAmount);
+            al := 0;
+            // for .stab we have to ignore leading zeros due to alignment in file
+            if nam='.stab' then
+              if assigned(ObjSectionList[0]) then
+                al := TObjSection(ObjSectionList[0]).dataalignbytes;
+            u32 := dataPos+al; FWriter.write(u32,sizeof(u32));
+            u32 := size-al; FWriter.write(u32,sizeof(u32));
+          end;
+      end;
+
+
+
+    procedure TNLMexeoutput.ExeSectionList_pass2_header(p:TObject;arg:pointer);
+    var len,alignAmount:longint;
+      begin
+        {list of sections, extension of binutils,CuStHeAd points to this list
+          The format of the section information is:
+           null terminated section name
+           zeroes to adjust to 4 byte boundary
+           4 byte section data file pointer
+           4 byte section size }
+
+        with TExeSection(p) do
+          begin
+            alignAmount := 4 - ((length (Name) + 1) MOD 4);
+            len := length(name) + 1 + alignAmount + 8;
+            if ObjSectionList.Count>0 then
+              inc(len,TObjSection(ObjSectionList[0]).dataalignbytes);
+            inc(plongint(arg)^,len);
+          end;
+      end;
+
+    procedure TNLMexeoutput.DataPos_Header;
+      begin
+        ExeSecsListSize:=0;
+        ExeSectionList.ForEachCall(@ExeSectionList_pass2_header,@ExeSecsListSize);
+
+        headerAlignBytes := align(totalheadersize+ExeSecsListSize,16)-(totalheadersize+ExeSecsListSize);  // align as in TObjData.sectiontype2align
+        currdatapos:=totalheadersize+ExeSecsListSize+headerAlignBytes;
+      end;
+
+
+    procedure TNLMexeoutput.fillNlmVersionHeader;
+    var
+        hour,min,sec,hsec,Year,Month,Day : word;
+    begin
+      DecodeTime(Time,hour,min,sec,hsec);
+      DecodeDate(Date,year,month,day);
+      nlmVersionHeader.stamp := NLM_VERSION_STAMP;
+      if nlmVersionHeader.year = 0 then
+        begin
+          nlmVersionHeader.year := Year;
+          nlmVersionHeader.month := Month;
+          nlmVersionHeader.day := Day;
+        end;
+    end;
+
+
+
+    function TNLMexeoutput.writedata:boolean;
+      var
+        dummyLong       : array[0..4] of char;
+        textExeSec,
+        dataExeSec,
+        bssExeSec,
+        relocsExeSec,
+        exportsExeSec,
+        importsExeSec,
+        xdcExeSec,
+        messagesExeSec,
+        helpExeSec,
+        customExeSec    : TExeSection;
+        hassymbols      : boolean;
+        nlmCygnusHeader : nlm32_i386_external_cygnus_ext_header;
+        ModuleName      : string;
+        exesym          : TExeSymbol;
+        expOffset       : PtrUInt;
+        expAddr         : longword;
+        i               : integer;
+
+      begin
+        result:=false;
+        textExeSec:=FindExeSection('.text');
+        dataExeSec:=FindExeSection('.data');
+        bssExeSec:=FindExeSection('.bss');
+        relocsExeSec:=FindExeSection('.reloc');
+        importsExeSec:=FindExeSection('.imports');
+        exportsExeSec:=FindExeSection('.exports');
+        xdcExeSec:=FindExeSection('.xdc');
+        messagesExeSec:=FindExeSection('.messages');
+        helpExeSec:=FindExeSection('.help');
+        customExeSec:=FindExeSection('.custom');
+
+        // exported function need the upper bit in the address
+        // to be set (=CODE), do this here to avoid another
+        // reloc type. The ExportFunctionOffsets list was
+        // filled in GenerateExports
+        if FexportFunctionOffsets.Count>0 then
+          begin
+            if not assigned(exportsExeSec) then
+              internalerror(201103201);   // we have to have a .export section
+            if not assigned(exportsExeSec.ObjSectionList[0]) then
+              internalerror(201103202);   // nothing in the .exports section but we have data in FexportFunctionOffsets
+            for i := 0 to FexportFunctionOffsets.Count-1 do
+              begin
+                expOffset := PtrUint(FexportFunctionOffsets[i]);
+                if TObjSection(exportsExeSec.ObjSectionList[0]).Data.size < expOffset+3 then
+                  internalerror(201103203);  // offset in FexportFunctionOffsets out of range
+                with TObjSection(exportsExeSec.ObjSectionList[0]) do
+                begin  // set the upper bit of address to indicate .text
+                  Data.seek(expOffset);
+                  Data.read(expAddr,4);
+                  Data.seek(expOffset);
+                  expAddr := expAddr or $80000000;
+                  Data.write(expAddr,4);
+                end;
+              end;
+           end;
+
+        if not assigned(TextExeSec) or
+           not assigned(RelocsExeSec) or
+           not assigned(DataExeSec) then
+          internalerror(200602231);   // we have to have .data, .text and .reloc
+        { do we need to write symbols? }
+        hassymbols:=(ExeWriteMode=ewm_dbgonly) or
+                    (
+                     (ExeWriteMode=ewm_exefull) and
+                     not(cs_link_strip in current_settings.globalswitches)
+                    );
+
+        { Initial header, will be updated later }
+        nlmHeader.signature := NLM_SIGNATURE;
+        nlmHeader.version := NLM_HEADER_VERSION;
+        moduleName := upperCase(current_module.exefilename^);
+        nlmHeader.moduleName := moduleName;
+        nlmHeader.codeImageOffset := TextExeSec.DataPos+TObjSection(TextExeSec.ObjSectionList[0]).dataalignbytes; // ??? may be that align has to be moved to fixups/imports
+        nlmHeader.codeImageSize := TextExeSec.Size;
+        nlmHeader.dataImageOffset := DataExeSec.DataPos;
+        nlmHeader.dataImageSize := DataExeSec.Size;
+        if assigned(BSSExeSec) then
+          nlmHeader.uninitializedDataSize:=BSSExeSec.Size;
+        if assigned(customExeSec) then
+          begin
+            nlmHeader.customDataOffset := customExeSec.DataPos;
+            nlmHeader.customDataSize := customExeSec.Size;
+          end;
+        if FNumModules > 0 then
+          begin
+            nlmHeader.moduleDependencyOffset := FindExeSection('.modules').DataPos+4;  // 4 bytes dummy
+            nlmHeader.numberOfModuleDependencies := FNumModules;
+          end;
+        nlmHeader.relocationFixupOffset := relocsExeSec.DataPos;
+        nlmHeader.numberOfRelocationFixups := FNumRelocs;
+        nlmHeader.externalReferencesOffset := importsExeSec.DataPos+4;  // 4 bytes dummy
+        nlmHeader.numberOfExternalReferences := FNumExternals;
+        if assigned(exportsExeSec) then
+          if exportsExeSec.Size>0 then
+          begin
+            nlmHeader.publicsOffset := exportsExeSec.dataPos;
+            nlmHeader.numberOfPublics := FnumExports;
+          end;
+        nlmHeader.codeStartOffset := EntrySym.Address;
+
+        {exit function}
+        exesym:=texesymbol(ExeSymbolList.Find('_Stop'));
+        if assigned(exesym) then
+          nlmHeader.exitProcedureOffset := exesym.ObjSymbol.address;
+
+        {check exit function}
+        exesym:=texesymbol(ExeSymbolList.Find('FPC_NW_CHECKFUNCTION'));
+        if assigned(exesym) then
+          nlmHeader.checkUnloadProcedureOffset := exesym.ObjSymbol.address;
+
+        // calc file pos after all exesections
+        fSizeWoDebugSyms := totalheadersize + ExeSecsListSize + headerAlignBytes;
+        ExeSectionList.ForEachCall(@ExeSectionList_calc_size,nil);
+
+        nlmExtHeader.stamp := NLM_MESSAGES_STAMP;
+        //extHeader.languageID    // TODO: where to get this from ?
+        if assigned(messagesExeSec) then
+          begin
+           nlmExtHeader.messageFileOffset := messagesExeSec.DataPos;
+           nlmExtHeader.messageFileLength := messagesExeSec.Size;
+          end;
+        //nlmExtHeader.messageCount  // TODO: how is messageCount set ?
+        if assigned(helpExeSec) then
+          begin
+           nlmExtHeader.helpFileOffset := helpExeSec.DataPos;
+           nlmExtHeader.helpFileLength := helpExeSec.Size;
+          end;
+        //nlmExtHeader.productID     // TODO: were does this came from ?
+        if assigned(xdcExeSec) then
+          begin
+            nlmExtHeader.RPCDataOffset  := xdcExeSec.DataPos;
+            nlmExtHeader.RPCDataLength  := xdcExeSec.Size;
+          end;
+
+        if hassymbols then
+        begin
+          nlmHeader.debugInfoOffset := fSizeWoDebugSyms;
+          ExeSymbolList.ForEachCall(@globalsyms_create_symbol,nil);
+          nlmHeader.numberOfDebugRecords := FNumDebugSymbols;
+        end;
+
+        fillNlmVersionHeader;
+        FWriter.write(nlmHeader,sizeof(nlmHeader));
+
+        { variable header }
+        NLMWriteString(nlmDescription,true);
+        if stacksize < NLM_DEFAULT_STACKSIZE then stacksize := NLM_DEFAULT_STACKSIZE;
+        FWriter.Write(stacksize,4);
+        FWriter.writezeros(4);
+        dummyLong := ' LONG';
+        FWriter.Write(dummyLong,sizeof(dummyLong));  // old thread name
+        NLMWriteString(nlmScreenname,true);
+        NLMWriteString(nlmThreadname,true);
+
+        {version}
+        FWriter.Write(nlmVersionHeader,sizeof(nlmVersionHeader));
+        {copyright}
+        if nlmCopyright <> '' then
+        begin
+          FWriter.write(NLM_COPYRIGHT_STAMP,sizeof(NLM_COPYRIGHT_STAMP));
+          NLMWriteString(nlmCopyright,true);
+        end;
+        {messages}
+        FWriter.write(nlmExtHeader,sizeof(nlmExtHeader));
+
+        {custhead}
+        nlmCustHeader.stamp := NLM_CUSTOM_STAMP;
+        nlmCustHeader.dataLength := ExeSecsListSize;
+        nlmCustHeader.dataOffset := totalheadersize;
+        nlmCustHeader.hdrLength := $10;               // why 16 ?, this is what binutils write
+        FWriter.write(nlmCustHeader,sizeof(nlmCustHeader));
+
+        {CyGnUsEx}
+        // bfd has a strange way to read the sections:
+        // the section directory is written under CuStHeAd
+        // when bfd finds the neader "CyGnUsEx", it uses the
+        // offset and size from CuStHeAd to read the section table
+
+        nlmCygnusHeader.stamp  := NLM_CYGNUS_STAMP;  // CyGnUsEx
+        // ld writes some unknown values here, bfd irgnores the values at all
+        // lets write the offset and length of the segment table
+        nlmCygnusHeader.offset := nlmCustHeader.dataLength;
+        nlmCygnusHeader.length := nlmCustHeader.dataOffset;
+        FWriter.write(nlmCygnusHeader,sizeof(nlmCygnusHeader));
+        FWriter.WriteZeros(8);   // empty stamp + align next to 16 bytes
+
+        if FWriter.Size<>totalheadersize then
+          internalerror(201103061);               // headersize <> header written
+
+        { Section headers, CuStHeAd points to this section, not needed by
+          netware. Can be used to find the section in the nlm file, binutils
+          will use this section }
+        ExeSectionList.ForEachCall(@ExeSectionList_write_header,nil);
+        FWriter.WriteZeros(headerAlignBytes);
+        if FWriter.Size<>totalheadersize+ExeSecsListSize+headerAlignBytes then
+          internalerror(201103062);
+        { Section data }
+        if assigned(exemap) then
+          begin
+            exemap.Add('');
+            exemap.Add('NLM file offsets:');
+          end;
+        ExeSectionList.ForEachCall(@ExeSectionList_write_data,nil);
+
+        if hassymbols then
+          FWriter.writearray(NlmSymbols);  // specific symbols for the internal netware debugger
+
+        result:=true;
+      end;
+
+
+
+    procedure TNLMexeoutput.GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);
+      var
+        idata5objsection : TObjSection;
+        basedllname : string;
+
+        function AddImport(const afuncname,amangledname:string; isvar:boolean):TObjSymbol;
+        var
+          secname:string;
+        begin
+          //Comment (V_Debug,'TNLMexeoutput.GenerateLibraryImports.AddImport '+afuncName);
+          result:=nil;
+          if assigned(exemap) then
+            exemap.Add(' Importing Function '+afuncname);
+
+          if not isvar then
+            with internalobjdata do
+            begin
+              secname:=basedllname+'_i_'+amangledname;
+              idata5objsection:=createsection(sec_idata5, secname);
+              internalobjdata.SetSection(idata5objsection);
+              result:=internalobjdata.SymbolDefine('_'+amangledname,AB_IMPORT,AT_FUNCTION);
+            end;
+        end;
+
+      var
+        i,j           : longint;
+        ImportLibrary : TImportLibrary;
+        ImportSymbol  : TImportSymbol;
+        exesym        : TExeSymbol;
+        importAddressList : TFPObjectList;
+      begin
+        if ImportLibraryList.Count > 0 then
+          begin
+            {objsec:=}internalObjData.createsection('.imports',0,[oso_data,oso_keep]);
+            i := 0;
+            internalobjdata.writebytes(i,4);  // dummy to avoid deletion
+            {objsec:=}internalObjData.createsection('.modules',0,[oso_data,oso_keep]);
+            internalobjdata.writebytes(i,4);  // dummy to avoid deletion
+          end;
+        for i:=0 to ImportLibraryList.Count-1 do
+          begin
+            ImportLibrary:=TImportLibrary(ImportLibraryList[i]);
+            idata5objsection:=nil;
+            for j:=0 to ImportLibrary.ImportSymbolList.Count-1 do
+              begin
+                ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList[j]);
+                exesym:=TExeSymbol(ExeSymbolList.Find(ImportSymbol.MangledName));
+                if assigned(exesym) and
+                   (exesym.State<>symstate_defined) then
+                  begin
+                    basedllname:=ExtractFileName(ImportLibrary.Name);
+                    exesym.objsymbol:=AddImport(ImportSymbol.Name,ImportSymbol.MangledName,ImportSymbol.IsVar);
+                    exesym.State:=symstate_defined;
+                    importAddressList := TFPObjectList.create(false);
+                    nlmImports.Add(ImportSymbol.Name,importAddressList);
+                    if pos('.',basedllname) = 0 then
+                      basedllname := basedllname + '.nlm';
+                    nlmImpNames.Add(ImportSymbol.Name,TStringObj.create(lower(basedllname)));
+                  end;
+              end;
+          end;
+
+        PackUnresolvedExeSymbols('after DLL imports');
+        GenerateExports;
+      end;
+
+
+
+    procedure TNLMexeoutput.GenerateImports;
+    var
+        exesec,
+        impexesec  : TExeSection;
+        objsec     : TObjSection;
+        objreloc   : TObjRelocation;
+        i,j,k      : integer;
+        importAddressList : TFPObjectList;
+        name,mName : string;
+        b          : byte;
+        modules    : string;
+        modName    : TStringObj;
+    begin
+      if FImportsGenerated then exit;
+      FImportsGenerated := true;
+      impexesec:=FindExeSection('.imports');
+      if impexesec=nil then exit;
+
+      for i:=0 to ExeSectionList.Count-1 do
+        begin
+          exesec:=TExeSection(ExeSectionList[i]);
+          for j:=0 to exesec.ObjSectionList.count-1 do
+            begin
+              objsec:=TObjSection(exesec.ObjSectionList[j]);
+              if j=0 then
+                begin
+                  exesec.DataPos:=objSec.DataPos;
+                  exesec.MemPos:=objSec.MemPos;
+                end;
+              if (copy(objsec.name,1,5) <> '.text') and (copy(objsec.name,1,4) <> '.bss') and (copy(objsec.name,1,5) <> '.data') then
+                  continue;
+              for k:=0 to objsec.ObjRelocations.Count-1 do
+                begin
+                  objreloc := TObjRelocation(objsec.ObjRelocations[k]);
+                  if assigned(objreloc.symbol) then
+                    begin
+                      //writeln (objreloc.symbol.name,' ',objreloc.symbol.bind);
+                      if objreloc.symbol.bind = AB_IMPORT then
+                        begin
+                          importAddressList := TFPObjectList(nlmImports.Find(objreloc.symbol.name));
+                          if assigned(importAddressList) then
+                            begin
+                              objreloc.objsection := objsec;   // points to idata5
+                              importAddressList.Add(objreloc);
+                            end else
+                            begin
+                              comment(v_error,objreloc.symbol.name+' is external but not defined in nlm imports');
+                            end;
+                        end;
+                    end
+                end;
+            end;
+        end;
+
+      modules := '';
+      for i := 0 to nlmImports.count-1 do
+        begin
+          importAddressList := TFPObjectList(nlmImports.Items[i]);
+          if importAddressList.Count > 0 then
+            begin
+              name := nlmImports.NameOfIndex(i);
+
+              // find the module to be imported and add it to the list
+              // of modules to be auto loaded
+              modName := TStringObj(nlmImpNames.Find(name));
+              if assigned(modName) then
+                begin
+                  mName := modName.Value;
+                  if mName <> '' then
+                    if copy(mName,1,1) <> '!' then  // special, with ! only the imp will be included but no module is autoloaded, needed i.e. for netware.imp
+                      begin
+                        if pos(mName+';',modules) < 1 then
+                          begin
+                            modules := modules + mName + ';';
+                            inc(FNumModules);
+                          end;
+                      end;
+                end;
+              internalobjdata.SetSection(TObjSection(impexesec.ObjSectionList[0]));
+              objNLMwriteString (name,false);           // name of symbol
+              k := importAddressList.Count;
+              internalobjdata.writebytes(k,sizeof(k));    // number of references
+              inc(FNumExternals);
+              for j := 0 to importAddressList.Count-1 do
+                begin
+                  objreloc := TObjRelocation(importAddressList[j]);
+                  objsec := objreloc.objsection;
+                  if oso_executable in objreloc.objsection.SecOptions then
+                    begin
+                      if objreloc.typ <> RELOC_RELATIVE then comment(v_error,'reference to external symbols must be RELOC_RELATIVE');
+                      // TODO: how to check if size is 4 ????
+
+                      k := objsec.MemPos + objreloc.DataOffset;
+                      k := k or $40000000;
+                      // TODO: data|code if we support importing data symbols
+                      //       i do not know if this is possible with netware
+                      internalobjdata.writebytes(k,sizeof(k));    // address
+
+                      // the netware loader requires an offset at the import address
+                      // for call = E8 this is -4
+                      // TODO: how can we check the needed offset ??
+                      if objreloc.DataOffset > 0 then
+                        begin
+                          objsec.Data.seek(objreloc.DataOffset-1);
+                          objsec.data.read(b,1);
+                          if b <> $E8 then
+                            comment(v_error,'no rcall (E8) before imported symbol target address');
+                          k := -4;
+                          objsec.Data.write(k,sizeof(k));
+                        end else
+                        begin
+                          objsec.Data.seek(objreloc.DataOffset);
+                          k := 0;
+                          objsec.Data.write(k,sizeof(k));
+                        end;
+                        objreloc.typ := RELOC_NONE;  // to avoid that TCoffObjSection.fixuprelocs changes the address again
+                    end else
+                      comment(v_error,'Importing of symbols only supported for .text');
+                end;
+            end;
+        end;
+
+      exesec := FindExeSection('.modules');
+      if not assigned(exesec) then internalerror(201103272);  // exe section .modules does not exist ???
+      internalobjdata.SetSection(TObjSection(exesec.ObjSectionList[0]));
+      for i := 1 to FNumModules do
+        begin
+          name := GetToken(modules,';');
+          objNLMwriteString (name,false);
+        end;
+    end;
+
+
+    procedure TNLMexeoutput.GenerateExports;
+    var
+        hp  : texported_item;  { for exports }
+        len : byte;
+        addr: longword;
+        exesym : texesymbol;
+    begin
+      internalObjData.createsection('.exports',0,[oso_data,oso_keep]);
+      {name   LString                                   1+n bytes
+      addr                                               4 bytes
+      addr and $80000000 > 0 -> .text else .data}
+      hp:=texported_item(current_module._exports.first);
+      if assigned(hp) then
+        if assigned(exemap) then
+           exemap.Add('');
+      while assigned(hp) do
+        begin
+          { Export the Symbol }
+          if assigned(exemap) then
+            exemap.Add(' Exporting Function '+hp.sym.prettyname+' as '+hp.name^);
+          len := length(hp.name^);
+          internalobjdata.writebytes(len,1);
+          internalobjdata.writebytes(hp.name^[1],len);
+          exesym:=texesymbol(ExeSymbolList.Find(hp.sym.prettyname));
+          if not assigned(exesym) then
+          begin
+            comment(v_error,'exported symbol '+hp.sym.prettyname+' not found');
+            exit;
+          end;
+          // for exported functions we have to set the upper bit
+          // this will be done in .writedata
+          if not hp.is_var then
+            FexportFunctionOffsets.Add(pointer(PtrUInt(internalobjdata.CurrObjSec.Size)));
+          internalobjdata.writereloc(0,4,exesym.ObjSymbol,RELOC_ABSOLUTE32);
+
+          addr := 0;
+          internalobjdata.writebytes(addr,4);
+          inc(FnumExports);
+          hp:=texported_item(hp.next);
+        end;
+    end;
+
+    procedure TNLMexeoutput.GenerateRelocs;
+
+      var
+        exesec : TExeSection;
+        objsec : TObjSection;
+        objreloc : TObjRelocation;
+        i,j,k : longint;
+        offset : longword;
+        inSec,toSec : TsecType;
+        targetSectionName : string;
+
+      begin
+        if not RelocSection or FRelocsGenerated then
+          exit;
+        exesec:=FindExeSection('.reloc');
+        if exesec=nil then
+          exit;
+        objsec:=internalObjData.createsection('.reloc',0,exesec.SecOptions+[oso_data]);
+        exesec.AddObjSection(objsec);
+        for i:=0 to ExeSectionList.Count-1 do
+          begin
+            exesec:=TExeSection(ExeSectionList[i]);
+            for j:=0 to exesec.ObjSectionList.count-1 do
+              begin
+                objsec:=TObjSection(exesec.ObjSectionList[j]);
+                //writeln ('Relocs for ',exesec.name,' - ',objsec.name);
+                { create relocs only for sections which are loaded in memory }
+                if not (oso_load in objsec.SecOptions) then
+                  continue;
+                { create relocs only for .text and .data }
+                inSec := SectionType (objsec.name);
+                if (inSec <> Section_Text) and (inSec <> Section_Data) then
+                  continue;
+
+                for k:=0 to objsec.ObjRelocations.Count-1 do
+                  begin
+                    objreloc:=TObjRelocation(objsec.ObjRelocations[k]);
+                    if objreloc.typ <> RELOC_ABSOLUTE then
+                      continue;
+                    offset:=objsec.MemPos+objreloc.dataoffset;
+                    targetSectionName := '';
+                    if objreloc.symbol <> nil then
+                    begin
+                      // writeln ('  MemPos',objsec.MemPos,' dataOfs:',objreloc.dataoffset,' ',objsec.name,'   objreloc.symbol: ',objreloc.symbol.name,'  objreloc.symbol.objsection.name: ',objreloc.symbol.objsection.name,' ',objreloc.symbol.Typ,' ',objreloc.symbol.bind,' ',objreloc.Typ);
+                      if objreloc.symbol.objsection.name[1] <> '.' then
+                        targetSectionName := objreloc.symbol.name                       // specials like __bss_start__
+                      else                                                              // dont use objsection.name because it begins with *
+                        targetSectionName := copy(objreloc.symbol.objsection.name,1,5); // all others begin with .segment, we only have to check for .text, .data or .bss
+                    end else
+                      internalerror(2011030603);
+
+                    toSec := SectionType(targetSectionName);
+
+                    if (toSec = Section_Text) or (toSec = Section_Data) then
+                    begin
+                      if (inSec = Section_text) then offset := offset or $40000000;
+                      if (toSec = Section_text) then offset := offset or $80000000;
+                      internalObjData.writebytes(offset,4);
+                      inc(FNumRelocs);
+                    end;
+                  end;
+              end;
+          end;
+        FRelocsGenerated:=true;
+      end;
+
+
+    procedure TNLMexeoutput.Order_End;
+      var
+        exesec : TExeSection;
+      begin
+        inherited;
+        exesec:=FindExeSection('.reloc');
+        if exesec=nil then
+          exit;
+        exesec.SecOptions:=exesec.SecOptions + [oso_Data,oso_keep,oso_load];
+      end;
+
+
+      procedure TNLMexeoutput.MemPos_ExeSection(const aname:string);
+        begin
+          if aname='.reloc' then
+            GenerateRelocs;
+          if aname='.imports' then
+            GenerateImports;
+          if aname='.data' then
+            currMemPos := 0;  // both, data and code in the nlm have a start offset of 0
+          inherited;
+        end;
+
+
+      procedure TNLMexeoutput.DataPos_ExeSection(const aname:string);
+        begin
+          inherited;
+        end;
+
+
+      procedure TNLMexeoutput.NLMwriteString (const s : string; terminateWithZero : boolean);
+      var len : byte;
+        begin
+          if length(s) > 254 then len := 254 else len := length(s);
+          FWriter.Write(len,1);
+          if len > 0 then
+            FWriter.write(s[1],len);
+          if terminateWithZero then
+            FWriter.writeZeros(1);
+        end;
+
+
+      procedure TNLMexeoutput.objNLMwriteString (const s : string; terminateWithZero : boolean);
+      var len : byte;
+        begin
+          if length(s) > 254 then len := 254 else len := length(s);
+          Internalobjdata.writebytes(len,1);
+          if len > 0 then
+            Internalobjdata.writebytes(s[1],len);
+          if terminateWithZero then
+          begin
+            len := 0;
+            Internalobjdata.writebytes(s[1],len);
+          end;
+        end;
+
+      { parse netware specific linker options }
+      procedure TNLMexeoutput.ParseScript (linkscript:TCmdStrList);
+      var
+        hp : TCmdStrListItem;
+        opt,keyword,s : string;
+        i : integer;
+
+          function toInteger(s:string; min,max:integer; var res:integer):boolean;
+          var
+            code:word;
+          begin
+            result := false;
+            val (s,res,code);
+            if code<>0 then exit;
+            if (res < min) or (res > max) then exit;
+            result := true;
+          end;
+
+
+          procedure loadFile (const secName, fileName, Desc : string);
+          var
+            fileBuf : array [0..4095] of char;
+            bytesRead : longint;
+            fileH : THandle;
+            fn : TCmdStr;
+
+            begin
+              fn := fileName;
+              if not fileExists(fn) then
+               if not unitsearchpath.FindFile(fileName,true,fn) then
+                 begin
+                   comment(v_error,'can not find '+desc+' file '+fileName);
+                   exit;
+                 end;
+               fileH := fileOpen (fn,fmOpenRead);
+               if fileH = -1 then
+                 begin
+                   comment(v_error,'can not open '+desc+' file '+fn);
+                   exit;
+                  end;
+               { load file into section  }
+               internalObjData.createsection(secName,0,[oso_data,oso_keep]);
+               repeat
+                 bytesRead := fileRead(fileH,fileBuf,sizeof(fileBuf));
+                 if bytesRead > 0 then
+                   internalobjdata.writebytes(fileBuf,bytesRead);
+               until bytesRead < sizeof(fileBuf);
+               fileClose(fileH);
+            end;
+
+        begin
+          hp:=TCmdStrListItem(linkscript.first);
+          while assigned(hp) do
+            begin
+              opt:=hp.str;
+              if (opt='') or (opt[1]='#') then
+                continue;
+              keyword:=Upper(GetToken(opt,' '));
+              if keyword = 'AUTOUNLOAD' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_AUTOUNLOAD;
+                end else
+              if keyword = 'COPYRIGHT' then
+                begin
+                  nlmCopyright := GetToken(opt,' ');
+                end else
+              if keyword = 'CUSTOM' then
+                begin
+                  loadFile ('.custom',GetToken(opt,' '),'custom data');
+                end;
+              if keyword = 'DATE' then  // month day 4-digit-year
+              begin
+                if not toInteger(GetToken(opt,' '),1,12,i) then comment(v_error,'DATE: invalid month')
+                  else nlmVersionHeader.month := i;
+                if not toInteger(GetToken(opt,' '),1,31,i) then comment(v_error,'DATE: invalid day')
+                  else nlmVersionHeader.day := i;
+                if not toInteger(GetToken(opt,' '),1900,3000,i) then comment(v_error,'DATE: invalid year')
+                  else nlmVersionHeader.year := i;
+              end else
+              if keyword = 'DEBUG' then
+              begin
+                // ignore
+              end else
+              if keyword = 'DESCRIPTION' then
+                begin
+                  nlmDescription := GetToken(opt,' ');
+                  if length (nlmDescription) > NLM_MAX_DESCRIPTION_LENGTH then
+                    nlmDescription := copy (nlmDescription,1,NLM_MAX_DESCRIPTION_LENGTH);
+                end else
+              if keyword = 'FLAG' then
+                begin
+                  s := upper(GetToken(opt,' '));
+                  if (not toInteger(GetToken(opt,' '),1,$FFFFFFF,i)) or ((s <> 'ON') and (S <> 'OFF')) then comment(v_error,'FLAG: invalid') else
+                    if (s='ON') then
+                      nlmHeader.flags:=nlmHeader.flags or i else
+                    nlmHeader.flags:=nlmHeader.flags and ($FFFFFFF-i);
+                end else
+              if keyword = 'HELP' then
+                begin
+                  loadFile ('.help',GetToken(opt,' '),'help');
+                end else
+              if keyword = 'MESSAGES' then
+                begin
+                  loadFile ('.messages',GetToken(opt,' '),'message');
+                end else
+              if keyword = 'MULTIPLE' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_MULTILOAD;
+                end else
+              if keyword = 'OS_DOMAIN' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_OSDOMAIN;
+                end else
+              if keyword = 'PSEUDOPREEMPTION' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_PSEUDOPREEMPTION;
+                end else
+              if keyword = 'REENTRANT' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_REENTRANT;
+                end else
+              if keyword = 'SCREENNAME' then
+                begin
+                  nlmScreenname := GetToken(opt,' ');
+                  if length(nlmScreenname) > NLM_MAX_SCREEN_NAME_LENGTH then
+                   nlmScreenName := copy (nlmScreenName,1,NLM_MAX_SCREEN_NAME_LENGTH);
+                end else
+              if (keyword = 'STACK') or (keyword = 'STACKSIZE') then
+                begin
+                   if (not toInteger(GetToken(opt,' '),1,$FFFFFFF,i)) then comment(v_error,'invalid stacksize') else
+                     stacksize := i;
+                end else
+              if keyword = 'SYNCHRONIZE' then
+                begin
+                  nlmHeader.flags:=nlmHeader.flags or NLM_FLAGS_SYNCHRONIZE;
+                end else
+              if keyword = 'THREADNAME' then
+                begin
+                  nlmThreadname := GetToken(opt,' ');
+                  if length(nlmThreadname) > NLM_MAX_THREAD_NAME_LENGTH then
+                    nlmThreadname := copy (nlmThreadname,1,NLM_MAX_THREAD_NAME_LENGTH);
+                end else
+              if keyword = 'TYPE' then
+                begin
+                   if (not toInteger(GetToken(opt,' '),1,16,i)) then comment(v_error,'invalid TYPE') else
+                     nlmHeader.moduleType := i;  // TODO: set executable extension (.DSK, .LAN, ...)
+                end else
+              if keyword = 'VERSION' then
+                begin
+                   if (not toInteger(GetToken(opt,' '),0,$FFFFFFF,i)) then comment(v_error,'invalid major version') else
+                     nlmVersionHeader.majorVersion := i;
+                   if (not toInteger(GetToken(opt,' '),0,99,i)) then comment(v_error,'invalid minor version') else
+                     nlmVersionHeader.minorVersion := i;
+                   if (not toInteger(GetToken(opt,' '),0,$FFFFFFF,i)) then comment(v_error,'invalid minor version') else
+                     if i > 26 then
+                       nlmVersionHeader.revision := 0 else
+                       nlmVersionHeader.revision := i;
+                end else
+              if keyword = 'XDCDATA' then
+                begin
+                  loadFile ('.xdc',GetToken(opt,' '),'xdc');
+                end;
+                { TODO: check for unknown options. This means all handled option
+                  (also in link.pas) have to be flagged if processed }
+              hp:=TCmdStrListItem(hp.next);
+            end;
+        end;
+
+{****************************************************************************
+                                TNLMCoffObjData
+****************************************************************************}
+
+    constructor TNLMCoffObjData.create(const n:string);
+      begin
+        inherited createcoff(n,true,TNLMCoffObjSection);
+      end;
+
+
+{****************************************************************************
+                               TNLMoffObjSection
+****************************************************************************}
+
+    constructor TNLMCoffObjSection.create(AList:TFPHashObjectList;const aname:string;aalign:shortint;aoptions:TObjSectionOptions);
+      begin
+        inherited create(alist,aname,aalign,aoptions);
+      end;
+
+
+    constructor TNLMCoffObjOutput.create(AWriter:TObjectWriter);
+      begin
+        // ??????
+        // if win32=false, .stabs and .stabstr will be written without oso_debug
+        // Without oso_debug the sections will be removed by the linker
+        inherited createcoff(AWriter,{win32}true);
+        cobjdata:=TNLMCoffObjData;
+      end;
+
+{****************************************************************************
+                                 TDJCoffAssembler
+****************************************************************************}
+
+    constructor TNLMCoffAssembler.Create(smart:boolean);
+      begin
+        inherited Create(smart);
+        CObjOutput:=TNLMCoffObjOutput;
+      end;
+
+    constructor TNLMCoffObjInput.create;
+      begin
+        inherited createcoff(true);
+        cobjdata:=TNLMCoffObjData;
+      end;
+
+{*****************************************************************************
+                                  Initialize
+*****************************************************************************}
+const
+    as_i386_nlmcoff_info : tasminfo =
+          (
+            id     : as_i386_nlmcoff;
+            idtxt  : 'NLMCOFF';
+            asmbin : '';
+            asmcmd : '';
+            supported_targets : [system_i386_Netware,system_i386_netwlibc];
+            flags : [af_outputbinary,af_smartlink_sections];
+            labelprefix : '.L';
+            comment : '';
+          );
+
+
+
+initialization
+{$ifdef i386}
+  RegisterAssembler(as_i386_nlmcoff_info,TNLMCoffAssembler);
+{$endif i386}
+end.

+ 2 - 2
compiler/owar.pas

@@ -262,11 +262,11 @@ implementation
 
     procedure tarobjectwriter.writear;
       var
-        arf      : TCFileStream;
+        arf      : TCCustomFileStream;
         fixup,l,
         relocs,i : longint;
       begin
-        arf:=TCFileStream.Create(arfn,fmCreate);
+        arf:=CFileStreamClass.Create(arfn,fmCreate);
         if CStreamError<>0 then
           begin
              Message1(exec_e_cant_create_archivefile,arfn);

+ 4 - 4
compiler/owbase.pas

@@ -31,7 +31,7 @@ uses
 type
   tobjectwriter=class
   private
-    f      : TCFileStream;
+    f      : TCCustomFileStream;
     opened : boolean;
     buf    : pchar;
     bufidx : longword;
@@ -54,7 +54,7 @@ type
 
   tobjectreader=class
   private
-    f      : TCFileStream;
+    f      : TCCustomFileStream;
     opened : boolean;
     buf    : pchar;
     ffilename : string;
@@ -108,7 +108,7 @@ end;
 function tobjectwriter.createfile(const fn:string):boolean;
 begin
   createfile:=false;
-  f:=TCFileStream.Create(fn,fmCreate);
+  f:=CFileStreamClass.Create(fn,fmCreate);
   if CStreamError<>0 then
     begin
        Message1(exec_e_cant_create_objectfile,fn);
@@ -233,7 +233,7 @@ end;
 function tobjectreader.openfile(const fn:string):boolean;
 begin
   openfile:=false;
-  f:=TCFileStream.Create(fn,fmOpenRead);
+  f:=CFileStreamClass.Create(fn,fmOpenRead);
   if CStreamError<>0 then
     begin
        Comment(V_Error,'Can''t open object file: '+fn);

+ 4 - 2
compiler/paramgr.pas

@@ -366,7 +366,8 @@ implementation
               i386 isn't affected anyways because it uses the stack to push parameters
               on arm it reduces executable size of the compiler by 2.1 per cent (FK) }
             { Does it fit a register? }
-            if (not can_use_final_stack_loc or
+            if ((not can_use_final_stack_loc and
+                 use_fixed_stack) or
                 not is_stack_paraloc(paraloc)) and
                (len<=sizeof(pint)) and
                (paraloc^.size in [OS_8,OS_16,OS_32,OS_64,OS_128,OS_S8,OS_S16,OS_S32,OS_S64,OS_S128]) then
@@ -382,7 +383,8 @@ implementation
                 newparaloc^.register:=cg.getmmregister(list,paraloc^.size);
               LOC_REFERENCE :
                 begin
-                  if can_use_final_stack_loc and
+                  if (can_use_final_stack_loc or
+                      not use_fixed_stack) and
                      is_stack_paraloc(paraloc) then
                     duplicatecgparaloc(paraloc,newparaloc)
                   else

+ 4 - 3
compiler/pdecl.pas

@@ -397,7 +397,6 @@ implementation
          typename,orgtypename : TIDString;
          newtype  : ttypesym;
          sym      : tsym;
-         srsymtable : TSymtable;
          hdef     : tdef;
          defpos,storetokenpos : tfileposinfo;
          old_block_type : tblock_type;
@@ -462,8 +461,10 @@ implementation
                current_scanner.startrecordtokens(generictokenbuf);
              end;
 
-           { is the type already defined? }
-           searchsym(typename,sym,srsymtable);
+           { is the type already defined? -- must be in the current symtable,
+             not in a nested symtable or one higher up the stack -> don't
+             use searchsym & frinds! }
+           sym:=tsym(symtablestack.top.find(typename));
            newtype:=nil;
            { found a symbol with this name? }
            if assigned(sym) then

+ 2 - 1
compiler/pdecobj.pas

@@ -280,12 +280,13 @@ implementation
 
     procedure handleImplementedProtocol(intfdef : tobjectdef);
       begin
+        intfdef:=find_real_objcclass_definition(intfdef,false);
         if not is_objcprotocol(intfdef) then
           begin
              Message1(type_e_protocol_type_expected,intfdef.typename);
              exit;
           end;
-        if (oo_is_forward in intfdef.objectoptions) then
+        if ([oo_is_forward,oo_is_formal] * intfdef.objectoptions <> []) then
           begin
              Message1(parser_e_forward_protocol_declaration_must_be_resolved,intfdef.objrealname^);
              exit;

+ 2 - 2
compiler/pdecsub.pas

@@ -3084,7 +3084,7 @@ const
                 can be in a different location because of the calling convention, eg. L-R vs. R-L order (PFV) }
               (
                (compare_paras(currpd.paras,fwpd.paras,cp_none,[cpo_comparedefaultvalue,cpo_ignorehidden,cpo_openequalisexact,cpo_ignoreuniv])=te_exact) and
-               (fwpd.returndef=currpd.returndef)
+               (compare_defs(fwpd.returndef,currpd.returndef,nothingn)=te_exact)
               ) then
              begin
                { Check if we've found the forwarddef, if found then
@@ -3155,7 +3155,7 @@ const
                    if ((m_repeat_forward in current_settings.modeswitches) or
                        not is_bareprocdef(currpd)) and
                       ((compare_paras(currpd.paras,fwpd.paras,cp_all,paracompopt)<>te_exact) or
-                       (fwpd.returndef<>currpd.returndef)) then
+                       (compare_defs(fwpd.returndef,currpd.returndef,nothingn)<>te_exact)) then
                      begin
                        MessagePos1(currpd.fileinfo,parser_e_header_dont_match_forward,
                                    fwpd.fullprocname(false));

+ 6 - 6
compiler/pexpr.pas

@@ -1451,7 +1451,7 @@ implementation
                         {  e.g., "with classinstance do field := 5"), then    }
                         { let do_member_read handle it                        }
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
-                          do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[])
+                          do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[])
                         else
                           { otherwise it's a regular record subscript }
                           p1:=csubscriptnode.create(srsym,p1);
@@ -1507,7 +1507,7 @@ implementation
                                if assigned(srsym) then
                                  check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                consume(_ID);
-                               do_member_read(tobjectdef(hdef),false,srsym,p1,again,[]);
+                               do_member_read(tabstractrecorddef(hdef),false,srsym,p1,again,[]);
                              end
                            else
                             begin
@@ -1522,7 +1522,7 @@ implementation
                                 begin
                                   check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                       consume(_ID);
-                                      do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[]);
+                                      do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[]);
                                 end
                               else
                                 Message1(sym_e_id_no_member,orgpattern);
@@ -1547,7 +1547,7 @@ implementation
                                  begin
                                    check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
                                    consume(_ID);
-                                   do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[]);
+                                   do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[]);
                                  end
                                 else
                                  begin
@@ -1597,7 +1597,7 @@ implementation
                         { not srsymtable.symtabletype since that can be }
                         { withsymtable as well                          }
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
-                          do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[])
+                          do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[])
                         else
                           { no procsyms in records (yet) }
                           internalerror(2007012006);
@@ -1630,7 +1630,7 @@ implementation
                         { not srsymtable.symtabletype since that can be }
                         { withsymtable as well                          }
                         if (srsym.owner.symtabletype in [ObjectSymtable,recordsymtable]) then
-                          do_member_read(tobjectdef(hdef),getaddr,srsym,p1,again,[])
+                          do_member_read(tabstractrecorddef(hdef),getaddr,srsym,p1,again,[])
                         else
                           { no propertysyms in records (yet) }
                           internalerror(2009111510);

+ 40 - 41
compiler/ppu.pas

@@ -26,7 +26,7 @@ unit ppu;
 interface
 
   uses
-    globtype,constexp;
+    globtype,constexp,cstreams;
 
 { Also write the ppu if only crc if done, this can be used with ppudump to
   see the differences between the intf and implementation }
@@ -188,7 +188,7 @@ type
 
   tppufile=class
   private
-    f        : file;
+    f        : TCCustomFileStream;
     mode     : byte; {0 - Closed, 1 - Reading, 2 - Writing}
     fname    : string;
     fsize    : integer;
@@ -282,8 +282,8 @@ type
     procedure putstring(const s:string);
     procedure putnormalset(const b);
     procedure putsmallset(const b);
-    procedure tempclose;
-    function  tempopen:boolean;
+    procedure tempclose;        // MG: not used, obsolete?
+    function  tempopen:boolean; // MG: not used, obsolete?
   end;
 
 implementation
@@ -356,10 +356,7 @@ begin
   if Mode<>0 then
    begin
      Flush;
-     {$I-}
-      system.close(f);
-     {$I+}
-     if ioresult<>0 then;
+     f.Free;
      Mode:=0;
      closed:=true;
    end;
@@ -415,21 +412,17 @@ var
   i      : integer;
 begin
   openfile:=false;
-  assign(f,fname);
-  ofmode:=filemode;
-  filemode:=$0;
-  {$I-}
-   reset(f,1);
-  {$I+}
-  filemode:=ofmode;
-  if ioresult<>0 then
-   exit;
+  try
+    f:=CFileStreamClass.Create(fname,fmOpenRead)
+  except
+    exit;
+  end;
   closed:=false;
 {read ppuheader}
-  fsize:=filesize(f);
+  fsize:=f.Size;
   if fsize<sizeof(tppuheader) then
    exit;
-  blockread(f,header,sizeof(tppuheader),i);
+  i:=f.Read(header,sizeof(tppuheader));
   { The header is always stored in little endian order }
   { therefore swap if on a big endian machine          }
 {$IFDEF ENDIAN_BIG}
@@ -478,7 +471,7 @@ end;
 procedure tppufile.reloadbuf;
 begin
   inc(bufstart,bufsize);
-  blockread(f,buf^,ppubufsize,bufsize);
+  bufsize:=f.Read(buf^,ppubufsize);
   bufidx:=0;
 end;
 
@@ -827,6 +820,8 @@ end;
 *****************************************************************************}
 
 function tppufile.createfile:boolean;
+var
+  ok: boolean;
 begin
   createfile:=false;
 {$ifdef INTFPPU}
@@ -838,24 +833,26 @@ begin
 {$endif}
   if not crc_only then
     begin
-      assign(f,fname);
       {$ifdef MACOS}
       {FPas is FreePascal's creator code on MacOS. See systems/mac_crea.txt}
       SetDefaultMacOSCreator('FPas');
       SetDefaultMacOSFiletype('FPPU');
       {$endif}
-      {$I-}
-      rewrite(f,1);
-      {$I+}
+      ok:=false;
+      try
+        f:=CFileStreamClass.Create(fname,fmCreate);
+        ok:=true;
+      except
+      end;
       {$ifdef MACOS}
       SetDefaultMacOSCreator('MPS ');
       SetDefaultMacOSFiletype('TEXT');
       {$endif}
-      if ioresult<>0 then
+      if not ok then
        exit;
       Mode:=2;
     {write header for sure}
-      blockwrite(f,header,sizeof(tppuheader));
+      f.Write(header,sizeof(tppuheader));
     end;
   bufsize:=ppubufsize;
   bufstart:=sizeof(tppuheader);
@@ -904,10 +901,10 @@ begin
     header.symlistsize:=swapendian(header.symlistsize);
 {$endif not FPC_BIG_ENDIAN}
 { write header and restore filepos after it }
-  opos:=filepos(f);
-  seek(f,0);
-  blockwrite(f,header,sizeof(tppuheader));
-  seek(f,opos);
+  opos:=f.Position;
+  f.Position:=0;
+  f.Write(header,sizeof(tppuheader));
+  f.Position:=opos;
 end;
 
 
@@ -915,7 +912,7 @@ procedure tppufile.writebuf;
 begin
   if not crc_only and
      (bufidx <> 0) then
-    blockwrite(f,buf^,bufidx);
+    f.Write(buf^,bufidx);
   inc(bufstart,bufidx);
   bufidx:=0;
 end;
@@ -985,10 +982,10 @@ begin
       {flush to be sure}
         WriteBuf;
       {write entry}
-        opos:=filepos(f);
-        seek(f,entrystart);
-        blockwrite(f,entry,sizeof(tppuentry));
-        seek(f,opos);
+        opos:=f.Position;
+        f.Position:=entrystart;
+        f.write(entry,sizeof(tppuentry));
+        f.Position:=opos;
       end;
      entrybufstart:=bufstart;
    end
@@ -1152,11 +1149,8 @@ procedure tppufile.tempclose;
   begin
     if not closed then
      begin
-       closepos:=filepos(f);
-       {$I-}
-        system.close(f);
-       {$I+}
-       if ioresult<>0 then;
+       closepos:=f.Position;
+       f.Free;
        closed:=true;
        tempclosed:=true;
      end;
@@ -1170,6 +1164,10 @@ function tppufile.tempopen:boolean;
     tempopen:=false;
     if not closed or not tempclosed then
      exit;
+    // MG: not sure, if this is correct
+
+    f.Position:=0;
+    (*
     ofm:=filemode;
     filemode:=0;
     {$I-}
@@ -1178,11 +1176,12 @@ function tppufile.tempopen:boolean;
     filemode:=ofm;
     if ioresult<>0 then
      exit;
+    *)
     closed:=false;
     tempclosed:=false;
 
   { restore state }
-    seek(f,closepos);
+    f.Position:=closepos;
     tempopen:=true;
   end;
 

+ 65 - 0
compiler/procinfo.pas

@@ -47,10 +47,17 @@ unit procinfo;
 
 
     type
+       tsavedlabels = array[Boolean] of TAsmLabel;
+
        {# This object gives information on the current routine being
           compiled.
        }
        tprocinfo = class(tlinkedlistitem)
+       private
+          { list to store the procinfo's of the nested procedures }
+          nestedprocs : tlinkedlist;
+          procedure addnestedproc(child: tprocinfo);
+       public
           { pointer to parent in nested procedures }
           parent : tprocinfo;
           {# the definition of the routine itself }
@@ -123,6 +130,18 @@ unit procinfo;
 
           { Allocate got register }
           procedure allocate_got_register(list: TAsmList);virtual;
+
+          { Destroy the entire procinfo tree, starting from the outermost parent }
+          procedure destroy_tree;
+
+          { Store CurrTrueLabel and CurrFalseLabel to saved and generate new ones }
+          procedure save_jump_labels(out saved: tsavedlabels);
+
+          { Restore CurrTrueLabel and CurrFalseLabel from saved }
+          procedure restore_jump_labels(const saved: tsavedlabels);
+
+          function get_first_nestedproc: tprocinfo;
+          function has_nestedprocs: boolean;
        end;
        tcprocinfo = class of tprocinfo;
 
@@ -165,15 +184,61 @@ implementation
         CurrTrueLabel:=nil;
         CurrFalseLabel:=nil;
         maxpushedparasize:=0;
+        if Assigned(parent) and (parent.procdef.parast.symtablelevel>=normal_function_level) then
+          parent.addnestedproc(Self);
       end;
 
 
     destructor tprocinfo.destroy;
       begin
+         nestedprocs.free;
          aktproccode.free;
          aktlocaldata.free;
       end;
 
+    procedure tprocinfo.destroy_tree;
+      var
+        hp: tprocinfo;
+      begin
+        hp:=Self;
+        while Assigned(hp.parent) do
+          hp:=hp.parent;
+        hp.Free;
+      end;
+
+    procedure tprocinfo.addnestedproc(child: tprocinfo);
+      begin
+        if nestedprocs=nil then
+          nestedprocs:=TLinkedList.Create;
+        nestedprocs.insert(child);
+      end;
+
+    function tprocinfo.get_first_nestedproc: tprocinfo;
+      begin
+        if assigned(nestedprocs) then
+          result:=tprocinfo(nestedprocs.first)
+        else
+          result:=nil;
+      end;
+
+    function tprocinfo.has_nestedprocs: boolean;
+      begin
+        result:=assigned(nestedprocs) and (nestedprocs.count>0);
+      end;
+
+    procedure tprocinfo.save_jump_labels(out saved: tsavedlabels);
+      begin
+        saved[false]:=CurrFalseLabel;
+        saved[true]:=CurrTrueLabel;
+        current_asmdata.getjumplabel(CurrTrueLabel);
+        current_asmdata.getjumplabel(CurrFalseLabel);
+      end;
+
+    procedure tprocinfo.restore_jump_labels(const saved: tsavedlabels);
+      begin
+        CurrFalseLabel:=saved[false];
+        CurrTrueLabel:=saved[true];
+      end;
 
     procedure tprocinfo.allocate_push_parasize(size:longint);
       begin

+ 6 - 19
compiler/psub.pas

@@ -45,10 +45,7 @@ interface
         stackcheck_asmnode,
         init_asmnode,
         final_asmnode : tasmnode;
-        { list to store the procinfo's of the nested procedures }
-        nestedprocs : tlinkedlist;
         dfabuilder : TDFABuilder;
-        constructor create(aparent:tprocinfo);override;
         destructor  destroy;override;
         procedure printproc(pass:string);
         procedure generate_code;
@@ -555,16 +552,8 @@ implementation
                                   TCGProcInfo
 ****************************************************************************}
 
-    constructor tcgprocinfo.create(aparent:tprocinfo);
-      begin
-        inherited Create(aparent);
-        nestedprocs:=tlinkedlist.create;
-      end;
-
-
      destructor tcgprocinfo.destroy;
        begin
-         nestedprocs.free;
          if assigned(code) then
            code.free;
          inherited destroy;
@@ -794,10 +783,10 @@ implementation
 
     function tcgprocinfo.has_assembler_child : boolean;
       var
-        hp : tcgprocinfo;
+        hp : tprocinfo;
       begin
         result:=false;
-        hp:=tcgprocinfo(nestedprocs.first);
+        hp:=get_first_nestedproc;
         while assigned(hp) do
           begin
             if (hp.flags*[pi_has_assembler_block,pi_is_assembler])<>[] then
@@ -805,7 +794,7 @@ implementation
                 result:=true;
                 exit;
               end;
-            hp:=tcgprocinfo(hp.next);
+            hp:=tprocinfo(hp.next);
           end;
       end;
 
@@ -1549,7 +1538,7 @@ implementation
           { generate code for this procedure }
           pi.generate_code;
           { process nested procs }
-          hpi:=tcgprocinfo(pi.nestedprocs.first);
+          hpi:=tcgprocinfo(pi.get_first_nestedproc);
           while assigned(hpi) do
            begin
              do_generate_code(hpi);
@@ -1602,7 +1591,7 @@ implementation
         { We can't support inlining for procedures that have nested
           procedures because the nested procedures use a fixed offset
           for accessing locals in the parent procedure (PFV) }
-        if (tcgprocinfo(current_procinfo).nestedprocs.count>0) then
+        if current_procinfo.has_nestedprocs then
           begin
             if (df_generic in current_procinfo.procdef.defoptions) then
               Comment(V_Error,'Generic methods cannot have nested procedures')
@@ -1618,9 +1607,7 @@ implementation
         { When it's a nested procedure then defer the code generation,
           when back at normal function level then generate the code
           for all defered nested procedures and the current procedure }
-        if isnestedproc then
-          tcgprocinfo(current_procinfo.parent).nestedprocs.insert(current_procinfo)
-        else
+        if not isnestedproc then
           begin
             if not(df_generic in current_procinfo.procdef.defoptions) then
               do_generate_code(tcgprocinfo(current_procinfo));

+ 55 - 17
compiler/ptype.pas

@@ -40,9 +40,6 @@ interface
 
     procedure resolve_forward_types;
 
-    { reads a type identifier }
-    procedure id_type(var def : tdef;isforwarddef:boolean);
-
     { reads a string, file type or a type identifier }
     procedure single_type(var def:tdef;options:TSingleTypeOptions);
 
@@ -389,10 +386,27 @@ implementation
       end;
 
 
-    procedure parse_nested_types(var def: tdef; isforwarddef: boolean);
+    procedure id_type(var def : tdef;isforwarddef,checkcurrentrecdef:boolean); forward;
+
+    { def is the outermost type in which other types have to be searched
+
+      isforward indicates whether the current definition can be a forward definition
+
+      if assigned, currentstructstack is a list of tabstractrecorddefs that, from
+      last to first, are child types of def that are not yet visible via the
+      normal symtable searching routines because they are types that are currently
+      being parsed (so using id_type on them after pushing def on the
+      symtablestack would result in errors because they'd come back as errordef)
+    }
+    procedure parse_nested_types(var def: tdef; isforwarddef: boolean; currentstructstack: tfpobjectlist);
       var
         t2: tdef;
+        structstackindex: longint;
       begin
+        if assigned(currentstructstack) then
+          structstackindex:=currentstructstack.count-1
+        else
+          structstackindex:=-1;
         { handle types inside classes, e.g. TNode.TLongint }
         while (token=_POINT) do
           begin
@@ -403,12 +417,23 @@ implementation
               end
              else if is_class_or_object(def) or is_record(def) then
                begin
-                 symtablestack.push(tabstractrecorddef(def).symtable);
                  consume(_POINT);
-                 t2:=generrordef;
-                 id_type(t2,isforwarddef);
-                 symtablestack.pop(tabstractrecorddef(def).symtable);
-                 def:=t2;
+                 if (structstackindex>=0) and
+                    (tabstractrecorddef(currentstructstack[structstackindex]).objname^=pattern) then
+                   begin
+                     def:=tdef(currentstructstack[structstackindex]);
+                     dec(structstackindex);
+                     consume(_ID);
+                   end
+                 else
+                   begin
+                     structstackindex:=-1;
+                     symtablestack.push(tabstractrecorddef(def).symtable);
+                     t2:=generrordef;
+                     id_type(t2,isforwarddef,false);
+                     symtablestack.pop(tabstractrecorddef(def).symtable);
+                     def:=t2;
+                   end;
                end
              else
                break;
@@ -418,27 +443,39 @@ implementation
 
     function try_parse_structdef_nested_type(out def: tdef; basedef: tabstractrecorddef; isfowarddef: boolean): boolean;
       var
-        structdef : tabstractrecorddef;
+        structdef : tdef;
+        structdefstack : tfpobjectlist;
       begin
          { use of current parsed object:
            classes, objects, records can be used also in themself }
          structdef:=basedef;
+         structdefstack:=nil;
          while assigned(structdef) and (structdef.typ in [objectdef,recorddef]) do
            begin
-             if (structdef.objname^=pattern) then
+             if (tabstractrecorddef(structdef).objname^=pattern) then
                begin
                  consume(_ID);
                  def:=structdef;
-                 parse_nested_types(def,isfowarddef);
+                 { we found the top-most match, now check how far down we can
+                   follow }
+                 structdefstack:=tfpobjectlist.create(false);
+                 structdef:=basedef;
+                 while (structdef<>def) do
+                   begin
+                     structdefstack.add(structdef);
+                     structdef:=tabstractrecorddef(structdef.owner.defowner);
+                   end;
+                 parse_nested_types(def,isfowarddef,structdefstack);
+                 structdefstack.free;
                  result:=true;
                  exit;
                end;
-             structdef:=tabstractrecorddef(structdef.owner.defowner);
+             structdef:=tdef(tabstractrecorddef(structdef).owner.defowner);
            end;
          result:=false;
       end;
 
-    procedure id_type(var def : tdef;isforwarddef:boolean);
+    procedure id_type(var def : tdef;isforwarddef,checkcurrentrecdef:boolean);
     { reads a type definition }
     { to a appropriating tdef, s gets the name of   }
     { the type to allow name mangling          }
@@ -456,7 +493,8 @@ implementation
          pos:=current_tokenpos;
          { use of current parsed object:
            classes, objects, records can be used also in themself }
-         if try_parse_structdef_nested_type(def,current_structdef,isforwarddef) then
+         if checkcurrentrecdef and
+            try_parse_structdef_nested_type(def,current_structdef,isforwarddef) then
            exit;
          { Use the special searchsym_type that search only types }
          searchsym_type(s,srsym,srsymtable);
@@ -558,8 +596,8 @@ implementation
                      end
                    else
                      begin
-                       id_type(def,stoIsForwardDef in options);
-                       parse_nested_types(def,stoIsForwardDef in options);
+                       id_type(def,stoIsForwardDef in options,true);
+                       parse_nested_types(def,stoIsForwardDef in options,nil);
                      end;
                  end;
 

+ 1 - 1
compiler/regvars.pas

@@ -148,7 +148,7 @@ implementation
       if (cs_opt_regvar in current_settings.optimizerswitches) and
         { we have to store regvars back to memory in this case (the nested }
         { procedures can access the variables of the parent)               }
-        (tcgprocinfo(current_procinfo).nestedprocs.count = 0) and
+        (not current_procinfo.has_nestedprocs) and
          not(pi_has_assembler_block in current_procinfo.flags) and
          not(pi_uses_exceptions in current_procinfo.flags) then
         begin

+ 18 - 9
compiler/symdef.pas

@@ -76,6 +76,7 @@ interface
           function  is_publishable : boolean;override;
           function  needs_inittable : boolean;override;
           function  rtti_mangledname(rt:trttitype):string;override;
+          function  OwnerHierarchyName: string; override;
           function  in_currentunit: boolean;
           { regvars }
           function is_intregable : boolean;
@@ -1029,6 +1030,22 @@ implementation
       end;
 
 
+    function tstoreddef.OwnerHierarchyName: string;
+      var
+        tmp: tdef;
+      begin
+        tmp:=self;
+        result:='';
+        repeat
+          if tmp.owner.symtabletype in [ObjectSymtable,recordsymtable] then
+            tmp:=tdef(tmp.owner.defowner)
+          else
+            break;
+          result:=tabstractrecorddef(tmp).objrealname^+'.'+result;
+        until tmp=nil;
+      end;
+
+
     function tstoreddef.in_currentunit: boolean;
       var
         st: tsymtable;
@@ -2684,15 +2701,7 @@ implementation
       var
         tmp: tabstractrecorddef;
       begin
-        Result:=objrealname^;
-        tmp:=self;
-        repeat
-          if tmp.owner.symtabletype in [ObjectSymtable,recordsymtable] then
-            tmp:=tabstractrecorddef(tmp.owner.defowner)
-          else
-            break;
-          Result:=tmp.objrealname^+'.'+Result;
-        until tmp=nil;
+        Result:=OwnerHierarchyName+objrealname^;
       end;
 
     function tabstractrecorddef.search_enumerator_get: tprocdef;

+ 1 - 0
compiler/symtable.pas

@@ -2199,6 +2199,7 @@ implementation
       var
         hashedid : THashedIDString;
       begin
+        result:=false;
         hashedid.id:=s;
         srsymtable:=recordh.symtable;
         srsym:=tsym(srsymtable.FindWithHash(hashedid));

+ 7 - 4
compiler/symtype.pas

@@ -73,6 +73,7 @@ interface
          function  mangledparaname:string;
          function  getmangledparaname:string;virtual;
          function  rtti_mangledname(rt:trttitype):string;virtual;abstract;
+         function  OwnerHierarchyName: string; virtual; abstract;
          function  size:asizeint;virtual;abstract;
          function  packedbitsize:asizeint;virtual;
          function  alignment:shortint;virtual;abstract;
@@ -258,12 +259,13 @@ implementation
 
     function tdef.typename:string;
       begin
+        result:=OwnerHierarchyName;
         if assigned(typesym) and
            not(typ in [procvardef,procdef]) and
            (typesym.realname[1]<>'$') then
-          result:=typesym.realname
+          result:=result+typesym.realname
         else
-          result:=GetTypeName;
+          result:=result+GetTypeName;
       end;
 
 
@@ -275,10 +277,11 @@ implementation
 
     function tdef.typesymbolprettyname:string;
       begin
+        result:=OwnerHierarchyName;
         if assigned(typesym) then
-          result:=typesym.prettyname
+          result:=result+typesym.prettyname
         else
-          result:='<no type symbol>'
+          result:=result+'<no type symbol>'
       end;
 
     function tdef.mangledparaname:string;

+ 1 - 0
compiler/systems.pas

@@ -185,6 +185,7 @@ interface
              ,as_ggas                  { gnu assembler called "gas" instead of "as" }
              ,as_i386_nasmhaiku
              ,as_powerpc_vasm
+             ,as_i386_nlmcoff
        );
 
        tar = (ar_none

+ 5 - 5
compiler/systems/i_nwm.pas

@@ -34,7 +34,7 @@ unit i_nwm;
             system       : system_i386_netware;
             name         : 'Netware for i386(clib)';
             shortname    : 'Netware';
-            flags        : [tf_smartlink_library];
+            flags        : [tf_smartlink_library,tf_smartlink_sections,tf_dwarf_only_local_labels];
             cpu          : cpu_i386;
             unit_env     : 'NETWAREUNITS';
             extradefines : 'NETWARE_CLIB';
@@ -50,18 +50,18 @@ unit i_nwm;
             resobjext    : '.or';
             sharedlibext : '.nlm';
             staticlibext : '.a';
-            staticlibprefix : '';
+            staticlibprefix : 'libp';
             sharedlibprefix : '';
             sharedClibext : '.nlm';
             staticClibext : '.a';
-            staticClibprefix : '';
+            staticClibprefix : 'lib';
             sharedClibprefix : '';
-            importlibprefix : 'imp';
+            importlibprefix : 'libimp';
             importlibext : '.a';
             Cprefix      : '';
             newline      : #13#10;
             dirsep       : '/';
-            assem        : as_i386_elf32;
+            assem        : as_i386_nlmcoff; // as_i386_elf32;
             assemextern  : as_gas;
             link         : nil;
             linkextern   : nil;

+ 432 - 5
compiler/systems/t_nwm.pas

@@ -97,7 +97,7 @@ implementation
     verbose,systems,globtype,globals,
     symconst,script,
     fmodule,aasmbase,aasmtai,aasmdata,aasmcpu,cpubase,symsym,symdef,
-    import,export,link,i_nwm,ogbase
+    import,export,link,i_nwm,ogbase, ogcoff, ognlm, cclasses
     {$ifdef netware} ,dos {$endif}
     ;
 
@@ -123,6 +123,16 @@ implementation
       function  MakeExecutable:boolean;override;
     end;
 
+    TInternalLinkerNetware = class(TInternalLinker)
+        prelude : string;
+        constructor create;override;
+        destructor destroy;override;
+        procedure DefaultLinkScript;override;
+        procedure InitSysInitUnitName;override;
+        procedure ConcatEntryName; virtual;
+        Function  MakeSharedLibrary:boolean;override;
+      end;
+
 Const tmpLinkFileName = 'link~tmp._o_';
       minStackSize = 32768;
 
@@ -330,10 +340,26 @@ begin
 
   { add objectfiles, start with nwpre always }
   LinkRes.Add ('INPUT(');
-  s2 := FindObjectFile('nwpre','',false);
+  if target_info.system = system_i386_netwlibc then
+   begin
+     s2 := FindObjectFile('nwplibc','',false);
+     if s2 = '' then
+       s2 := FindObjectFile('libcpre.gcc','',false);
+   end else
+     s2 := FindObjectFile('nwpre','',false);
   Comment (V_Debug,'adding Object File '+s2);
   {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
 
+  if target_info.system = system_i386_netwlibc then
+   begin
+     if isDll then  {needed to provide main}
+       s2 := FindObjectFile('nwl_dlle','',false)
+     else
+       s2 := FindObjectFile('nwl_main','',false);
+     Comment (V_Debug,'adding Object File '+s2);
+     {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
+    end;
+
   { main objectfiles, add to linker input }
   while not ObjectFiles.Empty do
   begin
@@ -355,9 +381,20 @@ begin
   {$endif}
 
   { start and stop-procedures }
-  NLMConvLinkFile.Add ('START _Prelude');  { defined in rtl/netware/nwpre.as }
-  NLMConvLinkFile.Add ('EXIT _Stop');                             { nwpre.as }
-  NLMConvLinkFile.Add ('CHECK FPC_NW_CHECKFUNCTION');            { system.pp }
+
+  if target_info.system = system_i386_netwlibc then
+    begin
+      NLMConvLinkFile.Add ('START _LibCPrelude');
+      NLMConvLinkFile.Add ('EXIT _LibCPostlude');
+      NLMConvLinkFile.Add ('CHECK _LibCCheckUnload');
+      NLMConvLinkFile.Add ('REENTRANT');            { needed by older libc versions }
+    end else
+    begin
+      NLMConvLinkFile.Add ('START _Prelude');  { defined in rtl/netware/nwpre.as }
+      NLMConvLinkFile.Add ('EXIT _Stop');                             { nwpre.as }
+      NLMConvLinkFile.Add ('CHECK FPC_NW_CHECKFUNCTION');            { system.pp }
+    end;
+
 
   if not (cs_link_strip in current_settings.globalswitches) then
   begin
@@ -549,6 +586,395 @@ begin
 end;
 
 
+{****************************************************************************
+                            TInternalLinkerNetware
+****************************************************************************}
+
+    constructor TInternalLinkerNetware.Create;
+      begin
+        inherited Create;
+        CExeoutput:=TNLMexeoutput;
+        CObjInput:=TNLMCoffObjInput;
+        nlmSpecialSymbols_Segments := TFPHashList.create;
+      end;
+
+    destructor TInternalLinkerNetware.destroy;
+      begin
+        if assigned(nlmSpecialSymbols_Segments) then
+          begin
+            nlmSpecialSymbols_Segments.Free;
+            nlmSpecialSymbols_Segments := nil;
+          end;
+        inherited destroy;
+      end;
+
+    procedure TInternalLinkerNetware.DefaultLinkScript;
+      var
+        s,s2 : TCmdStr;
+        secname,
+        secnames : string;
+        hasCopyright,
+        hasScreenname,
+        hasThreadname,
+        hasVersion,
+        hasDescription,
+        hasStacksize: boolean;
+        t : text;
+
+
+
+        procedure addLinkerOption(s : string);
+        var op : string;
+        begin
+          if s = '' then exit;
+          if s[1]  = '#' then exit;
+          LinkScript.Concat(s);
+          op := upper(GetToken(s,' '));
+          {check for options via -k that can also be specified vie
+           compiler directives in source, -k options will override
+           options in source}
+          if op = 'COPYRIGHT' then hasCopyright := true else
+          if op = 'SCREENNAME' then hasScreenname := true else
+          if op = 'THREADNAME' then hasThreadname := true else
+          if op = 'VERSION' then hasVersion := true else
+          if op = 'DESCRIPTION' then hasDescription := true else
+          if (op = 'STACK') or (op = 'STACKSIZE') then hasStacksize := true;
+        end;
+
+        { add linker scropt specified by -k@FileName }
+        procedure addLinkerOptionsFile (fileName : string);
+        var
+          t : text;
+          option : string;
+          fn : TCmdStr;
+        begin
+          fn := fileName;
+          if not sysutils.fileExists(fn) then
+            if not includesearchpath.FindFile(fileName,true,fn) then
+            begin
+              comment(v_error,'linker options file "'+fileName+'" not found');
+              exit;
+            end;
+          assign(t,fn); reset(t);
+          while not eof(t) do
+            begin
+              readln(t,option);
+              addLinkerOption(option);
+            end;
+          close(t);
+        end;
+
+        { add  linker options specified by command line parameter -k }
+        procedure addLinkerOptions;
+        var
+          s,option : string;
+          p : integer;
+        begin
+          s := ParaLinkOptions;
+          option := GetToken(s,';');
+          while option <> '' do
+          begin
+            if copy(option,1,1)='@' then
+            begin
+              delete(option,1,1);
+              addLinkerOptionsFile(option);
+            end else
+              addLinkerOption(option);
+            option := GetToken(s,';');
+          end;
+        end;
+
+        { default: nwpre but can be specified via linker options
+          bacuse this has to be the first object, we have to scan
+          linker options before adding other options }
+
+        function findPreludeInFile (fileName : string):string;
+        var
+          t : text;
+          option,s : string;
+          fn : TCmdStr;
+        begin
+          result := '';
+          fn := fileName;
+          if not sysutils.fileExists(fn) then
+            if not includesearchpath.FindFile(fileName,true,fn) then
+            begin
+              comment(v_error,'linker options file "'+fileName+'" not found');
+              exit;
+            end;
+          assign(t,fn); reset(t);
+          while not eof(t) do
+            begin
+              readln(t,option);
+              option := upper(GetToken(s,' '));
+              if option='PRELUDE' then
+                begin
+                  result := getToken(s,' ');
+                  close(t);
+                  exit;
+                end;
+            end;
+          close(t);
+        end;
+
+        function findPrelude : string;
+        var
+          s,option,keyword : string;
+          p : integer;
+        begin
+          s := ParaLinkOptions;
+          option := GetToken(s,';');
+          while option <> '' do
+          begin
+            if copy(option,1,1)='@' then
+            begin
+              delete(option,1,1);
+              result := findPreludeInFile(option);
+              if result <> '' then exit;
+            end else
+            begin
+              keyword := GetToken(option,' ');
+              if keyword = 'PRELUDE' then
+                begin
+                  result := GetToken(option,' ');
+                  exit;
+                end;
+            end;
+            option := GetToken(s,';');
+          end;
+          if target_info.system = system_i386_netwlibc then
+            result := 'libcpre'
+          else
+            result := 'nwpre';
+        end;
+
+      begin
+        with LinkScript do
+          begin
+            prelude := findPrelude;  // needs to be first object, can be specified by -k"PRELUDE ObjFileName"
+            if prelude = '' then internalerror(201103271);
+            if pos ('.',prelude) = 0 then prelude := prelude + '.o';
+            s2 := FindObjectFile(prelude,'',false);
+            Comment (V_Debug,'adding init Object File '+s2);
+            Concat('READOBJECT '+MaybeQuoted(s2));
+            while not ObjectFiles.Empty do
+              begin
+                s:=ObjectFiles.GetFirst;
+                if s<>'' then
+                begin
+                  Concat('READOBJECT '+MaybeQuoted(s));
+                  Comment (V_Debug,'adding Object File '+s);
+                end;
+              end;
+            while not StaticLibFiles.Empty do
+              begin
+                s:=StaticLibFiles.GetFirst;
+                if s<>'' then
+                begin
+                  Comment (V_Debug,'adding StaticLibFile '+s);
+                  Concat('READSTATICLIBRARY '+MaybeQuoted(s));
+                end;
+              end;
+           { While not SharedLibFiles.Empty do
+              begin
+                S:=SharedLibFiles.GetFirst;
+                if FindLibraryFile(s,target_info.staticClibprefix,target_info.importlibext,s2) then
+                begin
+                  Comment (V_Debug,'adding LibraryFile '+s);
+                  Concat('READSTATICLIBRARY '+MaybeQuoted(s2));
+                end else
+                  Comment(V_Error,'Import library not found for '+S);
+              end;}
+            if IsSharedLibrary then
+              Concat('ISSHAREDLIBRARY');
+            ConcatEntryName;
+            Concat('IMAGEBASE $' + hexStr(0, SizeOf(imagebase)*2));
+            Concat('HEADER');
+            Concat('EXESECTION .text');
+            Concat('  SYMBOL __text_start__');  nlmSpecialSymbols_Segments.Add('__text_start__',pointer(ptruint(Section_text)));
+            Concat('  OBJSECTION .text*');
+            Concat('  SYMBOL ___CTOR_LIST__');  nlmSpecialSymbols_Segments.Add('___CTOR_LIST__',pointer(ptruint(Section_text)));
+            Concat('  SYMBOL __CTOR_LIST__');   nlmSpecialSymbols_Segments.Add('__CTOR_LIST__',pointer(ptruint(Section_text)));
+            Concat('  LONG -1');
+            Concat('  OBJSECTION .ctor*');
+            Concat('  LONG 0');
+            Concat('  SYMBOL ___DTOR_LIST__');  nlmSpecialSymbols_Segments.Add('___DTOR_LIST__',pointer(ptruint(Section_text)));
+            Concat('  SYMBOL __DTOR_LIST__');   nlmSpecialSymbols_Segments.Add('__DTOR_LIST__',pointer(ptruint(Section_text)));
+            Concat('  LONG -1');
+            Concat('  OBJSECTION .dtor*');
+            Concat('  LONG 0');
+            Concat('  SYMBOL etext');           nlmSpecialSymbols_Segments.Add('etext',pointer(ptruint(Section_text)));
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .data');
+            Concat('  SYMBOL __data_start__');  nlmSpecialSymbols_Segments.Add('__data_start__',pointer(ptruint(Section_data)));
+            Concat('  OBJSECTION .data*');
+            Concat('  OBJSECTION .fpc*');
+            Concat('  SYMBOL edata');           nlmSpecialSymbols_Segments.Add('edata',pointer(ptruint(Section_data)));
+            Concat('  SYMBOL __data_end__');    nlmSpecialSymbols_Segments.Add('__data_end__',pointer(ptruint(Section_data)));
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .bss');
+            Concat('  SYMBOL __bss_start__');   nlmSpecialSymbols_Segments.Add('__bss_start__',pointer(ptruint(Section_data)));
+            Concat('  OBJSECTION .bss*');
+            Concat('  SYMBOL __bss_end__');     nlmSpecialSymbols_Segments.Add('__bss_end__',pointer(ptruint(Section_data)));
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .imports');
+            Concat('  SYMBOL __imports_start__');
+            Concat('  OBJSECTION .imports*');
+            Concat('  SYMBOL __imports_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .modules');
+            Concat('  SYMBOL __modules_start__');
+            Concat('  OBJSECTION .modules*');
+            Concat('  SYMBOL __modules_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .exports');
+            Concat('  SYMBOL __exports_start__');
+            Concat('  OBJSECTION .exports*');
+            Concat('  SYMBOL __exports_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .reloc');
+            Concat('  SYMBOL __reloc_start__');
+            Concat('  OBJSECTION .reloc*');
+            Concat('  SYMBOL __reloc_end__');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .xdc');
+            Concat('  OBJSECTION .xdc*');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .custom');
+            Concat('  OBJSECTION .custom*');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .messages');
+            Concat('  OBJSECTION .messages*');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .help');
+            Concat('  OBJSECTION .help*');
+            Concat('ENDEXESECTION');
+
+            Concat('EXESECTION .rdata');
+            Concat('  SYMBOL ___RUNTIME_PSEUDO_RELOC_LIST__');
+            Concat('  SYMBOL __RUNTIME_PSEUDO_RELOC_LIST__');
+            Concat('  OBJSECTION .rdata_runtime_pseudo_reloc');
+            Concat('  SYMBOL ___RUNTIME_PSEUDO_RELOC_LIST_END__');
+            Concat('  SYMBOL __RUNTIME_PSEUDO_RELOC_LIST_END__');
+            Concat('  OBJSECTION .rdata*');
+            Concat('  OBJSECTION .rodata*');
+            Concat('ENDEXESECTION');
+            Concat('EXESECTION .pdata');
+            Concat('  OBJSECTION .pdata');
+            Concat('ENDEXESECTION');
+            secnames:='.edata,.rsrc,.gnu_debuglink,'+
+                      '.debug_aranges,.debug_pubnames,.debug_info,.debug_abbrev,.debug_line,.debug_frame,.debug_str,.debug_loc,'+
+                      '.debug_macinfo,.debug_weaknames,.debug_funcnames,.debug_typenames,.debug_varnames,.debug_ranges';
+            repeat
+              secname:=gettoken(secnames,',');
+              if secname='' then
+                break;
+              Concat('EXESECTION '+secname);
+              Concat('  OBJSECTION '+secname+'*');
+              Concat('ENDEXESECTION');
+            until false;
+            { Can't use the generic rules, because that will add also .stabstr to .stab }
+            Concat('EXESECTION .stab');
+            Concat('  OBJSECTION .stab');
+            Concat('ENDEXESECTION');
+            Concat('EXESECTION .stabstr');
+            Concat('  OBJSECTION .stabstr');
+            Concat('ENDEXESECTION');
+            Concat('STABS');
+            Concat('SYMBOLS');
+            Concat('');
+
+            hasCopyright := false;
+            hasScreenname := false;
+            hasThreadname := false;
+            hasVersion := false;
+            hasDescription := false;
+            hasStacksize := false;
+            addLinkerOptions;
+            if not hasCopyright then
+              if nwcopyright <> '' then
+                Concat('COPYRIGHT "'+nwCopyright+'"');
+            if not hasScreenname then
+              if nwscreenname <> '' then
+                Concat('SCREENNAME "'+nwscreenname+'"');
+            if not hasThreadname then
+              if nwthreadname <> '' then
+                Concat('THREADNAME "'+nwthreadname+'"');
+            if not hasVersion then
+              Concat('VERSION '+tostr(dllmajor)+' '+tostr(dllminor)+' '+tostr(dllrevision));
+            if not hasDescription then
+              if description <> '' then
+                Concat ('DESCRIPTION "'+description+'"');
+            if not hasStacksize then
+              if MaxStackSizeSetExplicity then
+              begin
+                if stacksize < minStackSize then stacksize := minStackSize;
+                Concat ('STACKSIZE '+tostr(stacksize));
+              end else
+                Concat ('STACKSIZE '+tostr(minStackSize));
+              if target_info.system = system_i386_netwlibc then
+                Concat ('REENTRANT');            { needed by older libc versions }
+          end;
+
+        // add symbols needed by nwpre. We have not loaded the ppu,
+        // therefore we do not know the externals so read it from nwpre.imp
+        s := ChangeFileExt(prelude,'.imp');  // nwpre.imp
+        if not librarysearchpath.FindFile(s,true,s2) then
+          begin
+            comment(v_error,s+' not found');
+            exit;
+          end;
+        assign(t,s2); reset(t);
+        while not eof(t) do
+          begin
+            readln(t,s);
+            s := trimspace(s);
+            if (length(s) > 0) then
+              if copy(s,1,1) <> '#' then
+                AddImportSymbol('!clib',s,0,false);
+          end;
+        close(t);
+      end;
+
+
+    procedure TInternalLinkerNetware.InitSysInitUnitName;
+      begin
+        //if target_info.system=system_i386_netware then
+        //  GlobalInitSysInitUnitName(self);
+      end;
+
+    procedure TInternalLinkerNetware.ConcatEntryName;
+      begin
+        with LinkScript do
+          begin
+            if IsSharedLibrary then
+              begin
+                Concat('ISSHAREDLIBRARY');
+                Concat('ENTRYNAME _Prelude')
+              end
+            else
+              begin
+                Concat('ENTRYNAME _Prelude')
+              end;
+          end;
+      end;
+
+
+    Function  TInternalLinkerNetware.MakeSharedLibrary:boolean;
+    begin
+      Comment(V_Error,'Make shared library not supported for netware');
+    end;
+
 {*****************************************************************************
                                      Initialize
 *****************************************************************************}
@@ -556,6 +982,7 @@ end;
 
 initialization
   RegisterExternalLinker(system_i386_netware_info,TLinkerNetware);
+  RegisterInternalLinker(system_i386_netware_info,TInternalLinkerNetware);
   RegisterImport(system_i386_netware,TImportLibNetware);
   RegisterExport(system_i386_netware,TExportLibNetware);
   RegisterTarget(system_i386_netware_info);

+ 27 - 521
compiler/utils/samplecfg

@@ -5,30 +5,6 @@
 #  Generate Sample Free Pascal configuration file
 #
 
-setgccdir() {
-# Find path to libgcc.a
-GCCSPEC=`(gcc -v $@ 2>&1)| head -n 1| awk '{ print $4 } '`
-if [ -z "$GCCSPEC" ] ; then
-  GCCSPEC=`gcc -print-libgcc-file-name $@ 2>/dev/null`
-fi
-GCCDIR=`dirname "$GCCSPEC"`
-}
-
-
-setgccdirarch() {
-# First argument is fpc define for CPU type; remaining args are passed to gcc to set corresponding architecture
-FPCDEFINE=$1
-shift
-setgccdir $@
-
-if [ -z "$GCCDIR" ] ; then
-  return
-fi
-GCCDIR="#ifdef $FPCDEFINE
--Fl$GCCDIR
-#endif"
-}
-
 HOSTOS=`uname -s | tr A-Z a-z`
 echo Running on $HOSTOS
 
@@ -47,18 +23,23 @@ else
 fi
 FPCBIN=`dirname "$1"`/../../bin/fpc
 FPBIN=`dirname "$1"`/../../bin/fp
+FPPKGBIN=`dirname "$1"`/../../bin/fppkg
 sysfpdirbase=`dirname "$1"`/`"$FPCBIN" -iV`
 sysfpdirbase2=$sysfpdirbase/ide
 sysfpdir=$sysfpdirbase2/text
-fpctargetos=`"$FPCBIN" -iTO`
 
 # Detect if we have write permission in sysdir.
 if [ -w "$sysdir" ] ; then
   echo Write permission in $sysdir.
   fpccfgfile="$sysdir"/fpc.cfg
+  fppkgfile="$sysdir"/fppkg.cfg
+  defaultfile="$sysdir"/fppkg/default
+  compilerconfigdir="-d CompilerConfigDir=$sysdir/fppkg"
 else
   echo No write premission in $sysdir.
   fpccfgfile="$HOME"/.fpc.cfg
+  fppkgfile="$HOME"/.config/fppkg.cfg
+  defaultfile="$HOME"/.fppkg/config/default
 fi
 #
 
@@ -69,388 +50,24 @@ if [ -f "$FPBIN" ] ; then
   fpinifile="$HOME"/.fp/fp.ini
   fpcfgfile="$HOME"/.fp/fp.cfg
 
-# Detect if we have write permission in sysfpdirbase.
-  if [ -w "$sysfpdirbase" ] ; then
-    echo Write permission in $sysfpdirbase.
-    if ! [ -d "$sysfpdirbase2" ] ; then
-      echo Directory $sysfpdirbase2 did not exist, attempting to create it now
-      mkdir $sysfpdirbase2  >/dev/null 2>&1
-      echo Attempting to create directory $sysfpdir
-      mkdir $sysfpdir  >/dev/null 2>&1
-    elif ! [ -d "$sysfpdir" ] ; then
-      echo Directory $sysfpdir did not exist, attempting to create it now
-      mkdir $sysfpdir  >/dev/null 2>&1
-    fi
-    if [ -w "$sysfpdir" ] ; then
-      fpinifile="$sysfpdir"/fp.ini
-      fpcfgfile="$sysfpdir"/fp.cfg
-    fi
+# Detect if we have write permission in sysfpdir, or that the directory can be made
+  if ( [ -d "$sysfpdirbase" ] && [ -w "$sysfpdirbase" ] && ! [ -d "$sysfpdirbase2" ] ) ||
+     ( [ -d "$sysfpdirbase2" ] && [ -w "$sysfpdirbase2" ] && ! [ -d "$sysfpdir" ] ) ||
+     ( [ -d "$sysfpdir" ] && [ -w "$sysfpdir" ] ) ; then
+    fpinifile="$sysfpdir"/fp.ini
+    fpcfgfile="$sysfpdir"/fp.cfg
   fi
 #
-
-# When the local FP IDE configuration is used, check if the directory exists
-  if [ $fpcfgfile = "$HOME"/.fp/fp.cfg -a ! -d "$HOME"/.fp ] ; then
-    echo Directory $HOME/.fp did not exist, attempting to create it now
-    mkdir "$HOME"/.fp >/dev/null 2>&1     
-  fi
-fi
-#
-
-if [ -f "$fpccfgfile" ] ; then
-  mv "$fpccfgfile" "$fpccfgfile.orig"  >/dev/null 2>&1
-  if [ $? = 0 ]; then
-    echo Saved old compiler config to $fpccfgfile.orig
-  else
-    echo Could not save old compiler config. Bailing out...
-    exit
-  fi
 fi
 
-if [ -f "$FPBIN" ] ; then
-  if [ -f "$fpinifile" ] ; then
-    mv "$fpinifile" "$fpinifile.orig"  >/dev/null 2>&1
-    if [ $? = 0 ]; then
-      echo Saved old fp.ini to $fpinifile.orig
-    else
-      echo Could not save old fp.ini. Bailing out...
-      exit
-    fi
-  fi
-
-  if [ -f "$fpcfgfile" ] ; then
-    mv "$fpcfgfile" "$fpcfgfile.orig"  >/dev/null 2>&1
-    if [ $? = 0 ]; then
-      echo Saved old fp.cfg to $fpcfgfile.orig
-    else
-      echo Could not save old fp.cfg. Bailing out...
-      exit
-    fi
-  fi
-fi
-
-setgccdir
-GCCDIR2=""
-GCCDIR3=""
-GCCDIR4=""
-
-singlearch() {
-  if [ -d "$GCCDIR" ]; then	
-    echo Found libgcc.a in "$GCCDIR"
-    GCCDIR=-Fl$GCCDIR
-  fi
-}
-
-# include ports tree dir for FreeBSDers.
-case "$HOSTOS" in
- freebsd)
-    GCCDIR=-Fl/usr/local/lib
-     ;;
- openbsd)
-    GCCDIR=-Fl/usr/local/lib
-     ;;
- netbsd)
-   GCCDIR=-Fl/usr/pkg/lib
-     ;;
- darwin)
-   setgccdirarch cpupowerpc -arch ppc
-   GCCDIR2="$GCCDIR"
-   setgccdirarch cpupowerpc64 -arch ppc64
-   GCCDIR3="$GCCDIR"
-   setgccdirarch cpui386 -arch i386
-   GCCDIR4="$GCCDIR"
-   setgccdirarch cpux86_64 -arch x86_64
-     ;;
-  linux)
-    case `"$FPCBIN" -PP` in
-      i?86|x86_64|amd64)
-      # Allow for the possibility of both 32 and 64 bit compilation on same system
-        setgccdirarch cpui386 -m32
-        GCCDIR4="$GCCDIR"
-        setgccdirarch cpux86_64 -m64
-        ;;
-      powerpc|powerpc64)
-      # Allow for the possibility of both 32 and 64 bit compilation on same system
-        setgccdirarch cpupowerpc -m32
-	GCCDIR4="$GCCDIR"
-	setgccdirarch cpupowerpc64 -m64
-	;;
-      # Add cases for other linux dual architectures here
-      *) singlearch # Default          
-        ;;
-    esac
-    ;;
-
- *) singlearch
-    ;;
-   
-esac
-
-CPUCROSSIFDEF1="#DEFINE NEEDCROSSBINUTILS"
-CPUCROSSIFDEF2=""
-
-case `"$FPCBIN" -PP` in
-  i?86|x86_64|amd64)
-    # Cross-binutils are not needed to compile for i386 on an x86_64 system
-    CPUCROSSIFDEF1="
-#IFNDEF CPUI386
-#IFNDEF CPUAMD64
-#DEFINE NEEDCROSSBINUTILS
-#ENDIF
-#ENDIF
-"
-    CPUCROSSIFDEF2="
-#IFNDEF $HOSTOS
-#DEFINE NEEDCROSSBINUTILS
-#ENDIF
-"
-  ;;
-  *)
-    CPUCROSSIFDEF1="#DEFINE NEEDCROSSBINUTILS"
-    CPUCROSSIFDEF2=""
-  ;;
-esac
-
-# darwin->darwin does not need cross binutils
-case "$HOSTOS" in
-  darwin)
-    CPUCROSSIFDEF2="
-#ifdef darwin
-#undef NEEDCROSSBINUTILS
-#endif
-"
-  ;;
-esac
-
-
 # set right path to FPC with $fpcversion
 FPCPATH=`dirname "$1"`/\$fpcversion
+# set right prefix to FPC
+FPCGLOBALPREFIX=`dirname "$1"`/../../
 
 # Write (.)fpc.cfg
 echo Writing sample configuration file to $fpccfgfile
-cat <<EOFCFG > $fpccfgfile
-#
-# Example fpc.cfg for Free Pascal Compiler
-#
-
-# ----------------------
-# Defines (preprocessor)
-# ----------------------
-
-#
-# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
-#
-# -d is the same as #DEFINE
-# -u is the same as #UNDEF
-#
-
-#
-# Some examples (for switches see below, and the -? helppages)
-#
-# Try compiling with the -dRELEASE or -dDEBUG on the commandline
-#
-
-# For a release compile with optimizes and strip debuginfo
-#IFDEF RELEASE
-  -O2
-  -Xs
-  #WRITE Compiling Release Version
-#ENDIF
-
-# For a debug version compile with debuginfo and all codegeneration checks on
-#IFDEF DEBUG
-  -g
-  -Crtoi
-  #WRITE Compiling Debug Version
-#ENDIF
-
-# set binutils prefix
-$CPUCROSSIFDEF1
-$CPUCROSSIFDEF2
-
-#IFDEF FPC_CROSSCOMPILING
-#IFDEF NEEDCROSSBINUTILS
-  -XP\$fpctarget-
-#ENDIF NEEDCROSSBINUTILS
-#ENDIF
-
-# assembling
-#ifdef darwin
-# use pipes instead of temporary files for assembling
--ap
-#endif
-
-# ----------------
-# Parsing switches
-# ----------------
-
-# Pascal language mode
-#      -Mfpc      free pascal dialect (default)
-#      -Mobjfpc   switch some Delphi 2 extensions on
-#      -Mdelphi   tries to be Delphi compatible
-#      -Mtp       tries to be TP/BP 7.0 compatible
-#      -Mgpc      tries to be gpc compatible
-#      -Mmacpas   tries to be compatible to the macintosh pascal dialects
-#
-# Turn on Object Pascal extensions by default
-#-Mobjfpc
-
-# Assembler reader mode
-#      -Rdefault  use default assembler
-#      -Ratt      read AT&T style assembler
-#      -Rintel    read Intel style assembler
-#
-# All assembler blocks are AT&T styled by default
-#-Ratt
-
-# Semantic checking
-#      -S2        same as -Mobjfpc
-#      -Sc        supports operators like C (*=,+=,/= and -=)
-#      -Sa        include assertion code.
-#      -Sd        same as -Mdelphi
-#      -Se<x>     error options. <x> is a combination of the following:
-#         <n> : compiler stops after the <n> errors (default is 1)
-#         w : compiler stops also after warnings
-#         n : compiler stops also after notes
-#         h : compiler stops also after hints
-#      -Sg        allow LABEL and GOTO
-#      -Sh        Use ansistrings
-#      -Si        support C++ styled INLINE
-#      -Sk        load fpcylix unit
-#      -SI<x>     set interface style to <x>
-#         -SIcom     COM compatible interface (default)
-#         -SIcorba   CORBA compatible interface
-#      -Sm        support macros like C (global)
-#      -So        same as -Mtp
-#      -Sp        same as -Mgpc
-#      -Ss        constructor name must be init (destructor must be done)
-#      -Sx        enable exception keywords (default in Delphi/ObjFPC modes)
-#
-# Allow goto, inline, C-operators, C-vars
--Sgic
-
-# ---------------
-# Code generation
-# ---------------
-
-# Uncomment the next line if you always want static/dynamic units by default
-# (can be overruled with -CD, -CS at the commandline)
-#-CS
-#-CD
-
-# Set the default heapsize to 8Mb
-#-Ch8000000
-
-# Set default codegeneration checks (iocheck, overflow, range, stack)
-#-Ci
-#-Co
-#-Cr
-#-Ct
-
-# Optimizer switches
-# -Os        generate smaller code
-# -O1        level 1 optimizations (quick optimizations, debuggable)
-# -O2        level 2 optimizations (-O1 + optimizations which make debugging more difficult)
-# -O3        level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
-# -Op<x>     set target cpu for optimizing, see fpc -i for possible values
-#
-# See "fpc -i" also for more fine-grained control over which optimizations
-# to perform
-
-#ifdef darwin
-#ifdef cpui386
--Cppentiumm
--Oppentiumm
-#endif
-#endif
-
-# -----------------------
-# Set Filenames and Paths
-# -----------------------
-
-# Slashes are also allowed under dos
-
-# path to the messagefile, not necessary anymore but can be used to override
-# the default language
-#-Fr$FPCPATH/msg/errore.msg
-#-Fr$FPCPATH/msg/errorn.msg
-
-# searchpath for units and other system dependent things
--Fu$FPCPATH/units/\$fpctarget
--Fu$FPCPATH/units/\$fpctarget/*
--Fu$FPCPATH/units/\$fpctarget/rtl
-#-Fu~/fpc/packages/base/*/units/$fpctarget;~/fpc/fcl/units/$fpctarget;~/fpc/rtl/units/$fpctarget
-
-#IFDEF FPCAPACHE_1_3
--Fu$FPCPATH/units/\$fpctarget/httpd13/
-#ELSE
-#IFDEF FPCAPACHE_2_0
--Fu$FPCPATH/units/\$fpctarget/httpd20
-#ELSE
--Fu$FPCPATH/units/\$fpctarget/httpd22
-#ENDIF
-#ENDIF
-
-# searchpath for libraries
-$GCCDIR
-$GCCDIR2
-$GCCDIR3
-$GCCDIR4
-#-Fl/pp/lib
-#-Fl/lib;/usr/lib
-
-
-# -------------
-# Linking
-# -------------
-
-# generate always debugging information for GDB (slows down the compiling
-# process)
-#      -gc        generate checks for pointers
-#      -gd        use dbx
-#      -gg        use gsym
-#      -gh        use heap trace unit (for memory leak debugging)
-#      -gl        use line info unit to show more info for backtraces
-#      -gv        generates programs tracable with valgrind
-#      -gw        generate dwarf debugging info
-#
-# Enable debuginfo and use the line info unit by default
-#-gl
-
-# always pass an option to the linker
-#-k-s
-
-# Always strip debuginfo from the executable
--Xs
-
-
-# -------------
-# Miscellaneous
-# -------------
-
-# Write always a nice FPC logo ;)
--l
-
-# Verbosity
-#      e : Show errors (default)       d : Show debug info
-#      w : Show warnings               u : Show unit info
-#      n : Show notes                  t : Show tried/used files
-#      h : Show hints                  c : Show conditionals
-#      i : Show general info           d : Show debug info
-#      l : Show linenumbers            r : Rhide/GCC compatibility mode
-#      a : Show everything             x : Executable info (Win32 only)
-#      b : Write file names messages with full path
-#      v : write fpcdebug.txt with     p : Write tree.log with parse tree
-#          lots of debugging info
-#
-# Display Info, Warnings and Notes
--viwn
-# If you don't want so much verbosity use
-#-vw
-
-#
-# That's all folks
-#
-EOFCFG
+fpcmkcfg -d "basepath=$FPCPATH" -o $fpccfgfile
 
 if ! [ -f "$FPBIN" ] ; then
   exit
@@ -458,132 +75,21 @@ fi
 
 # Write fp.cfg
 echo Writing sample configuration file to $fpcfgfile
-cat <<EOFFPCFG > $fpcfgfile
-#IFDEF NORMAL
- -Ci
- -XS
- -T$fpctargetos
- -Sg
- -O1
- -Fu$FPCPATH/units/\$fpctarget
- -Fu$FPCPATH/units/\$fpctarget\*
- -Fu$FPCPATH/units/\$fpctarget\rtl
- $GCCDIR
- $GCCDIR2
- $GCCDIR3
- $GCCDIR4
- -g-
- -p-
- -b-
-#ENDIF
-
-#IFDEF DEBUG
- -Ci
- -XS
- -T$fpctargetos
- -Sg
- -Cr
- -Co
- -Fu$FPCPATH/units/\$fpctarget
- -Fu$FPCPATH/units/\$fpctarget\*
- -Fu$FPCPATH/units/\$fpctarget\rtl
- $GCCDIR
- $GCCDIR2
- $GCCDIR3
- $GCCDIR4
- -g
- -p-
- -b-
-#ENDIF
-
-#IFDEF RELEASE
- -XS
- -T$fpctargetos
- -Sg
- -O2
- -Fu$FPCPATH/units/\$fpctarget
- -Fu$FPCPATH/units/\$fpctarget\*
- -Fu$FPCPATH/units/\$fpctarget\rtl
- $GCCDIR
- $GCCDIR2
- $GCCDIR3
- $GCCDIR4
- -g-
- -p-
- -b-
-#ENDIF
-EOFFPCFG
+fpcmkcfg -p -1 -d "basepath=$FPCPATH" -o $fpcfgfile
 
 # Write fp.ini
 echo Writing sample configuration file to $fpinifile
-cat <<EOFFPINI > $fpinifile
-[Compile]
-CompileMode=DEBUG
-
-[Editor]
-DefaultTabSize=8
-DefaultFlags=20599
-DefaultSaveExt=.pas
-DefaultIndentSize=1
-
-[Highlight]
-Exts="*.pas;*.pp;*.inc"
-NeedsTabs="make*;make*.*"
-
-[SourcePath]
-SourceList=""
-
-[Mouse]
-DoubleDelay=8
-ReverseButtons=0
-AltClickAction=6
-CtrlClickAction=1
-
-[Search]
-FindFlags=4
+fpcmkcfg -p -2 -o $fpinifile
 
-[Breakpoints]
-Count=0
-
-[Watches]
-Count=0
-
-[Preferences]
-DesktopFileFlags=209
-CenterCurrentLineWhileDebugging=1
-AutoSaveFlags=7
-MiscOptions=6
-DesktopLocation=1
-
-[Misc]
-ShowReadme=1
+# Do not write fppkg configuration when fppkg is not available
+if ! [ -f "$FPPKGBIN" ] ; then
+  exit
+fi
 
-[Files]
-OpenExts="*.pas;*.pp;*.inc"
+# Write fppkg.cfg
+echo Writing sample configuration file to $fppkgfile
+fpcmkcfg -p -3 $compilerconfigdir -o $fppkgfile
 
-[Tools]
-Title1="svn ~u~p (curr. dir)"
-Program1="svn"
-Params1="up \$CAP_MSG()"
-HotKey1=23296
-Title2="svn c~i~ (curr. dir)"
-Program2="svn"
-Params2="ci \$CAP_MSG()"
-HotKey2=23552
-Title3="svn ~d~iff"
-Program3="svn"
-Params3="diff \$CAP_MSG() \$EDNAME"
-HotKey3=23808
-Title4="svn ~l~og"
-Program4="svn"
-Params4="log \$CAP_MSG() \$EDNAME"
-HotKey4=34560
-Title5="svn ~b~lame"
-Program5="svn"
-Params5="blame \$CAP_MSG() \$EDNAME"
-HotKey5=34816
-Title6="svn ~a~dd"
-Program6="svn"
-Params6="add \$CAP_MSG() \$EDNAME"
-HotKey6=0'
-EOFFPINI
+# Write default
+echo Writing sample configuration file to $defaultfile
+fpcmkcfg -p -4 -d "GlobalPrefix=$FPCGLOBALPREFIX" -o $defaultfile

+ 431 - 4
compiler/x86/x86ins.dat

@@ -2557,7 +2557,9 @@ xmmreg,mem            \1\x66\301\323\2\x0F\xE3\110          WILLAMETTE,SSE2,SM
 [PEXTRW]
 (Ch_All, Ch_None, Ch_None)
 reg32,mmxreg,imm      \2\x0F\xC5\110\22               KATMAI,MMX,SB,AR2
-reg32,xmmreg,imm      \1\x66\323\2\x0F\xC5\110\26       WILLAMETTE,SSE2,SB,AR2
+reg32,xmmreg,imm      \1\x66\323\2\x0F\xC5\110\26                    SSE4
+mem32,xmmreg,imm      \1\x66\300\323\3\x0F\x3A\x15\101\26            SSE4
+
 
 [PINSRW]
 (Ch_All, Ch_None, Ch_None)
@@ -3269,7 +3271,7 @@ mem,xmmreg              \333\300\323\2\x0F\x2B\101                   SSE4,SD
 
 [MOVNTSD]
 (Ch_All, Ch_None, Ch_None)
-mem,xmmreg              \300\334\325\323\2\x0F\x2B\\101                SSE4 ;,SQ
+mem,xmmreg              \300\334\325\323\2\x0F\x2B\101                SSE4 ;,SQ
 
 [INSERTQ]
 (Ch_All, Ch_None, Ch_None)
@@ -3287,7 +3289,432 @@ xmmreg,xmmreg           \336\323\2\x0F\x79\110                        SSE4
 reg16,regmem            \320\333\301\323\2\x0F\xBD\110                386,SM,SSE4
 reg32|64,regmem         \321\333\301\323\2\x0F\xBD\110                386,SM,SSE4
 
+;*******************************************************************************
+;**********SSSE3****************************************************************
+;*******************************************************************************
+;Use SSE4, but need special flag for SSSE3 insructions set
+[PABSB]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x1C\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x1C\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x1C\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x1C\110               SSE4
+
+[PABSW]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x1D\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x1D\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x1D\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x1D\110               SSE4
+
+[PABSD]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x1E\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x1E\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x1E\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x1E\110               SSE4
+
+[PALIGNR]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg,imm     \331\3\x0F\x3A\x0F\110\26                      SSE4
+mmxreg,mem,imm        \301\331\3\x0F\x3A\x0F\110\26                  SSE4
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x0F\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x0F\110\26            SSE4
+
+[PHADDW]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x01\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x01\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x01\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x01\110               SSE4
+
+[PHADDD]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x02\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x02\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x02\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x02\110               SSE4
+
+[PHADDSW]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x03\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x03\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x03\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x03\110               SSE4
+
+[PHSUBW]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x05\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x05\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x05\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x05\110               SSE4
+
+[PHSUBD]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x06\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x06\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x06\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x06\110               SSE4
+
+[PHSUBSW]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x07\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x07\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x07\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x07\110               SSE4
+
+[PMADDUBSW]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x04\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x04\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x04\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x04\110               SSE4
+
+[PMULHRSW]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x0B\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x0B\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x0B\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x0B\110               SSE4
+
+[PSHUFB]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x00\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x00\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x00\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x00\110               SSE4
+
+[PSIGNB]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x08\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x08\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x08\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x08\110               SSE4
+
+[PSIGNW]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x09\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x09\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x09\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x09\110               SSE4
+
+[PSIGND]
+(Ch_All, Ch_None, Ch_None)
+mmxreg,mmxreg         \331\3\x0F\x38\x0A\110                         SSE4
+mmxreg,mem            \301\331\3\x0F\x38\x0A\110                     SSE4
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x0A\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x0A\110               SSE4
+;*******************************************************************************
+;**********SSE4.1***************************************************************
+;*******************************************************************************
+[BLENDPS] ;By hands delete 'or ot_signed' from i386tab.inc or x8664tab.inc
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x0C\110\26          SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x0C\110\26      SSE4
+
+[BLENDPD] ;By hands delete 'or ot_signed' from i386tab.inc or x8664tab.inc 
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\2\x0F\x3A\375\1\x0D\110\26          SSE4
+xmmreg,mem,imm        \1\x66\301\331\2\x0F\x3A\375\1\x0D\110\26      SSE4
+
+[BLENDVPS]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x14\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x14\110               SSE4
+
+[BLENDVPD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x15\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x15\110               SSE4
+
+[DPPS]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x40\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x40\110\26            SSE4
+
+[DPPD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x41\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x41\110\26            SSE4
+
+[EXTRACTPS]
+(Ch_All, Ch_None, Ch_None)
+mem,xmmreg,imm       \1\x66\325\3\x0F\x3A\x17\101\26    SSE4
+reg32|64,xmmreg,imm  \1\x66\300\3\x0F\x3A\x17\101\26    SSE4
+
+[INSERTPS]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x21\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x21\110\26            SSE4
+
+[MOVNTDQA]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x2A\110               SSE4
+
+[MPSADBW]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x42\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x42\110\26            SSE4
+
+[PACKUSDW]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x2B\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x2B\110               SSE4
+
+[PBLENDVB]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x10\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x10\110               SSE4
+
+[PBLENDW]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x0E\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x0E\110\26            SSE4
+
+[PCMPEQQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x29\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x29\110               SSE4
+
+[PEXTRB]
+(Ch_All, Ch_None, Ch_None)
+reg32,xmmreg,imm      \1\x66\323\3\x0F\x3A\x14\101\26                SSE4
+mem8,xmmreg,imm       \1\x66\300\323\3\x0F\x3A\x14\101\26            SSE4
+
+;PEXTRW - Look is prev. implementation
+
+[PEXTRD]
+(Ch_All, Ch_None, Ch_None)
+reg32,xmmreg,imm      \1\x66\323\3\x0F\x3A\x16\101\26                SSE4
+mem32,xmmreg,imm      \1\x66\300\323\3\x0F\x3A\x16\101\26            SSE4
+
+[PEXTRQ]
+(Ch_All, Ch_None, Ch_None)
+reg64,xmmreg,imm      \1\x66\326\3\x0F\x3A\x16\101\26                SSE4
+mem64,xmmreg,imm      \1\x66\300\326\3\x0F\x3A\x16\101\26            SSE4
+
+[PHMINPOSUW]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x41\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x41\110               SSE4
+
+[PINSRB]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,reg32,imm      \1\x66\331\3\x0F\x3A\x20\110\26                SSE4
+xmmreg,mem8,imm       \1\x66\301\331\3\x0F\x3A\x20\110\26            SSE4
+
+[PINSRD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,reg32,imm      \1\x66\331\3\x0F\x3A\x22\110\26                SSE4
+xmmreg,mem32,imm      \1\x66\301\331\3\x0F\x3A\x22\110\26            SSE4
+
+[PINSRQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,reg64,imm      \1\x66\326\3\x0F\x3A\x22\110\26                SSE4
+xmmreg,mem64,imm      \1\x66\301\326\3\x0F\x3A\x22\110\26            SSE4
+
+[PMAXSB]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x3C\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x3C\110               SSE4
+
+[PMAXSD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x3D\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x3D\110               SSE4
+
+[PMAXUD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x3F\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x3F\110               SSE4
+
+[PMAXUW]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x3E\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x3E\110               SSE4
+
+[PMINSB]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x38\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x38\110               SSE4
+
+[PMINSD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x39\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x39\110               SSE4
+
+[PMINUW]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x3A\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x3A\110               SSE4
+
+[PMINUD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x3B\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x3B\110               SSE4
+
+[PMOVSXBW]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x20\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x20\110               SSE4
+
+[PMOVSXBD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x21\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x21\110               SSE4
+
+[PMOVSXBQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x22\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x22\110               SSE4
+
+[PMOVSXWD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x23\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x23\110               SSE4
+
+[PMOVSXWQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x24\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x24\110               SSE4
+
+[PMOVSXDQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x25\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x25\110               SSE4
+
+[PMOVZXBW]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x30\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x30\110               SSE4
+
+[PMOVZXBD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x31\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x31\110               SSE4
+
+[PMOVZXBQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x32\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x32\110               SSE4
+
+[PMOVZXWD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x33\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x33\110               SSE4
+
+[PMOVZXWQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x34\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x34\110               SSE4
+
+[PMOVZXDQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x35\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x35\110               SSE4
+
+[PMULDQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x28\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x28\110               SSE4
+
+[PTEST]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x17\110                   SSE4
+
+[ROUNDPS]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x08\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x08\110\26            SSE4
+
+[ROUNDPD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x09\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x09\110\26            SSE4
+
+[ROUNDSS]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x0A\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x0A\110\26            SSE4
+
+[ROUNDSD]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\x0B\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\x0B\110\26            SSE4
+;*******************************************************************************
+;**********SSE4.2***************************************************************
+;*******************************************************************************
+[PCMPESTRI]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm      \1\x66\331\3\x0F\x3A\x61\110\26               SSE4
+xmmreg,mem,imm         \1\x66\301\331\3\x0F\x3A\x61\110\26           SSE4
+[PCMPESTRM]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm      \1\x66\331\3\x0F\x3A\x60\110\26               SSE4
+xmmreg,mem,imm         \1\x66\301\331\3\x0F\x3A\x60\110\26           SSE4
+[PCMPISTRI]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm      \1\x66\331\3\x0F\x3A\x63\110\26               SSE4
+xmmreg,mem,imm         \1\x66\301\331\3\x0F\x3A\x63\110\26           SSE4
+[PCMPISTRM]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm      \1\x66\331\3\x0F\x3A\x62\110\26               SSE4
+xmmreg,mem,imm         \1\x66\301\331\3\x0F\x3A\x62\110\26           SSE4
+[PCMPGTQ]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\x37\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\x37\110               SSE4
+;   CRC32
 [POPCNT,popcntX]
 (Ch_All, Ch_None, Ch_None)
-reg16,regmem            \320\333\301\323\2\x0F\xB8\110                386,SM,SSE4
-reg32|64,regmem         \321\333\301\323\2\x0F\xB8\110                386,SM,SSE4
+reg16,rm16             \1\xF3\301\320\2\x0F\xB8\110                  386,SM,SSE4
+reg32,rm32             \1\xF3\301\320\2\x0F\xB8\110                  386,SM,SSE4
+reg64,rm64             \1\xF3\301\320\2\x0F\xB8\110                  386,SM,SSE4
+;*******************************************************************************
+;**********AES******************************************************************
+;*******************************************************************************
+;Use SSE4, but need special flag for AES insructions set
+
+[AESENC]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\xDC\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\xDC\110               SSE4
+
+[AESENCLAST]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\xDD\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\xDD\110               SSE4
+
+[AESDEC]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\xDE\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\xDE\110               SSE4
+
+[AESDECLAST]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\xDF\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\xDF\110               SSE4
+
+[AESIMC]
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg         \1\x66\331\3\x0F\x38\xDB\110                   SSE4
+xmmreg,mem            \1\x66\301\331\3\x0F\x38\xDB\110               SSE4
+
+[AESKEYGEN] ;AESKEYGENASIST
+(Ch_All, Ch_None, Ch_None)
+xmmreg,xmmreg,imm     \1\x66\331\3\x0F\x3A\xDF\110\26                SSE4
+xmmreg,mem,imm        \1\x66\301\331\3\x0F\x3A\xDF\110\26            SSE4
+;*******************************************************************************
+;*******************************************************************************
+;*******************************************************************************
+[STOSQ]
+(Ch_RRAX, Ch_WMemEDI, Ch_RWRDI)
+void                   \2\x48\xAB                                    X86_64  
+
+[LODSQ]
+(Ch_WRAX, Ch_RWRSI, Ch_None)
+void                   \2\x48\xAD                                    X86_64    
+
+[CMPSQ]
+(Ch_All, Ch_None, Ch_None)
+void                   \2\x48\xA7                                    X86_64

+ 78 - 1
compiler/x86_64/x8664ats.inc

@@ -602,5 +602,82 @@ attsufNONE,
 attsufNONE,
 attsufNONE,
 attsufINT,
-attsufINT
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufINT,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE,
+attsufNONE
 );

+ 78 - 1
compiler/x86_64/x8664att.inc

@@ -602,5 +602,82 @@
 'insertq',
 'extrq',
 'lzcnt',
-'popcnt'
+'pabsb',
+'pabsw',
+'pabsd',
+'palignr',
+'phaddw',
+'phaddd',
+'phaddsw',
+'phsubw',
+'phsubd',
+'phsubsw',
+'pmaddubsw',
+'pmulhrsw',
+'pshufb',
+'psignb',
+'psignw',
+'psignd',
+'blendps',
+'blendpd',
+'blendvps',
+'blendvpd',
+'dpps',
+'dppd',
+'extractps',
+'insertps',
+'movntdqa',
+'mpsadbw',
+'packusdw',
+'pblendvb',
+'pblendw',
+'pcmpeqq',
+'pextrb',
+'pextrd',
+'pextrq',
+'phminposuw',
+'pinsrb',
+'pinsrd',
+'pinsrq',
+'pmaxsb',
+'pmaxsd',
+'pmaxud',
+'pmaxuw',
+'pminsb',
+'pminsd',
+'pminuw',
+'pminud',
+'pmovsxbw',
+'pmovsxbd',
+'pmovsxbq',
+'pmovsxwd',
+'pmovsxwq',
+'pmovsxdq',
+'pmovzxbw',
+'pmovzxbd',
+'pmovzxbq',
+'pmovzxwd',
+'pmovzxwq',
+'pmovzxdq',
+'pmuldq',
+'ptest',
+'roundps',
+'roundpd',
+'roundss',
+'roundsd',
+'pcmpestri',
+'pcmpestrm',
+'pcmpistri',
+'pcmpistrm',
+'pcmpgtq',
+'popcnt',
+'aesenc',
+'aesenclast',
+'aesdec',
+'aesdeclast',
+'aesimc',
+'aeskeygen',
+'stosq',
+'lodsq',
+'cmpsq'
 );

+ 78 - 1
compiler/x86_64/x8664int.inc

@@ -602,5 +602,82 @@
 'insertq',
 'extrq',
 'lzcnt',
-'popcnt'
+'pabsb',
+'pabsw',
+'pabsd',
+'palignr',
+'phaddw',
+'phaddd',
+'phaddsw',
+'phsubw',
+'phsubd',
+'phsubsw',
+'pmaddubsw',
+'pmulhrsw',
+'pshufb',
+'psignb',
+'psignw',
+'psignd',
+'blendps',
+'blendpd',
+'blendvps',
+'blendvpd',
+'dpps',
+'dppd',
+'extractps',
+'insertps',
+'movntdqa',
+'mpsadbw',
+'packusdw',
+'pblendvb',
+'pblendw',
+'pcmpeqq',
+'pextrb',
+'pextrd',
+'pextrq',
+'phminposuw',
+'pinsrb',
+'pinsrd',
+'pinsrq',
+'pmaxsb',
+'pmaxsd',
+'pmaxud',
+'pmaxuw',
+'pminsb',
+'pminsd',
+'pminuw',
+'pminud',
+'pmovsxbw',
+'pmovsxbd',
+'pmovsxbq',
+'pmovsxwd',
+'pmovsxwq',
+'pmovsxdq',
+'pmovzxbw',
+'pmovzxbd',
+'pmovzxbq',
+'pmovzxwd',
+'pmovzxwq',
+'pmovzxdq',
+'pmuldq',
+'ptest',
+'roundps',
+'roundpd',
+'roundss',
+'roundsd',
+'pcmpestri',
+'pcmpestrm',
+'pcmpistri',
+'pcmpistrm',
+'pcmpgtq',
+'popcnt',
+'aesenc',
+'aesenclast',
+'aesdec',
+'aesdeclast',
+'aesimc',
+'aeskeygen',
+'stosq',
+'lodsq',
+'cmpsq'
 );

+ 1 - 1
compiler/x86_64/x8664nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
-1372;
+1555;

+ 78 - 1
compiler/x86_64/x8664op.inc

@@ -602,5 +602,82 @@ A_MOVNTSD,
 A_INSERTQ,
 A_EXTRQ,
 A_LZCNT,
-A_POPCNT
+A_PABSB,
+A_PABSW,
+A_PABSD,
+A_PALIGNR,
+A_PHADDW,
+A_PHADDD,
+A_PHADDSW,
+A_PHSUBW,
+A_PHSUBD,
+A_PHSUBSW,
+A_PMADDUBSW,
+A_PMULHRSW,
+A_PSHUFB,
+A_PSIGNB,
+A_PSIGNW,
+A_PSIGND,
+A_BLENDPS,
+A_BLENDPD,
+A_BLENDVPS,
+A_BLENDVPD,
+A_DPPS,
+A_DPPD,
+A_EXTRACTPS,
+A_INSERTPS,
+A_MOVNTDQA,
+A_MPSADBW,
+A_PACKUSDW,
+A_PBLENDVB,
+A_PBLENDW,
+A_PCMPEQQ,
+A_PEXTRB,
+A_PEXTRD,
+A_PEXTRQ,
+A_PHMINPOSUW,
+A_PINSRB,
+A_PINSRD,
+A_PINSRQ,
+A_PMAXSB,
+A_PMAXSD,
+A_PMAXUD,
+A_PMAXUW,
+A_PMINSB,
+A_PMINSD,
+A_PMINUW,
+A_PMINUD,
+A_PMOVSXBW,
+A_PMOVSXBD,
+A_PMOVSXBQ,
+A_PMOVSXWD,
+A_PMOVSXWQ,
+A_PMOVSXDQ,
+A_PMOVZXBW,
+A_PMOVZXBD,
+A_PMOVZXBQ,
+A_PMOVZXWD,
+A_PMOVZXWQ,
+A_PMOVZXDQ,
+A_PMULDQ,
+A_PTEST,
+A_ROUNDPS,
+A_ROUNDPD,
+A_ROUNDSS,
+A_ROUNDSD,
+A_PCMPESTRI,
+A_PCMPESTRM,
+A_PCMPISTRI,
+A_PCMPISTRM,
+A_PCMPGTQ,
+A_POPCNT,
+A_AESENC,
+A_AESENCLAST,
+A_AESDEC,
+A_AESDECLAST,
+A_AESIMC,
+A_AESKEYGEN,
+A_STOSQ,
+A_LODSQ,
+A_CMPSQ
 );

+ 77 - 0
compiler/x86_64/x8664pro.inc

@@ -602,5 +602,82 @@
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_All, Ch_None, Ch_None)),
+(Ch: (Ch_RRAX, Ch_WMemEDI, Ch_RWRDI)),
+(Ch: (Ch_WRAX, Ch_RWRSI, Ch_None)),
 (Ch: (Ch_All, Ch_None, Ch_None))
 );

+ 1291 - 10
compiler/x86_64/x8664tab.inc

@@ -7705,7 +7705,14 @@
     ops     : 3;
     optypes : (ot_reg32,ot_xmmreg,ot_immediate);
     code    : #1#102#211#2#15#197#72#22;
-    flags   : if_willamette or if_sse2 or if_sb or if_ar2
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRW;
+    ops     : 3;
+    optypes : (ot_memory or ot_bits32,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#211#3#15#58#21#65#22;
+    flags   : if_sse4
   ),
   (
     opcode  : A_PINSRW;
@@ -9552,7 +9559,7 @@
     opcode  : A_MOVNTSD;
     ops     : 2;
     optypes : (ot_memory,ot_xmmreg,ot_none);
-    code    : #192#220#213#211#2#15#43#0#65;
+    code    : #192#220#213#211#2#15#43#65;
     flags   : if_sse4
   ),
   (
@@ -9591,17 +9598,1291 @@
     flags   : if_386 or if_sm or if_sse4
   ),
   (
-    opcode  : A_POPCNT;
+    opcode  : A_PABSB;
     ops     : 2;
-    optypes : (ot_reg16,ot_regmem,ot_none);
-    code    : #208#219#193#211#2#15#184#72;
-    flags   : if_386 or if_sm or if_sse4
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#28#72;
+    flags   : if_sse4
   ),
   (
-    opcode  : A_POPCNT;
+    opcode  : A_PABSB;
     ops     : 2;
-    optypes : (ot_reg32 or ot_bits64,ot_regmem,ot_none);
-    code    : #209#219#193#211#2#15#184#72;
-    flags   : if_386 or if_sm or if_sse4
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#28#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#28#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#28#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#29#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#29#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#29#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#29#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#30#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#30#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#30#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PABSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#30#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PALIGNR;
+    ops     : 3;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_immediate);
+    code    : #217#3#15#58#15#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PALIGNR;
+    ops     : 3;
+    optypes : (ot_mmxreg,ot_memory,ot_immediate);
+    code    : #193#217#3#15#58#15#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PALIGNR;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#15#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PALIGNR;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#15#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#1#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#1#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#1#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#1#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#2#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#2#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#2#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#2#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#3#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#3#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#3#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHADDSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#3#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#5#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#5#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#5#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#5#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#6#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBD;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#6#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#6#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#6#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#7#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#7#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#7#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHSUBSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#7#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMADDUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#4#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMADDUBSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#4#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMADDUBSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#4#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMADDUBSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#4#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULHRSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#11#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULHRSW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#11#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULHRSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#11#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULHRSW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#11#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSHUFB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#0#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSHUFB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#0#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSHUFB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#0#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSHUFB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#0#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#8#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNB;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#8#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#8#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#8#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#9#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNW;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#9#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#9#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGNW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#9#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGND;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_mmxreg,ot_none);
+    code    : #217#3#15#56#10#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGND;
+    ops     : 2;
+    optypes : (ot_mmxreg,ot_memory,ot_none);
+    code    : #193#217#3#15#56#10#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGND;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#10#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PSIGND;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#10#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDPS;
+    ops     : 3;
+    optypes : (ot_xmmreg or ot_signed,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#12#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDPS;
+    ops     : 3;
+    optypes : (ot_xmmreg or ot_signed,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#12#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#2#15#58#253#1#13#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#2#15#58#253#1#13#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDVPS;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#20#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDVPS;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#20#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDVPD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#21#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_BLENDVPD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#21#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_DPPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#64#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_DPPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#64#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_DPPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#65#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_DPPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#65#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_EXTRACTPS;
+    ops     : 3;
+    optypes : (ot_memory,ot_xmmreg,ot_immediate);
+    code    : #1#102#213#3#15#58#23#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_EXTRACTPS;
+    ops     : 3;
+    optypes : (ot_reg32 or ot_bits64,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#3#15#58#23#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_INSERTPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#33#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_INSERTPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#33#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_MOVNTDQA;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#42#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_MPSADBW;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#66#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_MPSADBW;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#66#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PACKUSDW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#43#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PACKUSDW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#43#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PBLENDVB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#16#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PBLENDVB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#16#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PBLENDW;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate or ot_signed);
+    code    : #1#102#217#3#15#58#14#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PBLENDW;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate or ot_signed);
+    code    : #1#102#193#217#3#15#58#14#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPEQQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#41#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPEQQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#41#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRB;
+    ops     : 3;
+    optypes : (ot_reg32,ot_xmmreg,ot_immediate);
+    code    : #1#102#211#3#15#58#20#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRB;
+    ops     : 3;
+    optypes : (ot_memory or ot_bits8,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#211#3#15#58#20#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRD;
+    ops     : 3;
+    optypes : (ot_reg32,ot_xmmreg,ot_immediate);
+    code    : #1#102#211#3#15#58#22#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRD;
+    ops     : 3;
+    optypes : (ot_memory or ot_bits32,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#211#3#15#58#22#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRQ;
+    ops     : 3;
+    optypes : (ot_reg64,ot_xmmreg,ot_immediate);
+    code    : #1#102#214#3#15#58#22#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PEXTRQ;
+    ops     : 3;
+    optypes : (ot_memory or ot_bits64,ot_xmmreg,ot_immediate);
+    code    : #1#102#192#214#3#15#58#22#65#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHMINPOSUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#65#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PHMINPOSUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#65#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRB;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_reg32,ot_immediate);
+    code    : #1#102#217#3#15#58#32#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRB;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory or ot_bits8,ot_immediate);
+    code    : #1#102#193#217#3#15#58#32#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_reg32,ot_immediate);
+    code    : #1#102#217#3#15#58#34#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory or ot_bits32,ot_immediate);
+    code    : #1#102#193#217#3#15#58#34#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRQ;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_reg64,ot_immediate);
+    code    : #1#102#214#3#15#58#34#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PINSRQ;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory or ot_bits64,ot_immediate);
+    code    : #1#102#193#214#3#15#58#34#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#60#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#60#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#61#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#61#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXUD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#63#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXUD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#63#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#62#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMAXUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#62#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#56#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINSB;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#56#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#57#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINSD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#57#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#58#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINUW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#58#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINUD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#59#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMINUD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#59#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#32#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#32#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#33#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#33#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#34#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXBQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#34#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXWD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#35#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXWD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#35#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXWQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#36#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXWQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#36#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#37#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVSXDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#37#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#48#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBW;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#48#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#49#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#49#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#50#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXBQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#50#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXWD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#51#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXWD;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#51#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXWQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#52#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXWQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#52#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#53#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMOVZXDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#53#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#40#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PMULDQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#40#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PTEST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#23#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#8#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDPS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#8#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#9#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDPD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#9#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDSS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#10#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDSS;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#10#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDSD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#11#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_ROUNDSD;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#11#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPESTRI;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#97#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPESTRI;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#97#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPESTRM;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#96#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPESTRM;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#96#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPISTRI;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#99#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPISTRI;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#99#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPISTRM;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#98#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPISTRM;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#98#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPGTQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#55#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_PCMPGTQ;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#55#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_POPCNT;
+    ops     : 2;
+    optypes : (ot_reg16,ot_regmem or ot_bits16,ot_none);
+    code    : #1#243#193#208#2#15#184#72;
+    flags   : if_386 or if_sm or if_sse4
+  ),
+  (
+    opcode  : A_POPCNT;
+    ops     : 2;
+    optypes : (ot_reg32,ot_regmem or ot_bits32,ot_none);
+    code    : #1#243#193#208#2#15#184#72;
+    flags   : if_386 or if_sm or if_sse4
+  ),
+  (
+    opcode  : A_POPCNT;
+    ops     : 2;
+    optypes : (ot_reg64,ot_regmem or ot_bits64,ot_none);
+    code    : #1#243#193#208#2#15#184#72;
+    flags   : if_386 or if_sm or if_sse4
+  ),
+  (
+    opcode  : A_AESENC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#220#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESENC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#220#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESENCLAST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#221#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESENCLAST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#221#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESDEC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#222#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESDEC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#222#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESDECLAST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#223#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESDECLAST;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#223#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESIMC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_none);
+    code    : #1#102#217#3#15#56#219#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESIMC;
+    ops     : 2;
+    optypes : (ot_xmmreg,ot_memory,ot_none);
+    code    : #1#102#193#217#3#15#56#219#72;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESKEYGEN;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_xmmreg,ot_immediate);
+    code    : #1#102#217#3#15#58#223#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_AESKEYGEN;
+    ops     : 3;
+    optypes : (ot_xmmreg,ot_memory,ot_immediate);
+    code    : #1#102#193#217#3#15#58#223#72#22;
+    flags   : if_sse4
+  ),
+  (
+    opcode  : A_STOSQ;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#72#171;
+    flags   : if_x86_64
+  ),
+  (
+    opcode  : A_LODSQ;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#72#173;
+    flags   : if_x86_64
+  ),
+  (
+    opcode  : A_CMPSQ;
+    ops     : 0;
+    optypes : (ot_none,ot_none,ot_none);
+    code    : #2#72#167;
+    flags   : if_x86_64
   )
 );

+ 45 - 10
packages/cdrom/src/cdromlin.inc

@@ -117,20 +117,55 @@ end;
 
 Function GetCDRomDevices(Var Devices : Array of string) : Integer;
 
-Var
-  S : String;
 
-begin
-  Result:=TestFSTab(Devices);
-  If (Result<1) then
+  Function AlreadyAdded(AName: String; AMax: Integer): Boolean;
+  var
+    I: Integer;
+  begin
+    Result := False;
+    for I := 0 to AMax do
+      if Devices[I] = AName then
+        Exit(True);
+  end;
+
+  // Resolves name if it's a symlink and adds it ensuring no dups
+  Function AddCdrom(ACDRom: String; I: Integer): Integer;
+  var
+    SInfo : stat;
+    RealName: String;
+  begin
+    Result := I;
+    if fpStat(PChar(ACDRom), SInfo) <> -1 then
     begin
-    S:=DetectCD;
-    If (S<>'') then
+      RealName := ACDRom;
+      if SInfo.st_mode and S_IFMT = S_IFLNK then
+        RealName := fpReadLink(ACDRom);
+
+      if not AlreadyAdded(RealName, I-1) then
       begin
-      Devices[0]:=S;
-      Result:=1;
+        Devices[I] := RealName;
+        Result := I+1;
       end;
-    end
+    end;
+  end;
+
+var
+  I,J: Integer;
+  CDRec: TCDSearchRec;
+  FSTab: array[0..10] of String;
+
+begin
+  I := 0;
+  // First Add Entries From FSTab
+  for J := 0 to TestFSTab(FSTab)-1 do
+    I := AddCdrom(FSTab[J], I);
+
+  //Now Do A Search
+  if FindFirstCD(CDRec) then
+  repeat
+    I := AddCdrom(CDRec.Name, I);
+  until FindNextCD(CDRec) = False;
+  Result := I;
 end;
 
 

+ 64 - 0
packages/cdrom/src/lincd.pp

@@ -708,8 +708,15 @@ procedure set_sense_key(var a : Trequest_sense; __sense_key : Tu8);
 { ---------------------------------------------------------------------
     Utility functions
   ---------------------------------------------------------------------}
+type
+  TCDSearchRec = record
+    Name: String;
+    i,j: Integer;
+  end;
 
 Function IsCDDevice(Device : String) : Boolean;
+Function FindFirstCD(var ACDSearchRec: TCDSearchRec): Boolean;
+Function FindNextCD(var ACDSearchRec: TCDSearchRec): Boolean;
 Function DetectCd : String;
 
 implementation
@@ -1098,6 +1105,61 @@ Const
   '/dev/sr?',
   '/dev/optcd');
 
+function FindFirstCD(var ACDSearchRec: TCDSearchRec): Boolean;
+begin
+  Result := False;
+  With ACDSearchRec do
+  begin
+    I := 1;
+    J := 0;
+    Name := '';
+  end;
+  Result := FindNextCD(ACDSearchRec);
+end;
+
+function FindNextCD(var ACDSearchRec: TCDSearchRec): Boolean;
+var
+  L: integer;
+  S: String;
+  FoundDev: String;
+begin
+
+  Result := False;
+  FoundDev := '';
+  with ACDSearchRec do
+  begin
+    While (FoundDev='') and (I<NrDevices) do
+    begin
+      S:=Devices[i];
+      L:=Length(S);
+      If S[l]='?' then
+      begin
+        S:=Copy(S,1,L-1);
+        if j >= 3 then
+          j := 0;
+        while (j <= 3) and (Length(FoundDev)=0) do
+        begin
+          If IsCdDevice(S+Chr(Ord('0')+J)) then
+            FoundDev:=S+Chr(Ord('0')+J)
+          else If IsCdDevice(S+Chr(Ord('a')+J)) then
+            FoundDev:=S+Chr(Ord('a')+J);
+          Inc(j);
+        end;
+        if J >= 3 then
+          Inc(i);
+      end
+      else
+      begin
+        If IsCdDevice(S) then
+          FoundDev:=S;
+        Inc(i);
+      end;
+    end;
+  end;
+  Result := Length(FoundDev) > 0;
+  ACDSearchRec.Name:=FoundDev;
+end;
+
 Function DetectCD : String;
 
 Var
@@ -1163,7 +1225,9 @@ begin
   If fpStat(Device,info)<>0 then
     exit;
   DeviceMajor:=info.st_rdev shr 8;
+  {$ifdef debug}
   Writeln('Device major : ',DeviceMajor);
+  {$endif}
   If DeviceMajor in [IDE0_MAJOR,IDE1_MAJOR,IDE2_MAJOR,IDE3_MAJOR] then
     Result:=TestCDRomIOCTL(Device)
   else 

+ 2 - 1
packages/cocoaint/utils/uikit-skel/src/uikit/UIKit.inc

@@ -78,4 +78,5 @@
 {$ifdef IOS_SDK_4_2_OR_HIGHER}
 {$include UIActionSheet.inc}
 {$include UILocalNotification.inc}
-{$endif}
+{$include UIAlertView.inc}
+{$endif}

+ 11 - 2
packages/fcl-base/src/eventlog.pp

@@ -29,6 +29,7 @@ Type
 
   TEventLog = Class(TComponent)
   Private
+    fAppendContent : Boolean;
     FEventIDOffset : DWord;
     FLogHandle : Pointer;
     FStream : TFileStream;
@@ -84,6 +85,7 @@ Type
     Procedure Info (const Msg : String); {$ifndef fpc }Overload;{$endif}
     Procedure Info (const Fmt : String; Args : Array of const); {$ifndef fpc }Overload;{$endif}
   Published
+    Property AppendContent : Boolean Read fAppendContent Write fAppendContent;
     Property Identification : String Read FIdentification Write SetIdentification;
     Property LogType : TLogType Read Flogtype Write SetlogType;
     Property Active : Boolean Read FActive write SetActive;
@@ -240,12 +242,19 @@ begin
 end;
 
 Procedure TEventLog.ActivateFileLog;
-
+var
+  fFileFlags : Word;
 begin
   If (FFileName='') then
     FFileName:=DefaultFileName;
   // This will raise an exception if the file cannot be opened for writing !
-  FStream:=TFileStream.Create(FFileName,fmCreate or fmShareDenyWrite);
+  if fAppendContent and FileExists(FFileName) then
+    fFileFlags := fmOpenWrite
+  else
+    fFileFlags := fmCreate;
+
+  fFileFlags := fFileFlags or fmShareDenyWrite;
+  FStream:=TFileStream.Create(FFileName,fFileFlags);
 end;
 
 Procedure TEventLog.DeActivateFileLog;

+ 5 - 1
packages/fcl-base/src/inifiles.pp

@@ -657,7 +657,11 @@ end;
 destructor TIniFile.destroy;
 begin
   If FDirty and FCacheUpdates then
-    UpdateFile;
+    try
+      UpdateFile;
+    except
+      // Eat exception. Compatible to D7 behaviour, see comments to bug 19046
+    end;  
   inherited destroy;
 end;
 

+ 12 - 11
packages/fcl-db/src/base/fields.inc

@@ -819,7 +819,13 @@ procedure TField.SetData(Buffer: Pointer; NativeFormat : Boolean);
 
 begin
   If Not Assigned(FDataset) then
-    EDatabaseError.CreateFmt(SNoDataset,[FieldName]);
+    DatabaseErrorFmt(SNoDataset,[FieldName]);
+  if (FieldNo>0) and not (FDataSet.State in [dsSetKey, dsFilter]) then
+    begin
+    if ReadOnly then 
+      DatabaseErrorFmt(SReadOnlyField, [DisplayName], Self); 
+    Validate(Buffer);
+    end;
   FDataSet.SetFieldData(Self,Buffer, NativeFormat);
 end;
 
@@ -2475,28 +2481,23 @@ end;
 procedure TFMTBCDField.GetText(var TheText: string; ADisplayText: Boolean);
 var
   bcd: TBCD;
-  E: double; //remove when formatBCD,BCDToStrF in fmtbcd.pp will be implemented
   fmt: String;
 begin
   if GetData(@bcd) then begin
-    E:=BCDToDouble(bcd);
     if aDisplayText or (FEditFormat='') then
       fmt := FDisplayFormat
     else
       fmt := FEditFormat;
     if fmt<>'' then
-      TheText := FormatFloat(fmt,E)
-      //TheText := FormatBCD(fmt,bcd)
+      TheText := BCDToStr(bcd)
+      //TheText := FormatBCD(fmt,bcd) //uncomment when formatBCD in fmtbcd.pp will be implemented
     else if fCurrency then begin
       if aDisplayText then
-        TheText := FloatToStrF(E, ffCurrency, FPrecision, 2{digits?})
-        //TheText := BcdToStrF(bcd, ffCurrency, FPrecision, 2{digits?})
+        TheText := BcdToStrF(bcd, ffCurrency, FPrecision, 2)
       else
-        TheText := FloatToStrF(E, ffFixed, FPrecision, 2{digits?});
-        //TheText := BcdToStrF(bcd, ffFixed, FPrecision, 2{digits?});
+        TheText := BcdToStrF(bcd, ffFixed, FPrecision, 2);
     end else
-      TheText := BcdToStr(bcd);
-      //TheText := BcdToStrF(bcd, ffGeneral, FPrecision, FSize);
+      TheText := BcdToStrF(bcd, ffGeneral, FPrecision, FSize);
   end else
     TheText := '';
 end;

+ 41 - 16
packages/fcl-db/src/memds/memds.pp

@@ -11,8 +11,10 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{$IFDEF FPC}
 {$mode objfpc}
 {$H+}
+{$ENDIF}
 {
   TMemDataset : In-memory dataset.
   - Has possibility to copy Structure/Data from other dataset.
@@ -37,6 +39,10 @@ const
   smData      = 2;
 
 type
+  {$IFNDEF FPC}
+  ptrint = Integer;
+  {$ENDIF}
+
   MDSError=class(Exception);
 
   PRecInfo=^TMTRecInfo;
@@ -63,6 +69,9 @@ type
     FFilterBuffer: PChar;
     ffieldoffsets: PInteger;
     ffieldsizes: PInteger;
+    function GetCharPointer(p:PChar; Pos:Integer):PChar;
+    function GetIntegerPointer(p:PInteger; Pos:Integer):PInteger;
+
     procedure calcrecordlayout;
     function  MDSGetRecordOffset(ARecNo: integer): longint;
     function  MDSGetFieldOffset(FieldNo: integer): integer;
@@ -123,16 +132,16 @@ type
 
     Function  DataSize : Integer;
 
-    procedure Clear(ClearDefs : Boolean);
-    procedure Clear;
-    Procedure SaveToFile(AFileName : String);
-    Procedure SaveToFile(AFileName : String; SaveData : Boolean);
-    Procedure SaveToStream(F : TStream);
-    Procedure SaveToStream(F : TStream; SaveData : Boolean);
+    procedure Clear(ClearDefs : Boolean);{$IFNDEF FPC} overload; {$ENDIF}
+    procedure Clear;{$IFNDEF FPC} overload; {$ENDIF}
+    Procedure SaveToFile(AFileName : String);{$IFNDEF FPC} overload; {$ENDIF}
+    Procedure SaveToFile(AFileName : String; SaveData : Boolean);{$IFNDEF FPC} overload; {$ENDIF}
+    Procedure SaveToStream(F : TStream); {$IFNDEF FPC} overload; {$ENDIF}
+    Procedure SaveToStream(F : TStream; SaveData : Boolean);{$IFNDEF FPC} overload; {$ENDIF}
     Procedure LoadFromStream(F : TStream);
     Procedure LoadFromFile(AFileName : String);
-    Procedure CopyFromDataset(DataSet : TDataSet);
-    Procedure CopyFromDataset(DataSet : TDataSet; CopyData : Boolean);
+    Procedure CopyFromDataset(DataSet : TDataSet); {$IFNDEF FPC} overload; {$ENDIF}
+    Procedure CopyFromDataset(DataSet : TDataSet; CopyData : Boolean); {$IFNDEF FPC} overload; {$ENDIF}
 
     Property FileModified : Boolean Read FFileModified;
 
@@ -284,7 +293,7 @@ end;
 
 function TMemDataset.MDSGetFieldOffset(FieldNo: integer): integer;
 begin
- result:= ffieldoffsets[fieldno-1];
+ result:= getIntegerpointer(ffieldoffsets, fieldno-1)^;
 end;
 
 Procedure TMemDataset.RaiseError(Fmt : String; Args : Array of const);
@@ -706,7 +715,7 @@ begin
           not getfieldisnull(pointer(srcbuffer),I);
  if result and (buffer <> nil) then 
    begin
-   Move((SrcBuffer+ffieldoffsets[I])^, Buffer^,FFieldSizes[I]);
+   Move(getcharpointer(SrcBuffer,getintegerpointer(ffieldoffsets,I)^)^, Buffer^,GetIntegerPointer(FFieldSizes, I)^);
    end;
 end;
 
@@ -724,10 +733,10 @@ begin
    else 
      begin 
      unsetfieldisnull(pointer(destbuffer),I);
-     J:=FFieldSizes[I];
+     J:=GetIntegerPointer(FFieldSizes, I)^;
      if Field.DataType=ftString then
        Dec(J); // Do not move terminating 0, which is in the size.
-     Move(Buffer^,(DestBuffer+FFieldOffsets[I])^,J);
+     Move(Buffer^,GetCharPointer(DestBuffer, getIntegerPointer(FFieldOffsets, I)^)^,J);
      dataevent(defieldchange,ptrint(field));
      end;
    end;
@@ -843,18 +852,22 @@ begin
  // Avoid mem-leak if CreateTable is called twice
  FreeMem(ffieldoffsets);
  Freemem(ffieldsizes);
-
+ {$IFDEF FPC}
  FFieldOffsets:=getmem(Count*sizeof(integer));
  FFieldSizes:=getmem(Count*sizeof(integer));
+ {$ELSE}
+ getmem(FFieldOffsets, Count*sizeof(integer));
+ getmem(FFieldSizes, Count*sizeof(integer));
+ {$ENDIF}
  FRecSize:= (Count+7) div 8; //null mask
 {$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
  FRecSize:=Align(FRecSize,4);
 {$ENDIF}
  for i:= 0 to Count-1 do
    begin
-   ffieldoffsets[i] := frecsize;
-   ffieldsizes[i] := MDSGetbufferSize(i+1);
-   FRecSize:= FRecSize+FFieldSizes[i];
+   GetIntegerPointer(ffieldoffsets, i)^ := frecsize;
+   GetIntegerPointer(ffieldsizes,   i)^ := MDSGetbufferSize(i+1);
+   FRecSize:= FRecSize+GetIntegerPointeR(FFieldSizes, i)^;
    end;
 end;
 
@@ -988,4 +1001,16 @@ begin
     end;
 end;
 
+function TMemDataset.GetCharPointer(p:PChar; Pos:Integer):PChar;
+begin
+  Result:=p;
+  inc(Result, Pos);
+end;
+
+function TMemDataset.GetIntegerPointer(p:PInteger; Pos:Integer):PInteger;
+begin
+  Result:=p;
+  inc(Result, Pos);
+end;
+
 end.

+ 1 - 0
packages/fcl-db/src/sqldb/mysql/mysql50conn.pas

@@ -4,6 +4,7 @@
 
 unit mysql50conn;
 
+{$DEFINE MYSQL50_up}
 {$DEFINE MYSQL50}
 
 {$i mysqlconn.inc}

+ 2 - 0
packages/fcl-db/src/sqldb/mysql/mysql51conn.pas

@@ -4,6 +4,8 @@
 
 unit mysql51conn;
 
+{$DEFINE MYSQL50_UP}
+{$DEFINE MYSQL51_UP}
 {$DEFINE MYSQL51}
 
 {$i mysqlconn.inc}

+ 3 - 7
packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

@@ -188,12 +188,8 @@ const
      'MYSQL_OPT_USE_REMOTE_CONNECTION','MYSQL_OPT_USE_EMBEDDED_CONNECTION',
      'MYSQL_OPT_GUESS_CONNECTION','MYSQL_SET_CLIENT_IP',
      'MYSQL_SECURE_AUTH'
-{$IFDEF MYSQL50}
+{$IFDEF MYSQL50_UP}
      ,'MYSQL_REPORT_DATA_TRUNCATION', 'MYSQL_OPT_RECONNECT'
-{$ELSE}     
-  {$IFDEF MYSQL51}
-     ,'MYSQL_REPORT_DATA_TRUNCATION', 'MYSQL_OPT_RECONNECT'
-  {$ENDIF}     
 {$ENDIF}
      );
 
@@ -559,7 +555,7 @@ begin
       NewType := ftInteger;
       NewSize := 0;
       end;
-{$if defined(mysql51) or defined(mysql50)}
+{$ifdef mysql50_up}
     FIELD_TYPE_NEWDECIMAL,
 {$endif}
     FIELD_TYPE_DECIMAL: if ADecimals < 5 then
@@ -867,7 +863,7 @@ begin
         VL := 0;
       Move(VL, Dest^, SizeOf(LargeInt));
       end;
-{$if defined(mysql51) or defined(mysql50)}
+{$ifdef mysql50_up}
     FIELD_TYPE_NEWDECIMAL,
 {$endif}      
     FIELD_TYPE_DECIMAL, FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE:

+ 1 - 1
packages/fcl-db/src/sqldb/postgres/pqconnection.pp

@@ -546,7 +546,7 @@ begin
       FPrepared := True;
       end
     else
-      statement := buf;
+      statement := AParams.ParseSQL(buf,false,sqEscapeSlash in ConnOptions, sqEscapeRepeat in ConnOptions,psPostgreSQL);
     end;
 end;
 

+ 4 - 6
packages/fcl-db/tests/sqldbtoolsunit.pas

@@ -7,13 +7,13 @@ interface
 uses
   Classes, SysUtils, toolsunit,
   db,
-  sqldb, ibconnection, mysql40conn, mysql41conn, mysql50conn, pqconnection,odbcconn,oracleconnection,sqlite3conn;
+  sqldb, ibconnection, mysql40conn, mysql41conn, mysql50conn, mysql51conn, pqconnection,odbcconn,oracleconnection,sqlite3conn;
 
-type TSQLDBTypes = (mysql40,mysql41,mysql50,postgresql,interbase,odbc,oracle,sqlite3);
+type TSQLDBTypes = (mysql40,mysql41,mysql50,mysql51,postgresql,interbase,odbc,oracle,sqlite3);
 
 const MySQLdbTypes = [mysql40,mysql41,mysql50];
       DBTypesNames : Array [TSQLDBTypes] of String[19] =
-             ('MYSQL40','MYSQL41','MYSQL50','POSTGRESQL','INTERBASE','ODBC','ORACLE','SQLITE3');
+             ('MYSQL40','MYSQL41','MYSQL50','MYSQL51','POSTGRESQL','INTERBASE','ODBC','ORACLE','SQLITE3');
              
       FieldtypeDefinitionsConst : Array [TFieldType] of String[15] =
         (
@@ -115,8 +115,7 @@ begin
       testStringValues[t] := TrimRight(testStringValues[t]);
     end;
   if SQLDbType = MYSQL50 then Fconnection := tMySQL50Connection.Create(nil);
-  if SQLDbType in MySQLdbTypes then
-    FieldtypeDefinitions[ftLargeint] := 'BIGINT';
+  if SQLDbType = MYSQL51 then Fconnection := tMySQL51Connection.Create(nil);
   if SQLDbType = sqlite3 then
     begin
     Fconnection := TSQLite3Connection.Create(nil);
@@ -134,7 +133,6 @@ begin
   if SQLDbType = INTERBASE then
     begin
     Fconnection := tIBConnection.Create(nil);
-    FieldtypeDefinitions[ftLargeint] := 'BIGINT';
     end;
   if SQLDbType = ODBC then Fconnection := tODBCConnection.Create(nil);
   if SQLDbType = ORACLE then Fconnection := TOracleConnection.Create(nil);

+ 10 - 2
packages/fcl-db/tests/testfieldtypes.pas

@@ -1391,7 +1391,10 @@ begin
     begin
     with query do
       begin
-      SQL.Text:='select NAME from FPDEV where NAME=''TestName21'' limit 1';
+      if (sqlDBtype=interbase) then
+        SQL.Text:='select first 1 NAME from FPDEV where NAME=''TestName21'''
+      else
+        SQL.Text:='select NAME from FPDEV where NAME=''TestName21'' limit 1';
       Open;
       close;
       ServerFilter:='ID=21';
@@ -1626,6 +1629,8 @@ procedure TTestFieldTypes.TestSQLClob;
     AssertEquals(testStringValues[a],AField.AsString);
   end;
 begin
+  if SQLDbType=interbase then
+      Ignore('This test does not apply to Interbase/Firebird, since it does not support CLOB fields');
   TestSQLFieldType(ftMemo, 'CLOB', 0, @TestSQLClob_GetSQLText, @CheckFieldValue);
 end;
 
@@ -1641,7 +1646,10 @@ procedure TTestFieldTypes.TestSQLLargeint;
     AssertEquals(testLargeIntValues[a],AField.AsLargeInt);
   end;
 begin
-  TestSQLFieldType(ftLargeint, 'LARGEINT', 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue);
+  if sqlDBType=interbase then
+    TestSQLFieldType(ftLargeint, 'BIGINT', 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue)
+  else
+    TestSQLFieldType(ftLargeint, 'LARGEINT', 8, @TestSQLLargeint_GetSQLText, @CheckFieldValue);
 end;
 
 

+ 33 - 3
packages/fcl-image/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/29]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/03/21]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
@@ -377,6 +377,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd  freetypeh freetype ftfont
 endif
@@ -402,7 +405,7 @@ ifeq ($(FULL_TARGET),x86_64-darwin)
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd  freetypeh freetype ftfont
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
+override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd  freetypeh freetype ftfont
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 override TARGET_UNITS+=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm clipping fpcanvas pixtools fppixlcanv fpimgcanv pscanvas fpwritebmp fpreadbmp bmpcomn fpreadpnm fpwritepnm fpreadjpeg fpwritejpeg pcxcomn fpreadpcx fpwritepcx fptiffcmn fpreadtiff fpwritetiff targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
@@ -563,6 +566,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override TARGET_RSTS+=pscanvas
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_RSTS+=pscanvas
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override TARGET_RSTS+=pscanvas
 endif
@@ -749,6 +755,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override TARGET_EXAMPLEDIRS+=examples
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_EXAMPLEDIRS+=examples
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override TARGET_EXAMPLEDIRS+=examples
 endif
@@ -936,6 +945,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override COMPILER_OPTIONS+=-S2h
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_OPTIONS+=-S2h
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override COMPILER_OPTIONS+=-S2h
 endif
@@ -1122,6 +1134,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override COMPILER_SOURCEDIR+=src
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_SOURCEDIR+=src
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override COMPILER_SOURCEDIR+=src
 endif
@@ -1543,6 +1558,11 @@ ifeq ($(OS_TARGET),NativeNT)
 SHAREDLIBEXT=.dll
 SHORTSUFFIX=nativent
 endif
+ifeq ($(OS_TARGET),wii)
+EXEEXT=.dol
+SHAREDLIBEXT=.so
+SHORTSUFFIX=wii
+endif
 else
 ifeq ($(OS_TARGET),go32v1)
 PPUEXT=.pp1
@@ -2230,6 +2250,13 @@ REQUIRE_PACKAGES_HASH=1
 REQUIRE_PACKAGES_PASZLIB=1
 REQUIRE_PACKAGES_FCL-BASE=1
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASJPEG=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-BASE=1
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_PASJPEG=1
@@ -3268,6 +3295,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 TARGET_EXAMPLEDIRS_EXAMPLES=1
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 TARGET_EXAMPLEDIRS_EXAMPLES=1
 endif

+ 1 - 0
packages/fcl-image/Makefile.fpc

@@ -14,6 +14,7 @@ units=fpimgcmn fpimage pngcomn fpreadpng fpwritepng fpreadxpm fpwritexpm \
       targacmn fpreadtga fpwritetga ellipses fpcolhash fpditherer fpquantizer \ 
       extinterpolation fpreadgif fpreadpsd xwdfile fpreadxwd
 units_win32=freetypeh freetype ftfont
+units_win64=freetypeh freetype ftfont
 units_beos=freetypeh freetype ftfont
 units_haiku=freetypeh freetype ftfont
 units_linux=freetypeh freetype ftfont

+ 69 - 0
packages/fcl-image/src/fpcanvas.inc

@@ -402,6 +402,56 @@ begin
   FPenPos := points[high(points)];
 end;
 
+procedure TFPCustomCanvas.RadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer);
+
+begin
+  DoRadialPie(X1, y1, x2, y2, StartAngle16Deg, Angle16DegLength);
+end;
+
+procedure TFPCustomCanvas.DoRadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer);
+
+begin
+  // To be implemented
+end;
+
+procedure TFPCustomCanvas.DoPolyBezier(Points: PPoint; NumPts: Integer;
+                           Filled: boolean = False;
+                           Continuous: boolean = False);
+
+begin
+ // To be implemented
+end;
+
+procedure TFPCustomCanvas.PolyBezier(Points: PPoint; NumPts: Integer;
+                     Filled: boolean = False;
+                     Continuous: boolean = False);
+begin
+  DoPolyBezier(Points,NumPts,Filled,Continuous);
+end;
+                     
+procedure TFPCustomCanvas.PolyBezier(const Points: array of TPoint;  
+                     Filled: boolean = False;
+                     Continuous: boolean = False);
+var 
+  NPoints{, i}: integer;
+//  PointArray: ^TPoint;
+begin
+  NPoints:=High(Points)-Low(Points)+1;
+  if NPoints>0 then
+    DoPolyBezier(@Points[Low(Points)],NPoints,Filled,Continuous);
+{
+  NPoints:=High(Points)-Low(Points)+1;
+  if NPoints<=0 then exit;
+    GetMem(PointArray,SizeOf(TPoint)*NPoints);
+  try  
+    for i:=0 to NPoints-1 do
+      PointArray[i]:=Points[i+Low(Points)];
+    DoPolyBezier(PointArray, NPoints, Filled, Continuous);
+  finally
+    FreeMem(PointArray);
+  end;}
+end;
+
 procedure TFPCustomCanvas.Clear;
 var r : TRect;
 begin
@@ -500,6 +550,25 @@ begin
   Rectangle (Rect(left,top,right,bottom));
 end;
 
+procedure TFPCustomCanvas.FillRect(const ARect: TRect);
+
+begin
+  if (Brush.style <> bsClear) then
+    begin
+    if not (brush is TFPCustomDrawBrush) then
+      DoRectangleFill (ARect)
+    else 
+      with ARect do
+        TFPCustomDrawBrush(Brush).Rectangle (left,top,right,bottom);
+    end;
+end;
+
+procedure TFPCustomCanvas.FillRect(X1,Y1,X2,Y2: Integer);
+
+begin
+  FillRect (Rect(X1,Y1,X2,Y2));
+end;
+        
 procedure TFPCustomCanvas.Rectangle (const Bounds:TRect);
 var np,nb,dp,db,pb : boolean;
 begin

+ 20 - 1
packages/fcl-image/src/fpcanvas.pp

@@ -24,6 +24,7 @@ const
 
 type
 
+  PPoint = ^TPoint;
   TFPCanvasException = class (Exception);
   TFPPenException = class (TFPCanvasException);
   TFPBrushException = class (TFPCanvasException);
@@ -82,11 +83,14 @@ type
   TFPCustomFont = class (TFPCanvasHelper)
   private
     FName : string;
+    FOrientation,
     FSize : integer;
   protected
     procedure DoCopyProps (From:TFPCanvasHelper); override;
     procedure SetName (AValue:string); virtual;
     procedure SetSize (AValue:integer); virtual;
+    procedure SetOrientation (AValue:integer); virtual;
+    function GetOrientation : Integer;
   public
     function CopyFont : TFPCustomFont;
     // Creates a copy of the font with all properties the same, but not allocated
@@ -99,6 +103,8 @@ type
     property Italic : boolean index 6 read GetFlags write SetFlags;
     property Underline : boolean index 7 read GetFlags write SetFlags;
     property StrikeTrough : boolean index 8 read GetFlags write SetFlags;
+    property Orientation: Integer read GetOrientation write SetOrientation default 0;
+        
   end;
   TFPCustomFontClass = class of TFPCustomFont;
 
@@ -255,6 +261,10 @@ type
     procedure DoLine (x1,y1,x2,y2:integer); virtual; abstract;
     procedure DoCopyRect (x,y:integer; canvas:TFPCustomCanvas; Const SourceRect:TRect); virtual; abstract;
     procedure DoDraw (x,y:integer; Const image:TFPCustomImage); virtual; abstract;
+    procedure DoRadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer); virtual;
+    procedure DoPolyBezier(Points: PPoint; NumPts: Integer;
+                           Filled: boolean = False;
+                           Continuous: boolean = False); virtual;
     procedure CheckHelper (AHelper:TFPCanvasHelper); virtual;
     procedure AddHelper (AHelper:TFPCanvasHelper);
   public
@@ -277,8 +287,17 @@ type
     procedure EllipseC (x,y:integer; rx,ry:longword);
     procedure Polygon (Const points:array of TPoint);
     procedure Polyline (Const points:array of TPoint);
-    procedure Rectangle (Const Bounds:TRect);
+    procedure RadialPie(x1, y1, x2, y2, StartAngle16Deg, Angle16DegLength: Integer);
+    procedure PolyBezier(Points: PPoint; NumPts: Integer;
+                         Filled: boolean = False;
+                         Continuous: boolean = False); 
+    procedure PolyBezier(const Points: array of TPoint;  
+                         Filled: boolean = False;
+                         Continuous: boolean = False);
+    procedure Rectangle (Const Bounds : TRect);
     procedure Rectangle (left,top,right,bottom:integer);
+    procedure FillRect(const ARect: TRect); 
+    procedure FillRect(X1,Y1,X2,Y2: Integer);
     // using brush
     procedure FloodFill (x,y:integer);
     procedure Clear;

+ 11 - 0
packages/fcl-image/src/fpfont.inc

@@ -24,6 +24,17 @@ begin
   FSize := AValue;
 end;
 
+procedure TFPCustomFont.SetOrientation (AValue:integer);
+begin
+  FOrientation := AValue;
+end;
+
+function TFPCustomFont.GetOrientation : Integer;
+begin
+  Result := FOrientation;
+end;
+
+
 procedure TFPCustomFont.DoCopyProps (From:TFPCanvasHelper);
 begin
   with from as TFPCustomFont do

+ 3 - 3
packages/fcl-passrc/src/pastree.pp

@@ -2609,7 +2609,7 @@ Var
   I : Integer;
 
 begin
-  For I:=0 to Length(Params) do
+  For I:=0 to High(Params) do
     begin
     If (Result<>'')  then
       Result:=Result+', ';
@@ -2647,7 +2647,7 @@ Function TRecordValues.GetDeclaration(Full : Boolean):AnsiString;
 Var
   I : Integer;
 begin
-  For I:=0 to Length(Fields) do
+  For I:=0 to High(Fields) do
     begin
     If Result='' then
       Result:=Result+'; ';
@@ -2708,7 +2708,7 @@ Var
   I : Integer;
 
 begin
-  For I:=0 to Length(Values) do
+  For I:=0 to High(Values) do
     begin
     If Result='' then
       Result:=Result+', ';

+ 34 - 14
packages/fcl-registry/src/regini.inc

@@ -83,30 +83,44 @@ procedure TRegIniFile.WriteBool(const Section, Ident: string; Value: Boolean);
 begin
 	if not OpenKey(fPath+Section,true) then Exit;
 	try
-	 inherited WriteBool(Ident,Value);
-	finally
-	 CloseKey;
+    if not fPreferStringValues then
+  	  inherited WriteBool(Ident,Value)
+    else begin
+      if ValueExists(Ident) and (GetDataType(Ident)=rdInteger) then
+    	  inherited WriteBool(Ident,Value)
+      else
+        inherited WriteString(Ident,BoolToStr(Value));
+    end;
+  finally
+	  CloseKey;
 	end;
 end;
 
 procedure TRegIniFile.WriteInteger(const Section, Ident: string; Value: LongInt);
 begin
   if not OpenKey(fPath+Section,true) then Exit;
- try
-  inherited WriteInteger(Ident,Value);
- finally
-  CloseKey;
- end;
+  try
+    if not fPreferStringValues then
+      inherited WriteInteger(Ident,Value)
+    else begin
+      if ValueExists(Ident) and (GetDataType(Ident)=rdInteger) then
+    	  inherited WriteInteger(Ident,Value)
+      else
+        inherited WriteString(Ident,IntToStr(Value));
+    end;
+  finally
+    CloseKey;
+  end;
 end;
 
 procedure TRegIniFile.WriteString(const Section, Ident, Value: String);
 begin
-   if not OpenKey(fPath+Section,true) then Exit;
- try
+  if not OpenKey(fPath+Section,true) then Exit;
+  try
    inherited WriteString(Ident,Value);
- finally
+  finally
    CloseKey;
- end;
+  end;
 end;
 
 function TRegIniFile.ReadBool(const Section, Ident: string; Default: Boolean): Boolean;
@@ -115,7 +129,10 @@ begin
 	if not OpenKey(fPath+Section,false) then Exit;
 	try
     if ValueExists(Ident) then
-	    Result := inherited ReadBool(Ident);
+      if (not fPreferStringValues) or (GetDataType(Ident)=rdInteger) then
+  	    Result := inherited ReadBool(Ident)
+      else
+        Result := StrToBool(inherited ReadString(Ident));
 	finally
 	  CloseKey;
 	end;
@@ -127,7 +144,10 @@ begin
   if not OpenKey(fPath+Section,false) then Exit;
   try
     if ValueExists(Ident) then
-      Result := inherited ReadInteger(Ident);
+      if (not fPreferStringValues) or (GetDataType(Ident)=rdInteger) then
+        Result := inherited ReadInteger(Ident)
+      else
+        Result := StrToInt(inherited ReadString(Ident));
   finally
     CloseKey;
   end;

+ 5 - 2
packages/fcl-registry/src/registry.pp

@@ -130,8 +130,9 @@ type
   ---------------------------------------------------------------------}
   TRegIniFile = class(TRegistry)
   private
-    fFileName: String;
-    fPath    : String;
+    fFileName          : String;
+    fPath              : String;
+    fPreferStringValues: Boolean;
   public
     constructor Create(const FN: string); overload;
     constructor Create(const FN: string;aaccess:longword); overload;
@@ -150,6 +151,8 @@ type
     procedure DeleteKey(const Section, Ident: String);
 
     property FileName: String read fFileName;
+    property PreferStringValues: Boolean read fPreferStringValues
+                write fPreferStringValues;
   end;
 
 { ---------------------------------------------------------------------

+ 18 - 16
packages/fcl-registry/src/xmlreg.pp

@@ -352,22 +352,24 @@ begin
     begin
     Node[SType]:=IntToStr(Ord(DataType));
     DataNode:=Node.FirstChild;
-    Result:=DataNode<>Nil;  // Bug 9879. Create child here?
-    If Result Then
-      begin 
-        Case DataType of
-          dtDWORD : DataNode.NodeValue:=IntToStr(PCardinal(@Data)^);
-          dtString : begin
-                     SetLength(S,DataSize);
-                     If (DataSize>0) then
-                       Move(Data,S[1],DataSize);
-                     DataNode.NodeValue:=S;
-                     end;
-          dtBinary : begin
-                     S:=BufToHex(Data,DataSize);
-                     DataNode.NodeValue:=S;
-                     end;
-        end;
+    // Reading <value></value> results in <value/>, i.e. no subkey exists any more. Create textnode.
+    if (DataNode=nil) then
+      begin
+      DataNode:=FDocument.CreateTextNode('');
+      Node.AppendChild(DataNode);
+      end;
+    Case DataType of
+      dtDWORD : DataNode.NodeValue:=IntToStr(PCardinal(@Data)^);
+      dtString : begin
+                 SetLength(S,DataSize);
+                 If (DataSize>0) then
+                   Move(Data,S[1],DataSize);
+                 DataNode.NodeValue:=S;
+                 end;
+      dtBinary : begin
+                 S:=BufToHex(Data,DataSize);
+                 DataNode.NodeValue:=S;
+                 end;
       end;
     end;
   If Result then

+ 39 - 4
packages/fcl-registry/tests/testbasics.pp

@@ -19,6 +19,7 @@ type
   protected
   published
     procedure TestSimpleWinRegistry;
+    procedure TestDoubleWrite;
   end;
 
 implementation
@@ -37,15 +38,49 @@ begin
 
   // use a hopefully non existing key
   AssertFalse(Registry.KeyExists('FPC1234'));
-
+{$ifdef windows}
   AssertTrue(Registry.KeyExists('SOFTWARE'));
-
-  // Registry.OpenKey('FPC', False);
-  // Result:=Registry.ReadString('VALUE1');
+{$endif}  
 
   Registry.Free;
 end;
 
+procedure TTestBasics.TestDoubleWrite;
+
+{$ifndef windows}
+Var
+  FN : String;
+{$endif}
+
+begin
+{$ifndef windows}
+  FN:=includetrailingpathdelimiter(GetAppConfigDir(False))+'reg.xml';
+  if FileExists(FN) then
+    AssertTrue(DeleteFile(FN));
+{$endif}
+  with TRegistry.Create do
+    try
+      OpenKey('test', true);
+      WriteString('LAYOUT', '');
+      CloseKey;
+    finally
+      Free;
+    end;
+  with TRegistry.Create do
+    try
+      OpenKey('test', true);
+      WriteString('LAYOUT', '');
+      CloseKey;
+    finally
+      Free;
+    end;
+{$ifndef windows}
+  FN:=includetrailingpathdelimiter(GetAppConfigDir(False))+'reg.xml';
+  if FileExists(FN) then
+    AssertTrue(DeleteFile(FN));
+{$endif}
+end;
+
 initialization
   RegisterTest(TTestBasics);
 end.

+ 2427 - 0
packages/fcl-stl/Makefile

@@ -0,0 +1,2427 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/03/21]
+#
+default: all
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
+BSDs = freebsd netbsd openbsd darwin
+UNIXs = linux $(BSDs) solaris qnx haiku
+LIMIT83fs = go32v2 os2 emx watcom
+OSNeedsComspecToRunBatch = go32v2 watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef COMSPEC
+ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),)
+ifndef RUNBATCH
+RUNBATCH=$(COMSPEC) /C
+endif
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+endif
+override DEFAULT_FPCDIR=../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+ifneq ($(CPU_TARGET),)
+FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
+else
+FPC:=$(shell $(FPCPROG) -PB)
+endif
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+else
+ifeq ($(strip $(wildcard $(FPC))),)
+FPC:=$(firstword $(FPCPROG))
+endif
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifneq ($(words $(FPC_COMPILERINFO)),5)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSO)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTO)
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifeq ($(CPU_TARGET),armeb)
+ARCH=arm
+override FPCOPT+=-Cb
+else
+ifeq ($(CPU_TARGET),armel)
+ARCH=arm
+override FPCOPT+=-CaEABI
+else
+ARCH=$(CPU_TARGET)
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+export OS_TARGET OS_SOURCE ARCH CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
+ifeq ($(OS_SOURCE),darwin)
+DARWIN2DARWIN=1
+endif
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+ifndef DARWIN2DARWIN
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+endif
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=fcl-stl
+override PACKAGE_VERSION=2.5.1
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-haiku)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override TARGET_UNITS+=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+endif
+override INSTALL_FPCPACKAGE=y
+ifeq ($(FULL_TARGET),i386-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-haiku)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_OPTIONS+=-S2h
+endif
+ifeq ($(FULL_TARGET),i386-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-haiku)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+override COMPILER_SOURCEDIR+=src
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+override COMPILER_SOURCEDIR+=src
+endif
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),haiku)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=hai
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+IMPORTLIBPREFIX=imp
+endif
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+ifeq ($(OS_TARGET),symbian)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=symbian
+endif
+ifeq ($(OS_TARGET),NativeNT)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=nativent
+endif
+ifeq ($(OS_TARGET),wii)
+EXEEXT=.dol
+SHAREDLIBEXT=.so
+SHORTSUFFIX=wii
+endif
+else
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+SHORTSUFFIX=wat
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.sl2
+STATICLIBPREFIX=
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nw
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),netwlibc)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nwl
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+IMPORTLIBPREFIX=imp
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_ECHO
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE= __missing_command_DATE
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL= __missing_command_GINSTALL
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),win32)
+ifeq ($(CROSSBINDIR),)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+endif
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(SRCBATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(FULL_TARGET),i386-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-haiku)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-symbian)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-nativent)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-iphonesim)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-nds)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-symbian)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),armeb-embedded)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL)/$(OS_TARGET) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(ARCH)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(ARCH)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX)
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O2
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef CREATESHARED
+override FPCOPT+=-Cg
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-Aas
+endif
+endif
+ifeq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),linux)
+ifeq ($(CPU_TARGET),x86_64)
+override FPCOPT+=-Cg
+endif
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+ifdef RUNBATCH
+EXECPPAS:=@$(RUNBATCH) $(PPAS)
+else
+EXECPPAS:=@$(PPAS)
+endif
+endif
+endif
+.PHONY: fpc_units
+ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),)
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared
+$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res
+$(COMPILER_UNITTARGETDIR):
+	$(MKDIRTREE) $(COMPILER_UNITTARGETDIR)
+$(COMPILER_TARGETDIR):
+	$(MKDIRTREE) $(COMPILER_TARGETDIR)
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.lpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.dpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.inc $(COMPILER_INCLUDEDIR)
+vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_shared
+override INSTALLTARGET+=fpc_shared_install
+ifndef SHARED_LIBVERSION
+SHARED_LIBVERSION=$(FPC_VERSION)
+endif
+ifndef SHARED_LIBNAME
+SHARED_LIBNAME=$(PACKAGE_NAME)
+endif
+ifndef SHARED_FULLNAME
+SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT)
+endif
+ifndef SHARED_LIBUNITS
+SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS)
+override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS))
+endif
+fpc_shared:
+ifdef HASSHAREDLIB
+	$(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1
+ifneq ($(SHARED_BUILD),n)
+	$(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
+fpc_shared_install:
+ifneq ($(SHARED_BUILD),n)
+ifneq ($(SHARED_LIBUNITS),)
+ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),)
+	$(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR)
+endif
+endif
+endif
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+ifneq ($(UNITTARGETDIRPREFIX),)
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES)))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES))))
+endif
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+ifneq ($(TARGETDIRPREFIX),)
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES)))
+endif
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(PACKAGE_NAME)
+endif
+endif
+ifndef FULLZIPNAME
+FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX)
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(SRCBATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) c$(TAROPT)f $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+ifdef RUNBATCH
+	$(RUNBATCH) $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX)
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX)
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_PROGRAMS
+override CLEANEXEFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEEXT), $(CLEAN_PROGRAMS)))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+fpc_distclean: cleanall
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+units: fpc_units
+examples:
+shared: fpc_shared
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif
+.NOTPARALLEL:

+ 23 - 0
packages/fcl-stl/Makefile.fpc

@@ -0,0 +1,23 @@
+#
+#   Makefile.fpc for Free Component Library
+#
+
+[package]
+name=fcl-stl
+version=2.5.1
+
+[target]
+units=garrayutils gdeque gmap gpriorityqueue gqueue gset gstack gutil gvector
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../..
+
+[compiler]
+options=-S2h
+sourcedir=src
+
+[rules]
+.NOTPARALLEL:

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно