Commit 148c744a by Pascal Obry Committed by Arnaud Charlet

adaint.h, adaint.c (__gnat_file_length): Returns an __int64.

2014-08-01  Pascal Obry  <obry@adacore.com>

	* 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
parent 479f9059
2014-08-01 Pascal Obry <obry@adacore.com> 2014-08-01 Pascal Obry <obry@adacore.com>
* 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 <obry@adacore.com>
* adaint.h, adaint.c (__gnat_open): Added. * adaint.h, adaint.c (__gnat_open): Added.
* s-crtl.ads (open): Import __gnat_open for large file support. * s-crtl.ads (open): Import __gnat_open for large file support.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- 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 -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -1250,7 +1250,7 @@ package body Ada.Directories is ...@@ -1250,7 +1250,7 @@ package body Ada.Directories is
function Size (Name : String) return File_Size is function Size (Name : String) return File_Size is
C_Name : String (1 .. Name'Length + 1); 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"); pragma Import (C, C_Size, "__gnat_named_file_length");
begin begin
......
...@@ -1308,7 +1308,7 @@ __gnat_stat_to_attr (int fd, char* name, struct file_attributes* attr) ...@@ -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 ** Return the number of bytes in the specified file
****************************************************************/ ****************************************************************/
long __int64
__gnat_file_length_attr (int fd, char* name, struct file_attributes* attr) __gnat_file_length_attr (int fd, char* name, struct file_attributes* attr)
{ {
if (attr->file_length == -1) { if (attr->file_length == -1) {
...@@ -1318,7 +1318,7 @@ __gnat_file_length_attr (int fd, char* name, struct file_attributes* attr) ...@@ -1318,7 +1318,7 @@ __gnat_file_length_attr (int fd, char* name, struct file_attributes* attr)
return attr->file_length; return attr->file_length;
} }
long __int64
__gnat_file_length (int fd) __gnat_file_length (int fd)
{ {
struct file_attributes attr; struct file_attributes attr;
...@@ -1326,7 +1326,7 @@ __gnat_file_length (int fd) ...@@ -1326,7 +1326,7 @@ __gnat_file_length (int fd)
return __gnat_file_length_attr (fd, NULL, &attr); return __gnat_file_length_attr (fd, NULL, &attr);
} }
long __int64
__gnat_named_file_length (char *name) __gnat_named_file_length (char *name)
{ {
struct file_attributes attr; struct file_attributes attr;
......
...@@ -98,7 +98,7 @@ struct file_attributes { ...@@ -98,7 +98,7 @@ struct file_attributes {
unsigned char directory; unsigned char directory;
OS_Time timestamp; OS_Time timestamp;
long file_length; __int64 file_length;
}; };
/* WARNING: changing the size here might require changing the constant /* WARNING: changing the size here might require changing the constant
* File_Attributes_Size in osint.ads (which should be big enough to * File_Attributes_Size in osint.ads (which should be big enough to
...@@ -151,8 +151,8 @@ extern int __gnat_create_output_file (char *); ...@@ -151,8 +151,8 @@ extern int __gnat_create_output_file (char *);
extern int __gnat_create_output_file_new (char *); extern int __gnat_create_output_file_new (char *);
extern int __gnat_open_append (char *, int); extern int __gnat_open_append (char *, int);
extern long __gnat_file_length (int); extern __int64 __gnat_file_length (int);
extern long __gnat_named_file_length (char *); extern __int64 __gnat_named_file_length (char *);
extern void __gnat_tmp_name (char *); extern void __gnat_tmp_name (char *);
extern DIR *__gnat_opendir (char *); extern DIR *__gnat_opendir (char *);
extern char *__gnat_readdir (DIR *, char *, int *); extern char *__gnat_readdir (DIR *, char *, int *);
...@@ -177,7 +177,7 @@ extern int __gnat_is_executable_file (char *name); ...@@ -177,7 +177,7 @@ extern int __gnat_is_executable_file (char *name);
extern void __gnat_reset_attributes (struct file_attributes *); extern void __gnat_reset_attributes (struct file_attributes *);
extern int __gnat_error_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_name_attr (char *, struct file_attributes *);
extern OS_Time __gnat_file_time_fd_attr (int, 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 *); extern int __gnat_file_exists_attr (char *, struct file_attributes *);
......
...@@ -1076,10 +1076,13 @@ package body Osint is ...@@ -1076,10 +1076,13 @@ package body Osint is
function Internal function Internal
(F : Integer; (F : Integer;
N : C_File_Name; N : C_File_Name;
A : System.Address) return Long_Integer; A : System.Address) return size_t;
pragma Import (C, Internal, "__gnat_file_length_attr"); pragma Import (C, Internal, "__gnat_file_length_attr");
begin 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; end File_Length;
--------------------- ---------------------
......
...@@ -35,7 +35,6 @@ with Ada.Unchecked_Conversion; ...@@ -35,7 +35,6 @@ with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation; with Ada.Unchecked_Deallocation;
with System; use System; with System; use System;
with System.Case_Util; with System.Case_Util;
with System.CRTL;
with System.Soft_Links; with System.Soft_Links;
package body System.OS_Lib is package body System.OS_Lib is
......
...@@ -56,6 +56,8 @@ pragma Compiler_Unit_Warning; ...@@ -56,6 +56,8 @@ pragma Compiler_Unit_Warning;
with System; with System;
with System.Strings; with System.Strings;
with System.CRTL;
package System.OS_Lib is package System.OS_Lib is
pragma Preelaborate; pragma Preelaborate;
...@@ -432,7 +434,7 @@ package System.OS_Lib is ...@@ -432,7 +434,7 @@ package System.OS_Lib is
-- to the current position (origin = SEEK_CUR), end of file (origin = -- to the current position (origin = SEEK_CUR), end of file (origin =
-- SEEK_END), or start of file (origin = SEEK_SET). -- 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"); pragma Import (C, File_Length, "__gnat_file_length");
-- Get length of file from file descriptor FD -- Get length of file from file descriptor FD
......
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