__syscall_fcntl.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * __syscall_fcntl() 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 "syscalls.h"
  10. #include <stdarg.h>
  11. #include <fcntl.h>
  12. #include <bits/wordsize.h>
  13. extern __typeof(fcntl) __libc_fcntl;
  14. libc_hidden_proto(__libc_fcntl)
  15. #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
  16. extern __typeof(fcntl64) __libc_fcntl64;
  17. libc_hidden_proto(__libc_fcntl64)
  18. #endif
  19. #define __NR___syscall_fcntl __NR_fcntl
  20. static inline
  21. _syscall3(int, __syscall_fcntl, int, fd, int, cmd, long, arg);
  22. int __libc_fcntl(int fd, int cmd, ...)
  23. {
  24. long arg;
  25. va_list list;
  26. va_start(list, cmd);
  27. arg = va_arg(list, long);
  28. va_end(list);
  29. #if __WORDSIZE == 32
  30. if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
  31. #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
  32. return __libc_fcntl64(fd, cmd, arg);
  33. #else
  34. __set_errno(ENOSYS);
  35. return -1;
  36. #endif
  37. }
  38. #endif
  39. return (__syscall_fcntl(fd, cmd, arg));
  40. }
  41. libc_hidden_def(__libc_fcntl)
  42. libc_hidden_proto(fcntl)
  43. weak_alias(__libc_fcntl,fcntl)
  44. libc_hidden_def(fcntl)
  45. #if ! defined __NR_fcntl64 && defined __UCLIBC_HAS_LFS__
  46. strong_alias(__libc_fcntl,__libc_fcntl64)
  47. libc_hidden_proto(fcntl64)
  48. weak_alias(__libc_fcntl,fcntl64)
  49. libc_hidden_def(fcntl64)
  50. #endif