PostgreSQL Source Code  git master
win32_port.h File Reference
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <ntstatus.h>
#include <winternl.h>
#include <process.h>
#include <signal.h>
#include <direct.h>
#include <sys/stat.h>
Include dependency graph for win32_port.h:

Go to the source code of this file.

Data Structures

struct  itimerval
 
struct  stat
 

Macros

#define ENABLE_SSPI   1
 
#define _WINSOCKAPI_
 
#define WIN32_LEAN_AND_MEAN
 
#define UMDF_USING_NTSTATUS
 
#define fstat   microsoft_native_fstat
 
#define stat   microsoft_native_stat
 
#define mkdir(a, b)   mkdir(a)
 
#define ftruncate(a, b)   chsize(a,b)
 
#define fsync(fd)   _commit(fd)
 
#define USES_WINSOCK
 
#define HAVE_UNION_SEMUN   1
 
#define IPC_RMID   256
 
#define IPC_CREAT   512
 
#define IPC_EXCL   1024
 
#define IPC_PRIVATE   234564
 
#define IPC_NOWAIT   2048
 
#define IPC_STAT   4096
 
#define EACCESS   2048
 
#define EIDRM   4096
 
#define SETALL   8192
 
#define GETNCNT   16384
 
#define GETVAL   65536
 
#define SETVAL   131072
 
#define GETPID   262144
 
#define WIFEXITED(w)   (((w) & 0XFFFFFF00) == 0)
 
#define WIFSIGNALED(w)   (!WIFEXITED(w))
 
#define WEXITSTATUS(w)   (w)
 
#define WTERMSIG(w)   (w)
 
#define sigmask(sig)   ( 1 << ((sig)-1) )
 
#define SIG_DFL   ((pqsigfunc)0)
 
#define SIG_ERR   ((pqsigfunc)-1)
 
#define SIG_IGN   ((pqsigfunc)1)
 
#define SIGHUP   1
 
#define SIGQUIT   3
 
#define SIGTRAP   5
 
#define SIGABRT   22 /* Set to match W32 value -- not UNIX value */
 
#define SIGKILL   9
 
#define SIGPIPE   13
 
#define SIGALRM   14
 
#define SIGSTOP   17
 
#define SIGTSTP   18
 
#define SIGCONT   19
 
#define SIGCHLD   20
 
#define SIGWINCH   28
 
#define SIGUSR1   30
 
#define SIGUSR2   31
 
#define ITIMER_REAL   0
 
#define pgoff_t   __int64
 
#define fseeko(stream, offset, origin)   fseeko64(stream, offset, origin)
 
#define ftello(stream)   ftello64(stream)
 
#define symlink(oldpath, newpath)   pgsymlink(oldpath, newpath)
 
#define readlink(path, buf, size)   pgreadlink(path, buf, size)
 
#define fstat(fileno, sb)   _pgfstat64(fileno, sb)
 
#define stat(path, sb)   _pgstat64(path, sb)
 
#define lstat(path, sb)   _pglstat64(path, sb)
 
#define S_IRUSR   _S_IREAD
 
#define S_IWUSR   _S_IWRITE
 
#define S_IXUSR   _S_IEXEC
 
#define S_IRWXU   (S_IRUSR | S_IWUSR | S_IXUSR)
 
#define S_IRGRP   0
 
#define S_IWGRP   0
 
#define S_IXGRP   0
 
#define S_IRWXG   0
 
#define S_IROTH   0
 
#define S_IWOTH   0
 
#define S_IXOTH   0
 
#define S_IRWXO   0
 
#define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
 
#define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)
 
#define S_IFLNK   S_IFCHR
 
#define S_ISLNK(m)   (((m) & S_IFLNK) == S_IFLNK)
 
#define O_DSYNC   0x0080
 
#define O_CLOEXEC   0
 
#define EAGAIN   WSAEWOULDBLOCK
 
#define EINTR   WSAEINTR
 
#define EMSGSIZE   WSAEMSGSIZE
 
#define EAFNOSUPPORT   WSAEAFNOSUPPORT
 
#define EWOULDBLOCK   WSAEWOULDBLOCK
 
#define ECONNABORTED   WSAECONNABORTED
 
#define ECONNRESET   WSAECONNRESET
 
#define EINPROGRESS   WSAEINPROGRESS
 
#define EISCONN   WSAEISCONN
 
#define ENOBUFS   WSAENOBUFS
 
#define EPROTONOSUPPORT   WSAEPROTONOSUPPORT
 
#define ECONNREFUSED   WSAECONNREFUSED
 
#define ENOTSOCK   WSAENOTSOCK
 
#define EOPNOTSUPP   WSAEOPNOTSUPP
 
#define EADDRINUSE   WSAEADDRINUSE
 
#define EADDRNOTAVAIL   WSAEADDRNOTAVAIL
 
#define EHOSTDOWN   WSAEHOSTDOWN
 
#define EHOSTUNREACH   WSAEHOSTUNREACH
 
#define ENETDOWN   WSAENETDOWN
 
#define ENETRESET   WSAENETRESET
 
#define ENETUNREACH   WSAENETUNREACH
 
#define ENOTCONN   WSAENOTCONN
 
#define ETIMEDOUT   WSAETIMEDOUT
 
#define locale_t   _locale_t
 
#define tolower_l   _tolower_l
 
#define toupper_l   _toupper_l
 
#define towlower_l   _towlower_l
 
#define towupper_l   _towupper_l
 
#define isdigit_l   _isdigit_l
 
#define iswdigit_l   _iswdigit_l
 
#define isalpha_l   _isalpha_l
 
#define iswalpha_l   _iswalpha_l
 
#define isalnum_l   _isalnum_l
 
#define iswalnum_l   _iswalnum_l
 
#define isupper_l   _isupper_l
 
#define iswupper_l   _iswupper_l
 
#define islower_l   _islower_l
 
#define iswlower_l   _iswlower_l
 
#define isgraph_l   _isgraph_l
 
#define iswgraph_l   _iswgraph_l
 
#define isprint_l   _isprint_l
 
#define iswprint_l   _iswprint_l
 
#define ispunct_l   _ispunct_l
 
#define iswpunct_l   _iswpunct_l
 
#define isspace_l   _isspace_l
 
#define iswspace_l   _iswspace_l
 
#define strcoll_l   _strcoll_l
 
#define strxfrm_l   _strxfrm_l
 
#define wcscoll_l   _wcscoll_l
 
#define setlocale(a, b)   pgwin32_setlocale(a,b)
 
#define UNBLOCKED_SIGNAL_QUEUE()   (pg_signal_queue & ~pg_signal_mask)
 
#define PG_SIGNAL_COUNT   32
 
#define kill(pid, sig)   pgkill(pid,sig)
 
#define socket(af, type, protocol)   pgwin32_socket(af, type, protocol)
 
#define bind(s, addr, addrlen)   pgwin32_bind(s, addr, addrlen)
 
#define listen(s, backlog)   pgwin32_listen(s, backlog)
 
#define accept(s, addr, addrlen)   pgwin32_accept(s, addr, addrlen)
 
#define connect(s, name, namelen)   pgwin32_connect(s, name, namelen)
 
#define select(n, r, w, e, timeout)   pgwin32_select(n, r, w, e, timeout)
 
#define recv(s, buf, len, flags)   pgwin32_recv(s, buf, len, flags)
 
#define send(s, buf, len, flags)   pgwin32_send(s, buf, len, flags)
 
#define RTLD_NOW   1
 
#define RTLD_GLOBAL   0
 
#define putenv(x)   pgwin32_putenv(x)
 
#define setenv(x, y, z)   pgwin32_setenv(x,y,z)
 
#define unsetenv(x)   pgwin32_unsetenv(x)
 

Typedefs

typedef int uid_t
 
typedef int gid_t
 
typedef long key_t
 

Functions

int setitimer (int which, const struct itimerval *value, struct itimerval *ovalue)
 
DWORD pgwin32_get_file_type (HANDLE hFile)
 
int pgsymlink (const char *oldpath, const char *newpath)
 
int pgreadlink (const char *path, char *buf, size_t size)
 
int _pgfstat64 (int fileno, struct stat *buf)
 
int _pgstat64 (const char *name, struct stat *buf)
 
int _pglstat64 (const char *name, struct stat *buf)
 
char * pgwin32_setlocale (int category, const char *locale)
 
void pgwin32_signal_initialize (void)
 
HANDLE pgwin32_create_signal_listener (pid_t pid)
 
void pgwin32_dispatch_queued_signals (void)
 
void pg_queue_signal (int signum)
 
int pgkill (int pid, int sig)
 
SOCKET pgwin32_socket (int af, int type, int protocol)
 
int pgwin32_bind (SOCKET s, struct sockaddr *addr, int addrlen)
 
int pgwin32_listen (SOCKET s, int backlog)
 
SOCKET pgwin32_accept (SOCKET s, struct sockaddr *addr, int *addrlen)
 
int pgwin32_connect (SOCKET s, const struct sockaddr *name, int namelen)
 
int pgwin32_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout)
 
int pgwin32_recv (SOCKET s, char *buf, int len, int flags)
 
int pgwin32_send (SOCKET s, const void *buf, int len, int flags)
 
int pgwin32_waitforsinglesocket (SOCKET s, int what, int timeout)
 
int pgwin32_ReserveSharedMemoryRegion (HANDLE)
 
void pgwin32_install_crashdump_handler (void)
 
void * dlopen (const char *file, int mode)
 
void * dlsym (void *handle, const char *symbol)
 
int dlclose (void *handle)
 
char * dlerror (void)
 
void _dosmaperr (unsigned long)
 
int pgwin32_putenv (const char *)
 
int pgwin32_setenv (const char *name, const char *value, int overwrite)
 
int pgwin32_unsetenv (const char *name)
 
int pgwin32_is_service (void)
 
int pgwin32_is_admin (void)
 
BOOL AddUserToTokenDacl (HANDLE hToken)
 
ssize_t pg_pread (int fd, void *buf, size_t nbyte, off_t offset)
 
ssize_t pg_pwrite (int fd, const void *buf, size_t nbyte, off_t offset)
 

Variables

PGDLLIMPORT volatile int pg_signal_queue
 
PGDLLIMPORT int pg_signal_mask
 
PGDLLIMPORT HANDLE pgwin32_signal_event
 
PGDLLIMPORT HANDLE pgwin32_initial_signal_pipe
 
PGDLLIMPORT int pgwin32_noblock
 

Macro Definition Documentation

◆ _WINSOCKAPI_

#define _WINSOCKAPI_

Definition at line 43 of file win32_port.h.

◆ accept

#define accept (   s,
  addr,
  addrlen 
)    pgwin32_accept(s, addr, addrlen)

Definition at line 493 of file win32_port.h.

◆ bind

#define bind (   s,
  addr,
  addrlen 
)    pgwin32_bind(s, addr, addrlen)

Definition at line 491 of file win32_port.h.

◆ connect

#define connect (   s,
  name,
  namelen 
)    pgwin32_connect(s, name, namelen)

Definition at line 494 of file win32_port.h.

◆ EACCESS

#define EACCESS   2048

Definition at line 102 of file win32_port.h.

◆ EADDRINUSE

#define EADDRINUSE   WSAEADDRINUSE

Definition at line 400 of file win32_port.h.

◆ EADDRNOTAVAIL

#define EADDRNOTAVAIL   WSAEADDRNOTAVAIL

Definition at line 402 of file win32_port.h.

◆ EAFNOSUPPORT

#define EAFNOSUPPORT   WSAEAFNOSUPPORT

Definition at line 378 of file win32_port.h.

◆ EAGAIN

#define EAGAIN   WSAEWOULDBLOCK

Definition at line 372 of file win32_port.h.

◆ ECONNABORTED

#define ECONNABORTED   WSAECONNABORTED

Definition at line 382 of file win32_port.h.

◆ ECONNREFUSED

#define ECONNREFUSED   WSAECONNREFUSED

Definition at line 394 of file win32_port.h.

◆ ECONNRESET

#define ECONNRESET   WSAECONNRESET

Definition at line 384 of file win32_port.h.

◆ EHOSTDOWN

#define EHOSTDOWN   WSAEHOSTDOWN

Definition at line 404 of file win32_port.h.

◆ EHOSTUNREACH

#define EHOSTUNREACH   WSAEHOSTUNREACH

Definition at line 406 of file win32_port.h.

◆ EIDRM

#define EIDRM   4096

Definition at line 104 of file win32_port.h.

◆ EINPROGRESS

#define EINPROGRESS   WSAEINPROGRESS

Definition at line 386 of file win32_port.h.

◆ EINTR

#define EINTR   WSAEINTR

Definition at line 374 of file win32_port.h.

◆ EISCONN

#define EISCONN   WSAEISCONN

Definition at line 388 of file win32_port.h.

◆ EMSGSIZE

#define EMSGSIZE   WSAEMSGSIZE

Definition at line 376 of file win32_port.h.

◆ ENABLE_SSPI

#define ENABLE_SSPI   1

Definition at line 23 of file win32_port.h.

◆ ENETDOWN

#define ENETDOWN   WSAENETDOWN

Definition at line 408 of file win32_port.h.

◆ ENETRESET

#define ENETRESET   WSAENETRESET

Definition at line 410 of file win32_port.h.

◆ ENETUNREACH

#define ENETUNREACH   WSAENETUNREACH

Definition at line 412 of file win32_port.h.

◆ ENOBUFS

#define ENOBUFS   WSAENOBUFS

Definition at line 390 of file win32_port.h.

◆ ENOTCONN

#define ENOTCONN   WSAENOTCONN

Definition at line 414 of file win32_port.h.

◆ ENOTSOCK

#define ENOTSOCK   WSAENOTSOCK

Definition at line 396 of file win32_port.h.

◆ EOPNOTSUPP

#define EOPNOTSUPP   WSAEOPNOTSUPP

Definition at line 398 of file win32_port.h.

◆ EPROTONOSUPPORT

#define EPROTONOSUPPORT   WSAEPROTONOSUPPORT

Definition at line 392 of file win32_port.h.

◆ ETIMEDOUT

#define ETIMEDOUT   WSAETIMEDOUT

Definition at line 416 of file win32_port.h.

◆ EWOULDBLOCK

#define EWOULDBLOCK   WSAEWOULDBLOCK

Definition at line 380 of file win32_port.h.

◆ fseeko

#define fseeko (   stream,
  offset,
  origin 
)    fseeko64(stream, offset, origin)

Definition at line 216 of file win32_port.h.

◆ fstat [1/2]

#define fstat   microsoft_native_fstat

Definition at line 283 of file win32_port.h.

◆ fstat [2/2]

#define fstat (   fileno,
  sb 
)    _pgfstat64(fileno, sb)

Definition at line 283 of file win32_port.h.

◆ fsync

#define fsync (   fd)    _commit(fd)

Definition at line 85 of file win32_port.h.

◆ ftello

#define ftello (   stream)    ftello64(stream)

Definition at line 219 of file win32_port.h.

◆ ftruncate

#define ftruncate (   a,
  b 
)    chsize(a,b)

Definition at line 82 of file win32_port.h.

◆ GETNCNT

#define GETNCNT   16384

Definition at line 108 of file win32_port.h.

◆ GETPID

#define GETPID   262144

Definition at line 111 of file win32_port.h.

◆ GETVAL

#define GETVAL   65536

Definition at line 109 of file win32_port.h.

◆ HAVE_UNION_SEMUN

#define HAVE_UNION_SEMUN   1

Definition at line 93 of file win32_port.h.

◆ IPC_CREAT

#define IPC_CREAT   512

Definition at line 96 of file win32_port.h.

◆ IPC_EXCL

#define IPC_EXCL   1024

Definition at line 97 of file win32_port.h.

◆ IPC_NOWAIT

#define IPC_NOWAIT   2048

Definition at line 99 of file win32_port.h.

◆ IPC_PRIVATE

#define IPC_PRIVATE   234564

Definition at line 98 of file win32_port.h.

◆ IPC_RMID

#define IPC_RMID   256

Definition at line 95 of file win32_port.h.

◆ IPC_STAT

#define IPC_STAT   4096

Definition at line 100 of file win32_port.h.

◆ isalnum_l

#define isalnum_l   _isalnum_l

Definition at line 433 of file win32_port.h.

◆ isalpha_l

#define isalpha_l   _isalpha_l

Definition at line 431 of file win32_port.h.

◆ isdigit_l

#define isdigit_l   _isdigit_l

Definition at line 429 of file win32_port.h.

◆ isgraph_l

#define isgraph_l   _isgraph_l

Definition at line 439 of file win32_port.h.

◆ islower_l

#define islower_l   _islower_l

Definition at line 437 of file win32_port.h.

◆ isprint_l

#define isprint_l   _isprint_l

Definition at line 441 of file win32_port.h.

◆ ispunct_l

#define ispunct_l   _ispunct_l

Definition at line 443 of file win32_port.h.

◆ isspace_l

#define isspace_l   _isspace_l

Definition at line 445 of file win32_port.h.

◆ isupper_l

#define isupper_l   _isupper_l

Definition at line 435 of file win32_port.h.

◆ iswalnum_l

#define iswalnum_l   _iswalnum_l

Definition at line 434 of file win32_port.h.

◆ iswalpha_l

#define iswalpha_l   _iswalpha_l

Definition at line 432 of file win32_port.h.

◆ iswdigit_l

#define iswdigit_l   _iswdigit_l

Definition at line 430 of file win32_port.h.

◆ iswgraph_l

#define iswgraph_l   _iswgraph_l

Definition at line 440 of file win32_port.h.

◆ iswlower_l

#define iswlower_l   _iswlower_l

Definition at line 438 of file win32_port.h.

◆ iswprint_l

#define iswprint_l   _iswprint_l

Definition at line 442 of file win32_port.h.

◆ iswpunct_l

#define iswpunct_l   _iswpunct_l

Definition at line 444 of file win32_port.h.

◆ iswspace_l

#define iswspace_l   _iswspace_l

Definition at line 446 of file win32_port.h.

◆ iswupper_l

#define iswupper_l   _iswupper_l

Definition at line 436 of file win32_port.h.

◆ ITIMER_REAL

#define ITIMER_REAL   0

Definition at line 190 of file win32_port.h.

◆ kill

#define kill (   pid,
  sig 
)    pgkill(pid,sig)

Definition at line 485 of file win32_port.h.

◆ listen

#define listen (   s,
  backlog 
)    pgwin32_listen(s, backlog)

Definition at line 492 of file win32_port.h.

◆ locale_t

#define locale_t   _locale_t

Definition at line 424 of file win32_port.h.

◆ lstat

#define lstat (   path,
  sb 
)    _pglstat64(path, sb)

Definition at line 285 of file win32_port.h.

◆ mkdir

#define mkdir (   a,
  b 
)    mkdir(a)

Definition at line 80 of file win32_port.h.

◆ O_CLOEXEC

#define O_CLOEXEC   0

Definition at line 359 of file win32_port.h.

◆ O_DSYNC

#define O_DSYNC   0x0080

Definition at line 352 of file win32_port.h.

◆ PG_SIGNAL_COUNT

#define PG_SIGNAL_COUNT   32

Definition at line 477 of file win32_port.h.

◆ pgoff_t

#define pgoff_t   __int64

Definition at line 207 of file win32_port.h.

◆ putenv

#define putenv (   x)    pgwin32_putenv(x)

Definition at line 536 of file win32_port.h.

◆ readlink

#define readlink (   path,
  buf,
  size 
)    pgreadlink(path, buf, size)

Definition at line 236 of file win32_port.h.

◆ recv

#define recv (   s,
  buf,
  len,
  flags 
)    pgwin32_recv(s, buf, len, flags)

Definition at line 496 of file win32_port.h.

◆ RTLD_GLOBAL

#define RTLD_GLOBAL   0

Definition at line 526 of file win32_port.h.

◆ RTLD_NOW

#define RTLD_NOW   1

Definition at line 525 of file win32_port.h.

◆ S_IFLNK

#define S_IFLNK   S_IFCHR

Definition at line 343 of file win32_port.h.

◆ S_IRGRP

#define S_IRGRP   0

Definition at line 301 of file win32_port.h.

◆ S_IROTH

#define S_IROTH   0

Definition at line 313 of file win32_port.h.

◆ S_IRUSR

#define S_IRUSR   _S_IREAD

Definition at line 289 of file win32_port.h.

◆ S_IRWXG

#define S_IRWXG   0

Definition at line 310 of file win32_port.h.

◆ S_IRWXO

#define S_IRWXO   0

Definition at line 322 of file win32_port.h.

◆ S_IRWXU

#define S_IRWXU   (S_IRUSR | S_IWUSR | S_IXUSR)

Definition at line 298 of file win32_port.h.

◆ S_ISDIR

#define S_ISDIR (   m)    (((m) & S_IFMT) == S_IFDIR)

Definition at line 325 of file win32_port.h.

◆ S_ISLNK

#define S_ISLNK (   m)    (((m) & S_IFLNK) == S_IFLNK)

Definition at line 344 of file win32_port.h.

◆ S_ISREG

#define S_ISREG (   m)    (((m) & S_IFMT) == S_IFREG)

Definition at line 328 of file win32_port.h.

◆ S_IWGRP

#define S_IWGRP   0

Definition at line 304 of file win32_port.h.

◆ S_IWOTH

#define S_IWOTH   0

Definition at line 316 of file win32_port.h.

◆ S_IWUSR

#define S_IWUSR   _S_IWRITE

Definition at line 292 of file win32_port.h.

◆ S_IXGRP

#define S_IXGRP   0

Definition at line 307 of file win32_port.h.

◆ S_IXOTH

#define S_IXOTH   0

Definition at line 319 of file win32_port.h.

◆ S_IXUSR

#define S_IXUSR   _S_IEXEC

Definition at line 295 of file win32_port.h.

◆ select

#define select (   n,
  r,
  w,
  e,
  timeout 
)    pgwin32_select(n, r, w, e, timeout)

Definition at line 495 of file win32_port.h.

◆ send

#define send (   s,
  buf,
  len,
  flags 
)    pgwin32_send(s, buf, len, flags)

Definition at line 497 of file win32_port.h.

◆ SETALL

#define SETALL   8192

Definition at line 107 of file win32_port.h.

◆ setenv

#define setenv (   x,
  y,
 
)    pgwin32_setenv(x,y,z)

Definition at line 537 of file win32_port.h.

◆ setlocale

#define setlocale (   a,
  b 
)    pgwin32_setlocale(a,b)

Definition at line 467 of file win32_port.h.

◆ SETVAL

#define SETVAL   131072

Definition at line 110 of file win32_port.h.

◆ SIG_DFL

#define SIG_DFL   ((pqsigfunc)0)

Definition at line 163 of file win32_port.h.

◆ SIG_ERR

#define SIG_ERR   ((pqsigfunc)-1)

Definition at line 164 of file win32_port.h.

◆ SIG_IGN

#define SIG_IGN   ((pqsigfunc)1)

Definition at line 165 of file win32_port.h.

◆ SIGABRT

#define SIGABRT   22 /* Set to match W32 value -- not UNIX value */

Definition at line 171 of file win32_port.h.

◆ SIGALRM

#define SIGALRM   14

Definition at line 174 of file win32_port.h.

◆ SIGCHLD

#define SIGCHLD   20

Definition at line 178 of file win32_port.h.

◆ SIGCONT

#define SIGCONT   19

Definition at line 177 of file win32_port.h.

◆ SIGHUP

#define SIGHUP   1

Definition at line 168 of file win32_port.h.

◆ SIGKILL

#define SIGKILL   9

Definition at line 172 of file win32_port.h.

◆ sigmask

#define sigmask (   sig)    ( 1 << ((sig)-1) )

Definition at line 157 of file win32_port.h.

◆ SIGPIPE

#define SIGPIPE   13

Definition at line 173 of file win32_port.h.

◆ SIGQUIT

#define SIGQUIT   3

Definition at line 169 of file win32_port.h.

◆ SIGSTOP

#define SIGSTOP   17

Definition at line 175 of file win32_port.h.

◆ SIGTRAP

#define SIGTRAP   5

Definition at line 170 of file win32_port.h.

◆ SIGTSTP

#define SIGTSTP   18

Definition at line 176 of file win32_port.h.

◆ SIGUSR1

#define SIGUSR1   30

Definition at line 180 of file win32_port.h.

◆ SIGUSR2

#define SIGUSR2   31

Definition at line 181 of file win32_port.h.

◆ SIGWINCH

#define SIGWINCH   28

Definition at line 179 of file win32_port.h.

◆ socket

#define socket (   af,
  type,
  protocol 
)    pgwin32_socket(af, type, protocol)

Definition at line 490 of file win32_port.h.

◆ stat [1/2]

#define stat   microsoft_native_stat

Definition at line 284 of file win32_port.h.

◆ stat [2/2]

#define stat (   path,
  sb 
)    _pgstat64(path, sb)

Definition at line 284 of file win32_port.h.

◆ strcoll_l

#define strcoll_l   _strcoll_l

Definition at line 447 of file win32_port.h.

◆ strxfrm_l

#define strxfrm_l   _strxfrm_l

Definition at line 448 of file win32_port.h.

◆ symlink

#define symlink (   oldpath,
  newpath 
)    pgsymlink(oldpath, newpath)

Definition at line 235 of file win32_port.h.

◆ tolower_l

#define tolower_l   _tolower_l

Definition at line 425 of file win32_port.h.

◆ toupper_l

#define toupper_l   _toupper_l

Definition at line 426 of file win32_port.h.

◆ towlower_l

#define towlower_l   _towlower_l

Definition at line 427 of file win32_port.h.

◆ towupper_l

#define towupper_l   _towupper_l

Definition at line 428 of file win32_port.h.

◆ UMDF_USING_NTSTATUS

#define UMDF_USING_NTSTATUS

Definition at line 58 of file win32_port.h.

◆ UNBLOCKED_SIGNAL_QUEUE

#define UNBLOCKED_SIGNAL_QUEUE ( )    (pg_signal_queue & ~pg_signal_mask)

Definition at line 476 of file win32_port.h.

◆ unsetenv

#define unsetenv (   x)    pgwin32_unsetenv(x)

Definition at line 538 of file win32_port.h.

◆ USES_WINSOCK

#define USES_WINSOCK

Definition at line 87 of file win32_port.h.

◆ wcscoll_l

#define wcscoll_l   _wcscoll_l

Definition at line 449 of file win32_port.h.

◆ WEXITSTATUS

#define WEXITSTATUS (   w)    (w)

Definition at line 154 of file win32_port.h.

◆ WIFEXITED

#define WIFEXITED (   w)    (((w) & 0XFFFFFF00) == 0)

Definition at line 152 of file win32_port.h.

◆ WIFSIGNALED

#define WIFSIGNALED (   w)    (!WIFEXITED(w))

Definition at line 153 of file win32_port.h.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 57 of file win32_port.h.

◆ WTERMSIG

#define WTERMSIG (   w)    (w)

Definition at line 155 of file win32_port.h.

Typedef Documentation

◆ gid_t

typedef int gid_t

Definition at line 245 of file win32_port.h.

◆ key_t

typedef long key_t

Definition at line 247 of file win32_port.h.

◆ uid_t

typedef int uid_t

Definition at line 244 of file win32_port.h.

Function Documentation

◆ _dosmaperr()

void _dosmaperr ( unsigned long  e)

Definition at line 177 of file win32error.c.

178 {
179  int i;
180 
181  if (e == 0)
182  {
183  errno = 0;
184  return;
185  }
186 
187  for (i = 0; i < lengthof(doserrors); i++)
188  {
189  if (doserrors[i].winerr == e)
190  {
191  int doserr = doserrors[i].doserr;
192 
193 #ifndef FRONTEND
194  ereport(DEBUG5,
195  (errmsg_internal("mapped win32 error code %lu to %d",
196  e, doserr)));
197 #elif defined(FRONTEND_DEBUG)
198  fprintf(stderr, "mapped win32 error code %lu to %d", e, doserr);
199 #endif
200  errno = doserr;
201  return;
202  }
203  }
204 
205 #ifndef FRONTEND
206  ereport(LOG,
207  (errmsg_internal("unrecognized win32 error code: %lu",
208  e)));
209 #else
210  fprintf(stderr, "unrecognized win32 error code: %lu", e);
211 #endif
212 
213  errno = EINVAL;
214 }
#define lengthof(array)
Definition: c.h:777
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1156
#define LOG
Definition: elog.h:31
#define ereport(elevel,...)
Definition: elog.h:149
#define DEBUG5
Definition: elog.h:26
int i
Definition: isn.c:73
#define fprintf
Definition: port.h:242
e
Definition: preproc-init.c:82
static const struct @174 doserrors[]
int doserr
Definition: win32error.c:23
DWORD winerr
Definition: win32error.c:22

References DEBUG5, doserr, doserrors, ereport, errmsg_internal(), fprintf, i, lengthof, LOG, and winerr.

Referenced by BaseBackup(), copyFile(), dsm_impl_pin_segment(), dsm_impl_unpin_segment(), fdatasync(), FileRead(), FileWrite(), getrusage(), initialize_ntdll(), link(), pg_import_system_collations(), pg_pread(), pg_pwrite(), and readdir().

◆ _pgfstat64()

int _pgfstat64 ( int  fileno,
struct stat buf 
)

◆ _pglstat64()

int _pglstat64 ( const char *  name,
struct stat buf 
)

◆ _pgstat64()

int _pgstat64 ( const char *  name,
struct stat buf 
)

◆ AddUserToTokenDacl()

BOOL AddUserToTokenDacl ( HANDLE  hToken)

◆ dlclose()

int dlclose ( void *  handle)

Definition at line 49 of file win32dlopen.c.

50 {
51  if (!FreeLibrary((HMODULE) handle))
52  {
53  set_dl_error();
54  return 1;
55  }
56  last_dyn_error[0] = 0;
57  return 0;
58 }
static char last_dyn_error[512]
Definition: win32dlopen.c:18
static void set_dl_error(void)
Definition: win32dlopen.c:21

References last_dyn_error, and set_dl_error().

Referenced by internal_load_library().

◆ dlerror()

char* dlerror ( void  )

Definition at line 40 of file win32dlopen.c.

41 {
42  if (last_dyn_error[0])
43  return last_dyn_error;
44  else
45  return NULL;
46 }

References last_dyn_error.

Referenced by internal_load_library().

◆ dlopen()

void* dlopen ( const char *  file,
int  mode 
)

Definition at line 76 of file win32dlopen.c.

77 {
78  HMODULE h;
79  int prevmode;
80 
81  /* Disable popup error messages when loading DLLs */
82  prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
83  h = LoadLibrary(file);
84  SetErrorMode(prevmode);
85 
86  if (!h)
87  {
88  set_dl_error();
89  return NULL;
90  }
91  last_dyn_error[0] = 0;
92  return (void *) h;
93 }

References last_dyn_error, and set_dl_error().

Referenced by internal_load_library().

◆ dlsym()

void* dlsym ( void *  handle,
const char *  symbol 
)

Definition at line 61 of file win32dlopen.c.

62 {
63  void *ptr;
64 
65  ptr = GetProcAddress((HMODULE) handle, symbol);
66  if (!ptr)
67  {
68  set_dl_error();
69  return NULL;
70  }
71  last_dyn_error[0] = 0;
72  return ptr;
73 }
unsigned char symbol
Definition: api.h:2

References last_dyn_error, and set_dl_error().

Referenced by internal_load_library(), load_external_function(), and lookup_external_function().

◆ pg_pread()

ssize_t pg_pread ( int  fd,
void *  buf,
size_t  nbyte,
off_t  offset 
)

Definition at line 20 of file win32pread.c.

21 {
22  OVERLAPPED overlapped = {0};
23  HANDLE handle;
24  DWORD result;
25 
26  handle = (HANDLE) _get_osfhandle(fd);
27  if (handle == INVALID_HANDLE_VALUE)
28  {
29  errno = EBADF;
30  return -1;
31  }
32 
33  /* Note that this changes the file position, despite not using it. */
34  overlapped.Offset = offset;
35  if (!ReadFile(handle, buf, size, &result, &overlapped))
36  {
37  if (GetLastError() == ERROR_HANDLE_EOF)
38  return 0;
39 
40  _dosmaperr(GetLastError());
41  return -1;
42  }
43 
44  return result;
45 }
static char * buf
Definition: pg_test_fsync.c:73
static int fd(const char *x, int i)
Definition: preproc-init.c:105
void _dosmaperr(unsigned long)
Definition: win32error.c:177

References _dosmaperr(), buf, and fd().

◆ pg_pwrite()

ssize_t pg_pwrite ( int  fd,
const void *  buf,
size_t  nbyte,
off_t  offset 
)

Definition at line 20 of file win32pwrite.c.

21 {
22  OVERLAPPED overlapped = {0};
23  HANDLE handle;
24  DWORD result;
25 
26  handle = (HANDLE) _get_osfhandle(fd);
27  if (handle == INVALID_HANDLE_VALUE)
28  {
29  errno = EBADF;
30  return -1;
31  }
32 
33  /* Note that this changes the file position, despite not using it. */
34  overlapped.Offset = offset;
35  if (!WriteFile(handle, buf, size, &result, &overlapped))
36  {
37  _dosmaperr(GetLastError());
38  return -1;
39  }
40 
41  return result;
42 }

References _dosmaperr(), buf, and fd().

◆ pg_queue_signal()

void pg_queue_signal ( int  signum)

Definition at line 259 of file signal.c.

260 {
261  Assert(pgwin32_signal_event != NULL);
262  if (signum >= PG_SIGNAL_COUNT || signum <= 0)
263  return; /* ignore any bad signal number */
264 
265  EnterCriticalSection(&pg_signal_crit_sec);
266  pg_signal_queue |= sigmask(signum);
267  LeaveCriticalSection(&pg_signal_crit_sec);
268 
269  SetEvent(pgwin32_signal_event);
270 }
Assert(fmt[strlen(fmt) - 1] !='\n')
volatile int pg_signal_queue
Definition: signal.c:24
static CRITICAL_SECTION pg_signal_crit_sec
Definition: signal.c:34
HANDLE pgwin32_signal_event
Definition: signal.c:27
#define sigmask(sig)
Definition: win32_port.h:157
#define PG_SIGNAL_COUNT
Definition: win32_port.h:477

References Assert(), PG_SIGNAL_COUNT, pg_signal_crit_sec, pg_signal_queue, pgwin32_signal_event, and sigmask.

Referenced by pg_console_handler(), pg_signal_thread(), and pg_timer_thread().

◆ pgkill()

int pgkill ( int  pid,
int  sig 
)

◆ pgreadlink()

int pgreadlink ( const char *  path,
char *  buf,
size_t  size 
)

◆ pgsymlink()

int pgsymlink ( const char *  oldpath,
const char *  newpath 
)

◆ pgwin32_accept()

SOCKET pgwin32_accept ( SOCKET  s,
struct sockaddr *  addr,
int *  addrlen 
)

Definition at line 336 of file socket.c.

337 {
338  SOCKET rs;
339 
340  /*
341  * Poll for signals, but don't return with EINTR, since we don't handle
342  * that in pqcomm.c
343  */
345 
346  rs = WSAAccept(s, addr, addrlen, NULL, 0);
347  if (rs == INVALID_SOCKET)
348  {
350  return INVALID_SOCKET;
351  }
352  return rs;
353 }
static int pgwin32_poll_signals(void)
Definition: socket.c:157
static void TranslateSocketError(void)
Definition: socket.c:56

References pgwin32_poll_signals(), and TranslateSocketError().

◆ pgwin32_bind()

int pgwin32_bind ( SOCKET  s,
struct sockaddr *  addr,
int  addrlen 
)

Definition at line 314 of file socket.c.

315 {
316  int res;
317 
318  res = bind(s, addr, addrlen);
319  if (res < 0)
321  return res;
322 }
#define bind(s, addr, addrlen)
Definition: win32_port.h:491

References bind, res, and TranslateSocketError().

◆ pgwin32_connect()

int pgwin32_connect ( SOCKET  s,
const struct sockaddr *  name,
int  namelen 
)

Definition at line 358 of file socket.c.

359 {
360  int r;
361 
362  r = WSAConnect(s, addr, addrlen, NULL, NULL, NULL, NULL);
363  if (r == 0)
364  return 0;
365 
366  if (WSAGetLastError() != WSAEWOULDBLOCK)
367  {
369  return -1;
370  }
371 
372  while (pgwin32_waitforsinglesocket(s, FD_CONNECT, INFINITE) == 0)
373  {
374  /* Loop endlessly as long as we are just delivering signals */
375  }
376 
377  return 0;
378 }
int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout)
Definition: socket.c:181

References pgwin32_waitforsinglesocket(), and TranslateSocketError().

◆ pgwin32_create_signal_listener()

HANDLE pgwin32_create_signal_listener ( pid_t  pid)

Definition at line 227 of file signal.c.

228 {
229  char pipename[128];
230  HANDLE pipe;
231 
232  snprintf(pipename, sizeof(pipename), "\\\\.\\pipe\\pgsignal_%u", (int) pid);
233 
234  pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX,
235  PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
236  PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL);
237 
238  if (pipe == INVALID_HANDLE_VALUE)
239  ereport(ERROR,
240  (errmsg("could not create signal listener pipe for PID %d: error code %lu",
241  (int) pid, GetLastError())));
242 
243  return pipe;
244 }
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define snprintf
Definition: port.h:238

References ereport, errmsg(), ERROR, and snprintf.

◆ pgwin32_dispatch_queued_signals()

void pgwin32_dispatch_queued_signals ( void  )

Definition at line 120 of file signal.c.

121 {
122  int exec_mask;
123 
124  Assert(pgwin32_signal_event != NULL);
125  EnterCriticalSection(&pg_signal_crit_sec);
126  while ((exec_mask = UNBLOCKED_SIGNAL_QUEUE()) != 0)
127  {
128  /* One or more unblocked signals queued for execution */
129  int i;
130 
131  for (i = 1; i < PG_SIGNAL_COUNT; i++)
132  {
133  if (exec_mask & sigmask(i))
134  {
135  /* Execute this signal */
136  struct sigaction *act = &pg_signal_array[i];
137  pqsigfunc sig = act->sa_handler;
138 
139  if (sig == SIG_DFL)
142  if (sig != SIG_ERR && sig != SIG_IGN && sig != SIG_DFL)
143  {
144  sigset_t block_mask;
145  sigset_t save_mask;
146 
147  LeaveCriticalSection(&pg_signal_crit_sec);
148 
149  block_mask = act->sa_mask;
150  if ((act->sa_flags & SA_NODEFER) == 0)
151  block_mask |= sigmask(i);
152 
153  sigprocmask(SIG_BLOCK, &block_mask, &save_mask);
154  sig(i);
155  sigprocmask(SIG_SETMASK, &save_mask, NULL);
156 
157  EnterCriticalSection(&pg_signal_crit_sec);
158  break; /* Restart outer loop, in case signal mask or
159  * queue has been modified inside signal
160  * handler */
161  }
162  }
163  }
164  }
165  ResetEvent(pgwin32_signal_event);
166  LeaveCriticalSection(&pg_signal_crit_sec);
167 }
static int sig
Definition: pg_ctl.c:79
void(* pqsigfunc)(SIGNAL_ARGS)
Definition: port.h:488
static struct sigaction pg_signal_array[PG_SIGNAL_COUNT]
Definition: signal.c:37
static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT]
Definition: signal.c:38
#define UNBLOCKED_SIGNAL_QUEUE()
Definition: win32_port.h:476
#define SIG_DFL
Definition: win32_port.h:163
#define SIG_ERR
Definition: win32_port.h:164
#define SIG_IGN
Definition: win32_port.h:165

References Assert(), i, pg_signal_array, PG_SIGNAL_COUNT, pg_signal_crit_sec, pg_signal_defaults, pg_signal_queue, pgwin32_signal_event, sig, SIG_DFL, SIG_ERR, SIG_IGN, sigmask, and UNBLOCKED_SIGNAL_QUEUE.

Referenced by pg_usleep(), PGSemaphoreLock(), pgwin32_poll_signals(), pgwin32_select(), pgwin32_waitforsinglesocket(), pqsigprocmask(), and WaitEventSetWait().

◆ pgwin32_get_file_type()

DWORD pgwin32_get_file_type ( HANDLE  hFile)

◆ pgwin32_install_crashdump_handler()

void pgwin32_install_crashdump_handler ( void  )

Definition at line 178 of file crashdump.c.

179 {
180  SetUnhandledExceptionFilter(crashDumpHandler);
181 }
static LONG WINAPI crashDumpHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)
Definition: crashdump.c:90

References crashDumpHandler().

Referenced by main().

◆ pgwin32_is_admin()

int pgwin32_is_admin ( void  )

Definition at line 49 of file win32security.c.

50 {
51  PSID AdministratorsSid;
52  PSID PowerUsersSid;
53  SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
54  BOOL IsAdministrators;
55  BOOL IsPowerUsers;
56 
57  if (!AllocateAndInitializeSid(&NtAuthority, 2,
58  SECURITY_BUILTIN_DOMAIN_RID,
59  DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0,
60  0, &AdministratorsSid))
61  {
62  log_error(_("could not get SID for Administrators group: error code %lu\n"),
63  GetLastError());
64  exit(1);
65  }
66 
67  if (!AllocateAndInitializeSid(&NtAuthority, 2,
68  SECURITY_BUILTIN_DOMAIN_RID,
69  DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
70  0, &PowerUsersSid))
71  {
72  log_error(_("could not get SID for PowerUsers group: error code %lu\n"),
73  GetLastError());
74  exit(1);
75  }
76 
77  if (!CheckTokenMembership(NULL, AdministratorsSid, &IsAdministrators) ||
78  !CheckTokenMembership(NULL, PowerUsersSid, &IsPowerUsers))
79  {
80  log_error(_("could not check access token membership: error code %lu\n"),
81  GetLastError());
82  exit(1);
83  }
84 
85  FreeSid(AdministratorsSid);
86  FreeSid(PowerUsersSid);
87 
88  if (IsAdministrators || IsPowerUsers)
89  return 1;
90  else
91  return 0;
92 }
#define _(x)
Definition: elog.c:91
exit(1)
static void log_error(const char *fmt,...) pg_attribute_printf(1
Definition: win32security.c:28

References _, exit(), and log_error().

Referenced by check_root().

◆ pgwin32_is_service()

int pgwin32_is_service ( void  )

Definition at line 120 of file win32security.c.

121 {
122  static int _is_service = -1;
123  BOOL IsMember;
124  PSID ServiceSid;
125  PSID LocalSystemSid;
126  SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
127  HANDLE stderr_handle;
128 
129  /* Only check the first time */
130  if (_is_service != -1)
131  return _is_service;
132 
133  /* Check if standard error is not valid */
134  stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
135  if (stderr_handle != INVALID_HANDLE_VALUE && stderr_handle != NULL)
136  {
137  _is_service = 0;
138  return _is_service;
139  }
140 
141  /* Check if running as LocalSystem */
142  if (!AllocateAndInitializeSid(&NtAuthority, 1,
143  SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0,
144  &LocalSystemSid))
145  {
146  fprintf(stderr, "could not get SID for local system account\n");
147  return -1;
148  }
149 
150  if (!CheckTokenMembership(NULL, LocalSystemSid, &IsMember))
151  {
152  fprintf(stderr, "could not check access token membership: error code %lu\n",
153  GetLastError());
154  FreeSid(LocalSystemSid);
155  return -1;
156  }
157  FreeSid(LocalSystemSid);
158 
159  if (IsMember)
160  {
161  _is_service = 1;
162  return _is_service;
163  }
164 
165  /* Check for service group membership */
166  if (!AllocateAndInitializeSid(&NtAuthority, 1,
167  SECURITY_SERVICE_RID, 0, 0, 0, 0, 0, 0, 0,
168  &ServiceSid))
169  {
170  fprintf(stderr, "could not get SID for service group: error code %lu\n",
171  GetLastError());
172  return -1;
173  }
174 
175  if (!CheckTokenMembership(NULL, ServiceSid, &IsMember))
176  {
177  fprintf(stderr, "could not check access token membership: error code %lu\n",
178  GetLastError());
179  FreeSid(ServiceSid);
180  return -1;
181  }
182  FreeSid(ServiceSid);
183 
184  if (IsMember)
185  _is_service = 1;
186  else
187  _is_service = 0;
188 
189  return _is_service;
190 }

References fprintf.

Referenced by send_message_to_server_log(), and write_stderr().

◆ pgwin32_listen()

int pgwin32_listen ( SOCKET  s,
int  backlog 
)

Definition at line 325 of file socket.c.

326 {
327  int res;
328 
329  res = listen(s, backlog);
330  if (res < 0)
332  return res;
333 }
#define listen(s, backlog)
Definition: win32_port.h:492

References listen, res, and TranslateSocketError().

◆ pgwin32_putenv()

int pgwin32_putenv ( const char *  envval)

Definition at line 27 of file win32env.c.

28 {
29  char *envcpy;
30  char *cp;
31  typedef int (_cdecl * PUTENVPROC) (const char *);
32  static const char *const modulenames[] = {
33  "msvcrt", /* Visual Studio 6.0 / MinGW */
34  "msvcrtd",
35  "msvcr70", /* Visual Studio 2002 */
36  "msvcr70d",
37  "msvcr71", /* Visual Studio 2003 */
38  "msvcr71d",
39  "msvcr80", /* Visual Studio 2005 */
40  "msvcr80d",
41  "msvcr90", /* Visual Studio 2008 */
42  "msvcr90d",
43  "msvcr100", /* Visual Studio 2010 */
44  "msvcr100d",
45  "msvcr110", /* Visual Studio 2012 */
46  "msvcr110d",
47  "msvcr120", /* Visual Studio 2013 */
48  "msvcr120d",
49  "ucrtbase", /* Visual Studio 2015 and later */
50  "ucrtbased",
51  NULL
52  };
53  int i;
54 
55  /*
56  * Update process environment, making this change visible to child
57  * processes and to CRTs initializing in the future. Do this before the
58  * _putenv() loop, for the benefit of any CRT that initializes during this
59  * pgwin32_putenv() execution, after the loop checks that CRT.
60  *
61  * Need a copy of the string so we can modify it.
62  */
63  envcpy = strdup(envval);
64  if (!envcpy)
65  return -1;
66  cp = strchr(envcpy, '=');
67  if (cp == NULL)
68  {
69  free(envcpy);
70  return -1;
71  }
72  *cp = '\0';
73  cp++;
74  if (*cp)
75  {
76  /*
77  * Only call SetEnvironmentVariable() when we are adding a variable,
78  * not when removing it. Calling it on both crashes on at least
79  * certain versions of MinGW.
80  */
81  if (!SetEnvironmentVariable(envcpy, cp))
82  {
83  free(envcpy);
84  return -1;
85  }
86  }
87  free(envcpy);
88 
89  /*
90  * Each CRT has its own _putenv() symbol and copy of the environment.
91  * Update the environment in each CRT module currently loaded, so every
92  * third-party library sees this change regardless of the CRT it links
93  * against. Addresses within these modules may become invalid the moment
94  * we call FreeLibrary(), so don't cache them.
95  */
96  for (i = 0; modulenames[i]; i++)
97  {
98  HMODULE hmodule = NULL;
99  BOOL res = GetModuleHandleEx(0, modulenames[i], &hmodule);
100 
101  if (res != 0 && hmodule != NULL)
102  {
103  PUTENVPROC putenvFunc;
104 
105  putenvFunc = (PUTENVPROC) (pg_funcptr_t) GetProcAddress(hmodule, "_putenv");
106  if (putenvFunc)
107  putenvFunc(envval);
108  FreeLibrary(hmodule);
109  }
110  }
111 
112  /*
113  * Finally, update our "own" cache. This is redundant with the loop
114  * above, except when PostgreSQL itself links to a CRT not listed above.
115  * Ideally, the loop does visit all possible CRTs, making this redundant.
116  */
117  return _putenv(envval);
118 }
void(* pg_funcptr_t)(void)
Definition: c.h:377
#define free(a)
Definition: header.h:65

References free, i, and res.

Referenced by pgwin32_setenv(), and pgwin32_unsetenv().

◆ pgwin32_recv()

int pgwin32_recv ( SOCKET  s,
char *  buf,
int  len,
int  flags 
)

Definition at line 381 of file socket.c.

382 {
383  WSABUF wbuf;
384  int r;
385  DWORD b;
386  DWORD flags = f;
387  int n;
388 
389  if (pgwin32_poll_signals())
390  return -1;
391 
392  wbuf.len = len;
393  wbuf.buf = buf;
394 
395  r = WSARecv(s, &wbuf, 1, &b, &flags, NULL, NULL);
396  if (r != SOCKET_ERROR)
397  return b; /* success */
398 
399  if (WSAGetLastError() != WSAEWOULDBLOCK)
400  {
402  return -1;
403  }
404 
405  if (pgwin32_noblock)
406  {
407  /*
408  * No data received, and we are in "emulated non-blocking mode", so
409  * return indicating that we'd block if we were to continue.
410  */
411  errno = EWOULDBLOCK;
412  return -1;
413  }
414 
415  /* We're in blocking mode, so wait for data */
416 
417  for (n = 0; n < 5; n++)
418  {
419  if (pgwin32_waitforsinglesocket(s, FD_READ | FD_CLOSE | FD_ACCEPT,
420  INFINITE) == 0)
421  return -1; /* errno already set */
422 
423  r = WSARecv(s, &wbuf, 1, &b, &flags, NULL, NULL);
424  if (r != SOCKET_ERROR)
425  return b; /* success */
426  if (WSAGetLastError() != WSAEWOULDBLOCK)
427  {
429  return -1;
430  }
431 
432  /*
433  * There seem to be cases on win2k (at least) where WSARecv can return
434  * WSAEWOULDBLOCK even when pgwin32_waitforsinglesocket claims the
435  * socket is readable. In this case, just sleep for a moment and try
436  * again. We try up to 5 times - if it fails more than that it's not
437  * likely to ever come back.
438  */
439  pg_usleep(10000);
440  }
441  ereport(NOTICE,
442  (errmsg_internal("could not read from ready socket (after retries)")));
443  errno = EWOULDBLOCK;
444  return -1;
445 }
#define NOTICE
Definition: elog.h:35
int b
Definition: isn.c:70
const void size_t len
void pg_usleep(long microsec)
Definition: signal.c:53
int pgwin32_noblock
Definition: socket.c:28
#define EWOULDBLOCK
Definition: win32_port.h:380

References b, buf, ereport, errmsg_internal(), EWOULDBLOCK, len, NOTICE, pg_usleep(), pgwin32_noblock, pgwin32_poll_signals(), pgwin32_waitforsinglesocket(), and TranslateSocketError().

◆ pgwin32_ReserveSharedMemoryRegion()

int pgwin32_ReserveSharedMemoryRegion ( HANDLE  hChild)

Definition at line 573 of file win32_shmem.c.

574 {
575  void *address;
576 
577  Assert(ShmemProtectiveRegion != NULL);
578  Assert(UsedShmemSegAddr != NULL);
579  Assert(UsedShmemSegSize != 0);
580 
581  /* ShmemProtectiveRegion */
582  address = VirtualAllocEx(hChild, ShmemProtectiveRegion,
584  MEM_RESERVE, PAGE_NOACCESS);
585  if (address == NULL)
586  {
587  /* Don't use FATAL since we're running in the postmaster */
588  elog(LOG, "could not reserve shared memory region (addr=%p) for child %p: error code %lu",
589  ShmemProtectiveRegion, hChild, GetLastError());
590  return false;
591  }
592  if (address != ShmemProtectiveRegion)
593  {
594  /*
595  * Should never happen - in theory if allocation granularity causes
596  * strange effects it could, so check just in case.
597  *
598  * Don't use FATAL since we're running in the postmaster.
599  */
600  elog(LOG, "reserved shared memory region got incorrect address %p, expected %p",
601  address, ShmemProtectiveRegion);
602  return false;
603  }
604 
605  /* UsedShmemSegAddr */
606  address = VirtualAllocEx(hChild, UsedShmemSegAddr, UsedShmemSegSize,
607  MEM_RESERVE, PAGE_READWRITE);
608  if (address == NULL)
609  {
610  elog(LOG, "could not reserve shared memory region (addr=%p) for child %p: error code %lu",
611  UsedShmemSegAddr, hChild, GetLastError());
612  return false;
613  }
614  if (address != UsedShmemSegAddr)
615  {
616  elog(LOG, "reserved shared memory region got incorrect address %p, expected %p",
617  address, UsedShmemSegAddr);
618  return false;
619  }
620 
621  return true;
622 }
#define PROTECTIVE_REGION_SIZE
Definition: win32_shmem.c:41
void * ShmemProtectiveRegion
Definition: win32_shmem.c:42
void * UsedShmemSegAddr
Definition: win32_shmem.c:45
static Size UsedShmemSegSize
Definition: win32_shmem.c:46

References Assert(), elog(), LOG, PROTECTIVE_REGION_SIZE, ShmemProtectiveRegion, UsedShmemSegAddr, and UsedShmemSegSize.

◆ pgwin32_select()

int pgwin32_select ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
const struct timeval *  timeout 
)

Definition at line 516 of file socket.c.

517 {
518  WSAEVENT events[FD_SETSIZE * 2]; /* worst case is readfds totally
519  * different from writefds, so
520  * 2*FD_SETSIZE sockets */
521  SOCKET sockets[FD_SETSIZE * 2];
522  int numevents = 0;
523  int i;
524  int r;
525  DWORD timeoutval = WSA_INFINITE;
526  FD_SET outreadfds;
527  FD_SET outwritefds;
528  int nummatches = 0;
529 
530  Assert(exceptfds == NULL);
531 
532  if (pgwin32_poll_signals())
533  return -1;
534 
535  FD_ZERO(&outreadfds);
536  FD_ZERO(&outwritefds);
537 
538  /*
539  * Windows does not guarantee to log an FD_WRITE network event indicating
540  * that more data can be sent unless the previous send() failed with
541  * WSAEWOULDBLOCK. While our caller might well have made such a call, we
542  * cannot assume that here. Therefore, if waiting for write-ready, force
543  * the issue by doing a dummy send(). If the dummy send() succeeds,
544  * assume that the socket is in fact write-ready, and return immediately.
545  * Also, if it fails with something other than WSAEWOULDBLOCK, return a
546  * write-ready indication to let our caller deal with the error condition.
547  */
548  if (writefds != NULL)
549  {
550  for (i = 0; i < writefds->fd_count; i++)
551  {
552  char c;
553  WSABUF buf;
554  DWORD sent;
555 
556  buf.buf = &c;
557  buf.len = 0;
558 
559  r = WSASend(writefds->fd_array[i], &buf, 1, &sent, 0, NULL, NULL);
560  if (r == 0 || WSAGetLastError() != WSAEWOULDBLOCK)
561  FD_SET(writefds->fd_array[i], &outwritefds);
562  }
563 
564  /* If we found any write-ready sockets, just return them immediately */
565  if (outwritefds.fd_count > 0)
566  {
567  memcpy(writefds, &outwritefds, sizeof(fd_set));
568  if (readfds)
569  FD_ZERO(readfds);
570  return outwritefds.fd_count;
571  }
572  }
573 
574 
575  /* Now set up for an actual select */
576 
577  if (timeout != NULL)
578  {
579  /* timeoutval is in milliseconds */
580  timeoutval = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
581  }
582 
583  if (readfds != NULL)
584  {
585  for (i = 0; i < readfds->fd_count; i++)
586  {
587  events[numevents] = WSACreateEvent();
588  sockets[numevents] = readfds->fd_array[i];
589  numevents++;
590  }
591  }
592  if (writefds != NULL)
593  {
594  for (i = 0; i < writefds->fd_count; i++)
595  {
596  if (!readfds ||
597  !FD_ISSET(writefds->fd_array[i], readfds))
598  {
599  /* If the socket is not in the read list */
600  events[numevents] = WSACreateEvent();
601  sockets[numevents] = writefds->fd_array[i];
602  numevents++;
603  }
604  }
605  }
606 
607  for (i = 0; i < numevents; i++)
608  {
609  int flags = 0;
610 
611  if (readfds && FD_ISSET(sockets[i], readfds))
612  flags |= FD_READ | FD_ACCEPT | FD_CLOSE;
613 
614  if (writefds && FD_ISSET(sockets[i], writefds))
615  flags |= FD_WRITE | FD_CLOSE;
616 
617  if (WSAEventSelect(sockets[i], events[i], flags) != 0)
618  {
620  /* release already-assigned event objects */
621  while (--i >= 0)
622  WSAEventSelect(sockets[i], NULL, 0);
623  for (i = 0; i < numevents; i++)
624  WSACloseEvent(events[i]);
625  return -1;
626  }
627  }
628 
629  events[numevents] = pgwin32_signal_event;
630  r = WaitForMultipleObjectsEx(numevents + 1, events, FALSE, timeoutval, TRUE);
631  if (r != WAIT_TIMEOUT && r != WAIT_IO_COMPLETION && r != (WAIT_OBJECT_0 + numevents))
632  {
633  /*
634  * We scan all events, even those not signaled, in case more than one
635  * event has been tagged but Wait.. can only return one.
636  */
637  WSANETWORKEVENTS resEvents;
638 
639  for (i = 0; i < numevents; i++)
640  {
641  ZeroMemory(&resEvents, sizeof(resEvents));
642  if (WSAEnumNetworkEvents(sockets[i], events[i], &resEvents) != 0)
643  elog(ERROR, "failed to enumerate network events: error code %d",
644  WSAGetLastError());
645  /* Read activity? */
646  if (readfds && FD_ISSET(sockets[i], readfds))
647  {
648  if ((resEvents.lNetworkEvents & FD_READ) ||
649  (resEvents.lNetworkEvents & FD_ACCEPT) ||
650  (resEvents.lNetworkEvents & FD_CLOSE))
651  {
652  FD_SET(sockets[i], &outreadfds);
653 
654  nummatches++;
655  }
656  }
657  /* Write activity? */
658  if (writefds && FD_ISSET(sockets[i], writefds))
659  {
660  if ((resEvents.lNetworkEvents & FD_WRITE) ||
661  (resEvents.lNetworkEvents & FD_CLOSE))
662  {
663  FD_SET(sockets[i], &outwritefds);
664 
665  nummatches++;
666  }
667  }
668  }
669  }
670 
671  /* Clean up all the event objects */
672  for (i = 0; i < numevents; i++)
673  {
674  WSAEventSelect(sockets[i], NULL, 0);
675  WSACloseEvent(events[i]);
676  }
677 
678  if (r == WSA_WAIT_TIMEOUT)
679  {
680  if (readfds)
681  FD_ZERO(readfds);
682  if (writefds)
683  FD_ZERO(writefds);
684  return 0;
685  }
686 
687  /* Signal-like events. */
688  if (r == WAIT_OBJECT_0 + numevents || r == WAIT_IO_COMPLETION)
689  {
691  errno = EINTR;
692  if (readfds)
693  FD_ZERO(readfds);
694  if (writefds)
695  FD_ZERO(writefds);
696  return -1;
697  }
698 
699  /* Overwrite socket sets with our resulting values */
700  if (readfds)
701  memcpy(readfds, &outreadfds, sizeof(fd_set));
702  if (writefds)
703  memcpy(writefds, &outwritefds, sizeof(fd_set));
704  return nummatches;
705 }
char * c
void pgwin32_dispatch_queued_signals(void)
Definition: signal.c:120
#define EINTR
Definition: win32_port.h:374

References Assert(), buf, EINTR, elog(), ERROR, i, pgwin32_dispatch_queued_signals(), pgwin32_poll_signals(), pgwin32_signal_event, and TranslateSocketError().

◆ pgwin32_send()

int pgwin32_send ( SOCKET  s,
const void *  buf,
int  len,
int  flags 
)

Definition at line 458 of file socket.c.

459 {
460  WSABUF wbuf;
461  int r;
462  DWORD b;
463 
464  if (pgwin32_poll_signals())
465  return -1;
466 
467  wbuf.len = len;
468  wbuf.buf = (char *) buf;
469 
470  /*
471  * Readiness of socket to send data to UDP socket may be not true: socket
472  * can become busy again! So loop until send or error occurs.
473  */
474  for (;;)
475  {
476  r = WSASend(s, &wbuf, 1, &b, flags, NULL, NULL);
477  if (r != SOCKET_ERROR && b > 0)
478  /* Write succeeded right away */
479  return b;
480 
481  if (r == SOCKET_ERROR &&
482  WSAGetLastError() != WSAEWOULDBLOCK)
483  {
485  return -1;
486  }
487 
488  if (pgwin32_noblock)
489  {
490  /*
491  * No data sent, and we are in "emulated non-blocking mode", so
492  * return indicating that we'd block if we were to continue.
493  */
494  errno = EWOULDBLOCK;
495  return -1;
496  }
497 
498  /* No error, zero bytes */
499 
500  if (pgwin32_waitforsinglesocket(s, FD_WRITE | FD_CLOSE, INFINITE) == 0)
501  return -1;
502  }
503 
504  return -1;
505 }

References b, buf, EWOULDBLOCK, len, pgwin32_noblock, pgwin32_poll_signals(), pgwin32_waitforsinglesocket(), and TranslateSocketError().

◆ pgwin32_setenv()

int pgwin32_setenv ( const char *  name,
const char *  value,
int  overwrite 
)

Definition at line 121 of file win32env.c.

122 {
123  int res;
124  char *envstr;
125 
126  /* Error conditions, per POSIX */
127  if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL ||
128  value == NULL)
129  {
130  errno = EINVAL;
131  return -1;
132  }
133 
134  /* No work if variable exists and we're not to replace it */
135  if (overwrite == 0 && getenv(name) != NULL)
136  return 0;
137 
138  envstr = (char *) malloc(strlen(name) + strlen(value) + 2);
139  if (!envstr) /* not much we can do if no memory */
140  return -1;
141 
142  sprintf(envstr, "%s=%s", name, value);
143 
144  res = pgwin32_putenv(envstr);
145  free(envstr);
146  return res;
147 }
#define malloc(a)
Definition: header.h:50
static struct @148 value
#define sprintf
Definition: port.h:240
static void overwrite(PGconn *conn, Oid lobjId, int start, int len)
Definition: testlo.c:108
const char * name
int pgwin32_putenv(const char *envval)
Definition: win32env.c:27

References free, malloc, name, overwrite(), pgwin32_putenv(), res, sprintf, and value.

◆ pgwin32_setlocale()

char* pgwin32_setlocale ( int  category,
const char *  locale 
)

Definition at line 172 of file win32setlocale.c.

173 {
174  const char *argument;
175  char *result;
176 
177  if (locale == NULL)
178  argument = NULL;
179  else
181 
182  /* Call the real setlocale() function */
183  result = setlocale(category, argument);
184 
185  /*
186  * setlocale() is specified to return a "char *" that the caller is
187  * forbidden to modify, so casting away the "const" is innocuous.
188  */
189  if (result)
190  result = unconstify(char *, map_locale(locale_map_result, result));
191 
192  return result;
193 }
#define unconstify(underlying_type, expr)
Definition: c.h:1255
static char * locale
Definition: initdb.c:140
#define setlocale(a, b)
Definition: win32_port.h:467
static const char * map_locale(const struct locale_map *map, const char *locale)
static const struct locale_map locale_map_argument[]
static const struct locale_map locale_map_result[]

References locale, locale_map_argument, locale_map_result, map_locale(), setlocale, and unconstify.

◆ pgwin32_signal_initialize()

void pgwin32_signal_initialize ( void  )

Definition at line 79 of file signal.c.

80 {
81  int i;
82  HANDLE signal_thread_handle;
83 
84  InitializeCriticalSection(&pg_signal_crit_sec);
85 
86  for (i = 0; i < PG_SIGNAL_COUNT; i++)
87  {
88  pg_signal_array[i].sa_handler = SIG_DFL;
89  pg_signal_array[i].sa_mask = 0;
90  pg_signal_array[i].sa_flags = 0;
92  }
93  pg_signal_mask = 0;
94  pg_signal_queue = 0;
95 
96  /* Create the global event handle used to flag signals */
97  pgwin32_signal_event = CreateEvent(NULL, TRUE, FALSE, NULL);
98  if (pgwin32_signal_event == NULL)
99  ereport(FATAL,
100  (errmsg_internal("could not create signal event: error code %lu", GetLastError())));
101 
102  /* Create thread for handling signals */
103  signal_thread_handle = CreateThread(NULL, 0, pg_signal_thread, NULL, 0, NULL);
104  if (signal_thread_handle == NULL)
105  ereport(FATAL,
106  (errmsg_internal("could not create signal handler thread")));
107 
108  /* Create console control handle to pick up Ctrl-C etc */
109  if (!SetConsoleCtrlHandler(pg_console_handler, TRUE))
110  ereport(FATAL,
111  (errmsg_internal("could not set console control handler")));
112 }
#define FATAL
Definition: elog.h:41
static DWORD WINAPI pg_signal_thread(LPVOID param)
Definition: signal.c:274
static BOOL WINAPI pg_console_handler(DWORD dwCtrlType)
Definition: signal.c:377
int pg_signal_mask
Definition: signal.c:25

References ereport, errmsg_internal(), FATAL, i, pg_console_handler(), pg_signal_array, PG_SIGNAL_COUNT, pg_signal_crit_sec, pg_signal_defaults, pg_signal_mask, pg_signal_queue, pg_signal_thread(), pgwin32_signal_event, SIG_DFL, and SIG_IGN.

Referenced by InitPostmasterChild(), InitStandaloneProcess(), and PostmasterMain().

◆ pgwin32_socket()

SOCKET pgwin32_socket ( int  af,
int  type,
int  protocol 
)

Definition at line 291 of file socket.c.

292 {
293  SOCKET s;
294  unsigned long on = 1;
295 
296  s = WSASocket(af, type, protocol, NULL, 0, WSA_FLAG_OVERLAPPED);
297  if (s == INVALID_SOCKET)
298  {
300  return INVALID_SOCKET;
301  }
302 
303  if (ioctlsocket(s, FIONBIO, &on))
304  {
306  return INVALID_SOCKET;
307  }
308  errno = 0;
309 
310  return s;
311 }
const char * type

References TranslateSocketError(), and type.

◆ pgwin32_unsetenv()

int pgwin32_unsetenv ( const char *  name)

Definition at line 150 of file win32env.c.

151 {
152  int res;
153  char *envbuf;
154 
155  envbuf = (char *) malloc(strlen(name) + 2);
156  if (!envbuf)
157  return -1;
158 
159  sprintf(envbuf, "%s=", name);
160  res = pgwin32_putenv(envbuf);
161  free(envbuf);
162  return res;
163 }

References free, malloc, name, pgwin32_putenv(), res, and sprintf.

◆ pgwin32_waitforsinglesocket()

int pgwin32_waitforsinglesocket ( SOCKET  s,
int  what,
int  timeout 
)

Definition at line 181 of file socket.c.

182 {
183  static HANDLE waitevent = INVALID_HANDLE_VALUE;
184  static SOCKET current_socket = INVALID_SOCKET;
185  static int isUDP = 0;
186  HANDLE events[2];
187  int r;
188 
189  /* Create an event object just once and use it on all future calls */
190  if (waitevent == INVALID_HANDLE_VALUE)
191  {
192  waitevent = CreateEvent(NULL, TRUE, FALSE, NULL);
193 
194  if (waitevent == INVALID_HANDLE_VALUE)
195  ereport(ERROR,
196  (errmsg_internal("could not create socket waiting event: error code %lu", GetLastError())));
197  }
198  else if (!ResetEvent(waitevent))
199  ereport(ERROR,
200  (errmsg_internal("could not reset socket waiting event: error code %lu", GetLastError())));
201 
202  /*
203  * Track whether socket is UDP or not. (NB: most likely, this is both
204  * useless and wrong; there is no reason to think that the behavior of
205  * WSAEventSelect is different for TCP and UDP.)
206  */
207  if (current_socket != s)
208  isUDP = isDataGram(s);
209  current_socket = s;
210 
211  /*
212  * Attach event to socket. NOTE: we must detach it again before
213  * returning, since other bits of code may try to attach other events to
214  * the socket.
215  */
216  if (WSAEventSelect(s, waitevent, what) != 0)
217  {
219  return 0;
220  }
221 
222  events[0] = pgwin32_signal_event;
223  events[1] = waitevent;
224 
225  /*
226  * Just a workaround of unknown locking problem with writing in UDP socket
227  * under high load: Client's pgsql backend sleeps infinitely in
228  * WaitForMultipleObjectsEx, pgstat process sleeps in pgwin32_select().
229  * So, we will wait with small timeout(0.1 sec) and if socket is still
230  * blocked, try WSASend (see comments in pgwin32_select) and wait again.
231  */
232  if ((what & FD_WRITE) && isUDP)
233  {
234  for (;;)
235  {
236  r = WaitForMultipleObjectsEx(2, events, FALSE, 100, TRUE);
237 
238  if (r == WAIT_TIMEOUT)
239  {
240  char c;
241  WSABUF buf;
242  DWORD sent;
243 
244  buf.buf = &c;
245  buf.len = 0;
246 
247  r = WSASend(s, &buf, 1, &sent, 0, NULL, NULL);
248  if (r == 0) /* Completed - means things are fine! */
249  {
250  WSAEventSelect(s, NULL, 0);
251  return 1;
252  }
253  else if (WSAGetLastError() != WSAEWOULDBLOCK)
254  {
256  WSAEventSelect(s, NULL, 0);
257  return 0;
258  }
259  }
260  else
261  break;
262  }
263  }
264  else
265  r = WaitForMultipleObjectsEx(2, events, FALSE, timeout, TRUE);
266 
267  WSAEventSelect(s, NULL, 0);
268 
269  if (r == WAIT_OBJECT_0 || r == WAIT_IO_COMPLETION)
270  {
272  errno = EINTR;
273  return 0;
274  }
275  if (r == WAIT_OBJECT_0 + 1)
276  return 1;
277  if (r == WAIT_TIMEOUT)
278  {
279  errno = EWOULDBLOCK;
280  return 0;
281  }
282  ereport(ERROR,
283  (errmsg_internal("unrecognized return value from WaitForMultipleObjects: %d (error code %lu)", r, GetLastError())));
284  return 0;
285 }
static int isDataGram(SOCKET s)
Definition: socket.c:169

References buf, EINTR, ereport, errmsg_internal(), ERROR, EWOULDBLOCK, isDataGram(), pgwin32_dispatch_queued_signals(), pgwin32_signal_event, and TranslateSocketError().

Referenced by pgwin32_connect(), pgwin32_recv(), and pgwin32_send().

◆ setitimer()

int setitimer ( int  which,
const struct itimerval value,
struct itimerval ovalue 
)

Definition at line 86 of file timer.c.

87 {
88  Assert(value != NULL);
89  Assert(value->it_interval.tv_sec == 0 && value->it_interval.tv_usec == 0);
90  Assert(which == ITIMER_REAL);
91 
92  if (timerThreadHandle == INVALID_HANDLE_VALUE)
93  {
94  /* First call in this backend, create event and the timer thread */
95  timerCommArea.event = CreateEvent(NULL, TRUE, FALSE, NULL);
96  if (timerCommArea.event == NULL)
97  ereport(FATAL,
98  (errmsg_internal("could not create timer event: error code %lu",
99  GetLastError())));
100 
101  MemSet(&timerCommArea.value, 0, sizeof(struct itimerval));
102 
103  InitializeCriticalSection(&timerCommArea.crit_sec);
104 
105  timerThreadHandle = CreateThread(NULL, 0, pg_timer_thread, NULL, 0, NULL);
106  if (timerThreadHandle == INVALID_HANDLE_VALUE)
107  ereport(FATAL,
108  (errmsg_internal("could not create timer thread: error code %lu",
109  GetLastError())));
110  }
111 
112  /* Request the timer thread to change settings */
113  EnterCriticalSection(&timerCommArea.crit_sec);
114  if (ovalue)
115  *ovalue = timerCommArea.value;
117  LeaveCriticalSection(&timerCommArea.crit_sec);
118  SetEvent(timerCommArea.event);
119 
120  return 0;
121 }
#define MemSet(start, val, len)
Definition: c.h:1009
CRITICAL_SECTION crit_sec
Definition: timer.c:27
struct itimerval value
Definition: timer.c:25
HANDLE event
Definition: timer.c:26
static timerCA timerCommArea
Definition: timer.c:30
static DWORD WINAPI pg_timer_thread(LPVOID param)
Definition: timer.c:36
static HANDLE timerThreadHandle
Definition: timer.c:31
#define ITIMER_REAL
Definition: win32_port.h:190

Referenced by do_watch(), fork_process(), and schedule_alarm().

Variable Documentation

◆ pg_signal_mask

PGDLLIMPORT int pg_signal_mask
extern

Definition at line 25 of file signal.c.

Referenced by pgwin32_signal_initialize(), and pqsigprocmask().

◆ pg_signal_queue

PGDLLIMPORT volatile int pg_signal_queue
extern

◆ pgwin32_initial_signal_pipe

PGDLLIMPORT HANDLE pgwin32_initial_signal_pipe
extern

Definition at line 28 of file signal.c.

Referenced by pg_signal_thread().

◆ pgwin32_noblock

PGDLLIMPORT int pgwin32_noblock
extern

Definition at line 28 of file socket.c.

Referenced by pgwin32_recv(), pgwin32_send(), secure_raw_read(), and secure_raw_write().

◆ pgwin32_signal_event