Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Nov 2025 15:20:06 +0000
From:      Robert Clausecker <fuz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f0e541118c37 - main - uchar.h: add char8_t
Message-ID:  <6929bda6.2ee02.6bec62c6@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/src/commit/?id=f0e541118c374869a8226eaa1320bb6eda248a20

commit f0e541118c374869a8226eaa1320bb6eda248a20
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2025-11-27 17:57:02 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2025-11-28 15:19:53 +0000

    uchar.h: add char8_t
    
    A type similar to char16 and char32_t, for compliance with C23.
    The related type atomic_char8_t is added to stdatomic.h.
    As char8_t is always unsigned char, I've skipped adding __char8_t.
    This can be added, too, if desired.
    
    Reviewed by:    imp
    Approved by:    markj (mentor)
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D53952
---
 include/uchar.h     | 5 +++++
 sys/sys/stdatomic.h | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/include/uchar.h b/include/uchar.h
index 951c6339abec..ebb2c89776b8 100644
--- a/include/uchar.h
+++ b/include/uchar.h
@@ -32,6 +32,11 @@
 #include <sys/cdefs.h>
 #include <sys/_types.h>
 
+#if __ISO_C_VISIBLE >= 2023 && !defined(_CHAR8_T_DECLARED)
+typedef unsigned char	char8_t;
+#define	_CHAR8_T_DECLARED
+#endif
+
 #ifndef _CHAR16_T_DECLARED
 typedef	__char16_t	char16_t;
 #define	_CHAR16_T_DECLARED
diff --git a/sys/sys/stdatomic.h b/sys/sys/stdatomic.h
index 099097ea84a4..67107f47e6b3 100644
--- a/sys/sys/stdatomic.h
+++ b/sys/sys/stdatomic.h
@@ -54,6 +54,9 @@
 #ifdef __GCC_ATOMIC_CHAR_LOCK_FREE
 #define	ATOMIC_CHAR_LOCK_FREE		__GCC_ATOMIC_CHAR_LOCK_FREE
 #endif
+#if __ISO_C_VISIBLE >= 2023 && defined(__GCC_ATOMIC_CHAR8_T_LOCK_FREE)
+#define	ATOMIC_CHAR8_T_LOCK_FREE	__GCC_ATOMIC_CHAR8_T_LOCK_FREE
+#endif
 #ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE
 #define	ATOMIC_CHAR16_T_LOCK_FREE	__GCC_ATOMIC_CHAR16_T_LOCK_FREE
 #endif
@@ -199,6 +202,9 @@ typedef _Atomic(long)			atomic_long;
 typedef _Atomic(unsigned long)		atomic_ulong;
 typedef _Atomic(long long)		atomic_llong;
 typedef _Atomic(unsigned long long)	atomic_ullong;
+#if __ISO_C_VISIBLE >= 2023
+typedef _Atomic(unsigned char)		atomic_char8_t;
+#endif
 typedef _Atomic(__char16_t)		atomic_char16_t;
 typedef _Atomic(__char32_t)		atomic_char32_t;
 typedef _Atomic(___wchar_t)		atomic_wchar_t;


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6929bda6.2ee02.6bec62c6>