From 89333db963af20988fc407463ea626b1c41404e8 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Sun, 9 Jul 2023 18:12:28 +1200 Subject: [PATCH] Rename port/thread.c to port/user.c. Historically this module dealt with thread-safety of system interfaces, but now all that's left is wrapper code for user name and home directory lookup. Arguably the Windows variants of this logic could be moved in here too, to justify its presence under port. For now, just tidy up some obsolete references to multi-threading, and give the file a meaningful name. Reviewed-by: Andres Freund Reviewed-by: Peter Eisentraut Reviewed-by: Heikki Linnakangas Discussion: https://postgr.es/m/CA%2BhUKGLtmexrpMtxBRLCVePqV_dtWG-ZsEbyPrYc%2BNBB2TkNsw%40mail.gmail.com --- configure | 1 - configure.ac | 1 - src/bin/psql/nls.mk | 2 +- src/include/port.h | 2 +- src/interfaces/libpq/nls.mk | 2 +- src/port/Makefile | 6 +----- src/port/meson.build | 2 +- src/port/{thread.c => user.c} | 13 +++---------- 8 files changed, 8 insertions(+), 21 deletions(-) rename src/port/{thread.c => user.c} (88%) diff --git a/configure b/configure index 842ef855fc..4a8f652129 100755 --- a/configure +++ b/configure @@ -10728,7 +10728,6 @@ fi # # For each platform, we need to know about any special compile and link # libraries, and whether the normal C function names are thread-safe. -# See the comment at the top of src/port/thread.c for more information. # WIN32 doesn't need the pthread tests; it always uses threads # # These tests are run before the library-tests, because linking with the diff --git a/configure.ac b/configure.ac index 2c18a64b0f..0f802f3df4 100644 --- a/configure.ac +++ b/configure.ac @@ -1232,7 +1232,6 @@ fi # # For each platform, we need to know about any special compile and link # libraries, and whether the normal C function names are thread-safe. -# See the comment at the top of src/port/thread.c for more information. # WIN32 doesn't need the pthread tests; it always uses threads # # These tests are run before the library-tests, because linking with the diff --git a/src/bin/psql/nls.mk b/src/bin/psql/nls.mk index cf0b800291..8624612969 100644 --- a/src/bin/psql/nls.mk +++ b/src/bin/psql/nls.mk @@ -23,7 +23,7 @@ GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \ ../../common/fe_memutils.c \ ../../common/username.c \ ../../common/wait_error.c \ - ../../port/thread.c + ../../port/user.c GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) \ HELP0 HELPN N_ simple_prompt simple_prompt_extended GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS) \ diff --git a/src/include/port.h b/src/include/port.h index a88d403483..5979139ebc 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -432,7 +432,7 @@ extern size_t strlcpy(char *dst, const char *src, size_t siz); extern size_t strnlen(const char *str, size_t maxlen); #endif -/* thread.c */ +/* port/user.c */ #ifndef WIN32 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); diff --git a/src/interfaces/libpq/nls.mk b/src/interfaces/libpq/nls.mk index 5959fa0c07..40b662dc08 100644 --- a/src/interfaces/libpq/nls.mk +++ b/src/interfaces/libpq/nls.mk @@ -13,7 +13,7 @@ GETTEXT_FILES = fe-auth.c \ fe-secure-gssapi.c \ fe-secure-openssl.c \ win32.c \ - ../../port/thread.c + ../../port/user.c GETTEXT_TRIGGERS = libpq_append_conn_error:2 \ libpq_append_error:2 \ libpq_gettext \ diff --git a/src/port/Makefile b/src/port/Makefile index 711f59e32b..f205c2c9c5 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -59,7 +59,7 @@ OBJS = \ snprintf.o \ strerror.o \ tar.o \ - thread.o + user.o # libpgport.a, libpgport_shlib.a, and libpgport_srv.a contain the same files # foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c @@ -84,10 +84,6 @@ libpgport.a: $(OBJS) rm -f $@ $(AR) $(AROPT) $@ $^ -# thread.o and thread_shlib.o need PTHREAD_CFLAGS (but thread_srv.o does not) -thread.o: CFLAGS+=$(PTHREAD_CFLAGS) -thread_shlib.o: CFLAGS+=$(PTHREAD_CFLAGS) - # all versions of pg_crc32c_sse42.o need CFLAGS_CRC pg_crc32c_sse42.o: CFLAGS+=$(CFLAGS_CRC) pg_crc32c_sse42_shlib.o: CFLAGS+=$(CFLAGS_CRC) diff --git a/src/port/meson.build b/src/port/meson.build index 24416b9bfc..9d0cd93c43 100644 --- a/src/port/meson.build +++ b/src/port/meson.build @@ -20,7 +20,7 @@ pgport_sources = [ 'snprintf.c', 'strerror.c', 'tar.c', - 'thread.c', + 'user.c', ] if host_system == 'windows' diff --git a/src/port/thread.c b/src/port/user.c similarity index 88% rename from src/port/thread.c rename to src/port/user.c index 375c89b297..d278684fe2 100644 --- a/src/port/thread.c +++ b/src/port/user.c @@ -1,13 +1,12 @@ /*------------------------------------------------------------------------- * - * thread.c + * user.c * - * Prototypes and macros around system calls, used to help make - * threaded libraries reentrant and safe to use from threaded applications. + * Wrapper functions for user and home directory lookup. * * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group * - * src/port/thread.c + * src/port/user.c * *------------------------------------------------------------------------- */ @@ -16,12 +15,6 @@ #include - -/* - * Historically, the code in this module had to deal with operating systems - * that lacked getpwuid_r(). - */ - #ifndef WIN32 /*