Преглед изворни кода

Fix types on embedded RTL.
Optimize consoleio for size on AVR.
Add support for RISC-V.
Regenerated makefile

git-svn-id: trunk@42333 -
(cherry picked from commit 9c77e87dd0dcb7a59ac1b899fbb8e2d565204f34)

Jeppe Johansen пре 6 година
родитељ
комит
0b182a1620

+ 16 - 0
rtl/embedded/Makefile

@@ -477,6 +477,22 @@ ifeq ($(CPU_UNITS_DEFINED),)
 $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
 endif
 endif
+ifeq ($(ARCH),riscv32)
+CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
+CPU_UNITS=
+CPU_UNITS_DEFINED=1
+ifeq ($(CPU_UNITS_DEFINED),)
+$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
+endif
+endif
+ifeq ($(ARCH),riscv64)
+CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
+CPU_UNITS=
+CPU_UNITS_DEFINED=1
+ifeq ($(CPU_UNITS_DEFINED),)
+$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
+endif
+endif
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph
 ifeq ($(FULL_TARGET),i386-linux)

+ 18 - 0
rtl/embedded/Makefile.fpc

@@ -200,6 +200,24 @@ $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNIT
 endif
 endif
 
+ifeq ($(ARCH),riscv32)
+CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
+CPU_UNITS=
+CPU_UNITS_DEFINED=1
+ifeq ($(CPU_UNITS_DEFINED),)
+$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
+endif
+endif
+
+ifeq ($(ARCH),riscv64)
+CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
+CPU_UNITS=
+CPU_UNITS_DEFINED=1
+ifeq ($(CPU_UNITS_DEFINED),)
+$(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
+endif
+endif
+
 # Paths
 OBJPASDIR=$(RTL)/objpas
 GRAPHDIR=$(INC)/graph

+ 17 - 5
rtl/embedded/consoleio.pp

@@ -20,7 +20,7 @@ Unit consoleio;
       TWriteCharFunc = function(ACh: char; AUserData: pointer): boolean;
       TReadCharFunc = function(var ACh: char; AUserData: pointer): boolean;
 
-    procedure OpenIO(var f: Text; AWrite: TWriteCharFunc; ARead: TReadCharFunc; AMode:longint; AUserData: pointer);
+    procedure OpenIO(var f: Text; AWrite: TWriteCharFunc; ARead: TReadCharFunc; AMode: word; AUserData: pointer);
 
   implementation
 
@@ -49,7 +49,7 @@ Unit consoleio;
       begin
       end;
 
-    function ReadData(Func: TReadCharFunc; UserData: pointer; Buffer: pchar; count: longint): longint;
+    function ReadData(Func: TReadCharFunc; UserData: pointer; Buffer: pchar; count: SizeInt): SizeInt;
       var
         c: char;
         got_linechar: boolean;
@@ -83,7 +83,7 @@ Unit consoleio;
       var
         userdata: PUserData;
         p: pchar;
-        i: longint;
+        i: SizeInt;
       begin
         if t.BufPos=0 then exit;
         userdata:[email protected][1];
@@ -103,11 +103,20 @@ Unit consoleio;
         t.BufPos:=0;
       end;
 
-    procedure OpenIO(var f: Text; AWrite: TWriteCharFunc; ARead: TReadCharFunc; AMode:longint; AUserData: pointer);
+    procedure OpenIO(var f: Text; AWrite: TWriteCharFunc; ARead: TReadCharFunc; AMode: word; AUserData: pointer);
       var
         userdata: PUserData;
       begin
-        Assign(f,'');
+        { Essentially just init everything, more or less what Assign(f,'');
+          does }
+        FillChar(f,SizeOf(TextRec),0);
+        { only set things that are not zero }
+        TextRec(f).Handle:=UnusedHandle;
+        TextRec(f).BufSize:=TextRecBufSize;
+        TextRec(f).Bufptr:=@TextRec(f).Buffer;
+        TextRec(f).OpenFunc:=nil;
+        TextRec(f).LineEnd := #13#10;
+
         userdata:=@TextRec(f).UserData[1];
         TextRec(f).Mode:=AMode;
         case AMode of
@@ -148,6 +157,7 @@ var
 var
   pstdout : ^Text;
 
+{$ifndef CPUAVR}
 initialization
   { Setup stdin, stdout and stderr }
   SysInitStdIO;
@@ -163,6 +173,8 @@ finalization
      Writeln(pstdout^,'');
    End;
   SysFlushStdIO;
+{$endif CPUAVR}
+
 end.
 
 

+ 1 - 1
rtl/embedded/sysfile.inc

@@ -107,7 +107,7 @@ begin
 end;
 
 
-function do_isdevice(handle: longint): boolean;
+function do_isdevice(handle: THandle): boolean;
 begin
   result := false;
   if assigned (rtl_do_isdevice) then

+ 1 - 1
rtl/embedded/sysosh.inc

@@ -18,7 +18,7 @@
 {Platform specific information}
 type
   { fd are int in C also for 64bit targets (x86_64) }
-  THandle = Longint;
+  THandle = SizeInt;
   { pthread_t is defined as an "unsigned long" }
   {$ifdef CPU64}
   TThreadID = QWord;

+ 32 - 0
rtl/embedded/system.cfg

@@ -214,3 +214,35 @@
 -CX
 -XX
 #endif
+
+#ifdef CPURISCV32
+-SfSOFTFPU
+-SfCLASSES
+-SfEXCEPTIONS
+-SfANSISTRINGS
+-SfRTTI
+-SfWIDESTRINGS
+-SfDYNARRAYS
+-SfTHREADING
+-SfVARIANTS
+-SfOBJECTS
+-SfCOMMANDARGS
+-SfRANDOM
+-SfRESOURCES
+#endif CPURISCV32
+
+#ifdef CPURISCV64
+-SfSOFTFPU
+-SfCLASSES
+-SfEXCEPTIONS
+-SfANSISTRINGS
+-SfRTTI
+-SfWIDESTRINGS
+-SfDYNARRAYS
+-SfTHREADING
+-SfVARIANTS
+-SfOBJECTS
+-SfCOMMANDARGS
+-SfRANDOM
+-SfRESOURCES
+#endif CPURISCV64

+ 10 - 10
rtl/embedded/sysutils.pp

@@ -47,7 +47,7 @@ uses
 {****************************************************************************
                               File Functions
 ****************************************************************************}
-function FileOpen(const FileName: RawByteString; Mode: Integer): LongInt;
+function FileOpen(const FileName: RawByteString; Mode: Integer): THandle;
 begin
   result := -1;
 end;
@@ -58,54 +58,54 @@ begin
 end;
 
 
-function FileSetDate(Handle, Age: LongInt) : LongInt;
+function FileSetDate(Handle: THandle; Age: LongInt) : Longint;
 begin
   result := -1;
 end;
 
 
-function FileCreate(const FileName: RawByteString) : LongInt;
+function FileCreate(const FileName: RawByteString) : THandle;
 begin
   result := -1;
 end;
 
 
-function FileCreate(const FileName: RawByteString; Rights: integer): LongInt;
+function FileCreate(const FileName: RawByteString; Rights: integer): THandle;
 begin
   result := -1;
 end;
 
 
-function FileCreate(const FileName: RawByteString; ShareMode: integer; rights : integer): LongInt;
+function FileCreate(const FileName: RawByteString; ShareMode: integer; rights : integer): THandle;
 begin
   result := -1;
 end;
 
 
-function FileRead(Handle: LongInt; Out Buffer; Count: LongInt): LongInt;
+function FileRead(Handle: THandle; Out Buffer; Count: LongInt): LongInt;
 begin
   result := -1;
 end;
 
 
-function FileWrite(Handle: LongInt; const Buffer; Count: LongInt): LongInt;
+function FileWrite(Handle: THandle; const Buffer; Count: LongInt): LongInt;
 begin
   result := -1;
 end;
 
 
-function FileSeek(Handle, FOffset, Origin: LongInt) : LongInt;
+function FileSeek(Handle: THandle; FOffset, Origin: LongInt) : LongInt;
 begin
   result := -1;
 end;
 
-function FileSeek(Handle: LongInt; FOffset: Int64; Origin: Longint): Int64;
+function FileSeek(Handle: THandle; FOffset: Int64; Origin: Longint): Int64;
 begin
   result := -1;
 end;
 
 
-procedure FileClose(Handle: LongInt);
+procedure FileClose(Handle: THandle);
 begin
 end;