Commit e9f80612 by Arnaud Charlet

[multiple changes]

2013-01-02  Thomas Quinot  <quinot@adacore.com>

	* sem_ch3.adb: Minor reformatting.

2013-01-02  Pascal Obry  <obry@adacore.com>

	* cstreams.c (__gnat_ftell64): New routine. Use _ftelli64 on
	Win64 and default to ftell on other platforms.
	(__gnat_fsek64): Likewise.
	* i-cstrea.ads: Add fssek64 and ftell64 specs.
	* s-crtl.ads: Likewise.
	* a-ststio.adb, s-direio.adb (Size): Use 64 bits version when required.
	(Set_Position): Likewise.

From-SVN: r194797
parent 2c28c7a7
2013-01-02 Thomas Quinot <quinot@adacore.com> 2013-01-02 Thomas Quinot <quinot@adacore.com>
* sem_ch3.adb: Minor reformatting.
2013-01-02 Pascal Obry <obry@adacore.com>
* cstreams.c (__gnat_ftell64): New routine. Use _ftelli64 on
Win64 and default to ftell on other platforms.
(__gnat_fsek64): Likewise.
* i-cstrea.ads: Add fssek64 and ftell64 specs.
* s-crtl.ads: Likewise.
* a-ststio.adb, s-direio.adb (Size): Use 64 bits version when required.
(Set_Position): Likewise.
2013-01-02 Thomas Quinot <quinot@adacore.com>
* par_sco.adb: Generate X SCOs for default expressions in * par_sco.adb: Generate X SCOs for default expressions in
subprogram body stubs. Do not generate any SCO for package, subprogram body stubs. Do not generate any SCO for package,
task, or protected body stubs. task, or protected body stubs.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2012, 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- --
...@@ -367,8 +367,14 @@ package body Ada.Streams.Stream_IO is ...@@ -367,8 +367,14 @@ package body Ada.Streams.Stream_IO is
FIO.Append_Set (AP (File)); FIO.Append_Set (AP (File));
if File.Mode = FCB.Append_File then if File.Mode = FCB.Append_File then
pragma Warnings (Off, "*condition is always*");
if Standard'Address_Size = 64 then
File.Index := Count (ftell64 (File.Stream)) + 1;
else
File.Index := Count (ftell (File.Stream)) + 1; File.Index := Count (ftell (File.Stream)) + 1;
end if; end if;
pragma Warnings (On, "*condition is always*");
end if;
File.Last_Op := Op_Other; File.Last_Op := Op_Other;
end Set_Mode; end Set_Mode;
...@@ -379,10 +385,20 @@ package body Ada.Streams.Stream_IO is ...@@ -379,10 +385,20 @@ 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.long;
use type System.CRTL.ssize_t;
R : int;
begin begin
if fseek (File.Stream, pragma Warnings (Off, "*condition is always*");
System.CRTL.long (File.Index) - 1, SEEK_SET) /= 0 if Standard'Address_Size = 64 then
then 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;
pragma Warnings (On, "*condition is always*");
if R /= 0 then
raise Use_Error; raise Use_Error;
end if; end if;
end Set_Position; end Set_Position;
...@@ -402,8 +418,14 @@ package body Ada.Streams.Stream_IO is ...@@ -402,8 +418,14 @@ package body Ada.Streams.Stream_IO is
raise Device_Error; raise Device_Error;
end if; end if;
pragma Warnings (Off, "*condition is always*");
if Standard'Address_Size = 64 then
File.File_Size := Stream_Element_Offset (ftell64 (File.Stream));
else
File.File_Size := Stream_Element_Offset (ftell (File.Stream)); File.File_Size := Stream_Element_Offset (ftell (File.Stream));
end if; end if;
pragma Warnings (On, "*condition is always*");
end if;
return Count (File.File_Size); return Count (File.File_Size);
end Size; end Size;
......
...@@ -257,6 +257,35 @@ __gnat_full_name (char *nam, char *buffer) ...@@ -257,6 +257,35 @@ __gnat_full_name (char *nam, char *buffer)
return buffer; return buffer;
} }
#ifdef _WIN64
/* On Windows 64 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 */
__int64
__gnat_ftell64 (FILE *stream)
{
return _ftelli64 (stream);
}
int
__gnat_fseek64 (FILE *stream, __int64 offset, int origin)
{
return _fseeki64 (stream, offset, origin);
}
#else
long
__gnat_ftell64 (FILE *stream)
{
return ftell (stream);
}
int
__gnat_fseek64 (FILE *stream, long offset, int origin)
{
return fseek (stream, offset, origin);
}
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
...@@ -42,6 +42,7 @@ package Interfaces.C_Streams is ...@@ -42,6 +42,7 @@ package Interfaces.C_Streams is
subtype int is System.CRTL.int; subtype int is System.CRTL.int;
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 voids is System.Address; subtype voids is System.Address;
NULL_Stream : constant FILEs; NULL_Stream : constant FILEs;
...@@ -153,9 +154,18 @@ package Interfaces.C_Streams is ...@@ -153,9 +154,18 @@ package Interfaces.C_Streams is
origin : int) return int origin : int) return int
renames System.CRTL.fseek; renames System.CRTL.fseek;
function fseek64
(stream : FILEs;
offset : ssize_t;
origin : int) return int
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
renames System.CRTL.ftell64;
function fwrite function fwrite
(buffer : voids; (buffer : voids;
size : size_t; size : size_t;
......
...@@ -122,9 +122,18 @@ package System.CRTL is ...@@ -122,9 +122,18 @@ package System.CRTL is
origin : int) return int; origin : int) return int;
pragma Import (C, fseek, "fseek"); pragma Import (C, fseek, "fseek");
function fseek64
(stream : FILEs;
offset : ssize_t;
origin : int) return int;
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;
pragma Import (C, ftell64, "__gnat_ftell64");
function getenv (S : String) return System.Address; function getenv (S : String) return System.Address;
pragma Import (C, getenv, "getenv"); pragma Import (C, getenv, "getenv");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2012, 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- --
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Ada.IO_Exceptions; use Ada.IO_Exceptions; with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Ada.Unchecked_Deallocation;
with Interfaces.C_Streams; use Interfaces.C_Streams; with Interfaces.C_Streams; use Interfaces.C_Streams;
with System; use System; with System; use System;
with System.CRTL; with System.CRTL;
with System.File_IO; with System.File_IO;
with System.Soft_Links; with System.Soft_Links;
with Ada.Unchecked_Deallocation;
package body System.Direct_IO is package body System.Direct_IO is
...@@ -280,11 +280,22 @@ package body System.Direct_IO is ...@@ -280,11 +280,22 @@ 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;
begin begin
if fseek pragma Warnings (Off, "*condition is always*");
if Standard'Address_Size = 64 then
R := fseek64
(File.Stream, ssize_t (File.Bytes) *
ssize_t (File.Index - 1), SEEK_SET);
else
R := fseek
(File.Stream, long (File.Bytes) * (File.Stream, long (File.Bytes) *
long (File.Index - 1), SEEK_SET) /= 0 long (File.Index - 1), SEEK_SET);
then end if;
pragma Warnings (On, "*condition is always*");
if R /= 0 then
raise Use_Error; raise Use_Error;
end if; end if;
end Set_Position; end Set_Position;
...@@ -294,6 +305,7 @@ package body System.Direct_IO is ...@@ -294,6 +305,7 @@ 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;
begin begin
FIO.Check_File_Open (AP (File)); FIO.Check_File_Open (AP (File));
File.Last_Op := Op_Other; File.Last_Op := Op_Other;
...@@ -302,7 +314,13 @@ package body System.Direct_IO is ...@@ -302,7 +314,13 @@ package body System.Direct_IO is
raise Device_Error; raise Device_Error;
end if; end if;
pragma Warnings (Off, "*condition is always*");
if Standard'Address_Size = 64 then
return Count (ftell64 (File.Stream) / ssize_t (File.Bytes));
else
return Count (ftell (File.Stream) / long (File.Bytes)); return Count (ftell (File.Stream) / long (File.Bytes));
end if;
pragma Warnings (On, "*condition is always*");
end Size; end Size;
----------- -----------
......
...@@ -5056,8 +5056,8 @@ package body Sem_Ch3 is ...@@ -5056,8 +5056,8 @@ package body Sem_Ch3 is
-- In ASIS mode, analyze the profile on the original node, because -- In ASIS mode, analyze the profile on the original node, because
-- the separate copy does not provide enough links to recover the -- the separate copy does not provide enough links to recover the
-- original tree. Analysis is limited to type annotations, within -- original tree. Analysis is limited to type annotations, within
-- a temporary scope that serves as an anonnymous subprogram to -- a temporary scope that serves as an anonymous subprogram to collect
-- collect otherwise useless temporaries and itypes. -- otherwise useless temporaries and itypes.
if ASIS_Mode then if ASIS_Mode then
declare declare
......
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