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.
* s-crtl.ads (open): Import __gnat_open for large file support.
-- --
-- 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- --
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
** 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) {
return attr->file_length;
}
-long
+__int64
__gnat_file_length (int fd)
{
struct file_attributes attr;
return __gnat_file_length_attr (fd, NULL, &attr);
}
-long
+__int64
__gnat_named_file_length (char *name)
{
struct file_attributes attr;
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
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 *);
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 *);
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;
---------------------
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
with System;
with System.Strings;
+with System.CRTL;
+
package System.OS_Lib is
pragma Preelaborate;
-- 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