tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: sendfile on various systems?

Le 06/07/2014 23:55, Georg Schwarz a écrit :
On Linux, sendfile() looka like this:

ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)

On MacOS X it looks like this:

      sendfile(int fd, int s, off_t offset, off_t *len, struct sf_hdtr *hdtr,
          int flags)

what about other systems?

What's best practice of handling (probably Linux-originated) code that uses 

Have a wrapper that implements sendfile() equivalent functionality (usually mmap + write from userland). Somehow it blows, but the API itself does already with non blocking sockets, so...

Should sendfile support best be disabled in systems other than Linux? (the code 
already has useful #ifdefs included)

I'd say no; FreeBSD has it. For NetBSD I don't know if it brings anything useful besides being a wrapper around mmap + write (due to UVM's page loaning, the only benefit being perhaps that the "loop" is done in kernel).

Regarding prototype I'd say to keep glibc's one around; the original syscall from Linux handled offset with a variable not big enough for large files, and then they introduced sendfile64() to fix the limitation (sigh).

Jean-Yves Migeon

Home | Main Index | Thread Index | Old Index