16#ifndef PG_WIN32_PORT_H
17#define PG_WIN32_PORT_H
35#define _WINSOCK_DEPRECATED_NO_WARNINGS
42#if !defined(__MINGW64_VERSION_MAJOR) || defined(_MSC_VER)
57#define WIN32_LEAN_AND_MEAN
58#define UMDF_USING_NTSTATUS
73#define fstat microsoft_native_fstat
74#define stat microsoft_native_stat
80#define mkdir(a,b) mkdir(a)
82#define ftruncate(a,b) chsize(a,b)
85#define fsync(fd) _commit(fd)
92#undef HAVE_UNION_SEMUN
93#define HAVE_UNION_SEMUN 1
98#define IPC_PRIVATE 234564
99#define IPC_NOWAIT 2048
152#define WIFEXITED(w) (((w) & 0XFFFFFF00) == 0)
153#define WIFSIGNALED(w) (!WIFEXITED(w))
154#define WEXITSTATUS(w) (w)
155#define WTERMSIG(w) (w)
157#define sigmask(sig) ( 1 << ((sig)-1) )
163#define SIG_DFL ((pqsigfunc)0)
164#define SIG_ERR ((pqsigfunc)-1)
165#define SIG_IGN ((pqsigfunc)1)
207#define pgoff_t __int64
210extern int _pgfseeko64(FILE *stream,
pgoff_t offset,
int origin);
211extern pgoff_t _pgftello64(FILE *stream);
212#define fseeko(stream, offset, origin) _pgfseeko64(stream, offset, origin)
213#define ftello(stream) _pgftello64(stream)
216#define fseeko(stream, offset, origin) fseeko64(stream, offset, origin)
219#define ftello(stream) ftello64(stream)
232extern int pgsymlink(
const char *oldpath,
const char *newpath);
235#define symlink(oldpath, newpath) pgsymlink(oldpath, newpath)
236#define readlink(path, buf, size) pgreadlink(path, buf, size)
243#ifndef PLPERL_HAVE_UID_GID
283#define fstat(fileno, sb) _pgfstat64(fileno, sb)
284#define stat(path, sb) _pgstat64(path, sb)
285#define lstat(path, sb) _pglstat64(path, sb)
289#define S_IRUSR _S_IREAD
292#define S_IWUSR _S_IWRITE
295#define S_IXUSR _S_IEXEC
298#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
325#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
328#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
338#error "S_ISLNK is already defined"
341#error "S_IFLNK is already defined"
343#define S_IFLNK S_IFCHR
344#define S_ISLNK(m) (((m) & S_IFLNK) == S_IFLNK)
352#define O_DSYNC 0x0080
372#define EAGAIN WSAEWOULDBLOCK
374#define EINTR WSAEINTR
376#define EMSGSIZE WSAEMSGSIZE
378#define EAFNOSUPPORT WSAEAFNOSUPPORT
380#define EWOULDBLOCK WSAEWOULDBLOCK
382#define ECONNABORTED WSAECONNABORTED
384#define ECONNRESET WSAECONNRESET
386#define EINPROGRESS WSAEINPROGRESS
388#define EISCONN WSAEISCONN
390#define ENOBUFS WSAENOBUFS
391#undef EPROTONOSUPPORT
392#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
394#define ECONNREFUSED WSAECONNREFUSED
396#define ENOTSOCK WSAENOTSOCK
398#define EOPNOTSUPP WSAEOPNOTSUPP
400#define EADDRINUSE WSAEADDRINUSE
402#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
404#define EHOSTDOWN WSAEHOSTDOWN
406#define EHOSTUNREACH WSAEHOSTUNREACH
408#define ENETDOWN WSAENETDOWN
410#define ENETRESET WSAENETRESET
412#define ENETUNREACH WSAENETUNREACH
414#define ENOTCONN WSAENOTCONN
416#define ETIMEDOUT WSAETIMEDOUT
421#define strtok_r strtok_s
432#define gmtime_r(clock, result) (gmtime_s(result, clock) ? NULL : (result))
433#define localtime_r(clock, result) (localtime_s(result, clock) ? NULL : (result))
442#define locale_t _locale_t
443#define tolower_l _tolower_l
444#define toupper_l _toupper_l
445#define towlower_l _towlower_l
446#define towupper_l _towupper_l
447#define isdigit_l _isdigit_l
448#define iswdigit_l _iswdigit_l
449#define isalpha_l _isalpha_l
450#define iswalpha_l _iswalpha_l
451#define isalnum_l _isalnum_l
452#define iswalnum_l _iswalnum_l
453#define isupper_l _isupper_l
454#define iswupper_l _iswupper_l
455#define islower_l _islower_l
456#define iswlower_l _iswlower_l
457#define isgraph_l _isgraph_l
458#define iswgraph_l _iswgraph_l
459#define isprint_l _isprint_l
460#define iswprint_l _iswprint_l
461#define ispunct_l _ispunct_l
462#define iswpunct_l _iswpunct_l
463#define isspace_l _isspace_l
464#define iswspace_l _iswspace_l
465#define strcoll_l _strcoll_l
466#define strxfrm_l _strxfrm_l
467#define wcscoll_l _wcscoll_l
475#if defined(setlocale)
485#define setlocale(a,b) pgwin32_setlocale(a,b)
494#define UNBLOCKED_SIGNAL_QUEUE() (pg_signal_queue & ~pg_signal_mask)
495#define PG_SIGNAL_COUNT 32
503#define kill(pid,sig) pgkill(pid,sig)
508#define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
509#define bind(s, addr, addrlen) pgwin32_bind(s, addr, addrlen)
510#define listen(s, backlog) pgwin32_listen(s, backlog)
511#define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
512#define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
513#define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
514#define recv(s, buf, len, flags) pgwin32_recv(s, buf, len, flags)
515#define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
518extern int pgwin32_bind(SOCKET s,
struct sockaddr *addr,
int addrlen);
520extern SOCKET
pgwin32_accept(SOCKET s,
struct sockaddr *addr,
int *addrlen);
522extern int pgwin32_select(
int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
const struct timeval *timeout);
538extern void *
dlopen(
const char *file,
int mode);
539extern void *
dlsym(
void *handle,
const char *
symbol);
540extern int dlclose(
void *handle);
554#define putenv(x) pgwin32_putenv(x)
555#define setenv(x,y,z) pgwin32_setenv(x,y,z)
556#define unsetenv(x) pgwin32_unsetenv(x)
571typedef __int64 ssize_t;
574typedef unsigned short mode_t;
582#if defined(__MINGW32__) || defined(__MINGW64__)
593#define HAVE_BUGGY_STRTOF 1
597extern ssize_t
pg_pread(
int fd,
void *
buf,
size_t nbyte, off_t offset);
600extern ssize_t
pg_pwrite(
int fd,
const void *
buf,
size_t nbyte, off_t offset);
static PgChecksumMode mode
static int fd(const char *x, int i)
static pg_noinline void Size size
struct timeval it_interval
static void overwrite(PGconn *conn, Oid lobjId, int start, int len)
HANDLE pgwin32_create_signal_listener(pid_t pid)
void * dlopen(const char *file, int mode)
int pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout)
void pg_queue_signal(int signum)
int pgwin32_send(SOCKET s, const void *buf, int len, int flags)
PGDLLIMPORT int pgwin32_noblock
int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout)
SOCKET pgwin32_socket(int af, int type, int protocol)
int _pgfstat64(int fileno, struct stat *buf)
int pgwin32_connect(SOCKET s, const struct sockaddr *name, int namelen)
void * dlsym(void *handle, const char *symbol)
int pgwin32_recv(SOCKET s, char *buf, int len, int flags)
void pgwin32_dispatch_queued_signals(void)
void pgwin32_install_crashdump_handler(void)
BOOL AddUserToTokenDacl(HANDLE hToken)
int _pgstat64(const char *name, struct stat *buf)
int pgwin32_unsetenv(const char *name)
SOCKET pgwin32_accept(SOCKET s, struct sockaddr *addr, int *addrlen)
PGDLLIMPORT volatile int pg_signal_queue
ssize_t pg_pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
void _dosmaperr(unsigned long)
int pgreadlink(const char *path, char *buf, size_t size)
DWORD pgwin32_get_file_type(HANDLE hFile)
PGDLLIMPORT HANDLE pgwin32_initial_signal_pipe
int pgwin32_bind(SOCKET s, struct sockaddr *addr, int addrlen)
ssize_t pg_pread(int fd, void *buf, size_t nbyte, off_t offset)
PGDLLIMPORT int pg_signal_mask
int pgwin32_putenv(const char *)
int pgwin32_is_service(void)
int pgwin32_ReserveSharedMemoryRegion(HANDLE)
int pgsymlink(const char *oldpath, const char *newpath)
int _pglstat64(const char *name, struct stat *buf)
PGDLLIMPORT HANDLE pgwin32_signal_event
void pgwin32_signal_initialize(void)
int pgwin32_is_admin(void)
int pgwin32_setenv(const char *name, const char *value, int overwrite)
int pgkill(int pid, int sig)
char * pgwin32_setlocale(int category, const char *locale)
int dlclose(void *handle)
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
int pgwin32_listen(SOCKET s, int backlog)
int gettimeofday(struct timeval *tp, void *tzp)