commit b3afba8a70af984423fc24e5b834df966693b50a (tree)
parent 0d7aa1b637b26f87025b7c8b5dc20d9a92fbb7ab
Author: Linus Groh <mail@linusgroh.de>
Date: Tue, 25 Jun 2024 20:40:50 +0100
std.c: Add setlocale()
Diffstat:
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/lib/std/c.zig b/lib/std/c.zig
@@ -1895,6 +1895,27 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int;
pub extern "c" fn if_nametoindex([*:0]const u8) c_int;
+/// These are implementation defined but share identical values in at least musl and glibc:
+/// - https://git.musl-libc.org/cgit/musl/tree/include/locale.h?id=ab31e9d6a0fa7c5c408856c89df2dfb12c344039#n18
+/// - https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/bits/locale.h;h=0fcbb66114be5fef0577dc9047256eb508c45919;hb=c90cfce849d010474e8cccf3e5bff49a2c8b141f#l26
+pub const LC = enum(c_int) {
+ CTYPE = 0,
+ NUMERIC = 1,
+ TIME = 2,
+ COLLATE = 3,
+ MONETARY = 4,
+ MESSAGES = 5,
+ ALL = 6,
+ PAPER = 7,
+ NAME = 8,
+ ADDRESS = 9,
+ TELEPHONE = 10,
+ MEASUREMENT = 11,
+ IDENTIFICATION = 12,
+};
+
+pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) [*:0]const u8;
+
pub const getcontext = if (builtin.target.isAndroid())
@compileError("android bionic libc does not implement getcontext")
else if (native_os == .linux and builtin.target.isMusl())