diff options
Diffstat (limited to 'otherlibs/unix')
58 files changed, 135 insertions, 81 deletions
diff --git a/otherlibs/unix/accept.c b/otherlibs/unix/accept.c index 3247c43dc..d2cb598e5 100644 --- a/otherlibs/unix/accept.c +++ b/otherlibs/unix/accept.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include <memory.h> #include <signals.h> #include "unixsupport.h" @@ -36,7 +37,7 @@ CAMLprim value unix_accept(value sock) retcode = accept(Int_val(sock), &addr.s_gen, &addr_len); leave_blocking_section(); if (retcode == -1) uerror("accept", Nothing); - a = alloc_sockaddr(&addr, addr_len); + a = alloc_sockaddr(&addr, addr_len, retcode); Begin_root (a); res = alloc_small(2, 0); Field(res, 0) = Val_int(retcode); @@ -47,6 +48,7 @@ CAMLprim value unix_accept(value sock) #else -CAMLprim value unix_accept(value sock) { invalid_argument("accept not implemented"); } +CAMLprim value unix_accept(value sock) +{ invalid_argument("accept not implemented"); } #endif diff --git a/otherlibs/unix/access.c b/otherlibs/unix/access.c index 6d81c2bcd..d7065c68e 100644 --- a/otherlibs/unix/access.c +++ b/otherlibs/unix/access.c @@ -42,9 +42,10 @@ static int access_permission_table[] = { CAMLprim value unix_access(value path, value perms) { - int ret; - ret = access(String_val(path), - convert_flag_list(perms, access_permission_table)); + int ret, cv_flags; + + cv_flags = convert_flag_list(perms, access_permission_table); + ret = access(String_val(path), cv_flags); if (ret == -1) uerror("access", path); return Val_unit; diff --git a/otherlibs/unix/alarm.c b/otherlibs/unix/alarm.c index 6eb6ebe81..55e4d6cf8 100644 --- a/otherlibs/unix/alarm.c +++ b/otherlibs/unix/alarm.c @@ -16,8 +16,7 @@ #include <mlvalues.h> #include "unixsupport.h" -CAMLprim value unix_alarm(t) - value t; +CAMLprim value unix_alarm(value t) { return Val_int(alarm((unsigned int) Long_val(t))); } diff --git a/otherlibs/unix/bind.c b/otherlibs/unix/bind.c index d3520d3f5..bec2a9123 100644 --- a/otherlibs/unix/bind.c +++ b/otherlibs/unix/bind.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" diff --git a/otherlibs/unix/connect.c b/otherlibs/unix/connect.c index 2db973b53..3c70d227f 100644 --- a/otherlibs/unix/connect.c +++ b/otherlibs/unix/connect.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include <signals.h> #include "unixsupport.h" diff --git a/otherlibs/unix/envir.c b/otherlibs/unix/envir.c index d17aaa410..1df842c59 100644 --- a/otherlibs/unix/envir.c +++ b/otherlibs/unix/envir.c @@ -20,7 +20,7 @@ extern char ** environ; #endif -CAMLprim value unix_environment(void) +CAMLprim value unix_environment(value unit) { return copy_string_array((const char**)environ); } diff --git a/otherlibs/unix/fchmod.c b/otherlibs/unix/fchmod.c index f812edf16..6378bb198 100644 --- a/otherlibs/unix/fchmod.c +++ b/otherlibs/unix/fchmod.c @@ -15,6 +15,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" diff --git a/otherlibs/unix/fchown.c b/otherlibs/unix/fchown.c index ba74ffeeb..5d28596d0 100644 --- a/otherlibs/unix/fchown.c +++ b/otherlibs/unix/fchown.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" diff --git a/otherlibs/unix/fcntl.c b/otherlibs/unix/fcntl.c index 914406eed..a0891b2c3 100644 --- a/otherlibs/unix/fcntl.c +++ b/otherlibs/unix/fcntl.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" #ifdef HAS_UNISTD diff --git a/otherlibs/unix/ftruncate.c b/otherlibs/unix/ftruncate.c index 8fe041b47..6d9ba450b 100644 --- a/otherlibs/unix/ftruncate.c +++ b/otherlibs/unix/ftruncate.c @@ -14,6 +14,7 @@ /* $Id$ */ #include <sys/types.h> +#include <fail.h> #include <mlvalues.h> #include <io.h> #include "unixsupport.h" diff --git a/otherlibs/unix/getaddrinfo.c b/otherlibs/unix/getaddrinfo.c index 104f55c49..675bcb312 100644 --- a/otherlibs/unix/getaddrinfo.c +++ b/otherlibs/unix/getaddrinfo.c @@ -16,8 +16,8 @@ #include <string.h> #include <mlvalues.h> #include <alloc.h> -#include <memory.h> #include <fail.h> +#include <memory.h> #include <signals.h> #include "unixsupport.h" #include "cst2constr.h" @@ -40,7 +40,7 @@ static value convert_addrinfo(struct addrinfo * a) union sock_addr_union sa; memcpy(&sa.s_gen, a->ai_addr, sizeof(struct sockaddr)); - vaddr = alloc_sockaddr(&sa, sizeof(struct sockaddr)); + vaddr = alloc_sockaddr(&sa, sizeof(struct sockaddr), -1); vcanonname = copy_string(a->ai_canonname == NULL ? "" : a->ai_canonname); vres = alloc_small(5, 0); Field(vres, 0) = cst_to_constr(a->ai_family, socket_domain_table, 3, 0); diff --git a/otherlibs/unix/getcwd.c b/otherlibs/unix/getcwd.c index ee96c88b9..7c735b68d 100644 --- a/otherlibs/unix/getcwd.c +++ b/otherlibs/unix/getcwd.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include "unixsupport.h" #if !defined (_WIN32) && !macintosh diff --git a/otherlibs/unix/getegid.c b/otherlibs/unix/getegid.c index e9900fb69..02beaf124 100644 --- a/otherlibs/unix/getegid.c +++ b/otherlibs/unix/getegid.c @@ -16,7 +16,7 @@ #include <mlvalues.h> #include "unixsupport.h" -CAMLprim value unix_getegid(void) +CAMLprim value unix_getegid(value unit) { return Val_int(getegid()); } diff --git a/otherlibs/unix/geteuid.c b/otherlibs/unix/geteuid.c index fd39879d2..7c9f660af 100644 --- a/otherlibs/unix/geteuid.c +++ b/otherlibs/unix/geteuid.c @@ -16,7 +16,7 @@ #include <mlvalues.h> #include "unixsupport.h" -CAMLprim value unix_geteuid(void) +CAMLprim value unix_geteuid(value unit) { return Val_int(geteuid()); } diff --git a/otherlibs/unix/getgid.c b/otherlibs/unix/getgid.c index debac27ee..d0ed4bff7 100644 --- a/otherlibs/unix/getgid.c +++ b/otherlibs/unix/getgid.c @@ -16,7 +16,7 @@ #include <mlvalues.h> #include "unixsupport.h" -CAMLprim value unix_getgid(void) +CAMLprim value unix_getgid(value unit) { return Val_int(getgid()); } diff --git a/otherlibs/unix/getgroups.c b/otherlibs/unix/getgroups.c index 7bbcfef16..4d34d5be9 100644 --- a/otherlibs/unix/getgroups.c +++ b/otherlibs/unix/getgroups.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #ifdef HAS_GETGROUPS diff --git a/otherlibs/unix/gethost.c b/otherlibs/unix/gethost.c index 3e3e5f971..33c9fdff7 100644 --- a/otherlibs/unix/gethost.c +++ b/otherlibs/unix/gethost.c @@ -16,8 +16,8 @@ #include <string.h> #include <mlvalues.h> #include <alloc.h> -#include <memory.h> #include <fail.h> +#include <memory.h> #include <signals.h> #include "unixsupport.h" diff --git a/otherlibs/unix/gethostname.c b/otherlibs/unix/gethostname.c index 777076bf2..f84f8f5b5 100644 --- a/otherlibs/unix/gethostname.c +++ b/otherlibs/unix/gethostname.c @@ -15,9 +15,10 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #if defined (_WIN32) #include <winsock.h> -#elif !macintosh +#else #include <sys/param.h> #endif #include "unixsupport.h" diff --git a/otherlibs/unix/getlogin.c b/otherlibs/unix/getlogin.c index de569df7f..132ed443a 100644 --- a/otherlibs/unix/getlogin.c +++ b/otherlibs/unix/getlogin.c @@ -20,7 +20,7 @@ extern char * getlogin(void); -CAMLprim value unix_getlogin(void) +CAMLprim value unix_getlogin(value unit) { char * name; name = getlogin(); diff --git a/otherlibs/unix/getnameinfo.c b/otherlibs/unix/getnameinfo.c index a8029eb96..b5824bcb5 100644 --- a/otherlibs/unix/getnameinfo.c +++ b/otherlibs/unix/getnameinfo.c @@ -16,8 +16,8 @@ #include <string.h> #include <mlvalues.h> #include <alloc.h> -#include <memory.h> #include <fail.h> +#include <memory.h> #include <signals.h> #include "unixsupport.h" diff --git a/otherlibs/unix/getpeername.c b/otherlibs/unix/getpeername.c index d4fc3ee36..0431e9a33 100644 --- a/otherlibs/unix/getpeername.c +++ b/otherlibs/unix/getpeername.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" @@ -29,7 +30,7 @@ CAMLprim value unix_getpeername(value sock) addr_len = sizeof(addr); retcode = getpeername(Int_val(sock), &addr.s_gen, &addr_len); if (retcode == -1) uerror("getpeername", Nothing); - return alloc_sockaddr(&addr, addr_len); + return alloc_sockaddr(&addr, addr_len, -1); } #else diff --git a/otherlibs/unix/getpid.c b/otherlibs/unix/getpid.c index 876c63605..cb522749d 100644 --- a/otherlibs/unix/getpid.c +++ b/otherlibs/unix/getpid.c @@ -16,7 +16,7 @@ #include <mlvalues.h> #include "unixsupport.h" -CAMLprim value unix_getpid(void) +CAMLprim value unix_getpid(value unit) { return Val_int(getpid()); } diff --git a/otherlibs/unix/getppid.c b/otherlibs/unix/getppid.c index 660c45c9e..0d69aafb4 100644 --- a/otherlibs/unix/getppid.c +++ b/otherlibs/unix/getppid.c @@ -16,7 +16,7 @@ #include <mlvalues.h> #include "unixsupport.h" -CAMLprim value unix_getppid(void) +CAMLprim value unix_getppid(value unit) { return Val_int(getppid()); } diff --git a/otherlibs/unix/getproto.c b/otherlibs/unix/getproto.c index 7ab2d2e1f..3444072d1 100644 --- a/otherlibs/unix/getproto.c +++ b/otherlibs/unix/getproto.c @@ -15,8 +15,8 @@ #include <mlvalues.h> #include <alloc.h> -#include <memory.h> #include <fail.h> +#include <memory.h> #include "unixsupport.h" #ifdef HAS_SOCKETS diff --git a/otherlibs/unix/getserv.c b/otherlibs/unix/getserv.c index e58022583..e882e8435 100644 --- a/otherlibs/unix/getserv.c +++ b/otherlibs/unix/getserv.c @@ -15,8 +15,8 @@ #include <mlvalues.h> #include <alloc.h> -#include <memory.h> #include <fail.h> +#include <memory.h> #include "unixsupport.h" #ifdef HAS_SOCKETS diff --git a/otherlibs/unix/getsockname.c b/otherlibs/unix/getsockname.c index 94990e26d..5422236ff 100644 --- a/otherlibs/unix/getsockname.c +++ b/otherlibs/unix/getsockname.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" @@ -29,7 +30,7 @@ CAMLprim value unix_getsockname(value sock) addr_len = sizeof(addr); retcode = getsockname(Int_val(sock), &addr.s_gen, &addr_len); if (retcode == -1) uerror("getsockname", Nothing); - return alloc_sockaddr(&addr, addr_len); + return alloc_sockaddr(&addr, addr_len, -1); } #else diff --git a/otherlibs/unix/gettimeofday.c b/otherlibs/unix/gettimeofday.c index 97f80f05e..e095326e6 100644 --- a/otherlibs/unix/gettimeofday.c +++ b/otherlibs/unix/gettimeofday.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include "unixsupport.h" #ifdef HAS_GETTIMEOFDAY diff --git a/otherlibs/unix/getuid.c b/otherlibs/unix/getuid.c index 0417665a2..780a8d8ec 100644 --- a/otherlibs/unix/getuid.c +++ b/otherlibs/unix/getuid.c @@ -16,7 +16,7 @@ #include <mlvalues.h> #include "unixsupport.h" -CAMLprim value unix_getuid(void) +CAMLprim value unix_getuid(value unit) { return Val_int(getuid()); } diff --git a/otherlibs/unix/gmtime.c b/otherlibs/unix/gmtime.c index 502a5f9f9..2ffeb3927 100644 --- a/otherlibs/unix/gmtime.c +++ b/otherlibs/unix/gmtime.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include <memory.h> #include "unixsupport.h" #include <time.h> @@ -88,6 +89,7 @@ CAMLprim value unix_mktime(value t) #else -CAMLprim value unix_mktime(value t) { invalid_argument("mktime not implemented"); } +CAMLprim value unix_mktime(value t) +{ invalid_argument("mktime not implemented"); } #endif diff --git a/otherlibs/unix/itimer.c b/otherlibs/unix/itimer.c index 6e5ea3589..43fc4e10f 100644 --- a/otherlibs/unix/itimer.c +++ b/otherlibs/unix/itimer.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include <memory.h> #include "unixsupport.h" diff --git a/otherlibs/unix/listen.c b/otherlibs/unix/listen.c index d85d854fc..2f40cfbaf 100644 --- a/otherlibs/unix/listen.c +++ b/otherlibs/unix/listen.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" diff --git a/otherlibs/unix/lockf.c b/otherlibs/unix/lockf.c index 82f3c5d7e..6e6ce5c17 100644 --- a/otherlibs/unix/lockf.c +++ b/otherlibs/unix/lockf.c @@ -15,6 +15,7 @@ #include <errno.h> #include <fcntl.h> +#include <fail.h> #include <mlvalues.h> #include <signals.h> #include "unixsupport.h" diff --git a/otherlibs/unix/mkfifo.c b/otherlibs/unix/mkfifo.c index f260cb74e..3e2cf3ddb 100644 --- a/otherlibs/unix/mkfifo.c +++ b/otherlibs/unix/mkfifo.c @@ -15,6 +15,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" @@ -43,7 +44,10 @@ CAMLprim value unix_mkfifo(value path, value mode) #else -CAMLprim value unix_mkfifo() { invalid_argument("mkfifo not implemented"); } +CAMLprim value unix_mkfifo(value path, value mode) +{ + invalid_argument("mkfifo not implemented"); +} #endif #endif diff --git a/otherlibs/unix/open.c b/otherlibs/unix/open.c index 880cbb5c6..c108f7a55 100644 --- a/otherlibs/unix/open.c +++ b/otherlibs/unix/open.c @@ -42,14 +42,15 @@ static int open_flag_table[] = { CAMLprim value unix_open(value path, value flags, value perm) { CAMLparam3(path, flags, perm); - int ret; + int ret, cv_flags; char * p; + cv_flags = convert_flag_list(flags, open_flag_table); p = stat_alloc(string_length(path) + 1); strcpy(p, String_val(path)); /* open on a named FIFO can block (PR#1533) */ enter_blocking_section(); - ret = open(p, convert_flag_list(flags, open_flag_table), Int_val(perm)); + ret = open(p, cv_flags, Int_val(perm)); leave_blocking_section(); stat_free(p); if (ret == -1) uerror("open", path); diff --git a/otherlibs/unix/pipe.c b/otherlibs/unix/pipe.c index 6b571be65..b68705e9f 100644 --- a/otherlibs/unix/pipe.c +++ b/otherlibs/unix/pipe.c @@ -17,7 +17,7 @@ #include <alloc.h> #include "unixsupport.h" -CAMLprim value unix_pipe(void) +CAMLprim value unix_pipe(value unit) { int fd[2]; value res; diff --git a/otherlibs/unix/putenv.c b/otherlibs/unix/putenv.c index 962fd7902..e403d2966 100644 --- a/otherlibs/unix/putenv.c +++ b/otherlibs/unix/putenv.c @@ -16,6 +16,7 @@ #include <stdlib.h> #include <string.h> +#include <fail.h> #include <memory.h> #include <mlvalues.h> diff --git a/otherlibs/unix/readlink.c b/otherlibs/unix/readlink.c index 6cc4d9ec4..d2b9c4e12 100644 --- a/otherlibs/unix/readlink.c +++ b/otherlibs/unix/readlink.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #ifdef HAS_SYMLINK diff --git a/otherlibs/unix/rewinddir.c b/otherlibs/unix/rewinddir.c index 120701b5b..d14c526d9 100644 --- a/otherlibs/unix/rewinddir.c +++ b/otherlibs/unix/rewinddir.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" #include <errno.h> diff --git a/otherlibs/unix/select.c b/otherlibs/unix/select.c index 43de97709..376fcf783 100644 --- a/otherlibs/unix/select.c +++ b/otherlibs/unix/select.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include <memory.h> #include <signals.h> #include "unixsupport.h" diff --git a/otherlibs/unix/sendrecv.c b/otherlibs/unix/sendrecv.c index ac9b32e85..bb3989af7 100644 --- a/otherlibs/unix/sendrecv.c +++ b/otherlibs/unix/sendrecv.c @@ -16,6 +16,7 @@ #include <string.h> #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include <memory.h> #include <signals.h> #include "unixsupport.h" @@ -27,18 +28,19 @@ static int msg_flag_table[] = { MSG_OOB, MSG_DONTROUTE, MSG_PEEK }; -CAMLprim value unix_recv(value sock, value buff, value ofs, value len, value flags) +CAMLprim value unix_recv(value sock, value buff, value ofs, value len, + value flags) { - int ret; + int ret, cv_flags; long numbytes; char iobuf[UNIX_BUFFER_SIZE]; + cv_flags = convert_flag_list(flags, msg_flag_table); Begin_root (buff); numbytes = Long_val(len); if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE; enter_blocking_section(); - ret = recv(Int_val(sock), iobuf, (int) numbytes, - convert_flag_list(flags, msg_flag_table)); + ret = recv(Int_val(sock), iobuf, (int) numbytes, cv_flags); leave_blocking_section(); if (ret == -1) uerror("recv", Nothing); memmove (&Byte(buff, Long_val(ofs)), iobuf, ret); @@ -46,9 +48,10 @@ CAMLprim value unix_recv(value sock, value buff, value ofs, value len, value fla return Val_int(ret); } -CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, value flags) +CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, + value flags) { - int ret; + int ret, cv_flags; long numbytes; char iobuf[UNIX_BUFFER_SIZE]; value res; @@ -56,18 +59,18 @@ CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, value union sock_addr_union addr; socklen_param_type addr_len; + cv_flags = convert_flag_list(flags, msg_flag_table); Begin_roots2 (buff, adr); numbytes = Long_val(len); if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE; addr_len = sizeof(addr); enter_blocking_section(); - ret = recvfrom(Int_val(sock), iobuf, (int) numbytes, - convert_flag_list(flags, msg_flag_table), + ret = recvfrom(Int_val(sock), iobuf, (int) numbytes, cv_flags, &addr.s_gen, &addr_len); leave_blocking_section(); if (ret == -1) uerror("recvfrom", Nothing); memmove (&Byte(buff, Long_val(ofs)), iobuf, ret); - adr = alloc_sockaddr(&addr, addr_len); + adr = alloc_sockaddr(&addr, addr_len, -1); res = alloc_small(2, 0); Field(res, 0) = Val_int(ret); Field(res, 1) = adr; @@ -75,38 +78,40 @@ CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, value return res; } -CAMLprim value unix_send(value sock, value buff, value ofs, value len, value flags) +CAMLprim value unix_send(value sock, value buff, value ofs, value len, + value flags) { - int ret; + int ret, cv_flags; long numbytes; char iobuf[UNIX_BUFFER_SIZE]; + cv_flags = convert_flag_list(flags, msg_flag_table); numbytes = Long_val(len); if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE; memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes); enter_blocking_section(); - ret = send(Int_val(sock), iobuf, (int) numbytes, - convert_flag_list(flags, msg_flag_table)); + ret = send(Int_val(sock), iobuf, (int) numbytes, cv_flags); leave_blocking_section(); if (ret == -1) uerror("send", Nothing); return Val_int(ret); } -CAMLprim value unix_sendto_native(value sock, value buff, value ofs, value len, value flags, value dest) +CAMLprim value unix_sendto_native(value sock, value buff, value ofs, value len, + value flags, value dest) { - int ret; + int ret, cv_flags; long numbytes; char iobuf[UNIX_BUFFER_SIZE]; union sock_addr_union addr; socklen_param_type addr_len; + cv_flags = convert_flag_list(flags, msg_flag_table); get_sockaddr(dest, &addr, &addr_len); numbytes = Long_val(len); if (numbytes > UNIX_BUFFER_SIZE) numbytes = UNIX_BUFFER_SIZE; memmove (iobuf, &Byte(buff, Long_val(ofs)), numbytes); enter_blocking_section(); - ret = sendto(Int_val(sock), iobuf, (int) numbytes, - convert_flag_list(flags, msg_flag_table), + ret = sendto(Int_val(sock), iobuf, (int) numbytes, cv_flags, &addr.s_gen, addr_len); leave_blocking_section(); if (ret == -1) uerror("sendto", Nothing); @@ -121,16 +126,20 @@ CAMLprim value unix_sendto(value *argv, int argc) #else -CAMLprim value unix_recv(value sock, value buff, value ofs, value len, value flags) +CAMLprim value unix_recv(value sock, value buff, value ofs, value len, + value flags) { invalid_argument("recv not implemented"); } -CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, value flags) +CAMLprim value unix_recvfrom(value sock, value buff, value ofs, value len, + value flags) { invalid_argument("recvfrom not implemented"); } -CAMLprim value unix_send(value sock, value buff, value ofs, value len, value flags) +CAMLprim value unix_send(value sock, value buff, value ofs, value len, + value flags) { invalid_argument("send not implemented"); } -CAMLprim value unix_sendto_native(value sock, value buff, value ofs, value len, value flags, value dest) +CAMLprim value unix_sendto_native(value sock, value buff, value ofs, value len, + value flags, value dest) { invalid_argument("sendto not implemented"); } CAMLprim value unix_sendto(value *argv, int argc) diff --git a/otherlibs/unix/setsid.c b/otherlibs/unix/setsid.c index fed8e0dca..bfa9dac0b 100644 --- a/otherlibs/unix/setsid.c +++ b/otherlibs/unix/setsid.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" #ifdef HAS_UNISTD diff --git a/otherlibs/unix/shutdown.c b/otherlibs/unix/shutdown.c index f8216bd2e..d51b1a3de 100644 --- a/otherlibs/unix/shutdown.c +++ b/otherlibs/unix/shutdown.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" diff --git a/otherlibs/unix/signals.c b/otherlibs/unix/signals.c index 95db00bd2..b244f8af6 100644 --- a/otherlibs/unix/signals.c +++ b/otherlibs/unix/signals.c @@ -17,6 +17,7 @@ #include <signal.h> #include <alloc.h> +#include <fail.h> #include <memory.h> #include <mlvalues.h> #include <signals.h> diff --git a/otherlibs/unix/socket.c b/otherlibs/unix/socket.c index 1723faa27..82f6329c0 100644 --- a/otherlibs/unix/socket.c +++ b/otherlibs/unix/socket.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" diff --git a/otherlibs/unix/socketaddr.c b/otherlibs/unix/socketaddr.c index 932bb9643..0ee1cf5ee 100644 --- a/otherlibs/unix/socketaddr.c +++ b/otherlibs/unix/socketaddr.c @@ -28,7 +28,7 @@ #define EAFNOSUPPORT WSAEAFNOSUPPORT #endif -CAMLprim value alloc_inet_addr(struct in_addr * a) +CAMLexport value alloc_inet_addr(struct in_addr * a) { value res; /* Use a string rather than an abstract block so that it can be @@ -41,7 +41,7 @@ CAMLprim value alloc_inet_addr(struct in_addr * a) #ifdef HAS_IPV6 -CAMLprim value alloc_inet6_addr(struct in6_addr * a) +CAMLexport value alloc_inet6_addr(struct in6_addr * a) { value res; res = alloc_string(16); @@ -94,7 +94,7 @@ void get_sockaddr(value mladr, } value alloc_sockaddr(union sock_addr_union * adr /*in*/, - socklen_param_type adr_len) + socklen_param_type adr_len, int close_on_error) { value res; switch(adr->s_gen.sa_family) { @@ -129,6 +129,7 @@ value alloc_sockaddr(union sock_addr_union * adr /*in*/, } #endif default: + if (close_on_error != -1) close (close_on_error); unix_error(EAFNOSUPPORT, "", Nothing); } return res; diff --git a/otherlibs/unix/socketaddr.h b/otherlibs/unix/socketaddr.h index 0cabfcc6d..79bc80fa7 100644 --- a/otherlibs/unix/socketaddr.h +++ b/otherlibs/unix/socketaddr.h @@ -38,12 +38,12 @@ typedef int socklen_param_type; extern void get_sockaddr (value mladdr, union sock_addr_union * addr /*out*/, socklen_param_type * addr_len /*out*/); -CAMLprim value alloc_sockaddr (union sock_addr_union * addr /*in*/, - socklen_param_type addr_len); -CAMLprim value alloc_inet_addr (struct in_addr * inaddr); +CAMLexport value alloc_sockaddr (union sock_addr_union * addr /*in*/, + socklen_param_type addr_len, int close_on_error); +CAMLexport value alloc_inet_addr (struct in_addr * inaddr); #define GET_INET_ADDR(v) (*((struct in_addr *) (v))) #ifdef HAS_IPV6 -CAMLprim value alloc_inet6_addr (struct in6_addr * inaddr); +CAMLexport value alloc_inet6_addr (struct in6_addr * inaddr); #define GET_INET6_ADDR(v) (*((struct in6_addr *) (v))) #endif diff --git a/otherlibs/unix/socketpair.c b/otherlibs/unix/socketpair.c index 6c7b4ebc8..df4dcff03 100644 --- a/otherlibs/unix/socketpair.c +++ b/otherlibs/unix/socketpair.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include "unixsupport.h" #ifdef HAS_SOCKETS diff --git a/otherlibs/unix/sockopt.c b/otherlibs/unix/sockopt.c index 3d913dca3..ad6fe3367 100644 --- a/otherlibs/unix/sockopt.c +++ b/otherlibs/unix/sockopt.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include "unixsupport.h" #ifdef HAS_SOCKETS @@ -85,8 +86,8 @@ static int sockopt_optint[] = { SO_LINGER }; static int sockopt_float[] = { SO_RCVTIMEO, SO_SNDTIMEO }; -CAMLprim value getsockopt_int(int *sockopt, value socket, - int level, value option) +CAMLexport value getsockopt_int(int *sockopt, value socket, + int level, value option) { int optval; socklen_param_type optsize; @@ -98,8 +99,8 @@ CAMLprim value getsockopt_int(int *sockopt, value socket, return Val_int(optval); } -CAMLprim value setsockopt_int(int *sockopt, value socket, int level, - value option, value status) +CAMLexport value setsockopt_int(int *sockopt, value socket, int level, + value option, value status) { int optval = Int_val(status); if (setsockopt(Int_val(socket), level, sockopt[Int_val(option)], @@ -127,8 +128,8 @@ CAMLprim value unix_setsockopt_int(value socket, value option, value status) return setsockopt_int(sockopt_int, socket, SOL_SOCKET, option, status); } -CAMLprim value getsockopt_optint(int *sockopt, value socket, - int level, value option) +CAMLexport value getsockopt_optint(int *sockopt, value socket, + int level, value option) { struct linger optval; socklen_param_type optsize; @@ -145,8 +146,8 @@ CAMLprim value getsockopt_optint(int *sockopt, value socket, return res; } -CAMLprim value setsockopt_optint(int *sockopt, value socket, int level, - value option, value status) +CAMLexport value setsockopt_optint(int *sockopt, value socket, int level, + value option, value status) { struct linger optval; @@ -169,8 +170,8 @@ CAMLprim value unix_setsockopt_optint(value socket, value option, value status) return setsockopt_optint(sockopt_optint, socket, SOL_SOCKET, option, status); } -CAMLprim value getsockopt_float(int *sockopt, value socket, - int level, value option) +CAMLexport value getsockopt_float(int *sockopt, value socket, + int level, value option) { struct timeval tv; socklen_param_type optsize; @@ -182,8 +183,8 @@ CAMLprim value getsockopt_float(int *sockopt, value socket, return copy_double((double) tv.tv_sec + (double) tv.tv_usec / 1e6); } -CAMLprim value setsockopt_float(int *sockopt, value socket, int level, - value option, value status) +CAMLexport value setsockopt_float(int *sockopt, value socket, int level, + value option, value status) { struct timeval tv; double tv_f; diff --git a/otherlibs/unix/strofaddr.c b/otherlibs/unix/strofaddr.c index 90ffd9749..ad9ea1911 100644 --- a/otherlibs/unix/strofaddr.c +++ b/otherlibs/unix/strofaddr.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include "unixsupport.h" #ifdef HAS_SOCKETS diff --git a/otherlibs/unix/symlink.c b/otherlibs/unix/symlink.c index 8c011152b..6085fd516 100644 --- a/otherlibs/unix/symlink.c +++ b/otherlibs/unix/symlink.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" diff --git a/otherlibs/unix/termios.c b/otherlibs/unix/termios.c index e3c759444..f885544cf 100644 --- a/otherlibs/unix/termios.c +++ b/otherlibs/unix/termios.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include "unixsupport.h" #ifdef HAS_TERMIOS diff --git a/otherlibs/unix/time.c b/otherlibs/unix/time.c index c63c2eb80..2fdf4978e 100644 --- a/otherlibs/unix/time.c +++ b/otherlibs/unix/time.c @@ -18,7 +18,7 @@ #include <alloc.h> #include "unixsupport.h" -CAMLprim value unix_time(void) +CAMLprim value unix_time(value unit) { return copy_double((double) time((time_t *) NULL)); } diff --git a/otherlibs/unix/times.c b/otherlibs/unix/times.c index c108cbfde..9952cb7ac 100644 --- a/otherlibs/unix/times.c +++ b/otherlibs/unix/times.c @@ -29,7 +29,7 @@ #endif #endif -CAMLprim value unix_times(void) +CAMLprim value unix_times(value unit) { value res; struct tms buffer; diff --git a/otherlibs/unix/truncate.c b/otherlibs/unix/truncate.c index 009d3c0e5..b7b7a83d4 100644 --- a/otherlibs/unix/truncate.c +++ b/otherlibs/unix/truncate.c @@ -15,6 +15,7 @@ #include <sys/types.h> #include <mlvalues.h> +#include <fail.h> #include <io.h> #include "unixsupport.h" #ifdef HAS_UNISTD diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml index a21316b36..8433376fe 100644 --- a/otherlibs/unix/unix.ml +++ b/otherlibs/unix/unix.ml @@ -868,21 +868,25 @@ let find_proc_id fun_name proc = with Not_found -> raise(Unix_error(EBADF, fun_name, "")) +let rec waitpid_non_intr pid = + try waitpid [] pid + with Unix_error (EINTR, _, _) -> waitpid_non_intr pid + let close_process_in inchan = let pid = find_proc_id "close_process_in" (Process_in inchan) in close_in inchan; - snd(waitpid [] pid) + snd(waitpid_non_intr pid) let close_process_out outchan = let pid = find_proc_id "close_process_out" (Process_out outchan) in close_out outchan; - snd(waitpid [] pid) + snd(waitpid_non_intr pid) let close_process (inchan, outchan) = let pid = find_proc_id "close_process" (Process(inchan, outchan)) in close_in inchan; begin try close_out outchan with Sys_error _ -> () end; - snd(waitpid [] pid) + snd(waitpid_non_intr pid) let close_process_full (inchan, outchan, errchan) = let pid = @@ -891,7 +895,7 @@ let close_process_full (inchan, outchan, errchan) = close_in inchan; begin try close_out outchan with Sys_error _ -> () end; close_in errchan; - snd(waitpid [] pid) + snd(waitpid_non_intr pid) (* High-level network functions *) diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli index ee08a2760..ead724eb9 100644 --- a/otherlibs/unix/unix.mli +++ b/otherlibs/unix/unix.mli @@ -705,7 +705,7 @@ type process_times = (** The execution times (CPU times) of a process. *) type tm = - { tm_sec : int; (** Seconds 0..59 *) + { tm_sec : int; (** Seconds 0..60 *) tm_min : int; (** Minutes 0..59 *) tm_hour : int; (** Hours 0..23 *) tm_mday : int; (** Day of month 1..31 *) diff --git a/otherlibs/unix/utimes.c b/otherlibs/unix/utimes.c index 51d34350c..da2913570 100644 --- a/otherlibs/unix/utimes.c +++ b/otherlibs/unix/utimes.c @@ -13,6 +13,7 @@ /* $Id$ */ +#include <fail.h> #include <mlvalues.h> #include "unixsupport.h" diff --git a/otherlibs/unix/wait.c b/otherlibs/unix/wait.c index b660a75e4..5d74b8380 100644 --- a/otherlibs/unix/wait.c +++ b/otherlibs/unix/wait.c @@ -15,6 +15,7 @@ #include <mlvalues.h> #include <alloc.h> +#include <fail.h> #include <memory.h> #include <signals.h> #include "unixsupport.h" @@ -60,7 +61,7 @@ static value alloc_process_status(int pid, int status) return res; } -CAMLprim value unix_wait(void) +CAMLprim value unix_wait(value unit) { int pid, status; @@ -83,11 +84,11 @@ static int wait_flag_table[] = { CAMLprim value unix_waitpid(value flags, value pid_req) { - int pid, status; - + int pid, status, cv_flags; + + cv_flags = convert_flag_list(flags, wait_flag_table); enter_blocking_section(); - pid = waitpid(Int_val(pid_req), &status, - convert_flag_list(flags, wait_flag_table)); + pid = waitpid(Int_val(pid_req), &status, cv_flags); leave_blocking_section(); if (pid == -1) uerror("waitpid", Nothing); return alloc_process_status(pid, status); |