diff options
author | Tom Lane | 2022-01-11 18:46:12 +0000 |
---|---|---|
committer | Tom Lane | 2022-01-11 18:46:20 +0000 |
commit | 98e93a1fc93e9b54eb477d870ec744e9e1669f34 (patch) | |
tree | 8d16b420c2b1b49c9c21af5d8fe93c9d1da93e1e /src/include/port.h | |
parent | 7fa945b857cc1b2964799411f1633468826861ff (diff) |
Clean up messy API for src/port/thread.c.
The point of this patch is to reduce inclusion spam by not needing
to #include <netdb.h> or <pwd.h> in port.h (which is read by every
compile in our tree). To do that, we must remove port.h's
declarations of pqGetpwuid and pqGethostbyname.
pqGethostbyname is only used, and is only ever likely to be used,
in src/port/getaddrinfo.c --- which isn't even built on most
platforms, making pqGethostbyname dead code for most people.
Hence, deal with that by just moving it into getaddrinfo.c.
To clean up pqGetpwuid, invent a couple of simple wrapper
functions with less-messy APIs. This allows removing some
duplicate error-handling code, too.
In passing, remove thread.c from the MSVC build, since it
contains nothing we use on Windows.
Noted while working on 376ce3e40.
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/include/port.h')
-rw-r--r-- | src/include/port.h | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/include/port.h b/src/include/port.h index 56e3721f6a4..3d103a2b31b 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -14,8 +14,6 @@ #define PG_PORT_H #include <ctype.h> -#include <netdb.h> -#include <pwd.h> /* * Windows has enough specialized port stuff that we push most of it off @@ -484,18 +482,12 @@ extern char *dlerror(void); #define RTLD_GLOBAL 0 #endif -/* thread.h */ +/* thread.c */ #ifndef WIN32 -extern int pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer, - size_t buflen, struct passwd **result); +extern bool pg_get_user_name(uid_t user_id, char *buffer, size_t buflen); +extern bool pg_get_user_home_dir(uid_t user_id, char *buffer, size_t buflen); #endif -extern int pqGethostbyname(const char *name, - struct hostent *resultbuf, - char *buffer, size_t buflen, - struct hostent **result, - int *herrno); - extern void pg_qsort(void *base, size_t nel, size_t elsize, int (*cmp) (const void *, const void *)); extern int pg_qsort_strcmp(const void *a, const void *b); |