1
- From 0eb5403c389aaa7144d6bea297aac57d442bc9f6 Mon Sep 17 00:00:00 2001
1
+ From 52be7281e3becafe49603ed6bbc01c0ded64d9e1 Mon Sep 17 00:00:00 2001
2
2
From: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
3
3
Date: Fri, 8 Jul 2022 12:32:32 +1000
4
4
Subject: [PATCH] yes
5
5
6
6
Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
7
7
---
8
- .gitignore | 2 +
9
- options/ansi/generic/stdlib-stubs.cpp | 142 +++++++++++++++++++++-----
10
- options/glibc/generic/execinfo.cpp | 5 +-
11
- options/rtdl/generic/linker.cpp | 2 +-
12
- sysdeps/aero/generic/aero.cpp | 38 +++----
13
- sysdeps/aero/generic/filesystem.cpp | 25 ++++-
14
- sysdeps/aero/generic/sockets.cpp | 77 +++++++++++++-
15
- sysdeps/aero/generic/time.cpp | 24 +++++
16
- sysdeps/aero/include/aero/syscall.h | 6 ++
17
- sysdeps/aero/meson.build | 1 +
18
- 10 files changed, 268 insertions(+), 54 deletions(-)
8
+ .gitignore | 2 +
9
+ options/glibc/generic/execinfo.cpp | 5 +-
10
+ options/rtdl/generic/linker.cpp | 2 +-
11
+ sysdeps/aero/generic/aero.cpp | 38 +++++++-------
12
+ sysdeps/aero/generic/filesystem.cpp | 25 ++++++++--
13
+ sysdeps/aero/generic/sockets.cpp | 77 ++++++++++++++++++++++++++++-
14
+ sysdeps/aero/generic/time.cpp | 24 +++++++++
15
+ sysdeps/aero/include/aero/syscall.h | 6 +++
16
+ sysdeps/aero/meson.build | 1 +
17
+ 9 files changed, 152 insertions(+), 28 deletions(-)
19
18
create mode 100644 sysdeps/aero/generic/time.cpp
20
19
21
20
diff --git a/.gitignore b/.gitignore
@@ -28,159 +27,6 @@ index fdd60a00..9f811f47 100644
28
27
.vscode
29
28
+ # clangd cache files:
30
29
+ .cache
31
- diff --git a/options/ansi/generic/stdlib-stubs.cpp b/options/ansi/generic/stdlib-stubs.cpp
32
- index 4836391e..2a73c6d0 100644
33
- --- a/options/ansi/generic/stdlib-stubs.cpp
34
- +++ b/options/ansi/generic/stdlib-stubs.cpp
35
- @@ -375,32 +375,122 @@ int mblen(const char *mbs, size_t mb_limit) {
36
- return nseq.it - mbs;
37
- }
38
-
39
- - int mbtowc(wchar_t *__restrict wc, const char *__restrict mb, size_t max_size) {
40
- - auto cc = mlibc::current_charcode();
41
- - __ensure(max_size);
42
- -
43
- - if (mb) {
44
- - if (*mb) {
45
- - // If wc is NULL, decode into a single local character which we discard
46
- - // to obtain the length.
47
- - wchar_t tmp_wc;
48
- - if (!wc)
49
- - wc = &tmp_wc;
50
- -
51
- - mlibc::code_seq<wchar_t> wseq{wc, wc + 1};
52
- - mlibc::code_seq<const char> nseq{mb, mb + max_size};
53
- - auto e = cc->decode_wtranscode(nseq, wseq, mbtowc_state);
54
- - if (e != mlibc::charcode_error::null)
55
- - __ensure(!"decode_wtranscode() errors are not handled");
56
- -
57
- - return nseq.it - mb;
58
- - } else {
59
- - return 0; // When mbs is a null byte, return 0
60
- - }
61
- - } else {
62
- - mblen_state = __MLIBC_MBSTATE_INITIALIZER;
63
- - return cc->has_shift_states;
64
- - }
65
- + // int mbtowc(wchar_t *__restrict wc, const char *__restrict mb, size_t max_size) {
66
- + // auto cc = mlibc::current_charcode();
67
- + // __ensure(max_size);
68
- + //
69
- + // if (mb) {
70
- + // if (*mb) {
71
- + // // If wc is NULL, decode into a single local character which we discard
72
- + // // to obtain the length.
73
- + // wchar_t tmp_wc;
74
- + // if (!wc)
75
- + // wc = &tmp_wc;
76
- + //
77
- + // mlibc::code_seq<wchar_t> wseq{wc, wc + 1};
78
- + // mlibc::code_seq<const char> nseq{mb, mb + max_size};
79
- + // auto e = cc->decode_wtranscode(nseq, wseq, mbtowc_state);
80
- + // if (e != mlibc::charcode_error::null)
81
- + // __ensure(!"decode_wtranscode() errors are not handled");
82
- + //
83
- + // return nseq.it - mb;
84
- + // } else {
85
- + // return 0; // When mbs is a null byte, return 0
86
- + // }
87
- + // } else {
88
- + // mblen_state = __MLIBC_MBSTATE_INITIALIZER;
89
- + // return cc->has_shift_states;
90
- + // }
91
- + // }
92
- +
93
- + // Upper 6 state bits are a negative integer offset to bound-check next byte
94
- + // equivalent to: ( (b-0x80) | (b+offset) ) & ~0x3f
95
- + #define OOB(c, b) (((((b) >> 3) - 0x10) | (((b) >> 3) + ((int32_t)(c) >> 26))) & ~7)
96
- +
97
- + // Interval [a,b]. Either a must be 80 or b must be c0, lower 3 bits clear.
98
- + #define R(a, b) ((uint32_t)((a == 0x80 ? 0x40u - b : 0u - a) << 23))
99
- + #define FAILSTATE R(0x80, 0x80)
100
- +
101
- + #define SA 0xc2u
102
- + #define SB 0xf4u
103
- +
104
- + // Arbitrary encoding for representing code units instead of characters.
105
- + #define CODEUNIT(c) (0xdfff & (signed char)(c))
106
- + #define IS_CODEUNIT(c) ((unsigned)(c)-0xdf80 < 0x80)
107
- +
108
- + #define C(x) ( x<2 ? -1 : ( R(0x80,0xc0) | x ) )
109
- + #define D(x) C((x+16))
110
- + #define E(x) ( ( x==0 ? R(0xa0,0xc0) : \
111
- + x==0xd ? R(0x80,0xa0) : \
112
- + R(0x80,0xc0) ) \
113
- + | ( R(0x80,0xc0) >> 6 ) \
114
- + | x )
115
- + #define F(x) ( ( x>=5 ? 0 : \
116
- + x==0 ? R(0x90,0xc0) : \
117
- + x==4 ? R(0x80,0xa0) : \
118
- + R(0x80,0xc0) ) \
119
- + | ( R(0x80,0xc0) >> 6 ) \
120
- + | ( R(0x80,0xc0) >> 12 ) \
121
- + | x )
122
- +
123
- + const uint32_t bittab[] = {
124
- + C(0x2),C(0x3),C(0x4),C(0x5),C(0x6),C(0x7),
125
- + C(0x8),C(0x9),C(0xa),C(0xb),C(0xc),C(0xd),C(0xe),C(0xf),
126
- + D(0x0),D(0x1),D(0x2),D(0x3),D(0x4),D(0x5),D(0x6),D(0x7),
127
- + D(0x8),D(0x9),D(0xa),D(0xb),D(0xc),D(0xd),D(0xe),D(0xf),
128
- + E(0x0),E(0x1),E(0x2),E(0x3),E(0x4),E(0x5),E(0x6),E(0x7),
129
- + E(0x8),E(0x9),E(0xa),E(0xb),E(0xc),E(0xd),E(0xe),E(0xf),
130
- + F(0x0),F(0x1),F(0x2),F(0x3),F(0x4)
131
- + };
132
- +
133
- + // Converts a multibyte sequence to a wide character.
134
- + //
135
- + // Credits - MUSL
136
- + int mbtowc(wchar_t *__restrict wc, const char *__restrict src, size_t n) {
137
- + unsigned c;
138
- + const unsigned char *s = static_cast<const unsigned char *>((const void *)src);
139
- + wchar_t dummy;
140
- +
141
- + if (!s) return 0;
142
- + if (!n) goto ilseq;
143
- + if (!wc) wc = &dummy;
144
- +
145
- + if (*s < 0x80) return !!(*wc = *s);
146
- + if (MB_CUR_MAX == 1) return (*wc = CODEUNIT(*s)), 1;
147
- + if (*s - SA > SB - SA) goto ilseq;
148
- +
149
- + c = bittab[*s++ - SA];
150
- +
151
- + // Avoid excessive checks against n: If shifting the state n-1
152
- + // times does not clear the high bit, then the value of n is
153
- + // insufficient to read a character.
154
- + if (n < 4 && ((c << (6 * n - 6)) & (1U << 31))) goto ilseq;
155
- + if (OOB(c, *s)) goto ilseq;
156
- +
157
- + c = c << 6 | (*s++ - 0x80);
158
- +
159
- + if (!(c & (1U << 31))) {
160
- + *wc = c;
161
- + return 2;
162
- + }
163
- +
164
- + if (*s - 0x80u >= 0x40) goto ilseq;
165
- +
166
- + c = c << 6 | (*s++ - 0x80);
167
- +
168
- + if (!(c & (1U << 31))) {
169
- + *wc = c;
170
- + return 3;
171
- + }
172
- +
173
- + if (*s - 0x80u >= 0x40) goto ilseq;
174
- +
175
- + *wc = c << 6 | (*s++ - 0x80);
176
- + return 4;
177
- +
178
- + ilseq:
179
- + errno = EILSEQ;
180
- + return -1;
181
- }
182
-
183
- int wctomb(char *, wchar_t) {
184
30
diff --git a/options/glibc/generic/execinfo.cpp b/options/glibc/generic/execinfo.cpp
185
31
index 3474615e..10a2109e 100644
186
32
--- a/options/glibc/generic/execinfo.cpp
@@ -199,10 +45,10 @@ index 3474615e..10a2109e 100644
199
45
200
46
char **backtrace_symbols(void *const *, int) {
201
47
diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp
202
- index 6716ef4f..e5ec8cff 100644
48
+ index f51a543f..74f4e96a 100644
203
49
--- a/options/rtdl/generic/linker.cpp
204
50
+++ b/options/rtdl/generic/linker.cpp
205
- @@ -15 ,7 +15 ,7 @@ uintptr_t libraryBase = 0x41000000;
51
+ @@ -16 ,7 +16 ,7 @@ uintptr_t libraryBase = 0x41000000;
206
52
207
53
constexpr bool verbose = false;
208
54
constexpr bool stillSlightlyVerbose = false;
@@ -477,7 +323,7 @@ index 12f8dc61..03001c46 100644
477
323
// Invalid syscall used to trigger a log error in the kernel (as a hint)
478
324
// so, that we can implement the syscall in the kernel.
479
325
diff --git a/sysdeps/aero/meson.build b/sysdeps/aero/meson.build
480
- index 3ca8463e..f1d80139 100644
326
+ index 14975990..8e30aa3a 100644
481
327
--- a/sysdeps/aero/meson.build
482
328
+++ b/sysdeps/aero/meson.build
483
329
@@ -11,6 +11,7 @@ libc_sources += files(
0 commit comments