xref: /freebsd/lib/libc/gen/uexterr_gettext.c (revision c27f7d6b9cf6d4ab01cb3d0972726c14e0aca146)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2025 The FreeBSD Foundation
5  * All rights reserved.
6  *
7  * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
8  * under sponsorship from the FreeBSD Foundation.
9  */
10 
11 #include <sys/types.h>
12 #include <sys/exterrvar.h>
13 #include <exterr.h>
14 #include <string.h>
15 #include "libc_private.h"
16 
17 static struct uexterror uexterr = {
18 	.ver = UEXTERROR_VER,
19 };
20 
21 static void uexterr_ctr(void) __attribute__((constructor));
22 static void
23 uexterr_ctr(void)
24 {
25 	exterrctl(EXTERRCTL_ENABLE, 0, &uexterr);
26 }
27 
28 int
29 __libc_uexterr_gettext(char *buf, size_t bufsz)
30 {
31 	return (__uexterr_format(&uexterr, buf, bufsz));
32 }
33 
34 int
35 uexterr_gettext(char *buf, size_t bufsz)
36 {
37 	return (((int (*)(char *, size_t))
38 	    __libc_interposing[INTERPOS_uexterr_gettext])(buf, bufsz));
39 }
40