re PR libgcj/16204 (File I/O fails on files >= 2^31 bytes (2GB))
authorBryce McKinlay <mckinlay@redhat.com>
Thu, 15 Jul 2004 00:58:41 +0000 (00:58 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Thu, 15 Jul 2004 00:58:41 +0000 (01:58 +0100)
2004-07-14  Bryce McKinlay  <mckinlay@redhat.com>

PR libgcj/16204
* Makefile.am (AM_CXXFLAGS): Add -D_FILE_OFFSET_BITS=64 to enable
large file support.
* Makefile.in: Rebuilt.
* testsuite/libjava.lang/LargeFile.java: New test case.
* testsuite/libjava.lang/LargeFile.out: New file.

From-SVN: r84733

libjava/ChangeLog
libjava/Makefile.am
libjava/Makefile.in
libjava/testsuite/libjava.lang/LargeFile.java [new file with mode: 0644]
libjava/testsuite/libjava.lang/LargeFile.out [new file with mode: 0644]

index 516a34dc275bf14553a3880a8ee725834b9d0dda..7b36105f32b1c528ccc21915189033a8a25fd1a1 100644 (file)
@@ -1,3 +1,12 @@
+2004-07-14  Bryce McKinlay  <mckinlay@redhat.com>
+
+       PR libgcj/16204
+       * Makefile.am (AM_CXXFLAGS): Add -D_FILE_OFFSET_BITS=64 to enable
+       large file support.
+       * Makefile.in: Rebuilt.
+       * testsuite/libjava.lang/LargeFile.java: New test case.
+       * testsuite/libjava.lang/LargeFile.out: New file.
+
 2004-07-14  Jerry Quinn  <jlquinn@optonline.net>
 
        * java/beans/EventHandler.java: Remove debugging statements.
index fb7756131953521b7bb40c3befe11015d216bfe8..7e5f6af001a905bd56ed33badfa576b81120dc8a 100644 (file)
@@ -111,6 +111,8 @@ AM_CXXFLAGS = -fno-rtti -fnon-call-exceptions $(THREADCXXFLAGS) \
        -fdollars-in-identifiers \
 ## Detect bugs in the verifier implementation, and maybe other places.
        -Wswitch-enum \
+## Some systems, including Linux, need this to enable > 2GB file support.
+       -D_FILE_OFFSET_BITS=64 \
        @LIBGCJ_CXXFLAGS@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE \
        -DPREFIX="\"$(prefix)\"" -DLIBDIR="\"$(libdir)\"" \
        -DBOOT_CLASS_PATH="\"$(jardir)/$(jar_DATA)\"" \
index d9c8a5fe1c808520052d1beb05e1075e3993db53..f6da90894a94d43be59c64322994212fa23625c1 100644 (file)
@@ -215,6 +215,7 @@ WARNINGS = -Wextra -Wall
 AM_CXXFLAGS = -fno-rtti -fnon-call-exceptions $(THREADCXXFLAGS) \
        -fdollars-in-identifiers \
        -Wswitch-enum \
+       -D_FILE_OFFSET_BITS=64 \
        @LIBGCJ_CXXFLAGS@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE \
        -DPREFIX="\"$(prefix)\"" -DLIBDIR="\"$(libdir)\"" \
        -DBOOT_CLASS_PATH="\"$(jardir)/$(jar_DATA)\"" \
@@ -3076,7 +3077,7 @@ libgcj-test.spec.in libgcj.pc.in libgcj.spec.in
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = tar
+TAR = gtar
 GZIP_ENV = --best
 DIST_SUBDIRS =  @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include
 DEP_FILES =  .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
diff --git a/libjava/testsuite/libjava.lang/LargeFile.java b/libjava/testsuite/libjava.lang/LargeFile.java
new file mode 100644 (file)
index 0000000..1bb8aec
--- /dev/null
@@ -0,0 +1,36 @@
+/* Test to ensure files >= 2^31 bytes are supported. */
+
+import java.io.*;
+
+public class LargeFile
+{
+  public static void main(String[] args) throws IOException
+  {
+    File file = new File("LargeFile.tmp");
+
+    try
+      {
+       RandomAccessFile rfile = new RandomAccessFile(file, "rw");
+
+       long pos = (long) Math.pow(2, 31);
+
+       rfile.seek(pos);
+       rfile.write('O');
+       rfile.write('K');
+       rfile.close();
+
+       // Re-open, read byte back using FileInputStream and clean up.
+
+       FileInputStream fis = new FileInputStream(file);
+       fis.skip(pos);
+       System.out.print((char) fis.read());
+       System.out.println((char) fis.read());
+       fis.close();
+      }
+    finally
+      {
+        if (file.exists())
+         file.delete();
+      }
+  }
+}
diff --git a/libjava/testsuite/libjava.lang/LargeFile.out b/libjava/testsuite/libjava.lang/LargeFile.out
new file mode 100644 (file)
index 0000000..d86bac9
--- /dev/null
@@ -0,0 +1 @@
+OK