| author | |
| committer | |
| log | 964e93dc471a2b7b226112a609af482f6907e3fa |
| tree | 5cd7f9a584a564d4845ff8daad792ceb274ac555 |
| parent | 45a40c4fa8609de2a1e2cd9c6366e7f31def4fd7 |
| signature | Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM |
Similar to strlen, LLVM 23+ will sometimes emit libcalls to this function even
when libc isn't linked.3 files changed, 8 insertions(+), 6 deletions(-)
lib/c/wchar.zig+1-6| ... | ... | @@ -14,7 +14,6 @@ comptime { |
| 14 | 14 | symbol(&wmemcpy, "wmemcpy"); |
| 15 | 15 | symbol(&wmemmove, "wmemmove"); |
| 16 | 16 | symbol(&wmemset, "wmemset"); |
| 17 | symbol(&wcslen, "wcslen"); | |
| 18 | 17 | symbol(&wcsnlen, "wcsnlen"); |
| 19 | 18 | symbol(&wcscmp, "wcscmp"); |
| 20 | 19 | symbol(&wcsncmp, "wcsncmp"); |
| ... | ... | @@ -81,10 +80,6 @@ fn wmemset(dest: [*]wchar_t, elem: wchar_t, len: usize) callconv(.c) [*]wchar_t |
| 81 | 80 | return dest; |
| 82 | 81 | } |
| 83 | 82 | |
| 84 | fn wcslen(str: [*:0]const wchar_t) callconv(.c) usize { | |
| 85 | return std.mem.len(str); | |
| 86 | } | |
| 87 | ||
| 88 | 83 | fn wcsnlen(str: [*:0]const wchar_t, max: usize) callconv(.c) usize { |
| 89 | 84 | for (0..max) |i| { |
| 90 | 85 | if (str[i] == 0) return i; |
| ... | ... | @@ -199,7 +194,7 @@ fn wcswcs(noalias haystack: [*:0]const wchar_t, noalias needle: [*:0]const wchar |
| 199 | 194 | } |
| 200 | 195 | |
| 201 | 196 | fn wcsdup(str: [*:0]const wchar_t) callconv(.c) ?[*:0]wchar_t { |
| 202 | const len = wcslen(str); | |
| 197 | const len = c.wcslen(str); | |
| 203 | 198 | const size = (len + 1) * @sizeOf(wchar_t); |
| 204 | 199 | const d_opaque = c.malloc(size) orelse return null; |
| 205 | 200 | const d: [*]wchar_t = @ptrCast(@alignCast(d_opaque)); |
lib/compiler_rt.zig+5| ... | ... | @@ -162,6 +162,7 @@ comptime { |
| 162 | 162 | symbol(&bcmp, "bcmp"); |
| 163 | 163 | _ = @import("compiler_rt/ssp.zig"); |
| 164 | 164 | symbol(&strlen, "strlen"); |
| 165 | symbol(&wcslen, "wcslen"); | |
| 165 | 166 | } |
| 166 | 167 | |
| 167 | 168 | _ = @import("compiler_rt/elf.zig"); |
| ... | ... | @@ -178,6 +179,10 @@ fn strlen(s: [*:0]const c_char) callconv(.c) usize { |
| 178 | 179 | return std.mem.len(s); |
| 179 | 180 | } |
| 180 | 181 | |
| 182 | fn wcslen(s: [*:0]const std.c.wchar_t) callconv(.c) usize { | |
| 183 | return std.mem.len(s); | |
| 184 | } | |
| 185 | ||
| 181 | 186 | fn memcmp(vl: [*]const u8, vr: [*]const u8, n: usize) callconv(.c) c_int { |
| 182 | 187 | var i: usize = 0; |
| 183 | 188 | while (i < n) : (i += 1) { |
lib/std/c.zig+2| ... | ... | @@ -11389,6 +11389,8 @@ pub extern "c" fn div(a: c_int, b: c_int) div_t; |
| 11389 | 11389 | pub extern "c" fn ldiv(a: c_long, b: c_long) ldiv_t; |
| 11390 | 11390 | pub extern "c" fn lldiv(a: c_longlong, b: c_longlong) lldiv_t; |
| 11391 | 11391 | |
| 11392 | pub extern "c" fn wcslen(s: [*:0]const wchar_t) usize; | |
| 11393 | ||
| 11392 | 11394 | pub extern "c" fn atoi(str: [*:0]const c_char) c_int; |
| 11393 | 11395 | pub extern "c" fn atol(str: [*:0]const c_char) c_long; |
| 11394 | 11396 | pub extern "c" fn atoll(str: [*:0]const c_char) c_longlong; |