ftruncate.c 670 B

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