The CRTL infrastructure to do this been available for a year or two or
three but I've just now gotten around to configuring for it. It got a
bit more interesting than I expected, mainly because we have a custom
stat structure that overlays the CRTL stat structure, and the latter is
a completely different beast when _LARGEFILE is defined. The attached
patch does not introduce any test failures, though I assume the test
suite is not actually creating files over 2GB in size. Does anyone have
some good large file tests?

There are also some cosmetic changes here to configure.com for other
64-bit items, but there is more to do in this arena. For example,
-Duse64bitall does not actually enable 64-bit pointers even though long
pointers have been available on Alpha for 6 or 8 years now.

--- configure.com;-0    Fri Dec 31 10:10:02 2004
+++ configure.com       Mon Jan  3 22:40:14 2005
@@ -881,7 +881,7 @@
 $   config_symbols1 
="|installprivlib|installscript|installsitearch|installsitelib|most|oldarchlib|oldarchlibexp|osname|pager|perl_symbol|perl_verb|"
 $   config_symbols2 
="|prefix|privlib|privlibexp|scriptdir|sitearch|sitearchexp|sitebin|sitelib|sitelib_stem|sitelibexp|try_cxx|use64bitall|use64bitint|"
 $   config_symbols3 
="|usecasesensitive|usedefaulttypes|usedevel|useieee|useithreads|usemultiplicity|usemymalloc|usedebugging_perl|useperlio|usesecurelog|"
-$   config_symbols4 
="|usethreads|usevmsdebug|usefaststdio|usemallocwrap|unlink_all_versions|"
+$   config_symbols4 
="|usethreads|usevmsdebug|usefaststdio|usemallocwrap|unlink_all_versions|uselargefiles|"
 $!  
 $   open/read CONFIG 'config_sh'
 $   rd_conf_loop:
@@ -2289,15 +2289,13 @@
 $       IF use64bitint .OR. use64bitint .eqs. "define" THEN bool_dflt = "y"
 $   ENDIF
 $   echo ""
-$   echo "You can have native 64-bit long integers."
+$   echo "You have natively 64-bit long integers."
 $   echo ""
 $   echo "Perl can be built to take advantage of 64-bit integer types"
-$   echo "on some systems, which provide a much larger range for perl's"
-$   echo "mathematical operations.  (Note that does *not* enable 64-bit"
-$   echo "fileops at the moment, as Dec C doesn't do that yet)."
+$   echo "on some systems, To do so, Configure can be run with -Duse64bitint."
 $   echo "Choosing this option will most probably introduce binary 
incompatibilities."
 $   echo ""
-$   echo "If this does not make any sense to you, just accept the default 
''dflt'."
+$   echo "If this does not make any sense to you, just accept the default '" + 
bool_dflt + "'."
 $   rp = "Try to use 64-bit integers, if available? [''bool_dflt'] "
 $   GOSUB myread
 $   use64bitint = ans
@@ -2313,7 +2311,7 @@
 $   echo "binary incompatibilities.  On the other hand, your platform may not"
 $   echo "have any more 64-bitness available than what you already have 
chosen."
 $   echo ""
-$   echo "If this does not make any sense to you, just accept the default 
''dflt'."
+$   echo "If this does not make any sense to you, just accept the default '" + 
bool_dflt + "'."
 $   rp = "Try to use maximal 64-bit support, if available? [''bool_dflt'] "
 $   GOSUB myread
 $   use64bitall=ans
@@ -2324,7 +2322,27 @@
 $     echo "the use of 64-bit integers."
 $     use64bitint="Y"
 $   ENDIF
-$ ENDIF ! AXP && >= 7.1
+$!
+$   bool_dflt = "n"
+$   IF F$TYPE(uselargefiles) .NES. "" 
+$   THEN
+$       IF uselargefiles .OR. uselargefiles .eqs. "define" THEN bool_dflt = "y"
+$   ENDIF
+$   echo ""
+$   echo "Perl can be built to understand large files (files larger than 2 
gigabytes)"
+$   echo "on some systems.  To do so, Configure can be run with 
-Duselargefiles."
+$   echo ""
+$   echo "If this does not make any sense to you, just accept the default '" + 
bool_dflt + "'."
+$   rp = "Try to understand large files, if available? [''bool_dflt'] "
+$   GOSUB myread
+$   IF ans
+$   THEN
+$     uselargefiles="define"
+$   ELSE
+$     uselargefiles="undef"
+$   ENDIF
+$!
+$ ENDIF ! not VAX && >= 7.1
 $!
 $! Ask about threads, if appropriate
 $ IF ccname .EQS. "DEC" .OR. ccname .EQS. "CXX"
@@ -2819,7 +2837,7 @@
 $!
 $ IF use_ieee_math
 $ THEN
-$   extra_flags = "''extra_flags'" + "/float=ieee/ieee=denorm_results"
+$   extra_flags = "''extra_flags'" + "/float=ieee/ieee=denorm"
 $ ENDIF
 $ IF be_case_sensitive
 $ THEN
@@ -2960,7 +2978,6 @@
 $ IF use64bitint .OR. use64bitint .EQS. "define"
 $ THEN
 $   use64bitint = "define"
-$   uselargefiles = "define"
 $   uselongdouble = "define"
 $   alignbytes="16"
 $   usemorebits = "define"
@@ -2971,7 +2988,6 @@
 $   uvXUformat="""LX"""
 $ ELSE
 $   use64bitint = "undef"
-$   uselargefiles = "undef"
 $   uselongdouble = "undef"
 $   usemorebits = "undef"
 $   ivdformat="""ld"""
@@ -3668,6 +3684,36 @@
 $   echo "You do not have int64_t."
 $ ENDIF
 $!
+$! Check to see if fseeko exists
+$!
+$ OS
+$ WS "#include <stdio.h>"
+$ WS "int main()"
+$ WS "{"
+$ WS "FILE *f=NULL;"
+$ WS "fseeko(f,(off_t)0,SEEK_SET);"
+$ WS "return(0);"
+$ WS "}"
+$ CS
+$ tmp = "fseeko"
+$ GOSUB inlibc
+$ d_fseeko = tmp
+$!
+$! Check to see if ftello exists
+$!
+$ OS
+$ WS "#include <stdio.h>"
+$ WS "int main()"
+$ WS "{"
+$ WS "FILE *f=NULL; off_t o=0;"
+$ WS "o=ftello(f);"
+$ WS "return(0);"
+$ WS "}"
+$ CS
+$ tmp = "ftello"
+$ GOSUB inlibc
+$ d_ftello = tmp
+$!
 $!: see if this is a netdb.h system
 $ IF Has_Dec_C_Sockets
 $ THEN 
@@ -4720,6 +4766,32 @@
 $ sizesize = tmp
 $ echo "Your ''zzz' size is ''sizesize' bytes."
 $!
+$! Check for _LARGEFILE capability.
+$!
+$ off_t_size = 4
+$ OS
+$ WS "#define _LARGEFILE"
+$ WS "#include <stdio.h>"
+$ WS "int main()"
+$ WS "{"
+$ WS "printf(""%d\n"", sizeof(off_t));"
+$ WS "return(0);"
+$ WS "}"
+$ CS
+$ GOSUB link_ok
+$ IF link_status .EQ. good_link
+$ THEN
+$   GOSUB just_mcr_it
+$   off_t_size = tmp
+$ ENDIF
+$ echo "Your off_t size is ''off_t_size' bytes when _LARGEFILE is defined."
+$ IF off_t_size .ne. 8 .AND. (uselargefiles .OR. uselargefiles .eqs. "define")
+$ THEN
+$   echo4 "You configured with -Duselargefiles but your CRTL does not support 
_LARGEFILE."
+$   echo4 "I'm disabling large file support."
+$   uselargefiles = "undef"
+$ ENDIF
+$!
 $! Check rand48 and its ilk
 $!
 $ echo4 "Looking for a random number function..."
@@ -5289,7 +5361,13 @@
 $ WC "cc='" + perl_cc + "'"
 $ WC "cccdlflags='" + cccdlflags + "'"
 $ WC "ccdlflags='" + ccdlflags + "'"
-$ WC "ccflags='" + ccflags + "'"
+$ IF uselargefiles .OR. uselargefiles .EQS. "define"
+$ THEN
+$   WC "ccflags='" + ccflags + "/Define=_LARGEFILE'"
+$ ELSE
+$   WC "ccflags='" + ccflags + "'"
+$ ENDIF
+$ WC "ccflags_uselargefiles='" + "'"
 $ WC "ccname='" + ccname + "'"
 $ WC "ccversion='" + ccversion + "'"
 $ WC "cf_by='" + cf_by + "'"
@@ -5390,12 +5468,12 @@
 $ WC "d_fpos64_t='" + d_fpos64_t + "'"
 $ WC "d_frexpl='" + d_frexpl + "'"
 $ WC "d_fs_data_s='undef'"
-$ WC "d_fseeko='undef'"
+$ WC "d_fseeko='" + d_fseeko + "'"
 $ WC "d_fsetpos='define'"
 $ WC "d_fstatfs='undef'"
 $ WC "d_fstatvfs='undef'"
 $ WC "d_fsync='undef'"
-$ WC "d_ftello='undef'"
+$ WC "d_ftello='" + d_ftello + "'"
 $ WC "d_getcwd='define'"
 $ WC "d_getespwnam='undef'"
 $ WC "d_getfsstat='undef'"
@@ -5814,15 +5892,24 @@
 $ WC "ld='" + ld + "'"
 $ WC "lddlflags='/Share'"
 $ WC "ldflags='" + ldflags + "'"
+$ WC "ldflags_uselargefiles='" + "'"
 $ WC "lib_ext='" + lib_ext + "'"
 $ WC "libc='" + libc + "'"
 $ WC "libpth='/sys$share /sys$library'"
 $ WC "libs='" + libs + "'"
+$ WC "libswanted='" + "'"
+$ WC "libswanted_uselargefiles='" + "'"
 $ WC "longdblsize='" + longdblsize + "'"
 $ WC "longlongsize='" + longlongsize + "'"
 $ WC "longsize='" + longsize + "'"
-$ WC "lseeksize='4'"
-$ WC "lseektype='int'"
+$ IF uselargefiles .OR. uselargefiles .EQS. "define"
+$ THEN
+$   WC "lseeksize='8'"
+$   WC "lseektype='off_t'"
+$ ELSE
+$   WC "lseeksize='4'"
+$   WC "lseektype='int'"
+$ ENDIF
 $ WC "mab='" + "'"
 $ WC "make='" + make + "'"
 $ WC "malloctype='void *'"
@@ -6275,12 +6362,17 @@
 $ ELSE
 $   MALLOC_REPLACE = "MALLOC="
 $ ENDIF
+$ IF uselargefiles .OR. uselargefiles .EQS. "define"
+$ THEN
+$   LARGEFILE_REPLACE = "LARGEFILE=LARGEFILE=1"
+$ ELSE
+$   LARGEFILE_REPLACE = "LARGEFILE="
+$ ENDIF
 $ echo4 "Extracting ''defmakefile' (with variable substitutions)"
 $ DEFINE/USER_MODE sys$output 'UUmakefile'
-$ mcr []munchconfig 'config_sh' 'Makefile_SH' "''DECC_REPLACE'" -
- "''DECCXX_REPLACE'" "''ARCH_TYPE'" "''GNUC_REPLACE'" "''SOCKET_REPLACE'" -
- "''THREAD_REPLACE'" "''C_Compiler_Replace'" "''MALLOC_REPLACE'" -
- "''Thread_Live_Dangerously'" "PV=''version'" "FLAGS=FLAGS=''extra_flags'"
+$ mcr []munchconfig 'config_sh' 'Makefile_SH' "''DECC_REPLACE'" 
"''DECCXX_REPLACE'" "''ARCH_TYPE'" "''GNUC_REPLACE'" -
+"''SOCKET_REPLACE'" "''THREAD_REPLACE'" "''C_Compiler_Replace'" 
"''MALLOC_REPLACE'" -
+"''Thread_Live_Dangerously'" "PV=''version'" "FLAGS=FLAGS=''extra_flags'" 
"''LARGEFILE_REPLACE'"
 $! Clean up after ourselves
 $ DELETE/NOLOG/NOCONFIRM []munchconfig.exe;
 $!
--- vms/descrip_mms.template;-0 Wed Dec  1 07:56:00 2004
+++ vms/descrip_mms.template    Sun Jan  2 17:25:16 2005
@@ -31,6 +31,7 @@
 ~CC~
 ~MT~
 ~FLAGS~
+~LARGEFILE~
 
 #: >>>>> Architecture-specific options <<<<<
 .ifdef IXE
@@ -210,11 +211,16 @@
 .endif
 
 # C preprocessor manifest "DEBUGGING" ==> perl -D, not the VMS debugger
+.IFDEF LARGEFILE
+CFLAGS = $(XTRACCFLAGS)$(DBGCCFLAGS)$(FLAGS)/Define=_LARGEFILE
+X2PCFLAGS = 
$(XTRACCFLAGS)$(DBGCCFLAGS)$(FLAGS)/Define=(PERL_FOR_X2P,_LARGEFILE)
+CORECFLAGS = $(XTRACCFLAGS)$(DBGCCFLAGS)$(FLAGS)/Define=(PERL_CORE,_LARGEFILE)
+.ELSE
 CFLAGS = $(XTRACCFLAGS)$(DBGCCFLAGS)$(FLAGS)
-# Flags for a core compile
-X2PCFLAGS = $(CFLAGS)/Define=PERL_FOR_X2P
-# Flags for an x2p compile
-CORECFLAGS = $(CFLAGS)/Define=PERL_CORE
+X2PCFLAGS = $(XTRACCFLAGS)$(DBGCCFLAGS)$(FLAGS)/Define=PERL_FOR_X2P
+CORECFLAGS = $(XTRACCFLAGS)$(DBGCCFLAGS)$(FLAGS)/Define=PERL_CORE
+.ENDIF
+
 LINKFLAGS = $(DBGLINKFLAGS)
 
 MAKE = $(MMS)
--- vms/vmsish.h;-0     Sat Aug  2 01:26:02 2003
+++ vms/vmsish.h        Mon Jan  3 01:42:12 2005
@@ -609,6 +609,45 @@
 /* Since we've got to match the size of the CRTL's stat_t, we need
  * to mimic DECC's alignment settings.
  */
+#ifdef USE_LARGE_FILES
+/* Mimic the new stat structure, filler fields, and alignment. */
+#if defined(__DECC) || defined(__DECCXX)
+#  pragma __member_alignment __save
+#  pragma member_alignment
+#endif
+
+struct mystat
+{
+        char *st_devnam;       /* pointer to device name */
+        char *st_fill_dev;
+        unsigned st_ino;        /* hack - CRTL uses unsigned short[3] for */
+        unsigned short rvn;     /* FID (num,seq,rvn) */
+        unsigned short st_fill_ino;
+        unsigned short st_mode; /* file "mode" i.e. prot, dir, reg, etc. */
+        unsigned short st_fill_mode;
+        int     st_nlink;       /* for compatibility - not really used */
+        unsigned st_uid;        /* from ACP - QIO uic field */
+        unsigned short st_gid;  /* group number extracted from st_uid */
+        unsigned short st_fill_gid;
+        dev_t   st_rdev;        /* for compatibility - always zero */
+        off_t   st_size;        /* file size in bytes */
+        unsigned st_atime;      /* file access time; always same as st_mtime */
+        unsigned st_fill_atime;
+        unsigned st_mtime;      /* last modification time */
+        unsigned st_fill_mtime;
+        unsigned st_ctime;      /* file creation time */
+        unsigned st_fill_ctime;
+        char    st_fab_rfm;     /* record format */
+        char    st_fab_rat;     /* record attributes */
+        char    st_fab_fsz;     /* fixed header size */
+        char    st_fab_fill;
+        unsigned st_fab_mrs;    /* record size */
+        int st_fill_expand[7];  /* will probably fill from beginning, so put 
our st_dev at end */
+        unsigned st_dev;        /* encoded device name */
+};
+
+#else /* !defined(USE_LARGE_FILES) */
+
 #if defined(__DECC) || defined(__DECCXX)
 #  pragma __member_alignment __save
 #  pragma __nomember_alignment
@@ -618,6 +657,7 @@
 #  pragma __message disable (__MISALGNDSTRCT)
 #  pragma __message disable (__MISALGNDMEM)
 #endif
+
 struct mystat
 {
         char *st_devnam;  /* pointer to device name */
@@ -644,6 +684,17 @@
          */
         char   st_fill1[sizeof(void *) - (3*sizeof(unsigned short) + 
3*sizeof(char))%sizeof(void *)];
 };
+
+#if defined(__DECC) 
+#  pragma __message __restore
+#endif
+
+#endif /* defined(USE_LARGE_FILES) */
+
+#if defined(__DECC) || defined(__DECCXX)
+#  pragma __member_alignment __restore
+#endif
+
 typedef unsigned mydev_t;
 typedef unsigned myino_t;
 
@@ -673,12 +724,6 @@
 #  define dev_t mydev_t
 #  define ino_t myino_t
 #endif
-#if defined(__DECC) || defined(__DECCXX)
-#  pragma __member_alignment __restore
-#endif
-#if defined(__DECC) 
-#  pragma __message __restore
-#endif
 /* Cons up a 'delete' bit for testing access */
 #define S_IDUSR (S_IWUSR | S_IXUSR)
 #define S_IDGRP (S_IWGRP | S_IXGRP)

Reply via email to