truncate.c 817 B

12345678910111213141516171819202122232425262728293031323334
  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. #include <sys/syscall.h>
  10. #include <unistd.h>
  11. #if defined(__NR_truncate64) && !defined(__NR_truncate)
  12. # include <endian.h>
  13. # include <stdint.h>
  14. int truncate(const char *path, __off_t length)
  15. {
  16. # if defined __UCLIBC_HAS_LFS
  17. return truncate64(path, length);
  18. # elif __WORDSIZE == 32
  19. # if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
  20. return INLINE_SYSCALL(truncate64, 4, path, 0, OFF_HI_LO(length));
  21. # else
  22. return INLINE_SYSCALL(truncate64, 3, path, OFF_HI_LO(length));
  23. # endif
  24. # endif
  25. }
  26. libc_hidden_def(truncate);
  27. #else
  28. _syscall2(int, truncate, const char *, path, __off_t, length)
  29. libc_hidden_def(truncate)
  30. #endif