From 148c744a1789b29b3c3c32b45ea3be913fef6a52 Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Fri, 1 Aug 2014 08:10:34 +0000 Subject: [PATCH] adaint.h, adaint.c (__gnat_file_length): Returns an __int64. 2014-08-01 Pascal Obry * adaint.h, adaint.c (__gnat_file_length): Returns an __int64. (__gnat_named_file_length): Likewise. (__gnat_file_length_attr): Likewise. * a-direct.adb (C_Size): Use size_t as returned type. * osint.adb (File_Length): Adjust spec for Internal routine (returns size_t). * s-os_lib.adb (File_Length): Now returns a CRTL.size_t. (System.CRTL): With claused moved to spec. * s-os_lib.ads (System.CRTL): With clause moved to here. From-SVN: r213412 --- gcc/ada/ChangeLog | 12 ++++++++++++ gcc/ada/a-direct.adb | 4 ++-- gcc/ada/adaint.c | 6 +++--- gcc/ada/adaint.h | 8 ++++---- gcc/ada/osint.adb | 7 +++++-- gcc/ada/s-os_lib.adb | 1 - gcc/ada/s-os_lib.ads | 4 +++- 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 51f92026a232..2248f1d8783f 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,15 @@ +2014-08-01 Pascal Obry + + * adaint.h, adaint.c (__gnat_file_length): Returns an __int64. + (__gnat_named_file_length): Likewise. + (__gnat_file_length_attr): Likewise. + * a-direct.adb (C_Size): Use size_t as returned type. + * osint.adb (File_Length): Adjust spec for Internal routine + (returns size_t). + * s-os_lib.adb (File_Length): Now returns a CRTL.size_t. + (System.CRTL): With claused moved to spec. + * s-os_lib.ads (System.CRTL): With clause moved to here. + 2014-08-01 Pascal Obry * adaint.h, adaint.c (__gnat_open): Added. diff --git a/gcc/ada/a-direct.adb b/gcc/ada/a-direct.adb index c6d2b7ceda36..275ad7ad5031 100644 --- a/gcc/ada/a-direct.adb +++ b/gcc/ada/a-direct.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2004-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1250,7 +1250,7 @@ package body Ada.Directories is function Size (Name : String) return File_Size is C_Name : String (1 .. Name'Length + 1); - function C_Size (Name : Address) return Long_Integer; + function C_Size (Name : Address) return size_t; pragma Import (C, C_Size, "__gnat_named_file_length"); begin diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 42a8077952a5..e0193afcc34b 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -1308,7 +1308,7 @@ __gnat_stat_to_attr (int fd, char* name, struct file_attributes* attr) ** Return the number of bytes in the specified file ****************************************************************/ -long +__int64 __gnat_file_length_attr (int fd, char* name, struct file_attributes* attr) { if (attr->file_length == -1) { @@ -1318,7 +1318,7 @@ __gnat_file_length_attr (int fd, char* name, struct file_attributes* attr) return attr->file_length; } -long +__int64 __gnat_file_length (int fd) { struct file_attributes attr; @@ -1326,7 +1326,7 @@ __gnat_file_length (int fd) return __gnat_file_length_attr (fd, NULL, &attr); } -long +__int64 __gnat_named_file_length (char *name) { struct file_attributes attr; diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h index a870910e1cfd..9b6bbca4e521 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -98,7 +98,7 @@ struct file_attributes { unsigned char directory; OS_Time timestamp; - long file_length; + __int64 file_length; }; /* WARNING: changing the size here might require changing the constant * File_Attributes_Size in osint.ads (which should be big enough to @@ -151,8 +151,8 @@ extern int __gnat_create_output_file (char *); extern int __gnat_create_output_file_new (char *); extern int __gnat_open_append (char *, int); -extern long __gnat_file_length (int); -extern long __gnat_named_file_length (char *); +extern __int64 __gnat_file_length (int); +extern __int64 __gnat_named_file_length (char *); extern void __gnat_tmp_name (char *); extern DIR *__gnat_opendir (char *); extern char *__gnat_readdir (DIR *, char *, int *); @@ -177,7 +177,7 @@ extern int __gnat_is_executable_file (char *name); extern void __gnat_reset_attributes (struct file_attributes *); extern int __gnat_error_attributes (struct file_attributes *); -extern long __gnat_file_length_attr (int, char *, struct file_attributes *); +extern __int64 __gnat_file_length_attr (int, char *, struct file_attributes *); extern OS_Time __gnat_file_time_name_attr (char *, struct file_attributes *); extern OS_Time __gnat_file_time_fd_attr (int, struct file_attributes *); extern int __gnat_file_exists_attr (char *, struct file_attributes *); diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb index 0c15982597d4..159501de777b 100644 --- a/gcc/ada/osint.adb +++ b/gcc/ada/osint.adb @@ -1076,10 +1076,13 @@ package body Osint is function Internal (F : Integer; N : C_File_Name; - A : System.Address) return Long_Integer; + A : System.Address) return size_t; pragma Import (C, Internal, "__gnat_file_length_attr"); begin - return Internal (-1, Name, Attr.all'Address); + -- The conversion from size_t to Long_Integer is ok here as this + -- routine is only to be used by the compiler and we do not expect + -- a unit to be larger than a 32bit integer. + return Long_Integer (Internal (-1, Name, Attr.all'Address)); end File_Length; --------------------- diff --git a/gcc/ada/s-os_lib.adb b/gcc/ada/s-os_lib.adb index 940bf514c327..eacc8968750d 100644 --- a/gcc/ada/s-os_lib.adb +++ b/gcc/ada/s-os_lib.adb @@ -35,7 +35,6 @@ with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System; use System; with System.Case_Util; -with System.CRTL; with System.Soft_Links; package body System.OS_Lib is diff --git a/gcc/ada/s-os_lib.ads b/gcc/ada/s-os_lib.ads index d50d11f3276c..7c474007378f 100644 --- a/gcc/ada/s-os_lib.ads +++ b/gcc/ada/s-os_lib.ads @@ -56,6 +56,8 @@ pragma Compiler_Unit_Warning; with System; with System.Strings; +with System.CRTL; + package System.OS_Lib is pragma Preelaborate; @@ -432,7 +434,7 @@ package System.OS_Lib is -- to the current position (origin = SEEK_CUR), end of file (origin = -- SEEK_END), or start of file (origin = SEEK_SET). - function File_Length (FD : File_Descriptor) return Long_Integer; + function File_Length (FD : File_Descriptor) return CRTL.size_t; pragma Import (C, File_Length, "__gnat_file_length"); -- Get length of file from file descriptor FD