diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-24 16:51:58 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-02-24 16:51:58 +0000 |
commit | 28a4283c747db61dedc1aaaec46de161351d3f35 (patch) | |
tree | 3a271858d673fb57c047135e5a838d33e1ee5af4 /gcc/ada/s-os_lib.adb | |
parent | 34e4634c639c5851505de84caf03374a9648570b (diff) | |
download | ppe42-gcc-28a4283c747db61dedc1aaaec46de161351d3f35.tar.gz ppe42-gcc-28a4283c747db61dedc1aaaec46de161351d3f35.zip |
2014-02-24 Hristian Kirtchev <kirtchev@adacore.com>
* sem_prag.adb (Analyze_Global_Item): Emit the
variable related checks concerning volatile objects only when
SPARK_Mode is on.
2014-02-24 Robert Dewar <dewar@adacore.com>
* sem_ch5.adb (Analyze_Iterator_Specification): use
Error_Msg_Ada_2012_Feature.
2014-02-24 Jose Ruiz <ruiz@adacore.com>
* s-rident.ads (Profile_Info): For Ravenscar, the restrictions
No_Local_Timing_Events and No_Specific_Termination_Handlers
must be set, according to the Ravenscar profile definition
in D.13(6/3).
2014-02-24 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Analyze_Expression_Function): If this is a
completion, freeze return type and its designated type if needed.
2014-02-24 Thomas Quinot <quinot@adacore.com>
* sem_ch13.adb (Analyze_Attribute_Definition_Clause, case
'Address): When moving initialization statements to a freeze
entity, keep them under a single node (i.e. do not unwrap
expressions with actions), and set the Initialization_Statements
attribute again so that processing of a later pragma Import can
still remove them.
2014-02-24 Claire Dross <dross@adacore.com>
* a-cfdlli.adb, a-cfdlli.ads, a-cfhama.adb, a-cfhama.ads,
a-cfhase.adb, a-cfhase.ads, a-cforma.adb, a-cforma.ads,
a-cforse.adb, a-cforse.ads, a-cofove.adb, a-cofove.ads: Rename
Left/Right to First_To_Previous/Current_To_Last.
2014-02-24 Thomas Quinot <quinot@adacore.com>
* adaint.h (struct file_attributes): New component "error"
(__gnat_error_attributes): Accessor for the above.
* adaint.c (__gnat_error_attributes): New subprogram
(__gnat_stat): Fix returned value (expect errno value)
(__gnat_stat_to_attr): Add management of error component (set to
stat errno value, except for missing files where it is set to 0,
and exists is set to 0).
* osint.ads (File_Attributes_Size): Update per change above,
also clarify documentation.
* s-filatt.ads: New file, binding to file attributes related
functions.
* Makefile.rtl (s-filatt): New runtime unit.
* s-crtl.ads (strlen): Expose binding to GCC builtin (falls back
to library function if not available on target).
* s-os_lib.ads, s-os_lib.adb (Errno_Message): New subprogram.
* s-oscons-tmplt.c (SIZEOF_struct_file_attributes,
SIZEOF_struct_dirent_alloc): New constants.
* Make-generated.in (s-oscons.ads): Now requires adaint.h.
* a-direct.adb (Fetch_Next_Entry): Fix incorrect buffer sizes.
Perform appropriate error checking if stat fails (do not just
ignore existing files if stat fails)
* gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS): Update
dependencies.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208078 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-os_lib.adb')
-rw-r--r-- | gcc/ada/s-os_lib.adb | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/gcc/ada/s-os_lib.adb b/gcc/ada/s-os_lib.adb index 42e4c549401..7b6a28b4408 100644 --- a/gcc/ada/s-os_lib.adb +++ b/gcc/ada/s-os_lib.adb @@ -88,8 +88,8 @@ package body System.OS_Lib is -- parameters are as in Create_Temp_File. function C_String_Length (S : Address) return Integer; - -- Returns the length of a C string. Does check for null address - -- (returns 0). + -- Returns the length of C (null-terminated) string at S, or 0 for + -- Null_Address. procedure Spawn_Internal (Program_Name : String; @@ -252,13 +252,11 @@ package body System.OS_Lib is --------------------- function C_String_Length (S : Address) return Integer is - function Strlen (S : Address) return Integer; - pragma Import (C, Strlen, "strlen"); begin if S = Null_Address then return 0; else - return Strlen (S); + return Integer (CRTL.strlen (S)); end if; end C_String_Length; @@ -912,6 +910,38 @@ package body System.OS_Lib is Delete_File (C_Name'Address, Success); end Delete_File; + ------------------- + -- Errno_Message -- + ------------------- + + function Errno_Message + (Err : Integer := Errno; + Default : String := "") return String + is + function strerror (errnum : Integer) return System.Address; + pragma Import (C, strerror, "strerror"); + + C_Msg : constant System.Address := strerror (Err); + + begin + if C_Msg = Null_Address then + if Default /= "" then + return Default; + else + return "errno =" & Err'Img; + end if; + + else + declare + Msg : String (1 .. Integer (CRTL.strlen (C_Msg))); + for Msg'Address use C_Msg; + pragma Import (Ada, Msg); + begin + return Msg; + end; + end if; + end Errno_Message; + --------------------- -- File_Time_Stamp -- --------------------- @@ -1028,14 +1058,11 @@ package body System.OS_Lib is procedure Strncpy (Astring_Addr, Cstring : Address; N : Integer); pragma Import (C, Strncpy, "strncpy"); - function Strlen (Cstring : Address) return Integer; - pragma Import (C, Strlen, "strlen"); - Suffix_Length : Integer; Result : String_Access; begin - Suffix_Length := Strlen (Target_Exec_Ext_Ptr); + Suffix_Length := Integer (CRTL.strlen (Target_Exec_Ext_Ptr)); Result := new String (1 .. Suffix_Length); if Suffix_Length > 0 then @@ -1057,14 +1084,11 @@ package body System.OS_Lib is procedure Strncpy (Astring_Addr, Cstring : Address; N : Integer); pragma Import (C, Strncpy, "strncpy"); - function Strlen (Cstring : Address) return Integer; - pragma Import (C, Strlen, "strlen"); - Suffix_Length : Integer; Result : String_Access; begin - Suffix_Length := Strlen (Target_Exec_Ext_Ptr); + Suffix_Length := Integer (CRTL.strlen (Target_Exec_Ext_Ptr)); Result := new String (1 .. Suffix_Length); if Suffix_Length > 0 then @@ -1086,14 +1110,11 @@ package body System.OS_Lib is procedure Strncpy (Astring_Addr, Cstring : Address; N : Integer); pragma Import (C, Strncpy, "strncpy"); - function Strlen (Cstring : Address) return Integer; - pragma Import (C, Strlen, "strlen"); - Suffix_Length : Integer; Result : String_Access; begin - Suffix_Length := Strlen (Target_Object_Ext_Ptr); + Suffix_Length := Integer (CRTL.strlen (Target_Object_Ext_Ptr)); Result := new String (1 .. Suffix_Length); if Suffix_Length > 0 then @@ -1792,9 +1813,6 @@ package body System.OS_Lib is Canonical_File_Addr : System.Address; Canonical_File_Len : Integer; - function Strlen (S : System.Address) return Integer; - pragma Import (C, Strlen, "strlen"); - function Final_Value (S : String) return String; -- Make final adjustment to the returned string. This function strips -- trailing directory separators, and folds returned string to lower @@ -1926,7 +1944,7 @@ package body System.OS_Lib is The_Name (The_Name'Last) := ASCII.NUL; Canonical_File_Addr := To_Canonical_File_Spec (The_Name'Address); - Canonical_File_Len := Strlen (Canonical_File_Addr); + Canonical_File_Len := Integer (CRTL.strlen (Canonical_File_Addr)); -- If VMS syntax conversion has failed, return an empty string -- to indicate the failure. @@ -1937,17 +1955,12 @@ package body System.OS_Lib is declare subtype Path_String is String (1 .. Canonical_File_Len); - type Path_String_Access is access Path_String; - - function Address_To_Access is new - Ada.Unchecked_Conversion (Source => Address, - Target => Path_String_Access); - - Path_Access : constant Path_String_Access := - Address_To_Access (Canonical_File_Addr); + Canonical_File : Path_String; + for Canonical_File'Address use Canonical_File_Addr; + pragma Import (Ada, Canonical_File); begin - Path_Buffer (1 .. Canonical_File_Len) := Path_Access.all; + Path_Buffer (1 .. Canonical_File_Len) := Canonical_File; End_Path := Canonical_File_Len; Last := 1; end; |