libc: split multi-source epoll.c
[uclibc-ng.git] / libc / sysdeps / linux / common / posix_fallocate.c
blob9aaa6ce154b4c65acb4c1f9d8804f5bcd00ff226
1 /* vi: set sw=4 ts=4: */
2 /*
3 * posix_fallocate() for uClibc
4 * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
6 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
8 * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
9 */
11 #include <sys/syscall.h>
12 #include <fcntl.h>
13 #include <bits/kernel-features.h>
14 #include <stdint.h>
16 #if defined __NR_fallocate
17 int posix_fallocate(int fd, __off_t offset, __off_t len)
19 int ret;
21 # if __WORDSIZE == 32
22 uint32_t off_low = offset;
23 uint32_t len_low = len;
24 /* may assert that these >>31 are 0 */
25 uint32_t zero = 0;
26 INTERNAL_SYSCALL_DECL(err);
27 ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, 0,
28 __LONG_LONG_PAIR (zero, off_low),
29 __LONG_LONG_PAIR (zero, len_low)));
30 # elif __WORDSIZE == 64
31 INTERNAL_SYSCALL_DECL(err);
32 ret = (int) (INTERNAL_SYSCALL(fallocate, err, 4, fd, 0, offset, len));
33 # else
34 # error your machine is neither 32 bit or 64 bit ... it must be magical
35 #endif
36 if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err)))
37 return INTERNAL_SYSCALL_ERRNO (ret, err);
38 return 0;
40 # if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
41 strong_alias(posix_fallocate,posix_fallocate64)
42 # endif
43 #endif