Commit d1e0e148 by Arnaud Charlet

[multiple changes]

2014-07-31  Pascal Obry  <obry@adacore.com>

	* a-stream.ads (Stream_Element_Offset): Now a signed 64bit type.
	* i-cstrea.ads, s-crtl.ads (fseek64): Offset is always a 64bit value.
	(ftell64): Always returns a 64bit value.
	* cstreams.c (int64): New definition.
	(_FILE_OFFSET_BITS): Set to 64 to enable 64bit offset support.
	(__gnat_ftell64): Always returns a 64bit value. The implemenation now
	uses ftello() on UNIX.
	(__gnat_fseek64): Offset is always a 64bit value. The
	implementation now uses fseeko() on UNIX.
	* a-ststio.adb, s-direio.adb (Set_Position): Simplify code,
	always use fseek64 to set the offset.
	(Size): Simplify code, always use fseek64/ftell64.
	* s-direio.ads (Count): Now an int64.
	* g-socket.ads (Vector_Element): Adjust definition for Length
	to be a size_t. This matches the C definition and avoid using
	a 64bit integer on 32bit platforms now that Count is always 64bit.
	* g-socthi-mingw.adb (Ada.Streams): Removed as not used anymore.
	(C_Recvmsg): Change some conversion to account for change in
	Vector_Element.
	(C_Sendmsg): Likewise.

2014-07-31  Robert Dewar  <dewar@adacore.com>

	* cstand.adb (Create_Standard): Remove handling of -gnatdm flag.
	* debug.adb: Remove documentation of -gnatdm flag.
	* gnat1drv.adb (Adjust_Global_Switches): Remove handling of
	-gnatdm flag.

From-SVN: r213365
parent fce54763
2014-07-31 Pascal Obry <obry@adacore.com>
* a-stream.ads (Stream_Element_Offset): Now a signed 64bit type.
* i-cstrea.ads, s-crtl.ads (fseek64): Offset is always a 64bit value.
(ftell64): Always returns a 64bit value.
* cstreams.c (int64): New definition.
(_FILE_OFFSET_BITS): Set to 64 to enable 64bit offset support.
(__gnat_ftell64): Always returns a 64bit value. The implemenation now
uses ftello() on UNIX.
(__gnat_fseek64): Offset is always a 64bit value. The
implementation now uses fseeko() on UNIX.
* a-ststio.adb, s-direio.adb (Set_Position): Simplify code,
always use fseek64 to set the offset.
(Size): Simplify code, always use fseek64/ftell64.
* s-direio.ads (Count): Now an int64.
* g-socket.ads (Vector_Element): Adjust definition for Length
to be a size_t. This matches the C definition and avoid using
a 64bit integer on 32bit platforms now that Count is always 64bit.
* g-socthi-mingw.adb (Ada.Streams): Removed as not used anymore.
(C_Recvmsg): Change some conversion to account for change in
Vector_Element.
(C_Sendmsg): Likewise.
2014-07-31 Robert Dewar <dewar@adacore.com>
* cstand.adb (Create_Standard): Remove handling of -gnatdm flag.
* debug.adb: Remove documentation of -gnatdm flag.
* gnat1drv.adb (Adjust_Global_Switches): Remove handling of
-gnatdm flag.
2014-07-31 Arnaud Charlet <charlet@adacore.com> 2014-07-31 Arnaud Charlet <charlet@adacore.com>
* lib-writ.adb (Write_Unit_Information): Fix case where U = * lib-writ.adb (Write_Unit_Information): Fix case where U =
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- -- -- --
-- This specification is derived from the Ada Reference Manual for use with -- -- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow -- -- GNAT. The copyright notice above, and the license provisions that follow --
...@@ -41,9 +41,7 @@ package Ada.Streams is ...@@ -41,9 +41,7 @@ package Ada.Streams is
type Stream_Element is mod 2 ** Standard'Storage_Unit; type Stream_Element is mod 2 ** Standard'Storage_Unit;
type Stream_Element_Offset is range type Stream_Element_Offset is range -(2 ** 63) .. +(2 ** 63) - 1;
-(2 ** (Standard'Address_Size - 1)) ..
+(2 ** (Standard'Address_Size - 1)) - 1;
subtype Stream_Element_Count is subtype Stream_Element_Count is
Stream_Element_Offset range 0 .. Stream_Element_Offset'Last; Stream_Element_Offset range 0 .. Stream_Element_Offset'Last;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- Copyright (C) 1992-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- --
...@@ -382,17 +382,10 @@ package body Ada.Streams.Stream_IO is ...@@ -382,17 +382,10 @@ package body Ada.Streams.Stream_IO is
------------------ ------------------
procedure Set_Position (File : File_Type) is procedure Set_Position (File : File_Type) is
use type System.CRTL.long; use type System.CRTL.int64;
use type System.CRTL.ssize_t;
R : int; R : int;
begin begin
if Standard'Address_Size = 64 then R := fseek64 (File.Stream, System.CRTL.int64 (File.Index) - 1, SEEK_SET);
R := fseek64 (File.Stream,
System.CRTL.ssize_t (File.Index) - 1, SEEK_SET);
else
R := fseek (File.Stream,
System.CRTL.long (File.Index) - 1, SEEK_SET);
end if;
if R /= 0 then if R /= 0 then
raise Use_Error; raise Use_Error;
...@@ -410,14 +403,14 @@ package body Ada.Streams.Stream_IO is ...@@ -410,14 +403,14 @@ package body Ada.Streams.Stream_IO is
if File.File_Size = -1 then if File.File_Size = -1 then
File.Last_Op := Op_Other; File.Last_Op := Op_Other;
if fseek (File.Stream, 0, SEEK_END) /= 0 then if fseek64 (File.Stream, 0, SEEK_END) /= 0 then
raise Device_Error; raise Device_Error;
end if; end if;
if Standard'Address_Size = 64 then File.File_Size := Stream_Element_Offset (ftell64 (File.Stream));
File.File_Size := Stream_Element_Offset (ftell64 (File.Stream));
else if File.File_Size = -1 then
File.File_Size := Stream_Element_Offset (ftell (File.Stream)); raise Use_Error;
end if; end if;
end if; end if;
......
...@@ -740,17 +740,8 @@ package body CStand is ...@@ -740,17 +740,8 @@ package body CStand is
Build_Signed_Integer_Type Build_Signed_Integer_Type
(Standard_Integer, Standard_Integer_Size); (Standard_Integer, Standard_Integer_Size);
declare Build_Signed_Integer_Type
LIS : Nat; (Standard_Long_Integer, Standard_Long_Integer_Size);
begin
if Debug_Flag_M then
LIS := 64;
else
LIS := Standard_Long_Integer_Size;
end if;
Build_Signed_Integer_Type (Standard_Long_Integer, LIS);
end;
Build_Signed_Integer_Type Build_Signed_Integer_Type
(Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size); (Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size);
......
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
/* Routines required for implementing routines in Interfaces.C.Streams. */ /* Routines required for implementing routines in Interfaces.C.Streams. */
#define _FILE_OFFSET_BITS 64
/* the define above will make off_t a 64bit type on GNU/Linux */
#include <stdio.h>
#include <sys/types.h>
#ifdef __vxworks #ifdef __vxworks
#include "vxWorks.h" #include "vxWorks.h"
#endif #endif
...@@ -247,8 +253,10 @@ __gnat_full_name (char *nam, char *buffer) ...@@ -247,8 +253,10 @@ __gnat_full_name (char *nam, char *buffer)
return buffer; return buffer;
} }
#ifdef _WIN64 #define __int64 long long
/* On Windows 64 we want to use the fseek/fteel supporting large files. This
#ifdef _WIN32
/* On Windows we want to use the fseek/fteel supporting large files. This
issue is due to the fact that a long on Win64 is still a 32 bits value */ issue is due to the fact that a long on Win64 is still a 32 bits value */
__int64 __int64
__gnat_ftell64 (FILE *stream) __gnat_ftell64 (FILE *stream)
...@@ -263,16 +271,22 @@ __gnat_fseek64 (FILE *stream, __int64 offset, int origin) ...@@ -263,16 +271,22 @@ __gnat_fseek64 (FILE *stream, __int64 offset, int origin)
} }
#else #else
long __int64
__gnat_ftell64 (FILE *stream) __gnat_ftell64 (FILE *stream)
{ {
return ftell (stream); return (__int64)ftello (stream);
} }
int int
__gnat_fseek64 (FILE *stream, long offset, int origin) __gnat_fseek64 (FILE *stream, __int64 offset, int origin)
{ {
return fseek (stream, offset, origin); /* make sure that the offset is not bigger than the OS off_t, if so return
with error as this mean that we are trying to handle files larger than
2Gb on a patform not supporting it. */
if ((off_t)offset == offset)
return fseeko (stream, (off_t) offset, origin);
else
return -1;
} }
#endif #endif
......
...@@ -49,7 +49,7 @@ package body Debug is ...@@ -49,7 +49,7 @@ package body Debug is
-- dj Suppress "junk null check" for access parameter values -- dj Suppress "junk null check" for access parameter values
-- dk Generate GNATBUG message on abort, even if previous errors -- dk Generate GNATBUG message on abort, even if previous errors
-- dl Generate unit load trace messages -- dl Generate unit load trace messages
-- dm Allow VMS features even if not OpenVMS version -- dm
-- dn Generate messages for node/list allocation -- dn Generate messages for node/list allocation
-- do Print source from tree (original code only) -- do Print source from tree (original code only)
-- dp Generate messages for parser scope stack push/pops -- dp Generate messages for parser scope stack push/pops
...@@ -281,14 +281,6 @@ package body Debug is ...@@ -281,14 +281,6 @@ package body Debug is
-- generated each time a request is made to the library manager to -- generated each time a request is made to the library manager to
-- load a new unit. -- load a new unit.
-- dm Some features are permitted only in OpenVMS ports of GNAT (e.g.
-- the specification of passing by descriptor). Normally any use
-- of these features will be flagged as an error, but this debug
-- flag allows acceptance of these features in non OpenVMS ports.
-- Of course they may not have any useful effect, and in particular
-- attempting to generate code with this flag set may blow up.
-- The flag also forces the use of 64-bits for Long_Integer.
-- dn Generate messages for node/list allocation. Each time a node or -- dn Generate messages for node/list allocation. Each time a node or
-- list header is allocated, a line of output is generated. Certain -- list header is allocated, a line of output is generated. Certain
-- other basic tree operations also cause a line of output to be -- other basic tree operations also cause a line of output to be
......
...@@ -797,7 +797,7 @@ package GNAT.Sockets is ...@@ -797,7 +797,7 @@ package GNAT.Sockets is
type Vector_Element is record type Vector_Element is record
Base : Stream_Element_Reference; Base : Stream_Element_Reference;
Length : Ada.Streams.Stream_Element_Count; Length : Interfaces.C.size_t;
end record; end record;
type Vector_Type is array (Integer range <>) of Vector_Element; type Vector_Type is array (Integer range <>) of Vector_Element;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2013, AdaCore -- -- Copyright (C) 2001-2014, AdaCore --
-- -- -- --
-- 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- --
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
-- This version is for NT -- This version is for NT
with Ada.Streams; use Ada.Streams;
with Ada.Unchecked_Conversion; with Ada.Unchecked_Conversion;
with Interfaces.C.Strings; use Interfaces.C.Strings; with Interfaces.C.Strings; use Interfaces.C.Strings;
with System; use System; with System; use System;
...@@ -334,11 +333,11 @@ package body GNAT.Sockets.Thin is ...@@ -334,11 +333,11 @@ package body GNAT.Sockets.Thin is
exit; exit;
else else
pragma Assert (Stream_Element_Count (Res) <= Current_Iovec.Length); pragma Assert (Interfaces.C.size_t (Res) <= Current_Iovec.Length);
Count := Count + Res; Count := Count + Res;
Current_Iovec.Length := Current_Iovec.Length :=
Current_Iovec.Length - Stream_Element_Count (Res); Current_Iovec.Length - Interfaces.C.size_t (Res);
Current_Iovec.Base := Current_Iovec.Base :=
To_Access (Current_Iovec.Base.all'Address To_Access (Current_Iovec.Base.all'Address
+ Storage_Offset (Res)); + Storage_Offset (Res));
...@@ -507,7 +506,7 @@ package body GNAT.Sockets.Thin is ...@@ -507,7 +506,7 @@ package body GNAT.Sockets.Thin is
-- Exit now if the buffer is not fully transmitted -- Exit now if the buffer is not fully transmitted
exit when Stream_Element_Count (Res) < Iovec (J).Length; exit when Interfaces.C.size_t (Res) < Iovec (J).Length;
end loop; end loop;
return System.CRTL.ssize_t (Count); return System.CRTL.ssize_t (Count);
......
...@@ -38,7 +38,6 @@ with Fname; use Fname; ...@@ -38,7 +38,6 @@ with Fname; use Fname;
with Fname.UF; use Fname.UF; with Fname.UF; use Fname.UF;
with Frontend; with Frontend;
with Gnatvsn; use Gnatvsn; with Gnatvsn; use Gnatvsn;
with Hostparm;
with Inline; with Inline;
with Lib; use Lib; with Lib; use Lib;
with Lib.Writ; use Lib.Writ; with Lib.Writ; use Lib.Writ;
...@@ -477,17 +476,11 @@ procedure Gnat1drv is ...@@ -477,17 +476,11 @@ procedure Gnat1drv is
Ttypes.Bytes_Big_Endian := not Ttypes.Bytes_Big_Endian; Ttypes.Bytes_Big_Endian := not Ttypes.Bytes_Big_Endian;
end if; end if;
-- Deal with forcing OpenVMS switches True if debug flag M is set, but -- Temporarily set True_VMS_Target to OpenVMS_On_Target. This is just
-- record the setting of Targparm.Open_VMS_On_Target in True_VMS_Target -- temporary, we no longer deal with the debug flag -gnatdm here.
-- before doing this, so we know if we are in real OpenVMS or not.
Opt.True_VMS_Target := Targparm.OpenVMS_On_Target; Opt.True_VMS_Target := Targparm.OpenVMS_On_Target;
if Debug_Flag_M then
Targparm.OpenVMS_On_Target := True;
Hostparm.OpenVMS := True;
end if;
-- Activate front end layout if debug flag -gnatdF is set -- Activate front end layout if debug flag -gnatdF is set
if Debug_Flag_FF then if Debug_Flag_FF then
......
...@@ -43,6 +43,7 @@ package Interfaces.C_Streams is ...@@ -43,6 +43,7 @@ package Interfaces.C_Streams is
subtype long is System.CRTL.long; subtype long is System.CRTL.long;
subtype size_t is System.CRTL.size_t; subtype size_t is System.CRTL.size_t;
subtype ssize_t is System.CRTL.ssize_t; subtype ssize_t is System.CRTL.ssize_t;
subtype int64 is System.CRTL.int64;
subtype voids is System.Address; subtype voids is System.Address;
NULL_Stream : constant FILEs; NULL_Stream : constant FILEs;
...@@ -159,14 +160,14 @@ package Interfaces.C_Streams is ...@@ -159,14 +160,14 @@ package Interfaces.C_Streams is
function fseek64 function fseek64
(stream : FILEs; (stream : FILEs;
offset : ssize_t; offset : int64;
origin : int) return int origin : int) return int
renames System.CRTL.fseek64; renames System.CRTL.fseek64;
function ftell (stream : FILEs) return long function ftell (stream : FILEs) return long
renames System.CRTL.ftell; renames System.CRTL.ftell;
function ftell64 (stream : FILEs) return ssize_t function ftell64 (stream : FILEs) return int64
renames System.CRTL.ftell64; renames System.CRTL.ftell64;
function fwrite function fwrite
......
...@@ -62,6 +62,8 @@ package System.CRTL is ...@@ -62,6 +62,8 @@ package System.CRTL is
type ssize_t is range -(2 ** (Standard'Address_Size - 1)) type ssize_t is range -(2 ** (Standard'Address_Size - 1))
.. +(2 ** (Standard'Address_Size - 1)) - 1; .. +(2 ** (Standard'Address_Size - 1)) - 1;
type int64 is range -(2 ** 63) .. (2 ** 63) - 1;
type Filename_Encoding is (UTF8, ASCII_8bits, Unspecified); type Filename_Encoding is (UTF8, ASCII_8bits, Unspecified);
for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1, Unspecified => 2); for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1, Unspecified => 2);
pragma Convention (C, Filename_Encoding); pragma Convention (C, Filename_Encoding);
...@@ -147,14 +149,14 @@ package System.CRTL is ...@@ -147,14 +149,14 @@ package System.CRTL is
function fseek64 function fseek64
(stream : FILEs; (stream : FILEs;
offset : ssize_t; offset : int64;
origin : int) return int; origin : int) return int;
pragma Import (C, fseek64, "__gnat_fseek64"); pragma Import (C, fseek64, "__gnat_fseek64");
function ftell (stream : FILEs) return long; function ftell (stream : FILEs) return long;
pragma Import (C, ftell, "ftell"); pragma Import (C, ftell, "ftell");
function ftell64 (stream : FILEs) return ssize_t; function ftell64 (stream : FILEs) return int64;
pragma Import (C, ftell64, "__gnat_ftell64"); pragma Import (C, ftell64, "__gnat_ftell64");
function getenv (S : String) return System.Address; function getenv (S : String) return System.Address;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- Copyright (C) 1992-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- --
...@@ -45,7 +45,7 @@ package body System.Direct_IO is ...@@ -45,7 +45,7 @@ package body System.Direct_IO is
subtype AP is FCB.AFCB_Ptr; subtype AP is FCB.AFCB_Ptr;
use type FCB.Shared_Status_Type; use type FCB.Shared_Status_Type;
use type System.CRTL.long; use type System.CRTL.int64;
use type System.CRTL.size_t; use type System.CRTL.size_t;
----------------------- -----------------------
...@@ -280,18 +280,10 @@ package body System.Direct_IO is ...@@ -280,18 +280,10 @@ package body System.Direct_IO is
------------------ ------------------
procedure Set_Position (File : File_Type) is procedure Set_Position (File : File_Type) is
use type System.CRTL.ssize_t;
R : int; R : int;
begin begin
if Standard'Address_Size = 64 then R := fseek64
R := fseek64 (File.Stream, int64 (File.Bytes) * int64 (File.Index - 1), SEEK_SET);
(File.Stream, ssize_t (File.Bytes) *
ssize_t (File.Index - 1), SEEK_SET);
else
R := fseek
(File.Stream, long (File.Bytes) *
long (File.Index - 1), SEEK_SET);
end if;
if R /= 0 then if R /= 0 then
raise Use_Error; raise Use_Error;
...@@ -303,20 +295,22 @@ package body System.Direct_IO is ...@@ -303,20 +295,22 @@ package body System.Direct_IO is
---------- ----------
function Size (File : File_Type) return Count is function Size (File : File_Type) return Count is
use type System.CRTL.ssize_t; Pos : int64;
begin begin
FIO.Check_File_Open (AP (File)); FIO.Check_File_Open (AP (File));
File.Last_Op := Op_Other; File.Last_Op := Op_Other;
if fseek (File.Stream, 0, SEEK_END) /= 0 then if fseek64 (File.Stream, 0, SEEK_END) /= 0 then
raise Device_Error; raise Device_Error;
end if; end if;
if Standard'Address_Size = 64 then Pos := ftell64 (File.Stream);
return Count (ftell64 (File.Stream) / ssize_t (File.Bytes));
else if Pos = -1 then
return Count (ftell (File.Stream) / long (File.Bytes)); raise Use_Error;
end if; end if;
return Count (Pos / int64 (File.Bytes));
end Size; end Size;
----------- -----------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- Copyright (C) 1992-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- --
...@@ -45,7 +45,7 @@ package System.Direct_IO is ...@@ -45,7 +45,7 @@ package System.Direct_IO is
type Operation is (Op_Read, Op_Write, Op_Other); type Operation is (Op_Read, Op_Write, Op_Other);
-- Type used to record last operation (to optimize sequential operations) -- Type used to record last operation (to optimize sequential operations)
subtype Count is Interfaces.C_Streams.long; subtype Count is Interfaces.C_Streams.int64;
-- The Count type in each instantiation is derived from this type -- The Count type in each instantiation is derived from this type
subtype Positive_Count is Count range 1 .. Count'Last; subtype Positive_Count is Count range 1 .. Count'Last;
......
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