Skip to content

Commit 6406769

Browse files
committed
(this commit is UNSTABLE) added libc wide-char prototypes
1 parent 4658d6e commit 6406769

File tree

6 files changed

+133
-12
lines changed

6 files changed

+133
-12
lines changed

src/libc/include/inttypes.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,21 @@ typedef struct {
194194

195195
__BEGIN_DECLS
196196

197-
extern intmax_t imaxabs(intmax_t __n) __NOEXCEPT_CONST;
197+
intmax_t imaxabs(intmax_t __n) __NOEXCEPT_CONST;
198198

199-
extern imaxdiv_t imaxdiv(intmax_t __numer, intmax_t __denom) __NOEXCEPT_CONST;
199+
imaxdiv_t imaxdiv(intmax_t __numer, intmax_t __denom) __NOEXCEPT_CONST;
200200

201-
intmax_t strtoimax(
202-
const char *__restrict nptr,
203-
char **__restrict endptr,
204-
int base
205-
) __attribute__((nonnull(1)));
201+
intmax_t strtoimax(const char *__restrict nptr, char **__restrict endptr, int base)
202+
__attribute__((nonnull(1)));
206203

207-
uintmax_t strtoumax(
208-
const char *__restrict nptr,
209-
char **__restrict endptr,
210-
int base
211-
) __attribute__((nonnull(1)));
204+
uintmax_t strtoumax(const char *__restrict nptr, char **__restrict endptr, int base)
205+
__attribute__((nonnull(1)));
206+
207+
intmax_t wcstoimax(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base)
208+
__attribute__((nonnull(1)));
209+
210+
uintmax_t wcstoumax(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base)
211+
__attribute__((nonnull(1)));
212212

213213
__END_DECLS
214214

src/libc/include/limits.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@
4848
#define ULLONG_MAX __ULONG_LONG_MAX__
4949
#define ULLONG_WIDTH __LLONG_WIDTH__
5050

51+
#ifndef MB_LEN_MAX
52+
#define MB_LEN_MAX 1
53+
#endif /* MB_LEN_MAX */
54+
5155
#endif /* _LIMITS_H */

src/libc/include/stdlib.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ lldiv_t lldiv(long long numer, long long denom);
118118
i48div_t i48div(signed __int48 numer, signed __int48 denom) __NOEXCEPT_CONST;
119119
#endif /* __SIZEOF_INT48__ */
120120

121+
int mblen(const char* s, size_t n);
122+
123+
int mbtowc(wchar_t* pwc, const char* s, size_t n);
124+
125+
int wctomb(char* s, wchar_t wchar);
126+
127+
size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
128+
129+
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
130+
131+
int __mb_cur_max(void);
132+
133+
#define MB_CUR_MAX __mb_cur_max()
134+
121135
__END_DECLS
122136

123137
#endif /* _STDLIB_H */

src/libc/include/string.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ int strncasecmp(const char *s1, const char *s2, size_t n)
118118

119119
char* strerror(int errnum);
120120

121+
int strcoll(const char *s1, const char *s2);
122+
123+
size_t strxfrm(char *__restrict dest, const char *__restrict src, size_t n);
124+
121125
__END_DECLS
122126

123127
#endif /* _STRING_H */

src/libc/include/wchar.h

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#define _WCHAR_H
33

44
#include <__wchar_def.h>
5+
#include <__mbstate.h>
6+
#include <stdio.h>
7+
#include <time.h>
58

69
__BEGIN_DECLS
710

@@ -65,6 +68,90 @@ int wcscmp(const wchar_t *s1, const wchar_t *s2)
6568
int wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
6669
__attribute__((nonnull(1, 2)));
6770

71+
int wprintf(const wchar_t *__restrict format, ...);
72+
73+
int vwprintf(const wchar_t *__restrict format, va_list va);
74+
75+
int swprintf(wchar_t *__restrict buffer, size_t count, const wchar_t *__restrict format, ...);
76+
77+
int vswprintf(wchar_t *__restrict buffer, size_t count, const wchar_t *__restrict format, va_list va);
78+
79+
int fwprintf(FILE *__restrict stream, const wchar_t *__restrict format, ...);
80+
81+
int vfwprintf(FILE *__restrict stream, const wchar_t *__restrict format, va_list va);
82+
83+
int wscanf(const wchar_t *__restrict format, ...);
84+
85+
int vwscanf(const wchar_t *__restrict format, va_list arg);
86+
87+
int swscanf(const wchar_t *__restrict s, const wchar_t *__restrict format, ...);
88+
89+
int vswscanf(const wchar_t *__restrict s, const wchar_t *__restrict format, va_list arg);
90+
91+
int fwscanf(FILE *__restrict stream, const wchar_t *__restrict format, ...);
92+
93+
int vfwscanf(FILE *__restrict stream, const wchar_t *__restrict format, va_list arg);
94+
95+
wint_t fgetwc(FILE *stream);
96+
97+
wchar_t *fgetws(wchar_t *__restrict s, int n, FILE *__restrict stream);
98+
99+
wint_t fputwc(wchar_t c, FILE *stream);
100+
101+
int fputws(const wchar_t *__restrict s, FILE *__restrict stream);
102+
103+
int fwide(FILE *stream, int mode);
104+
105+
wint_t getwc(FILE *stream);
106+
107+
wint_t getwchar(void);
108+
109+
wint_t putwc(wchar_t c, FILE *stream);
110+
111+
wint_t putwchar(wchar_t c);
112+
113+
wint_t ungetwc(wint_t c, FILE *stream);
114+
115+
float wcstof(const wchar_t *__restrict nptr, wchar_t **__restrict endptr);
116+
117+
double wcstod(const wchar_t *__restrict nptr, wchar_t **__restrict endptr);
118+
119+
long double wcstold(const wchar_t *__restrict nptr, wchar_t **__restrict endptr);
120+
121+
long wcstol(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base);
122+
123+
long long wcstoll(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base);
124+
125+
unsigned long wcstoul(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base);
126+
127+
unsigned long long wcstoull(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base);
128+
129+
size_t wcsftime(wchar_t *__restrict s, size_t maxsize, const wchar_t *__restrict format, const struct tm *__restrict timeptr);
130+
131+
int wcscoll(const wchar_t *s1, const wchar_t *s2);
132+
133+
size_t wcsxfrm(wchar_t *__restrict s1, const wchar_t *__restrict s2, size_t n);
134+
135+
wint_t btowc(int c);
136+
137+
int wctob(wint_t c);
138+
139+
int mbsinit(const mbstate_t *ps);
140+
141+
size_t mbrlen(const char *__restrict s, size_t n, mbstate_t *__restrict ps);
142+
143+
size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s, size_t n, mbstate_t *__restrict ps);
144+
145+
size_t wcrtomb(char *__restrict s, wchar_t wc, mbstate_t *__restrict ps);
146+
147+
size_t mbsrtowcs(wchar_t *__restrict dst, const char **__restrict src, size_t len, mbstate_t *__restrict ps);
148+
149+
size_t wcsrtombs(char *__restrict dst, const wchar_t **__restrict src, size_t len, mbstate_t *__restrict ps);
150+
151+
size_t mbsnrtowcs(wchar_t *__restrict dest, const char **__restrict src, size_t nms, size_t size, mbstate_t *__restrict ps);
152+
153+
size_t wcsnrtombs(char *__restrict dest, const wchar_t **__restrict src, size_t nwc, size_t size, mbstate_t *__restrict ps);
154+
68155
__END_DECLS
69156

70157
#endif /* _WCHAR_H */

src/libc/include/wctype.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include <__wchar_def.h>
55

6+
typedef int wctrans_t;
7+
8+
typedef int wctype_t;
9+
610
__BEGIN_DECLS
711

812
int iswalnum(wint_t wc);
@@ -33,6 +37,14 @@ wint_t towlower(wint_t wc);
3337

3438
wint_t towupper(wint_t wc);
3539

40+
wint_t towctrans(wint_t wc, wctrans_t desc);
41+
42+
wctrans_t wctrans(const char *str);
43+
44+
int iswctype(wint_t wc, wctype_t desc);
45+
46+
wctype_t wctype(const char *property);
47+
3648
__END_DECLS
3749

3850
#endif /* _WCTYPE_H */

0 commit comments

Comments
 (0)