[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sendfile compatibility
From: |
Bruno Haible |
Subject: |
Re: sendfile compatibility |
Date: |
Thu, 27 Jan 2011 20:45:26 +0100 |
User-agent: |
KMail/1.9.9 |
Hello Alan,
> I'm wondering if gnulib is scheduled to provide sendfile compatibility
> using lseek/read/write ?
>
> I know sendfile is a kernel routine, and I'm unsure of whether the file
> pointer needs restoration after the operation or not in a user-space
> replacement.
If gnulib implements such a function, I would suggest to *not* call it
'sendfile' or 'send_file', because various systems implement different
functions with these names:
glibc:
#include <sys/sendfile.h>
ssize_t sendfile (int out_fd, int in_fd, off_t *offset, size_t count);
Doc:
<http://www.kernel.org/doc/man-pages/online/pages/man2/sendfile.2.html>
MacOS X:
#include <sys/socket.h>
int sendfile(int, int, off_t, off_t *, struct sf_hdtr *, int);
Doc:
<http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/sendfile.2.html>
FreeBSD:
#include <sys/socket.h>
int sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int);
Doc:
<http://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2>
AIX:
#include <sys/socket.h>
ssize_t send_file(int *, struct sf_parms *, uint_t);
Doc:
<https://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.commtechref/doc/commtrf2/send_file.htm>
HP-UX:
#include <sys/socket.h>
sbsize_t sendfile (int, int, off_t, bsize_t, const struct iovec *, int);
Doc:
<http://h21007.www2.hp.com/portal/download/files/unprot/LPK/LinuxPortGuide.pdf>
OSF/1:
#include <net/proto_uipc.h>
int sendfile (struct proc *, void *, long *);
Note that the APR (Apache Portable Runtime) library contains a portable wrapper
around each of these methods. See the files
apr-1.4.2/network_io/unix/sendrecv.c
apr-1.4.2/network_io/win32/sendrecv.c
Of course, this is not an invitation to steal code from there ;-)
Bruno