summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2023-08-20 15:02:52 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2023-08-20 15:02:52 +0000
commit760ee81d8908250cb71452aecbbf761cf41781a9 (patch)
tree421292b6338597f8db39084e52297761a9db718d /include
parente26061305556764a023264740aae3c5c91d52bf9 (diff)
Provide C11 <uchar.h>.
OK millert@. Tested by naddy@ in a bulk and by matthieu@ in the new foot(1) port. I originally wrote the code in 2022 at the prodding of espie@. Using one improvement to a manual page from jmc@.
Diffstat (limited to 'include')
-rw-r--r--include/Makefile4
-rw-r--r--include/uchar.h38
2 files changed, 40 insertions, 2 deletions
diff --git a/include/Makefile b/include/Makefile
index 1d874e8c70f..a2d539f1c3b 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.230 2022/08/30 18:50:06 krw Exp $
+# $OpenBSD: Makefile,v 1.231 2023/08/20 15:02:50 schwarze Exp $
# $NetBSD: Makefile,v 1.59 1996/05/15 21:36:43 jtc Exp $
# @(#)Makefile 5.45.1.1 (Berkeley) 5/6/91
@@ -27,7 +27,7 @@ FILES= a.out.h ar.h asr.h assert.h \
signal.h siphash.h sndio.h spawn.h stdbool.h stddef.h \
stdio.h stdlib.h string.h strings.h sysexits.h \
tar.h tgmath.h tib.h time.h ttyent.h \
- unistd.h utime.h utmp.h uuid.h \
+ uchar.h unistd.h utime.h utmp.h uuid.h \
vis.h \
wchar.h wctype.h
diff --git a/include/uchar.h b/include/uchar.h
new file mode 100644
index 00000000000..2ed5f2c1282
--- /dev/null
+++ b/include/uchar.h
@@ -0,0 +1,38 @@
+/* $OpenBSD: uchar.h,v 1.1 2023/08/20 15:02:50 schwarze Exp $ */
+/*
+ * Written by Ingo Schwarze <schwarze@openbsd.org>
+ * and placed in the public domain on March 19, 2022.
+ */
+
+#ifndef _UCHAR_H_
+#define _UCHAR_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#ifndef _MBSTATE_T_DEFINED_
+#define _MBSTATE_T_DEFINED_
+typedef __mbstate_t mbstate_t;
+#endif
+
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef __size_t size_t;
+#endif
+
+#define __STDC_UTF_16__ 1
+#define __STDC_UTF_32__ 1
+
+typedef __uint16_t char16_t;
+typedef __uint32_t char32_t;
+
+__BEGIN_DECLS
+size_t mbrtoc16(char16_t * __restrict, const char * __restrict, size_t,
+ mbstate_t * __restrict);
+size_t c16rtomb(char * __restrict, char16_t, mbstate_t * __restrict);
+size_t mbrtoc32(char32_t * __restrict, const char * __restrict, size_t,
+ mbstate_t * __restrict);
+size_t c32rtomb(char * __restrict, char32_t, mbstate_t * __restrict);
+__END_DECLS
+
+#endif /* !_UCHAR_H_ */