(foreign-declare " #include #include #include #include ") (define %sendfile-implementation (foreign-lambda* ssize_t ((integer src) (integer dst) (ssize_t offset) (size_t to_send)) " off_t res = 0; if(sendfile(src,dst,offset,to_send,NULL,&res,0) < 0) { if(errno == EAGAIN || errno == EINTR) { C_return(res == 0 ? -2 : offset + res); }else{ C_return(-1); } } C_return(offset + res); "))