aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/cstreams.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-07-31 15:29:58 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-07-31 15:29:58 +0200
commitd1e0e1480b0210a6a5cfff7bc8be2bfea298a95b (patch)
tree10012e7856220cfaf4ab1f30d7681354236337a8 /gcc/ada/cstreams.c
parentfce547639dcebba692c4c864287cb371360a6661 (diff)
downloadgcc-d1e0e1480b0210a6a5cfff7bc8be2bfea298a95b.zip
gcc-d1e0e1480b0210a6a5cfff7bc8be2bfea298a95b.tar.gz
gcc-d1e0e1480b0210a6a5cfff7bc8be2bfea298a95b.tar.bz2
[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
Diffstat (limited to 'gcc/ada/cstreams.c')
-rw-r--r--gcc/ada/cstreams.c26
1 files changed, 20 insertions, 6 deletions
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 <stdio.h>
+#include <sys/types.h>
+
#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