summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--otherlibs/unix/Makefile27
-rw-r--r--otherlibs/unix/sendrecv.c21
-rw-r--r--otherlibs/unix/unix.ml2
-rw-r--r--otherlibs/unix/unix.mli2
4 files changed, 35 insertions, 17 deletions
diff --git a/otherlibs/unix/Makefile b/otherlibs/unix/Makefile
index 18b7fd4c5..149d61bf0 100644
--- a/otherlibs/unix/Makefile
+++ b/otherlibs/unix/Makefile
@@ -6,6 +6,7 @@ include ../../Makefile.config
CC=$(BYTECC)
CFLAGS=-I../../byterun -O $(BYTECCCOMPOPTS)
CAMLC=../../boot/camlrun ../../boot/camlc -I ../../boot
+CAMLOPT=../../boot/camlrun ../../camlopt -I ../../stdlib
OBJS=accept.o access.o addrofstr.o alarm.o bind.o chdir.o chmod.o \
chown.o chroot.o close.o closedir.o connect.o cst2constr.o cstringv.o \
@@ -22,29 +23,34 @@ OBJS=accept.o access.o addrofstr.o alarm.o bind.o chdir.o chmod.o \
truncate.o umask.o unix.o unlink.o utimes.o wait.o waitpid.o \
write.o
-INTF= unix.cmi
-IMPL= unix.cmo
-LIB= unix.cma
+all: libunix.a unix.cmi unix.cma
-all: libunix.a $(INTF) $(LIB)
+allopt: libunix.a unix.cmi unix.cmxa
libunix.a: $(OBJS)
rm -f libunix.a
ar rc libunix.a $(OBJS)
$(RANLIB) libunix.a
-unix.cma: $(IMPL)
- $(CAMLC) -a -o unix.cma $(IMPL)
+unix.cma: unix.cmo
+ $(CAMLC) -a -o unix.cma unix.cmo
+
+unix.cmxa: unix.cmx
+ $(CAMLOPT) -a -o unix.cmxa unix.cmx
clean:
- rm -f libunix.a *.o *.cm[ioa]
+ rm -f libunix.a *.o *.cm*
install:
cp libunix.a $(LIBDIR)/libunix.a
cd $(LIBDIR); $(RANLIB) libunix.a
- cp $(INTF) $(LIB) $(LIBDIR)
+ cp unix.cmi unix.cma $(LIBDIR)
+
+installopt:
+ cp unix.cmxa unix.a $(LIBDIR)
+ cd $(LIBDIR); $(RANLIB) unix.a
-.SUFFIXES: .ml .mli .cmo .cmi
+.SUFFIXES: .ml .mli .cmo .cmi .cmx
.mli.cmi:
$(CAMLC) -c $(COMPFLAGS) $<
@@ -52,6 +58,9 @@ install:
.ml.cmo:
$(CAMLC) -c $(COMPFLAGS) $<
+.ml.cmx:
+ $(CAMLOPT) -c $(COMPFLAGS) $<
+
depend:
gcc -MM $(CFLAGS) *.c > .depend
../../tools/camldep *.mli *.ml >> .depend
diff --git a/otherlibs/unix/sendrecv.c b/otherlibs/unix/sendrecv.c
index 58a896ecc..dfa54c902 100644
--- a/otherlibs/unix/sendrecv.c
+++ b/otherlibs/unix/sendrecv.c
@@ -72,21 +72,28 @@ value unix_send(sock, buff, ofs, len, flags) /* ML */
return Val_int(ret);
}
-value unix_sendto(argv, argc) /* ML */
- value * argv;
- int argc;
+value unix_sendto_native(sock, buff, ofs, len, flags, dest)
+ value sock, buff, ofs, len, flags, dest;
{
int ret;
- get_sockaddr(argv[5]);
+ get_sockaddr(dest);
enter_blocking_section();
- ret = sendto(Int_val(argv[0]), &Byte(argv[1], Long_val(argv[2])),
- Int_val(argv[3]), convert_flag_list(argv[4], msg_flag_table),
+ ret = sendto(Int_val(sock), &Byte(buff, Long_val(ofs)),
+ Int_val(len), convert_flag_list(flags, msg_flag_table),
&sock_addr.s_gen, sock_addr_len);
leave_blocking_section();
if (ret == -1) uerror("sendto", Nothing);
return Val_int(ret);
}
+value unix_sendto(argv, argc) /* ML */
+ value * argv;
+ int argc;
+{
+ return unix_sendto_native
+ (argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
+}
+
#else
value unix_recv() { invalid_argument("recv not implemented"); }
@@ -95,6 +102,8 @@ value unix_recvfrom() { invalid_argument("recvfrom not implemented"); }
value unix_send() { invalid_argument("send not implemented"); }
+value unix_sendto_native() { invalid_argument("sendto not implemented"); }
+
value unix_sendto() { invalid_argument("sendto not implemented"); }
#endif
diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml
index 2ca2de59e..e6dcfdff0 100644
--- a/otherlibs/unix/unix.ml
+++ b/otherlibs/unix/unix.ml
@@ -356,7 +356,7 @@ external send : file_descr -> string -> int -> int -> msg_flag list -> int
= "unix_send"
external sendto :
file_descr -> string -> int -> int -> msg_flag list -> sockaddr -> int
- = "unix_sendto"
+ = "unix_sendto" "unix_sendto_native"
type host_entry =
{ h_name : string;
diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli
index b1a866f7a..9a5f57bb9 100644
--- a/otherlibs/unix/unix.mli
+++ b/otherlibs/unix/unix.mli
@@ -663,7 +663,7 @@ external send : file_descr -> string -> int -> int -> msg_flag list -> int
= "unix_send"
external sendto :
file_descr -> string -> int -> int -> msg_flag list -> sockaddr -> int
- = "unix_sendto"
+ = "unix_sendto" "unix_sendto_native"
(* Send data over an unconnected socket. *)