Commit 4f852a1a by Eric Botcazou Committed by Eric Botcazou

osint.adb: Add use type clause for CRTL.size_t.

	* osint.adb: Add use type clause for CRTL.size_t.
	(C_String_Length): Return CRTL.size_t instead of Integer.
	(To_Path_String_Access): Take CRTL.size_t instead of Integer.
	(Get_Libraries_From_Registry): Use CRTL throughout.
	(To_Canonical_Dir_Spec): Use CRTL.size_t instead of Integer.
	(To_Canonical_File_List): Likewise.
	(To_Canonical_File_Spec): Likewise.
	(To_Canonical_Path_Spec): Likewise.
	(To_Host_Dir_Spec): Likewise.
	(To_Host_File_Spec): Likewise.
	(Update_Path): Use CRTL throughout.
	* s-shasto.adb: Add with clause for System.CRTL.
	(Initialize): Rename CRTL.strncpy instead of importing it manually.

From-SVN: r231066
parent 2056c5ed
2015-11-30 Eric Botcazou <ebotcazou@adacore.com> 2015-11-30 Eric Botcazou <ebotcazou@adacore.com>
* osint.adb: Add use type clause for CRTL.size_t.
(C_String_Length): Return CRTL.size_t instead of Integer.
(To_Path_String_Access): Take CRTL.size_t instead of Integer.
(Get_Libraries_From_Registry): Use CRTL throughout.
(To_Canonical_Dir_Spec): Use CRTL.size_t instead of Integer.
(To_Canonical_File_List): Likewise.
(To_Canonical_File_Spec): Likewise.
(To_Canonical_Path_Spec): Likewise.
(To_Host_Dir_Spec): Likewise.
(To_Host_File_Spec): Likewise.
(Update_Path): Use CRTL throughout.
* s-shasto.adb: Add with clause for System.CRTL.
(Initialize): Rename CRTL.strncpy instead of importing it manually.
2015-11-30 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/gigi.h (create_var_decl): Adjust prototype. * gcc-interface/gigi.h (create_var_decl): Adjust prototype.
(create_subprog_decl): Likewise. (create_subprog_decl): Likewise.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Rename * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Rename
......
...@@ -46,6 +46,8 @@ with GNAT.HTable; ...@@ -46,6 +46,8 @@ with GNAT.HTable;
package body Osint is package body Osint is
use type CRTL.size_t;
Running_Program : Program_Type := Unspecified; Running_Program : Program_Type := Unspecified;
-- comment required here ??? -- comment required here ???
...@@ -135,12 +137,12 @@ package body Osint is ...@@ -135,12 +137,12 @@ package body Osint is
-- A version of Smart_Find_File that also returns a cache of the file -- A version of Smart_Find_File that also returns a cache of the file
-- attributes for later reuse -- attributes for later reuse
function C_String_Length (S : Address) return Integer; function C_String_Length (S : Address) return CRTL.size_t;
-- Returns length of a C string (zero for a null address) -- Returns length of a C string (zero for a null address)
function To_Path_String_Access function To_Path_String_Access
(Path_Addr : Address; (Path_Addr : Address;
Path_Len : Integer) return String_Access; Path_Len : CRTL.size_t) return String_Access;
-- Converts a C String to an Ada String. Are we doing this to avoid withing -- Converts a C String to an Ada String. Are we doing this to avoid withing
-- Interfaces.C.Strings ??? -- Interfaces.C.Strings ???
-- Caller must free result. -- Caller must free result.
...@@ -419,27 +421,18 @@ package body Osint is ...@@ -419,27 +421,18 @@ package body Osint is
pragma Import (C, C_Get_Libraries_From_Registry, pragma Import (C, C_Get_Libraries_From_Registry,
"__gnat_get_libraries_from_registry"); "__gnat_get_libraries_from_registry");
function Strlen (Str : Address) return Integer;
pragma Import (C, Strlen, "strlen");
procedure Strncpy (X : Address; Y : Address; Length : Integer);
pragma Import (C, Strncpy, "strncpy");
procedure C_Free (Str : Address);
pragma Import (C, C_Free, "free");
Result_Ptr : Address; Result_Ptr : Address;
Result_Length : Integer; Result_Length : CRTL.size_t;
Out_String : String_Ptr; Out_String : String_Ptr;
begin begin
Result_Ptr := C_Get_Libraries_From_Registry; Result_Ptr := C_Get_Libraries_From_Registry;
Result_Length := Strlen (Result_Ptr); Result_Length := CRTL.strlen (Result_Ptr);
Out_String := new String (1 .. Result_Length); Out_String := new String (1 .. Integer (Result_Length));
Strncpy (Out_String.all'Address, Result_Ptr, Result_Length); CRTL.strncpy (Out_String.all'Address, Result_Ptr, Result_Length);
C_Free (Result_Ptr); CRTL.free (Result_Ptr);
return Out_String; return Out_String;
end Get_Libraries_From_Registry; end Get_Libraries_From_Registry;
...@@ -673,14 +666,12 @@ package body Osint is ...@@ -673,14 +666,12 @@ package body Osint is
-- C_String_Length -- -- C_String_Length --
--------------------- ---------------------
function C_String_Length (S : Address) return Integer is function C_String_Length (S : Address) return CRTL.size_t is
function Strlen (S : Address) return Integer;
pragma Import (C, Strlen, "strlen");
begin begin
if S = Null_Address then if S = Null_Address then
return 0; return 0;
else else
return Strlen (S); return CRTL.strlen (S);
end if; end if;
end C_String_Length; end C_String_Length;
...@@ -2959,7 +2950,7 @@ package body Osint is ...@@ -2959,7 +2950,7 @@ package body Osint is
C_Host_Dir : String (1 .. Host_Dir'Length + 1); C_Host_Dir : String (1 .. Host_Dir'Length + 1);
Canonical_Dir_Addr : Address; Canonical_Dir_Addr : Address;
Canonical_Dir_Len : Integer; Canonical_Dir_Len : CRTL.size_t;
begin begin
C_Host_Dir (1 .. Host_Dir'Length) := Host_Dir; C_Host_Dir (1 .. Host_Dir'Length) := Host_Dir;
...@@ -3023,7 +3014,7 @@ package body Osint is ...@@ -3023,7 +3014,7 @@ package body Osint is
declare declare
Canonical_File_List : String_Access_List (1 .. Num_Files); Canonical_File_List : String_Access_List (1 .. Num_Files);
Canonical_File_Addr : Address; Canonical_File_Addr : Address;
Canonical_File_Len : Integer; Canonical_File_Len : CRTL.size_t;
begin begin
-- Retrieve the expanded directory names and build the list -- Retrieve the expanded directory names and build the list
...@@ -3056,7 +3047,7 @@ package body Osint is ...@@ -3056,7 +3047,7 @@ package body Osint is
C_Host_File : String (1 .. Host_File'Length + 1); C_Host_File : String (1 .. Host_File'Length + 1);
Canonical_File_Addr : Address; Canonical_File_Addr : Address;
Canonical_File_Len : Integer; Canonical_File_Len : CRTL.size_t;
begin begin
C_Host_File (1 .. Host_File'Length) := Host_File; C_Host_File (1 .. Host_File'Length) := Host_File;
...@@ -3091,7 +3082,7 @@ package body Osint is ...@@ -3091,7 +3082,7 @@ package body Osint is
C_Host_Path : String (1 .. Host_Path'Length + 1); C_Host_Path : String (1 .. Host_Path'Length + 1);
Canonical_Path_Addr : Address; Canonical_Path_Addr : Address;
Canonical_Path_Len : Integer; Canonical_Path_Len : CRTL.size_t;
begin begin
C_Host_Path (1 .. Host_Path'Length) := Host_Path; C_Host_Path (1 .. Host_Path'Length) := Host_Path;
...@@ -3126,7 +3117,7 @@ package body Osint is ...@@ -3126,7 +3117,7 @@ package body Osint is
C_Canonical_Dir : String (1 .. Canonical_Dir'Length + 1); C_Canonical_Dir : String (1 .. Canonical_Dir'Length + 1);
Host_Dir_Addr : Address; Host_Dir_Addr : Address;
Host_Dir_Len : Integer; Host_Dir_Len : CRTL.size_t;
begin begin
C_Canonical_Dir (1 .. Canonical_Dir'Length) := Canonical_Dir; C_Canonical_Dir (1 .. Canonical_Dir'Length) := Canonical_Dir;
...@@ -3158,7 +3149,7 @@ package body Osint is ...@@ -3158,7 +3149,7 @@ package body Osint is
C_Canonical_File : String (1 .. Canonical_File'Length + 1); C_Canonical_File : String (1 .. Canonical_File'Length + 1);
Host_File_Addr : Address; Host_File_Addr : Address;
Host_File_Len : Integer; Host_File_Len : CRTL.size_t;
begin begin
C_Canonical_File (1 .. Canonical_File'Length) := Canonical_File; C_Canonical_File (1 .. Canonical_File'Length) := Canonical_File;
...@@ -3181,9 +3172,9 @@ package body Osint is ...@@ -3181,9 +3172,9 @@ package body Osint is
function To_Path_String_Access function To_Path_String_Access
(Path_Addr : Address; (Path_Addr : Address;
Path_Len : Integer) return String_Access Path_Len : CRTL.size_t) return String_Access
is is
subtype Path_String is String (1 .. Path_Len); subtype Path_String is String (1 .. Integer (Path_Len));
type Path_String_Access is access Path_String; type Path_String_Access is access Path_String;
function Address_To_Access is new function Address_To_Access is new
...@@ -3196,9 +3187,9 @@ package body Osint is ...@@ -3196,9 +3187,9 @@ package body Osint is
Return_Val : String_Access; Return_Val : String_Access;
begin begin
Return_Val := new String (1 .. Path_Len); Return_Val := new String (1 .. Integer (Path_Len));
for J in 1 .. Path_Len loop for J in 1 .. Integer (Path_Len) loop
Return_Val (J) := Path_Access (J); Return_Val (J) := Path_Access (J);
end loop; end loop;
...@@ -3214,27 +3205,21 @@ package body Osint is ...@@ -3214,27 +3205,21 @@ package body Osint is
function C_Update_Path (Path, Component : Address) return Address; function C_Update_Path (Path, Component : Address) return Address;
pragma Import (C, C_Update_Path, "update_path"); pragma Import (C, C_Update_Path, "update_path");
function Strlen (Str : Address) return Integer;
pragma Import (C, Strlen, "strlen");
procedure Strncpy (X : Address; Y : Address; Length : Integer);
pragma Import (C, Strncpy, "strncpy");
In_Length : constant Integer := Path'Length; In_Length : constant Integer := Path'Length;
In_String : String (1 .. In_Length + 1); In_String : String (1 .. In_Length + 1);
Component_Name : aliased String := "GCC" & ASCII.NUL; Component_Name : aliased String := "GCC" & ASCII.NUL;
Result_Ptr : Address; Result_Ptr : Address;
Result_Length : Integer; Result_Length : CRTL.size_t;
Out_String : String_Ptr; Out_String : String_Ptr;
begin begin
In_String (1 .. In_Length) := Path.all; In_String (1 .. In_Length) := Path.all;
In_String (In_Length + 1) := ASCII.NUL; In_String (In_Length + 1) := ASCII.NUL;
Result_Ptr := C_Update_Path (In_String'Address, Component_Name'Address); Result_Ptr := C_Update_Path (In_String'Address, Component_Name'Address);
Result_Length := Strlen (Result_Ptr); Result_Length := CRTL.strlen (Result_Ptr);
Out_String := new String (1 .. Result_Length); Out_String := new String (1 .. Integer (Result_Length));
Strncpy (Out_String.all'Address, Result_Ptr, Result_Length); CRTL.strncpy (Out_String.all'Address, Result_Ptr, Result_Length);
return Out_String; return Out_String;
end Update_Path; end Update_Path;
......
...@@ -37,6 +37,7 @@ with System.Global_Locks; ...@@ -37,6 +37,7 @@ with System.Global_Locks;
with System.Soft_Links; with System.Soft_Links;
with System; with System;
with System.CRTL;
with System.File_Control_Block; with System.File_Control_Block;
with System.File_IO; with System.File_IO;
with System.HTable; with System.HTable;
...@@ -270,24 +271,26 @@ package body System.Shared_Storage is ...@@ -270,24 +271,26 @@ package body System.Shared_Storage is
procedure Get_Env_Value_Ptr (Name, Length, Ptr : Address); procedure Get_Env_Value_Ptr (Name, Length, Ptr : Address);
pragma Import (C, Get_Env_Value_Ptr, "__gnat_getenv"); pragma Import (C, Get_Env_Value_Ptr, "__gnat_getenv");
procedure Strncpy (Astring_Addr, Cstring : Address; N : Integer); subtype size_t is CRTL.size_t;
pragma Import (C, Strncpy, "strncpy");
procedure Strncpy (dest, src : System.Address; n : size_t)
renames CRTL.strncpy;
Dir_Name : aliased constant String := Dir_Name : aliased constant String :=
"SHARED_MEMORY_DIRECTORY" & ASCII.NUL; "SHARED_MEMORY_DIRECTORY" & ASCII.NUL;
Env_Value_Ptr : aliased Address; Env_Value_Ptr : aliased Address;
Env_Value_Length : aliased Integer; Env_Value_Len : aliased Integer;
begin begin
if Dir = null then if Dir = null then
Get_Env_Value_Ptr Get_Env_Value_Ptr
(Dir_Name'Address, Env_Value_Length'Address, Env_Value_Ptr'Address); (Dir_Name'Address, Env_Value_Len'Address, Env_Value_Ptr'Address);
Dir := new String (1 .. Env_Value_Length); Dir := new String (1 .. Env_Value_Len);
if Env_Value_Length > 0 then if Env_Value_Len > 0 then
Strncpy (Dir.all'Address, Env_Value_Ptr, Env_Value_Length); Strncpy (Dir.all'Address, Env_Value_Ptr, size_t (Env_Value_Len));
end if; end if;
System.Global_Locks.Create_Lock (Global_Lock, Dir.all & "__lock"); System.Global_Locks.Create_Lock (Global_Lock, Dir.all & "__lock");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment