diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-02-24 17:51:58 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-02-24 17:51:58 +0100 |
commit | c6d2191a0da9f40899da20933f008242f90262e0 (patch) | |
tree | 3a271858d673fb57c047135e5a838d33e1ee5af4 /gcc/ada/adaint.c | |
parent | ec77b14454cfb80c70a0b17b7ced31c8956af30b (diff) | |
download | gcc-c6d2191a0da9f40899da20933f008242f90262e0.zip gcc-c6d2191a0da9f40899da20933f008242f90262e0.tar.gz gcc-c6d2191a0da9f40899da20933f008242f90262e0.tar.bz2 |
[multiple changes]
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.
From-SVN: r208078
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r-- | gcc/ada/adaint.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 3cabec9..8d574da 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -350,7 +350,9 @@ int __gnat_vmsp = 0; #endif -/* Used for Ada bindings */ +/* Used for runtime check that Ada constant File_Attributes_Size is no + less than the actual size of struct file_attributes (see Osint + initialization). */ int __gnat_size_of_file_attributes = sizeof (struct file_attributes); void __gnat_stat_to_attr (int fd, char* name, struct file_attributes* attr); @@ -411,6 +413,7 @@ void __gnat_reset_attributes (struct file_attributes* attr) { attr->exists = ATTR_UNSET; + attr->error = EINVAL; attr->writable = ATTR_UNSET; attr->readable = ATTR_UNSET; @@ -424,6 +427,11 @@ __gnat_reset_attributes (struct file_attributes* attr) attr->file_length = -1; } +int +__gnat_error_attributes (struct file_attributes *attr) { + return attr->error; +} + OS_Time __gnat_current_time (void) { @@ -1170,12 +1178,28 @@ void __gnat_stat_to_attr (int fd, char* name, struct file_attributes* attr) { GNAT_STRUCT_STAT statbuf; - int ret; + int ret, error; - if (fd != -1) + if (fd != -1) { + /* GNAT_FSTAT returns -1 and sets errno for failure */ ret = GNAT_FSTAT (fd, &statbuf); + error = ret ? errno : 0; + + } else { + /* __gnat_stat returns errno value directly */ + error = __gnat_stat (name, &statbuf); + ret = error ? -1 : 0; + } + + /* + * A missing file is reported as an attr structure with error == 0 and + * exists == 0. + */ + + if (error == 0 || error == ENOENT) + attr->error = 0; else - ret = __gnat_stat (name, &statbuf); + attr->error = error; attr->regular = (!ret && S_ISREG (statbuf.st_mode)); attr->directory = (!ret && S_ISDIR (statbuf.st_mode)); @@ -1793,6 +1817,9 @@ __gnat_get_libraries_from_registry (void) return result; } +/* Query information for the given file NAME and return it in STATBUF. + * Returns 0 for success, or errno value for failure. + */ int __gnat_stat (char *name, GNAT_STRUCT_STAT *statbuf) { @@ -1807,7 +1834,7 @@ __gnat_stat (char *name, GNAT_STRUCT_STAT *statbuf) name_len = _tcslen (wname); if (name_len > GNAT_MAX_PATH_LEN) - return -1; + return EINVAL; ZeroMemory (statbuf, sizeof(GNAT_STRUCT_STAT)); @@ -1860,7 +1887,7 @@ __gnat_stat (char *name, GNAT_STRUCT_STAT *statbuf) return 0; #else - return GNAT_STAT (name, statbuf); + return GNAT_STAT (name, statbuf) == 0 ? 0 : errno; #endif } |