diff -Naur ocaml-unix-3.08.4/otherlibs/unix/accept.c ocaml-unix-3.09.3/otherlibs/unix/accept.c --- ocaml-unix-3.08.4/otherlibs/unix/accept.c 2005-01-12 16:08:56.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/accept.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: accept.c,v 1.12.6.2 2005/01/12 15:08:56 doligez Exp $ */ +/* $Id: accept.c,v 1.13 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/access.c ocaml-unix-3.09.3/otherlibs/unix/access.c --- ocaml-unix-3.08.4/otherlibs/unix/access.c 2004-11-02 17:21:25.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/access.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: access.c,v 1.10.6.1 2004/11/02 16:21:25 doligez Exp $ */ +/* $Id: access.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/alarm.c ocaml-unix-3.09.3/otherlibs/unix/alarm.c --- ocaml-unix-3.08.4/otherlibs/unix/alarm.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/alarm.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: alarm.c,v 1.7.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: alarm.c,v 1.8 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/unix/bind.c ocaml-unix-3.09.3/otherlibs/unix/bind.c --- ocaml-unix-3.08.4/otherlibs/unix/bind.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/bind.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: bind.c,v 1.9.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: bind.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/connect.c ocaml-unix-3.09.3/otherlibs/unix/connect.c --- ocaml-unix-3.08.4/otherlibs/unix/connect.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/connect.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: connect.c,v 1.11.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: connect.c,v 1.12 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/envir.c ocaml-unix-3.09.3/otherlibs/unix/envir.c --- ocaml-unix-3.08.4/otherlibs/unix/envir.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/envir.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: envir.c,v 1.9.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: envir.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/fchmod.c ocaml-unix-3.09.3/otherlibs/unix/fchmod.c --- ocaml-unix-3.08.4/otherlibs/unix/fchmod.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/fchmod.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: fchmod.c,v 1.9.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: fchmod.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <sys/types.h> #include <sys/stat.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/fchown.c ocaml-unix-3.09.3/otherlibs/unix/fchown.c --- ocaml-unix-3.08.4/otherlibs/unix/fchown.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/fchown.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: fchown.c,v 1.8.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: fchown.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/fcntl.c ocaml-unix-3.09.3/otherlibs/unix/fcntl.c --- ocaml-unix-3.08.4/otherlibs/unix/fcntl.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/fcntl.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: fcntl.c,v 1.11.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: fcntl.c,v 1.12 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/ftruncate.c ocaml-unix-3.09.3/otherlibs/unix/ftruncate.c --- ocaml-unix-3.08.4/otherlibs/unix/ftruncate.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/ftruncate.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: ftruncate.c,v 1.9.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: ftruncate.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <sys/types.h> #include <fail.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getaddrinfo.c ocaml-unix-3.09.3/otherlibs/unix/getaddrinfo.c --- ocaml-unix-3.08.4/otherlibs/unix/getaddrinfo.c 2005-04-17 10:53:02.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/getaddrinfo.c 2005-08-13 22:59:37.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getaddrinfo.c,v 1.1.4.3 2005/04/17 08:53:02 xleroy Exp $ */ +/* $Id: getaddrinfo.c,v 1.3 2005/08/13 20:59:37 doligez Exp $ */ #include <string.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getcwd.c ocaml-unix-3.09.3/otherlibs/unix/getcwd.c --- ocaml-unix-3.08.4/otherlibs/unix/getcwd.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/getcwd.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getcwd.c,v 1.14.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: getcwd.c,v 1.15 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getegid.c ocaml-unix-3.09.3/otherlibs/unix/getegid.c --- ocaml-unix-3.08.4/otherlibs/unix/getegid.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/getegid.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getegid.c,v 1.8.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: getegid.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/unix/geteuid.c ocaml-unix-3.09.3/otherlibs/unix/geteuid.c --- ocaml-unix-3.08.4/otherlibs/unix/geteuid.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/geteuid.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: geteuid.c,v 1.8.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: geteuid.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getgid.c ocaml-unix-3.09.3/otherlibs/unix/getgid.c --- ocaml-unix-3.08.4/otherlibs/unix/getgid.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/getgid.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getgid.c,v 1.8.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: getgid.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getgroups.c ocaml-unix-3.09.3/otherlibs/unix/getgroups.c --- ocaml-unix-3.08.4/otherlibs/unix/getgroups.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/getgroups.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getgroups.c,v 1.10.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: getgroups.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/gethost.c ocaml-unix-3.09.3/otherlibs/unix/gethost.c --- ocaml-unix-3.08.4/otherlibs/unix/gethost.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/gethost.c 2006-06-10 11:10:41.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: gethost.c,v 1.24.2.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: gethost.c,v 1.26.2.1 2006/06/10 09:10:41 xleroy Exp $ */ #include <string.h> #include <mlvalues.h> @@ -62,7 +62,12 @@ Begin_roots4 (name, aliases, addr_list, adr); name = copy_string((char *)(entry->h_name)); - aliases = copy_string_array((const char**)entry->h_aliases); + /* PR#4043: protect against buggy implementations of gethostbyname() + that return a NULL pointer in h_aliases */ + if (entry->h_aliases) + aliases = copy_string_array((const char**)entry->h_aliases); + else + aliases = Atom(0); entry_h_length = entry->h_length; #ifdef h_addr addr_list = alloc_array(alloc_one_addr, (const char**)entry->h_addr_list); @@ -74,7 +79,11 @@ res = alloc_small(4, 0); Field(res, 0) = name; Field(res, 1) = aliases; - Field(res, 2) = entry->h_addrtype == PF_UNIX ? Val_int(0) : Val_int(1); + switch (entry->h_addrtype) { + case PF_UNIX: Field(res, 2) = Val_int(0); break; + case PF_INET: Field(res, 2) = Val_int(1); break; + default: /*PF_INET6 */ Field(res, 2) = Val_int(2); break; + } Field(res, 3) = addr_list; End_roots(); return res; diff -Naur ocaml-unix-3.08.4/otherlibs/unix/gethostname.c ocaml-unix-3.09.3/otherlibs/unix/gethostname.c --- ocaml-unix-3.08.4/otherlibs/unix/gethostname.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/gethostname.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: gethostname.c,v 1.10.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: gethostname.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getlogin.c ocaml-unix-3.09.3/otherlibs/unix/getlogin.c --- ocaml-unix-3.08.4/otherlibs/unix/getlogin.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/getlogin.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getlogin.c,v 1.8.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: getlogin.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getnameinfo.c ocaml-unix-3.09.3/otherlibs/unix/getnameinfo.c --- ocaml-unix-3.08.4/otherlibs/unix/getnameinfo.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/getnameinfo.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getnameinfo.c,v 1.1.4.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: getnameinfo.c,v 1.2 2005/03/24 17:20:53 doligez Exp $ */ #include <string.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getpeername.c ocaml-unix-3.09.3/otherlibs/unix/getpeername.c --- ocaml-unix-3.08.4/otherlibs/unix/getpeername.c 2005-01-12 16:08:56.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/getpeername.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getpeername.c,v 1.10.2.2 2005/01/12 15:08:56 doligez Exp $ */ +/* $Id: getpeername.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getpid.c ocaml-unix-3.09.3/otherlibs/unix/getpid.c --- ocaml-unix-3.08.4/otherlibs/unix/getpid.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/getpid.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getpid.c,v 1.8.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: getpid.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getppid.c ocaml-unix-3.09.3/otherlibs/unix/getppid.c --- ocaml-unix-3.08.4/otherlibs/unix/getppid.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/getppid.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getppid.c,v 1.8.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: getppid.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getproto.c ocaml-unix-3.09.3/otherlibs/unix/getproto.c --- ocaml-unix-3.08.4/otherlibs/unix/getproto.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/getproto.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getproto.c,v 1.12.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: getproto.c,v 1.13 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getserv.c ocaml-unix-3.09.3/otherlibs/unix/getserv.c --- ocaml-unix-3.08.4/otherlibs/unix/getserv.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/getserv.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getserv.c,v 1.13.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: getserv.c,v 1.14 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getsockname.c ocaml-unix-3.09.3/otherlibs/unix/getsockname.c --- ocaml-unix-3.08.4/otherlibs/unix/getsockname.c 2005-01-12 16:08:56.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/getsockname.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getsockname.c,v 1.9.6.2 2005/01/12 15:08:56 doligez Exp $ */ +/* $Id: getsockname.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/gettimeofday.c ocaml-unix-3.09.3/otherlibs/unix/gettimeofday.c --- ocaml-unix-3.08.4/otherlibs/unix/gettimeofday.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/gettimeofday.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: gettimeofday.c,v 1.7.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: gettimeofday.c,v 1.8 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/getuid.c ocaml-unix-3.09.3/otherlibs/unix/getuid.c --- ocaml-unix-3.08.4/otherlibs/unix/getuid.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/getuid.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getuid.c,v 1.8.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: getuid.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/unix/gmtime.c ocaml-unix-3.09.3/otherlibs/unix/gmtime.c --- ocaml-unix-3.08.4/otherlibs/unix/gmtime.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/gmtime.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: gmtime.c,v 1.16.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: gmtime.c,v 1.17 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/itimer.c ocaml-unix-3.09.3/otherlibs/unix/itimer.c --- ocaml-unix-3.08.4/otherlibs/unix/itimer.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/itimer.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: itimer.c,v 1.13.4.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: itimer.c,v 1.14 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/listen.c ocaml-unix-3.09.3/otherlibs/unix/listen.c --- ocaml-unix-3.08.4/otherlibs/unix/listen.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/listen.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: listen.c,v 1.10.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: listen.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/lockf.c ocaml-unix-3.09.3/otherlibs/unix/lockf.c --- ocaml-unix-3.08.4/otherlibs/unix/lockf.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/lockf.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: lockf.c,v 1.13.2.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: lockf.c,v 1.14 2005/03/24 17:20:53 doligez Exp $ */ #include <errno.h> #include <fcntl.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/Makefile ocaml-unix-3.09.3/otherlibs/unix/Makefile --- ocaml-unix-3.08.4/otherlibs/unix/Makefile 2004-04-09 15:25:20.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/Makefile 2004-11-29 15:53:32.000000000 +0100 @@ -11,7 +11,7 @@ # # ######################################################################### -# $Id: Makefile,v 1.38 2004/04/09 13:25:20 xleroy Exp $ +# $Id: Makefile,v 1.41 2004/11/29 14:53:32 doligez Exp $ # Makefile for the Unix interface library diff -Naur ocaml-unix-3.08.4/otherlibs/unix/mkfifo.c ocaml-unix-3.09.3/otherlibs/unix/mkfifo.c --- ocaml-unix-3.08.4/otherlibs/unix/mkfifo.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/mkfifo.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: mkfifo.c,v 1.10.6.2 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: mkfifo.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <sys/types.h> #include <sys/stat.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/open.c ocaml-unix-3.09.3/otherlibs/unix/open.c --- ocaml-unix-3.08.4/otherlibs/unix/open.c 2004-11-02 17:21:25.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/open.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: open.c,v 1.11.6.1 2004/11/02 16:21:25 doligez Exp $ */ +/* $Id: open.c,v 1.12 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/pipe.c ocaml-unix-3.09.3/otherlibs/unix/pipe.c --- ocaml-unix-3.08.4/otherlibs/unix/pipe.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/pipe.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: pipe.c,v 1.9.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: pipe.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/putenv.c ocaml-unix-3.09.3/otherlibs/unix/putenv.c --- ocaml-unix-3.08.4/otherlibs/unix/putenv.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/putenv.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: putenv.c,v 1.8.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: putenv.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <stdlib.h> #include <string.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/readlink.c ocaml-unix-3.09.3/otherlibs/unix/readlink.c --- ocaml-unix-3.08.4/otherlibs/unix/readlink.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/readlink.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: readlink.c,v 1.10.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: readlink.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/rewinddir.c ocaml-unix-3.09.3/otherlibs/unix/rewinddir.c --- ocaml-unix-3.08.4/otherlibs/unix/rewinddir.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/rewinddir.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: rewinddir.c,v 1.11.2.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: rewinddir.c,v 1.12 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/select.c ocaml-unix-3.09.3/otherlibs/unix/select.c --- ocaml-unix-3.08.4/otherlibs/unix/select.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/select.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: select.c,v 1.21.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: select.c,v 1.22 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/sendrecv.c ocaml-unix-3.09.3/otherlibs/unix/sendrecv.c --- ocaml-unix-3.08.4/otherlibs/unix/sendrecv.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/sendrecv.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: sendrecv.c,v 1.18.6.4 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: sendrecv.c,v 1.19 2005/03/24 17:20:53 doligez Exp $ */ #include <string.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/setsid.c ocaml-unix-3.09.3/otherlibs/unix/setsid.c --- ocaml-unix-3.08.4/otherlibs/unix/setsid.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/setsid.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: setsid.c,v 1.5.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: setsid.c,v 1.6 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/shutdown.c ocaml-unix-3.09.3/otherlibs/unix/shutdown.c --- ocaml-unix-3.08.4/otherlibs/unix/shutdown.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/shutdown.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: shutdown.c,v 1.10.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: shutdown.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/signals.c ocaml-unix-3.09.3/otherlibs/unix/signals.c --- ocaml-unix-3.08.4/otherlibs/unix/signals.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/signals.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: signals.c,v 1.9.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: signals.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <errno.h> #include <signal.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/socketaddr.c ocaml-unix-3.09.3/otherlibs/unix/socketaddr.c --- ocaml-unix-3.08.4/otherlibs/unix/socketaddr.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/socketaddr.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: socketaddr.c,v 1.22.2.2 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: socketaddr.c,v 1.23 2005/03/24 17:20:53 doligez Exp $ */ #include <string.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/socketaddr.h ocaml-unix-3.09.3/otherlibs/unix/socketaddr.h --- ocaml-unix-3.08.4/otherlibs/unix/socketaddr.h 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/socketaddr.h 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: socketaddr.h,v 1.15.2.2 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: socketaddr.h,v 1.16 2005/03/24 17:20:53 doligez Exp $ */ #include <misc.h> #include <sys/types.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/socket.c ocaml-unix-3.09.3/otherlibs/unix/socket.c --- ocaml-unix-3.08.4/otherlibs/unix/socket.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/socket.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: socket.c,v 1.10.2.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: socket.c,v 1.11 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/socketpair.c ocaml-unix-3.09.3/otherlibs/unix/socketpair.c --- ocaml-unix-3.08.4/otherlibs/unix/socketpair.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/socketpair.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: socketpair.c,v 1.11.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: socketpair.c,v 1.12 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/sockopt.c ocaml-unix-3.09.3/otherlibs/unix/sockopt.c --- ocaml-unix-3.08.4/otherlibs/unix/sockopt.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/sockopt.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: sockopt.c,v 1.18.6.2 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: sockopt.c,v 1.19 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/strofaddr.c ocaml-unix-3.09.3/otherlibs/unix/strofaddr.c --- ocaml-unix-3.08.4/otherlibs/unix/strofaddr.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/strofaddr.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: strofaddr.c,v 1.9.2.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: strofaddr.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/symlink.c ocaml-unix-3.09.3/otherlibs/unix/symlink.c --- ocaml-unix-3.08.4/otherlibs/unix/symlink.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/symlink.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: symlink.c,v 1.8.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: symlink.c,v 1.9 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/termios.c ocaml-unix-3.09.3/otherlibs/unix/termios.c --- ocaml-unix-3.08.4/otherlibs/unix/termios.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/termios.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: termios.c,v 1.14.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: termios.c,v 1.15 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/time.c ocaml-unix-3.09.3/otherlibs/unix/time.c --- ocaml-unix-3.08.4/otherlibs/unix/time.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/time.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: time.c,v 1.9.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: time.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <time.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/times.c ocaml-unix-3.09.3/otherlibs/unix/times.c --- ocaml-unix-3.08.4/otherlibs/unix/times.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/times.c 2006-01-24 14:44:08.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: times.c,v 1.14.6.1 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: times.c,v 1.15.4.1 2006/01/24 13:44:08 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> @@ -20,6 +20,10 @@ #include <time.h> #include <sys/types.h> #include <sys/times.h> +#ifdef HAS_GETRUSAGE +#include <sys/time.h> +#include <sys/resource.h> +#endif #ifndef CLK_TCK #ifdef HZ @@ -31,6 +35,23 @@ CAMLprim value unix_times(value unit) { +#ifdef HAS_GETRUSAGE + + value res; + struct rusage ru; + + res = alloc_small(4 * Double_wosize, Double_array_tag); + + getrusage (RUSAGE_SELF, &ru); + Store_double_field (res, 0, ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1e6); + Store_double_field (res, 1, ru.ru_stime.tv_sec + ru.ru_stime.tv_usec / 1e6); + getrusage (RUSAGE_CHILDREN, &ru); + Store_double_field (res, 2, ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1e6); + Store_double_field (res, 3, ru.ru_stime.tv_sec + ru.ru_stime.tv_usec / 1e6); + return res; + +#else + value res; struct tms buffer; @@ -41,4 +62,6 @@ Store_double_field(res, 2, (double) buffer.tms_cutime / CLK_TCK); Store_double_field(res, 3, (double) buffer.tms_cstime / CLK_TCK); return res; + +#endif } diff -Naur ocaml-unix-3.08.4/otherlibs/unix/truncate.c ocaml-unix-3.09.3/otherlibs/unix/truncate.c --- ocaml-unix-3.08.4/otherlibs/unix/truncate.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/truncate.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: truncate.c,v 1.9.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: truncate.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <sys/types.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/unixLabels.mli ocaml-unix-3.09.3/otherlibs/unix/unixLabels.mli --- ocaml-unix-3.08.4/otherlibs/unix/unixLabels.mli 2004-07-02 11:37:17.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/unixLabels.mli 2004-07-13 14:25:14.000000000 +0200 @@ -11,7 +11,7 @@ (* *) (***********************************************************************) -(* $Id: unixLabels.mli,v 1.12.2.2 2004/07/02 09:37:17 doligez Exp $ *) +(* $Id: unixLabels.mli,v 1.13 2004/07/13 12:25:14 xleroy Exp $ *) (** Interface to the Unix system. To use as replacement to default {!Unix} module, diff -Naur ocaml-unix-3.08.4/otherlibs/unix/unix.ml ocaml-unix-3.09.3/otherlibs/unix/unix.ml --- ocaml-unix-3.08.4/otherlibs/unix/unix.ml 2004-11-06 11:14:58.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/unix.ml 2005-10-12 16:55:40.000000000 +0200 @@ -11,7 +11,7 @@ (* *) (***********************************************************************) -(* $Id: unix.ml,v 1.60.2.3 2004/11/06 10:14:58 xleroy Exp $ *) +(* $Id: unix.ml,v 1.65 2005/10/12 14:55:40 xleroy Exp $ *) type error = E2BIG @@ -804,8 +804,9 @@ 0 -> if input <> stdin then begin dup2 input stdin; close input end; if output <> stdout then begin dup2 output stdout; close output end; if not cloexec then List.iter close toclose; - execv "/bin/sh" [| "/bin/sh"; "-c"; cmd |]; - exit 127 + begin try execv "/bin/sh" [| "/bin/sh"; "-c"; cmd |] + with _ -> exit 127 + end | id -> Hashtbl.add popen_processes proc id let open_process_in cmd = @@ -840,8 +841,9 @@ dup2 output stdout; close output; dup2 error stderr; close error; if not cloexec then List.iter close toclose; - execve "/bin/sh" [| "/bin/sh"; "-c"; cmd |] env; - exit 127 + begin try execve "/bin/sh" [| "/bin/sh"; "-c"; cmd |] env + with _ -> exit 127 + end | id -> Hashtbl.add popen_processes proc id let open_process_full cmd env = @@ -910,6 +912,10 @@ let shutdown_connection inchan = shutdown (descr_of_in_channel inchan) SHUTDOWN_SEND +let rec accept_non_intr s = + try accept s + with Unix_error (EINTR, _, _) -> accept_non_intr s + let establish_server server_fun sockaddr = let sock = socket (domain_of_sockaddr sockaddr) SOCK_STREAM 0 in @@ -917,20 +923,20 @@ bind sock sockaddr; listen sock 5; while true do - let (s, caller) = accept sock in + let (s, caller) = accept_non_intr sock in (* The "double fork" trick, the process which calls server_fun will not leave a zombie process *) match fork() with 0 -> if fork() <> 0 then exit 0; (* The son exits, the grandson works *) + close sock; ignore(try_set_close_on_exec s); let inchan = in_channel_of_descr s in let outchan = out_channel_of_descr s in server_fun inchan outchan; - close_out outchan; - (* The file descriptor was already closed by close_out. - close_in inchan; - *) + (* Do not close inchan nor outchan, as the server_fun could + have done it already, and we are about to exit anyway + (PR#3794) *) exit 0 - | id -> close s; ignore(waitpid [] id) (* Reclaim the son *) + | id -> close s; ignore(waitpid_non_intr id) (* Reclaim the son *) done diff -Naur ocaml-unix-3.08.4/otherlibs/unix/unix.mli ocaml-unix-3.09.3/otherlibs/unix/unix.mli --- ocaml-unix-3.08.4/otherlibs/unix/unix.mli 2004-12-22 17:11:13.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/unix.mli 2006-03-21 16:50:29.000000000 +0100 @@ -11,7 +11,7 @@ (* *) (***********************************************************************) -(* $Id: unix.mli,v 1.79.2.4 2004/12/22 16:11:13 doligez Exp $ *) +(* $Id: unix.mli,v 1.81.4.2 2006/03/21 15:50:29 doligez Exp $ *) (** Interface to the Unix system *) @@ -90,7 +90,7 @@ | EOVERFLOW (** File size or position not representable *) | EUNKNOWNERR of int (** Unknown error *) -(** The type of error codes. +(** The type of error codes. Errors defined in the POSIX standard and additional errors from UNIX98 and BSD. All other errors are mapped to EUNKNOWNERR. @@ -118,7 +118,7 @@ val environment : unit -> string array (** Return the process environment, as an array of strings with the format ``variable=value''. *) - + val getenv : string -> string (** Return the value associated to a variable in the process environment. Raise [Not_found] if the variable is unbound. @@ -135,8 +135,8 @@ type process_status = - WEXITED of int - (** The process terminated normally by [exit]; + WEXITED of int + (** The process terminated normally by [exit]; the argument is the return code. *) | WSIGNALED of int (** The process was killed by a signal; @@ -155,9 +155,9 @@ val execv : string -> string array -> 'a (** [execv prog args] execute the program in file [prog], with - the arguments [args], and the current process environment. - These [execv*] functions never return: on success, the current - program is replaced by the new one; + the arguments [args], and the current process environment. + These [execv*] functions never return: on success, the current + program is replaced by the new one; on failure, a {!Unix.Unix_error} exception is raised. *) val execve : string -> string array -> string array -> 'a @@ -165,11 +165,11 @@ environment to the program executed. *) val execvp : string -> string array -> 'a -(** Same as {!Unix.execv} respectively, except that +(** Same as {!Unix.execv}, except that the program is searched in the path. *) val execvpe : string -> string array -> string array -> 'a -(** Same as {!Unix.execvp} respectively, except that +(** Same as {!Unix.execve}, except that the program is searched in the path. *) val fork : unit -> int @@ -240,7 +240,7 @@ type file_perm = int -(** The type of file access rights, e.g. [0o640] is read and write for user, +(** The type of file access rights, e.g. [0o640] is read and write for user, read for group, none for others *) val openfile : string -> open_flag list -> file_perm -> file_descr @@ -310,7 +310,7 @@ to the given size. *) -(** {6 File statistics} *) +(** {6 File status} *) type file_kind = @@ -334,7 +334,7 @@ st_size : int; (** Size in bytes *) st_atime : float; (** Last access time *) st_mtime : float; (** Last modification time *) - st_ctime : float; (** Last status change time *) + st_ctime : float; (** Last status change time *) } (** The informations returned by the {!Unix.stat} calls. *) @@ -369,7 +369,7 @@ 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 *) + st_ctime : float; (** Last status change time *) } val stat : string -> stats val lstat : string -> stats @@ -569,23 +569,23 @@ and standard error of the command. *) val close_process_in : in_channel -> process_status -(** Close channels opened by {!Unix.open_process_in}, +(** Close channels opened by {!Unix.open_process_in}, wait for the associated command to terminate, and return its termination status. *) val close_process_out : out_channel -> process_status -(** Close channels opened by {!Unix.open_process_out}, +(** Close channels opened by {!Unix.open_process_out}, wait for the associated command to terminate, and return its termination status. *) val close_process : in_channel * out_channel -> process_status -(** Close channels opened by {!Unix.open_process}, +(** Close channels opened by {!Unix.open_process}, wait for the associated command to terminate, and return its termination status. *) val close_process_full : in_channel * out_channel * in_channel -> process_status -(** Close channels opened by {!Unix.open_process_full}, +(** Close channels opened by {!Unix.open_process_full}, wait for the associated command to terminate, and return its termination status. *) @@ -659,14 +659,14 @@ (** {6 Signals} Note: installation of signal handlers is performed via - the functions {!Sys.signal} and {!Sys.set_signal}. + the functions {!Sys.signal} and {!Sys.set_signal}. *) val kill : int -> int -> unit (** [kill pid sig] sends signal number [sig] to the process with id [pid]. *) -type sigprocmask_command = +type sigprocmask_command = SIG_SETMASK | SIG_BLOCK | SIG_UNBLOCK @@ -700,7 +700,7 @@ { tms_utime : float; (** User time for the process *) tms_stime : float; (** System time for the process *) tms_cutime : float; (** User time for the children processes *) - tms_cstime : float; (** System time for the children processes *) + tms_cstime : float; (** System time for the children processes *) } (** The execution times (CPU times) of a process. *) @@ -713,7 +713,7 @@ tm_year : int; (** Year - 1900 *) tm_wday : int; (** Day of week (Sunday is 0) *) tm_yday : int; (** Day of year 0..365 *) - tm_isdst : bool; (** Daylight time savings in effect *) + tm_isdst : bool; (** Daylight time savings in effect *) } (** The type representing wallclock time and calendar date. *) @@ -758,7 +758,7 @@ 00:00:00 GMT, Jan. 1, 1970. *) type interval_timer = - ITIMER_REAL + ITIMER_REAL (** decrements in real time, and sends the signal [SIGALRM] when expired.*) | ITIMER_VIRTUAL (** decrements in process virtual time, and sends [SIGVTALRM] when expired. *) @@ -770,7 +770,7 @@ type interval_timer_status = { it_interval : float; (** Period *) - it_value : float; (** Current value of the timer *) + it_value : float; (** Current value of the timer *) } (** The type describing the status of an interval timer *) @@ -821,7 +821,7 @@ pw_gid : int; pw_gecos : string; pw_dir : string; - pw_shell : string + pw_shell : string } (** Structure of entries in the [passwd] database. *) @@ -829,7 +829,7 @@ { gr_name : string; gr_passwd : string; gr_gid : int; - gr_mem : string array + gr_mem : string array } (** Structure of entries in the [groups] database. *) @@ -958,11 +958,11 @@ val getpeername : file_descr -> sockaddr (** Return the address of the host connected to the given socket. *) -type msg_flag = +type msg_flag = MSG_OOB | MSG_DONTROUTE | MSG_PEEK -(** The flags for {!Unix.recv}, {!Unix.recvfrom}, +(** The flags for {!Unix.recv}, {!Unix.recvfrom}, {!Unix.send} and {!Unix.sendto}. *) val recv : file_descr -> string -> int -> int -> msg_flag list -> int @@ -1014,7 +1014,7 @@ (** The socket options that can be consulted with {!Unix.getsockopt_optint} and modified with {!Unix.setsockopt_optint}. These options have a value of type [int option], with [None] meaning ``disabled''. *) - + type socket_float_option = SO_RCVTIMEO (** Timeout for input operations *) | SO_SNDTIMEO (** Timeout for output operations *) @@ -1084,14 +1084,14 @@ { h_name : string; h_aliases : string array; h_addrtype : socket_domain; - h_addr_list : inet_addr array + h_addr_list : inet_addr array } (** Structure of entries in the [hosts] database. *) type protocol_entry = - { p_name : string; - p_aliases : string array; - p_proto : int + { p_name : string; + p_aliases : string array; + p_proto : int } (** Structure of entries in the [protocols] database. *) @@ -1099,7 +1099,7 @@ { s_name : string; s_aliases : string array; s_port : int; - s_proto : string + s_proto : string } (** Structure of entries in the [services] database. *) @@ -1143,7 +1143,7 @@ AI_FAMILY of socket_domain (** Impose the given socket domain *) | AI_SOCKTYPE of socket_type (** Impose the given socket type *) | AI_PROTOCOL of int (** Impose the given protocol *) - | AI_NUMERICHOST (** Do not call name resolver, + | AI_NUMERICHOST (** Do not call name resolver, expect numeric IP address *) | AI_CANONNAME (** Fill the [ai_canonname] field of the result *) @@ -1151,7 +1151,7 @@ for use with {!Unix.bind} *) (** Options to {!Unix.getaddrinfo}. *) -val getaddrinfo: +val getaddrinfo: string -> string -> getaddrinfo_option list -> addr_info list (** [getaddrinfo host service opts] returns a list of {!Unix.addr_info} records describing socket parameters and addresses suitable for @@ -1200,7 +1200,7 @@ complete description. *) type terminal_io = - { + { (* input modes *) mutable c_ignbrk : bool; (** Ignore the break condition. *) mutable c_brkint : bool; (** Signal interrupt on break condition. *) @@ -1245,14 +1245,14 @@ before the read request is satisfied. *) mutable c_vtime : int; (** Maximum read wait (in 0.1s units). *) mutable c_vstart : char; (** Start character (usually ctrl-Q). *) - mutable c_vstop : char; (** Stop character (usually ctrl-S). *) + mutable c_vstop : char; (** Stop character (usually ctrl-S). *) } val tcgetattr : file_descr -> terminal_io (** Return the status of the terminal referred to by the given file descriptor. *) -type setattr_when = +type setattr_when = TCSANOW | TCSADRAIN | TCSAFLUSH @@ -1276,7 +1276,7 @@ (** Waits until all output written on the given file descriptor has been transmitted. *) -type flush_queue = +type flush_queue = TCIFLUSH | TCOFLUSH | TCIOFLUSH @@ -1288,7 +1288,7 @@ [TCOFLUSH] flushes data written but not transmitted, and [TCIOFLUSH] flushes both. *) -type flow_action = +type flow_action = TCOOFF | TCOON | TCIOFF diff -Naur ocaml-unix-3.08.4/otherlibs/unix/unixsupport.c ocaml-unix-3.09.3/otherlibs/unix/unixsupport.c --- ocaml-unix-3.08.4/otherlibs/unix/unixsupport.c 2002-03-02 10:16:38.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/unixsupport.c 2005-09-06 14:38:32.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: unixsupport.c,v 1.17 2002/03/02 09:16:38 xleroy Exp $ */ +/* $Id: unixsupport.c,v 1.18 2005/09/06 12:38:32 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> @@ -247,23 +247,31 @@ static value * unix_error_exn = NULL; +value unix_error_of_code (int errcode) +{ + int errconstr; + value err; + + errconstr = + cst_to_constr(errcode, error_table, sizeof(error_table)/sizeof(int), -1); + if (errconstr == Val_int(-1)) { + err = alloc_small(1, 0); + Field(err, 0) = Val_int(errcode); + } else { + err = errconstr; + } + return err; +} + void unix_error(int errcode, char *cmdname, value cmdarg) { value res; value name = Val_unit, err = Val_unit, arg = Val_unit; - int errconstr; Begin_roots3 (name, err, arg); arg = cmdarg == Nothing ? copy_string("") : cmdarg; name = copy_string(cmdname); - errconstr = - cst_to_constr(errcode, error_table, sizeof(error_table)/sizeof(int), -1); - if (errconstr == Val_int(-1)) { - err = alloc_small(1, 0); - Field(err, 0) = Val_int(errcode); - } else { - err = errconstr; - } + err = unix_error_of_code (errcode); if (unix_error_exn == NULL) { unix_error_exn = caml_named_value("Unix.Unix_error"); if (unix_error_exn == NULL) diff -Naur ocaml-unix-3.08.4/otherlibs/unix/unixsupport.h ocaml-unix-3.09.3/otherlibs/unix/unixsupport.h --- ocaml-unix-3.08.4/otherlibs/unix/unixsupport.h 2004-02-14 11:21:23.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/unixsupport.h 2005-09-06 14:38:32.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: unixsupport.h,v 1.7 2004/02/14 10:21:23 xleroy Exp $ */ +/* $Id: unixsupport.h,v 1.8 2005/09/06 12:38:32 doligez Exp $ */ #ifdef HAS_UNISTD #include <unistd.h> @@ -19,6 +19,7 @@ #define Nothing ((value) 0) +extern value unix_error_of_code (int errcode); extern void unix_error (int errcode, char * cmdname, value arg) Noreturn; extern void uerror (char * cmdname, value arg) Noreturn; diff -Naur ocaml-unix-3.08.4/otherlibs/unix/utimes.c ocaml-unix-3.09.3/otherlibs/unix/utimes.c --- ocaml-unix-3.08.4/otherlibs/unix/utimes.c 2004-08-23 13:31:44.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/utimes.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: utimes.c,v 1.9.6.1 2004/08/23 11:31:44 doligez Exp $ */ +/* $Id: utimes.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <fail.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/unix/wait.c ocaml-unix-3.09.3/otherlibs/unix/wait.c --- ocaml-unix-3.08.4/otherlibs/unix/wait.c 2005-01-17 19:10:36.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/unix/wait.c 2005-04-17 10:23:51.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: wait.c,v 1.17.6.3 2005/01/17 18:10:36 doligez Exp $ */ +/* $Id: wait.c,v 1.19 2005/04/17 08:23:51 xleroy Exp $ */ #include <mlvalues.h> #include <alloc.h> @@ -47,11 +47,11 @@ } else if (WIFSTOPPED(status)) { st = alloc_small(1, TAG_WSTOPPED); - Field(st, 0) = Val_int(WSTOPSIG(status)); + Field(st, 0) = Val_int(caml_rev_convert_signal_number(WSTOPSIG(status))); } else { st = alloc_small(1, TAG_WSIGNALED); - Field(st, 0) = Val_int(WTERMSIG(status)); + Field(st, 0) = Val_int(caml_rev_convert_signal_number(WTERMSIG(status))); } Begin_root (st); res = alloc_small(2, 0); diff -Naur ocaml-unix-3.08.4/otherlibs/unix/write.c ocaml-unix-3.09.3/otherlibs/unix/write.c --- ocaml-unix-3.08.4/otherlibs/unix/write.c 2004-07-08 10:40:47.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/unix/write.c 2004-07-13 14:25:15.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: write.c,v 1.13.6.3 2004/07/08 08:40:47 xleroy Exp $ */ +/* $Id: write.c,v 1.14 2004/07/13 12:25:15 xleroy Exp $ */ #include <errno.h> #include <string.h> diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/accept.c ocaml-unix-3.09.3/otherlibs/win32unix/accept.c --- ocaml-unix-3.08.4/otherlibs/win32unix/accept.c 2005-02-02 16:40:14.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/win32unix/accept.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: accept.c,v 1.18.6.1 2005/02/02 15:40:14 xleroy Exp $ */ +/* $Id: accept.c,v 1.19 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include <alloc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/getpeername.c ocaml-unix-3.09.3/otherlibs/win32unix/getpeername.c --- ocaml-unix-3.08.4/otherlibs/win32unix/getpeername.c 2005-02-02 16:40:14.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/win32unix/getpeername.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getpeername.c,v 1.9.6.1 2005/02/02 15:40:14 xleroy Exp $ */ +/* $Id: getpeername.c,v 1.10 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/getsockname.c ocaml-unix-3.09.3/otherlibs/win32unix/getsockname.c --- ocaml-unix-3.08.4/otherlibs/win32unix/getsockname.c 2005-02-02 16:40:14.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/win32unix/getsockname.c 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: getsockname.c,v 1.7.6.1 2005/02/02 15:40:14 xleroy Exp $ */ +/* $Id: getsockname.c,v 1.8 2005/03/24 17:20:53 doligez Exp $ */ #include <mlvalues.h> #include "unixsupport.h" diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/lockf.c ocaml-unix-3.09.3/otherlibs/win32unix/lockf.c --- ocaml-unix-3.08.4/otherlibs/win32unix/lockf.c 2002-07-23 16:12:01.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/win32unix/lockf.c 2005-09-22 16:21:50.000000000 +0200 @@ -12,7 +12,7 @@ /* */ /***********************************************************************/ -/* $Id: lockf.c,v 1.3 2002/07/23 14:12:01 doligez Exp $ */ +/* $Id: lockf.c,v 1.4 2005/09/22 14:21:50 xleroy Exp $ */ #include <errno.h> #include <fcntl.h> @@ -62,7 +62,7 @@ LONG high = dest.HighPart; DWORD ret = SetFilePointer(h, dest.LowPart, &high, method); if (ret == INVALID_SET_FILE_POINTER) { - long err = GetLastError(); + DWORD err = GetLastError(); if (err != NO_ERROR) { win32_maperr(err); uerror("lockf", Nothing); } } if (cur != NULL) { cur->LowPart = ret; cur->HighPart = high; } diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/lseek.c ocaml-unix-3.09.3/otherlibs/win32unix/lseek.c --- ocaml-unix-3.08.4/otherlibs/win32unix/lseek.c 2002-06-07 11:49:41.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/win32unix/lseek.c 2005-02-02 16:52:26.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: lseek.c,v 1.6 2002/06/07 09:49:41 xleroy Exp $ */ +/* $Id: lseek.c,v 1.7 2005/02/02 15:52:26 xleroy Exp $ */ #include <mlvalues.h> #include <alloc.h> @@ -25,7 +25,7 @@ #define SEEK_END 2 #endif -static int seek_command_table[] = { +static DWORD seek_command_table[] = { FILE_BEGIN, FILE_CURRENT, FILE_END }; @@ -33,23 +33,27 @@ #define INVALID_SET_FILE_POINTER (-1) #endif -CAMLprim value unix_lseek(value fd, value ofs, value cmd) +static __int64 caml_set_file_pointer(HANDLE h, __int64 dist, DWORD mode) { - long ret; - long ofs_low = Long_val(ofs); - long ofs_high = ofs_low >= 0 ? 0 : -1; - long err; - - ret = SetFilePointer(Handle_val(fd), ofs_low, &ofs_high, - seek_command_table[Int_val(cmd)]); - if (ret == INVALID_SET_FILE_POINTER) { + LARGE_INTEGER i; + DWORD err; + + i.QuadPart = dist; + i.LowPart = SetFilePointer(h, i.LowPart, &i.HighPart, mode); + if (i.LowPart == INVALID_SET_FILE_POINTER) { err = GetLastError(); - if (err != NO_ERROR) { - win32_maperr(err); - uerror("lseek", Nothing); - } + if (err != NO_ERROR) { win32_maperr(err); uerror("lseek", Nothing); } } - if (ofs_high != 0 || ret > Max_long) { + return i.QuadPart; +} + +CAMLprim value unix_lseek(value fd, value ofs, value cmd) +{ + __int64 ret; + + ret = caml_set_file_pointer(Handle_val(fd), Long_val(ofs), + seek_command_table[Int_val(cmd)]); + if (ret > Max_long) { win32_maperr(ERROR_ARITHMETIC_OVERFLOW); uerror("lseek", Nothing); } @@ -58,19 +62,9 @@ CAMLprim value unix_lseek_64(value fd, value ofs, value cmd) { - long ret; - long ofs_low = (long) Int64_val(ofs); - long ofs_high = (long) (Int64_val(ofs) >> 32); - long err; - - ret = SetFilePointer(Handle_val(fd), ofs_low, &ofs_high, - seek_command_table[Int_val(cmd)]); - if (ret == INVALID_SET_FILE_POINTER) { - err = GetLastError(); - if (err != NO_ERROR) { - win32_maperr(err); - uerror("lseek", Nothing); - } - } - return copy_int64((int64) ofs_high << 32 | ret); + __int64 ret; + + ret = caml_set_file_pointer(Handle_val(fd), Int64_val(ofs), + seek_command_table[Int_val(cmd)]); + return copy_int64(ret); } diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/rename.c ocaml-unix-3.09.3/otherlibs/win32unix/rename.c --- ocaml-unix-3.08.4/otherlibs/win32unix/rename.c 2004-06-21 18:18:32.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/win32unix/rename.c 2004-07-13 14:25:15.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: rename.c,v 1.2.8.1 2004/06/21 16:18:32 xleroy Exp $ */ +/* $Id: rename.c,v 1.3 2004/07/13 12:25:15 xleroy Exp $ */ #include <stdio.h> #include <mlvalues.h> diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/sendrecv.c ocaml-unix-3.09.3/otherlibs/win32unix/sendrecv.c --- ocaml-unix-3.08.4/otherlibs/win32unix/sendrecv.c 2005-02-02 16:40:14.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/win32unix/sendrecv.c 2005-09-22 16:21:50.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: sendrecv.c,v 1.16.6.1 2005/02/02 15:40:14 xleroy Exp $ */ +/* $Id: sendrecv.c,v 1.18 2005/09/22 14:21:50 xleroy Exp $ */ #include <mlvalues.h> #include <alloc.h> @@ -27,7 +27,7 @@ CAMLprim value unix_recv(value sock, value buff, value ofs, value len, value flags) { int ret; - long numbytes; + intnat numbytes; char iobuf[UNIX_BUFFER_SIZE]; Begin_root (buff); @@ -49,7 +49,7 @@ CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, value flags) { int ret; - long numbytes; + intnat numbytes; char iobuf[UNIX_BUFFER_SIZE]; value res; value adr = Val_unit; @@ -82,7 +82,7 @@ CAMLprim value unix_send(value sock, value buff, value ofs, value len, value flags) { int ret; - long numbytes; + intnat numbytes; char iobuf[UNIX_BUFFER_SIZE]; numbytes = Long_val(len); @@ -102,7 +102,7 @@ value unix_sendto_native(value sock, value buff, value ofs, value len, value flags, value dest) { int ret; - long numbytes; + intnat numbytes; char iobuf[UNIX_BUFFER_SIZE]; union sock_addr_union addr; socklen_param_type addr_len; diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/socketaddr.h ocaml-unix-3.09.3/otherlibs/win32unix/socketaddr.h --- ocaml-unix-3.08.4/otherlibs/win32unix/socketaddr.h 2005-02-02 16:40:14.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/win32unix/socketaddr.h 2005-03-24 18:20:53.000000000 +0100 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: socketaddr.h,v 1.7.2.1 2005/02/02 15:40:14 xleroy Exp $ */ +/* $Id: socketaddr.h,v 1.8 2005/03/24 17:20:53 doligez Exp $ */ #include <misc.h> diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/stat.c ocaml-unix-3.09.3/otherlibs/win32unix/stat.c --- ocaml-unix-3.08.4/otherlibs/win32unix/stat.c 2002-03-06 17:55:20.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/win32unix/stat.c 2006-04-06 15:26:58.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: stat.c,v 1.1 2002/03/06 16:55:20 xleroy Exp $ */ +/* $Id: stat.c,v 1.1.14.1 2006/04/06 13:26:58 doligez Exp $ */ #include <errno.h> #include <mlvalues.h> @@ -42,30 +42,25 @@ static value stat_aux(int use_64, struct _stati64 *buf) { - value v; - value atime = Val_unit, mtime = Val_unit, ctime = Val_unit; + CAMLparam0 (); + CAMLlocal1 (v); - 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) = - use_64 ? copy_int64(buf->st_size) : Val_int (buf->st_size); - Field (v, 9) = atime; - Field (v, 10) = mtime; - Field (v, 11) = ctime; - End_roots(); - return v; + v = caml_alloc (12, 0); + Store_field (v, 0, Val_int (buf->st_dev)); + Store_field (v, 1, Val_int (buf->st_ino)); + Store_field (v, 2, cst_to_constr (buf->st_mode & S_IFMT, file_kind_table, + sizeof(file_kind_table) / sizeof(int), 0)); + Store_field (v, 3, Val_int(buf->st_mode & 07777)); + Store_field (v, 4, Val_int (buf->st_nlink)); + Store_field (v, 5, Val_int (buf->st_uid)); + Store_field (v, 6, Val_int (buf->st_gid)); + Store_field (v, 7, Val_int (buf->st_rdev)); + Store_field (v, 8, + use_64 ? copy_int64(buf->st_size) : Val_int (buf->st_size)); + Store_field (v, 9, copy_double((double) buf->st_atime)); + Store_field (v, 10, copy_double((double) buf->st_mtime)); + Store_field (v, 11, copy_double((double) buf->st_ctime)); + CAMLreturn (v); } CAMLprim value unix_stat(value path) diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/unix.ml ocaml-unix-3.09.3/otherlibs/win32unix/unix.ml --- ocaml-unix-3.08.4/otherlibs/win32unix/unix.ml 2004-06-22 19:18:50.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/win32unix/unix.ml 2004-11-30 18:06:19.000000000 +0100 @@ -11,7 +11,7 @@ (* *) (***********************************************************************) -(* $Id: unix.ml,v 1.41.2.1 2004/06/22 17:18:50 remy Exp $ *) +(* $Id: unix.ml,v 1.43 2004/11/30 17:06:19 xleroy Exp $ *) (* Initialization *) @@ -872,7 +872,7 @@ shutdown (descr_of_in_channel inchan) SHUTDOWN_SEND let establish_server server_fun sockaddr = - invalid_arg "Unix.establish_server not implmented" + invalid_arg "Unix.establish_server not implemented" (* Terminal interface *) diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/unixsupport.c ocaml-unix-3.09.3/otherlibs/win32unix/unixsupport.c --- ocaml-unix-3.08.4/otherlibs/win32unix/unixsupport.c 2004-04-01 15:12:36.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/win32unix/unixsupport.c 2005-09-22 16:21:50.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: unixsupport.c,v 1.19 2004/04/01 13:12:36 xleroy Exp $ */ +/* $Id: unixsupport.c,v 1.20 2005/09/22 14:21:50 xleroy Exp $ */ #include <stddef.h> #include <mlvalues.h> @@ -33,9 +33,9 @@ return h1 == h2 ? 0 : h1 < h2 ? -1 : 1; } -static long win_handle_hash(value v) +static intnat win_handle_hash(value v) { - return (long) Handle_val(v); + return (intnat) Handle_val(v); } static struct custom_operations win_handle_ops = { @@ -77,7 +77,7 @@ /* Mapping of Windows error codes to POSIX error codes */ -struct error_entry { unsigned long win_code; int range; int posix_code; }; +struct error_entry { DWORD win_code; int range; int posix_code; }; static struct error_entry win_error_table[] = { { ERROR_INVALID_FUNCTION, 0, EINVAL}, @@ -148,7 +148,7 @@ { 0, -1, 0 } }; -void win32_maperr(unsigned long errcode) +void win32_maperr(DWORD errcode) { int i; diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/unixsupport.h ocaml-unix-3.09.3/otherlibs/win32unix/unixsupport.h --- ocaml-unix-3.08.4/otherlibs/win32unix/unixsupport.h 2003-01-06 15:52:57.000000000 +0100 +++ ocaml-unix-3.09.3/otherlibs/win32unix/unixsupport.h 2005-09-22 16:21:50.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: unixsupport.h,v 1.15 2003/01/06 14:52:57 xleroy Exp $ */ +/* $Id: unixsupport.h,v 1.16 2005/09/22 14:21:50 xleroy Exp $ */ #define WIN32_LEAN_AND_MEAN #include <wtypes.h> @@ -46,7 +46,7 @@ #define NO_CRT_FD (-1) #define Nothing ((value) 0) -extern void win32_maperr(unsigned long errcode); +extern void win32_maperr(DWORD errcode); extern void unix_error (int errcode, char * cmdname, value arg); extern void uerror (char * cmdname, value arg); extern value unix_freeze_buffer (value); diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/winwait.c ocaml-unix-3.09.3/otherlibs/win32unix/winwait.c --- ocaml-unix-3.08.4/otherlibs/win32unix/winwait.c 2002-06-07 11:49:41.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/win32unix/winwait.c 2005-09-22 16:21:50.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: winwait.c,v 1.14 2002/06/07 09:49:41 xleroy Exp $ */ +/* $Id: winwait.c,v 1.15 2005/09/22 14:21:50 xleroy Exp $ */ #include <windows.h> #include <mlvalues.h> @@ -28,7 +28,7 @@ Field(st, 0) = Val_int(status); Begin_root (st); res = alloc_small(2, 0); - Field(res, 0) = Val_long((long) pid); + Field(res, 0) = Val_long((intnat) pid); Field(res, 1) = st; End_roots(); return res; diff -Naur ocaml-unix-3.08.4/otherlibs/win32unix/write.c ocaml-unix-3.09.3/otherlibs/win32unix/write.c --- ocaml-unix-3.08.4/otherlibs/win32unix/write.c 2004-07-08 10:40:55.000000000 +0200 +++ ocaml-unix-3.09.3/otherlibs/win32unix/write.c 2005-09-22 16:21:50.000000000 +0200 @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: write.c,v 1.7.6.2 2004/07/08 08:40:55 xleroy Exp $ */ +/* $Id: write.c,v 1.9 2005/09/22 14:21:50 xleroy Exp $ */ #include <errno.h> #include <string.h> @@ -22,7 +22,7 @@ CAMLprim value unix_write(value fd, value buf, value vofs, value vlen) { - long ofs, len, written; + intnat ofs, len, written; DWORD numbytes, numwritten; char iobuf[UNIX_BUFFER_SIZE]; @@ -65,7 +65,7 @@ CAMLprim value unix_single_write(value fd, value buf, value vofs, value vlen) { - long ofs, len, written; + intnat ofs, len, written; DWORD numbytes, numwritten; char iobuf[UNIX_BUFFER_SIZE];