posix: deprecate PTHREAD_BARRIER for POSIX_BARRIERS

The standard specifies _POSIX_BARRIERS as an Option so let's
use CONFIG_POSIX_BARRIERS for consistence.

This change deprecates CONFIG_PTHREAD_BARRIER. Users should
instead choose CONFIG_POSIX_BARRIERS.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
diff --git a/doc/services/portability/posix/conformance/index.rst b/doc/services/portability/posix/conformance/index.rst
index dffc1c5..3e2b945 100644
--- a/doc/services/portability/posix/conformance/index.rst
+++ b/doc/services/portability/posix/conformance/index.rst
@@ -62,7 +62,7 @@
 
     _POSIX_VERSION, 200809L,
     :ref:`_POSIX_ASYNCHRONOUS_IO<posix_option_asynchronous_io>`, 200809L, :ref:`†<posix_undefined_behaviour>`
-    :ref:`_POSIX_BARRIERS<posix_option_group_barriers>`, 200809L, :kconfig:option:`CONFIG_PTHREAD_BARRIER`
+    :ref:`_POSIX_BARRIERS<posix_option_group_barriers>`, 200809L, :kconfig:option:`CONFIG_POSIX_BARRIERS`
     :ref:`_POSIX_CLOCK_SELECTION<posix_option_group_clock_selection>`, 200809L, :kconfig:option:`CONFIG_POSIX_CLOCK_SELECTION`
     _POSIX_MAPPED_FILES, -1, :ref:`†<posix_undefined_behaviour>`
     _POSIX_MEMORY_PROTECTION, -1, :ref:`†<posix_undefined_behaviour>`
diff --git a/doc/services/portability/posix/kconfig/index.rst b/doc/services/portability/posix/kconfig/index.rst
index 58ef249..e8d82d6 100644
--- a/doc/services/portability/posix/kconfig/index.rst
+++ b/doc/services/portability/posix/kconfig/index.rst
@@ -12,7 +12,6 @@
 * :kconfig:option:`CONFIG_FNMATCH`
 * :kconfig:option:`CONFIG_GETOPT`
 * :kconfig:option:`CONFIG_GETOPT_LONG`
-* :kconfig:option:`CONFIG_MAX_PTHREAD_BARRIER_COUNT`
 * :kconfig:option:`CONFIG_MAX_PTHREAD_COUNT`
 * :kconfig:option:`CONFIG_MAX_PTHREAD_KEY_COUNT`
 * :kconfig:option:`CONFIG_MAX_PTHREAD_MUTEX_COUNT`
@@ -35,7 +34,6 @@
 * :kconfig:option:`CONFIG_POSIX_UNAME_NODENAME_LEN`
 * :kconfig:option:`CONFIG_POSIX_UNAME_VERSION_LEN`
 * :kconfig:option:`CONFIG_PTHREAD`
-* :kconfig:option:`CONFIG_PTHREAD_BARRIER`
 * :kconfig:option:`CONFIG_PTHREAD_COND`
 * :kconfig:option:`CONFIG_PTHREAD_CREATE_BARRIER`
 * :kconfig:option:`CONFIG_PTHREAD_IPC`
diff --git a/include/zephyr/posix/posix_features.h b/include/zephyr/posix/posix_features.h
index da42000..809f514 100644
--- a/include/zephyr/posix/posix_features.h
+++ b/include/zephyr/posix/posix_features.h
@@ -27,7 +27,7 @@
 #define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
 #endif
 
-#ifdef CONFIG_PTHREAD_BARRIER
+#ifdef CONFIG_POSIX_BARRIERS
 #define _POSIX_BARRIERS _POSIX_VERSION
 #endif
 
diff --git a/include/zephyr/posix/sys/sysconf.h b/include/zephyr/posix/sys/sysconf.h
index 1732dfd..40e4e6a 100644
--- a/include/zephyr/posix/sys/sysconf.h
+++ b/include/zephyr/posix/sys/sysconf.h
@@ -144,7 +144,7 @@
 #define __z_posix_sysconf_SC_ADVISORY_INFO (-1L)
 #define __z_posix_sysconf_SC_ASYNCHRONOUS_IO                                                       \
 	COND_CODE_1(CONFIG_POSIX_ASYNCHRONOUS_IO, (_POSIX_ASYNCHRONOUS_IO), (-1L))
-#define __z_posix_sysconf_SC_BARRIERS COND_CODE_1(CONFIG_PTHREAD_BARRIER, (_POSIX_BARRIERS), (-1L))
+#define __z_posix_sysconf_SC_BARRIERS COND_CODE_1(CONFIG_POSIX_BARRIERS, (_POSIX_BARRIERS), (-1L))
 #define __z_posix_sysconf_SC_CLOCK_SELECTION                                                       \
 	COND_CODE_1(CONFIG_POSIX_CLOCK_SELECTION, (_POSIX_CLOCK_SELECTION), (-1L))
 #define __z_posix_sysconf_SC_CPUTIME \
diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt
index 40326ac..1bf0823 100644
--- a/lib/posix/options/CMakeLists.txt
+++ b/lib/posix/options/CMakeLists.txt
@@ -38,6 +38,7 @@
 zephyr_library_sources_ifdef(CONFIG_FNMATCH fnmatch.c)
 zephyr_library_sources_ifdef(CONFIG_GETENTROPY getentropy.c)
 zephyr_library_sources_ifdef(CONFIG_POSIX_ASYNCHRONOUS_IO aio.c)
+zephyr_library_sources_ifdef(CONFIG_POSIX_BARRIERS barrier.c)
 zephyr_library_sources_ifdef(CONFIG_POSIX_CONFSTR confstr.c)
 zephyr_library_sources_ifdef(CONFIG_POSIX_DEVICE_IO
   # perror should be moved to the common libc
@@ -64,7 +65,6 @@
 )
 zephyr_library_sources_ifdef(CONFIG_POSIX_UNAME uname.c)
 zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC _common.c)
-zephyr_library_sources_ifdef(CONFIG_PTHREAD_BARRIER barrier.c)
 zephyr_library_sources_ifdef(CONFIG_PTHREAD_COND cond.c)
 zephyr_library_sources_ifdef(CONFIG_PTHREAD_KEY key.c)
 zephyr_library_sources_ifdef(CONFIG_PTHREAD_MUTEX mutex.c)
diff --git a/lib/posix/options/Kconfig.barrier b/lib/posix/options/Kconfig.barrier
index 72dd814..1a6b2e4 100644
--- a/lib/posix/options/Kconfig.barrier
+++ b/lib/posix/options/Kconfig.barrier
@@ -1,17 +1,30 @@
 # Copyright (c) 2017 Intel Corporation
 # Copyright (c) 2023 Meta
+# Copyright (c) 2024 Tenstorrent
 #
 # SPDX-License-Identifier: Apache-2.0
 
-TYPE = PTHREAD_BARRIER
-type = pthread_barrier_t
-type-function = pthread_barrier_wait
-rsource "Kconfig.template.pooled_ipc_type"
+menuconfig POSIX_BARRIERS
+	bool "POSIX barriers"
+	default y if POSIX_API
+	help
+	  Select 'y' here to enable POSIX barriers.
 
-if PTHREAD_BARRIER
+	  For more information please see
+	  https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
+
+if POSIX_BARRIERS
+
+config MAX_PTHREAD_BARRIER_COUNT
+	int "Maximum number of POSIX barriers"
+	default 5
+	help
+	  Maximum simultaneously active pthread_barrier_t in a POSIX application.
+
+	  Note: this is a non-standard option.
 
 config PTHREAD_CREATE_BARRIER
-	bool "Use a pthread_barrier_t to serialize pthread_create()"
+	bool "Use a POSIX barrier to serialize pthread_create()"
 	help
 	  When running several SMP applications in parallel instances of Qemu,
 	  e.g. via twister, explicit serialization may be required between
@@ -21,4 +34,8 @@
 	  On such systems, say Y here to introduce explicit serialization
 	  via pthread_barrier_wait().
 
-endif
+module = PTHREAD_BARRIER
+module-str = POSIX thread barriers
+source "subsys/logging/Kconfig.template.log_config"
+
+endif # POSIX_BARRIERS
diff --git a/lib/posix/options/Kconfig.deprecated b/lib/posix/options/Kconfig.deprecated
index ab76a8b..8da2f0e 100644
--- a/lib/posix/options/Kconfig.deprecated
+++ b/lib/posix/options/Kconfig.deprecated
@@ -57,6 +57,15 @@
 
 	  See also CONFIG_ZVFS_OPEN_MAX.
 
+config PTHREAD_BARRIER
+	bool "pthread_barrier_t support [DEPRECATED]"
+	select DEPRECATED
+	select POSIX_BARRIERS
+	help
+	  This option is deprecated.
+
+	  Please use CONFIG_POSIX_BARRIERS instead.
+
 config TIMER
 	bool "Timer support [DEPRECATED]"
 	select DEPRECATED