diff options
-rwxr-xr-x | boot/ocamlc | bin | 804070 -> 804572 bytes | |||
-rwxr-xr-x | boot/ocamllex | bin | 89925 -> 90278 bytes | |||
-rw-r--r-- | byterun/ints.c | 6 | ||||
-rw-r--r-- | byterun/io.c | 81 | ||||
-rw-r--r-- | byterun/io.h | 18 | ||||
-rw-r--r-- | byterun/sys.c | 2 | ||||
-rwxr-xr-x | configure | 5 | ||||
-rw-r--r-- | otherlibs/threads/pervasives.ml | 12 | ||||
-rw-r--r-- | otherlibs/threads/unix.ml | 25 | ||||
-rw-r--r-- | otherlibs/unix/Makefile | 2 | ||||
-rw-r--r-- | otherlibs/unix/ftruncate.c | 12 | ||||
-rw-r--r-- | otherlibs/unix/lseek.c | 21 | ||||
-rw-r--r-- | otherlibs/unix/stat.c | 68 | ||||
-rw-r--r-- | otherlibs/unix/truncate.c | 12 | ||||
-rw-r--r-- | otherlibs/unix/unix.ml | 25 | ||||
-rw-r--r-- | otherlibs/unix/unix.mli | 39 | ||||
-rw-r--r-- | otherlibs/unix/unixLabels.mli | 36 | ||||
-rw-r--r-- | otherlibs/unix/unixsupport.c | 5 | ||||
-rw-r--r-- | stdlib/.depend | 13 | ||||
-rw-r--r-- | stdlib/pervasives.ml | 12 | ||||
-rw-r--r-- | stdlib/pervasives.mli | 16 |
21 files changed, 387 insertions, 23 deletions
diff --git a/boot/ocamlc b/boot/ocamlc Binary files differindex 5c743fbd6..5246b5b92 100755 --- a/boot/ocamlc +++ b/boot/ocamlc diff --git a/boot/ocamllex b/boot/ocamllex Binary files differindex d9f7246c8..360bf3392 100755 --- a/boot/ocamllex +++ b/boot/ocamllex diff --git a/byterun/ints.c b/byterun/ints.c index e9ad19401..b28807bc5 100644 --- a/byterun/ints.c +++ b/byterun/ints.c @@ -267,10 +267,6 @@ CAMLexport int64 Int64_val(value v) return buffer.j; } -CAMLexport void Store_int64(value v, int64 i) -{ -} - #endif static int int64_compare(value v1, value v2) @@ -452,7 +448,7 @@ CAMLprim value int64_float_of_bits(value vi) #else static char int64_error[] = - "The type Int64.t is not supported on this platform"; + "The type int64 is not supported on this platform"; value copy_int64(int64 i) { invalid_argument(int64_error); } diff --git a/byterun/io.c b/byterun/io.c index 1b2b413c7..614f63db9 100644 --- a/byterun/io.c +++ b/byterun/io.c @@ -15,10 +15,15 @@ /* Buffered input/output. */ +#define _FILE_OFFSET_BITS 64 + #include <errno.h> #include <fcntl.h> #include <limits.h> #include <string.h> +#if !macintosh +#include <sys/types.h> +#endif #include "config.h" #ifdef HAS_UNISTD #include <unistd.h> @@ -104,9 +109,9 @@ CAMLexport void close_channel(struct channel *channel) stat_free(channel); } -CAMLexport long channel_size(struct channel *channel) +CAMLexport file_offset channel_size(struct channel *channel) { - long end; + file_offset end; end = lseek(channel->fd, 0, SEEK_END); if (end == -1 || @@ -240,7 +245,7 @@ CAMLexport void really_putblock(struct channel *channel, char *p, long int len) } } -CAMLexport void seek_out(struct channel *channel, long int dest) +CAMLexport void seek_out(struct channel *channel, file_offset dest) { flush(channel); if (lseek(channel->fd, dest, 0) != dest) sys_error(NO_ARG); @@ -337,7 +342,7 @@ CAMLexport int really_getblock(struct channel *chan, char *p, long int n) return (n == 0); } -CAMLexport void seek_in(struct channel *channel, long int dest) +CAMLexport void seek_in(struct channel *channel, file_offset dest) { if (dest >= channel->offset - (channel->max - channel->buff) && dest <= channel->offset) { @@ -486,9 +491,25 @@ CAMLprim value caml_close_channel(value vchannel) return Val_unit; } +/* EOVERFLOW is the Unix98 error indicating that a file position or file + size is not representable. + ERANGE is the ANSI C error indicating that some argument to some + function is out of range. This is less precise than EOVERFLOW, + but guaranteed to be defined on all ANSI C environments. */ +#ifndef EOVERFLOW +#define EOVERFLOW ERANGE +#endif + CAMLprim value caml_channel_size(value vchannel) { - return Val_long(channel_size(Channel(vchannel))); + file_offset size = channel_size(Channel(vchannel)); + if (size > Max_long) { errno = EOVERFLOW; sys_error(NO_ARG); } + return Val_long(size); +} + +CAMLprim value caml_channel_size_64(value vchannel) +{ + return Val_file_offset(channel_size(Channel(vchannel))); } CAMLprim value caml_set_binary_mode(value vchannel, value mode) @@ -578,9 +599,25 @@ CAMLprim value caml_seek_out(value vchannel, value pos) return Val_unit; } +CAMLprim value caml_seek_out_64(value vchannel, value pos) +{ + struct channel * channel = Channel(vchannel); + Lock(channel); + seek_out(channel, File_offset_val(pos)); + Unlock(channel); + return Val_unit; +} + CAMLprim value caml_pos_out(value vchannel) { - return Val_long(pos_out(Channel(vchannel))); + file_offset pos = pos_out(Channel(vchannel)); + if (pos > Max_long) { errno = EOVERFLOW; sys_error(NO_ARG); } + return Val_long(pos); +} + +CAMLprim value caml_pos_out_64(value vchannel) +{ + return Val_file_offset(pos_out(Channel(vchannel))); } CAMLprim value caml_input_char(value vchannel) @@ -649,9 +686,25 @@ CAMLprim value caml_seek_in(value vchannel, value pos) return Val_unit; } +CAMLprim value caml_seek_in_64(value vchannel, value pos) +{ + struct channel * channel = Channel(vchannel); + Lock(channel); + seek_in(channel, File_offset_val(pos)); + Unlock(channel); + return Val_unit; +} + CAMLprim value caml_pos_in(value vchannel) { - return Val_long(pos_in(Channel(vchannel))); + file_offset pos = pos_in(Channel(vchannel)); + if (pos > Max_long) { errno = EOVERFLOW; sys_error(NO_ARG); } + return Val_long(pos); +} + +CAMLprim value caml_pos_in_64(value vchannel) +{ + return Val_file_offset(pos_in(Channel(vchannel))); } CAMLprim value caml_input_scan_line(value vchannel) @@ -664,3 +717,17 @@ CAMLprim value caml_input_scan_line(value vchannel) Unlock(channel); return Val_long(res); } + +/* Conversion between file_offset and int64 */ + +#ifndef ARCH_INT64_TYPE +CAMLexport value Val_file_offset(file_offset fofs) +{ + invalid_argument("The type int64 is not supported on this platform"); +} + +CAMLexport file_offset File_offset_val(value v) +{ + invalid_argument("The type int64 is not supported on this platform"); +} +#endif diff --git a/byterun/io.h b/byterun/io.h index 04bfd28c1..83c61ed62 100644 --- a/byterun/io.h +++ b/byterun/io.h @@ -26,9 +26,15 @@ #define IO_BUFFER_SIZE 4096 #endif +#ifdef HAS_OFF_T +typedef off_t file_offset; +#else +typedef long file_offset; +#endif + struct channel { int fd; /* Unix file descriptor */ - long offset; /* Absolute position of fd in the file */ + file_offset offset; /* Absolute position of fd in the file */ char * end; /* Physical end of the buffer */ char * curr; /* Current position in the buffer */ char * max; /* Logical end of the buffer (for input) */ @@ -93,4 +99,14 @@ CAMLextern void (*channel_mutex_unlock_exn) (void); #define Unlock_exn() \ if (channel_mutex_unlock_exn != NULL) (*channel_mutex_unlock_exn)() +/* Conversion between file_offset and int64 */ + +#ifdef ARCH_INT64_TYPE +#define Val_file_offset(fofs) copy_int64(fofs) +#define File_offset_val(v) ((file_offset) Int64_val(v)) +#else +CAMLextern value Val_file_offset(file_offset fofs); +CAMLextern file_offset File_offset_val(value v); +#endif + #endif /* _io_ */ diff --git a/byterun/sys.c b/byterun/sys.c index cb70ba345..9261bce49 100644 --- a/byterun/sys.c +++ b/byterun/sys.c @@ -15,6 +15,8 @@ /* Basic system calls */ +#define _FILE_OFFSET_BITS 64 + #include <errno.h> #include <fcntl.h> #include <signal.h> @@ -703,6 +703,11 @@ if sh ./hasgot -i unistd.h; then echo "#define HAS_UNISTD" >> s.h fi +if sh ./hasgot -i sys/types.h -t off_t; then + echo "off_t is defined in <sys/types.h>" + echo "#define HAS_OFF_T" >> s.h +fi + if sh ./hasgot -i sys/types.h -i dirent.h; then echo "dirent.h found." echo "#define HAS_DIRENT" >> s.h diff --git a/otherlibs/threads/pervasives.ml b/otherlibs/threads/pervasives.ml index 605989190..2e342dfb0 100644 --- a/otherlibs/threads/pervasives.ml +++ b/otherlibs/threads/pervasives.ml @@ -472,6 +472,18 @@ let read_line () = flush stdout; input_line stdin let read_int () = int_of_string(read_line()) let read_float () = float_of_string(read_line()) +(* Operations on large files *) + +module LargeFile = + struct + external seek_out : out_channel -> int64 -> unit = "caml_seek_out_64" + external pos_out : out_channel -> int64 = "caml_pos_out_64" + external out_channel_length : out_channel -> int64 = "caml_channel_size_64" + external seek_in : in_channel -> int64 -> unit = "caml_seek_in_64" + external pos_in : in_channel -> int64 = "caml_pos_in_64" + external in_channel_length : in_channel -> int64 = "caml_channel_size_64" + end + (* Miscellaneous *) external sys_exit : int -> 'a = "sys_exit" diff --git a/otherlibs/threads/unix.ml b/otherlibs/threads/unix.ml index 9904b5a44..34d97d874 100644 --- a/otherlibs/threads/unix.ml +++ b/otherlibs/threads/unix.ml @@ -121,6 +121,7 @@ type error = | EHOSTDOWN | EHOSTUNREACH | ELOOP + | EOVERFLOW | EUNKNOWNERR of int exception Unix_error of error * string * string @@ -256,6 +257,30 @@ external unlink : string -> unit = "unix_unlink" external rename : string -> string -> unit = "unix_rename" external link : string -> string -> unit = "unix_link" +module LargeFile = + struct + external lseek : file_descr -> int64 -> seek_command -> int = "unix_lseek_64" + external truncate : string -> int64 -> unit = "unix_truncate_64" + external ftruncate : file_descr -> int64 -> unit = "unix_ftruncate_64" + type stats = + { st_dev : int; + st_ino : int; + st_kind : file_kind; + st_perm : file_perm; + st_nlink : int; + st_uid : int; + st_gid : int; + st_rdev : int; + st_size : int64; + st_atime : float; + st_mtime : float; + st_ctime : float; + } + external stat : string -> stats = "unix_stat_64" + external lstat : string -> stats = "unix_lstat_64" + external fstat : file_descr -> stats = "unix_fstat_64" + end + type access_permission = R_OK | W_OK diff --git a/otherlibs/unix/Makefile b/otherlibs/unix/Makefile index bea9c8026..b3d39e29b 100644 --- a/otherlibs/unix/Makefile +++ b/otherlibs/unix/Makefile @@ -19,7 +19,7 @@ include ../../config/Makefile # Compilation options CC=$(BYTECC) -CFLAGS=-I../../byterun -O $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS) +CFLAGS=-I../../byterun -O $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS) -D_FILE_OFFSET_BITS=64 CAMLC=../../boot/ocamlrun ../../ocamlc -I ../../stdlib CAMLOPT=../../boot/ocamlrun ../../ocamlopt -I ../../stdlib MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib diff --git a/otherlibs/unix/ftruncate.c b/otherlibs/unix/ftruncate.c index 259404362..8fe041b47 100644 --- a/otherlibs/unix/ftruncate.c +++ b/otherlibs/unix/ftruncate.c @@ -13,8 +13,13 @@ /* $Id$ */ +#include <sys/types.h> #include <mlvalues.h> +#include <io.h> #include "unixsupport.h" +#ifdef HAS_UNISTD +#include <unistd.h> +#endif #ifdef HAS_TRUNCATE @@ -25,6 +30,13 @@ CAMLprim value unix_ftruncate(value fd, value len) return Val_unit; } +CAMLprim value unix_ftruncate_64(value fd, value len) +{ + if (ftruncate(Int_val(fd), File_offset_val(len)) == -1) + uerror("ftruncate", Nothing); + return Val_unit; +} + #else CAMLprim value unix_ftruncate(value fd, value len) diff --git a/otherlibs/unix/lseek.c b/otherlibs/unix/lseek.c index 3f7d8e698..5dfa7e37f 100644 --- a/otherlibs/unix/lseek.c +++ b/otherlibs/unix/lseek.c @@ -13,7 +13,11 @@ /* $Id$ */ +#include <errno.h> +#include <sys/types.h> #include <mlvalues.h> +#include <alloc.h> +#include <io.h> #include "unixsupport.h" #ifdef HAS_UNISTD @@ -24,15 +28,30 @@ #define SEEK_END 2 #endif +#ifndef EOVERFLOW +#define EOVERFLOW ERANGE +#endif + static int seek_command_table[] = { SEEK_SET, SEEK_CUR, SEEK_END }; CAMLprim value unix_lseek(value fd, value ofs, value cmd) { - long ret; + file_offset ret; ret = lseek(Int_val(fd), Long_val(ofs), seek_command_table[Int_val(cmd)]); if (ret == -1) uerror("lseek", Nothing); + if (ret > Max_long) unix_error(EOVERFLOW, "lseek", Nothing); return Val_long(ret); } + +CAMLprim value unix_lseek_64(value fd, value ofs, value cmd) +{ + file_offset ret; + ret = lseek(Int_val(fd), File_offset_val(ofs), + seek_command_table[Int_val(cmd)]); + if (ret == -1) uerror("lseek", Nothing); + return Val_file_offset(ret); +} + diff --git a/otherlibs/unix/stat.c b/otherlibs/unix/stat.c index a0f1c04a8..db9150ad0 100644 --- a/otherlibs/unix/stat.c +++ b/otherlibs/unix/stat.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <errno.h> #include <mlvalues.h> #include <memory.h> #include <alloc.h> @@ -20,6 +21,7 @@ #include "cst2constr.h" #include <sys/types.h> #include <sys/stat.h> +#include <io.h> #ifndef S_IFLNK #define S_IFLNK 0 @@ -34,6 +36,10 @@ #define S_IFBLK 0 #endif +#ifndef EOVERFLOW +#define EOVERFLOW ERANGE +#endif + static int file_kind_table[] = { S_IFREG, S_IFDIR, S_IFCHR, S_IFBLK, S_IFLNK, S_IFIFO, S_IFSOCK }; @@ -71,6 +77,7 @@ CAMLprim value unix_stat(value path) struct stat buf; ret = stat(String_val(path), &buf); if (ret == -1) uerror("stat", path); + if (buf.st_size > Max_long) unix_error(EOVERFLOW, "stat", path); return stat_aux(&buf); } @@ -84,6 +91,7 @@ CAMLprim value unix_lstat(value path) ret = stat(String_val(path), &buf); #endif if (ret == -1) uerror("lstat", path); + if (buf.st_size > Max_long) unix_error(EOVERFLOW, "lstat", path); return stat_aux(&buf); } @@ -93,5 +101,65 @@ CAMLprim value unix_fstat(value fd) struct stat buf; ret = fstat(Int_val(fd), &buf); if (ret == -1) uerror("fstat", Nothing); + if (buf.st_size > Max_long) unix_error(EOVERFLOW, "fstat", Nothing); return stat_aux(&buf); } + +static value stat_aux_64(struct stat *buf) +{ + value v; + value atime = Val_unit, mtime = Val_unit, ctime = Val_unit; + + Begin_roots3(atime,mtime,ctime) + atime = copy_double((double) buf->st_atime); + mtime = copy_double((double) buf->st_mtime); + ctime = copy_double((double) buf->st_ctime); + v = alloc_small(12, 0); + Field (v, 0) = Val_int (buf->st_dev); + Field (v, 1) = Val_int (buf->st_ino); + Field (v, 2) = cst_to_constr(buf->st_mode & S_IFMT, file_kind_table, + sizeof(file_kind_table) / sizeof(int), 0); + Field (v, 3) = Val_int(buf->st_mode & 07777); + Field (v, 4) = Val_int (buf->st_nlink); + Field (v, 5) = Val_int (buf->st_uid); + Field (v, 6) = Val_int (buf->st_gid); + Field (v, 7) = Val_int (buf->st_rdev); + Field (v, 8) = Val_file_offset (buf->st_size); + Field (v, 9) = atime; + Field (v, 10) = mtime; + Field (v, 11) = ctime; + End_roots(); + return v; +} + +CAMLprim value unix_stat_64(value path) +{ + int ret; + struct stat buf; + ret = stat(String_val(path), &buf); + if (ret == -1) uerror("stat", path); + return stat_aux_64(&buf); +} + +CAMLprim value unix_lstat_64(value path) +{ + int ret; + struct stat buf; +#ifdef HAS_SYMLINK + ret = lstat(String_val(path), &buf); +#else + ret = stat(String_val(path), &buf); +#endif + if (ret == -1) uerror("lstat", path); + return stat_aux_64(&buf); +} + +CAMLprim value unix_fstat_64(value fd) +{ + int ret; + struct stat buf; + ret = fstat(Int_val(fd), &buf); + if (ret == -1) uerror("fstat", Nothing); + return stat_aux_64(&buf); +} + diff --git a/otherlibs/unix/truncate.c b/otherlibs/unix/truncate.c index a3812ae56..009d3c0e5 100644 --- a/otherlibs/unix/truncate.c +++ b/otherlibs/unix/truncate.c @@ -13,8 +13,13 @@ /* $Id$ */ +#include <sys/types.h> #include <mlvalues.h> +#include <io.h> #include "unixsupport.h" +#ifdef HAS_UNISTD +#include <unistd.h> +#endif #ifdef HAS_TRUNCATE @@ -25,6 +30,13 @@ CAMLprim value unix_truncate(value path, value len) return Val_unit; } +CAMLprim value unix_truncate_64(value path, value len) +{ + if (truncate(String_val(path), File_offset_val(len)) == -1) + uerror("truncate", path); + return Val_unit; +} + #else CAMLprim value unix_truncate(value path, value len) diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml index 332669abf..5065a47ae 100644 --- a/otherlibs/unix/unix.ml +++ b/otherlibs/unix/unix.ml @@ -81,6 +81,7 @@ type error = | EHOSTDOWN | EHOSTUNREACH | ELOOP + | EOVERFLOW | EUNKNOWNERR of int exception Unix_error of error * string * string @@ -213,6 +214,30 @@ external unlink : string -> unit = "unix_unlink" external rename : string -> string -> unit = "unix_rename" external link : string -> string -> unit = "unix_link" +module LargeFile = + struct + external lseek : file_descr -> int64 -> seek_command -> int = "unix_lseek_64" + external truncate : string -> int64 -> unit = "unix_truncate_64" + external ftruncate : file_descr -> int64 -> unit = "unix_ftruncate_64" + type stats = + { st_dev : int; + st_ino : int; + st_kind : file_kind; + st_perm : file_perm; + st_nlink : int; + st_uid : int; + st_gid : int; + st_rdev : int; + st_size : int64; + st_atime : float; + st_mtime : float; + st_ctime : float; + } + external stat : string -> stats = "unix_stat_64" + external lstat : string -> stats = "unix_lstat_64" + external fstat : file_descr -> stats = "unix_fstat_64" + end + type access_permission = R_OK | W_OK diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli index b4d021bce..f4060ea80 100644 --- a/otherlibs/unix/unix.mli +++ b/otherlibs/unix/unix.mli @@ -87,11 +87,12 @@ type error = | EHOSTDOWN (** Host is down *) | EHOSTUNREACH (** No route to host *) | ELOOP (** Too many levels of symbolic links *) + | EOVERFLOW (** File size or position not representable *) | EUNKNOWNERR of int (** Unknown error *) (** The type of error codes. Errors defined in the POSIX standard - and additional errors, mostly BSD. + and additional errors from UNIX98 and BSD. All other errors are mapped to EUNKNOWNERR. *) @@ -337,6 +338,42 @@ val fstat : file_descr -> stats descriptor. *) +(** {6 Seeking, truncating and statistics on large files} *) + + +module LargeFile : + sig + val lseek : file_descr -> int64 -> seek_command -> int + val truncate : string -> int64 -> unit + val ftruncate : file_descr -> int64 -> unit + type stats = + { st_dev : int; (** Device number *) + st_ino : int; (** Inode number *) + st_kind : file_kind; (** Kind of the file *) + st_perm : file_perm; (** Access rights *) + st_nlink : int; (** Number of links *) + st_uid : int; (** User id of the owner *) + st_gid : int; (** Group ID of the file's group *) + st_rdev : int; (** Device minor number *) + st_size : int64; (** Size in bytes *) + st_atime : float; (** Last access time *) + st_mtime : float; (** Last modification time *) + st_ctime : float; (** Last status change time *) + } + val stat : string -> stats + val lstat : string -> stats + val fstat : file_descr -> stats + end +(** This sub-module provides 64-bit variants of the functions + {!Unix.lseek} (for positioning a file descriptor), + {!Unix.truncate} and {!Unix.ftruncate} (for changing the size of a file), + and {!Unix.stat}, {!Unix.lstat} and {!Unix.fstat} (for obtaining + information on files). These alternate functions represent + positions and sizes by 64-bit integers (type [int64]) instead of + regular integers (type [int]), thus allowing operating on files + whose sizes are greater than [max_int]. *) + + (** {6 Operations on file names} *) diff --git a/otherlibs/unix/unixLabels.mli b/otherlibs/unix/unixLabels.mli index c0353112b..069a2f9a8 100644 --- a/otherlibs/unix/unixLabels.mli +++ b/otherlibs/unix/unixLabels.mli @@ -90,6 +90,7 @@ type error = | EHOSTDOWN (** Host is down *) | EHOSTUNREACH (** No route to host *) | ELOOP (** Too many levels of symbolic links *) + | EOVERFLOW (** File size or position not representable *) | EUNKNOWNERR of int (** Unknown error *) (** The type of error codes. @@ -341,6 +342,41 @@ val fstat : file_descr -> stats (** Return the information for the file associated with the given descriptor. *) +(** {6 Seeking, truncating and statistics on large files} *) + + +module LargeFile : + sig + val lseek : file_descr -> int64 -> mode:seek_command -> int + val truncate : string -> len:int64 -> unit + val ftruncate : file_descr -> len:int64 -> unit + type stats = Unix.LargeFile.stats = + { st_dev : int; (** Device number *) + st_ino : int; (** Inode number *) + st_kind : file_kind; (** Kind of the file *) + st_perm : file_perm; (** Access rights *) + st_nlink : int; (** Number of links *) + st_uid : int; (** User id of the owner *) + st_gid : int; (** Group ID of the file's group *) + st_rdev : int; (** Device minor number *) + st_size : int64; (** Size in bytes *) + st_atime : float; (** Last access time *) + st_mtime : float; (** Last modification time *) + st_ctime : float; (** Last status change time *) + } + val stat : string -> stats + val lstat : string -> stats + val fstat : file_descr -> stats + end +(** This sub-module provides 64-bit variants of the functions + {!UnixLabels.lseek} (for positioning a file descriptor), + {!UnixLabels.truncate} and {!UnixLabels.ftruncate} + (for changing the size of a file), + and {!UnixLabels.stat}, {!UnixLabels.lstat} and {!UnixLabels.fstat} + (for obtaining information on files). These alternate functions represent + positions and sizes by 64-bit integers (type [int64]) instead of + regular integers (type [int]), thus allowing operating on files + whose sizes are greater than [max_int]. *) (** {6 Operations on file names} *) diff --git a/otherlibs/unix/unixsupport.c b/otherlibs/unix/unixsupport.c index 247f722a2..2a723924c 100644 --- a/otherlibs/unix/unixsupport.c +++ b/otherlibs/unix/unixsupport.c @@ -227,6 +227,9 @@ #ifndef ELOOP #define ELOOP (-1) #endif +#ifndef EOVERFLOW +#define EOVERFLOW (-1) +#endif int error_table[] = { E2BIG, EACCES, EAGAIN, EBADF, EBUSY, ECHILD, EDEADLK, EDOM, @@ -239,7 +242,7 @@ int error_table[] = { EAFNOSUPPORT, EADDRINUSE, EADDRNOTAVAIL, ENETDOWN, ENETUNREACH, ENETRESET, ECONNABORTED, ECONNRESET, ENOBUFS, EISCONN, ENOTCONN, ESHUTDOWN, ETOOMANYREFS, ETIMEDOUT, ECONNREFUSED, EHOSTDOWN, - EHOSTUNREACH, ELOOP /*, EUNKNOWNERR */ + EHOSTUNREACH, ELOOP, EOVERFLOW /*, EUNKNOWNERR */ }; static value * unix_error_exn = NULL; diff --git a/stdlib/.depend b/stdlib/.depend index c22ca15c6..5ab9e10a8 100644 --- a/stdlib/.depend +++ b/stdlib/.depend @@ -3,6 +3,7 @@ genlex.cmi: stream.cmi moreLabels.cmi: hashtbl.cmi map.cmi set.cmi parsing.cmi: lexing.cmi obj.cmi printf.cmi: buffer.cmi +weak.cmi: hashtbl.cmi arg.cmo: array.cmi list.cmi printf.cmi string.cmi sys.cmi arg.cmi arg.cmx: array.cmx list.cmx printf.cmx string.cmx sys.cmx arg.cmi arrayLabels.cmo: array.cmi arrayLabels.cmi @@ -17,8 +18,8 @@ char.cmo: char.cmi char.cmx: char.cmi complex.cmo: complex.cmi complex.cmx: complex.cmi -digest.cmo: string.cmi digest.cmi -digest.cmx: string.cmx digest.cmi +digest.cmo: printf.cmi string.cmi digest.cmi +digest.cmx: printf.cmx string.cmx digest.cmi filename.cmo: buffer.cmi string.cmi sys.cmi filename.cmi filename.cmx: buffer.cmx string.cmx sys.cmx filename.cmi format.cmo: buffer.cmi obj.cmi printf.cmi string.cmi format.cmi @@ -33,8 +34,8 @@ int32.cmo: int32.cmi int32.cmx: int32.cmi int64.cmo: int32.cmi obj.cmi int64.cmi int64.cmx: int32.cmx obj.cmx int64.cmi -lazy.cmo: lazy.cmi -lazy.cmx: lazy.cmi +lazy.cmo: obj.cmi lazy.cmi +lazy.cmx: obj.cmx lazy.cmi lexing.cmo: string.cmi lexing.cmi lexing.cmx: string.cmx lexing.cmi listLabels.cmo: list.cmi listLabels.cmi @@ -83,5 +84,5 @@ string.cmo: char.cmi list.cmi string.cmi string.cmx: char.cmx list.cmx string.cmi sys.cmo: sys.cmi sys.cmx: sys.cmi -weak.cmo: obj.cmi weak.cmi -weak.cmx: obj.cmx weak.cmi +weak.cmo: array.cmi hashtbl.cmi obj.cmi sys.cmi weak.cmi +weak.cmx: array.cmx hashtbl.cmx obj.cmx sys.cmx weak.cmi diff --git a/stdlib/pervasives.ml b/stdlib/pervasives.ml index a13c925f3..b048ef33a 100644 --- a/stdlib/pervasives.ml +++ b/stdlib/pervasives.ml @@ -373,6 +373,18 @@ let read_line () = flush stdout; input_line stdin let read_int () = int_of_string(read_line()) let read_float () = float_of_string(read_line()) +(* Operations on large files *) + +module LargeFile = + struct + external seek_out : out_channel -> int64 -> unit = "caml_seek_out_64" + external pos_out : out_channel -> int64 = "caml_pos_out_64" + external out_channel_length : out_channel -> int64 = "caml_channel_size_64" + external seek_in : in_channel -> int64 -> unit = "caml_seek_in_64" + external pos_in : in_channel -> int64 = "caml_pos_in_64" + external in_channel_length : in_channel -> int64 = "caml_channel_size_64" + end + (* References *) type 'a ref = { mutable contents: 'a } diff --git a/stdlib/pervasives.mli b/stdlib/pervasives.mli index 0d6b4d230..7eecd7f92 100644 --- a/stdlib/pervasives.mli +++ b/stdlib/pervasives.mli @@ -802,6 +802,22 @@ val set_binary_mode_in : in_channel -> bool -> unit This function has no effect under operating systems that do not distinguish between text mode and binary mode. *) +(** {7 Operations on large files} *) + +module LargeFile : + sig + val seek_out : out_channel -> int64 -> unit + val pos_out : out_channel -> int64 + val out_channel_length : out_channel -> int64 + val seek_in : in_channel -> int64 -> unit + val pos_in : in_channel -> int64 + val in_channel_length : in_channel -> int64 + end +(** This sub-module provides 64-bit variants of the channel functions + that manipulate file positions and file sizes. By representing + positions and sizes by 64-bit integers (type [int64]) instead of + regular integers (type [int]), these alternate functions allow + operating on files whose sizes are greater than [max_int]. *) (** {6 References} *) |