pg_iovec.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*-------------------------------------------------------------------------
  2. *
  3. * pg_iovec.h
  4. * Header for vectored I/O functions, to use in place of <sys/uio.h>.
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * src/include/port/pg_iovec.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef PG_IOVEC_H
  14. #define PG_IOVEC_H
  15. #include <limits.h>
  16. #ifdef HAVE_SYS_UIO_H
  17. #include <sys/uio.h>
  18. #endif
  19. /* If <sys/uio.h> is missing, define our own POSIX-compatible iovec struct. */
  20. #ifndef HAVE_SYS_UIO_H
  21. struct iovec
  22. {
  23. void *iov_base;
  24. size_t iov_len;
  25. };
  26. #endif
  27. /*
  28. * If <limits.h> didn't define IOV_MAX, define our own. POSIX requires at
  29. * least 16.
  30. */
  31. #ifndef IOV_MAX
  32. #define IOV_MAX 16
  33. #endif
  34. /* Define a reasonable maximum that is safe to use on the stack. */
  35. #define PG_IOV_MAX Min(IOV_MAX, 32)
  36. #if HAVE_DECL_PREADV
  37. #define pg_preadv preadv
  38. #else
  39. extern ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset);
  40. #endif
  41. #if HAVE_DECL_PWRITEV
  42. #define pg_pwritev pwritev
  43. #else
  44. extern ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset);
  45. #endif
  46. #endif /* PG_IOVEC_H */