From f21e1c57a3c01f1623a09cc0507000b4db1b6df4 Mon Sep 17 00:00:00 2001 From: leitner Date: Thu, 8 Jan 2004 17:11:08 +0000 Subject: [PATCH] macos x support --- CHANGES | 2 ++ GNUmakefile | 15 ++++++++++++--- io/io_sendfile.c | 1 + io/iob_send.c | 7 +++++-- trybsdsf.c | 3 +++ trysendfile.c | 4 ++++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 4a62c64..a0aef2c 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,8 @@ remove socket_sendfile now that we have io_sendfile break out alloca #include dependency into havealloca.h support HP-UX sendfile64 (thanks to Rolf Eike Beer) + support Solaris sendfile64 + support MacOS X sendfile (thanks to Bernhard Schmidt) 0.16: add buffer_fromsa (make buffer from stralloc) diff --git a/GNUmakefile b/GNUmakefile index e7f8533..ae33871 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -12,7 +12,7 @@ MAN3DIR=${prefix}/man/man3 LIBS=byte.a fmt.a scan.a str.a uint.a open.a stralloc.a unix.a socket.a \ buffer.a mmap.a taia.a tai.a dns.a case.a mult.a array.a io.a textcode.a -all: t $(LIBS) libowfat.a +all: t $(LIBS) libowfat.a libsocket CC=gcc CFLAGS=-pipe -Wall -O2 -fomit-frame-pointer @@ -130,8 +130,8 @@ CFLAGS+=-I. t.o: iopause.h -t: t.o libowfat.a - $(DIET) $(CC) -g -o $@ t.o libowfat.a +t: t.o libowfat.a libsocket + $(DIET) $(CC) -g -o $@ t.o libowfat.a `cat libsocket` .PHONY: all clean tar install rename clean: @@ -234,6 +234,15 @@ select.h: select.h1 select.h2 trysysel.c if $(DIET) $(CC) $(CFLAGS) -c trysysel.c >/dev/null 2>&1; then cp select.h2 select.h; else cp select.h1 select.h; fi -rm -f trysysel.o +libsocket: trysocket.c + if $(DIET) $(CC) $(CFLAGS) -o trysocket trysocket.c >/dev/null 2>&1; then echo ""; else \ + if $(DIET) $(CC) $(CFLAGS) -o trysocket trysocket.c -lsocket >/dev/null 2>&1; then echo "-lsocket"; else \ + if $(DIET) $(CC) $(CFLAGS) -o trysocket trysocket.c -lsocket -lnsl >/dev/null 2>&1; then echo "-lsocket -lnsl"; \ + fi; fi; fi > blah + if $(DIET) $(CC) $(CFLAGS) -o trysocket trysendfile.c `cat blah`>/dev/null 2>&1; then cat blah; else \ + if $(DIET) $(CC) $(CFLAGS) -o trysocket trysendfile.c -lsendfile `cat blah` >/dev/null 2>&1; then echo "-lsendfile"; cat blah; \ + fi; fi > libsocket + rm -f blah trysocket socket_accept6.o socket_connect6.o socket_local6.o socket_mchopcount6.o \ socket_mcjoin6.o socket_mcleave6.o socket_mcloop6.o socket_recv6.o \ diff --git a/io/io_sendfile.c b/io/io_sendfile.c index a50cb73..97751fa 100644 --- a/io/io_sendfile.c +++ b/io/io_sendfile.c @@ -5,6 +5,7 @@ #include "havesendfile.h" #if defined(HAVE_BSDSENDFILE) +#define SENDFILE 1 #include #include #include diff --git a/io/iob_send.c b/io/iob_send.c index 6f77618..7ed4c91 100644 --- a/io/iob_send.c +++ b/io/iob_send.c @@ -1,3 +1,8 @@ +#include "havebsdsf.h" +#ifdef HAVE_BSDSENDFILE +/* for MacOS X. Yep, they blew it again. */ +#define SENDFILE 1 +#endif #include #include #include @@ -7,7 +12,6 @@ #include #include "havealloca.h" #include "iob_internal.h" -#include "havebsdsf.h" int64 iob_send(int64 s,io_batch* b) { iob_entry* e,* last; @@ -16,7 +20,6 @@ int64 iob_send(int64 s,io_batch* b) { long i; long headers; #ifdef HAVE_BSDSENDFILE -#define SENDFILE 1 long trailers; #endif diff --git a/trybsdsf.c b/trybsdsf.c index 81d226c..27a0529 100644 --- a/trybsdsf.c +++ b/trybsdsf.c @@ -1,3 +1,6 @@ +/* for macos X, don't ask */ +#define SENDFILE 1 + #include #include #include diff --git a/trysendfile.c b/trysendfile.c index 53fd2ac..84b4501 100644 --- a/trysendfile.c +++ b/trysendfile.c @@ -2,6 +2,7 @@ #include #include #include +#include int main() { /* @@ -18,17 +19,20 @@ int main() { 0 /* offset */, 23 /* nbytes */, x, 0); perror("sendfile"); + return 0; } #elif defined (__sun__) && defined(__svr4__) #include #include #include +#include int main() { off_t o; o=0; sendfile(1 /* dest */, 0 /* src */,&o,23 /* nbytes */); perror("sendfile"); + return 0; } #else #error unsupported architecture