summaryrefslogtreecommitdiffstats
path: root/otherlibs/unix
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/unix')
-rw-r--r--otherlibs/unix/.depend1
-rw-r--r--otherlibs/unix/Makefile2
-rw-r--r--otherlibs/unix/chmod.c2
-rw-r--r--otherlibs/unix/fchmod.c2
-rw-r--r--otherlibs/unix/getgroups.c2
-rw-r--r--otherlibs/unix/gethost.c3
-rw-r--r--otherlibs/unix/ioctl.c33
-rw-r--r--otherlibs/unix/listen.c2
-rw-r--r--otherlibs/unix/mkdir.c2
-rw-r--r--otherlibs/unix/mkfifo.c2
-rw-r--r--otherlibs/unix/read.c1
-rw-r--r--otherlibs/unix/rename.c1
-rw-r--r--otherlibs/unix/sendrecv.c1
-rw-r--r--otherlibs/unix/shutdown.c2
-rw-r--r--otherlibs/unix/socketaddr.c1
-rw-r--r--otherlibs/unix/socketpair.c2
-rw-r--r--otherlibs/unix/termios.c4
-rw-r--r--otherlibs/unix/times.c1
-rw-r--r--otherlibs/unix/umask.c2
-rw-r--r--otherlibs/unix/unix.ml2
-rw-r--r--otherlibs/unix/unix.mli12
-rw-r--r--otherlibs/unix/unixsupport.h8
-rw-r--r--otherlibs/unix/wait.c15
-rw-r--r--otherlibs/unix/write.c1
24 files changed, 43 insertions, 61 deletions
diff --git a/otherlibs/unix/.depend b/otherlibs/unix/.depend
index 1975d6546..8bc3e3894 100644
--- a/otherlibs/unix/.depend
+++ b/otherlibs/unix/.depend
@@ -44,7 +44,6 @@ getsockname.o: getsockname.c unixsupport.h socketaddr.h
gettimeofday.o: gettimeofday.c unixsupport.h
getuid.o: getuid.c unixsupport.h
gmtime.o: gmtime.c unixsupport.h
-ioctl.o: ioctl.c unixsupport.h
itimer.o: itimer.c unixsupport.h
kill.o: kill.c unixsupport.h
link.o: link.c unixsupport.h
diff --git a/otherlibs/unix/Makefile b/otherlibs/unix/Makefile
index a2d95d609..165813627 100644
--- a/otherlibs/unix/Makefile
+++ b/otherlibs/unix/Makefile
@@ -15,7 +15,7 @@ OBJS=accept.o access.o addrofstr.o alarm.o bind.o chdir.o chmod.o \
geteuid.o getgid.o getgr.o getgroups.o gethost.o gethostname.o \
getlogin.o getpeername.o getpid.o getppid.o getproto.o getpw.o \
gettimeofday.o getserv.o getsockname.o getuid.o \
- gmtime.o ioctl.o itimer.o kill.o link.o listen.o lockf.o lseek.o mkdir.o \
+ gmtime.o itimer.o kill.o link.o listen.o lockf.o lseek.o mkdir.o \
mkfifo.o nice.o open.o opendir.o pause.o pipe.o read.o \
readdir.o readlink.o rename.o rewinddir.o rmdir.o select.o sendrecv.o \
setgid.o setsid.o setuid.o shutdown.o sleep.o socket.o socketaddr.o \
diff --git a/otherlibs/unix/chmod.c b/otherlibs/unix/chmod.c
index 1dbfc3702..557e20a60 100644
--- a/otherlibs/unix/chmod.c
+++ b/otherlibs/unix/chmod.c
@@ -11,6 +11,8 @@
/* $Id$ */
+#include <sys/types.h>
+#include <sys/stat.h>
#include <mlvalues.h>
#include "unixsupport.h"
diff --git a/otherlibs/unix/fchmod.c b/otherlibs/unix/fchmod.c
index 22da62215..07c608c44 100644
--- a/otherlibs/unix/fchmod.c
+++ b/otherlibs/unix/fchmod.c
@@ -11,6 +11,8 @@
/* $Id$ */
+#include <sys/types.h>
+#include <sys/stat.h>
#include <mlvalues.h>
#include "unixsupport.h"
diff --git a/otherlibs/unix/getgroups.c b/otherlibs/unix/getgroups.c
index 3fe4bef24..4c9b2d3fc 100644
--- a/otherlibs/unix/getgroups.c
+++ b/otherlibs/unix/getgroups.c
@@ -22,7 +22,7 @@
value unix_getgroups() /* ML */
{
- int gidset[NGROUPS];
+ gid_t gidset[NGROUPS];
int n;
value res;
int i;
diff --git a/otherlibs/unix/gethost.c b/otherlibs/unix/gethost.c
index 4c141e8a6..5eb8f6790 100644
--- a/otherlibs/unix/gethost.c
+++ b/otherlibs/unix/gethost.c
@@ -11,6 +11,7 @@
/* $Id$ */
+#include <string.h>
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
@@ -44,7 +45,7 @@ static value alloc_host_entry(entry)
value addr_list = Val_unit, addr = Val_unit;
Begin_roots4 (name, aliases, addr_list, addr);
- name = copy_string(entry->h_name);
+ name = copy_string((char *)(entry->h_name));
aliases = copy_string_array(entry->h_aliases);
entry_h_length = entry->h_length;
#ifdef h_addr
diff --git a/otherlibs/unix/ioctl.c b/otherlibs/unix/ioctl.c
deleted file mode 100644
index e2fd9ed28..000000000
--- a/otherlibs/unix/ioctl.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/***********************************************************************/
-/* */
-/* Objective Caml */
-/* */
-/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
-/* */
-/* Copyright 1996 Institut National de Recherche en Informatique et */
-/* Automatique. Distributed only by permission. */
-/* */
-/***********************************************************************/
-
-/* $Id$ */
-
-#include <mlvalues.h>
-#include "unixsupport.h"
-
-value unix_ioctl_int(fd, request, arg)
- value fd, request, arg;
-{
- int retcode;
- retcode = ioctl(Int_val(fd), Int_val(request), (char *) Long_val(arg));
- if (retcode == -1) uerror("ioctl_int", Nothing);
- return Val_int(retcode);
-}
-
-value unix_ioctl_ptr(fd, request, arg)
- value fd, request, arg;
-{
- int retcode;
- retcode = ioctl(Int_val(fd), Int_val(request), String_val(arg));
- if (retcode == -1) uerror("ioctl_ptr", Nothing);
- return Val_int(retcode);
-}
diff --git a/otherlibs/unix/listen.c b/otherlibs/unix/listen.c
index 969c2b844..f8db79407 100644
--- a/otherlibs/unix/listen.c
+++ b/otherlibs/unix/listen.c
@@ -16,6 +16,8 @@
#ifdef HAS_SOCKETS
+#include <sys/socket.h>
+
value unix_listen(sock, backlog)
value sock, backlog;
{
diff --git a/otherlibs/unix/mkdir.c b/otherlibs/unix/mkdir.c
index 08bf1f0ae..330d366ff 100644
--- a/otherlibs/unix/mkdir.c
+++ b/otherlibs/unix/mkdir.c
@@ -11,6 +11,8 @@
/* $Id$ */
+#include <sys/types.h>
+#include <sys/stat.h>
#include <mlvalues.h>
#include "unixsupport.h"
diff --git a/otherlibs/unix/mkfifo.c b/otherlibs/unix/mkfifo.c
index d53c3ccb7..f187baf8c 100644
--- a/otherlibs/unix/mkfifo.c
+++ b/otherlibs/unix/mkfifo.c
@@ -11,6 +11,8 @@
/* $Id$ */
+#include <sys/types.h>
+#include <sys/stat.h>
#include <mlvalues.h>
#include "unixsupport.h"
diff --git a/otherlibs/unix/read.c b/otherlibs/unix/read.c
index c22c426bf..17ef9109c 100644
--- a/otherlibs/unix/read.c
+++ b/otherlibs/unix/read.c
@@ -11,6 +11,7 @@
/* $Id$ */
+#include <string.h>
#include <mlvalues.h>
#include <memory.h>
#include <signals.h>
diff --git a/otherlibs/unix/rename.c b/otherlibs/unix/rename.c
index 5bc2425be..5a1e32f16 100644
--- a/otherlibs/unix/rename.c
+++ b/otherlibs/unix/rename.c
@@ -11,6 +11,7 @@
/* $Id$ */
+#include <stdio.h>
#include <mlvalues.h>
#include "unixsupport.h"
diff --git a/otherlibs/unix/sendrecv.c b/otherlibs/unix/sendrecv.c
index 1b0b2d210..a729472c6 100644
--- a/otherlibs/unix/sendrecv.c
+++ b/otherlibs/unix/sendrecv.c
@@ -11,6 +11,7 @@
/* $Id$ */
+#include <string.h>
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
diff --git a/otherlibs/unix/shutdown.c b/otherlibs/unix/shutdown.c
index f0750cf7e..96098b7c5 100644
--- a/otherlibs/unix/shutdown.c
+++ b/otherlibs/unix/shutdown.c
@@ -16,6 +16,8 @@
#ifdef HAS_SOCKETS
+#include <sys/socket.h>
+
static int shutdown_command_table[] = {
0, 1, 2
};
diff --git a/otherlibs/unix/socketaddr.c b/otherlibs/unix/socketaddr.c
index 349c5082f..3ef205be1 100644
--- a/otherlibs/unix/socketaddr.c
+++ b/otherlibs/unix/socketaddr.c
@@ -11,6 +11,7 @@
/* $Id$ */
+#include <string.h>
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
diff --git a/otherlibs/unix/socketpair.c b/otherlibs/unix/socketpair.c
index 655667c4e..67dec4ee1 100644
--- a/otherlibs/unix/socketpair.c
+++ b/otherlibs/unix/socketpair.c
@@ -17,6 +17,8 @@
#ifdef HAS_SOCKETS
+#include <sys/socket.h>
+
extern int socket_domain_table[], socket_type_table[];
value unix_socketpair(domain, type, proto) /* ML */
diff --git a/otherlibs/unix/termios.c b/otherlibs/unix/termios.c
index 0e04281c8..7153fca17 100644
--- a/otherlibs/unix/termios.c
+++ b/otherlibs/unix/termios.c
@@ -144,7 +144,7 @@ static void encode_terminal_status(dst)
break; }
case Speed:
{ int which = *pc++;
- speed_t speed;
+ speed_t speed = 0;
switch (which) {
case Output:
speed = cfgetospeed(&terminal_status); break;
@@ -198,7 +198,7 @@ static void decode_terminal_status(src)
case Speed:
{ int which = *pc++;
int baud = Int_val(*src);
- int res;
+ int res = 0;
for (i = 0; i < NSPEEDS; i++) {
if (baud == speedtable[i].baud) {
switch (which) {
diff --git a/otherlibs/unix/times.c b/otherlibs/unix/times.c
index 7b5e73aa6..4f9cc074b 100644
--- a/otherlibs/unix/times.c
+++ b/otherlibs/unix/times.c
@@ -31,7 +31,6 @@ value unix_times_bytecode() /* ML */
{
value res;
struct tms buffer;
- int i;
value u = Val_unit, s = Val_unit, cu = Val_unit, cs = Val_unit;
Begin_roots4 (u, s, cu, cs);
diff --git a/otherlibs/unix/umask.c b/otherlibs/unix/umask.c
index 5cd445d62..4c19cba04 100644
--- a/otherlibs/unix/umask.c
+++ b/otherlibs/unix/umask.c
@@ -11,6 +11,8 @@
/* $Id$ */
+#include <sys/types.h>
+#include <sys/stat.h>
#include <mlvalues.h>
#include "unixsupport.h"
diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml
index 018de678a..d065548c3 100644
--- a/otherlibs/unix/unix.ml
+++ b/otherlibs/unix/unix.ml
@@ -242,8 +242,6 @@ external pipe : unit -> file_descr * file_descr = "unix_pipe"
external symlink : string -> string -> unit = "unix_symlink"
external readlink : string -> string = "unix_readlink"
external mkfifo : string -> file_perm -> unit = "unix_mkfifo"
-external ioctl_int : file_descr -> int -> int -> int = "unix_ioctl_int"
-external ioctl_ptr : file_descr -> int -> string -> int = "unix_ioctl_ptr"
external select :
file_descr list -> file_descr list -> file_descr list -> float ->
file_descr list * file_descr list * file_descr list = "unix_select"
diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli
index dce5ee185..4f5804739 100644
--- a/otherlibs/unix/unix.mli
+++ b/otherlibs/unix/unix.mli
@@ -442,18 +442,6 @@ external readlink : string -> string = "unix_readlink"
(* Read the contents of a link. *)
-(*** Special files *)
-
-external ioctl_int : file_descr -> int -> int -> int = "unix_ioctl_int"
- (* Interface to [ioctl] in the case where the argument is an
- integer. The first integer argument is the command code;
- the second is the integer parameter. *)
-external ioctl_ptr : file_descr -> int -> string -> int = "unix_ioctl_ptr"
- (* Interface to [ioctl] in the case where the argument is a pointer.
- The integer argument is the command code. A pointer to the string
- argument is passed as argument to the command. *)
-
-
(*** Polling *)
external select :
diff --git a/otherlibs/unix/unixsupport.h b/otherlibs/unix/unixsupport.h
index 51e425d2d..c8b7e1e03 100644
--- a/otherlibs/unix/unixsupport.h
+++ b/otherlibs/unix/unixsupport.h
@@ -11,9 +11,13 @@
/* $Id$ */
+#ifdef HAS_UNISTD
+#include <unistd.h>
+#endif
+
#define Nothing ((value) 0)
-extern void unix_error P((int errcode, char * cmdname, value arg));
-extern void uerror P((char * cmdname, value arg));
+extern void unix_error P((int errcode, char * cmdname, value arg)) Noreturn;
+extern void uerror P((char * cmdname, value arg)) Noreturn;
#define UNIX_BUFFER_SIZE 16384
diff --git a/otherlibs/unix/wait.c b/otherlibs/unix/wait.c
index fbc24a9d6..78ef7621e 100644
--- a/otherlibs/unix/wait.c
+++ b/otherlibs/unix/wait.c
@@ -22,28 +22,33 @@
#if !(defined(WIFEXITED) && defined(WEXITSTATUS) && defined(WIFSTOPPED) && \
defined(WSTOPSIG) && defined(WTERMSIG))
-#define WIFEXITED(status) ((status) & 0xFF == 0)
+/* Assume old-style V7 status word */
+#define WIFEXITED(status) (((status) & 0xFF) == 0)
#define WEXITSTATUS(status) (((status) >> 8) & 0xFF)
-#define WIFSTOPPED(status) ((status) & 0xFF == 0xFF)
+#define WIFSTOPPED(status) (((status) & 0xFF) == 0xFF)
#define WSTOPSIG(status) (((status) >> 8) & 0xFF)
#define WTERMSIG(status) ((status) & 0x3F)
#endif
+#define TAG_WEXITED 0
+#define TAG_WSIGNALED 1
+#define TAG_WSTOPPED 2
+
static value alloc_process_status(pid, status)
int pid, status;
{
value st, res;
if (WIFEXITED(status)) {
- st = alloc(1, 0);
+ st = alloc(1, TAG_WEXITED);
Field(st, 0) = Val_int(WEXITSTATUS(status));
}
else if (WIFSTOPPED(status)) {
- st = alloc(1, 2);
+ st = alloc(1, TAG_WSTOPPED);
Field(st, 0) = Val_int(WSTOPSIG(status));
}
else {
- st = alloc(1, 1);
+ st = alloc(1, TAG_WSIGNALED);
Field(st, 0) = Val_int(WTERMSIG(status));
}
Begin_root (st);
diff --git a/otherlibs/unix/write.c b/otherlibs/unix/write.c
index aae03aaae..83de1fa08 100644
--- a/otherlibs/unix/write.c
+++ b/otherlibs/unix/write.c
@@ -12,6 +12,7 @@
/* $Id$ */
#include <errno.h>
+#include <string.h>
#include <mlvalues.h>
#include <memory.h>
#include <signals.h>