package body Osint is
+ use type CRTL.size_t;
+
Running_Program : Program_Type := Unspecified;
-- comment required here ???
-- A version of Smart_Find_File that also returns a cache of the file
-- 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)
function To_Path_String_Access
(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
-- Interfaces.C.Strings ???
-- Caller must free result.
pragma Import (C, C_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_Length : Integer;
+ Result_Length : CRTL.size_t;
Out_String : String_Ptr;
begin
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);
- Strncpy (Out_String.all'Address, Result_Ptr, Result_Length);
+ Out_String := new String (1 .. Integer (Result_Length));
+ CRTL.strncpy (Out_String.all'Address, Result_Ptr, Result_Length);
- C_Free (Result_Ptr);
+ CRTL.free (Result_Ptr);
return Out_String;
end Get_Libraries_From_Registry;
-- C_String_Length --
---------------------
- function C_String_Length (S : Address) return Integer is
- function Strlen (S : Address) return Integer;
- pragma Import (C, Strlen, "strlen");
+ function C_String_Length (S : Address) return CRTL.size_t is
begin
if S = Null_Address then
return 0;
else
- return Strlen (S);
+ return CRTL.strlen (S);
end if;
end C_String_Length;
C_Host_Dir : String (1 .. Host_Dir'Length + 1);
Canonical_Dir_Addr : Address;
- Canonical_Dir_Len : Integer;
+ Canonical_Dir_Len : CRTL.size_t;
begin
C_Host_Dir (1 .. Host_Dir'Length) := Host_Dir;
declare
Canonical_File_List : String_Access_List (1 .. Num_Files);
Canonical_File_Addr : Address;
- Canonical_File_Len : Integer;
+ Canonical_File_Len : CRTL.size_t;
begin
-- Retrieve the expanded directory names and build the list
C_Host_File : String (1 .. Host_File'Length + 1);
Canonical_File_Addr : Address;
- Canonical_File_Len : Integer;
+ Canonical_File_Len : CRTL.size_t;
begin
C_Host_File (1 .. Host_File'Length) := Host_File;
C_Host_Path : String (1 .. Host_Path'Length + 1);
Canonical_Path_Addr : Address;
- Canonical_Path_Len : Integer;
+ Canonical_Path_Len : CRTL.size_t;
begin
C_Host_Path (1 .. Host_Path'Length) := Host_Path;
C_Canonical_Dir : String (1 .. Canonical_Dir'Length + 1);
Host_Dir_Addr : Address;
- Host_Dir_Len : Integer;
+ Host_Dir_Len : CRTL.size_t;
begin
C_Canonical_Dir (1 .. Canonical_Dir'Length) := Canonical_Dir;
C_Canonical_File : String (1 .. Canonical_File'Length + 1);
Host_File_Addr : Address;
- Host_File_Len : Integer;
+ Host_File_Len : CRTL.size_t;
begin
C_Canonical_File (1 .. Canonical_File'Length) := Canonical_File;
function To_Path_String_Access
(Path_Addr : Address;
- Path_Len : Integer) return String_Access
+ Path_Len : CRTL.size_t) return String_Access
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;
function Address_To_Access is new
Return_Val : String_Access;
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);
end loop;
function C_Update_Path (Path, Component : Address) return Address;
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_String : String (1 .. In_Length + 1);
Component_Name : aliased String := "GCC" & ASCII.NUL;
Result_Ptr : Address;
- Result_Length : Integer;
+ Result_Length : CRTL.size_t;
Out_String : String_Ptr;
begin
In_String (1 .. In_Length) := Path.all;
In_String (In_Length + 1) := ASCII.NUL;
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);
- Strncpy (Out_String.all'Address, Result_Ptr, Result_Length);
+ Out_String := new String (1 .. Integer (Result_Length));
+ CRTL.strncpy (Out_String.all'Address, Result_Ptr, Result_Length);
return Out_String;
end Update_Path;
with System.Soft_Links;
with System;
+with System.CRTL;
with System.File_Control_Block;
with System.File_IO;
with System.HTable;
procedure Get_Env_Value_Ptr (Name, Length, Ptr : Address);
pragma Import (C, Get_Env_Value_Ptr, "__gnat_getenv");
- procedure Strncpy (Astring_Addr, Cstring : Address; N : Integer);
- pragma Import (C, Strncpy, "strncpy");
+ subtype size_t is CRTL.size_t;
+
+ procedure Strncpy (dest, src : System.Address; n : size_t)
+ renames CRTL.strncpy;
Dir_Name : aliased constant String :=
"SHARED_MEMORY_DIRECTORY" & ASCII.NUL;
- Env_Value_Ptr : aliased Address;
- Env_Value_Length : aliased Integer;
+ Env_Value_Ptr : aliased Address;
+ Env_Value_Len : aliased Integer;
begin
if Dir = null then
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
- Strncpy (Dir.all'Address, Env_Value_Ptr, Env_Value_Length);
+ if Env_Value_Len > 0 then
+ Strncpy (Dir.all'Address, Env_Value_Ptr, size_t (Env_Value_Len));
end if;
System.Global_Locks.Create_Lock (Global_Lock, Dir.all & "__lock");