| 1 |
|
| 2 | |
| 3 | * sendfile for NOLIBC
|
| 4 | * Copyright (C) 2026 Daniel Palmer <[email protected]>
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 | #include "../nolibc.h"
|
| 9 |
|
| 10 | #ifndef _NOLIBC_SYS_SENDFILE_H
|
| 11 | #define _NOLIBC_SYS_SENDFILE_H
|
| 12 |
|
| 13 | #include "../sys.h"
|
| 14 | #include <linux/unistd.h>
|
| 15 |
|
| 16 | |
| 17 | * ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);
|
| 18 |
|
| 19 |
|
| 20 | static __attribute__((unused))
|
| 21 | ssize_t _sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
|
| 22 | {
|
| 23 | __nolibc_static_assert(sizeof(*offset) == sizeof(__kernel_loff_t));
|
| 24 |
|
| 25 | #ifdef __NR_sendfile64
|
| 26 |
|
| 27 | return __nolibc_syscall4(__NR_sendfile64, out_fd, in_fd, offset, count);
|
| 28 | #else
|
| 29 | __nolibc_static_assert(sizeof(*offset) == sizeof(__kernel_off_t));
|
| 30 |
|
| 31 | return __nolibc_syscall4(__NR_sendfile, out_fd, in_fd, offset, count);
|
| 32 | #endif
|
| 33 | }
|
| 34 |
|
| 35 | static __attribute__((unused))
|
| 36 | ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
|
| 37 | {
|
| 38 | return __sysret(_sys_sendfile(out_fd, in_fd, offset, count));
|
| 39 | }
|
| 40 |
|
| 41 | #endif
|