From d1e0e1480b0210a6a5cfff7bc8be2bfea298a95b Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Thu, 31 Jul 2014 15:29:58 +0200 Subject: [multiple changes] 2014-07-31 Pascal Obry * 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 * 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 --- gcc/ada/cstreams.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'gcc/ada/cstreams.c') diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c index 5d5bc8d..3de270f 100644 --- a/gcc/ada/cstreams.c +++ b/gcc/ada/cstreams.c @@ -31,6 +31,12 @@ /* 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 +#include + #ifdef __vxworks #include "vxWorks.h" #endif @@ -247,8 +253,10 @@ __gnat_full_name (char *nam, char *buffer) return buffer; } -#ifdef _WIN64 - /* On Windows 64 we want to use the fseek/fteel supporting large files. This +#define __int64 long long + +#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 */ __int64 __gnat_ftell64 (FILE *stream) @@ -263,16 +271,22 @@ __gnat_fseek64 (FILE *stream, __int64 offset, int origin) } #else -long +__int64 __gnat_ftell64 (FILE *stream) { - return ftell (stream); + return (__int64)ftello (stream); } 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 -- cgit v1.1