Browse Source

support HP-UX sendfile (thanks Rolf Eike Beer)

master
Felix von Leitner 18 years ago
parent
commit
d8c2458342
  1. 1
      CHANGES
  2. 12
      GNUmakefile
  3. 14
      io/io_sendfile.c
  4. 24
      trysendfile.c

1
CHANGES

@ -20,6 +20,7 @@
apending 0 bytes to an empty array would fail it
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)
0.16:
add buffer_fromsa (make buffer from stralloc)

12
GNUmakefile

@ -80,7 +80,7 @@ $(DNS_OBJS): dns.h stralloc.h taia.h tai.h uint64.h iopause.h
$(CASE_OBJS): case.h
$(ARRAY_OBJS): uint64.h array.h
$(MULT_OBJS): uint64.h uint32.h uint16.h safemult.h
$(IO_OBJS): uint64.h array.h io.h io_internal.h taia.h tai.h haveepoll.h havekqueue.h havesigio.h havebsdsf.h havedevpoll.h
$(IO_OBJS): uint64.h array.h io.h io_internal.h taia.h tai.h haveepoll.h havekqueue.h havesigio.h havebsdsf.h havedevpoll.h havesendfile.h
iob_addbuf.o iob_addfile.o iob_new.o iob_reset.o iob_send.o: iob_internal.h iob.h
@ -137,11 +137,12 @@ t: t.o libowfat.a
clean:
rm -f *.o *.a *.da *.bbg *.bb core t haveip6.h haven2i.h \
havesl.h haveinline.h iopause.h select.h havekqueue.h haveepoll.h \
libepoll havesigio.h havebsdsf.h havescope.h havedevpoll.h Makefile dep
libepoll havesigio.h havebsdsf.h havesendfile.h havescope.h havedevpoll.h \
Makefile dep
INCLUDES=buffer.h byte.h fmt.h ip4.h ip6.h mmap.h scan.h socket.h str.h stralloc.h \
uint16.h uint32.h uint64.h open.h textcode.h tai.h taia.h dns.h iopause.h case.h \
openreadclose.h readclose.h ndelay.h array.h io.h safemult.h iob.h
openreadclose.h readclose.h ndelay.h array.h io.h safemult.h iob.h havealloca.h
install: libowfat.a
install -d $(INCLUDEDIR) $(MAN3DIR) $(LIBDIR)
@ -199,6 +200,11 @@ havebsdsf.h: trybsdsf.c
if $(DIET) $(CC) $(CFLAGS) -c trybsdsf.c >/dev/null 2>&1; then echo "#define HAVE_BSDSENDFILE"; fi > $@
-rm -f trybsdsf.o
havesendfile.h: trysendfile.c
-rm -f $@
if $(DIET) $(CC) $(CFLAGS) -c trysendfile.c >/dev/null 2>&1; then echo "#define HAVE_SENDFILE"; fi > $@
-rm -f trysendfile.o
haveepoll.h: tryepoll.c
-rm -f $@
if $(DIET) $(CC) $(CFLAGS) -o tryepoll tryepoll.c >/dev/null 2>&1; then echo "#define HAVE_EPOLL 1"; else \

14
io/io_sendfile.c

@ -2,6 +2,7 @@
#define _FILE_OFFSET_BITS 64
#include "io_internal.h"
#include "havebsdsf.h"
#include "havesendfile.h"
#if defined(HAVE_BSDSENDFILE)
#include <sys/types.h>
@ -40,6 +41,19 @@ int64 io_sendfile(int64 s,int64 fd,uint64 off,uint64 n) {
return i;
}
#elif defined(HAVE_SENDFILE)
#ifdef __hpux__
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/socket.h>
int64 io_sendfile(int64 out,int64 in,uint64 off,uint64 bytes) {
return sendfile64(out,in,off,bytes,0,0);
}
#endif
#else
#include <unistd.h>

24
trysendfile.c

@ -0,0 +1,24 @@
#ifdef __hpux__
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/socket.h>
int main() {
/*
sbsize_t sendfile(int s, int fd, off_t offset, bsize_t nbytes,
const struct iovec *hdtrl, int flags);
*/
struct iovec x[2];
int fd=open("havesendfile.c",0);
x[0].iov_base="header";
x[0].iov_len=6;
x[1].iov_base="footer";
x[1].iov_len=6;
sendfile(1 /* dest socket */,fd /* src file */,
0 /* offset */, 23 /* nbytes */,
x, 0);
perror("sendfile");
}
#else
#error unsupported architecture
#endif
Loading…
Cancel
Save