__syscall_fcntl.c 1022 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * __syscall_fcntl() for uClibc
  4. *
  5. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  6. *
  7. * GNU Library General Public License (LGPL) version 2 or later.
  8. */
  9. #include "syscalls.h"
  10. #include <stdarg.h>
  11. #include <fcntl.h>
  12. #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
  13. extern int __libc_fcntl64(int fd, int cmd, long arg);
  14. #endif
  15. #define __NR___syscall_fcntl __NR_fcntl
  16. static inline
  17. _syscall3(int, __syscall_fcntl, int, fd, int, cmd, long, arg);
  18. int __libc_fcntl(int fd, int cmd, ...)
  19. {
  20. long arg;
  21. va_list list;
  22. va_start(list, cmd);
  23. arg = va_arg(list, long);
  24. va_end(list);
  25. if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
  26. #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
  27. return __libc_fcntl64(fd, cmd, arg);
  28. #else
  29. __set_errno(ENOSYS);
  30. return -1;
  31. #endif
  32. }
  33. return (__syscall_fcntl(fd, cmd, arg));
  34. }
  35. weak_alias(__libc_fcntl, fcntl);
  36. #if ! defined __NR_fcntl64 && defined __UCLIBC_HAS_LFS__
  37. weak_alias(__libc_fcntl, fcntl64);
  38. #endif