truncate.c 767 B

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