From 6ae2276ae54b32e7ffd3309bf65fa36d3b870a3f 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 v2 03/11] port: Use pg_threads.h API for pg_localconv_r().

Though only POSIX (probably only Solaris) systems will use this code
path, change direct <pthread.h> usage to the new style for consistency.

Discussion: https://postgr.es/m/CA%2BhUKG%2BK%2BLmYtz54%2BSv1j5Zu1Qo6szzAMbMyuKSeQmb7De4Ewg%40mail.gmail.com
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
---
 src/port/pg_localeconv_r.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/port/pg_localeconv_r.c b/src/port/pg_localeconv_r.c
index fcde4659957..eee28526481 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_ext.h"
+
 #include <langinfo.h>
-#include <pthread.h>
 #endif
 
 #include <limits.h>
@@ -337,10 +338,10 @@ exit:
 #else
 	/* We have nothing better than standard POSIX facilities. */
 	{
-		static pthread_mutex_t big_lock = PTHREAD_MUTEX_INITIALIZER;
+		static pg_mtx_t big_lock = PG_MTX_PLAIN_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.54.0

