1 /* vi: set sw=4 ts=4: */
2 /*
3 * truncate() for uClibc
4 *
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6 *
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8 */
9
10 #include <sys/syscall.h>
11 #include <unistd.h>
12
13 #if defined(__NR_truncate64) && !defined(__NR_truncate)
14 # include <endian.h>
15 # include <stdint.h>
16
truncate(const char * path,__off_t length)17 int truncate(const char *path, __off_t length)
18 {
19 # if defined __UCLIBC_HAS_LFS
20 return truncate64(path, length);
21 # elif __WORDSIZE == 32
22 # if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
23 return INLINE_SYSCALL(truncate64, 4, path, 0, OFF_HI_LO(length));
24 # else
25 return INLINE_SYSCALL(truncate64, 3, path, OFF_HI_LO(length));
26 # endif
27 # endif
28 }
29 libc_hidden_def(truncate);
30
31 #else
32 _syscall2(int, truncate, const char *, path, __off_t, length)
33 libc_hidden_def(truncate)
34 #endif
35