View Issue Details

IDProjectCategoryView StatusLast Update
0036647FPCRTLpublic2020-02-15 09:42
ReporterChristo Crause Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionwon't fix 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0036647: AVR [patch] Enable whole RTL to compile for avrtiny subarch
Description1. Exclude the following features: textio, fileio, exceptions and classes.

2. Define EXCLUDE_COMPLEX_PROCS for CPUAVR_16_REGS.

3. Regroup file access functions to simplify wrapping in {$ifdef FPC_HAS_FEATURE_X}

4. Exclude all functions/procedures that result in Internal error 200309041.

5. Functionality affected by above modifications where patched with runerror(217)

It may be possible to retain more functionality, but this is the quickest sensible way I could find to build the RTL for avrtiny.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Christo Crause

2020-02-01 14:36

reporter  

avrtiny-rtl.patch (26,194 bytes)   
diff --git a/rtl/embedded/system.cfg b/rtl/embedded/system.cfg
index 46fc62d231..d8e64b04cc 100644
--- a/rtl/embedded/system.cfg
+++ b/rtl/embedded/system.cfg
@@ -2,8 +2,10 @@
 -Sf-
 # enable required ones
 # they don't add much additional code or data
+#ifndef CPUAVRTINY
 -SfTEXTIO
 -SfFILEIO
+#endif CPUAVRTINY
 -SfHEAP
 
 # uncomment to enable the stuff you want to use
@@ -165,8 +167,10 @@
 # in programs not using e. g. writeln based I/O which is the common case for AVR
 #ifdef CPUAVR
 -SfOBJECTS
+#ifndef CPUAVRTINY
 -SfEXCEPTIONS
 -SfCLASSES
+#endif CPUAVRTINY
 -SfRTTI
 # AVR6 has normally more memory, so enable more functions
 #ifdef CPUAVR6
@@ -245,4 +249,4 @@
 -SfCOMMANDARGS
 -SfRANDOM
 -SfRESOURCES
-#endif CPURISCV64
\ No newline at end of file
+#endif CPURISCV64
diff --git a/rtl/embedded/system.pp b/rtl/embedded/system.pp
index 7489b38cff..31fe26ee6b 100644
--- a/rtl/embedded/system.pp
+++ b/rtl/embedded/system.pp
@@ -29,9 +29,9 @@ Unit System;
   which are probably anyways rarely used on avr
 
   meanwhile, the avr compiler can deal with them (FK) }
-{$ifdef CPUAVR}
-{ $define EXCLUDE_COMPLEX_PROCS}
-{$endif CPUAVR}
+{$ifdef CPUAVR_16_REGS}
+{$define EXCLUDE_COMPLEX_PROCS}
+{$endif CPUAVR_16_REGS}
 
 { $define USE_NOTHREADMANAGER}
 
@@ -55,9 +55,9 @@ Unit System;
 {$I systemh.inc}
 
 const
-{$ifdef FPC_HAS_FEATURE_TEXTIO}
+{ $ifdef FPC_HAS_FEATURE_TEXTIO}
   LineEnding = #10;
-{$endif FPC_HAS_FEATURE_TEXTIO}
+{ $endif FPC_HAS_FEATURE_TEXTIO}
 {$ifdef FPC_HAS_FEATURE_FILEIO}
   LFNSupport = true;
   DirectorySeparator = '/';
@@ -73,16 +73,17 @@ const
 {$ifdef FPC_HAS_FEATURE_EXITCODE}
   maxExitCode = 255;
 {$endif FPC_HAS_FEATURE_EXITCODE}
-{$ifdef FPC_HAS_FEATURE_FILEIO}
-
-  MaxPathLen = 1024; // BSDs since 1993, Solaris 10, Darwin
-  AllFilesMask = '*';
 
   UnusedHandle    = -1;
   StdInputHandle  = 0;
   StdOutputHandle = 1;
   StdErrorHandle  = 2;
 
+{$ifdef FPC_HAS_FEATURE_FILEIO}
+
+  MaxPathLen = 1024; // BSDs since 1993, Solaris 10, Darwin
+  AllFilesMask = '*';
+
   FileNameCaseSensitive : boolean = true;
   FileNameCasePreserving: boolean = true;
 {$endif FPC_HAS_FEATURE_FILEIO}
diff --git a/rtl/inc/charset.pp b/rtl/inc/charset.pp
index b3bc902131..5cfbb01c2a 100644
--- a/rtl/inc/charset.pp
+++ b/rtl/inc/charset.pp
@@ -291,6 +291,9 @@ unit charset;
          lastchar, i : longint;
 
       begin
+{$ifndef FPC_HAS_FEATURE_FILEIO}
+        runerror(217);
+{$else}
          lastchar:=-1;
          loadunicodemapping:=nil;
          datasize:=256;
@@ -381,6 +384,7 @@ unit charset;
          p^.map:=data;
          p^.reversemap:=buildreversemap(p^.map,(p^.lastchar+1),p^.reversemaplength);
          loadunicodemapping:=p;
+{$endif FPC_HAS_FEATURE_FILEIO}
       end;
 
 
@@ -395,6 +399,9 @@ unit charset;
       var
         fileName : string;
       begin
+{$ifndef FPC_HAS_FEATURE_FILEIO}
+        runerror(217);
+{$else}
         fileName := directory;
         if (fileName <> '') then begin
           if (fileName[Length(fileName)] <> DirectorySeparator) then
@@ -402,11 +409,17 @@ unit charset;
         end;
         fileName := fileName + cpname + '_' + ENDIAN_SUFFIX + BINARY_MAPPING_FILE_EXT;
         Result := loadbinaryunicodemapping(fileName);
+{$endif FPC_HAS_FEATURE_FILEIO}
       end;
 
     {$PUSH}
       {$I-}
     function loadbinaryunicodemapping(const filename : string) : punicodemap;
+    {$ifndef FPC_HAS_FEATURE_FILEIO}
+      begin
+        runerror(217);
+      end;
+    {$else}
       const
         BLOCK_SIZE = 16*1024;
       var
@@ -449,6 +462,7 @@ unit charset;
         FreeMem(locBuffer,locSize);
         Close(f);
       end;
+{$endif FPC_HAS_FEATURE_FILEIO}
     {$POP}
 
     procedure freemapping(amapping : punicodemap);
diff --git a/rtl/inc/compproc.inc b/rtl/inc/compproc.inc
index df9ba0161f..02a4792bbe 100644
--- a/rtl/inc/compproc.inc
+++ b/rtl/inc/compproc.inc
@@ -93,7 +93,9 @@ procedure fpc_ShortStr_Float(d : ValReal;len,fr,rt : SizeInt;out s : shortstring
 {$endif}
 procedure fpc_shortstr_enum(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out s:shortstring);compilerproc;
 procedure fpc_shortstr_bool(b : boolean;len:sizeint;out s:shortstring);compilerproc;
+{$ifndef CPUAVR_16_REGS}
 procedure fpc_ShortStr_Currency(c : currency; len,f : SizeInt; out s : shortstring); compilerproc;
+{$endif CPUAVR_16_REGS}
 
 procedure fpc_chararray_sint(v : valsint;len : SizeInt;out a : array of char); compilerproc;
 procedure fpc_chararray_uint(v : valuint;len : SizeInt;out a : array of char); compilerproc;
@@ -429,7 +431,7 @@ procedure fpc_PWideChar_To_ShortStr(out res : shortstring;const p : pwidechar);
 {$endif FPC_HAS_FEATURE_WIDESTRINGS}
 
 
-{ $ifdef FPC_HAS_FEATURE_TEXTIO}
+{$ifdef FPC_HAS_FEATURE_TEXTIO}
 { from text.inc }
 Function fpc_get_input:PText;compilerproc;
 Function fpc_get_output:PText;compilerproc;
@@ -508,7 +510,7 @@ procedure fpc_SetupReadStr_Unicodestr(var ReadWriteStrText: text; const s: unico
 {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
 procedure fpc_SetupReadStr_Widestr(var ReadWriteStrText: text; const s: widestring); compilerproc;
 {$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
-{ $endif FPC_HAS_FEATURE_TEXTIO}
+{$endif FPC_HAS_FEATURE_TEXTIO}
 
 {$ifdef FPC_HAS_FEATURE_VARIANTS}
 procedure fpc_variant_init(var v: tvardata);compilerproc;
@@ -617,6 +619,7 @@ function fpc_mul_dword_checkoverflow(f1,f2 : dword) : dword; compilerproc;
 {$endif FPC_INCLUDE_SOFTWARE_MUL}
 
 { from int64.inc }
+{$ifndef CPUAVR_16_REGS}
 function fpc_div_qword(n,z : qword) : qword; compilerproc;
 function fpc_mod_qword(n,z : qword) : qword; compilerproc;
 function fpc_div_int64(n,z : int64) : int64; compilerproc;
@@ -656,12 +659,15 @@ procedure fpc_ror_assign_qword(var AValue : QWord;const Dist : Byte);compilerpro
 procedure fpc_rol_assign_int64(var AValue : int64;const Dist : Byte);compilerproc;
 procedure fpc_rol_assign_qword(var AValue : QWord;const Dist : Byte);compilerproc;
 {$endif FPC_HAS_INTERNAL_ROX_ASSIGN_QWORD}
+{$endif CPUAVR_16_REGS}
 
 
 function fpc_popcnt_byte(AValue : Byte): Byte;compilerproc;
 function fpc_popcnt_word(AValue : Word): Word;compilerproc;
 function fpc_popcnt_dword(AValue : DWord): DWord;compilerproc;
+{$ifndef CPUAVR_16_REGS}
 function fpc_popcnt_qword(AValue : QWord): QWord;compilerproc;
+{$endif CPUAVR_16_REGS}
 
 
 {$ifndef FPUNONE}
diff --git a/rtl/inc/dos.inc b/rtl/inc/dos.inc
index 68894c073e..81e69e0f15 100644
--- a/rtl/inc/dos.inc
+++ b/rtl/inc/dos.inc
@@ -16,6 +16,7 @@
 
  **********************************************************************}
 
+{$ifdef FPC_HAS_FEATURE_FILEIO}
 procedure DoDirSeparators(var p:shortstring);
 var
   i : longint;
@@ -33,6 +34,7 @@ begin
     if p[i] in AllowDirectorySeparators then
       p[i]:=DirectorySeparator;
 end;
+{$endif FPC_HAS_FEATURE_FILEIO}
 
 {$IFNDEF HAS_DOSEXITCODE}
 {$ifdef FPC_HAS_FEATURE_THREADING}
@@ -234,6 +236,7 @@ end;
 {$IFNDEF HAS_FSPLIT}
 {$push}
 {$warnings off}
+{$ifdef FPC_HAS_FEATURE_FILEIO}
 Procedure FSplit (Path: PathStr; var Dir: DirStr; var Name: NameStr; var Ext: ExtStr);
 var
   DirEnd, ExtStart: Longint;
@@ -276,6 +279,7 @@ begin
   Name := Copy (Path, DirEnd + 1, ExtStart - DirEnd - 1);
   Ext := Copy (Path, ExtStart, Length (Path) - ExtStart + 1);
 end;
+{$endif FPC_HAS_FEATURE_FILEIO}
 {$pop}
 {$ENDIF HAS_FSPLIT}
 
@@ -287,7 +291,9 @@ end;
 {$IFNDEF HAS_FEXPAND}
 
 (* FExpand maintained in standalone include file for easier maintenance. *)
+{$ifdef FPC_HAS_FEATURE_FILEIO}
 {$I fexpand.inc}
+{$endif FPC_HAS_FEATURE_FILEIO}
 
 {$ENDIF HAS_FEXPAND}
 
diff --git a/rtl/inc/dosh.inc b/rtl/inc/dosh.inc
index a6fe01cc0b..faa43c4396 100644
--- a/rtl/inc/dosh.inc
+++ b/rtl/inc/dosh.inc
@@ -109,8 +109,10 @@ Procedure FindClose(Var f: SearchRec);
 Procedure GetFAttr(var f; var attr: word);
 Procedure GetFTime(var f; var time: longint);
 Function  FSearch(path: pathstr; dirlist: string): pathstr;
+{$ifdef FPC_HAS_FEATURE_FILEIO}
 Function  FExpand(const path: pathstr): pathstr;
 Procedure FSplit(path: pathstr; var dir: dirstr; var name: namestr; var ext: extstr);
+{$endif FPC_HAS_FEATURE_FILEIO}
 function  GetShortName(var p : String) : boolean;
 function  GetLongName(var p : String) : boolean;
 
diff --git a/rtl/inc/extpas.pp b/rtl/inc/extpas.pp
index 0cbf660954..17d1d68c95 100644
--- a/rtl/inc/extpas.pp
+++ b/rtl/inc/extpas.pp
@@ -45,6 +45,9 @@ unit extpas;
         year2,month2,mday2,wday2,
         hour,minute,second,sec100 : word;
       begin
+{$ifdef CPUAVR_16_REGS}
+        runerror(217);
+{$else}
         repeat
           GetDate(year1,month1,mday1,wday1);
           GetTime(hour,minute,second,sec100);
@@ -60,6 +63,7 @@ unit extpas;
         ts.minute:=minute;
         ts.second:=second;
         ts.second100:=sec100;
+{$endif CPUAVR_16_REGS}
       end;
 
 
diff --git a/rtl/inc/generic.inc b/rtl/inc/generic.inc
index 8009aed361..efcff2d125 100644
--- a/rtl/inc/generic.inc
+++ b/rtl/inc/generic.inc
@@ -2350,7 +2350,7 @@ end;
 
 {$endif ndef FPC_SYSTEM_HAS_SQR_LONGINT}
 
-
+{$ifndef CPUAVR_16_REGS}
 {$ifndef FPC_SYSTEM_HAS_ABS_INT64}
 
 function abs(l: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -2373,7 +2373,6 @@ end;
 
 {$endif ndef FPC_SYSTEM_HAS_SQR_INT64}
 
-
 {$ifndef FPC_SYSTEM_HAS_SQR_QWORD}
 
 function sqr(l: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -2382,6 +2381,7 @@ begin
 end;
 
 {$endif ndef FPC_SYSTEM_HAS_SQR_INT64}
+{$endif CPUAVR_16_REGS}
 
 {$ifdef CPU16}
 {$ifndef FPC_SYSTEM_HAS_DECLOCKED_SMALLINT}
@@ -2663,6 +2663,7 @@ function SwapEndian(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$en
   end;
 {$endif}
 
+{$ifndef CPUAVR_16_REGS}
 function SwapEndian(const AValue: Int64): Int64;
   begin
     Result := ((AValue shl 8) and $FF00FF00FF00FF00) or
@@ -2682,6 +2683,7 @@ function SwapEndian(const AValue: QWord): QWord;
     Result := (Result shl 32) or ((Result shr 32));
   end;
 {$endif}
+{$endif CPUAVR_16_REGS}
 {$endif FPC_SYSTEM_HAS_SWAPENDIAN}
 
 function BEtoN(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -2728,6 +2730,7 @@ function BEtoN(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 {$endif not cpujvm}
 
 
+{$ifndef CPUAVR_16_REGS}
 function BEtoN(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     {$IFDEF ENDIAN_BIG}
@@ -2748,7 +2751,7 @@ function BEtoN(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
     {$ENDIF}
   end;
 {$endif not cpujvm}
-
+{$endif CPUAVR_16_REGS}
 
 
 function LEtoN(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -2795,6 +2798,7 @@ function LEtoN(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 {$endif not cpujvm}
 
 
+{$ifndef CPUAVR_16_REGS}
 function LEtoN(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     {$IFDEF ENDIAN_LITTLE}
@@ -2815,7 +2819,7 @@ function LEtoN(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
     {$ENDIF}
   end;
 {$endif not cpujvm}
-
+{$endif CPUAVR_16_REGS}
 
 
 function NtoBE(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -2862,6 +2866,7 @@ function NtoBE(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 {$endif not cpujvm}
 
 
+{$ifndef CPUAVR_16_REGS}
 function NtoBE(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     {$IFDEF ENDIAN_BIG}
@@ -2882,7 +2887,7 @@ function NtoBE(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
     {$ENDIF}
   end;
 {$endif not cpujvm}
-
+{$endif CPUAVR_16_REGS}
 
 function NtoLE(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
@@ -2928,6 +2933,7 @@ function NtoLE(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 {$endif not cpujvm}
 
 
+{$ifndef CPUAVR_16_REGS}
 function NtoLE(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     {$IFDEF ENDIAN_LITTLE}
@@ -2948,6 +2954,7 @@ function NtoLE(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
     {$ENDIF}
   end;
 {$endif not cpujvm}
+{$endif CPUAVR_16_REGS}
 
 {$ifndef FPC_SYSTEM_HAS_MEM_BARRIER}
 
@@ -3056,6 +3063,7 @@ function RolDWord(Const AValue : DWord;const Dist : Byte): DWord;{$ifdef SYSTEMI
 {$endif FPC_SYSTEM_HAS_ROX_DWORD}
 {$endif FPC_HAS_INTERNAL_ROX_DWORD}
 
+{$ifndef CPUAVR_16_REGS}
 {$ifndef FPC_HAS_INTERNAL_ROX_QWORD}
 {$ifndef FPC_SYSTEM_HAS_ROX_QWORD}
 
@@ -3111,6 +3119,7 @@ procedure fpc_rol_assign_qword(var AValue : QWord;const Dist : Byte); [Public,Al
   end;
 {$endif FPC_SYSTEM_HAS_ROX_ASSIGN_QWORD}
 {$endif FPC_HAS_INTERNAL_ROX_ASSIGN_QWORD}
+{$endif CPUAVR_16_REGS}
 
 {$ifndef FPC_HAS_INTERNAL_SAR_BYTE}
 {$ifndef FPC_SYSTEM_HAS_SAR_BYTE}
@@ -3139,6 +3148,7 @@ function SarLongint(Const AValue : Longint;const Shift : Byte): Longint;
 {$endif FPC_HAS_INTERNAL_SAR_DWORD}
 {$endif FPC_SYSTEM_HAS_SAR_DWORD}
 
+{$ifndef CPUAVR_16_REGS}
 {$ifndef FPC_HAS_INTERNAL_SAR_QWORD}
 {$ifndef FPC_SYSTEM_HAS_SAR_QWORD}
 function fpc_SarInt64(Const AValue : Int64;const Shift : Byte): Int64; [Public,Alias:'FPC_SARINT64']; compilerproc;
@@ -3160,6 +3170,7 @@ procedure fpc_sar_assign_qword(var AValue : QWord;const Shift : Byte); [Public,A
   end;
 {$endif FPC_HAS_INTERNAL_SAR_ASSIGN_QWORD}
 {$endif FPC_SYSTEM_HAS_SAR_ASSIGN_QWORD}
+{$endif CPUAVR_16_REGS}
 
 {$ifndef FPC_HAS_INTERNAL_BSF_BYTE}
 {$ifndef FPC_SYSTEM_HAS_BSF_BYTE}
@@ -3320,6 +3331,7 @@ function fpc_PopCnt_dword(AValue : DWord): DWord;[Public,Alias:'FPC_POPCNT_DWORD
   end;
 
 
+{$ifndef CPUAVR_16_REGS}
 {$ifndef FPC_SYSTEM_HAS_POPCNT_QWORD}
 function fpc_PopCnt_qword(AValue : QWord): QWord;[Public,Alias:'FPC_POPCNT_QWORD'];compilerproc;
 {$ifdef VER2_6}
@@ -3338,4 +3350,5 @@ function fpc_PopCnt_qword(AValue : QWord): QWord;[Public,Alias:'FPC_POPCNT_QWORD
 {$endif VER2_6}
   end;
 {$endif}
+{$endif CPUAVR_16_REGS}
 
diff --git a/rtl/inc/iso7185.pp b/rtl/inc/iso7185.pp
index f00b78aa24..4589e7515d 100644
--- a/rtl/inc/iso7185.pp
+++ b/rtl/inc/iso7185.pp
@@ -24,16 +24,25 @@ unit iso7185;
     type
       Integer = Longint;
 
+{$ifdef FPC_HAS_FEATURE_TEXTIO}
     Procedure Rewrite(var t : Text);
     Procedure Reset(var t : Text);
+{$endif FPC_HAS_FEATURE_TEXTIO}
+{$ifdef FPC_HAS_FEATURE_FILEIO}
     Procedure Reset(var f : TypedFile);   [INTERNPROC: fpc_in_Reset_TypedFile];
     Procedure Rewrite(var f : TypedFile); [INTERNPROC: fpc_in_Rewrite_TypedFile];
+{$endif FPC_HAS_FEATURE_FILEIO}
 
+{$ifdef FPC_HAS_FEATURE_TEXTIO}
     Procedure Rewrite(var t : Text;const filename : string);
+{$endif FPC_HAS_FEATURE_TEXTIO}
+{$ifdef FPC_HAS_FEATURE_FILEIO}
     Procedure Reset(var t : Text;const filename : string);
     Procedure Reset(var f : TypedFile;const filename : string);   [INTERNPROC: fpc_in_Reset_TypedFile_Name];
     Procedure Rewrite(var f : TypedFile;const filename : string); [INTERNPROC: fpc_in_Rewrite_TypedFile_Name];
+{$endif FPC_HAS_FEATURE_FILEIO}
 
+{$ifdef FPC_HAS_FEATURE_TEXTIO}
     Function Eof(Var t: Text): Boolean;
     Function Eof:Boolean;
     Function Eoln(Var t: Text): Boolean;
@@ -44,13 +53,16 @@ unit iso7185;
 
     Procedure Get(Var t: Text);
     Procedure Put(Var t: Text);
+{$endif FPC_HAS_FEATURE_TEXTIO}
 
+{$ifdef FPC_HAS_FEATURE_FILEIO}
     Procedure Get(Var f: TypedFile);
     Procedure Put(Var f: TypedFile);
     Procedure Seek(var f:TypedFile;Pos:Int64);
     Function FilePos(var f:TypedFile):Int64;
 
     Function Eof(var f:TypedFile): Boolean;
+{$endif FPC_HAS_FEATURE_FILEIO}
 
 {$ifndef FPUNONE}
 {$ifdef FPC_CURRENCY_IS_INT64}
@@ -67,9 +79,12 @@ unit iso7185;
   implementation
 
 
+{$ifdef FPC_HAS_FEATURE_FILEIO}
 {$i isotmp.inc}
- 
+{$endif FPC_HAS_FEATURE_FILEIO}
+
 {$i-}
+{$ifdef FPC_HAS_FEATURE_TEXTIO}
     procedure DoAssign(var t : Text);
 {$ifndef FPC_HAS_FEATURE_RANDOM}
       const
@@ -202,8 +217,10 @@ unit iso7185;
         If TextRec(t).BufPos>=TextRec(t).BufSize Then
           FileFunc(TextRec(t).InOutFunc)(TextRec(t));
       end;
+{$endif FPC_HAS_FEATURE_TEXTIO}
 
 
+{$ifdef FPC_HAS_FEATURE_FILEIO}
     procedure Get(var f:TypedFile);[IOCheck];
       Begin
         if not(eof(f)) then
@@ -248,6 +265,7 @@ unit iso7185;
           (FileRec(f).mode=fmInput) then
           dec(FilePos);
       End;
+{$endif FPC_HAS_FEATURE_FILEIO}
 
 
 {$ifndef FPUNONE}
diff --git a/rtl/inc/sstrings.inc b/rtl/inc/sstrings.inc
index f8bcce6430..c4ed2ae34d 100644
--- a/rtl/inc/sstrings.inc
+++ b/rtl/inc/sstrings.inc
@@ -683,6 +683,7 @@ end;
 { also define alias for internal use in the system unit }
 procedure fpc_shortstr_bool(b : boolean;len:sizeint;out s:shortstring);external {$ifndef cpujvm}name 'FPC_SHORTSTR_BOOL'{$endif};
 
+{$ifndef CPUAVR_16_REGS}
 procedure fpc_shortstr_currency({$ifdef cpujvm}constref{$endif} c : currency; len,f : SizeInt; out s : shortstring);[public,alias:'FPC_SHORTSTR_CURRENCY']; compilerproc;
 const
   MinLen = 8; { Minimal string length in scientific format }
@@ -861,6 +862,7 @@ begin
       Dec(j);
     end;
 end;
+{$endif CPUAVR_16_REGS}
 
 {
    Array Of Char Str() helpers
@@ -1327,6 +1329,9 @@ end;
   const maxqword=qword($ffffffffffffffff);
 
   begin
+{$ifdef EXCLUDE_COMPLEX_PROCS}
+    runerror(219);
+{$else EXCLUDE_COMPLEX_PROCS}
     fpc_val_qword_shortstr:=0;
     Code:=InitVal(s,negative,base);
     If Negative or (Code>length(s)) Then
@@ -1357,6 +1362,7 @@ end;
        inc(code);
      end;
     code := 0;
+{$endif EXCLUDE_COMPLEX_PROCS}
   end;
 
 {$endif CPU64}
diff --git a/rtl/inc/system.inc b/rtl/inc/system.inc
index 472366bf2b..ef0b6e24e2 100644
--- a/rtl/inc/system.inc
+++ b/rtl/inc/system.inc
@@ -392,6 +392,7 @@ Begin
   Swap:=(X shl 16) + (X shr 16);
 End;
 
+{$ifndef CPUAVR_16_REGS}
 Function Swap (X : QWord) : QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   Swap:=(X shl 32) + (X shr 32);
@@ -401,6 +402,7 @@ Function Swap (X : Int64) : Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
 Begin
   Swap:=(X shl 32) + (X shr 32);
 End;
+{$endif CPUAVR_16_REGS}
 
 {$ifdef SUPPORT_DOUBLE}
 operator := (b:real48) d:double;{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -427,7 +429,9 @@ end;
 {$I genmath.inc}
 {$endif}
 
+{$ifndef CPUAVR_16_REGS}
 {$i gencurr.inc}
+{$endif CPUAVR_16_REGS}
 
 
 function aligntoptr(p : pointer) : pointer;inline;
@@ -489,8 +493,10 @@ type
 {$i sstrings.inc}
 
 { requires sstrings.inc for initval }
+{$ifndef CPUAVR_16_REGS}
 {$I int64p.inc}
 {$I int64.inc}
+{$endif CPUAVR_16_REGS}
 
 {Requires int64.inc, since that contains the VAL functions for int64 and qword}
 {$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
@@ -1329,6 +1335,7 @@ begin
 end;
 
 
+{$ifdef FPC_HAS_FEATURE_FILEIO}
 Procedure dump_stack(var f : text;fp : Pointer; addr : CodePointer);
 var
   i : Longint;
@@ -1385,6 +1392,7 @@ begin
   end;
 {$endif FPC_HAS_FEATURE_EXCEPTIONS}
 end;
+{$endif FPC_HAS_FEATURE_FILEIO}
 
 
 {$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
diff --git a/rtl/inc/systemh.inc b/rtl/inc/systemh.inc
index 9b76e2f2a1..520d388457 100644
--- a/rtl/inc/systemh.inc
+++ b/rtl/inc/systemh.inc
@@ -860,15 +860,19 @@ Function Swap (X : Word) : Word;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst
 Function Swap (X : Integer) : Integer;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_word];
 Function Swap (X : Longint) : Longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_long];
 Function Swap (X : Cardinal) : Cardinal;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_long];
+{$ifndef CPUAVR_16_REGS}
 Function Swap (X : QWord) : QWord;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_qword];
 Function Swap (X : Int64) : Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:fpc_in_const_swap_qword];
+{$endif CPUAVR_16_REGS}
 
 Function Align (Addr : PtrUInt; Alignment : PtrUInt) : PtrUInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Align (Addr : Pointer; Alignment : PtrUInt) : Pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 {$ifdef FPC_HAS_FEATURE_RANDOM}
 Function  Random(l:longint):longint;
+{$ifndef CPUAVR_16_REGS}
 Function  Random(l:int64):int64;
+{$endif CPUAVR_16_REGS}
 {$ifndef FPUNONE}
 Function  Random: extended;
 {$endif}
@@ -901,7 +905,9 @@ Function Abs(l:Longint):Longint;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINL
 {$define FPC_SYSTEM_HAS_ABS_INT64}
 Function Abs(l:Int64):Int64;[internproc:fpc_in_abs_long];
 {$else FPC_HAS_INTERNAL_ABS_INT64}
+{$ifndef CPUAVR_16_REGS}
 Function Abs(l:Int64):Int64;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUAVR_16_REGS}
 {$endif FPC_HAS_INTERNAL_ABS_INT64}
 {$if defined(CPUINT8)}
 Function Sqr(l:shortint):shortint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -910,8 +916,10 @@ Function Sqr(l:shortint):shortint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMI
 Function Sqr(l:smallint):smallint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
 {$endif CPUINT16 or CPUINT8}
 Function Sqr(l:Longint):Longint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
+{$ifndef CPUAVR_16_REGS}
 Function Sqr(l:Int64):Int64;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Sqr(l:QWord):QWord;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUAVR_16_REGS}
 {$if defined(CPUINT8)}
 Function Odd(l:shortint):Boolean;[internconst:fpc_in_const_odd];{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Odd(l:byte):Boolean;[internconst:fpc_in_const_odd];{$ifdef SYSTEMINLINE}inline;{$endif}
@@ -929,36 +937,46 @@ function SwapEndian(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inlin
 function SwapEndian(const AValue: Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 function SwapEndian(const AValue: LongInt): LongInt;
 function SwapEndian(const AValue: DWord): DWord;
+{$ifndef CPUAVR_16_REGS}
 function SwapEndian(const AValue: Int64): Int64;
 function SwapEndian(const AValue: QWord): QWord;
+{$endif CPUAVR_16_REGS}
 
 function BEtoN(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function BEtoN(const AValue: Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 function BEtoN(const AValue: LongInt): LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function BEtoN(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$ifndef CPUAVR_16_REGS}
 function BEtoN(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
 function BEtoN(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUAVR_16_REGS}
 
 function LEtoN(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function LEtoN(const AValue: Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 function LEtoN(const AValue: LongInt): LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function LEtoN(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$ifndef CPUAVR_16_REGS}
 function LEtoN(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
 function LEtoN(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUAVR_16_REGS}
 
 function NtoBE(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoBE(const AValue: Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoBE(const AValue: LongInt): LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoBE(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$ifndef CPUAVR_16_REGS}
 function NtoBE(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoBE(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUAVR_16_REGS}
 
 function NtoLE(const AValue: SmallInt): SmallInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoLE(const AValue: Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoLE(const AValue: LongInt): LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoLE(const AValue: DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$ifndef CPUAVR_16_REGS}
 function NtoLE(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoLE(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUAVR_16_REGS}
 
 {$ifdef FPC_HAS_INTERNAL_ROX}
 
@@ -1030,11 +1048,13 @@ function RorQWord(Const AValue : QWord;const Dist : Byte): QWord;[internproc:fpc
 function RolQWord(Const AValue : QWord): QWord;[internproc:fpc_in_rol_x];
 function RolQWord(Const AValue : QWord;const Dist : Byte): QWord;[internproc:fpc_in_rol_x_x];
 {$else FPC_HAS_INTERNAL_ROX_QWORD}
+{$ifndef CPUAVR_16_REGS}
 function RorQWord(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 function RorQWord(Const AValue : QWord;const Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 function RolQWord(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 function RolQWord(Const AValue : QWord;const Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUAVR_16_REGS}
 {$endif FPC_HAS_INTERNAL_ROX_QWORD}
 
 {$ifdef FPC_HAS_INTERNAL_SAR}
@@ -1080,7 +1100,9 @@ function SarLongint(Const AValue : Longint;const Shift : Byte = 1): Longint;
 function SarInt64(Const AValue : Int64): Int64;[internproc:fpc_in_sar_x];
 function SarInt64(Const AValue : Int64;Shift : Byte): Int64;[internproc:fpc_in_sar_x_y];
 {$ifndef FPC_HAS_INTERNAL_SAR_QWORD}
+{$ifndef CPUAVR_16_REGS}
 function fpc_SarInt64(Const AValue : Int64;const Shift : Byte): Int64;compilerproc;
+{$endif CPUAVR_16_REGS}
 {$endif FPC_HAS_INTERNAL_SAR_QWORD}
 
 {$ifdef FPC_HAS_INTERNAL_BSF}
@@ -1160,7 +1182,9 @@ function PopCnt(Const AValue : QWord): QWord;[internproc:fpc_in_popcnt_x];
 {$I mathh.inc}
 {$endif}
 { currency math routines }
+{$ifndef CPUAVR_16_REGS}
 {$I currh.inc}
+{$endif CPUAVR_16_REGS}
 
 {****************************************************************************
                          Addr/Pointer Handling
@@ -1548,8 +1572,10 @@ Function  ParamCount:Longint;
 Function  ParamStr(l:Longint):string;
 {$endif FPC_HAS_FEATURE_COMMANDARGS}
 
+{$ifndef CPUAVR_16_REGS}
 Procedure Dump_Stack(var f : text;fp:pointer;addr : codepointer = nil);
 procedure Dump_Stack(var f : text;skipframes : longint);
+{$endif CPUAVR_16_REGS}
 {$ifdef FPC_HAS_FEATURE_EXCEPTIONS}
 procedure DumpExceptionBacktrace(var f:text);
 {$endif FPC_HAS_FEATURE_EXCEPTIONS}
avrtiny-rtl.patch (26,194 bytes)   

Florian

2020-02-14 22:29

administrator   ~0121101

The patch is too invasive, the CPU dependent defines shouldn't be used in the headers. However, with my last commits, I can cross compile everything being included in avr-embedded with SUBARCH=avrtiny.

Christo Crause

2020-02-15 09:42

reporter   ~0121103

Noted, thanks.

Issue History

Date Modified Username Field Change
2020-02-01 14:36 Christo Crause New Issue
2020-02-01 14:36 Christo Crause File Added: avrtiny-rtl.patch
2020-02-14 22:29 Florian Assigned To => Florian
2020-02-14 22:29 Florian Status new => resolved
2020-02-14 22:29 Florian Resolution open => won't fix
2020-02-14 22:29 Florian Fixed in Version => 3.3.1
2020-02-14 22:29 Florian FPCTarget => -
2020-02-14 22:29 Florian Note Added: 0121101
2020-02-15 09:42 Christo Crause Status resolved => closed
2020-02-15 09:42 Christo Crause Note Added: 0121103