From 458e926c11ee955738203c6aabb1dde8cfb2a921 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Fri, 26 Jun 2026 22:44:54 +1200
Subject: [PATCH v1 03/14] port: Use pg_threads.h API for pg_localconv_r().

Though only POSIX (probably only Solaris?) systems will use this code
path, pg_threads.h is more future-proof than direct pthread.h APIs.

Discussion:
Reviewed-by:
---
 src/port/pg_localeconv_r.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/port/pg_localeconv_r.c b/src/port/pg_localeconv_r.c
index 640cb97a62e..68e6b0d5f84 100644
--- a/src/port/pg_localeconv_r.c
+++ b/src/port/pg_localeconv_r.c
@@ -16,8 +16,9 @@
 #include "c.h"
 
 #if !defined(WIN32)
+#include "port/pg_threads.h"
+
 #include <langinfo.h>
-#include <pthread.h>
 #endif
 
 #include <limits.h>
@@ -335,12 +336,12 @@ exit:
 											LC_NUMERIC);
 	}
 #else
-	/* We have nothing better than standard POSIX facilities. */
+	/* We have nothing better than standard C facilities. */
 	{
-		static pthread_mutex_t big_lock = PTHREAD_MUTEX_INITIALIZER;
+		static pg_mtx_t big_lock = PG_MTX_INIT;
 		locale_t	save_locale;
 
-		pthread_mutex_lock(&big_lock);
+		pg_mtx_lock(&big_lock);
 		/* Copy the LC_MONETARY members. */
 		save_locale = uselocale(monetary_locale);
 		result = pg_localeconv_copy_members(output,
@@ -354,7 +355,7 @@ exit:
 												localeconv(),
 												LC_NUMERIC);
 		}
-		pthread_mutex_unlock(&big_lock);
+		pg_mtx_unlock(&big_lock);
 
 		uselocale(save_locale);
 	}
-- 
2.47.3

