pread_write.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include <sys/syscall.h>
  8. #include <unistd.h>
  9. #include <endian.h>
  10. #include <sgidefs.h>
  11. #ifdef __NR_pread64
  12. # ifdef __NR_pread
  13. # error "__NR_pread and __NR_pread64 both defined???"
  14. # endif
  15. # define __NR_pread __NR_pread64
  16. #endif
  17. #ifdef __NR_pread
  18. # if _MIPS_SIM == _MIPS_SIM_ABI64 /* glibc uses it for N32 as well */
  19. # define __NR___syscall_pread __NR_pread
  20. static _syscall4(ssize_t, __syscall_pread, int, fd, void *, buf, size_t, count, off_t, offset)
  21. # define MY_PREAD(fd, buf, count, offset) \
  22. __syscall_pread(fd, buf, count, offset)
  23. # define MY_PREAD64(fd, buf, count, offset) \
  24. __syscall_pread(fd, buf, count, offset)
  25. # else /* O32 || N32 */
  26. # define __NR___syscall_pread __NR_pread
  27. static _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf,
  28. size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
  29. # define MY_PREAD(fd, buf, count, offset) \
  30. __syscall_pread(fd, buf, count, 0, OFF_HI_LO(offset))
  31. # define MY_PREAD64(fd, buf, count, offset) \
  32. __syscall_pread(fd, buf, count, 0, OFF64_HI_LO(offset))
  33. # endif
  34. #endif
  35. #ifdef __NR_pwrite64
  36. # ifdef __NR_pwrite
  37. # error "__NR_pwrite and __NR_pwrite64 both defined???"
  38. # endif
  39. # define __NR_pwrite __NR_pwrite64
  40. #endif
  41. #ifdef __NR_pwrite
  42. # if _MIPS_SIM == _MIPS_SIM_ABI64 /* glibc uses it for N32 as well */
  43. # define __NR___syscall_pwrite __NR_pwrite
  44. static _syscall4(ssize_t, __syscall_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset)
  45. # define MY_PWRITE(fd, buf, count, offset) \
  46. __syscall_pwrite(fd, buf, count, offset)
  47. # define MY_PWRITE64(fd, buf, count, offset) \
  48. __syscall_pwrite(fd, buf, count, offset)
  49. # else /* O32 || N32 */
  50. # define __NR___syscall_pwrite __NR_pwrite
  51. static _syscall6(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
  52. size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo)
  53. # define MY_PWRITE(fd, buf, count, offset) \
  54. __syscall_pwrite(fd, buf, count, 0, OFF_HI_LO(offset))
  55. # define MY_PWRITE64(fd, buf, count, offset) \
  56. __syscall_pwrite(fd, buf, count, 0, OFF64_HI_LO(offset))
  57. # endif
  58. #endif
  59. #include "../common/pread_write.c"