diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 19:16:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-14 19:16:20 +0000 |
commit | 323bcca5249c707b68d9f6d921d86fd750bcf33e (patch) | |
tree | 07b4722c510482f5ee2fdcc3d381fc77747b0178 /src/port | |
parent | Adding debian version 16.2-2. (diff) | |
download | postgresql-16-323bcca5249c707b68d9f6d921d86fd750bcf33e.tar.xz postgresql-16-323bcca5249c707b68d9f6d921d86fd750bcf33e.zip |
Merging upstream version 16.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/port')
-rw-r--r-- | src/port/meson.build | 1 | ||||
-rw-r--r-- | src/port/pthread-win32.h | 11 | ||||
-rw-r--r-- | src/port/win32gai_strerror.c | 45 |
3 files changed, 56 insertions, 1 deletions
diff --git a/src/port/meson.build b/src/port/meson.build index 0a16f1c..900076d 100644 --- a/src/port/meson.build +++ b/src/port/meson.build @@ -35,6 +35,7 @@ if host_system == 'windows' 'win32error.c', 'win32fdatasync.c', 'win32fseek.c', + 'win32gai_strerror.c', 'win32getrusage.c', 'win32link.c', 'win32ntdll.c', diff --git a/src/port/pthread-win32.h b/src/port/pthread-win32.h index 97ccc17..5f33269 100644 --- a/src/port/pthread-win32.h +++ b/src/port/pthread-win32.h @@ -5,7 +5,16 @@ #define __PTHREAD_H typedef ULONG pthread_key_t; -typedef CRITICAL_SECTION *pthread_mutex_t; + +typedef struct pthread_mutex_t +{ + /* initstate = 0: not initialized; 1: init done; 2: init in progress */ + LONG initstate; + CRITICAL_SECTION csection; +} pthread_mutex_t; + +#define PTHREAD_MUTEX_INITIALIZER { 0 } + typedef int pthread_once_t; DWORD pthread_self(void); diff --git a/src/port/win32gai_strerror.c b/src/port/win32gai_strerror.c new file mode 100644 index 0000000..5b47d17 --- /dev/null +++ b/src/port/win32gai_strerror.c @@ -0,0 +1,45 @@ +/*------------------------------------------------------------------------- + * + * win32gai_strerror.c + * Thread-safe gai_strerror() for Windows. + * + * Portions Copyright (c) 2024, PostgreSQL Global Development Group + * + * IDENTIFICATION + * src/port/win32gai_strerror.c + * + *------------------------------------------------------------------------- + */ + +#include <sys/socket.h> + +/* + * Windows has gai_strerrorA(), but it is not thread-safe so we avoid it. + * + * https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-gai_strerrora + */ +const char * +gai_strerror(int errcode) +{ + switch (errcode) + { + case EAI_AGAIN: + return "Temporary failure in name resolution"; + case EAI_BADFLAGS: + return "Bad value for ai_flags"; + case EAI_FAIL: + return "Non-recoverable failure in name resolution"; + case EAI_FAMILY: + return "ai_family not supported"; + case EAI_MEMORY: + return "Memory allocation failure"; + case EAI_NONAME: + return "Name or service not known"; + case EAI_SERVICE: + return "Servname not supported for ai_socktype"; + case EAI_SOCKTYPE: + return "ai_socktype not supported"; + default: + return "Unknown server error"; + } +} |