From 6991b8cea31833359bb56c7cfa880507a5b314a7 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 10 Jun 2023 12:26:04 +1200
Subject: [PATCH 2/5] Rename port/thread.c to port/user.c.

Historically this module dealt with non-threadsafe system interfaces for
user name and home directory lookup, but now it's just wrapper code.
Arguably the Windows variants of this logic could be moved in here too,
to justify its presence under port, but for now, just tidy up obsolete
references to threads.
---
 src/port/Makefile             |  6 +-----
 src/port/meson.build          |  2 +-
 src/port/{thread.c => user.c} | 13 +++----------
 3 files changed, 5 insertions(+), 16 deletions(-)
 rename src/port/{thread.c => user.c} (88%)

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 <pwd.h>
 
-
-/*
- *  Historically, the code in this module had to deal with operating systems
- *  that lacked getpwuid_r().
- */
-
 #ifndef WIN32
 
 /*
-- 
2.39.2

