authorgravatar for me@gasinfinity.devGasInfinity <me@gasinfinity.dev> 2026-01-17 20:56:35+01:00
committergravatar for me@gasinfinity.devGasInfinity <me@gasinfinity.dev> 2026-01-17 22:37:29+01:00
logf0649dd9782780f5b608af338b6d4add19ce2730
treef95a494933877975d081ee65a79e71560f4df917
parent06d05decaecb1dc5ad070b01c358f76e33095f71
signaturebadge-check Signed by SSH key SHA256:p3IHbr0lyK2ekfDC1Zi7dOEV/9T6lGghNawhl5sBnM4

feat(libzigc): use common implementations for `strings.h` and `string.h`

* forwards all functions to their equivalent `std` * removes their musl, wasi-libc and mingw implementations

42 files changed, 369 insertions(+), 1163 deletions(-)

lib/c.zig+2-2
...@@ -18,12 +18,12 @@ comptime {...@@ -18,12 +18,12 @@ comptime {
18 _ = @import("c/ctype.zig");18 _ = @import("c/ctype.zig");
19 _ = @import("c/stdlib.zig");19 _ = @import("c/stdlib.zig");
20 _ = @import("c/math.zig");20 _ = @import("c/math.zig");
21 _ = @import("c/string.zig");
22 _ = @import("c/strings.zig");
21 _ = @import("c/wchar.zig");23 _ = @import("c/wchar.zig");
2224
23 if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {25 if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
24 // Files specific to musl and wasi-libc.26 // Files specific to musl and wasi-libc.
25 _ = @import("c/string.zig");
26 _ = @import("c/strings.zig");
27 }27 }
2828
29 if (builtin.target.isMuslLibC()) {29 if (builtin.target.isMuslLibC()) {
lib/c/string.zig+264-69
...@@ -3,97 +3,292 @@ const std = @import("std");...@@ -3,97 +3,292 @@ const std = @import("std");
3const common = @import("common.zig");3const common = @import("common.zig");
44
5comptime {5comptime {
6 @export(&strcmp, .{ .name = "strcmp", .linkage = common.linkage, .visibility = common.visibility });6 if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
7 @export(&strncmp, .{ .name = "strncmp", .linkage = common.linkage, .visibility = common.visibility });7 // memcpy implemented in compiler_rt
8 @export(&strcasecmp, .{ .name = "strcasecmp", .linkage = common.linkage, .visibility = common.visibility });8 // memmove implemented in compiler_rt
9 @export(&strncasecmp, .{ .name = "strncasecmp", .linkage = common.linkage, .visibility = common.visibility });9 // memset implemented in compiler_rt
10 @export(&__strcasecmp_l, .{ .name = "__strcasecmp_l", .linkage = common.linkage, .visibility = common.visibility });10 // memcmp implemented in compiler_rt
11 @export(&__strncasecmp_l, .{ .name = "__strncasecmp_l", .linkage = common.linkage, .visibility = common.visibility });11 @export(&memchr, .{ .name = "memchr", .linkage = common.linkage, .visibility = common.visibility });
12 @export(&__strcasecmp_l, .{ .name = "strcasecmp_l", .linkage = .weak, .visibility = common.visibility });12 @export(&strcpy, .{ .name = "strcpy", .linkage = common.linkage, .visibility = common.visibility });
13 @export(&__strncasecmp_l, .{ .name = "strncasecmp_l", .linkage = .weak, .visibility = common.visibility });13 @export(&strncpy, .{ .name = "strncpy", .linkage = common.linkage, .visibility = common.visibility });
14}14 @export(&strcat, .{ .name = "strcat", .linkage = common.linkage, .visibility = common.visibility });
1515 @export(&strncat, .{ .name = "strncat", .linkage = common.linkage, .visibility = common.visibility });
16fn strcmp(s1: [*:0]const c_char, s2: [*:0]const c_char) callconv(.c) c_int {16 @export(&strcmp, .{ .name = "strcmp", .linkage = common.linkage, .visibility = common.visibility });
17 // We need to perform unsigned comparisons.17 @export(&strncmp, .{ .name = "strncmp", .linkage = common.linkage, .visibility = common.visibility });
18 return switch (std.mem.orderZ(u8, @ptrCast(s1), @ptrCast(s2))) {18 @export(&strcoll, .{ .name = "strcoll", .linkage = common.linkage, .visibility = common.visibility });
19 .lt => -1,19 @export(&strxfrm, .{ .name = "strxfrm", .linkage = common.linkage, .visibility = common.visibility });
20 @export(&strchr, .{ .name = "strchr", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&strrchr, .{ .name = "strrchr", .linkage = common.linkage, .visibility = common.visibility });
22 @export(&strcspn, .{ .name = "strcspn", .linkage = common.linkage, .visibility = common.visibility });
23 @export(&strspn, .{ .name = "strspn", .linkage = common.linkage, .visibility = common.visibility });
24 @export(&strpbrk, .{ .name = "strpbrk", .linkage = common.linkage, .visibility = common.visibility });
25 @export(&strstr, .{ .name = "strstr", .linkage = common.linkage, .visibility = common.visibility });
26 @export(&strtok, .{ .name = "strtok", .linkage = common.linkage, .visibility = common.visibility });
27 // strlen is in compiler_rt
28
29 @export(&strtok_r, .{ .name = "strtok_r", .linkage = common.linkage, .visibility = common.visibility });
30 @export(&stpcpy, .{ .name = "stpcpy", .linkage = common.linkage, .visibility = common.visibility });
31 @export(&stpncpy, .{ .name = "stpncpy", .linkage = common.linkage, .visibility = common.visibility });
32 @export(&strnlen, .{ .name = "strnlen", .linkage = common.linkage, .visibility = common.visibility });
33 @export(&memmem, .{ .name = "memmem", .linkage = common.linkage, .visibility = common.visibility });
34
35 @export(&memccpy, .{ .name = "memccpy", .linkage = common.linkage, .visibility = common.visibility });
36
37 @export(&strsep, .{ .name = "strsep", .linkage = common.linkage, .visibility = common.visibility });
38 @export(&strlcat, .{ .name = "strlcat", .linkage = common.linkage, .visibility = common.visibility });
39 @export(&strlcpy, .{ .name = "strlcpy", .linkage = common.linkage, .visibility = common.visibility });
40 @export(&explicit_bzero, .{ .name = "explicit_bzero", .linkage = common.linkage, .visibility = common.visibility });
41
42 @export(&strchrnul, .{ .name = "strchrnul", .linkage = common.linkage, .visibility = common.visibility });
43 @export(&strcasestr, .{ .name = "strcasestr", .linkage = common.linkage, .visibility = common.visibility });
44 @export(&memrchr, .{ .name = "memrchr", .linkage = common.linkage, .visibility = common.visibility });
45 @export(&mempcpy, .{ .name = "mempcpy", .linkage = common.linkage, .visibility = common.visibility });
46
47 @export(&__strcoll_l, .{ .name = "__strcoll_l", .linkage = common.linkage, .visibility = common.visibility });
48 @export(&__strxfrm_l, .{ .name = "__strxfrm_l", .linkage = common.linkage, .visibility = common.visibility });
49 @export(&__strcoll_l, .{ .name = "strcoll_l", .linkage = common.linkage, .visibility = common.visibility });
50 @export(&__strxfrm_l, .{ .name = "strxfrm_l", .linkage = common.linkage, .visibility = common.visibility });
51
52 // These symbols are not in the public ABI of musl/wasi. However they depend on these exports internally.
53 @export(&stpcpy, .{ .name = "__stpcpy", .linkage = common.linkage, .visibility = common.visibility });
54 @export(&stpncpy, .{ .name = "__stpncpy", .linkage = common.linkage, .visibility = common.visibility });
55 @export(&strchrnul, .{ .name = "__strchrnul", .linkage = common.linkage, .visibility = common.visibility });
56 @export(&memrchr, .{ .name = "__memrchr", .linkage = common.linkage, .visibility = common.visibility });
57 }
58
59 if (builtin.target.isMinGW()) {
60 @export(&strnlen, .{ .name = "strnlen", .linkage = common.linkage, .visibility = common.visibility });
61 @export(&mempcpy, .{ .name = "mempcpy", .linkage = common.linkage, .visibility = common.visibility });
62 @export(&strtok_r, .{ .name = "strtok_r", .linkage = common.linkage, .visibility = common.visibility });
63 }
64}
65
66fn memchr(ptr: *const anyopaque, value: c_int, len: usize) callconv(.c) ?*anyopaque {
67 const bytes: [*]const u8 = @ptrCast(ptr);
68 return @constCast(bytes[std.mem.findScalar(u8, bytes[0..len], @truncate(@as(c_uint, @bitCast(value)))) orelse return null ..]);
69}
70
71fn strcpy(noalias dst: [*]c_char, noalias src: [*:0]const c_char) callconv(.c) [*]c_char {
72 _ = stpcpy(dst, src);
73 return dst;
74}
75
76fn strncpy(noalias dst: [*]c_char, noalias src: [*:0]const c_char, max: usize) callconv(.c) [*]c_char {
77 _ = stpncpy(dst, src, max);
78 return dst;
79}
80
81fn strcat(noalias dst: [*:0]c_char, noalias src: [*:0]const c_char) callconv(.c) [*:0]c_char {
82 return strncat(dst, src, std.math.maxInt(usize));
83}
84
85fn strncat(noalias dst: [*:0]c_char, noalias src: [*:0]const c_char, max: usize) callconv(.c) [*:0]c_char {
86 const dst_len = std.mem.len(@as([*:0]u8, @ptrCast(dst)));
87 const src_len = strnlen(src, max);
88
89 @memcpy(dst[dst_len..][0..src_len], src[0..src_len]);
90 dst[dst_len + src_len] = 0;
91 return dst[0..(dst_len + src_len) :0].ptr;
92}
93
94fn strcmp(a: [*:0]const c_char, b: [*:0]const c_char) callconv(.c) c_int {
95 return strncmp(a, b, std.math.maxInt(usize));
96}
97
98fn strncmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) callconv(.c) c_int {
99 return switch (std.mem.boundedOrderZ(u8, @ptrCast(a), @ptrCast(b), max)) {
20 .eq => 0,100 .eq => 0,
21 .gt => 1,101 .gt => 1,
102 .lt => -1,
22 };103 };
23}104}
24105
25fn strncmp(s1: [*:0]const c_char, s2: [*:0]const c_char, n: usize) callconv(.c) c_int {106fn strcoll(a: [*:0]const c_char, b: [*:0]const c_char) callconv(.c) c_int {
26 if (n == 0) return 0;107 return strcmp(a, b);
108}
27109
28 var l: [*:0]const u8 = @ptrCast(s1);110fn __strcoll_l(a: [*:0]const c_char, b: [*:0]const c_char, locale: *anyopaque) callconv(.c) c_int {
29 var r: [*:0]const u8 = @ptrCast(s2);111 _ = locale;
30 var i = n - 1;112 return strcoll(a, b);
113}
31114
32 while (l[0] != 0 and r[0] != 0 and i != 0 and l[0] == r[0]) {115// NOTE: If 'max' is 0, 'dst' is allowed to be a null pointer
33 l += 1;116fn strxfrm(noalias dst: ?[*]c_char, noalias src: [*:0]const c_char, max: usize) callconv(.c) usize {
34 r += 1;117 const src_len = std.mem.len(@as([*:0]const u8, @ptrCast(src)));
35 i -= 1;118 if (src_len < max) @memcpy(dst.?[0 .. src_len + 1], src[0 .. src_len + 1]);
36 }119 return src_len;
120}
121
122fn __strxfrm_l(noalias dst: ?[*]c_char, noalias src: [*:0]const c_char, max: usize, locale: *anyopaque) callconv(.c) usize {
123 _ = locale;
124 return strxfrm(dst, src, max);
125}
126
127fn strchr(str: [*:0]const c_char, value: c_int) callconv(.c) ?[*:0]c_char {
128 const str_u8: [*:0]const u8 = @ptrCast(str);
129 const len = std.mem.len(str_u8);
37130
38 return @as(c_int, l[0]) - @as(c_int, r[0]);131 if (value == 0) return @constCast(str + len);
132 return @constCast(str[std.mem.findScalar(u8, str_u8[0..len], @truncate(@as(c_uint, @bitCast(value)))) orelse return null ..]);
39}133}
40134
41fn strcasecmp(s1: [*:0]const c_char, s2: [*:0]const c_char) callconv(.c) c_int {135fn strrchr(str: [*:0]const c_char, value: c_int) callconv(.c) ?[*:0]c_char {
42 const toLower = std.ascii.toLower;136 const str_u8: [*:0]const u8 = @ptrCast(str);
43 var l: [*:0]const u8 = @ptrCast(s1);137 // std.mem.len(str) + 1 to not special case '\0'
44 var r: [*:0]const u8 = @ptrCast(s2);138 return @constCast(str[std.mem.findScalarLast(u8, str_u8[0 .. std.mem.len(str_u8) + 1], @truncate(@as(c_uint, @bitCast(value)))) orelse return null ..]);
139}
140
141fn strcspn(dst: [*:0]const c_char, values: [*:0]const c_char) callconv(.c) usize {
142 const dst_slice = std.mem.span(@as([*:0]const u8, @ptrCast(dst)));
143 return std.mem.findAny(u8, dst_slice, std.mem.span(@as([*:0]const u8, @ptrCast(values)))) orelse dst_slice.len;
144}
145
146fn strspn(dst: [*:0]const c_char, values: [*:0]const c_char) callconv(.c) usize {
147 const dst_slice = std.mem.span(@as([*:0]const u8, @ptrCast(dst)));
148 return std.mem.findNone(u8, dst_slice, std.mem.span(@as([*:0]const u8, @ptrCast(values)))) orelse dst_slice.len;
149}
45150
46 while (l[0] != 0 and r[0] != 0 and (l[0] == r[0] or toLower(l[0]) == toLower(r[0]))) {151fn strpbrk(haystack: [*:0]const c_char, needle: [*:0]const c_char) callconv(.c) ?[*:0]c_char {
47 l += 1;152 return @constCast(haystack[std.mem.findAny(u8, std.mem.span(@as([*:0]const u8, @ptrCast(haystack))), std.mem.span(@as([*:0]const u8, @ptrCast(needle)))) orelse return null ..]);
48 r += 1;153}
154
155fn strstr(haystack: [*:0]const c_char, needle: [*:0]const c_char) callconv(.c) ?[*:0]c_char {
156 return @constCast(haystack[std.mem.find(u8, std.mem.span(@as([*:0]const u8, @ptrCast(haystack))), std.mem.span(@as([*:0]const u8, @ptrCast(needle)))) orelse return null ..]);
157}
158
159fn strtok(noalias maybe_str: ?[*:0]c_char, noalias values: [*:0]const c_char) callconv(.c) ?[*:0]c_char {
160 const state = struct {
161 var str: ?[*:0]c_char = null;
162 };
163
164 return strtok_r(maybe_str, values, &state.str);
165}
166
167// strlen is in compiler_rt
168
169fn strtok_r(noalias maybe_str: ?[*:0]c_char, noalias values: [*:0]const c_char, noalias state: *?[*:0]c_char) callconv(.c) ?[*:0]c_char {
170 const str = if (maybe_str) |str|
171 str
172 else if (state.*) |state_str|
173 state_str
174 else
175 return null;
176
177 const str_bytes = std.mem.span(@as([*:0]u8, @ptrCast(str)));
178 const values_bytes = std.mem.span(@as([*:0]const u8, @ptrCast(values)));
179 const tok_start = std.mem.findNone(u8, str_bytes, values_bytes) orelse return null;
180
181 if (std.mem.findAnyPos(u8, str_bytes, tok_start, values_bytes)) |tok_end| {
182 str[tok_end] = 0;
183 state.* = str[tok_end + 1 ..];
184 } else {
185 state.* = str[str_bytes.len..];
49 }186 }
50187
51 return @as(c_int, toLower(l[0])) - @as(c_int, toLower(r[0]));188 return str[tok_start..];
52}189}
53190
54fn __strcasecmp_l(s1: [*:0]const c_char, s2: [*:0]const c_char, locale: *anyopaque) callconv(.c) c_int {191fn stpcpy(noalias dst: [*]c_char, noalias src: [*:0]const c_char) callconv(.c) [*]c_char {
55 _ = locale;192 const src_len = std.mem.len(@as([*:0]const u8, @ptrCast(src)));
56 return strcasecmp(s1, s2);193 @memcpy(dst[0 .. src_len + 1], src[0 .. src_len + 1]);
194 return dst + src_len;
195}
196
197fn stpncpy(noalias dst: [*]c_char, noalias src: [*:0]const c_char, max: usize) callconv(.c) [*]c_char {
198 const src_len = strnlen(src, max);
199 const copying_len = @min(max, src_len);
200 @memcpy(dst[0..copying_len], src[0..copying_len]);
201 @memset(dst[copying_len..][0 .. max - copying_len], 0x00);
202 return dst + copying_len;
203}
204
205fn strnlen(str: [*:0]const c_char, max: usize) callconv(.c) usize {
206 return std.mem.findScalar(u8, @ptrCast(str[0..max]), 0) orelse max;
57}207}
58208
59fn strncasecmp(s1: [*:0]const c_char, s2: [*:0]const c_char, n: usize) callconv(.c) c_int {209fn memmem(haystack: *const anyopaque, haystack_len: usize, needle: *const anyopaque, needle_len: usize) callconv(.c) ?*anyopaque {
60 const toLower = std.ascii.toLower;210 const haystack_bytes: [*:0]const u8 = @ptrCast(haystack);
61 var l: [*:0]const u8 = @ptrCast(s1);211 const needle_bytes: [*:0]const u8 = @ptrCast(needle);
62 var r: [*:0]const u8 = @ptrCast(s2);212
63 var i = n - 1;213 return @constCast(haystack_bytes[std.mem.find(u8, haystack_bytes[0..haystack_len], needle_bytes[0..needle_len]) orelse return null ..]);
214}
64215
65 while (l[0] != 0 and r[0] != 0 and i != 0 and (l[0] == r[0] or toLower(l[0]) == toLower(r[0]))) {216fn strsep(maybe_str: *?[*:0]c_char, values: [*:0]const c_char) callconv(.c) ?[*]c_char {
66 l += 1;217 if (maybe_str.*) |str| {
67 r += 1;218 const values_bytes = std.mem.span(@as([*:0]const u8, @ptrCast(values)));
68 i -= 1;219 const str_bytes = std.mem.span(@as([*:0]u8, @ptrCast(str)));
220 const found = std.mem.findAny(u8, str_bytes, values_bytes) orelse {
221 maybe_str.* = null;
222 return str;
223 };
224
225 str[found] = 0;
226 maybe_str.* = str[found + 1 ..];
227 return str;
69 }228 }
70229
71 return @as(c_int, toLower(l[0])) - @as(c_int, toLower(r[0]));230 return null;
72}231}
73232
74fn __strncasecmp_l(s1: [*:0]const c_char, s2: [*:0]const c_char, n: usize, locale: *anyopaque) callconv(.c) c_int {233fn strlcat(dst: [*:0]c_char, src: [*:0]const c_char, dst_total_len: usize) callconv(.c) usize {
75 _ = locale;234 const dst_len = strnlen(dst, dst_total_len);
76 return strncasecmp(s1, s2, n);235 const src_bytes = std.mem.span(@as([*:0]const u8, @ptrCast(src)));
77}236
78237 if (dst_total_len == dst_len) return dst_len + src_bytes.len;
79test strcasecmp {238
80 try std.testing.expect(strcasecmp(@ptrCast("a"), @ptrCast("b")) < 0);239 const copying_len = @min(dst_total_len - (dst_len + 1), src_bytes.len);
81 try std.testing.expect(strcasecmp(@ptrCast("b"), @ptrCast("a")) > 0);240
82 try std.testing.expect(strcasecmp(@ptrCast("A"), @ptrCast("b")) < 0);241 @memcpy(dst[dst_len..][0..copying_len], src[0..copying_len]);
83 try std.testing.expect(strcasecmp(@ptrCast("b"), @ptrCast("A")) > 0);242 dst[dst_len + copying_len] = 0;
84 try std.testing.expect(strcasecmp(@ptrCast("A"), @ptrCast("A")) == 0);243 return dst_len + src_bytes.len;
85 try std.testing.expect(strcasecmp(@ptrCast("B"), @ptrCast("b")) == 0);244}
86 try std.testing.expect(strcasecmp(@ptrCast("bb"), @ptrCast("AA")) > 0);245
87}246fn strlcpy(dst: [*]c_char, src: [*:0]const c_char, dst_total_len: usize) callconv(.c) usize {
88247 const src_bytes = std.mem.span(@as([*:0]const u8, @ptrCast(src)));
89test strncasecmp {248 if (dst_total_len != 0) {
90 try std.testing.expect(strncasecmp(@ptrCast("a"), @ptrCast("b"), 1) < 0);249 const copying_len = @min(src_bytes.len, dst_total_len - 1);
91 try std.testing.expect(strncasecmp(@ptrCast("b"), @ptrCast("a"), 1) > 0);250 @memcpy(dst[0..copying_len], src[0..copying_len]);
92 try std.testing.expect(strncasecmp(@ptrCast("A"), @ptrCast("b"), 1) < 0);251 dst[copying_len] = 0;
93 try std.testing.expect(strncasecmp(@ptrCast("b"), @ptrCast("A"), 1) > 0);252 }
94 try std.testing.expect(strncasecmp(@ptrCast("A"), @ptrCast("A"), 1) == 0);253 return src_bytes.len;
95 try std.testing.expect(strncasecmp(@ptrCast("B"), @ptrCast("b"), 1) == 0);254}
96 try std.testing.expect(strncasecmp(@ptrCast("bb"), @ptrCast("AA"), 2) > 0);255
256fn memccpy(noalias dst: *anyopaque, noalias src: *const anyopaque, value: c_int, len: usize) callconv(.c) *anyopaque {
257 const dst_bytes: [*]u8 = @ptrCast(dst);
258 const src_bytes: [*]const u8 = @ptrCast(src);
259 const value_u8: u8 = @truncate(@as(c_uint, @bitCast(value)));
260 const copying_len = std.mem.findScalar(u8, src_bytes[0..len], value_u8) orelse len;
261 @memcpy(dst_bytes[0..copying_len], src_bytes[0..copying_len]);
262 return dst_bytes + copying_len;
263}
264
265fn explicit_bzero(ptr: *anyopaque, len: usize) callconv(.c) void {
266 const bytes: [*]u8 = @ptrCast(ptr);
267 std.crypto.secureZero(u8, bytes[0..len]);
268}
269
270fn strchrnul(str: [*:0]const c_char, value: c_int) callconv(.c) [*:0]c_char {
271 const str_u8: [*:0]const u8 = @ptrCast(str);
272 const len = std.mem.len(str_u8);
273
274 if (value == 0) return @constCast(str + len);
275 return @constCast(str[std.mem.findScalar(u8, str_u8[0..len], @truncate(@as(c_uint, @bitCast(value)))) orelse len ..]);
276}
277
278fn strcasestr(haystack: [*:0]const c_char, needle: [*:0]const c_char) callconv(.c) ?[*:0]c_char {
279 return @constCast(haystack[std.ascii.findIgnoreCase(std.mem.span(@as([*:0]const u8, @ptrCast(haystack))), std.mem.span(@as([*:0]const u8, @ptrCast(needle)))) orelse return null ..]);
280}
281
282fn memrchr(ptr: *const anyopaque, value: c_int, len: usize) callconv(.c) ?*anyopaque {
283 const bytes: [*]const u8 = @ptrCast(ptr);
284 return @constCast(bytes[std.mem.findScalarLast(u8, bytes[0..len], @truncate(@as(c_uint, @bitCast(value)))) orelse return null ..]);
285}
286
287fn mempcpy(noalias dst: *anyopaque, noalias src: *const anyopaque, len: usize) callconv(.c) *anyopaque {
288 const dst_bytes: [*]u8 = @ptrCast(dst);
289 const src_bytes: [*]const u8 = @ptrCast(src);
290 @memcpy(dst_bytes[0..len], src_bytes[0..len]);
291 return dst_bytes + len;
97}292}
98293
99test strncmp {294test strncmp {
lib/c/strings.zig+103-1
...@@ -1,8 +1,34 @@...@@ -1,8 +1,34 @@
1const std = @import("std");1const std = @import("std");
2const common = @import("common.zig");2const common = @import("common.zig");
3const builtin = @import("builtin");
34
4comptime {5comptime {
5 @export(&bzero, .{ .name = "bzero", .linkage = common.linkage, .visibility = common.visibility });6 if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
7 // bcmp is implemented in compiler_rt
8 @export(&bcopy, .{ .name = "bcopy", .linkage = common.linkage, .visibility = common.visibility });
9 @export(&bzero, .{ .name = "bzero", .linkage = common.linkage, .visibility = common.visibility });
10 @export(&index, .{ .name = "index", .linkage = common.linkage, .visibility = common.visibility });
11 @export(&rindex, .{ .name = "rindex", .linkage = common.linkage, .visibility = common.visibility });
12
13 @export(&ffs, .{ .name = "ffs", .linkage = common.linkage, .visibility = common.visibility });
14 @export(&ffsl, .{ .name = "ffsl", .linkage = common.linkage, .visibility = common.visibility });
15 @export(&ffsll, .{ .name = "ffsll", .linkage = common.linkage, .visibility = common.visibility });
16
17 @export(&strcasecmp, .{ .name = "strcasecmp", .linkage = common.linkage, .visibility = common.visibility });
18 @export(&strncasecmp, .{ .name = "strncasecmp", .linkage = common.linkage, .visibility = common.visibility });
19
20 @export(&__strcasecmp_l, .{ .name = "__strcasecmp_l", .linkage = common.linkage, .visibility = common.visibility });
21 @export(&__strncasecmp_l, .{ .name = "__strncasecmp_l", .linkage = common.linkage, .visibility = common.visibility });
22
23 @export(&__strcasecmp_l, .{ .name = "strcasecmp_l", .linkage = .weak, .visibility = common.visibility });
24 @export(&__strncasecmp_l, .{ .name = "strncasecmp_l", .linkage = .weak, .visibility = common.visibility });
25 }
26}
27
28fn bcopy(src: *const anyopaque, dst: *anyopaque, len: usize) callconv(.c) void {
29 const src_bytes: [*]const u8 = @ptrCast(src);
30 const dst_bytes: [*]u8 = @ptrCast(dst);
31 @memmove(dst_bytes[0..len], src_bytes[0..len]);
6}32}
733
8fn bzero(s: *anyopaque, n: usize) callconv(.c) void {34fn bzero(s: *anyopaque, n: usize) callconv(.c) void {
...@@ -10,6 +36,52 @@ fn bzero(s: *anyopaque, n: usize) callconv(.c) void {...@@ -10,6 +36,52 @@ fn bzero(s: *anyopaque, n: usize) callconv(.c) void {
10 @memset(s_cast[0..n], 0);36 @memset(s_cast[0..n], 0);
11}37}
1238
39fn index(str: [*:0]const c_char, value: c_int) callconv(.c) ?[*:0]c_char {
40 return @constCast(str[std.mem.findScalar(u8, std.mem.span(@as([*:0]const u8, @ptrCast(str))), @truncate(@as(c_uint, @bitCast(value)))) orelse return null ..]);
41}
42
43fn rindex(str: [*:0]const c_char, value: c_int) callconv(.c) ?[*:0]c_char {
44 return @constCast(str[std.mem.findScalarLast(u8, std.mem.span(@as([*:0]const u8, @ptrCast(str))), @truncate(@as(c_uint, @bitCast(value)))) orelse return null ..]);
45}
46
47fn firstBitSet(comptime T: type, value: T) T {
48 return @bitSizeOf(T) - @clz(value);
49}
50
51fn ffs(i: c_int) callconv(.c) c_int {
52 return firstBitSet(c_int, i);
53}
54
55fn ffsl(i: c_long) callconv(.c) c_long {
56 return firstBitSet(c_long, i);
57}
58
59fn ffsll(i: c_longlong) callconv(.c) c_longlong {
60 return firstBitSet(c_longlong, i);
61}
62
63fn strcasecmp(a: [*:0]const c_char, b: [*:0]const c_char) callconv(.c) c_int {
64 return strncasecmp(a, b, std.math.maxInt(usize));
65}
66
67fn __strcasecmp_l(a: [*:0]const c_char, b: [*:0]const c_char, locale: *anyopaque) callconv(.c) c_int {
68 _ = locale;
69 return strcasecmp(a, b);
70}
71
72fn strncasecmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) callconv(.c) c_int {
73 return switch (std.ascii.boundedOrderIgnoreCaseZ(@ptrCast(a), @ptrCast(b), max)) {
74 .eq => 0,
75 .gt => 1,
76 .lt => -1,
77 };
78}
79
80fn __strncasecmp_l(a: [*:0]const c_char, b: [*:0]const c_char, n: usize, locale: *anyopaque) callconv(.c) c_int {
81 _ = locale;
82 return strncasecmp(a, b, n);
83}
84
13test bzero {85test bzero {
14 var array: [10]u8 = [_]u8{ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };86 var array: [10]u8 = [_]u8{ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
15 var a = std.mem.zeroes([array.len]u8);87 var a = std.mem.zeroes([array.len]u8);
...@@ -17,3 +89,33 @@ test bzero {...@@ -17,3 +89,33 @@ test bzero {
17 bzero(&array[0], 9);89 bzero(&array[0], 9);
18 try std.testing.expect(std.mem.eql(u8, &array, &a));90 try std.testing.expect(std.mem.eql(u8, &array, &a));
19}91}
92
93test firstBitSet {
94 try std.testing.expectEqual(0, firstBitSet(usize, 0));
95
96 for (0..@bitSizeOf(usize)) |i| {
97 const bit = @as(usize, 1) << @intCast(i);
98
99 try std.testing.expectEqual(i + 1, firstBitSet(usize, bit));
100 }
101}
102
103test strcasecmp {
104 try std.testing.expect(strcasecmp(@ptrCast("a"), @ptrCast("b")) < 0);
105 try std.testing.expect(strcasecmp(@ptrCast("b"), @ptrCast("a")) > 0);
106 try std.testing.expect(strcasecmp(@ptrCast("A"), @ptrCast("b")) < 0);
107 try std.testing.expect(strcasecmp(@ptrCast("b"), @ptrCast("A")) > 0);
108 try std.testing.expect(strcasecmp(@ptrCast("A"), @ptrCast("A")) == 0);
109 try std.testing.expect(strcasecmp(@ptrCast("B"), @ptrCast("b")) == 0);
110 try std.testing.expect(strcasecmp(@ptrCast("bb"), @ptrCast("AA")) > 0);
111}
112
113test strncasecmp {
114 try std.testing.expect(strncasecmp(@ptrCast("a"), @ptrCast("b"), 1) < 0);
115 try std.testing.expect(strncasecmp(@ptrCast("b"), @ptrCast("a"), 1) > 0);
116 try std.testing.expect(strncasecmp(@ptrCast("A"), @ptrCast("b"), 1) < 0);
117 try std.testing.expect(strncasecmp(@ptrCast("b"), @ptrCast("A"), 1) > 0);
118 try std.testing.expect(strncasecmp(@ptrCast("A"), @ptrCast("A"), 1) == 0);
119 try std.testing.expect(strncasecmp(@ptrCast("B"), @ptrCast("b"), 1) == 0);
120 try std.testing.expect(strncasecmp(@ptrCast("bb"), @ptrCast("AA"), 2) > 0);
121}
lib/libc/mingw/misc/mempcpy.c deleted-12
...@@ -1,12 +0,0 @@
1#define __CRT__NO_INLINE
2#include <string.h>
3
4void * __cdecl
5mempcpy (void *d, const void *s, size_t len)
6{
7 char *r = ((char *) d) + len;
8 if (len != 0)
9 memcpy (d, s, len);
10 return r;
11}
12
lib/libc/mingw/misc/strnlen.c deleted-11
...@@ -1,11 +0,0 @@
1#define __CRT__NO_INLINE
2#include <string.h>
3
4size_t __cdecl strnlen (const char *s, size_t maxlen)
5{
6 const char *s2 = s;
7 while ((size_t) (s2 - s) < maxlen && *s2)
8 ++s2;
9 return s2 - s;
10}
11
lib/libc/mingw/stdio/strtok_r.c deleted-98
...@@ -1,98 +0,0 @@
1/*-
2 * Copyright (c) 1998 Softweyr LLC. All rights reserved.
3 *
4 * strtok_r, from Berkeley strtok
5 * Oct 13, 1998 by Wes Peters <wes@softweyr.com>
6 *
7 * Copyright (c) 1988, 1993
8 * The Regents of the University of California. All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notices, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notices, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE
26 * REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#define _POSIX_SOURCE 1
36#include <string.h>
37
38/*
39 * strtok_r documentation:
40 * http://pubs.opengroup.org/onlinepubs/009695399/functions/strtok.html
41 *
42 * Implementation:
43 * http://svnweb.freebsd.org/base/head/lib/libc/string/strtok.c?view=co
44 *
45 * strtok_r cannot completely be implemented by strtok because of the internal state.
46 * It breaks when used on 2 strings where they are scanned A, B then A, B.
47 * Thread-safety is not the issue.
48 *
49 * Sample strtok implemenatation, note the internal state:
50 * char *strtok(char *s, const char *d) { static char *t; return strtok_r(s,d,t); }
51 *
52 */
53
54char *
55strtok_r(char * __restrict s, const char * __restrict delim, char ** __restrict last)
56{
57 char *spanp, *tok;
58 int c, sc;
59
60 if (s == NULL && (s = *last) == NULL)
61 return (NULL);
62
63 /*
64 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
65 */
66cont:
67 c = *s++;
68 for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
69 if (c == sc)
70 goto cont;
71 }
72
73 if (c == 0) { /* no non-delimiter characters */
74 *last = NULL;
75 return (NULL);
76 }
77 tok = s - 1;
78
79 /*
80 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
81 * Note that delim must have one NUL; we stop if we see that, too.
82 */
83 for (;;) {
84 c = *s++;
85 spanp = (char *)delim;
86 do {
87 if ((sc = *spanp++) == c) {
88 if (c == 0)
89 s = NULL;
90 else
91 s[-1] = '\0';
92 *last = s;
93 return (tok);
94 }
95 } while (sc != 0);
96 }
97 /* NOTREACHED */
98}
lib/libc/musl/src/string/bcopy.c deleted-8
...@@ -1,8 +0,0 @@
1#define _BSD_SOURCE
2#include <string.h>
3#include <strings.h>
4
5void bcopy(const void *s1, void *s2, size_t n)
6{
7 memmove(s2, s1, n);
8}
lib/libc/musl/src/string/explicit_bzero.c deleted-8
...@@ -1,8 +0,0 @@
1#define _BSD_SOURCE
2#include <string.h>
3
4void explicit_bzero(void *d, size_t n)
5{
6 d = memset(d, 0, n);
7 __asm__ __volatile__ ("" : : "r"(d) : "memory");
8}
lib/libc/musl/src/string/index.c deleted-8
...@@ -1,8 +0,0 @@
1#define _BSD_SOURCE
2#include <string.h>
3#include <strings.h>
4
5char *index(const char *s, int c)
6{
7 return strchr(s, c);
8}
lib/libc/musl/src/string/memccpy.c deleted-34
...@@ -1,34 +0,0 @@
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4
5#define ALIGN (sizeof(size_t)-1)
6#define ONES ((size_t)-1/UCHAR_MAX)
7#define HIGHS (ONES * (UCHAR_MAX/2+1))
8#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
9
10void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n)
11{
12 unsigned char *d = dest;
13 const unsigned char *s = src;
14
15 c = (unsigned char)c;
16#ifdef __GNUC__
17 typedef size_t __attribute__((__may_alias__)) word;
18 word *wd;
19 const word *ws;
20 if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) {
21 for (; ((uintptr_t)s & ALIGN) && n && (*d=*s)!=c; n--, s++, d++);
22 if ((uintptr_t)s & ALIGN) goto tail;
23 size_t k = ONES * c;
24 wd=(void *)d; ws=(const void *)s;
25 for (; n>=sizeof(size_t) && !HASZERO(*ws^k);
26 n-=sizeof(size_t), ws++, wd++) *wd = *ws;
27 d=(void *)wd; s=(const void *)ws;
28 }
29#endif
30 for (; n && (*d=*s)!=c; n--, s++, d++);
31tail:
32 if (n) return d+1;
33 return 0;
34}
lib/libc/musl/src/string/memchr.c deleted-27
...@@ -1,27 +0,0 @@
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4
5#define SS (sizeof(size_t))
6#define ALIGN (sizeof(size_t)-1)
7#define ONES ((size_t)-1/UCHAR_MAX)
8#define HIGHS (ONES * (UCHAR_MAX/2+1))
9#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
10
11void *memchr(const void *src, int c, size_t n)
12{
13 const unsigned char *s = src;
14 c = (unsigned char)c;
15#ifdef __GNUC__
16 for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--);
17 if (n && *s != c) {
18 typedef size_t __attribute__((__may_alias__)) word;
19 const word *w;
20 size_t k = ONES * c;
21 for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS);
22 s = (const void *)w;
23 }
24#endif
25 for (; n && *s != c; s++, n--);
26 return n ? (void *)s : 0;
27}
lib/libc/musl/src/string/memmem.c deleted-149
...@@ -1,149 +0,0 @@
1#define _GNU_SOURCE
2#include <string.h>
3#include <stdint.h>
4
5static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
6{
7 uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1];
8 for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++)
9 if (hw == nw) return (char *)h-2;
10 return hw == nw ? (char *)h-2 : 0;
11}
12
13static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
14{
15 uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8;
16 uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8;
17 for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8)
18 if (hw == nw) return (char *)h-3;
19 return hw == nw ? (char *)h-3 : 0;
20}
21
22static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
23{
24 uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3];
25 uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3];
26 for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++)
27 if (hw == nw) return (char *)h-4;
28 return hw == nw ? (char *)h-4 : 0;
29}
30
31#define MAX(a,b) ((a)>(b)?(a):(b))
32#define MIN(a,b) ((a)<(b)?(a):(b))
33
34#define BITOP(a,b,op) \
35 ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
36
37static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const unsigned char *n, size_t l)
38{
39 size_t i, ip, jp, k, p, ms, p0, mem, mem0;
40 size_t byteset[32 / sizeof(size_t)] = { 0 };
41 size_t shift[256];
42
43 /* Computing length of needle and fill shift table */
44 for (i=0; i<l; i++)
45 BITOP(byteset, n[i], |=), shift[n[i]] = i+1;
46
47 /* Compute maximal suffix */
48 ip = -1; jp = 0; k = p = 1;
49 while (jp+k<l) {
50 if (n[ip+k] == n[jp+k]) {
51 if (k == p) {
52 jp += p;
53 k = 1;
54 } else k++;
55 } else if (n[ip+k] > n[jp+k]) {
56 jp += k;
57 k = 1;
58 p = jp - ip;
59 } else {
60 ip = jp++;
61 k = p = 1;
62 }
63 }
64 ms = ip;
65 p0 = p;
66
67 /* And with the opposite comparison */
68 ip = -1; jp = 0; k = p = 1;
69 while (jp+k<l) {
70 if (n[ip+k] == n[jp+k]) {
71 if (k == p) {
72 jp += p;
73 k = 1;
74 } else k++;
75 } else if (n[ip+k] < n[jp+k]) {
76 jp += k;
77 k = 1;
78 p = jp - ip;
79 } else {
80 ip = jp++;
81 k = p = 1;
82 }
83 }
84 if (ip+1 > ms+1) ms = ip;
85 else p = p0;
86
87 /* Periodic needle? */
88 if (memcmp(n, n+p, ms+1)) {
89 mem0 = 0;
90 p = MAX(ms, l-ms-1) + 1;
91 } else mem0 = l-p;
92 mem = 0;
93
94 /* Search loop */
95 for (;;) {
96 /* If remainder of haystack is shorter than needle, done */
97 if (z-h < l) return 0;
98
99 /* Check last byte first; advance by shift on mismatch */
100 if (BITOP(byteset, h[l-1], &)) {
101 k = l-shift[h[l-1]];
102 if (k) {
103 if (k < mem) k = mem;
104 h += k;
105 mem = 0;
106 continue;
107 }
108 } else {
109 h += l;
110 mem = 0;
111 continue;
112 }
113
114 /* Compare right half */
115 for (k=MAX(ms+1,mem); k<l && n[k] == h[k]; k++);
116 if (k < l) {
117 h += k-ms;
118 mem = 0;
119 continue;
120 }
121 /* Compare left half */
122 for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
123 if (k <= mem) return (char *)h;
124 h += p;
125 mem = mem0;
126 }
127}
128
129void *memmem(const void *h0, size_t k, const void *n0, size_t l)
130{
131 const unsigned char *h = h0, *n = n0;
132
133 /* Return immediately on empty needle */
134 if (!l) return (void *)h;
135
136 /* Return immediately when needle is longer than haystack */
137 if (k<l) return 0;
138
139 /* Use faster algorithms for short needles */
140 h = memchr(h0, *n, k);
141 if (!h || l==1) return (void *)h;
142 k -= h - (const unsigned char *)h0;
143 if (k<l) return 0;
144 if (l==2) return twobyte_memmem(h, k, n);
145 if (l==3) return threebyte_memmem(h, k, n);
146 if (l==4) return fourbyte_memmem(h, k, n);
147
148 return twoway_memmem(h, h+k, n, l);
149}
lib/libc/musl/src/string/mempcpy.c deleted-7
...@@ -1,7 +0,0 @@
1#define _GNU_SOURCE
2#include <string.h>
3
4void *mempcpy(void *dest, const void *src, size_t n)
5{
6 return (char *)memcpy(dest, src, n) + n;
7}
lib/libc/musl/src/string/memrchr.c deleted-11
...@@ -1,11 +0,0 @@
1#include <string.h>
2
3void *__memrchr(const void *m, int c, size_t n)
4{
5 const unsigned char *s = m;
6 c = (unsigned char)c;
7 while (n--) if (s[n]==c) return (void *)(s+n);
8 return 0;
9}
10
11weak_alias(__memrchr, memrchr);
lib/libc/musl/src/string/rindex.c deleted-8
...@@ -1,8 +0,0 @@
1#define _BSD_SOURCE
2#include <string.h>
3#include <strings.h>
4
5char *rindex(const char *s, int c)
6{
7 return strrchr(s, c);
8}
lib/libc/musl/src/string/stpcpy.c deleted-29
...@@ -1,29 +0,0 @@
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4
5#define ALIGN (sizeof(size_t))
6#define ONES ((size_t)-1/UCHAR_MAX)
7#define HIGHS (ONES * (UCHAR_MAX/2+1))
8#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
9
10char *__stpcpy(char *restrict d, const char *restrict s)
11{
12#ifdef __GNUC__
13 typedef size_t __attribute__((__may_alias__)) word;
14 word *wd;
15 const word *ws;
16 if ((uintptr_t)s % ALIGN == (uintptr_t)d % ALIGN) {
17 for (; (uintptr_t)s % ALIGN; s++, d++)
18 if (!(*d=*s)) return d;
19 wd=(void *)d; ws=(const void *)s;
20 for (; !HASZERO(*ws); *wd++ = *ws++);
21 d=(void *)wd; s=(const void *)ws;
22 }
23#endif
24 for (; (*d=*s); s++, d++);
25
26 return d;
27}
28
29weak_alias(__stpcpy, stpcpy);
lib/libc/musl/src/string/stpncpy.c deleted-32
...@@ -1,32 +0,0 @@
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4
5#define ALIGN (sizeof(size_t)-1)
6#define ONES ((size_t)-1/UCHAR_MAX)
7#define HIGHS (ONES * (UCHAR_MAX/2+1))
8#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
9
10char *__stpncpy(char *restrict d, const char *restrict s, size_t n)
11{
12#ifdef __GNUC__
13 typedef size_t __attribute__((__may_alias__)) word;
14 word *wd;
15 const word *ws;
16 if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) {
17 for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++);
18 if (!n || !*s) goto tail;
19 wd=(void *)d; ws=(const void *)s;
20 for (; n>=sizeof(size_t) && !HASZERO(*ws);
21 n-=sizeof(size_t), ws++, wd++) *wd = *ws;
22 d=(void *)wd; s=(const void *)ws;
23 }
24#endif
25 for (; n && (*d=*s); n--, s++, d++);
26tail:
27 memset(d, 0, n);
28 return d;
29}
30
31weak_alias(__stpncpy, stpncpy);
32
lib/libc/musl/src/string/strcasestr.c deleted-9
...@@ -1,9 +0,0 @@
1#define _GNU_SOURCE
2#include <string.h>
3
4char *strcasestr(const char *h, const char *n)
5{
6 size_t l = strlen(n);
7 for (; *h; h++) if (!strncasecmp(h, n, l)) return (char *)h;
8 return 0;
9}
lib/libc/musl/src/string/strcat.c deleted-7
...@@ -1,7 +0,0 @@
1#include <string.h>
2
3char *strcat(char *restrict dest, const char *restrict src)
4{
5 strcpy(dest + strlen(dest), src);
6 return dest;
7}
lib/libc/musl/src/string/strchr.c deleted-7
...@@ -1,7 +0,0 @@
1#include <string.h>
2
3char *strchr(const char *s, int c)
4{
5 char *r = __strchrnul(s, c);
6 return *(unsigned char *)r == (unsigned char)c ? r : 0;
7}
lib/libc/musl/src/string/strchrnul.c deleted-28
...@@ -1,28 +0,0 @@
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4
5#define ALIGN (sizeof(size_t))
6#define ONES ((size_t)-1/UCHAR_MAX)
7#define HIGHS (ONES * (UCHAR_MAX/2+1))
8#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
9
10char *__strchrnul(const char *s, int c)
11{
12 c = (unsigned char)c;
13 if (!c) return (char *)s + strlen(s);
14
15#ifdef __GNUC__
16 typedef size_t __attribute__((__may_alias__)) word;
17 const word *w;
18 for (; (uintptr_t)s % ALIGN; s++)
19 if (!*s || *(unsigned char *)s == c) return (char *)s;
20 size_t k = ONES * c;
21 for (w = (void *)s; !HASZERO(*w) && !HASZERO(*w^k); w++);
22 s = (void *)w;
23#endif
24 for (; *s && *(unsigned char *)s != c; s++);
25 return (char *)s;
26}
27
28weak_alias(__strchrnul, strchrnul);
lib/libc/musl/src/string/strcpy.c deleted-7
...@@ -1,7 +0,0 @@
1#include <string.h>
2
3char *strcpy(char *restrict dest, const char *restrict src)
4{
5 __stpcpy(dest, src);
6 return dest;
7}
lib/libc/musl/src/string/strcspn.c deleted-17
...@@ -1,17 +0,0 @@
1#include <string.h>
2
3#define BITOP(a,b,op) \
4 ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
5
6size_t strcspn(const char *s, const char *c)
7{
8 const char *a = s;
9 size_t byteset[32/sizeof(size_t)];
10
11 if (!c[0] || !c[1]) return __strchrnul(s, *c)-a;
12
13 memset(byteset, 0, sizeof byteset);
14 for (; *c && BITOP(byteset, *(unsigned char *)c, |=); c++);
15 for (; *s && !BITOP(byteset, *(unsigned char *)s, &); s++);
16 return s-a;
17}
lib/libc/musl/src/string/strlcat.c deleted-9
...@@ -1,9 +0,0 @@
1#define _BSD_SOURCE
2#include <string.h>
3
4size_t strlcat(char *d, const char *s, size_t n)
5{
6 size_t l = strnlen(d, n);
7 if (l == n) return l + strlen(s);
8 return l + strlcpy(d+l, s, n-l);
9}
lib/libc/musl/src/string/strlcpy.c deleted-34
...@@ -1,34 +0,0 @@
1#define _BSD_SOURCE
2#include <string.h>
3#include <stdint.h>
4#include <limits.h>
5
6#define ALIGN (sizeof(size_t)-1)
7#define ONES ((size_t)-1/UCHAR_MAX)
8#define HIGHS (ONES * (UCHAR_MAX/2+1))
9#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
10
11size_t strlcpy(char *d, const char *s, size_t n)
12{
13 char *d0 = d;
14 size_t *wd;
15
16 if (!n--) goto finish;
17#ifdef __GNUC__
18 typedef size_t __attribute__((__may_alias__)) word;
19 const word *ws;
20 if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) {
21 for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++);
22 if (n && *s) {
23 wd=(void *)d; ws=(const void *)s;
24 for (; n>=sizeof(size_t) && !HASZERO(*ws);
25 n-=sizeof(size_t), ws++, wd++) *wd = *ws;
26 d=(void *)wd; s=(const void *)ws;
27 }
28 }
29#endif
30 for (; n && (*d=*s); n--, s++, d++);
31 *d = 0;
32finish:
33 return d-d0 + strlen(s);
34}
lib/libc/musl/src/string/strncat.c deleted-10
...@@ -1,10 +0,0 @@
1#include <string.h>
2
3char *strncat(char *restrict d, const char *restrict s, size_t n)
4{
5 char *a = d;
6 d += strlen(d);
7 while (n && *s) n--, *d++ = *s++;
8 *d++ = 0;
9 return a;
10}
lib/libc/musl/src/string/strncpy.c deleted-7
...@@ -1,7 +0,0 @@
1#include <string.h>
2
3char *strncpy(char *restrict d, const char *restrict s, size_t n)
4{
5 __stpncpy(d, s, n);
6 return d;
7}
lib/libc/musl/src/string/strnlen.c deleted-7
...@@ -1,7 +0,0 @@
1#include <string.h>
2
3size_t strnlen(const char *s, size_t n)
4{
5 const char *p = memchr(s, 0, n);
6 return p ? p-s : n;
7}
lib/libc/musl/src/string/strpbrk.c deleted-7
...@@ -1,7 +0,0 @@
1#include <string.h>
2
3char *strpbrk(const char *s, const char *b)
4{
5 s += strcspn(s, b);
6 return *s ? (char *)s : 0;
7}
lib/libc/musl/src/string/strrchr.c deleted-6
...@@ -1,6 +0,0 @@
1#include <string.h>
2
3char *strrchr(const char *s, int c)
4{
5 return __memrchr(s, c, strlen(s) + 1);
6}
lib/libc/musl/src/string/strsep.c deleted-13
...@@ -1,13 +0,0 @@
1#define _GNU_SOURCE
2#include <string.h>
3
4char *strsep(char **str, const char *sep)
5{
6 char *s = *str, *end;
7 if (!s) return NULL;
8 end = s + strcspn(s, sep);
9 if (*end) *end++ = 0;
10 else end = 0;
11 *str = end;
12 return s;
13}
lib/libc/musl/src/string/strspn.c deleted-20
...@@ -1,20 +0,0 @@
1#include <string.h>
2
3#define BITOP(a,b,op) \
4 ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
5
6size_t strspn(const char *s, const char *c)
7{
8 const char *a = s;
9 size_t byteset[32/sizeof(size_t)] = { 0 };
10
11 if (!c[0]) return 0;
12 if (!c[1]) {
13 for (; *s == *c; s++);
14 return s-a;
15 }
16
17 for (; *c && BITOP(byteset, *(unsigned char *)c, |=); c++);
18 for (; *s && BITOP(byteset, *(unsigned char *)s, &); s++);
19 return s-a;
20}
lib/libc/musl/src/string/strstr.c deleted-154
...@@ -1,154 +0,0 @@
1#include <string.h>
2#include <stdint.h>
3
4static char *twobyte_strstr(const unsigned char *h, const unsigned char *n)
5{
6 uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1];
7 for (h++; *h && hw != nw; hw = hw<<8 | *++h);
8 return *h ? (char *)h-1 : 0;
9}
10
11static char *threebyte_strstr(const unsigned char *h, const unsigned char *n)
12{
13 uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8;
14 uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8;
15 for (h+=2; *h && hw != nw; hw = (hw|*++h)<<8);
16 return *h ? (char *)h-2 : 0;
17}
18
19static char *fourbyte_strstr(const unsigned char *h, const unsigned char *n)
20{
21 uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3];
22 uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3];
23 for (h+=3; *h && hw != nw; hw = hw<<8 | *++h);
24 return *h ? (char *)h-3 : 0;
25}
26
27#define MAX(a,b) ((a)>(b)?(a):(b))
28#define MIN(a,b) ((a)<(b)?(a):(b))
29
30#define BITOP(a,b,op) \
31 ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
32
33static char *twoway_strstr(const unsigned char *h, const unsigned char *n)
34{
35 const unsigned char *z;
36 size_t l, ip, jp, k, p, ms, p0, mem, mem0;
37 size_t byteset[32 / sizeof(size_t)] = { 0 };
38 size_t shift[256];
39
40 /* Computing length of needle and fill shift table */
41 for (l=0; n[l] && h[l]; l++)
42 BITOP(byteset, n[l], |=), shift[n[l]] = l+1;
43 if (n[l]) return 0; /* hit the end of h */
44
45 /* Compute maximal suffix */
46 ip = -1; jp = 0; k = p = 1;
47 while (jp+k<l) {
48 if (n[ip+k] == n[jp+k]) {
49 if (k == p) {
50 jp += p;
51 k = 1;
52 } else k++;
53 } else if (n[ip+k] > n[jp+k]) {
54 jp += k;
55 k = 1;
56 p = jp - ip;
57 } else {
58 ip = jp++;
59 k = p = 1;
60 }
61 }
62 ms = ip;
63 p0 = p;
64
65 /* And with the opposite comparison */
66 ip = -1; jp = 0; k = p = 1;
67 while (jp+k<l) {
68 if (n[ip+k] == n[jp+k]) {
69 if (k == p) {
70 jp += p;
71 k = 1;
72 } else k++;
73 } else if (n[ip+k] < n[jp+k]) {
74 jp += k;
75 k = 1;
76 p = jp - ip;
77 } else {
78 ip = jp++;
79 k = p = 1;
80 }
81 }
82 if (ip+1 > ms+1) ms = ip;
83 else p = p0;
84
85 /* Periodic needle? */
86 if (memcmp(n, n+p, ms+1)) {
87 mem0 = 0;
88 p = MAX(ms, l-ms-1) + 1;
89 } else mem0 = l-p;
90 mem = 0;
91
92 /* Initialize incremental end-of-haystack pointer */
93 z = h;
94
95 /* Search loop */
96 for (;;) {
97 /* Update incremental end-of-haystack pointer */
98 if (z-h < l) {
99 /* Fast estimate for MAX(l,63) */
100 size_t grow = l | 63;
101 const unsigned char *z2 = memchr(z, 0, grow);
102 if (z2) {
103 z = z2;
104 if (z-h < l) return 0;
105 } else z += grow;
106 }
107
108 /* Check last byte first; advance by shift on mismatch */
109 if (BITOP(byteset, h[l-1], &)) {
110 k = l-shift[h[l-1]];
111 if (k) {
112 if (k < mem) k = mem;
113 h += k;
114 mem = 0;
115 continue;
116 }
117 } else {
118 h += l;
119 mem = 0;
120 continue;
121 }
122
123 /* Compare right half */
124 for (k=MAX(ms+1,mem); n[k] && n[k] == h[k]; k++);
125 if (n[k]) {
126 h += k-ms;
127 mem = 0;
128 continue;
129 }
130 /* Compare left half */
131 for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--);
132 if (k <= mem) return (char *)h;
133 h += p;
134 mem = mem0;
135 }
136}
137
138char *strstr(const char *h, const char *n)
139{
140 /* Return immediately on empty needle */
141 if (!n[0]) return (char *)h;
142
143 /* Use faster algorithms for short needles */
144 h = strchr(h, *n);
145 if (!h || !n[1]) return (char *)h;
146 if (!h[1]) return 0;
147 if (!n[2]) return twobyte_strstr((void *)h, (void *)n);
148 if (!h[2]) return 0;
149 if (!n[3]) return threebyte_strstr((void *)h, (void *)n);
150 if (!h[3]) return 0;
151 if (!n[4]) return fourbyte_strstr((void *)h, (void *)n);
152
153 return twoway_strstr((void *)h, (void *)n);
154}
lib/libc/musl/src/string/strtok.c deleted-13
...@@ -1,13 +0,0 @@
1#include <string.h>
2
3char *strtok(char *restrict s, const char *restrict sep)
4{
5 static char *p;
6 if (!s && !(s = p)) return NULL;
7 s += strspn(s, sep);
8 if (!*s) return p = 0;
9 p = s + strcspn(s, sep);
10 if (*p) *p++ = 0;
11 else p = 0;
12 return s;
13}
lib/libc/musl/src/string/strtok_r.c deleted-12
...@@ -1,12 +0,0 @@
1#include <string.h>
2
3char *strtok_r(char *restrict s, const char *restrict sep, char **restrict p)
4{
5 if (!s && !(s = *p)) return NULL;
6 s += strspn(s, sep);
7 if (!*s) return *p = 0;
8 *p = s + strcspn(s, sep);
9 if (**p) *(*p)++ = 0;
10 else *p = 0;
11 return s;
12}
lib/libc/musl/src/string/wcstok.c deleted-12
...@@ -1,12 +0,0 @@
1#include <wchar.h>
2
3wchar_t *wcstok(wchar_t *restrict s, const wchar_t *restrict sep, wchar_t **restrict p)
4{
5 if (!s && !(s = *p)) return NULL;
6 s += wcsspn(s, sep);
7 if (!*s) return *p = 0;
8 *p = s + wcscspn(s, sep);
9 if (**p) *(*p)++ = 0;
10 else *p = 0;
11 return s;
12}
lib/libc/wasi/libc-top-half/musl/src/string/memchr.c deleted-89
...@@ -1,89 +0,0 @@
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4
5#ifdef __wasm_simd128__
6#include <wasm_simd128.h>
7#endif
8
9#define SS (sizeof(size_t))
10#define ALIGN (sizeof(size_t)-1)
11#define ONES ((size_t)-1/UCHAR_MAX)
12#define HIGHS (ONES * (UCHAR_MAX/2+1))
13#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
14
15void *memchr(const void *src, int c, size_t n)
16{
17#if defined(__wasm_simd128__) && defined(__wasilibc_simd_string)
18 // Skip Clang 19 and Clang 20 which have a bug (llvm/llvm-project#146574)
19 // which results in an ICE when inline assembly is used with a vector result.
20#if __clang_major__ != 19 && __clang_major__ != 20
21 // When n is zero, a function that locates a character finds no occurrence.
22 // Otherwise, decrement n to ensure sub_overflow overflows
23 // when n would go equal-to-or-below zero.
24 if (!n--) {
25 return NULL;
26 }
27
28 // Note that reading before/after the allocation of a pointer is UB in
29 // C, so inline assembly is used to generate the exact machine
30 // instruction we want with opaque semantics to the compiler to avoid
31 // the UB.
32 uintptr_t align = (uintptr_t)src % sizeof(v128_t);
33 uintptr_t addr = (uintptr_t)src - align;
34 v128_t vc = wasm_i8x16_splat(c);
35
36 for (;;) {
37 v128_t v;
38 __asm__ (
39 "local.get %1\n"
40 "v128.load 0\n"
41 "local.set %0\n"
42 : "=r"(v)
43 : "r"(addr)
44 : "memory");
45 v128_t cmp = wasm_i8x16_eq(v, vc);
46 // Bitmask is slow on AArch64, any_true is much faster.
47 if (wasm_v128_any_true(cmp)) {
48 // Clear the bits corresponding to align (little-endian)
49 // so we can count trailing zeros.
50 int mask = wasm_i8x16_bitmask(cmp) >> align << align;
51 // At least one bit will be set, unless align cleared them.
52 // Knowing this helps the compiler if it unrolls the loop.
53 __builtin_assume(mask || align);
54 // If the mask became zero because of align,
55 // it's as if we didn't find anything.
56 if (mask) {
57 // Find the offset of the first one bit (little-endian).
58 // That's a match, unless it is beyond the end of the object.
59 // Recall that we decremented n, so less-than-or-equal-to is correct.
60 size_t ctz = __builtin_ctz(mask);
61 return ctz - align <= n ? (char *)src + (addr + ctz - (uintptr_t)src)
62 : NULL;
63 }
64 }
65 // Decrement n; if it overflows we're done.
66 if (__builtin_sub_overflow(n, sizeof(v128_t) - align, &n)) {
67 return NULL;
68 }
69 align = 0;
70 addr += sizeof(v128_t);
71 }
72#endif
73#endif
74
75 const unsigned char *s = src;
76 c = (unsigned char)c;
77#ifdef __GNUC__
78 for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--);
79 if (n && *s != c) {
80 typedef size_t __attribute__((__may_alias__)) word;
81 const word *w;
82 size_t k = ONES * c;
83 for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS);
84 s = (const void *)w;
85 }
86#endif
87 for (; n && *s != c; s++, n--);
88 return n ? (void *)s : 0;
89}
lib/libc/wasi/libc-top-half/musl/src/string/memrchr.c deleted-33
...@@ -1,33 +0,0 @@
1#include <string.h>
2
3#ifdef __wasm_simd128__
4#include <wasm_simd128.h>
5#endif
6
7void *__memrchr(const void *m, int c, size_t n)
8{
9#if defined(__wasm_simd128__) && defined(__wasilibc_simd_string)
10 // memrchr is allowed to read up to n bytes from the object.
11 // Search backward for the last matching character.
12 const v128_t *v = (v128_t *)((char *)m + n);
13 const v128_t vc = wasm_i8x16_splat(c);
14 for (; n >= sizeof(v128_t); n -= sizeof(v128_t)) {
15 const v128_t cmp = wasm_i8x16_eq(wasm_v128_load(--v), vc);
16 // Bitmask is slow on AArch64, any_true is much faster.
17 if (wasm_v128_any_true(cmp)) {
18 // Find the offset of the last one bit (little-endian).
19 // The leading 16 bits of the bitmask are always zero,
20 // and to be ignored.
21 size_t clz = __builtin_clz(wasm_i8x16_bitmask(cmp)) - 16;
22 return (char *)(v + 1) - (clz + 1);
23 }
24 }
25#endif
26
27 const unsigned char *s = m;
28 c = (unsigned char)c;
29 while (n--) if (s[n]==c) return (void *)(s+n);
30 return 0;
31}
32
33weak_alias(__memrchr, memrchr);
lib/libc/wasi/libc-top-half/musl/src/string/strchrnul.c deleted-75
...@@ -1,75 +0,0 @@
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4
5#ifdef __wasm_simd128__
6#include <wasm_simd128.h>
7#endif
8
9#define ALIGN (sizeof(size_t))
10#define ONES ((size_t)-1/UCHAR_MAX)
11#define HIGHS (ONES * (UCHAR_MAX/2+1))
12#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
13
14char *__strchrnul(const char *s, int c)
15{
16 c = (unsigned char)c;
17 if (!c) return (char *)s + strlen(s);
18
19#if defined(__wasm_simd128__) && defined(__wasilibc_simd_string)
20 // Skip Clang 19 and Clang 20 which have a bug (llvm/llvm-project#146574)
21 // which results in an ICE when inline assembly is used with a vector result.
22#if __clang_major__ != 19 && __clang_major__ != 20
23 // Note that reading before/after the allocation of a pointer is UB in
24 // C, so inline assembly is used to generate the exact machine
25 // instruction we want with opaque semantics to the compiler to avoid
26 // the UB.
27 uintptr_t align = (uintptr_t)s % sizeof(v128_t);
28 uintptr_t addr = (uintptr_t)s - align;
29 v128_t vc = wasm_i8x16_splat(c);
30
31 for (;;) {
32 v128_t v;
33 __asm__ (
34 "local.get %1\n"
35 "v128.load 0\n"
36 "local.set %0\n"
37 : "=r"(v)
38 : "r"(addr)
39 : "memory");
40 const v128_t cmp = wasm_i8x16_eq(v, (v128_t){}) | wasm_i8x16_eq(v, vc);
41 // Bitmask is slow on AArch64, any_true is much faster.
42 if (wasm_v128_any_true(cmp)) {
43 // Clear the bits corresponding to align (little-endian)
44 // so we can count trailing zeros.
45 int mask = wasm_i8x16_bitmask(cmp) >> align << align;
46 // At least one bit will be set, unless align cleared them.
47 // Knowing this helps the compiler if it unrolls the loop.
48 __builtin_assume(mask || align);
49 // If the mask became zero because of align,
50 // it's as if we didn't find anything.
51 if (mask) {
52 // Find the offset of the first one bit (little-endian).
53 return (char *)s + (addr - (uintptr_t)s + __builtin_ctz(mask));
54 }
55 }
56 align = 0;
57 addr += sizeof(v128_t);
58 }
59#endif
60#endif
61
62#ifdef __GNUC__
63 typedef size_t __attribute__((__may_alias__)) word;
64 const word *w;
65 for (; (uintptr_t)s % ALIGN; s++)
66 if (!*s || *(unsigned char *)s == c) return (char *)s;
67 size_t k = ONES * c;
68 for (w = (void *)s; !HASZERO(*w) && !HASZERO(*w^k); w++);
69 s = (void *)w;
70#endif
71 for (; *s && *(unsigned char *)s != c; s++);
72 return (char *)s;
73}
74
75weak_alias(__strchrnul, strchrnul);
src/libs/mingw.zig-3
...@@ -661,7 +661,6 @@ const mingw32_generic_src = [_][]const u8{...@@ -661,7 +661,6 @@ const mingw32_generic_src = [_][]const u8{
661 "misc" ++ path.sep_str ++ "getlogin.c",661 "misc" ++ path.sep_str ++ "getlogin.c",
662 "misc" ++ path.sep_str ++ "getopt.c",662 "misc" ++ path.sep_str ++ "getopt.c",
663 "misc" ++ path.sep_str ++ "gettimeofday.c",663 "misc" ++ path.sep_str ++ "gettimeofday.c",
664 "misc" ++ path.sep_str ++ "mempcpy.c",
665 "misc" ++ path.sep_str ++ "mingw-access.c",664 "misc" ++ path.sep_str ++ "mingw-access.c",
666 "misc" ++ path.sep_str ++ "mingw-aligned-malloc.c",665 "misc" ++ path.sep_str ++ "mingw-aligned-malloc.c",
667 "misc" ++ path.sep_str ++ "mingw_getsp.S",666 "misc" ++ path.sep_str ++ "mingw_getsp.S",
...@@ -674,7 +673,6 @@ const mingw32_generic_src = [_][]const u8{...@@ -674,7 +673,6 @@ const mingw32_generic_src = [_][]const u8{
674 "misc" ++ path.sep_str ++ "mingw_wcstold.c",673 "misc" ++ path.sep_str ++ "mingw_wcstold.c",
675 "misc" ++ path.sep_str ++ "mkstemp.c",674 "misc" ++ path.sep_str ++ "mkstemp.c",
676 "misc" ++ path.sep_str ++ "sleep.c",675 "misc" ++ path.sep_str ++ "sleep.c",
677 "misc" ++ path.sep_str ++ "strnlen.c",
678 "misc" ++ path.sep_str ++ "strsafe.c",676 "misc" ++ path.sep_str ++ "strsafe.c",
679 "misc" ++ path.sep_str ++ "tdelete.c",677 "misc" ++ path.sep_str ++ "tdelete.c",
680 "misc" ++ path.sep_str ++ "tdestroy.c",678 "misc" ++ path.sep_str ++ "tdestroy.c",
...@@ -744,7 +742,6 @@ const mingw32_generic_src = [_][]const u8{...@@ -744,7 +742,6 @@ const mingw32_generic_src = [_][]const u8{
744 "stdio" ++ path.sep_str ++ "mingw_vswscanf.c",742 "stdio" ++ path.sep_str ++ "mingw_vswscanf.c",
745 "stdio" ++ path.sep_str ++ "snprintf.c",743 "stdio" ++ path.sep_str ++ "snprintf.c",
746 "stdio" ++ path.sep_str ++ "snwprintf.c",744 "stdio" ++ path.sep_str ++ "snwprintf.c",
747 "stdio" ++ path.sep_str ++ "strtok_r.c",
748 "stdio" ++ path.sep_str ++ "truncate.c",745 "stdio" ++ path.sep_str ++ "truncate.c",
749 "stdio" ++ path.sep_str ++ "ulltoa.c",746 "stdio" ++ path.sep_str ++ "ulltoa.c",
750 "stdio" ++ path.sep_str ++ "ulltow.c",747 "stdio" ++ path.sep_str ++ "ulltow.c",
src/libs/musl.zig-35
...@@ -784,10 +784,8 @@ const src_files = [_][]const u8{...@@ -784,10 +784,8 @@ const src_files = [_][]const u8{
784 "musl/src/locale/newlocale.c",784 "musl/src/locale/newlocale.c",
785 "musl/src/locale/pleval.c",785 "musl/src/locale/pleval.c",
786 "musl/src/locale/setlocale.c",786 "musl/src/locale/setlocale.c",
787 "musl/src/locale/strcoll.c",
788 "musl/src/locale/strfmon.c",787 "musl/src/locale/strfmon.c",
789 "musl/src/locale/strtod_l.c",788 "musl/src/locale/strtod_l.c",
790 "musl/src/locale/strxfrm.c",
791 "musl/src/locale/textdomain.c",789 "musl/src/locale/textdomain.c",
792 "musl/src/locale/uselocale.c",790 "musl/src/locale/uselocale.c",
793 "musl/src/locale/wcscoll.c",791 "musl/src/locale/wcscoll.c",
...@@ -1129,9 +1127,6 @@ const src_files = [_][]const u8{...@@ -1129,9 +1127,6 @@ const src_files = [_][]const u8{
1129 "musl/src/misc/a64l.c",1127 "musl/src/misc/a64l.c",
1130 "musl/src/misc/basename.c",1128 "musl/src/misc/basename.c",
1131 "musl/src/misc/dirname.c",1129 "musl/src/misc/dirname.c",
1132 "musl/src/misc/ffs.c",
1133 "musl/src/misc/ffsl.c",
1134 "musl/src/misc/ffsll.c",
1135 "musl/src/misc/fmtmsg.c",1130 "musl/src/misc/fmtmsg.c",
1136 "musl/src/misc/forkpty.c",1131 "musl/src/misc/forkpty.c",
1137 "musl/src/misc/getauxval.c",1132 "musl/src/misc/getauxval.c",
...@@ -1616,39 +1611,10 @@ const src_files = [_][]const u8{...@@ -1616,39 +1611,10 @@ const src_files = [_][]const u8{
1616 "musl/src/stdlib/strtod.c",1611 "musl/src/stdlib/strtod.c",
1617 "musl/src/stdlib/wcstod.c",1612 "musl/src/stdlib/wcstod.c",
1618 "musl/src/stdlib/wcstol.c",1613 "musl/src/stdlib/wcstol.c",
1619 "musl/src/string/bcopy.c",
1620 "musl/src/string/explicit_bzero.c",
1621 "musl/src/string/index.c",
1622 "musl/src/string/memccpy.c",
1623 "musl/src/string/memchr.c",
1624 "musl/src/string/memmem.c",
1625 "musl/src/string/mempcpy.c",
1626 "musl/src/string/memrchr.c",
1627 "musl/src/string/rindex.c",
1628 "musl/src/string/stpcpy.c",
1629 "musl/src/string/stpncpy.c",
1630 "musl/src/string/strcasestr.c",
1631 "musl/src/string/strcat.c",
1632 "musl/src/string/strchr.c",
1633 "musl/src/string/strchrnul.c",
1634 "musl/src/string/strcpy.c",
1635 "musl/src/string/strcspn.c",
1636 "musl/src/string/strdup.c",1614 "musl/src/string/strdup.c",
1637 "musl/src/string/strerror_r.c",1615 "musl/src/string/strerror_r.c",
1638 "musl/src/string/strlcat.c",
1639 "musl/src/string/strlcpy.c",
1640 "musl/src/string/strncat.c",
1641 "musl/src/string/strncpy.c",
1642 "musl/src/string/strndup.c",1616 "musl/src/string/strndup.c",
1643 "musl/src/string/strnlen.c",
1644 "musl/src/string/strpbrk.c",
1645 "musl/src/string/strrchr.c",
1646 "musl/src/string/strsep.c",
1647 "musl/src/string/strsignal.c",1617 "musl/src/string/strsignal.c",
1648 "musl/src/string/strspn.c",
1649 "musl/src/string/strstr.c",
1650 "musl/src/string/strtok.c",
1651 "musl/src/string/strtok_r.c",
1652 "musl/src/string/strverscmp.c",1618 "musl/src/string/strverscmp.c",
1653 "musl/src/string/swab.c",1619 "musl/src/string/swab.c",
1654 "musl/src/string/wcscasecmp.c",1620 "musl/src/string/wcscasecmp.c",
...@@ -1656,7 +1622,6 @@ const src_files = [_][]const u8{...@@ -1656,7 +1622,6 @@ const src_files = [_][]const u8{
1656 "musl/src/string/wcsdup.c",1622 "musl/src/string/wcsdup.c",
1657 "musl/src/string/wcsncasecmp.c",1623 "musl/src/string/wcsncasecmp.c",
1658 "musl/src/string/wcsncasecmp_l.c",1624 "musl/src/string/wcsncasecmp_l.c",
1659 "musl/src/string/wcstok.c",
1660 "musl/src/temp/mkdtemp.c",1625 "musl/src/temp/mkdtemp.c",
1661 "musl/src/temp/mkostemp.c",1626 "musl/src/temp/mkostemp.c",
1662 "musl/src/temp/mkostemps.c",1627 "musl/src/temp/mkostemps.c",
src/libs/wasi_libc.zig-35
...@@ -680,10 +680,8 @@ const libc_top_half_src_files = [_][]const u8{...@@ -680,10 +680,8 @@ const libc_top_half_src_files = [_][]const u8{
680 "musl/src/locale/__mo_lookup.c",680 "musl/src/locale/__mo_lookup.c",
681 "musl/src/locale/pleval.c",681 "musl/src/locale/pleval.c",
682 "musl/src/locale/setlocale.c",682 "musl/src/locale/setlocale.c",
683 "musl/src/locale/strcoll.c",
684 "musl/src/locale/strfmon.c",683 "musl/src/locale/strfmon.c",
685 "musl/src/locale/strtod_l.c",684 "musl/src/locale/strtod_l.c",
686 "musl/src/locale/strxfrm.c",
687 "musl/src/locale/wcscoll.c",685 "musl/src/locale/wcscoll.c",
688 "musl/src/locale/wcsxfrm.c",686 "musl/src/locale/wcsxfrm.c",
689 "musl/src/math/acos.c",687 "musl/src/math/acos.c",
...@@ -847,9 +845,6 @@ const libc_top_half_src_files = [_][]const u8{...@@ -847,9 +845,6 @@ const libc_top_half_src_files = [_][]const u8{
847 "musl/src/misc/a64l.c",845 "musl/src/misc/a64l.c",
848 "musl/src/misc/basename.c",846 "musl/src/misc/basename.c",
849 "musl/src/misc/dirname.c",847 "musl/src/misc/dirname.c",
850 "musl/src/misc/ffs.c",
851 "musl/src/misc/ffsl.c",
852 "musl/src/misc/ffsll.c",
853 "musl/src/misc/getdomainname.c",848 "musl/src/misc/getdomainname.c",
854 "musl/src/misc/gethostid.c",849 "musl/src/misc/gethostid.c",
855 "musl/src/misc/getopt.c",850 "musl/src/misc/getopt.c",
...@@ -968,35 +963,9 @@ const libc_top_half_src_files = [_][]const u8{...@@ -968,35 +963,9 @@ const libc_top_half_src_files = [_][]const u8{
968 "musl/src/stdlib/ecvt.c",963 "musl/src/stdlib/ecvt.c",
969 "musl/src/stdlib/fcvt.c",964 "musl/src/stdlib/fcvt.c",
970 "musl/src/stdlib/gcvt.c",965 "musl/src/stdlib/gcvt.c",
971 "musl/src/string/bcopy.c",
972 "musl/src/string/explicit_bzero.c",
973 "musl/src/string/index.c",
974 "musl/src/string/memccpy.c",
975 "musl/src/string/memmem.c",
976 "musl/src/string/mempcpy.c",
977 "musl/src/string/rindex.c",
978 "musl/src/string/stpcpy.c",
979 "musl/src/string/stpncpy.c",
980 "musl/src/string/strcasestr.c",
981 "musl/src/string/strcat.c",
982 "musl/src/string/strchr.c",
983 "musl/src/string/strcpy.c",
984 "musl/src/string/strcspn.c",
985 "musl/src/string/strdup.c",966 "musl/src/string/strdup.c",
986 "musl/src/string/strerror_r.c",967 "musl/src/string/strerror_r.c",
987 "musl/src/string/strlcat.c",
988 "musl/src/string/strlcpy.c",
989 "musl/src/string/strncat.c",
990 "musl/src/string/strncpy.c",
991 "musl/src/string/strndup.c",968 "musl/src/string/strndup.c",
992 "musl/src/string/strnlen.c",
993 "musl/src/string/strpbrk.c",
994 "musl/src/string/strrchr.c",
995 "musl/src/string/strsep.c",
996 "musl/src/string/strspn.c",
997 "musl/src/string/strstr.c",
998 "musl/src/string/strtok.c",
999 "musl/src/string/strtok_r.c",
1000 "musl/src/string/strverscmp.c",969 "musl/src/string/strverscmp.c",
1001 "musl/src/string/swab.c",970 "musl/src/string/swab.c",
1002 "musl/src/string/wcscasecmp.c",971 "musl/src/string/wcscasecmp.c",
...@@ -1004,7 +973,6 @@ const libc_top_half_src_files = [_][]const u8{...@@ -1004,7 +973,6 @@ const libc_top_half_src_files = [_][]const u8{
1004 "musl/src/string/wcsdup.c",973 "musl/src/string/wcsdup.c",
1005 "musl/src/string/wcsncasecmp.c",974 "musl/src/string/wcsncasecmp.c",
1006 "musl/src/string/wcsncasecmp_l.c",975 "musl/src/string/wcsncasecmp_l.c",
1007 "musl/src/string/wcstok.c",
1008 "musl/src/thread/default_attr.c",976 "musl/src/thread/default_attr.c",
1009 "musl/src/thread/pthread_attr_destroy.c",977 "musl/src/thread/pthread_attr_destroy.c",
1010 "musl/src/thread/pthread_attr_init.c",978 "musl/src/thread/pthread_attr_init.c",
...@@ -1132,9 +1100,6 @@ const libc_top_half_src_files = [_][]const u8{...@@ -1132,9 +1100,6 @@ const libc_top_half_src_files = [_][]const u8{
1132 "wasi/libc-top-half/musl/src/stdlib/strtod.c",1100 "wasi/libc-top-half/musl/src/stdlib/strtod.c",
1133 "wasi/libc-top-half/musl/src/stdlib/wcstod.c",1101 "wasi/libc-top-half/musl/src/stdlib/wcstod.c",
1134 "wasi/libc-top-half/musl/src/stdlib/wcstol.c",1102 "wasi/libc-top-half/musl/src/stdlib/wcstol.c",
1135 "wasi/libc-top-half/musl/src/string/memchr.c",
1136 "wasi/libc-top-half/musl/src/string/memrchr.c",
1137 "wasi/libc-top-half/musl/src/string/strchrnul.c",
1138 "wasi/libc-top-half/musl/src/thread/pthread_attr_get.c",1103 "wasi/libc-top-half/musl/src/thread/pthread_attr_get.c",
1139 "wasi/libc-top-half/musl/src/thread/pthread_attr_setguardsize.c",1104 "wasi/libc-top-half/musl/src/thread/pthread_attr_setguardsize.c",
1140 "wasi/libc-top-half/musl/src/thread/pthread_attr_setschedparam.c",1105 "wasi/libc-top-half/musl/src/thread/pthread_attr_setschedparam.c",