open64.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <_lfs_64.h>
  7. #include <fcntl.h>
  8. #include <stdarg.h>
  9. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  10. #include <errno.h>
  11. #include <sysdep-cancel.h>
  12. #endif
  13. #ifndef O_LARGEFILE
  14. # define O_LARGEFILE 0100000
  15. #endif
  16. /* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
  17. a third argument is the file protection. */
  18. int open64 (const char *file, int oflag, ...)
  19. {
  20. mode_t mode = 0;
  21. if (oflag & O_CREAT)
  22. {
  23. va_list arg;
  24. va_start (arg, oflag);
  25. mode = va_arg (arg, mode_t);
  26. va_end (arg);
  27. }
  28. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  29. if (SINGLE_THREAD_P)
  30. return INLINE_SYSCALL (open, 3, file, oflag | O_LARGEFILE, mode);
  31. int oldtype = LIBC_CANCEL_ASYNC ();
  32. int result = INLINE_SYSCALL (open, 3, file, oflag | O_LARGEFILE, mode);
  33. LIBC_CANCEL_RESET (oldtype);
  34. return result;
  35. #else
  36. return open(file, oflag | O_LARGEFILE, mode);
  37. #endif
  38. }
  39. #ifndef __LINUXTHREADS_OLD__
  40. libc_hidden_def(open64)
  41. #else
  42. libc_hidden_weak(open64)
  43. strong_alias(open64,__libc_open64)
  44. #endif