codekingpro/portable-devtools
114k
1/*-------------------------------------------------------------------------2 *3 * pg_iovec.h4 * Header for vectored I/O functions, to use in place of <sys/uio.h>.5 *6 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group7 * Portions Copyright (c) 1994, Regents of the University of California8 *9 * src/include/port/pg_iovec.h10 *11 *-------------------------------------------------------------------------12 */13#ifndef PG_IOVEC_H14#define PG_IOVEC_H15 16#ifndef WIN3217 18#include <limits.h>19#include <sys/uio.h>20 21#else22 23/* POSIX requires at least 16 as a maximum iovcnt. */24#define IOV_MAX 1625 26/* Define our own POSIX-compatible iovec struct. */27struct iovec28{29 void *iov_base;30 size_t iov_len;31};32 33#endif34 35/* Define a reasonable maximum that is safe to use on the stack. */36#define PG_IOV_MAX Min(IOV_MAX, 32)37 38/*39 * Note that pg_preadv and pg_pwritev have a pg_ prefix as a warning that the40 * Windows implementations have the side-effect of changing the file position.41 */42 43#if HAVE_DECL_PREADV44#define pg_preadv preadv45#else46extern ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset);47#endif48 49#if HAVE_DECL_PWRITEV50#define pg_pwritev pwritev51#else52extern ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset);53#endif54 55#endif /* PG_IOVEC_H */56 