ftruncate.c 747 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * ftruncate() 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_ftruncate64 && !defined __NR_ftruncate
  11. # include <endian.h>
  12. # include <stdint.h>
  13. int ftruncate(int fd, __off_t length)
  14. {
  15. # if __WORDSIZE == 32
  16. # if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
  17. return INLINE_SYSCALL(ftruncate64, 4, fd, 0, OFF_HI_LO(length));
  18. # else
  19. return INLINE_SYSCALL(ftruncate64, 3, fd, OFF_HI_LO(length));
  20. # endif
  21. # else
  22. return ftruncate64(fd, length);
  23. # endif
  24. }
  25. libc_hidden_def(ftruncate);
  26. #else
  27. _syscall2(int, ftruncate, int, fd, __off_t, length)
  28. libc_hidden_def(ftruncate)
  29. #endif