diff -r 1af0602ff9a2 ChangeLog
--- a/ChangeLog	Mon Mar 04 10:24:55 2013 -0700
+++ b/ChangeLog	Mon Mar 04 14:53:03 2013 -0700
@@ -1,3 +1,7 @@
+2013-03-04  Jerry James  <james@xemacs.org>
+
+	* configure.ac: Check for large file support.
+
 2013-03-04  Jerry James  <james@xemacs.org>
 
 	* configure.ac: Complete removal of need_modules_common, forgotten
diff -r 1af0602ff9a2 configure.ac
--- a/configure.ac	Mon Mar 04 10:24:55 2013 -0700
+++ b/configure.ac	Mon Mar 04 14:53:03 2013 -0700
@@ -2721,6 +2721,11 @@
 dnl check for long file names
 AC_SYS_LONG_FILE_NAMES
 
+dnl check for large file support
+AC_SYS_LARGEFILE
+AC_FUNC_FSEEKO
+AC_CHECK_SIZEOF(off_t)
+
 dnl -lm is required for floating point support, among other things
 AC_CHECK_FUNC(sin, ,AC_CHECK_LIB(m, sin))
 
diff -r 1af0602ff9a2 lib-src/ChangeLog
--- a/lib-src/ChangeLog	Mon Mar 04 10:24:55 2013 -0700
+++ b/lib-src/ChangeLog	Mon Mar 04 14:53:03 2013 -0700
@@ -1,3 +1,9 @@
+2013-03-04  Jerry James  <james@xemacs.org>
+
+	* insert-data-in-exec.c (main): Use OFF_T, FSEEK, and FTELL macros,
+	and adjust variable types and printf specifiers for large file
+	support on supporting systems.
+
 2013-01-04  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.5.33 "horseradish" is released.
diff -r 1af0602ff9a2 lib-src/insert-data-in-exec.c
--- a/lib-src/insert-data-in-exec.c	Mon Mar 04 10:24:55 2013 -0700
+++ b/lib-src/insert-data-in-exec.c	Mon Mar 04 14:53:03 2013 -0700
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <config.h>
 
 static const unsigned char key[] = {
   255,
@@ -55,8 +56,8 @@
 {
   FILE *te, *xe, *dump;
   unsigned char *xed, *p;
-  long size, size_dump, size1, i;
-  long max_size, offset;
+  size_t size1, offset;
+  OFF_T size, size_dump, max_size, i;
 
   char msg[65536];
 
@@ -73,24 +74,24 @@
       exit(1);
     }
 
-    if(fseek(dump, 0, SEEK_END)) {
+    if(FSEEK(dump, 0, SEEK_END)) {
       perror("fseek end dump");
       exit(1);
     }
 
-    size = ftell(dump);
+    size = FTELL(dump);
     if(size == -1) {
       perror("ftell dump");
       exit(1);
     }
 
-    printf("%ld\n", size);
+    printf("%" PRIdOFF "\n", size);
     exit(0);
   }
 
 
   max_size = strtol(argv[4], 0, 10);
-  offset   = strtol(argv[5], 0, 10);
+  offset   = strtoul(argv[5], 0, 10);
 
   sprintf(msg, "Opening %s failed", argv[1]);
   te = fopen(argv[1], "rb");
@@ -99,18 +100,18 @@
     exit(1);
   }
 
-  if(fseek(te, 0, SEEK_END)) {
+  if(FSEEK(te, 0, SEEK_END)) {
     perror("fseek end");
     exit(1);
   }
 
-  size = ftell(te);
+  size = FTELL(te);
   if(size == -1) {
     perror("ftell");
     exit(1);
   }
 
-  if(fseek(te, 0, SEEK_SET)) {
+  if(FSEEK(te, 0, SEEK_SET)) {
     perror("fseek beginning");
     exit(1);
   }
@@ -121,13 +122,14 @@
     exit(1);
   }
 
-  size1 = fread(xed, 1, size, te);
-  if(size1 != size) {
+  size1 = fread(xed, 1, (size_t) size, te);
+  if(size1 != (size_t) size) {
     if(ferror(te)) {
       perror("fread temacs");
       exit(1);
     }
-    fprintf(stderr, "Fread returned %ld, expected %ld ?\n", size1, size);
+    fprintf(stderr, "Fread returned %zu, expected %" PRIdOFF " ?\n",
+	    size1, size);
     exit(1);
   }
 
@@ -137,7 +139,7 @@
   }
 
   p = xed;
-  for(i=0; i<size-(long)sizeof(key); i++) {
+  for(i=0; i<size-(OFF_T)sizeof(key); i++) {
     if(!memcmp(p, key, sizeof(key)))
       goto found;
     p++;
@@ -147,7 +149,7 @@
   exit(1);
 
  found:
-  fprintf(stderr, "dumped_data found at offset 0x%lx, patching.\n", i);
+  fprintf(stderr, "dumped_data found at offset 0x%" PRIxOFF ", patching.\n", i);
 
   sprintf(msg, "Opening %s failed", argv[2]);
   dump = fopen(argv[2], "rb");
@@ -156,34 +158,36 @@
     exit(1);
   }
 
-  if(fseek(dump, 0, SEEK_END)) {
+  if(FSEEK(dump, 0, SEEK_END)) {
     perror("fseek end dump");
     exit(1);
   }
 
-  size_dump = ftell(dump);
+  size_dump = FTELL(dump);
   if(size_dump == -1) {
     perror("ftell dump");
     exit(1);
   }
 
   if(size_dump > max_size) {
-    fprintf(stderr, "Dump file too big for available space (max=%ld, dump=%ld)\n", max_size, size_dump);
+    fprintf(stderr, "Dump file too big for available space (max=%" PRIdOFF
+	    ", dump=%" PRIdOFF ")\n", max_size, size_dump);
     exit(2);
   }
 
-  if(fseek(dump, 0, SEEK_SET)) {
+  if(FSEEK(dump, 0, SEEK_SET)) {
     perror("fseek beginning dump");
     exit(1);
   }
 
-  size1 = fread(xed+i+offset, 1, size_dump, dump);
-  if(size1 != size_dump) {
+  size1 = fread(xed+i+offset, 1, (size_t) size_dump, dump);
+  if(size1 != (size_t) size_dump) {
     if(ferror(dump)) {
       perror("fread dump");
       exit(1);
     }
-    fprintf(stderr, "Fread dump returned %ld, expected %ld ?\n", size1, size_dump);
+    fprintf(stderr, "Fread dump returned %zu, expected %" PRIdOFF " ?\n",
+	    size1, size_dump);
     exit(1);
   }
 
@@ -199,7 +203,7 @@
   xed[i+2] = size_dump >> 16;
   xed[i+3] = size_dump >> 24;
 
-  fprintf(stderr, "dumped_data found at offset 0x%lx, patching.\n", i);
+  fprintf(stderr, "dumped_data found at offset 0x%" PRIxOFF ", patching.\n", i);
 
   sprintf(msg, "Opening %s failed", argv[3]);
   xe = fopen(argv[3], "wb");
@@ -208,13 +212,14 @@
     exit(1);
   }
 
-  size1 = fwrite(xed, 1, size, xe);
-  if(size1 != size) {
+  size1 = fwrite(xed, 1, (size_t) size, xe);
+  if(size1 != (size_t) size) {
     if(ferror(xe)) {
       perror("fwrite xemacs");
       exit(1);
     }
-    fprintf(stderr, "Fwrite xemacs returned %ld, expected %ld ?\n", size1, size);
+    fprintf(stderr, "Fwrite xemacs returned %zu, expected %" PRIdOFF " ?\n",
+	    size1, size);
     exit(1);
   }
 
diff -r 1af0602ff9a2 src/ChangeLog
--- a/src/ChangeLog	Mon Mar 04 10:24:55 2013 -0700
+++ b/src/ChangeLog	Mon Mar 04 14:53:03 2013 -0700
@@ -1,3 +1,13 @@
+2013-03-04  Jerry James  <james@xemacs.org>
+
+	* config.h.in: Add placeholders and definitions needed for large
+	file support.
+	* dired.c (Ffile_attributes): Some elements of the stat structure
+	can overflow a fixnum.  Allow them to be bignums, if possible.
+	* dumper.c (pdump_align_stream): Use OFF_T, FTELL, and FSEEK macros
+	to get large file support.
+	(pdump): Ditto.
+
 2013-03-02  Jerry James  <james@xemacs.org>
 
 	* Makefile.in.in: If modules are built into the executable, assume
diff -r 1af0602ff9a2 src/config.h.in
--- a/src/config.h.in	Mon Mar 04 10:24:55 2013 -0700
+++ b/src/config.h.in	Mon Mar 04 14:53:03 2013 -0700
@@ -757,6 +757,31 @@
 #undef SIZEOF_LONG_LONG
 #undef SIZEOF_VOID_P
 #undef SIZEOF_DOUBLE
+#undef SIZEOF_OFF_T
+
+/* Large file support */
+#undef AC_FUNC_FSEEKO
+#ifdef AC_FUNC_FSEEKO
+# define OFF_T off_t
+# define FSEEK(stream, offset, whence) fseeko (stream, offset, whence)
+# define FTELL(stream) ftello (stream)
+#else
+# define OFF_T long
+# define FSEEK(stream, offset, whence) fseek (stream, offset, whence)
+# define FTELL(stream) ftell (stream)
+#endif
+#if SIZEOF_OFF_T == SIZEOF_INT
+# define PRIdOFF "d"
+# define PRIxOFF "x"
+#elif SIZEOF_OFF_T == SIZEOF_LONG
+# define PRIdOFF "ld"
+# define PRIxOFF "lx"
+#elif SIZEOF_OFF_T == SIZEOF_LONG_LONG
+# define PRIdOFF "lld"
+# define PRIxOFF "llx"
+#else
+# error cannot determine how to print an off_t
+#endif
 
 /* some systems (Cygwin) typedef u?intptr_t in <sys/types.h>
    but the standard is <inttypes.h>
diff -r 1af0602ff9a2 src/dired.c
--- a/src/dired.c	Mon Mar 04 10:24:55 2013 -0700
+++ b/src/dired.c	Mon Mar 04 14:53:03 2013 -0700
@@ -927,7 +927,7 @@
 
   RETURN_UNGCPRO (listn (12,
 			 mode,
-			 make_fixnum (s.st_nlink),
+			 make_integer (s.st_nlink),
 			 make_fixnum (s.st_uid),
 			 make_fixnum (s.st_gid),
 			 make_time (s.st_atime),
@@ -936,8 +936,8 @@
 			 size,
 			 modestring,
 			 gid,
-			 make_fixnum (s.st_ino),
-			 make_fixnum (s.st_dev)));
+			 make_integer (s.st_ino),
+			 make_integer (s.st_dev)));
 }
 
 
diff -r 1af0602ff9a2 src/dumper.c
--- a/src/dumper.c	Mon Mar 04 10:24:55 2013 -0700
+++ b/src/dumper.c	Mon Mar 04 14:53:03 2013 -0700
@@ -203,10 +203,10 @@
 inline static void
 pdump_align_stream (FILE *stream, Bytecount alignment)
 {
-  long offset = ftell (stream);
-  long adjustment = ALIGN_SIZE (offset, alignment) - offset;
+  OFF_T offset = FTELL (stream);
+  OFF_T adjustment = ALIGN_SIZE (offset, alignment) - offset;
   if (adjustment)
-    fseek (stream, adjustment, SEEK_CUR);
+    FSEEK (stream, adjustment, SEEK_CUR);
 }
 
 #define PDUMP_ALIGN_OUTPUT(type) pdump_align_stream (pdump_out, ALIGNOF (type))
@@ -2168,7 +2168,7 @@
 	elt->fcts->convert_free(elt->object, elt->data, elt->size);
     }
 
-  fseek (pdump_out, header.stab_offset, SEEK_SET);
+  FSEEK (pdump_out, header.stab_offset, SEEK_SET);
 
 #ifdef NEW_GC
   {
