truncate.c 792 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 __WORDSIZE == 32
  17. # if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
  18. return INLINE_SYSCALL(truncate64, 4, path, 0, OFF_HI_LO(length));
  19. # else
  20. return INLINE_SYSCALL(truncate64, 3, path, OFF_HI_LO(length));
  21. # endif
  22. # else
  23. return truncate64(path, length);
  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