diff --git a/lib/c.zig b/lib/c.zig index 39684264ce28..8111813e58e1 100644 --- a/lib/c.zig +++ b/lib/c.zig @@ -14,10 +14,11 @@ else std.debug.no_panic; comptime { + _ = @import("c/string.zig"); + _ = @import("c/strings.zig"); + if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { // Files specific to musl and wasi-libc. - _ = @import("c/string.zig"); - _ = @import("c/strings.zig"); } if (builtin.target.isMuslLibC()) { diff --git a/lib/c/string.zig b/lib/c/string.zig index 0633f7e654ac..f61470fa384e 100644 --- a/lib/c/string.zig +++ b/lib/c/string.zig @@ -3,9 +3,36 @@ const std = @import("std"); const common = @import("common.zig"); comptime { - @export(&strcmp, .{ .name = "strcmp", .linkage = common.linkage, .visibility = common.visibility }); - @export(&strlen, .{ .name = "strlen", .linkage = common.linkage, .visibility = common.visibility }); - @export(&strncmp, .{ .name = "strncmp", .linkage = common.linkage, .visibility = common.visibility }); + if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { + @export(&strcmp, .{ .name = "strcmp", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strlen, .{ .name = "strlen", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strnlen, .{ .name = "strnlen", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strncmp, .{ .name = "strncmp", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strchr, .{ .name = "strchr", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strrchr, .{ .name = "strrchr", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strcpy, .{ .name = "strcpy", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strcat, .{ .name = "strcat", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strncpy, .{ .name = "strncpy", .linkage = common.linkage, .visibility = common.visibility }); + @export(&memccpy, .{ .name = "memccpy", .linkage = common.linkage, .visibility = common.visibility }); + @export(&mempcpy, .{ .name = "mempcpy", .linkage = common.linkage, .visibility = common.visibility }); + @export(&memmem, .{ .name = "memmem", .linkage = common.linkage, .visibility = common.visibility }); + @export(&memchr, .{ .name = "memchr", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strchrnul, .{ .name = "strchrnul", .linkage = .weak, .visibility = common.visibility }); + @export(&memrchr, .{ .name = "memrchr", .linkage = .weak, .visibility = common.visibility }); + @export(&stpcpy, .{ .name = "stpcpy", .linkage = .weak, .visibility = common.visibility }); + @export(&stpncpy, .{ .name = "stpncpy", .linkage = .weak, .visibility = common.visibility }); + { + // NOTE: These symbols are only depended on by other parts of the + // musl c-sources. They should be removed once libzigc is further + // along, and these functions have been re-implemented in zig. + @export(&strchrnul, .{ .name = "__strchrnul", .linkage = .strong, .visibility = .hidden }); + } + } + + if (builtin.target.isMinGW()) { + @export(&mempcpy, .{ .name = "mempcpy", .linkage = common.linkage, .visibility = common.visibility }); + @export(&strnlen, .{ .name = "strnlen", .linkage = common.linkage, .visibility = common.visibility }); + } } fn strcmp(s1: [*:0]const c_char, s2: [*:0]const c_char) callconv(.c) c_int { @@ -43,3 +70,235 @@ test strncmp { fn strlen(s: [*:0]const c_char) callconv(.c) usize { return std.mem.len(s); } + +fn strnlen(s: [*:0]const c_char, n: usize) callconv(.c) usize { + return if (std.mem.indexOfScalar(c_char, s[0..n], 0)) |idx| idx else n; +} + +fn strchrnul(s: [*:0]const c_char, c: c_int) callconv(.c) [*:0]const c_char { + const needle: c_char = @intCast(c); + if (needle == 0) return s + strlen(s); + + var it: [*:0]const c_char = s; + while (it[0] != 0 and it[0] != needle) : (it += 1) {} + return it; +} + +test strchrnul { + const foo: [*:0]const c_char = @ptrCast("disco"); + try std.testing.expect(strchrnul(foo, 'd') == foo); + try std.testing.expect(strchrnul(foo, 'o') == (foo + 4)); + try std.testing.expect(strchrnul(foo, 'z') == (foo + 5)); + try std.testing.expect(strchrnul(foo, 0) == (foo + 5)); +} + +pub fn strchr(s: [*:0]const c_char, c: c_int) callconv(.c) ?[*:0]const c_char { + const result = strchrnul(s, c); + const needle: c_char = @intCast(c); + return if (result[0] == needle) result else null; +} + +test strchr { + const foo: [*:0]const c_char = @ptrCast("disco"); + try std.testing.expect(strchr(foo, 'd') == foo); + try std.testing.expect(strchr(foo, 'o') == (foo + 4)); + try std.testing.expect(strchr(foo, 'z') == null); + try std.testing.expect(strchr(foo, 0) == (foo + 5)); +} + +fn memchr(m: *const anyopaque, c: c_int, n: usize) callconv(.c) ?*const anyopaque { + const needle: c_char = @intCast(c); + const s: [*]const c_char = @ptrCast(m); + if (std.mem.indexOfScalar(c_char, s[0..n], needle)) |idx| { + return @ptrCast(s + idx); + } else { + return null; + } +} + +test memchr { + const foo: [*:0]const c_char = @ptrCast("disco"); + try std.testing.expect(memchr(foo, 'd', 5) == @as(*const anyopaque, @ptrCast(foo))); + try std.testing.expect(memchr(foo, 'o', 5) == @as(*const anyopaque, @ptrCast(foo + 4))); + try std.testing.expect(memchr(foo, 'z', 5) == null); +} + +fn memrchr(m: *const anyopaque, c: c_int, n: usize) callconv(.c) ?*const anyopaque { + const needle: c_char = @intCast(c); + const s: [*]const c_char = @ptrCast(m); + if (std.mem.lastIndexOfScalar(c_char, s[0..n], needle)) |idx| { + return @ptrCast(s + idx); + } else { + return null; + } +} + +test memrchr { + const foo: [*:0]const c_char = @ptrCast("disco"); + try std.testing.expect(memrchr(foo, 'd', 5) == @as(*const anyopaque, @ptrCast(foo))); + try std.testing.expect(memrchr(foo, 'o', 5) == @as(*const anyopaque, @ptrCast(foo + 4))); + try std.testing.expect(memrchr(foo, 'z', 5) == null); +} + +pub fn strrchr(s: [*:0]const c_char, c: c_int) callconv(.c) ?[*:0]const c_char { + return @ptrCast(memrchr(s, c, strlen(s) + 1)); +} + +test strrchr { + const foo: [*:0]const c_char = @ptrCast("disco"); + try std.testing.expect(strrchr(foo, 'd') == foo); + try std.testing.expect(strrchr(foo, 'o') == (foo + 4)); + try std.testing.expect(strrchr(foo, 'z') == null); + try std.testing.expect(strrchr(foo, 0) == (foo + 5)); +} + +fn __aeabi_memclr(dest: *anyopaque, n: usize) callconv(.c) *anyopaque { + const buf: [*]c_char = @ptrCast(dest); + @memset(buf[0..n], 0); + return dest; +} + +fn memccpy(noalias dest: *anyopaque, noalias src: *const anyopaque, c: c_int, n: usize) callconv(.c) ?*anyopaque { + @setRuntimeSafety(false); + const d: [*]c_char = @ptrCast(dest); + const s: [*]const c_char = @ptrCast(src); + const needle: c_char = @intCast(c); + var idx: usize = 0; + while (idx < n) : (idx += 1) { + d[idx] = s[idx]; + if (d[idx] == needle) return d + idx + 1; + } + return null; +} + +test memccpy { + const src: []const u8 = "supercalifragilisticexpialidocious"; + var dst: [src.len]u8 = @splat(0); + const dOffset = std.mem.indexOfScalar(u8, src, 'd').?; + const endPtr: *anyopaque = @ptrCast(@as([*]u8, &dst) + dOffset + 1); + try std.testing.expect(memccpy(@ptrCast(&dst), @ptrCast(src.ptr), 'd', src.len) == endPtr); + try std.testing.expectEqualStrings("supercalifragilisticexpialid", std.mem.trimRight(u8, dst[0..], &.{0})); + + dst = @splat(0); + try std.testing.expect(memccpy(@constCast(@ptrCast(&dst)), (@ptrCast(src.ptr)), 'z', src.len) == null); + try std.testing.expectEqualStrings(src, dst[0..]); +} + +fn mempcpy(noalias dest: *anyopaque, noalias src: *const anyopaque, n: usize) callconv(.c) *anyopaque { + @setRuntimeSafety(false); + const d: [*]u8 = @ptrCast(dest); + const s: [*]const u8 = @ptrCast(src); + @memcpy(d[0..n], s[0..n]); + return @ptrCast(d + n); +} + +test mempcpy { + const bytesToWrite = 3; + const src: []const u8 = "testing"; + var dst: [src.len]u8 = @splat('z'); + const endPtr: *anyopaque = @ptrCast(@as([*]u8, &dst) + bytesToWrite); + try std.testing.expect(mempcpy(@ptrCast(&dst), @ptrCast(src.ptr), bytesToWrite) == endPtr); + try std.testing.expect(@as(*u8, @ptrCast(endPtr)).* == 'z'); +} + +fn memmem(haystack: *const anyopaque, haystack_len: usize, needle: *const anyopaque, needle_len: usize) callconv(.c) ?*const anyopaque { + const h: [*]const c_char = @ptrCast(haystack); + const n: [*]const c_char = @ptrCast(needle); + + if (std.mem.indexOf(c_char, h[0..haystack_len], n[0..needle_len])) |idx| { + return @ptrCast(h + idx); + } else { + return null; + } +} + +fn stpcpy(noalias dest: [*:0]c_char, noalias src: [*:0]const c_char) callconv(.c) [*:0]c_char { + var d: [*:0]c_char = dest; + var s: [*:0]const c_char = src; + // QUESTION: is std.mem.span -> @memset more efficient here? + while (true) { + d[0] = s[0]; + if (s[0] == 0) return d; + d += 1; + s += 1; + } +} + +test stpcpy { + const src: [:0]const c_char = @ptrCast("bananas"); + var dst: [src.len + 1]c_char = undefined; + const endPtr: [*]c_char = @ptrCast(@as([*]c_char, &dst) + src.len); + try std.testing.expect(stpcpy(@ptrCast(&dst), @ptrCast(src.ptr)) == endPtr); + try std.testing.expect(endPtr[0] == 0); + try std.testing.expectEqualSentinel(c_char, 0, src, dst[0..src.len :0]); +} + +fn strcpy(noalias dest: [*:0]c_char, noalias src: [*:0]const c_char) callconv(.c) [*:0]c_char { + _ = stpcpy(dest, src); + return dest; +} + +test strcpy { + const src: [:0]const c_char = @ptrCast("bananas"); + var dst: [src.len + 1]c_char = undefined; + try std.testing.expect(strcpy(@ptrCast(&dst), @ptrCast(src.ptr)) == @as([*:0]c_char, @ptrCast(&dst))); + try std.testing.expectEqualSentinel(c_char, 0, src, dst[0..src.len :0]); +} + +fn stpncpy(noalias dest: [*:0]c_char, noalias src: [*:0]const c_char, n: usize) callconv(.c) [*:0]c_char { + const dlen = strnlen(src, n); + const end = mempcpy(@ptrCast(dest), @ptrCast(src), dlen); + const remaining: [*]u8 = @ptrCast(end); + @memset(remaining[0 .. n - dlen], 0); + return @ptrCast(end); +} + +test stpncpy { + var buf: [5]c_char = undefined; + const b: [*:0]c_char = @ptrCast(&buf); + try std.testing.expect(stpncpy(@ptrCast(&buf), @ptrCast("1"), buf.len) == b + 1); + try std.testing.expectEqualSlices(c_char, &.{ '1', 0, 0, 0, 0 }, buf[0..]); + try std.testing.expect(stpncpy(@ptrCast(&buf), @ptrCast("12"), buf.len) == b + 2); + try std.testing.expectEqualSlices(c_char, &.{ '1', '2', 0, 0, 0 }, buf[0..]); + try std.testing.expect(stpncpy(@ptrCast(&buf), @ptrCast("123"), buf.len) == b + 3); + try std.testing.expectEqualSlices(c_char, &.{ '1', '2', '3', 0, 0 }, buf[0..]); + try std.testing.expect(stpncpy(@ptrCast(&buf), @ptrCast("1234"), buf.len) == b + 4); + try std.testing.expectEqualSlices(c_char, &.{ '1', '2', '3', '4', 0 }, buf[0..]); + try std.testing.expect(stpncpy(@ptrCast(&buf), @ptrCast("12345"), buf.len) == b + 5); + try std.testing.expectEqualSlices(c_char, &.{ '1', '2', '3', '4', '5' }, buf[0..]); +} + +fn strncpy(noalias dest: [*:0]c_char, noalias src: [*:0]const c_char, n: usize) callconv(.c) [*:0]c_char { + _ = stpncpy(dest, src, n); + return dest; +} + +test strncpy { + var buf: [5]c_char = undefined; + const b: [*:0]c_char = @ptrCast(&buf); + try std.testing.expect(strncpy(@ptrCast(&buf), @ptrCast("1"), buf.len) == b); + try std.testing.expectEqualSlices(c_char, &.{ '1', 0, 0, 0, 0 }, buf[0..]); + try std.testing.expect(strncpy(@ptrCast(&buf), @ptrCast("12"), buf.len) == b); + try std.testing.expectEqualSlices(c_char, &.{ '1', '2', 0, 0, 0 }, buf[0..]); + try std.testing.expect(strncpy(@ptrCast(&buf), @ptrCast("123"), buf.len) == b); + try std.testing.expectEqualSlices(c_char, &.{ '1', '2', '3', 0, 0 }, buf[0..]); + try std.testing.expect(strncpy(@ptrCast(&buf), @ptrCast("1234"), buf.len) == b); + try std.testing.expectEqualSlices(c_char, &.{ '1', '2', '3', '4', 0 }, buf[0..]); + try std.testing.expect(strncpy(@ptrCast(&buf), @ptrCast("12345"), buf.len) == b); + try std.testing.expectEqualSlices(c_char, &.{ '1', '2', '3', '4', '5' }, buf[0..]); +} + +fn strcat(noalias dest: [*:0]c_char, noalias src: [*:0]const c_char) callconv(.c) [*:0]c_char { + const start = dest + strlen(dest); + _ = stpcpy(start, src); + return dest; +} + +test strcat { + const start = "Hello"; + const end = " World!\n"; + var buf: [start.len + end.len:0]c_char = undefined; + @memcpy(buf[0 .. start.len + 1], @as([*:0]const c_char, @ptrCast(start))); + try std.testing.expect(strcat(&buf, @as([*:0]const c_char, @ptrCast(end))) == &buf); + try std.testing.expectEqualStrings("Hello World!\n", @as([]u8, @ptrCast(buf[0..]))); +} diff --git a/lib/c/strings.zig b/lib/c/strings.zig index 30e945e7b110..d8f14284b695 100644 --- a/lib/c/strings.zig +++ b/lib/c/strings.zig @@ -1,8 +1,14 @@ +const builtin = @import("builtin"); const std = @import("std"); const common = @import("common.zig"); +const string = @import("string.zig"); comptime { - @export(&bzero, .{ .name = "bzero", .linkage = common.linkage, .visibility = common.visibility }); + if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { + @export(&bzero, .{ .name = "bzero", .linkage = common.linkage, .visibility = common.visibility }); + @export(&string.strchr, .{ .name = "index", .linkage = common.linkage, .visibility = common.visibility }); + @export(&string.strrchr, .{ .name = "rindex", .linkage = common.linkage, .visibility = common.visibility }); + } } fn bzero(s: *anyopaque, n: usize) callconv(.c) void { diff --git a/lib/libc/mingw/misc/mempcpy.c b/lib/libc/mingw/misc/mempcpy.c deleted file mode 100644 index f4e7ed9f6c6c..000000000000 --- a/lib/libc/mingw/misc/mempcpy.c +++ /dev/null @@ -1,12 +0,0 @@ -#define __CRT__NO_INLINE -#include - -void * __cdecl -mempcpy (void *d, const void *s, size_t len) -{ - char *r = ((char *) d) + len; - if (len != 0) - memcpy (d, s, len); - return r; -} - diff --git a/lib/libc/mingw/misc/strnlen.c b/lib/libc/mingw/misc/strnlen.c deleted file mode 100644 index 6f9e80335712..000000000000 --- a/lib/libc/mingw/misc/strnlen.c +++ /dev/null @@ -1,11 +0,0 @@ -#define __CRT__NO_INLINE -#include - -size_t __cdecl strnlen (const char *s, size_t maxlen) -{ - const char *s2 = s; - while ((size_t) (s2 - s) < maxlen && *s2) - ++s2; - return s2 - s; -} - diff --git a/lib/libc/musl/src/string/aarch64/memset.S b/lib/libc/musl/src/string/aarch64/memset.S deleted file mode 100644 index f0d29b7fa39b..000000000000 --- a/lib/libc/musl/src/string/aarch64/memset.S +++ /dev/null @@ -1,115 +0,0 @@ -/* - * memset - fill memory with a constant byte - * - * Copyright (c) 2012-2020, Arm Limited. - * SPDX-License-Identifier: MIT - */ - -/* Assumptions: - * - * ARMv8-a, AArch64, Advanced SIMD, unaligned accesses. - * - */ - -#define dstin x0 -#define val x1 -#define valw w1 -#define count x2 -#define dst x3 -#define dstend x4 -#define zva_val x5 - -.global memset -.type memset,%function -memset: - - dup v0.16B, valw - add dstend, dstin, count - - cmp count, 96 - b.hi .Lset_long - cmp count, 16 - b.hs .Lset_medium - mov val, v0.D[0] - - /* Set 0..15 bytes. */ - tbz count, 3, 1f - str val, [dstin] - str val, [dstend, -8] - ret - nop -1: tbz count, 2, 2f - str valw, [dstin] - str valw, [dstend, -4] - ret -2: cbz count, 3f - strb valw, [dstin] - tbz count, 1, 3f - strh valw, [dstend, -2] -3: ret - - /* Set 17..96 bytes. */ -.Lset_medium: - str q0, [dstin] - tbnz count, 6, .Lset96 - str q0, [dstend, -16] - tbz count, 5, 1f - str q0, [dstin, 16] - str q0, [dstend, -32] -1: ret - - .p2align 4 - /* Set 64..96 bytes. Write 64 bytes from the start and - 32 bytes from the end. */ -.Lset96: - str q0, [dstin, 16] - stp q0, q0, [dstin, 32] - stp q0, q0, [dstend, -32] - ret - - .p2align 4 -.Lset_long: - and valw, valw, 255 - bic dst, dstin, 15 - str q0, [dstin] - cmp count, 160 - ccmp valw, 0, 0, hs - b.ne .Lno_zva - -#ifndef SKIP_ZVA_CHECK - mrs zva_val, dczid_el0 - and zva_val, zva_val, 31 - cmp zva_val, 4 /* ZVA size is 64 bytes. */ - b.ne .Lno_zva -#endif - str q0, [dst, 16] - stp q0, q0, [dst, 32] - bic dst, dst, 63 - sub count, dstend, dst /* Count is now 64 too large. */ - sub count, count, 128 /* Adjust count and bias for loop. */ - - .p2align 4 -.Lzva_loop: - add dst, dst, 64 - dc zva, dst - subs count, count, 64 - b.hi .Lzva_loop - stp q0, q0, [dstend, -64] - stp q0, q0, [dstend, -32] - ret - -.Lno_zva: - sub count, dstend, dst /* Count is 16 too large. */ - sub dst, dst, 16 /* Dst is biased by -32. */ - sub count, count, 64 + 16 /* Adjust count and bias for loop. */ -.Lno_zva_loop: - stp q0, q0, [dst, 32] - stp q0, q0, [dst, 64]! - subs count, count, 64 - b.hi .Lno_zva_loop - stp q0, q0, [dstend, -64] - stp q0, q0, [dstend, -32] - ret - -.size memset,.-memset - diff --git a/lib/libc/musl/src/string/arm/__aeabi_memset.s b/lib/libc/musl/src/string/arm/__aeabi_memset.s deleted file mode 100644 index f9f605838bd9..000000000000 --- a/lib/libc/musl/src/string/arm/__aeabi_memset.s +++ /dev/null @@ -1,31 +0,0 @@ -.syntax unified - -.global __aeabi_memclr8 -.global __aeabi_memclr4 -.global __aeabi_memclr -.global __aeabi_memset8 -.global __aeabi_memset4 -.global __aeabi_memset - -.type __aeabi_memclr8,%function -.type __aeabi_memclr4,%function -.type __aeabi_memclr,%function -.type __aeabi_memset8,%function -.type __aeabi_memset4,%function -.type __aeabi_memset,%function - -__aeabi_memclr8: -__aeabi_memclr4: -__aeabi_memclr: - movs r2, #0 -__aeabi_memset8: -__aeabi_memset4: -__aeabi_memset: - cmp r1, #0 - beq 2f - adds r1, r0, r1 -1: strb r2, [r0] - adds r0, r0, #1 - cmp r1, r0 - bne 1b -2: bx lr diff --git a/lib/libc/musl/src/string/i386/memset.s b/lib/libc/musl/src/string/i386/memset.s deleted file mode 100644 index d00422c4ac15..000000000000 --- a/lib/libc/musl/src/string/i386/memset.s +++ /dev/null @@ -1,76 +0,0 @@ -.global memset -.type memset,@function -memset: - mov 12(%esp),%ecx - cmp $62,%ecx - ja 2f - - mov 8(%esp),%dl - mov 4(%esp),%eax - test %ecx,%ecx - jz 1f - - mov %dl,%dh - - mov %dl,(%eax) - mov %dl,-1(%eax,%ecx) - cmp $2,%ecx - jbe 1f - - mov %dx,1(%eax) - mov %dx,(-1-2)(%eax,%ecx) - cmp $6,%ecx - jbe 1f - - shl $16,%edx - mov 8(%esp),%dl - mov 8(%esp),%dh - - mov %edx,(1+2)(%eax) - mov %edx,(-1-2-4)(%eax,%ecx) - cmp $14,%ecx - jbe 1f - - mov %edx,(1+2+4)(%eax) - mov %edx,(1+2+4+4)(%eax) - mov %edx,(-1-2-4-8)(%eax,%ecx) - mov %edx,(-1-2-4-4)(%eax,%ecx) - cmp $30,%ecx - jbe 1f - - mov %edx,(1+2+4+8)(%eax) - mov %edx,(1+2+4+8+4)(%eax) - mov %edx,(1+2+4+8+8)(%eax) - mov %edx,(1+2+4+8+12)(%eax) - mov %edx,(-1-2-4-8-16)(%eax,%ecx) - mov %edx,(-1-2-4-8-12)(%eax,%ecx) - mov %edx,(-1-2-4-8-8)(%eax,%ecx) - mov %edx,(-1-2-4-8-4)(%eax,%ecx) - -1: ret - -2: movzbl 8(%esp),%eax - mov %edi,12(%esp) - imul $0x1010101,%eax - mov 4(%esp),%edi - test $15,%edi - mov %eax,-4(%edi,%ecx) - jnz 2f - -1: shr $2, %ecx - rep - stosl - mov 4(%esp),%eax - mov 12(%esp),%edi - ret - -2: xor %edx,%edx - sub %edi,%edx - and $15,%edx - mov %eax,(%edi) - mov %eax,4(%edi) - mov %eax,8(%edi) - mov %eax,12(%edi) - sub %edx,%ecx - add %edx,%edi - jmp 1b diff --git a/lib/libc/musl/src/string/index.c b/lib/libc/musl/src/string/index.c deleted file mode 100644 index 252948f9fd58..000000000000 --- a/lib/libc/musl/src/string/index.c +++ /dev/null @@ -1,8 +0,0 @@ -#define _BSD_SOURCE -#include -#include - -char *index(const char *s, int c) -{ - return strchr(s, c); -} diff --git a/lib/libc/musl/src/string/memccpy.c b/lib/libc/musl/src/string/memccpy.c deleted file mode 100644 index 3b0a370020c4..000000000000 --- a/lib/libc/musl/src/string/memccpy.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include - -#define ALIGN (sizeof(size_t)-1) -#define ONES ((size_t)-1/UCHAR_MAX) -#define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) - -void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n) -{ - unsigned char *d = dest; - const unsigned char *s = src; - - c = (unsigned char)c; -#ifdef __GNUC__ - typedef size_t __attribute__((__may_alias__)) word; - word *wd; - const word *ws; - if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) { - for (; ((uintptr_t)s & ALIGN) && n && (*d=*s)!=c; n--, s++, d++); - if ((uintptr_t)s & ALIGN) goto tail; - size_t k = ONES * c; - wd=(void *)d; ws=(const void *)s; - for (; n>=sizeof(size_t) && !HASZERO(*ws^k); - n-=sizeof(size_t), ws++, wd++) *wd = *ws; - d=(void *)wd; s=(const void *)ws; - } -#endif - for (; n && (*d=*s)!=c; n--, s++, d++); -tail: - if (n) return d+1; - return 0; -} diff --git a/lib/libc/musl/src/string/memchr.c b/lib/libc/musl/src/string/memchr.c deleted file mode 100644 index 65f0d789b2c9..000000000000 --- a/lib/libc/musl/src/string/memchr.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include - -#define SS (sizeof(size_t)) -#define ALIGN (sizeof(size_t)-1) -#define ONES ((size_t)-1/UCHAR_MAX) -#define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) - -void *memchr(const void *src, int c, size_t n) -{ - const unsigned char *s = src; - c = (unsigned char)c; -#ifdef __GNUC__ - for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--); - if (n && *s != c) { - typedef size_t __attribute__((__may_alias__)) word; - const word *w; - size_t k = ONES * c; - for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS); - s = (const void *)w; - } -#endif - for (; n && *s != c; s++, n--); - return n ? (void *)s : 0; -} diff --git a/lib/libc/musl/src/string/memcmp.c b/lib/libc/musl/src/string/memcmp.c deleted file mode 100644 index bdbce9f0f563..000000000000 --- a/lib/libc/musl/src/string/memcmp.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -int memcmp(const void *vl, const void *vr, size_t n) -{ - const unsigned char *l=vl, *r=vr; - for (; n && *l == *r; n--, l++, r++); - return n ? *l-*r : 0; -} diff --git a/lib/libc/musl/src/string/memmem.c b/lib/libc/musl/src/string/memmem.c deleted file mode 100644 index 11eff86e443e..000000000000 --- a/lib/libc/musl/src/string/memmem.c +++ /dev/null @@ -1,149 +0,0 @@ -#define _GNU_SOURCE -#include -#include - -static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) -{ - uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; - for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++) - if (hw == nw) return (char *)h-2; - return hw == nw ? (char *)h-2 : 0; -} - -static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) -{ - uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8; - uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8; - for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) - if (hw == nw) return (char *)h-3; - return hw == nw ? (char *)h-3 : 0; -} - -static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) -{ - uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; - uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; - for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) - if (hw == nw) return (char *)h-4; - return hw == nw ? (char *)h-4 : 0; -} - -#define MAX(a,b) ((a)>(b)?(a):(b)) -#define MIN(a,b) ((a)<(b)?(a):(b)) - -#define BITOP(a,b,op) \ - ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) - -static char *twoway_memmem(const unsigned char *h, const unsigned char *z, const unsigned char *n, size_t l) -{ - size_t i, ip, jp, k, p, ms, p0, mem, mem0; - size_t byteset[32 / sizeof(size_t)] = { 0 }; - size_t shift[256]; - - /* Computing length of needle and fill shift table */ - for (i=0; i n[jp+k]) { - jp += k; - k = 1; - p = jp - ip; - } else { - ip = jp++; - k = p = 1; - } - } - ms = ip; - p0 = p; - - /* And with the opposite comparison */ - ip = -1; jp = 0; k = p = 1; - while (jp+k ms+1) ms = ip; - else p = p0; - - /* Periodic needle? */ - if (memcmp(n, n+p, ms+1)) { - mem0 = 0; - p = MAX(ms, l-ms-1) + 1; - } else mem0 = l-p; - mem = 0; - - /* Search loop */ - for (;;) { - /* If remainder of haystack is shorter than needle, done */ - if (z-h < l) return 0; - - /* Check last byte first; advance by shift on mismatch */ - if (BITOP(byteset, h[l-1], &)) { - k = l-shift[h[l-1]]; - if (k) { - if (k < mem) k = mem; - h += k; - mem = 0; - continue; - } - } else { - h += l; - mem = 0; - continue; - } - - /* Compare right half */ - for (k=MAX(ms+1,mem); kmem && n[k-1] == h[k-1]; k--); - if (k <= mem) return (char *)h; - h += p; - mem = mem0; - } -} - -void *memmem(const void *h0, size_t k, const void *n0, size_t l) -{ - const unsigned char *h = h0, *n = n0; - - /* Return immediately on empty needle */ - if (!l) return (void *)h; - - /* Return immediately when needle is longer than haystack */ - if (k - -void *mempcpy(void *dest, const void *src, size_t n) -{ - return (char *)memcpy(dest, src, n) + n; -} diff --git a/lib/libc/musl/src/string/memrchr.c b/lib/libc/musl/src/string/memrchr.c deleted file mode 100644 index e51748b80565..000000000000 --- a/lib/libc/musl/src/string/memrchr.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -void *__memrchr(const void *m, int c, size_t n) -{ - const unsigned char *s = m; - c = (unsigned char)c; - while (n--) if (s[n]==c) return (void *)(s+n); - return 0; -} - -weak_alias(__memrchr, memrchr); diff --git a/lib/libc/musl/src/string/memset.c b/lib/libc/musl/src/string/memset.c deleted file mode 100644 index 5613a1486e6a..000000000000 --- a/lib/libc/musl/src/string/memset.c +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include - -void *memset(void *dest, int c, size_t n) -{ - unsigned char *s = dest; - size_t k; - - /* Fill head and tail with minimal branching. Each - * conditional ensures that all the subsequently used - * offsets are well-defined and in the dest region. */ - - if (!n) return dest; - s[0] = c; - s[n-1] = c; - if (n <= 2) return dest; - s[1] = c; - s[2] = c; - s[n-2] = c; - s[n-3] = c; - if (n <= 6) return dest; - s[3] = c; - s[n-4] = c; - if (n <= 8) return dest; - - /* Advance pointer to align it at a 4-byte boundary, - * and truncate n to a multiple of 4. The previous code - * already took care of any head/tail that get cut off - * by the alignment. */ - - k = -(uintptr_t)s & 3; - s += k; - n -= k; - n &= -4; - -#ifdef __GNUC__ - typedef uint32_t __attribute__((__may_alias__)) u32; - typedef uint64_t __attribute__((__may_alias__)) u64; - - u32 c32 = ((u32)-1)/255 * (unsigned char)c; - - /* In preparation to copy 32 bytes at a time, aligned on - * an 8-byte bounary, fill head/tail up to 28 bytes each. - * As in the initial byte-based head/tail fill, each - * conditional below ensures that the subsequent offsets - * are valid (e.g. !(n<=24) implies n>=28). */ - - *(u32 *)(s+0) = c32; - *(u32 *)(s+n-4) = c32; - if (n <= 8) return dest; - *(u32 *)(s+4) = c32; - *(u32 *)(s+8) = c32; - *(u32 *)(s+n-12) = c32; - *(u32 *)(s+n-8) = c32; - if (n <= 24) return dest; - *(u32 *)(s+12) = c32; - *(u32 *)(s+16) = c32; - *(u32 *)(s+20) = c32; - *(u32 *)(s+24) = c32; - *(u32 *)(s+n-28) = c32; - *(u32 *)(s+n-24) = c32; - *(u32 *)(s+n-20) = c32; - *(u32 *)(s+n-16) = c32; - - /* Align to a multiple of 8 so we can fill 64 bits at a time, - * and avoid writing the same bytes twice as much as is - * practical without introducing additional branching. */ - - k = 24 + ((uintptr_t)s & 4); - s += k; - n -= k; - - /* If this loop is reached, 28 tail bytes have already been - * filled, so any remainder when n drops below 32 can be - * safely ignored. */ - - u64 c64 = c32 | ((u64)c32 << 32); - for (; n >= 32; n-=32, s+=32) { - *(u64 *)(s+0) = c64; - *(u64 *)(s+8) = c64; - *(u64 *)(s+16) = c64; - *(u64 *)(s+24) = c64; - } -#else - /* Pure C fallback with no aliasing violations. */ - for (; n; n--, s++) *s = c; -#endif - - return dest; -} diff --git a/lib/libc/musl/src/string/rindex.c b/lib/libc/musl/src/string/rindex.c deleted file mode 100644 index 693c750b6b65..000000000000 --- a/lib/libc/musl/src/string/rindex.c +++ /dev/null @@ -1,8 +0,0 @@ -#define _BSD_SOURCE -#include -#include - -char *rindex(const char *s, int c) -{ - return strrchr(s, c); -} diff --git a/lib/libc/musl/src/string/stpcpy.c b/lib/libc/musl/src/string/stpcpy.c deleted file mode 100644 index 4db46a9e50b2..000000000000 --- a/lib/libc/musl/src/string/stpcpy.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - -#define ALIGN (sizeof(size_t)) -#define ONES ((size_t)-1/UCHAR_MAX) -#define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) - -char *__stpcpy(char *restrict d, const char *restrict s) -{ -#ifdef __GNUC__ - typedef size_t __attribute__((__may_alias__)) word; - word *wd; - const word *ws; - if ((uintptr_t)s % ALIGN == (uintptr_t)d % ALIGN) { - for (; (uintptr_t)s % ALIGN; s++, d++) - if (!(*d=*s)) return d; - wd=(void *)d; ws=(const void *)s; - for (; !HASZERO(*ws); *wd++ = *ws++); - d=(void *)wd; s=(const void *)ws; - } -#endif - for (; (*d=*s); s++, d++); - - return d; -} - -weak_alias(__stpcpy, stpcpy); diff --git a/lib/libc/musl/src/string/stpncpy.c b/lib/libc/musl/src/string/stpncpy.c deleted file mode 100644 index f57fa6b71bf3..000000000000 --- a/lib/libc/musl/src/string/stpncpy.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -#define ALIGN (sizeof(size_t)-1) -#define ONES ((size_t)-1/UCHAR_MAX) -#define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) - -char *__stpncpy(char *restrict d, const char *restrict s, size_t n) -{ -#ifdef __GNUC__ - typedef size_t __attribute__((__may_alias__)) word; - word *wd; - const word *ws; - if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) { - for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++); - if (!n || !*s) goto tail; - wd=(void *)d; ws=(const void *)s; - for (; n>=sizeof(size_t) && !HASZERO(*ws); - n-=sizeof(size_t), ws++, wd++) *wd = *ws; - d=(void *)wd; s=(const void *)ws; - } -#endif - for (; n && (*d=*s); n--, s++, d++); -tail: - memset(d, 0, n); - return d; -} - -weak_alias(__stpncpy, stpncpy); - diff --git a/lib/libc/musl/src/string/strcat.c b/lib/libc/musl/src/string/strcat.c deleted file mode 100644 index 33f749b1d21c..000000000000 --- a/lib/libc/musl/src/string/strcat.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -char *strcat(char *restrict dest, const char *restrict src) -{ - strcpy(dest + strlen(dest), src); - return dest; -} diff --git a/lib/libc/musl/src/string/strchr.c b/lib/libc/musl/src/string/strchr.c deleted file mode 100644 index 3cbc828bebf7..000000000000 --- a/lib/libc/musl/src/string/strchr.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -char *strchr(const char *s, int c) -{ - char *r = __strchrnul(s, c); - return *(unsigned char *)r == (unsigned char)c ? r : 0; -} diff --git a/lib/libc/musl/src/string/strchrnul.c b/lib/libc/musl/src/string/strchrnul.c deleted file mode 100644 index 39e2635b3064..000000000000 --- a/lib/libc/musl/src/string/strchrnul.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#define ALIGN (sizeof(size_t)) -#define ONES ((size_t)-1/UCHAR_MAX) -#define HIGHS (ONES * (UCHAR_MAX/2+1)) -#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) - -char *__strchrnul(const char *s, int c) -{ - c = (unsigned char)c; - if (!c) return (char *)s + strlen(s); - -#ifdef __GNUC__ - typedef size_t __attribute__((__may_alias__)) word; - const word *w; - for (; (uintptr_t)s % ALIGN; s++) - if (!*s || *(unsigned char *)s == c) return (char *)s; - size_t k = ONES * c; - for (w = (void *)s; !HASZERO(*w) && !HASZERO(*w^k); w++); - s = (void *)w; -#endif - for (; *s && *(unsigned char *)s != c; s++); - return (char *)s; -} - -weak_alias(__strchrnul, strchrnul); diff --git a/lib/libc/musl/src/string/strcpy.c b/lib/libc/musl/src/string/strcpy.c deleted file mode 100644 index 6668a1295638..000000000000 --- a/lib/libc/musl/src/string/strcpy.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -char *strcpy(char *restrict dest, const char *restrict src) -{ - __stpcpy(dest, src); - return dest; -} diff --git a/lib/libc/musl/src/string/strncpy.c b/lib/libc/musl/src/string/strncpy.c deleted file mode 100644 index 545892e6ec5f..000000000000 --- a/lib/libc/musl/src/string/strncpy.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -char *strncpy(char *restrict d, const char *restrict s, size_t n) -{ - __stpncpy(d, s, n); - return d; -} diff --git a/lib/libc/musl/src/string/strnlen.c b/lib/libc/musl/src/string/strnlen.c deleted file mode 100644 index 6442eb793fbe..000000000000 --- a/lib/libc/musl/src/string/strnlen.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -size_t strnlen(const char *s, size_t n) -{ - const char *p = memchr(s, 0, n); - return p ? p-s : n; -} diff --git a/lib/libc/musl/src/string/strrchr.c b/lib/libc/musl/src/string/strrchr.c deleted file mode 100644 index 98ad1b045492..000000000000 --- a/lib/libc/musl/src/string/strrchr.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -char *strrchr(const char *s, int c) -{ - return __memrchr(s, c, strlen(s) + 1); -} diff --git a/lib/libc/musl/src/string/x86_64/memset.s b/lib/libc/musl/src/string/x86_64/memset.s deleted file mode 100644 index 2d3f5e52b8af..000000000000 --- a/lib/libc/musl/src/string/x86_64/memset.s +++ /dev/null @@ -1,72 +0,0 @@ -.global memset -.type memset,@function -memset: - movzbq %sil,%rax - mov $0x101010101010101,%r8 - imul %r8,%rax - - cmp $126,%rdx - ja 2f - - test %edx,%edx - jz 1f - - mov %sil,(%rdi) - mov %sil,-1(%rdi,%rdx) - cmp $2,%edx - jbe 1f - - mov %ax,1(%rdi) - mov %ax,(-1-2)(%rdi,%rdx) - cmp $6,%edx - jbe 1f - - mov %eax,(1+2)(%rdi) - mov %eax,(-1-2-4)(%rdi,%rdx) - cmp $14,%edx - jbe 1f - - mov %rax,(1+2+4)(%rdi) - mov %rax,(-1-2-4-8)(%rdi,%rdx) - cmp $30,%edx - jbe 1f - - mov %rax,(1+2+4+8)(%rdi) - mov %rax,(1+2+4+8+8)(%rdi) - mov %rax,(-1-2-4-8-16)(%rdi,%rdx) - mov %rax,(-1-2-4-8-8)(%rdi,%rdx) - cmp $62,%edx - jbe 1f - - mov %rax,(1+2+4+8+16)(%rdi) - mov %rax,(1+2+4+8+16+8)(%rdi) - mov %rax,(1+2+4+8+16+16)(%rdi) - mov %rax,(1+2+4+8+16+24)(%rdi) - mov %rax,(-1-2-4-8-16-32)(%rdi,%rdx) - mov %rax,(-1-2-4-8-16-24)(%rdi,%rdx) - mov %rax,(-1-2-4-8-16-16)(%rdi,%rdx) - mov %rax,(-1-2-4-8-16-8)(%rdi,%rdx) - -1: mov %rdi,%rax - ret - -2: test $15,%edi - mov %rdi,%r8 - mov %rax,-8(%rdi,%rdx) - mov %rdx,%rcx - jnz 2f - -1: shr $3,%rcx - rep - stosq - mov %r8,%rax - ret - -2: xor %edx,%edx - sub %edi,%edx - and $15,%edx - mov %rax,(%rdi) - mov %rax,8(%rdi) - sub %rdx,%rcx - add %rdx,%rdi - jmp 1b diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/memset.c b/lib/libc/wasi/libc-top-half/musl/src/string/memset.c deleted file mode 100644 index f64c9cf5ae96..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/string/memset.c +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include - -void *memset(void *dest, int c, size_t n) -{ -#if defined(__wasm_bulk_memory__) - if (n > BULK_MEMORY_THRESHOLD) - return __builtin_memset(dest, c, n); -#endif - unsigned char *s = dest; - size_t k; - - /* Fill head and tail with minimal branching. Each - * conditional ensures that all the subsequently used - * offsets are well-defined and in the dest region. */ - - if (!n) return dest; - s[0] = c; - s[n-1] = c; - if (n <= 2) return dest; - s[1] = c; - s[2] = c; - s[n-2] = c; - s[n-3] = c; - if (n <= 6) return dest; - s[3] = c; - s[n-4] = c; - if (n <= 8) return dest; - - /* Advance pointer to align it at a 4-byte boundary, - * and truncate n to a multiple of 4. The previous code - * already took care of any head/tail that get cut off - * by the alignment. */ - - k = -(uintptr_t)s & 3; - s += k; - n -= k; - n &= -4; - -#ifdef __GNUC__ - typedef uint32_t __attribute__((__may_alias__)) u32; - typedef uint64_t __attribute__((__may_alias__)) u64; - - u32 c32 = ((u32)-1)/255 * (unsigned char)c; - - /* In preparation to copy 32 bytes at a time, aligned on - * an 8-byte bounary, fill head/tail up to 28 bytes each. - * As in the initial byte-based head/tail fill, each - * conditional below ensures that the subsequent offsets - * are valid (e.g. !(n<=24) implies n>=28). */ - - *(u32 *)(s+0) = c32; - *(u32 *)(s+n-4) = c32; - if (n <= 8) return dest; - *(u32 *)(s+4) = c32; - *(u32 *)(s+8) = c32; - *(u32 *)(s+n-12) = c32; - *(u32 *)(s+n-8) = c32; - if (n <= 24) return dest; - *(u32 *)(s+12) = c32; - *(u32 *)(s+16) = c32; - *(u32 *)(s+20) = c32; - *(u32 *)(s+24) = c32; - *(u32 *)(s+n-28) = c32; - *(u32 *)(s+n-24) = c32; - *(u32 *)(s+n-20) = c32; - *(u32 *)(s+n-16) = c32; - - /* Align to a multiple of 8 so we can fill 64 bits at a time, - * and avoid writing the same bytes twice as much as is - * practical without introducing additional branching. */ - - k = 24 + ((uintptr_t)s & 4); - s += k; - n -= k; - - /* If this loop is reached, 28 tail bytes have already been - * filled, so any remainder when n drops below 32 can be - * safely ignored. */ - - u64 c64 = c32 | ((u64)c32 << 32); - for (; n >= 32; n-=32, s+=32) { - *(u64 *)(s+0) = c64; - *(u64 *)(s+8) = c64; - *(u64 *)(s+16) = c64; - *(u64 *)(s+24) = c64; - } -#else - /* Pure C fallback with no aliasing violations. */ - for (; n; n--, s++) *s = c; -#endif - - return dest; -} diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig index 2049b0f6b7d7..1991986518ec 100644 --- a/src/libs/mingw.zig +++ b/src/libs/mingw.zig @@ -630,7 +630,6 @@ const mingw32_generic_src = [_][]const u8{ "misc" ++ path.sep_str ++ "getlogin.c", "misc" ++ path.sep_str ++ "getopt.c", "misc" ++ path.sep_str ++ "gettimeofday.c", - "misc" ++ path.sep_str ++ "mempcpy.c", "misc" ++ path.sep_str ++ "mingw-access.c", "misc" ++ path.sep_str ++ "mingw-aligned-malloc.c", "misc" ++ path.sep_str ++ "mingw_getsp.S", @@ -643,7 +642,6 @@ const mingw32_generic_src = [_][]const u8{ "misc" ++ path.sep_str ++ "mingw_wcstold.c", "misc" ++ path.sep_str ++ "mkstemp.c", "misc" ++ path.sep_str ++ "sleep.c", - "misc" ++ path.sep_str ++ "strnlen.c", "misc" ++ path.sep_str ++ "strsafe.c", "misc" ++ path.sep_str ++ "tdelete.c", "misc" ++ path.sep_str ++ "tdestroy.c", diff --git a/src/libs/musl.zig b/src/libs/musl.zig index bc89e20c2131..be3f3dd919a1 100644 --- a/src/libs/musl.zig +++ b/src/libs/musl.zig @@ -1836,29 +1836,11 @@ const src_files = [_][]const u8{ "musl/src/stdlib/strtol.c", "musl/src/stdlib/wcstod.c", "musl/src/stdlib/wcstol.c", - "musl/src/string/aarch64/memset.S", - "musl/src/string/arm/__aeabi_memset.s", "musl/src/string/bcmp.c", "musl/src/string/bcopy.c", "musl/src/string/explicit_bzero.c", - "musl/src/string/i386/memset.s", - "musl/src/string/index.c", - "musl/src/string/memccpy.c", - "musl/src/string/memchr.c", - "musl/src/string/memcmp.c", - "musl/src/string/memmem.c", - "musl/src/string/mempcpy.c", - "musl/src/string/memrchr.c", - "musl/src/string/memset.c", - "musl/src/string/rindex.c", - "musl/src/string/stpcpy.c", - "musl/src/string/stpncpy.c", "musl/src/string/strcasecmp.c", "musl/src/string/strcasestr.c", - "musl/src/string/strcat.c", - "musl/src/string/strchr.c", - "musl/src/string/strchrnul.c", - "musl/src/string/strcpy.c", "musl/src/string/strcspn.c", "musl/src/string/strdup.c", "musl/src/string/strerror_r.c", @@ -1866,11 +1848,8 @@ const src_files = [_][]const u8{ "musl/src/string/strlcpy.c", "musl/src/string/strncasecmp.c", "musl/src/string/strncat.c", - "musl/src/string/strncpy.c", "musl/src/string/strndup.c", - "musl/src/string/strnlen.c", "musl/src/string/strpbrk.c", - "musl/src/string/strrchr.c", "musl/src/string/strsep.c", "musl/src/string/strsignal.c", "musl/src/string/strspn.c", @@ -1907,7 +1886,6 @@ const src_files = [_][]const u8{ "musl/src/string/wmemcpy.c", "musl/src/string/wmemmove.c", "musl/src/string/wmemset.c", - "musl/src/string/x86_64/memset.s", "musl/src/temp/mkdtemp.c", "musl/src/temp/mkostemp.c", "musl/src/temp/mkostemps.c", diff --git a/src/libs/wasi_libc.zig b/src/libs/wasi_libc.zig index 2657c2e1f8a4..de148530ad9f 100644 --- a/src/libs/wasi_libc.zig +++ b/src/libs/wasi_libc.zig @@ -1045,22 +1045,8 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/string/bcmp.c", "musl/src/string/bcopy.c", "musl/src/string/explicit_bzero.c", - "musl/src/string/index.c", - "musl/src/string/memccpy.c", - "musl/src/string/memchr.c", - "musl/src/string/memcmp.c", - "musl/src/string/memmem.c", - "musl/src/string/mempcpy.c", - "musl/src/string/memrchr.c", - "musl/src/string/rindex.c", - "musl/src/string/stpcpy.c", - "musl/src/string/stpncpy.c", "musl/src/string/strcasecmp.c", "musl/src/string/strcasestr.c", - "musl/src/string/strcat.c", - "musl/src/string/strchr.c", - "musl/src/string/strchrnul.c", - "musl/src/string/strcpy.c", "musl/src/string/strcspn.c", "musl/src/string/strdup.c", "musl/src/string/strerror_r.c", @@ -1068,11 +1054,8 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/string/strlcpy.c", "musl/src/string/strncasecmp.c", "musl/src/string/strncat.c", - "musl/src/string/strncpy.c", "musl/src/string/strndup.c", - "musl/src/string/strnlen.c", "musl/src/string/strpbrk.c", - "musl/src/string/strrchr.c", "musl/src/string/strsep.c", "musl/src/string/strspn.c", "musl/src/string/strstr.c", @@ -1208,7 +1191,6 @@ const libc_top_half_src_files = [_][]const u8{ "wasi/libc-top-half/musl/src/stdlib/strtol.c", "wasi/libc-top-half/musl/src/stdlib/wcstod.c", "wasi/libc-top-half/musl/src/stdlib/wcstol.c", - "wasi/libc-top-half/musl/src/string/memset.c", "wasi/libc-top-half/musl/src/time/getdate.c", "wasi/libc-top-half/musl/src/time/gmtime.c", "wasi/libc-top-half/musl/src/time/gmtime_r.c",