Rename port/thread.c to port/user.c.
authorThomas Munro <[email protected]>
Sun, 9 Jul 2023 06:12:28 +0000 (18:12 +1200)
committerThomas Munro <[email protected]>
Sun, 9 Jul 2023 06:17:09 +0000 (18:17 +1200)
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 <[email protected]>
Reviewed-by: Peter Eisentraut <[email protected]>
Reviewed-by: Heikki Linnakangas <[email protected]>
Discussion: https://postgr.es/m/CA%2BhUKGLtmexrpMtxBRLCVePqV_dtWG-ZsEbyPrYc%2BNBB2TkNsw%40mail.gmail.com

configure
configure.ac
src/bin/psql/nls.mk
src/include/port.h
src/interfaces/libpq/nls.mk
src/port/Makefile
src/port/meson.build
src/port/user.c [moved from src/port/thread.c with 88% similarity]

index 842ef855fc6543d5018b09bd465d2826141a16cd..4a8f652129693c0f5d455ae1f872a53845528d3d 100755 (executable)
--- 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
index 2c18a64b0f70862749b85d2bf95659ad769df1a3..0f802f3df40dcfa3135632ed35beab011330533b 100644 (file)
@@ -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
index cf0b80029183b60aa655854c70cb5cc6b08d0f16..8624612969ca500e2c1de24cf37d5e14e77eb677 100644 (file)
@@ -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) \
index a88d403483eab927d25958d58872b7ec90329f04..5979139ebc63c4af08fb9f633bf04b42f7b5956a 100644 (file)
@@ -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);
index 5959fa0c074499db00b32599c5241cde8adff4c6..40b662dc08b8dea2058d57ecfd7a86c5aa1a1e11 100644 (file)
@@ -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 \
index 711f59e32bd0391085f42716256600ac8f3a95a6..f205c2c9c50ed4109b91640bb24f0343286d7b66 100644 (file)
@@ -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)
index 24416b9bfc07cbb2f05c433485b4a5278b5da922..9d0cd93c438c7457ee713634cfdcacb2093933b5 100644 (file)
@@ -20,7 +20,7 @@ pgport_sources = [
   'snprintf.c',
   'strerror.c',
   'tar.c',
-  'thread.c',
+  'user.c',
 ]
 
 if host_system == 'windows'
similarity index 88%
rename from src/port/thread.c
rename to src/port/user.c
index 375c89b2974ed7240cbcdb56954b657f0a941f3b..d278684fe290f2c0d7754a5bb79b0ad4861551e8 100644 (file)
@@ -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
  *
  *-------------------------------------------------------------------------
  */
 
 #include <pwd.h>
 
-
-/*
- *  Historically, the code in this module had to deal with operating systems
- *  that lacked getpwuid_r().
- */
-
 #ifndef WIN32
 
 /*