| author | |
| committer | |
| log | 96bd268c8c07b8aae0372317bfea60ef2fb3f257 |
| tree | 26d3645af6702688e1ffd95f12e3d9f4a4c2bdc0 |
| parent | 68403267117bf5cf73e0f747887f2834336ae4a2 |
- use symbol export helper
- move all declarations from common.zig into c.zig
- correct documentation
- delete dead code18 files changed, 398 insertions(+), 387 deletions(-)
lib/c.zig+41-22| ... | @@ -1,7 +1,9 @@ | ... | @@ -1,7 +1,9 @@ |
| 1 | //! This is Zig's multi-target implementation of libc. | 1 | //! Multi-target implementation of libc, providing ABI compatibility with |
| 2 | //! bundled libcs. | ||
| 2 | //! | 3 | //! |
| 3 | //! When `builtin.link_libc` is true, we need to export all the functions and | 4 | //! mingw-w64 libc is not fully statically linked, so some symbols don't need |
| 4 | //! provide a libc API compatible with the target (e.g. musl, wasi-libc, ...). | 5 | //! to be exported. However, a future enhancement could be eliminating Zig's |
| 6 | //! dependency on msvcrt dll even when linking libc and targeting Windows. | ||
| 5 | 7 | ||
| 6 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 7 | const std = @import("std"); | 9 | const std = @import("std"); |
| ... | @@ -13,8 +15,36 @@ pub const panic = if (builtin.is_test) | ... | @@ -13,8 +15,36 @@ pub const panic = if (builtin.is_test) |
| 13 | else | 15 | else |
| 14 | std.debug.no_panic; | 16 | std.debug.no_panic; |
| 15 | 17 | ||
| 16 | // NOTE: `libzigc` aims to be a standalone libc and provide ABI compatibility with its bundled libc's. | 18 | /// It is incorrect to make this conditional on `builtin.is_test`, because it is possible that |
| 17 | // Some of them like `mingw` are not fully statically linked so some symbols don't need to be exported. | 19 | /// libzigc is being linked into a different test compilation, as opposed to being tested itself. |
| 20 | pub const linkage: std.builtin.GlobalLinkage = .strong; | ||
| 21 | |||
| 22 | /// Determines the symbol's visibility to other objects. | ||
| 23 | /// For WebAssembly this allows the symbol to be resolved to other modules, but will not | ||
| 24 | /// export it to the host runtime. | ||
| 25 | pub const visibility: std.builtin.SymbolVisibility = .hidden; | ||
| 26 | |||
| 27 | pub inline fn symbol(comptime func: *const anyopaque, comptime name: []const u8) void { | ||
| 28 | @export(func, .{ .name = name, .linkage = linkage, .visibility = visibility }); | ||
| 29 | } | ||
| 30 | |||
| 31 | /// Given a low-level syscall return value, sets errno and returns `-1`, or on | ||
| 32 | /// success returns the result. | ||
| 33 | pub fn errno(syscall_return_value: usize) c_int { | ||
| 34 | return switch (builtin.os.tag) { | ||
| 35 | .linux => { | ||
| 36 | const signed: isize = @bitCast(syscall_return_value); | ||
| 37 | const casted: c_int = @intCast(signed); | ||
| 38 | if (casted < 0) { | ||
| 39 | @branchHint(.unlikely); | ||
| 40 | std.c._errno().* = -casted; | ||
| 41 | return -1; | ||
| 42 | } | ||
| 43 | return casted; | ||
| 44 | }, | ||
| 45 | else => comptime unreachable, | ||
| 46 | }; | ||
| 47 | } | ||
| 18 | 48 | ||
| 19 | comptime { | 49 | comptime { |
| 20 | _ = @import("c/inttypes.zig"); | 50 | _ = @import("c/inttypes.zig"); |
| ... | @@ -25,22 +55,11 @@ comptime { | ... | @@ -25,22 +55,11 @@ comptime { |
| 25 | _ = @import("c/strings.zig"); | 55 | _ = @import("c/strings.zig"); |
| 26 | _ = @import("c/wchar.zig"); | 56 | _ = @import("c/wchar.zig"); |
| 27 | 57 | ||
| 28 | _ = @import("c/sys.zig"); | 58 | _ = @import("c/sys/mman.zig"); |
| 29 | _ = @import("c/unistd.zig"); | 59 | _ = @import("c/sys/file.zig"); |
| 30 | 60 | _ = @import("c/sys/reboot.zig"); | |
| 31 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 61 | _ = @import("c/sys/capability.zig"); |
| 32 | // Files specific to musl and wasi-libc. | 62 | _ = @import("c/sys/utsname.zig"); |
| 33 | } | ||
| 34 | |||
| 35 | if (builtin.target.isMuslLibC()) { | ||
| 36 | // Files specific to musl. | ||
| 37 | } | ||
| 38 | 63 | ||
| 39 | if (builtin.target.isWasiLibC()) { | 64 | _ = @import("c/unistd.zig"); |
| 40 | // Files specific to wasi-libc. | ||
| 41 | } | ||
| 42 | |||
| 43 | if (builtin.target.isMinGW()) { | ||
| 44 | // Files specific to MinGW-w64. | ||
| 45 | } | ||
| 46 | } | 65 | } |
lib/c/common.zig deleted-29| ... | @@ -1,29 +0,0 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | ||
| 3 | |||
| 4 | /// It is incorrect to make this conditional on `builtin.is_test`, because it is possible that | ||
| 5 | /// libzigc is being linked into a different test compilation, as opposed to being tested itself. | ||
| 6 | pub const linkage: std.builtin.GlobalLinkage = .strong; | ||
| 7 | |||
| 8 | /// Determines the symbol's visibility to other objects. | ||
| 9 | /// For WebAssembly this allows the symbol to be resolved to other modules, but will not | ||
| 10 | /// export it to the host runtime. | ||
| 11 | pub const visibility: std.builtin.SymbolVisibility = .hidden; | ||
| 12 | |||
| 13 | /// Given a low-level syscall return value, sets errno and returns `-1`, or on | ||
| 14 | /// success returns the result. | ||
| 15 | pub fn errno(syscall_return_value: usize) c_int { | ||
| 16 | return switch (builtin.os.tag) { | ||
| 17 | .linux => { | ||
| 18 | const signed: isize = @bitCast(syscall_return_value); | ||
| 19 | const casted: c_int = @intCast(signed); | ||
| 20 | if (casted < 0) { | ||
| 21 | @branchHint(.unlikely); | ||
| 22 | std.c._errno().* = -casted; | ||
| 23 | return -1; | ||
| 24 | } | ||
| 25 | return casted; | ||
| 26 | }, | ||
| 27 | else => comptime unreachable, | ||
| 28 | }; | ||
| 29 | } | ||
lib/c/ctype.zig+49-49| ... | @@ -1,57 +1,57 @@ | ... | @@ -1,57 +1,57 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const std = @import("std"); | ||
| 3 | const symbol = @import("../c.zig").symbol; | ||
| 4 | 4 | ||
| 5 | comptime { | 5 | comptime { |
| 6 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 6 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 7 | // Functions specific to musl and wasi-libc. | 7 | // Functions specific to musl and wasi-libc. |
| 8 | @export(&isalnum, .{ .name = "isalnum", .linkage = common.linkage, .visibility = common.visibility }); | 8 | symbol(&isalnum, "isalnum"); |
| 9 | @export(&isalpha, .{ .name = "isalpha", .linkage = common.linkage, .visibility = common.visibility }); | 9 | symbol(&isalpha, "isalpha"); |
| 10 | @export(&isblank, .{ .name = "isblank", .linkage = common.linkage, .visibility = common.visibility }); | 10 | symbol(&isblank, "isblank"); |
| 11 | @export(&iscntrl, .{ .name = "iscntrl", .linkage = common.linkage, .visibility = common.visibility }); | 11 | symbol(&iscntrl, "iscntrl"); |
| 12 | @export(&isdigit, .{ .name = "isdigit", .linkage = common.linkage, .visibility = common.visibility }); | 12 | symbol(&isdigit, "isdigit"); |
| 13 | @export(&isgraph, .{ .name = "isgraph", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&isgraph, "isgraph"); |
| 14 | @export(&islower, .{ .name = "islower", .linkage = common.linkage, .visibility = common.visibility }); | 14 | symbol(&islower, "islower"); |
| 15 | @export(&isprint, .{ .name = "isprint", .linkage = common.linkage, .visibility = common.visibility }); | 15 | symbol(&isprint, "isprint"); |
| 16 | @export(&ispunct, .{ .name = "ispunct", .linkage = common.linkage, .visibility = common.visibility }); | 16 | symbol(&ispunct, "ispunct"); |
| 17 | @export(&isspace, .{ .name = "isspace", .linkage = common.linkage, .visibility = common.visibility }); | 17 | symbol(&isspace, "isspace"); |
| 18 | @export(&isupper, .{ .name = "isupper", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&isupper, "isupper"); |
| 19 | @export(&isxdigit, .{ .name = "isxdigit", .linkage = common.linkage, .visibility = common.visibility }); | 19 | symbol(&isxdigit, "isxdigit"); |
| 20 | @export(&tolower, .{ .name = "tolower", .linkage = common.linkage, .visibility = common.visibility }); | 20 | symbol(&tolower, "tolower"); |
| 21 | @export(&toupper, .{ .name = "toupper", .linkage = common.linkage, .visibility = common.visibility }); | 21 | symbol(&toupper, "toupper"); |
| 22 | 22 | ||
| 23 | @export(&__isalnum_l, .{ .name = "__isalnum_l", .linkage = common.linkage, .visibility = common.visibility }); | 23 | symbol(&__isalnum_l, "__isalnum_l"); |
| 24 | @export(&__isalpha_l, .{ .name = "__isalpha_l", .linkage = common.linkage, .visibility = common.visibility }); | 24 | symbol(&__isalpha_l, "__isalpha_l"); |
| 25 | @export(&__isblank_l, .{ .name = "__isblank_l", .linkage = common.linkage, .visibility = common.visibility }); | 25 | symbol(&__isblank_l, "__isblank_l"); |
| 26 | @export(&__iscntrl_l, .{ .name = "__iscntrl_l", .linkage = common.linkage, .visibility = common.visibility }); | 26 | symbol(&__iscntrl_l, "__iscntrl_l"); |
| 27 | @export(&__isdigit_l, .{ .name = "__isdigit_l", .linkage = common.linkage, .visibility = common.visibility }); | 27 | symbol(&__isdigit_l, "__isdigit_l"); |
| 28 | @export(&__isgraph_l, .{ .name = "__isgraph_l", .linkage = common.linkage, .visibility = common.visibility }); | 28 | symbol(&__isgraph_l, "__isgraph_l"); |
| 29 | @export(&__islower_l, .{ .name = "__islower_l", .linkage = common.linkage, .visibility = common.visibility }); | 29 | symbol(&__islower_l, "__islower_l"); |
| 30 | @export(&__isprint_l, .{ .name = "__isprint_l", .linkage = common.linkage, .visibility = common.visibility }); | 30 | symbol(&__isprint_l, "__isprint_l"); |
| 31 | @export(&__ispunct_l, .{ .name = "__ispunct_l", .linkage = common.linkage, .visibility = common.visibility }); | 31 | symbol(&__ispunct_l, "__ispunct_l"); |
| 32 | @export(&__isspace_l, .{ .name = "__isspace_l", .linkage = common.linkage, .visibility = common.visibility }); | 32 | symbol(&__isspace_l, "__isspace_l"); |
| 33 | @export(&__isupper_l, .{ .name = "__isupper_l", .linkage = common.linkage, .visibility = common.visibility }); | 33 | symbol(&__isupper_l, "__isupper_l"); |
| 34 | @export(&__isxdigit_l, .{ .name = "__isxdigit_l", .linkage = common.linkage, .visibility = common.visibility }); | 34 | symbol(&__isxdigit_l, "__isxdigit_l"); |
| 35 | @export(&__tolower_l, .{ .name = "__tolower_l", .linkage = common.linkage, .visibility = common.visibility }); | 35 | symbol(&__tolower_l, "__tolower_l"); |
| 36 | @export(&__toupper_l, .{ .name = "__toupper_l", .linkage = common.linkage, .visibility = common.visibility }); | 36 | symbol(&__toupper_l, "__toupper_l"); |
| 37 | 37 | ||
| 38 | @export(&__isalnum_l, .{ .name = "isalnum_l", .linkage = common.linkage, .visibility = common.visibility }); | 38 | symbol(&__isalnum_l, "isalnum_l"); |
| 39 | @export(&__isalpha_l, .{ .name = "isalpha_l", .linkage = common.linkage, .visibility = common.visibility }); | 39 | symbol(&__isalpha_l, "isalpha_l"); |
| 40 | @export(&__isblank_l, .{ .name = "isblank_l", .linkage = common.linkage, .visibility = common.visibility }); | 40 | symbol(&__isblank_l, "isblank_l"); |
| 41 | @export(&__iscntrl_l, .{ .name = "iscntrl_l", .linkage = common.linkage, .visibility = common.visibility }); | 41 | symbol(&__iscntrl_l, "iscntrl_l"); |
| 42 | @export(&__isdigit_l, .{ .name = "isdigit_l", .linkage = common.linkage, .visibility = common.visibility }); | 42 | symbol(&__isdigit_l, "isdigit_l"); |
| 43 | @export(&__isgraph_l, .{ .name = "isgraph_l", .linkage = common.linkage, .visibility = common.visibility }); | 43 | symbol(&__isgraph_l, "isgraph_l"); |
| 44 | @export(&__islower_l, .{ .name = "islower_l", .linkage = common.linkage, .visibility = common.visibility }); | 44 | symbol(&__islower_l, "islower_l"); |
| 45 | @export(&__isprint_l, .{ .name = "isprint_l", .linkage = common.linkage, .visibility = common.visibility }); | 45 | symbol(&__isprint_l, "isprint_l"); |
| 46 | @export(&__ispunct_l, .{ .name = "ispunct_l", .linkage = common.linkage, .visibility = common.visibility }); | 46 | symbol(&__ispunct_l, "ispunct_l"); |
| 47 | @export(&__isspace_l, .{ .name = "isspace_l", .linkage = common.linkage, .visibility = common.visibility }); | 47 | symbol(&__isspace_l, "isspace_l"); |
| 48 | @export(&__isupper_l, .{ .name = "isupper_l", .linkage = common.linkage, .visibility = common.visibility }); | 48 | symbol(&__isupper_l, "isupper_l"); |
| 49 | @export(&__isxdigit_l, .{ .name = "isxdigit_l", .linkage = common.linkage, .visibility = common.visibility }); | 49 | symbol(&__isxdigit_l, "isxdigit_l"); |
| 50 | @export(&__tolower_l, .{ .name = "tolower_l", .linkage = common.linkage, .visibility = common.visibility }); | 50 | symbol(&__tolower_l, "tolower_l"); |
| 51 | @export(&__toupper_l, .{ .name = "toupper_l", .linkage = common.linkage, .visibility = common.visibility }); | 51 | symbol(&__toupper_l, "toupper_l"); |
| 52 | 52 | ||
| 53 | @export(&isascii, .{ .name = "isascii", .linkage = common.linkage, .visibility = common.visibility }); | 53 | symbol(&isascii, "isascii"); |
| 54 | @export(&toascii, .{ .name = "toascii", .linkage = common.linkage, .visibility = common.visibility }); | 54 | symbol(&toascii, "toascii"); |
| 55 | } | 55 | } |
| 56 | } | 56 | } |
| 57 | 57 |
lib/c/inttypes.zig+6-4| ... | @@ -1,14 +1,16 @@ | ... | @@ -1,14 +1,16 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | |||
| 3 | const std = @import("std"); | ||
| 4 | const intmax_t = std.c.intmax_t; | 4 | const intmax_t = std.c.intmax_t; |
| 5 | const imaxdiv_t = std.c.imaxdiv_t; | 5 | const imaxdiv_t = std.c.imaxdiv_t; |
| 6 | 6 | ||
| 7 | const symbol = @import("../c.zig").symbol; | ||
| 8 | |||
| 7 | comptime { | 9 | comptime { |
| 8 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 10 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 9 | // Functions specific to musl and wasi-libc. | 11 | // Functions specific to musl and wasi-libc. |
| 10 | @export(&imaxabs, .{ .name = "imaxabs", .linkage = common.linkage, .visibility = common.visibility }); | 12 | symbol(&imaxabs, "imaxabs"); |
| 11 | @export(&imaxdiv, .{ .name = "imaxdiv", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&imaxdiv, "imaxdiv"); |
| 12 | } | 14 | } |
| 13 | } | 15 | } |
| 14 | 16 |
lib/c/math.zig+41-39| ... | @@ -1,57 +1,59 @@ | ... | @@ -1,57 +1,59 @@ |
| 1 | const builtin = @import("builtin"); | ||
| 2 | |||
| 1 | const std = @import("std"); | 3 | const std = @import("std"); |
| 2 | const math = std.math; | 4 | const math = std.math; |
| 3 | const common = @import("common.zig"); | 5 | |
| 4 | const builtin = @import("builtin"); | 6 | const symbol = @import("../c.zig").symbol; |
| 5 | 7 | ||
| 6 | comptime { | 8 | comptime { |
| 7 | if (builtin.target.isMinGW()) { | 9 | if (builtin.target.isMinGW()) { |
| 8 | @export(&isnan, .{ .name = "isnan", .linkage = common.linkage, .visibility = common.visibility }); | 10 | symbol(&isnan, "isnan"); |
| 9 | @export(&isnan, .{ .name = "__isnan", .linkage = common.linkage, .visibility = common.visibility }); | 11 | symbol(&isnan, "__isnan"); |
| 10 | @export(&isnanf, .{ .name = "isnanf", .linkage = common.linkage, .visibility = common.visibility }); | 12 | symbol(&isnanf, "isnanf"); |
| 11 | @export(&isnanf, .{ .name = "__isnanf", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&isnanf, "__isnanf"); |
| 12 | @export(&isnanl, .{ .name = "isnanl", .linkage = common.linkage, .visibility = common.visibility }); | 14 | symbol(&isnanl, "isnanl"); |
| 13 | @export(&isnanl, .{ .name = "__isnanl", .linkage = common.linkage, .visibility = common.visibility }); | 15 | symbol(&isnanl, "__isnanl"); |
| 14 | 16 | ||
| 15 | @export(&math.nan(f64), .{ .name = "__QNAN", .linkage = common.linkage, .visibility = common.visibility }); | 17 | symbol(&math.nan(f64), "__QNAN"); |
| 16 | @export(&math.snan(f64), .{ .name = "__SNAN", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&math.snan(f64), "__SNAN"); |
| 17 | @export(&math.inf(f64), .{ .name = "__INF", .linkage = common.linkage, .visibility = common.visibility }); | 19 | symbol(&math.inf(f64), "__INF"); |
| 18 | @export(&math.floatTrueMin(f64), .{ .name = "__DENORM", .linkage = common.linkage, .visibility = common.visibility }); | 20 | symbol(&math.floatTrueMin(f64), "__DENORM"); |
| 19 | 21 | ||
| 20 | @export(&math.nan(f32), .{ .name = "__QNANF", .linkage = common.linkage, .visibility = common.visibility }); | 22 | symbol(&math.nan(f32), "__QNANF"); |
| 21 | @export(&math.snan(f32), .{ .name = "__SNANF", .linkage = common.linkage, .visibility = common.visibility }); | 23 | symbol(&math.snan(f32), "__SNANF"); |
| 22 | @export(&math.inf(f32), .{ .name = "__INFF", .linkage = common.linkage, .visibility = common.visibility }); | 24 | symbol(&math.inf(f32), "__INFF"); |
| 23 | @export(&math.floatTrueMin(f32), .{ .name = "__DENORMF", .linkage = common.linkage, .visibility = common.visibility }); | 25 | symbol(&math.floatTrueMin(f32), "__DENORMF"); |
| 24 | 26 | ||
| 25 | @export(&math.nan(c_longdouble), .{ .name = "__QNANL", .linkage = common.linkage, .visibility = common.visibility }); | 27 | symbol(&math.nan(c_longdouble), "__QNANL"); |
| 26 | @export(&math.snan(c_longdouble), .{ .name = "__SNANL", .linkage = common.linkage, .visibility = common.visibility }); | 28 | symbol(&math.snan(c_longdouble), "__SNANL"); |
| 27 | @export(&math.inf(c_longdouble), .{ .name = "__INFL", .linkage = common.linkage, .visibility = common.visibility }); | 29 | symbol(&math.inf(c_longdouble), "__INFL"); |
| 28 | @export(&math.floatTrueMin(c_longdouble), .{ .name = "__DENORML", .linkage = common.linkage, .visibility = common.visibility }); | 30 | symbol(&math.floatTrueMin(c_longdouble), "__DENORML"); |
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | if (builtin.target.isMinGW() or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 33 | if (builtin.target.isMinGW() or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 32 | @export(&hypotf, .{ .name = "hypotf", .linkage = common.linkage, .visibility = common.visibility }); | 34 | symbol(&hypotf, "hypotf"); |
| 33 | @export(&hypotl, .{ .name = "hypotl", .linkage = common.linkage, .visibility = common.visibility }); | 35 | symbol(&hypotl, "hypotl"); |
| 34 | @export(&nan, .{ .name = "nan", .linkage = common.linkage, .visibility = common.visibility }); | 36 | symbol(&nan, "nan"); |
| 35 | @export(&nanf, .{ .name = "nanf", .linkage = common.linkage, .visibility = common.visibility }); | 37 | symbol(&nanf, "nanf"); |
| 36 | @export(&nanl, .{ .name = "nanl", .linkage = common.linkage, .visibility = common.visibility }); | 38 | symbol(&nanl, "nanl"); |
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 41 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 40 | @export(&acos, .{ .name = "acos", .linkage = common.linkage, .visibility = common.visibility }); | 42 | symbol(&acos, "acos"); |
| 41 | @export(&atanf, .{ .name = "atanf", .linkage = common.linkage, .visibility = common.visibility }); | 43 | symbol(&atanf, "atanf"); |
| 42 | @export(&atan, .{ .name = "atan", .linkage = common.linkage, .visibility = common.visibility }); | 44 | symbol(&atan, "atan"); |
| 43 | @export(&atanl, .{ .name = "atanl", .linkage = common.linkage, .visibility = common.visibility }); | 45 | symbol(&atanl, "atanl"); |
| 44 | @export(&cbrt, .{ .name = "cbrt", .linkage = common.linkage, .visibility = common.visibility }); | 46 | symbol(&cbrt, "cbrt"); |
| 45 | @export(&cbrtf, .{ .name = "cbrtf", .linkage = common.linkage, .visibility = common.visibility }); | 47 | symbol(&cbrtf, "cbrtf"); |
| 46 | @export(&hypot, .{ .name = "hypot", .linkage = common.linkage, .visibility = common.visibility }); | 48 | symbol(&hypot, "hypot"); |
| 47 | @export(&pow, .{ .name = "pow", .linkage = common.linkage, .visibility = common.visibility }); | 49 | symbol(&pow, "pow"); |
| 48 | } | 50 | } |
| 49 | 51 | ||
| 50 | if (builtin.target.isMuslLibC()) { | 52 | if (builtin.target.isMuslLibC()) { |
| 51 | @export(&copysignf, .{ .name = "copysignf", .linkage = common.linkage, .visibility = common.visibility }); | 53 | symbol(&copysignf, "copysignf"); |
| 52 | @export(&copysign, .{ .name = "copysign", .linkage = common.linkage, .visibility = common.visibility }); | 54 | symbol(&copysign, "copysign"); |
| 53 | } | 55 | } |
| 54 | @export(&copysignl, .{ .name = "copysignl", .linkage = common.linkage, .visibility = common.visibility }); | 56 | symbol(&copysignl, "copysignl"); |
| 55 | } | 57 | } |
| 56 | 58 | ||
| 57 | fn acos(x: f64) callconv(.c) f64 { | 59 | fn acos(x: f64) callconv(.c) f64 { |
lib/c/stdlib.zig+34-32| ... | @@ -1,47 +1,49 @@ | ... | @@ -1,47 +1,49 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | |||
| 3 | const std = @import("std"); | ||
| 4 | const assert = std.debug.assert; | 4 | const assert = std.debug.assert; |
| 5 | const div_t = std.c.div_t; | 5 | const div_t = std.c.div_t; |
| 6 | const ldiv_t = std.c.ldiv_t; | 6 | const ldiv_t = std.c.ldiv_t; |
| 7 | const lldiv_t = std.c.lldiv_t; | 7 | const lldiv_t = std.c.lldiv_t; |
| 8 | 8 | ||
| 9 | const symbol = @import("../c.zig").symbol; | ||
| 10 | |||
| 9 | comptime { | 11 | comptime { |
| 10 | _ = @import("stdlib/rand.zig"); | 12 | _ = @import("stdlib/rand.zig"); |
| 11 | _ = @import("stdlib/drand48.zig"); | 13 | _ = @import("stdlib/drand48.zig"); |
| 12 | 14 | ||
| 13 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 15 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 14 | // Functions specific to musl and wasi-libc. | 16 | // Functions specific to musl and wasi-libc. |
| 15 | @export(&abs, .{ .name = "abs", .linkage = common.linkage, .visibility = common.visibility }); | 17 | symbol(&abs, "abs"); |
| 16 | @export(&labs, .{ .name = "labs", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&labs, "labs"); |
| 17 | @export(&llabs, .{ .name = "llabs", .linkage = common.linkage, .visibility = common.visibility }); | 19 | symbol(&llabs, "llabs"); |
| 18 | 20 | ||
| 19 | @export(&div, .{ .name = "div", .linkage = common.linkage, .visibility = common.visibility }); | 21 | symbol(&div, "div"); |
| 20 | @export(&ldiv, .{ .name = "ldiv", .linkage = common.linkage, .visibility = common.visibility }); | 22 | symbol(&ldiv, "ldiv"); |
| 21 | @export(&lldiv, .{ .name = "lldiv", .linkage = common.linkage, .visibility = common.visibility }); | 23 | symbol(&lldiv, "lldiv"); |
| 22 | 24 | ||
| 23 | @export(&atoi, .{ .name = "atoi", .linkage = common.linkage, .visibility = common.visibility }); | 25 | symbol(&atoi, "atoi"); |
| 24 | @export(&atol, .{ .name = "atol", .linkage = common.linkage, .visibility = common.visibility }); | 26 | symbol(&atol, "atol"); |
| 25 | @export(&atoll, .{ .name = "atoll", .linkage = common.linkage, .visibility = common.visibility }); | 27 | symbol(&atoll, "atoll"); |
| 26 | 28 | ||
| 27 | @export(&strtol, .{ .name = "strtol", .linkage = common.linkage, .visibility = common.visibility }); | 29 | symbol(&strtol, "strtol"); |
| 28 | @export(&strtoll, .{ .name = "strtoll", .linkage = common.linkage, .visibility = common.visibility }); | 30 | symbol(&strtoll, "strtoll"); |
| 29 | @export(&strtoul, .{ .name = "strtoul", .linkage = common.linkage, .visibility = common.visibility }); | 31 | symbol(&strtoul, "strtoul"); |
| 30 | @export(&strtoull, .{ .name = "strtoull", .linkage = common.linkage, .visibility = common.visibility }); | 32 | symbol(&strtoull, "strtoull"); |
| 31 | @export(&strtoimax, .{ .name = "strtoimax", .linkage = common.linkage, .visibility = common.visibility }); | 33 | symbol(&strtoimax, "strtoimax"); |
| 32 | @export(&strtoumax, .{ .name = "strtoumax", .linkage = common.linkage, .visibility = common.visibility }); | 34 | symbol(&strtoumax, "strtoumax"); |
| 33 | 35 | ||
| 34 | @export(&strtol, .{ .name = "__strtol_internal", .linkage = common.linkage, .visibility = common.visibility }); | 36 | symbol(&strtol, "__strtol_internal"); |
| 35 | @export(&strtoll, .{ .name = "__strtoll_internal", .linkage = common.linkage, .visibility = common.visibility }); | 37 | symbol(&strtoll, "__strtoll_internal"); |
| 36 | @export(&strtoul, .{ .name = "__strtoul_internal", .linkage = common.linkage, .visibility = common.visibility }); | 38 | symbol(&strtoul, "__strtoul_internal"); |
| 37 | @export(&strtoull, .{ .name = "__strtoull_internal", .linkage = common.linkage, .visibility = common.visibility }); | 39 | symbol(&strtoull, "__strtoull_internal"); |
| 38 | @export(&strtoimax, .{ .name = "__strtoimax_internal", .linkage = common.linkage, .visibility = common.visibility }); | 40 | symbol(&strtoimax, "__strtoimax_internal"); |
| 39 | @export(&strtoumax, .{ .name = "__strtoumax_internal", .linkage = common.linkage, .visibility = common.visibility }); | 41 | symbol(&strtoumax, "__strtoumax_internal"); |
| 40 | 42 | ||
| 41 | @export(&qsort_r, .{ .name = "qsort_r", .linkage = common.linkage, .visibility = common.visibility }); | 43 | symbol(&qsort_r, "qsort_r"); |
| 42 | @export(&qsort, .{ .name = "qsort", .linkage = common.linkage, .visibility = common.visibility }); | 44 | symbol(&qsort, "qsort"); |
| 43 | 45 | ||
| 44 | @export(&bsearch, .{ .name = "bsearch", .linkage = common.linkage, .visibility = common.visibility }); | 46 | symbol(&bsearch, "bsearch"); |
| 45 | } | 47 | } |
| 46 | } | 48 | } |
| 47 | 49 |
lib/c/stdlib/drand48.zig+13-11| ... | @@ -1,21 +1,23 @@ | ... | @@ -1,21 +1,23 @@ |
| 1 | //! drand48 functions are based off a 48-bit lcg prng: https://pubs.opengroup.org/onlinepubs/9799919799/functions/drand48.html | 1 | //! drand48 functions are based off a 48-bit lcg prng: https://pubs.opengroup.org/onlinepubs/9799919799/functions/drand48.html |
| 2 | 2 | ||
| 3 | const std = @import("std"); | ||
| 4 | const common = @import("../common.zig"); | ||
| 5 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | |||
| 5 | const std = @import("std"); | ||
| 6 | const Lcg = std.Random.lcg.Wrapping(u48); | 6 | const Lcg = std.Random.lcg.Wrapping(u48); |
| 7 | 7 | ||
| 8 | const symbol = @import("../../c.zig").symbol; | ||
| 9 | |||
| 8 | comptime { | 10 | comptime { |
| 9 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 11 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 10 | @export(&erand48, .{ .name = "erand48", .linkage = common.linkage, .visibility = common.visibility }); | 12 | symbol(&erand48, "erand48"); |
| 11 | @export(&jrand48, .{ .name = "jrand48", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&jrand48, "jrand48"); |
| 12 | @export(&nrand48, .{ .name = "nrand48", .linkage = common.linkage, .visibility = common.visibility }); | 14 | symbol(&nrand48, "nrand48"); |
| 13 | @export(&drand48, .{ .name = "drand48", .linkage = common.linkage, .visibility = common.visibility }); | 15 | symbol(&drand48, "drand48"); |
| 14 | @export(&lrand48, .{ .name = "lrand48", .linkage = common.linkage, .visibility = common.visibility }); | 16 | symbol(&lrand48, "lrand48"); |
| 15 | @export(&mrand48, .{ .name = "mrand48", .linkage = common.linkage, .visibility = common.visibility }); | 17 | symbol(&mrand48, "mrand48"); |
| 16 | @export(&lcong48, .{ .name = "lcong48", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&lcong48, "lcong48"); |
| 17 | @export(&seed48, .{ .name = "seed48", .linkage = common.linkage, .visibility = common.visibility }); | 19 | symbol(&seed48, "seed48"); |
| 18 | @export(&srand48, .{ .name = "srand48", .linkage = common.linkage, .visibility = common.visibility }); | 20 | symbol(&srand48, "srand48"); |
| 19 | } | 21 | } |
| 20 | } | 22 | } |
| 21 | 23 |
lib/c/stdlib/rand.zig+5-5| ... | @@ -1,12 +1,12 @@ | ... | @@ -1,12 +1,12 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const std = @import("std"); | ||
| 3 | const symbol = @import("../../c.zig").symbol; | ||
| 4 | 4 | ||
| 5 | comptime { | 5 | comptime { |
| 6 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 6 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 7 | @export(&rand, .{ .name = "rand", .linkage = common.linkage, .visibility = common.visibility }); | 7 | symbol(&rand, "rand"); |
| 8 | @export(&srand, .{ .name = "srand", .linkage = common.linkage, .visibility = common.visibility }); | 8 | symbol(&srand, "srand"); |
| 9 | @export(&rand_r, .{ .name = "rand_r", .linkage = common.linkage, .visibility = common.visibility }); | 9 | symbol(&rand_r, "rand_r"); |
| 10 | } | 10 | } |
| 11 | } | 11 | } |
| 12 | 12 |
lib/c/string.zig+42-42| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | const common = @import("common.zig"); | 3 | const symbol = @import("../c.zig").symbol; |
| 4 | 4 | ||
| 5 | comptime { | 5 | comptime { |
| 6 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 6 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| ... | @@ -8,58 +8,58 @@ comptime { | ... | @@ -8,58 +8,58 @@ comptime { |
| 8 | // memmove implemented in compiler_rt | 8 | // memmove implemented in compiler_rt |
| 9 | // memset implemented in compiler_rt | 9 | // memset implemented in compiler_rt |
| 10 | // memcmp implemented in compiler_rt | 10 | // memcmp implemented in compiler_rt |
| 11 | @export(&memchr, .{ .name = "memchr", .linkage = common.linkage, .visibility = common.visibility }); | 11 | symbol(&memchr, "memchr"); |
| 12 | @export(&strcpy, .{ .name = "strcpy", .linkage = common.linkage, .visibility = common.visibility }); | 12 | symbol(&strcpy, "strcpy"); |
| 13 | @export(&strncpy, .{ .name = "strncpy", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&strncpy, "strncpy"); |
| 14 | @export(&strcat, .{ .name = "strcat", .linkage = common.linkage, .visibility = common.visibility }); | 14 | symbol(&strcat, "strcat"); |
| 15 | @export(&strncat, .{ .name = "strncat", .linkage = common.linkage, .visibility = common.visibility }); | 15 | symbol(&strncat, "strncat"); |
| 16 | @export(&strcmp, .{ .name = "strcmp", .linkage = common.linkage, .visibility = common.visibility }); | 16 | symbol(&strcmp, "strcmp"); |
| 17 | @export(&strncmp, .{ .name = "strncmp", .linkage = common.linkage, .visibility = common.visibility }); | 17 | symbol(&strncmp, "strncmp"); |
| 18 | @export(&strcoll, .{ .name = "strcoll", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&strcoll, "strcoll"); |
| 19 | @export(&strxfrm, .{ .name = "strxfrm", .linkage = common.linkage, .visibility = common.visibility }); | 19 | symbol(&strxfrm, "strxfrm"); |
| 20 | @export(&strchr, .{ .name = "strchr", .linkage = common.linkage, .visibility = common.visibility }); | 20 | symbol(&strchr, "strchr"); |
| 21 | @export(&strrchr, .{ .name = "strrchr", .linkage = common.linkage, .visibility = common.visibility }); | 21 | symbol(&strrchr, "strrchr"); |
| 22 | @export(&strcspn, .{ .name = "strcspn", .linkage = common.linkage, .visibility = common.visibility }); | 22 | symbol(&strcspn, "strcspn"); |
| 23 | @export(&strspn, .{ .name = "strspn", .linkage = common.linkage, .visibility = common.visibility }); | 23 | symbol(&strspn, "strspn"); |
| 24 | @export(&strpbrk, .{ .name = "strpbrk", .linkage = common.linkage, .visibility = common.visibility }); | 24 | symbol(&strpbrk, "strpbrk"); |
| 25 | @export(&strstr, .{ .name = "strstr", .linkage = common.linkage, .visibility = common.visibility }); | 25 | symbol(&strstr, "strstr"); |
| 26 | @export(&strtok, .{ .name = "strtok", .linkage = common.linkage, .visibility = common.visibility }); | 26 | symbol(&strtok, "strtok"); |
| 27 | // strlen is in compiler_rt | 27 | // strlen is in compiler_rt |
| 28 | 28 | ||
| 29 | @export(&strtok_r, .{ .name = "strtok_r", .linkage = common.linkage, .visibility = common.visibility }); | 29 | symbol(&strtok_r, "strtok_r"); |
| 30 | @export(&stpcpy, .{ .name = "stpcpy", .linkage = common.linkage, .visibility = common.visibility }); | 30 | symbol(&stpcpy, "stpcpy"); |
| 31 | @export(&stpncpy, .{ .name = "stpncpy", .linkage = common.linkage, .visibility = common.visibility }); | 31 | symbol(&stpncpy, "stpncpy"); |
| 32 | @export(&strnlen, .{ .name = "strnlen", .linkage = common.linkage, .visibility = common.visibility }); | 32 | symbol(&strnlen, "strnlen"); |
| 33 | @export(&memmem, .{ .name = "memmem", .linkage = common.linkage, .visibility = common.visibility }); | 33 | symbol(&memmem, "memmem"); |
| 34 | 34 | ||
| 35 | @export(&memccpy, .{ .name = "memccpy", .linkage = common.linkage, .visibility = common.visibility }); | 35 | symbol(&memccpy, "memccpy"); |
| 36 | 36 | ||
| 37 | @export(&strsep, .{ .name = "strsep", .linkage = common.linkage, .visibility = common.visibility }); | 37 | symbol(&strsep, "strsep"); |
| 38 | @export(&strlcat, .{ .name = "strlcat", .linkage = common.linkage, .visibility = common.visibility }); | 38 | symbol(&strlcat, "strlcat"); |
| 39 | @export(&strlcpy, .{ .name = "strlcpy", .linkage = common.linkage, .visibility = common.visibility }); | 39 | symbol(&strlcpy, "strlcpy"); |
| 40 | @export(&explicit_bzero, .{ .name = "explicit_bzero", .linkage = common.linkage, .visibility = common.visibility }); | 40 | symbol(&explicit_bzero, "explicit_bzero"); |
| 41 | 41 | ||
| 42 | @export(&strchrnul, .{ .name = "strchrnul", .linkage = common.linkage, .visibility = common.visibility }); | 42 | symbol(&strchrnul, "strchrnul"); |
| 43 | @export(&strcasestr, .{ .name = "strcasestr", .linkage = common.linkage, .visibility = common.visibility }); | 43 | symbol(&strcasestr, "strcasestr"); |
| 44 | @export(&memrchr, .{ .name = "memrchr", .linkage = common.linkage, .visibility = common.visibility }); | 44 | symbol(&memrchr, "memrchr"); |
| 45 | @export(&mempcpy, .{ .name = "mempcpy", .linkage = common.linkage, .visibility = common.visibility }); | 45 | symbol(&mempcpy, "mempcpy"); |
| 46 | 46 | ||
| 47 | @export(&__strcoll_l, .{ .name = "__strcoll_l", .linkage = common.linkage, .visibility = common.visibility }); | 47 | symbol(&__strcoll_l, "__strcoll_l"); |
| 48 | @export(&__strxfrm_l, .{ .name = "__strxfrm_l", .linkage = common.linkage, .visibility = common.visibility }); | 48 | symbol(&__strxfrm_l, "__strxfrm_l"); |
| 49 | @export(&__strcoll_l, .{ .name = "strcoll_l", .linkage = common.linkage, .visibility = common.visibility }); | 49 | symbol(&__strcoll_l, "strcoll_l"); |
| 50 | @export(&__strxfrm_l, .{ .name = "strxfrm_l", .linkage = common.linkage, .visibility = common.visibility }); | 50 | symbol(&__strxfrm_l, "strxfrm_l"); |
| 51 | 51 | ||
| 52 | // These symbols are not in the public ABI of musl/wasi. However they depend on these exports internally. | 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 }); | 53 | symbol(&stpcpy, "__stpcpy"); |
| 54 | @export(&stpncpy, .{ .name = "__stpncpy", .linkage = common.linkage, .visibility = common.visibility }); | 54 | symbol(&stpncpy, "__stpncpy"); |
| 55 | @export(&strchrnul, .{ .name = "__strchrnul", .linkage = common.linkage, .visibility = common.visibility }); | 55 | symbol(&strchrnul, "__strchrnul"); |
| 56 | @export(&memrchr, .{ .name = "__memrchr", .linkage = common.linkage, .visibility = common.visibility }); | 56 | symbol(&memrchr, "__memrchr"); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | if (builtin.target.isMinGW()) { | 59 | if (builtin.target.isMinGW()) { |
| 60 | @export(&strnlen, .{ .name = "strnlen", .linkage = common.linkage, .visibility = common.visibility }); | 60 | symbol(&strnlen, "strnlen"); |
| 61 | @export(&mempcpy, .{ .name = "mempcpy", .linkage = common.linkage, .visibility = common.visibility }); | 61 | symbol(&mempcpy, "mempcpy"); |
| 62 | @export(&strtok_r, .{ .name = "strtok_r", .linkage = common.linkage, .visibility = common.visibility }); | 62 | symbol(&strtok_r, "strtok_r"); |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 |
lib/c/strings.zig+15-15| ... | @@ -1,27 +1,27 @@ | ... | @@ -1,27 +1,27 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | const std = @import("std"); | ||
| 3 | const symbol = @import("../c.zig").symbol; | ||
| 4 | 4 | ||
| 5 | comptime { | 5 | comptime { |
| 6 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 6 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 7 | // bcmp is implemented in compiler_rt | 7 | // bcmp is implemented in compiler_rt |
| 8 | @export(&bcopy, .{ .name = "bcopy", .linkage = common.linkage, .visibility = common.visibility }); | 8 | symbol(&bcopy, "bcopy"); |
| 9 | @export(&bzero, .{ .name = "bzero", .linkage = common.linkage, .visibility = common.visibility }); | 9 | symbol(&bzero, "bzero"); |
| 10 | @export(&index, .{ .name = "index", .linkage = common.linkage, .visibility = common.visibility }); | 10 | symbol(&index, "index"); |
| 11 | @export(&rindex, .{ .name = "rindex", .linkage = common.linkage, .visibility = common.visibility }); | 11 | symbol(&rindex, "rindex"); |
| 12 | 12 | ||
| 13 | @export(&ffs, .{ .name = "ffs", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&ffs, "ffs"); |
| 14 | @export(&ffsl, .{ .name = "ffsl", .linkage = common.linkage, .visibility = common.visibility }); | 14 | symbol(&ffsl, "ffsl"); |
| 15 | @export(&ffsll, .{ .name = "ffsll", .linkage = common.linkage, .visibility = common.visibility }); | 15 | symbol(&ffsll, "ffsll"); |
| 16 | 16 | ||
| 17 | @export(&strcasecmp, .{ .name = "strcasecmp", .linkage = common.linkage, .visibility = common.visibility }); | 17 | symbol(&strcasecmp, "strcasecmp"); |
| 18 | @export(&strncasecmp, .{ .name = "strncasecmp", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&strncasecmp, "strncasecmp"); |
| 19 | 19 | ||
| 20 | @export(&__strcasecmp_l, .{ .name = "__strcasecmp_l", .linkage = common.linkage, .visibility = common.visibility }); | 20 | symbol(&__strcasecmp_l, "__strcasecmp_l"); |
| 21 | @export(&__strncasecmp_l, .{ .name = "__strncasecmp_l", .linkage = common.linkage, .visibility = common.visibility }); | 21 | symbol(&__strncasecmp_l, "__strncasecmp_l"); |
| 22 | 22 | ||
| 23 | @export(&__strcasecmp_l, .{ .name = "strcasecmp_l", .linkage = .weak, .visibility = common.visibility }); | 23 | symbol(&__strcasecmp_l, "strcasecmp_l"); |
| 24 | @export(&__strncasecmp_l, .{ .name = "strncasecmp_l", .linkage = .weak, .visibility = common.visibility }); | 24 | symbol(&__strncasecmp_l, "strncasecmp_l"); |
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 |
lib/c/sys.zig deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | comptime { | ||
| 2 | _ = @import("sys/mman.zig"); | ||
| 3 | _ = @import("sys/file.zig"); | ||
| 4 | _ = @import("sys/reboot.zig"); | ||
| 5 | _ = @import("sys/capability.zig"); | ||
| 6 | _ = @import("sys/utsname.zig"); | ||
| 7 | } | ||
lib/c/sys/capability.zig+9-6| ... | @@ -1,18 +1,21 @@ | ... | @@ -1,18 +1,21 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 4 | 2 | ||
| 3 | const std = @import("std"); | ||
| 4 | |||
| 5 | const symbol = @import("../../c.zig").symbol; | ||
| 6 | const errno = @import("../../c.zig").errno; | ||
| 7 | |||
| 5 | comptime { | 8 | comptime { |
| 6 | if (builtin.target.isMuslLibC()) { | 9 | if (builtin.target.isMuslLibC()) { |
| 7 | @export(&capsetLinux, .{ .name = "capset", .linkage = common.linkage, .visibility = common.visibility }); | 10 | symbol(&capsetLinux, "capset"); |
| 8 | @export(&capgetLinux, .{ .name = "capget", .linkage = common.linkage, .visibility = common.visibility }); | 11 | symbol(&capgetLinux, "capget"); |
| 9 | } | 12 | } |
| 10 | } | 13 | } |
| 11 | 14 | ||
| 12 | fn capsetLinux(hdrp: *anyopaque, datap: *anyopaque) callconv(.c) c_int { | 15 | fn capsetLinux(hdrp: *anyopaque, datap: *anyopaque) callconv(.c) c_int { |
| 13 | return common.errno(std.os.linux.capset(@ptrCast(@alignCast(hdrp)), @ptrCast(@alignCast(datap)))); | 16 | return errno(std.os.linux.capset(@ptrCast(@alignCast(hdrp)), @ptrCast(@alignCast(datap)))); |
| 14 | } | 17 | } |
| 15 | 18 | ||
| 16 | fn capgetLinux(hdrp: *anyopaque, datap: *anyopaque) callconv(.c) c_int { | 19 | fn capgetLinux(hdrp: *anyopaque, datap: *anyopaque) callconv(.c) c_int { |
| 17 | return common.errno(std.os.linux.capget(@ptrCast(@alignCast(hdrp)), @ptrCast(@alignCast(datap)))); | 20 | return errno(std.os.linux.capget(@ptrCast(@alignCast(hdrp)), @ptrCast(@alignCast(datap)))); |
| 18 | } | 21 | } |
lib/c/sys/file.zig+7-4| ... | @@ -1,13 +1,16 @@ | ... | @@ -1,13 +1,16 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 4 | 2 | ||
| 3 | const std = @import("std"); | ||
| 4 | |||
| 5 | const symbol = @import("../../c.zig").symbol; | ||
| 6 | const errno = @import("../../c.zig").errno; | ||
| 7 | |||
| 5 | comptime { | 8 | comptime { |
| 6 | if (builtin.target.isMuslLibC()) { | 9 | if (builtin.target.isMuslLibC()) { |
| 7 | @export(&flockLinux, .{ .name = "flock", .linkage = common.linkage, .visibility = common.visibility }); | 10 | symbol(&flockLinux, "flock"); |
| 8 | } | 11 | } |
| 9 | } | 12 | } |
| 10 | 13 | ||
| 11 | fn flockLinux(fd: c_int, operation: c_int) callconv(.c) c_int { | 14 | fn flockLinux(fd: c_int, operation: c_int) callconv(.c) c_int { |
| 12 | return common.errno(std.os.linux.flock(fd, operation)); | 15 | return errno(std.os.linux.flock(fd, operation)); |
| 13 | } | 16 | } |
lib/c/sys/mman.zig+22-19| ... | @@ -1,56 +1,59 @@ | ... | @@ -1,56 +1,59 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 4 | 2 | ||
| 3 | const std = @import("std"); | ||
| 4 | |||
| 5 | const symbol = @import("../../c.zig").symbol; | ||
| 6 | const errno = @import("../../c.zig").errno; | ||
| 7 | |||
| 5 | comptime { | 8 | comptime { |
| 6 | if (builtin.target.isMuslLibC()) { | 9 | if (builtin.target.isMuslLibC()) { |
| 7 | @export(&madviseLinux, .{ .name = "madvise", .linkage = common.linkage, .visibility = common.visibility }); | 10 | symbol(&madviseLinux, "madvise"); |
| 8 | @export(&madviseLinux, .{ .name = "__madvise", .linkage = common.linkage, .visibility = common.visibility }); | 11 | symbol(&madviseLinux, "__madvise"); |
| 9 | 12 | ||
| 10 | @export(&mincoreLinux, .{ .name = "mincore", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&mincoreLinux, "mincore"); |
| 11 | 14 | ||
| 12 | @export(&mlockLinux, .{ .name = "mlock", .linkage = common.linkage, .visibility = common.visibility }); | 15 | symbol(&mlockLinux, "mlock"); |
| 13 | @export(&mlockallLinux, .{ .name = "mlockall", .linkage = common.linkage, .visibility = common.visibility }); | 16 | symbol(&mlockallLinux, "mlockall"); |
| 14 | 17 | ||
| 15 | @export(&mprotectLinux, .{ .name = "mprotect", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&mprotectLinux, "mprotect"); |
| 16 | @export(&mprotectLinux, .{ .name = "__mprotect", .linkage = common.linkage, .visibility = common.visibility }); | 19 | symbol(&mprotectLinux, "__mprotect"); |
| 17 | 20 | ||
| 18 | @export(&munlockLinux, .{ .name = "munlock", .linkage = common.linkage, .visibility = common.visibility }); | 21 | symbol(&munlockLinux, "munlock"); |
| 19 | @export(&munlockallLinux, .{ .name = "munlockall", .linkage = common.linkage, .visibility = common.visibility }); | 22 | symbol(&munlockallLinux, "munlockall"); |
| 20 | 23 | ||
| 21 | @export(&posix_madviseLinux, .{ .name = "posix_madvise", .linkage = common.linkage, .visibility = common.visibility }); | 24 | symbol(&posix_madviseLinux, "posix_madvise"); |
| 22 | } | 25 | } |
| 23 | } | 26 | } |
| 24 | 27 | ||
| 25 | fn madviseLinux(addr: *anyopaque, len: usize, advice: c_int) callconv(.c) c_int { | 28 | fn madviseLinux(addr: *anyopaque, len: usize, advice: c_int) callconv(.c) c_int { |
| 26 | return common.errno(std.os.linux.madvise(@ptrCast(addr), len, @bitCast(advice))); | 29 | return errno(std.os.linux.madvise(@ptrCast(addr), len, @bitCast(advice))); |
| 27 | } | 30 | } |
| 28 | 31 | ||
| 29 | fn mincoreLinux(addr: *anyopaque, len: usize, vec: [*]u8) callconv(.c) c_int { | 32 | fn mincoreLinux(addr: *anyopaque, len: usize, vec: [*]u8) callconv(.c) c_int { |
| 30 | return common.errno(std.os.linux.mincore(@ptrCast(addr), len, vec)); | 33 | return errno(std.os.linux.mincore(@ptrCast(addr), len, vec)); |
| 31 | } | 34 | } |
| 32 | 35 | ||
| 33 | fn mlockLinux(addr: *const anyopaque, len: usize) callconv(.c) c_int { | 36 | fn mlockLinux(addr: *const anyopaque, len: usize) callconv(.c) c_int { |
| 34 | return common.errno(std.os.linux.mlock(@ptrCast(addr), len)); | 37 | return errno(std.os.linux.mlock(@ptrCast(addr), len)); |
| 35 | } | 38 | } |
| 36 | 39 | ||
| 37 | fn mlockallLinux(flags: c_int) callconv(.c) c_int { | 40 | fn mlockallLinux(flags: c_int) callconv(.c) c_int { |
| 38 | return common.errno(std.os.linux.mlockall(@bitCast(flags))); | 41 | return errno(std.os.linux.mlockall(@bitCast(flags))); |
| 39 | } | 42 | } |
| 40 | 43 | ||
| 41 | fn mprotectLinux(addr: *anyopaque, len: usize, prot: c_int) callconv(.c) c_int { | 44 | fn mprotectLinux(addr: *anyopaque, len: usize, prot: c_int) callconv(.c) c_int { |
| 42 | const page_size = std.heap.pageSize(); | 45 | const page_size = std.heap.pageSize(); |
| 43 | const start = std.mem.alignBackward(usize, @intFromPtr(addr), page_size); | 46 | const start = std.mem.alignBackward(usize, @intFromPtr(addr), page_size); |
| 44 | const aligned_len = std.mem.alignForward(usize, len, page_size); | 47 | const aligned_len = std.mem.alignForward(usize, len, page_size); |
| 45 | return common.errno(std.os.linux.mprotect(@ptrFromInt(start), aligned_len, @bitCast(prot))); | 48 | return errno(std.os.linux.mprotect(@ptrFromInt(start), aligned_len, @bitCast(prot))); |
| 46 | } | 49 | } |
| 47 | 50 | ||
| 48 | fn munlockLinux(addr: *const anyopaque, len: usize) callconv(.c) c_int { | 51 | fn munlockLinux(addr: *const anyopaque, len: usize) callconv(.c) c_int { |
| 49 | return common.errno(std.os.linux.munlock(@ptrCast(addr), len)); | 52 | return errno(std.os.linux.munlock(@ptrCast(addr), len)); |
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | fn munlockallLinux() callconv(.c) c_int { | 55 | fn munlockallLinux() callconv(.c) c_int { |
| 53 | return common.errno(std.os.linux.munlockall()); | 56 | return errno(std.os.linux.munlockall()); |
| 54 | } | 57 | } |
| 55 | 58 | ||
| 56 | fn posix_madviseLinux(addr: *anyopaque, len: usize, advice: c_int) callconv(.c) c_int { | 59 | fn posix_madviseLinux(addr: *anyopaque, len: usize, advice: c_int) callconv(.c) c_int { |
lib/c/sys/reboot.zig+7-4| ... | @@ -1,13 +1,16 @@ | ... | @@ -1,13 +1,16 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 4 | 2 | ||
| 3 | const std = @import("std"); | ||
| 4 | |||
| 5 | const symbol = @import("../../c.zig").symbol; | ||
| 6 | const errno = @import("../../c.zig").errno; | ||
| 7 | |||
| 5 | comptime { | 8 | comptime { |
| 6 | if (builtin.target.isMuslLibC()) { | 9 | if (builtin.target.isMuslLibC()) { |
| 7 | @export(&rebootLinux, .{ .name = "reboot", .linkage = common.linkage, .visibility = common.visibility }); | 10 | symbol(&rebootLinux, "reboot"); |
| 8 | } | 11 | } |
| 9 | } | 12 | } |
| 10 | 13 | ||
| 11 | fn rebootLinux(cmd: c_int) callconv(.c) c_int { | 14 | fn rebootLinux(cmd: c_int) callconv(.c) c_int { |
| 12 | return common.errno(std.os.linux.reboot(.MAGIC1, .MAGIC2, @enumFromInt(cmd), null)); | 15 | return errno(std.os.linux.reboot(.MAGIC1, .MAGIC2, @enumFromInt(cmd), null)); |
| 13 | } | 16 | } |
lib/c/sys/utsname.zig+8-5| ... | @@ -1,19 +1,22 @@ | ... | @@ -1,19 +1,22 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 4 | 2 | ||
| 3 | const std = @import("std"); | ||
| 4 | |||
| 5 | const symbol = @import("../../c.zig").symbol; | ||
| 6 | const errno = @import("../../c.zig").errno; | ||
| 7 | |||
| 5 | comptime { | 8 | comptime { |
| 6 | if (builtin.target.isMuslLibC()) { | 9 | if (builtin.target.isMuslLibC()) { |
| 7 | @export(&unameLinux, .{ .name = "uname", .linkage = common.linkage, .visibility = common.visibility }); | 10 | symbol(&unameLinux, "uname"); |
| 8 | } | 11 | } |
| 9 | 12 | ||
| 10 | if (builtin.target.isWasiLibC()) { | 13 | if (builtin.target.isWasiLibC()) { |
| 11 | @export(&unameWasi, .{ .name = "uname", .linkage = common.linkage, .visibility = common.visibility }); | 14 | symbol(&unameWasi, "uname"); |
| 12 | } | 15 | } |
| 13 | } | 16 | } |
| 14 | 17 | ||
| 15 | fn unameLinux(uts: *std.os.linux.utsname) callconv(.c) c_int { | 18 | fn unameLinux(uts: *std.os.linux.utsname) callconv(.c) c_int { |
| 16 | return common.errno(std.os.linux.uname(uts)); | 19 | return errno(std.os.linux.uname(uts)); |
| 17 | } | 20 | } |
| 18 | 21 | ||
| 19 | fn unameWasi(uts: *std.c.utsname) callconv(.c) c_int { | 22 | fn unameWasi(uts: *std.c.utsname) callconv(.c) c_int { |
lib/c/unistd.zig+65-62| ... | @@ -1,50 +1,53 @@ | ... | @@ -1,50 +1,53 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | |||
| 3 | const std = @import("std"); | ||
| 4 | const linux = std.os.linux; | 4 | const linux = std.os.linux; |
| 5 | 5 | ||
| 6 | const symbol = @import("../c.zig").symbol; | ||
| 7 | const errno = @import("../c.zig").errno; | ||
| 8 | |||
| 6 | comptime { | 9 | comptime { |
| 7 | if (builtin.target.isMuslLibC()) { | 10 | if (builtin.target.isMuslLibC()) { |
| 8 | @export(&_exit, .{ .name = "_exit", .linkage = common.linkage, .visibility = common.visibility }); | 11 | symbol(&_exit, "_exit"); |
| 9 | 12 | ||
| 10 | @export(&accessLinux, .{ .name = "access", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&accessLinux, "access"); |
| 11 | @export(&acctLinux, .{ .name = "acct", .linkage = common.linkage, .visibility = common.visibility }); | 14 | symbol(&acctLinux, "acct"); |
| 12 | @export(&chdirLinux, .{ .name = "chdir", .linkage = common.linkage, .visibility = common.visibility }); | 15 | symbol(&chdirLinux, "chdir"); |
| 13 | @export(&chownLinux, .{ .name = "chown", .linkage = common.linkage, .visibility = common.visibility }); | 16 | symbol(&chownLinux, "chown"); |
| 14 | @export(&fchownatLinux, .{ .name = "fchownat", .linkage = common.linkage, .visibility = common.visibility }); | 17 | symbol(&fchownatLinux, "fchownat"); |
| 15 | @export(&lchownLinux, .{ .name = "lchown", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&lchownLinux, "lchown"); |
| 16 | @export(&chrootLinux, .{ .name = "chroot", .linkage = common.linkage, .visibility = common.visibility }); | 19 | symbol(&chrootLinux, "chroot"); |
| 17 | @export(&ctermidLinux, .{ .name = "ctermid", .linkage = common.linkage, .visibility = common.visibility }); | 20 | symbol(&ctermidLinux, "ctermid"); |
| 18 | @export(&dupLinux, .{ .name = "dup", .linkage = common.linkage, .visibility = common.visibility }); | 21 | symbol(&dupLinux, "dup"); |
| 19 | 22 | ||
| 20 | @export(&getegidLinux, .{ .name = "getegid", .linkage = common.linkage, .visibility = common.visibility }); | 23 | symbol(&getegidLinux, "getegid"); |
| 21 | @export(&geteuidLinux, .{ .name = "geteuid", .linkage = common.linkage, .visibility = common.visibility }); | 24 | symbol(&geteuidLinux, "geteuid"); |
| 22 | @export(&getgidLinux, .{ .name = "getgid", .linkage = common.linkage, .visibility = common.visibility }); | 25 | symbol(&getgidLinux, "getgid"); |
| 23 | @export(&getgroupsLinux, .{ .name = "getgroups", .linkage = common.linkage, .visibility = common.visibility }); | 26 | symbol(&getgroupsLinux, "getgroups"); |
| 24 | @export(&getpgidLinux, .{ .name = "getpgid", .linkage = common.linkage, .visibility = common.visibility }); | 27 | symbol(&getpgidLinux, "getpgid"); |
| 25 | @export(&getpgrpLinux, .{ .name = "getpgrp", .linkage = common.linkage, .visibility = common.visibility }); | 28 | symbol(&getpgrpLinux, "getpgrp"); |
| 26 | @export(&setpgidLinux, .{ .name = "setpgid", .linkage = common.linkage, .visibility = common.visibility }); | 29 | symbol(&setpgidLinux, "setpgid"); |
| 27 | @export(&setpgrpLinux, .{ .name = "setpgrp", .linkage = common.linkage, .visibility = common.visibility }); | 30 | symbol(&setpgrpLinux, "setpgrp"); |
| 28 | @export(&getsidLinux, .{ .name = "getsid", .linkage = common.linkage, .visibility = common.visibility }); | 31 | symbol(&getsidLinux, "getsid"); |
| 29 | @export(&getpidLinux, .{ .name = "getpid", .linkage = common.linkage, .visibility = common.visibility }); | 32 | symbol(&getpidLinux, "getpid"); |
| 30 | @export(&getppidLinux, .{ .name = "getppid", .linkage = common.linkage, .visibility = common.visibility }); | 33 | symbol(&getppidLinux, "getppid"); |
| 31 | @export(&getuidLinux, .{ .name = "getuid", .linkage = common.linkage, .visibility = common.visibility }); | 34 | symbol(&getuidLinux, "getuid"); |
| 32 | 35 | ||
| 33 | @export(&rmdirLinux, .{ .name = "rmdir", .linkage = common.linkage, .visibility = common.visibility }); | 36 | symbol(&rmdirLinux, "rmdir"); |
| 34 | @export(&linkLinux, .{ .name = "link", .linkage = common.linkage, .visibility = common.visibility }); | 37 | symbol(&linkLinux, "link"); |
| 35 | @export(&linkatLinux, .{ .name = "linkat", .linkage = common.linkage, .visibility = common.visibility }); | 38 | symbol(&linkatLinux, "linkat"); |
| 36 | @export(&pipeLinux, .{ .name = "pipe", .linkage = common.linkage, .visibility = common.visibility }); | 39 | symbol(&pipeLinux, "pipe"); |
| 37 | @export(&renameatLinux, .{ .name = "renameat", .linkage = common.linkage, .visibility = common.visibility }); | 40 | symbol(&renameatLinux, "renameat"); |
| 38 | @export(&symlinkLinux, .{ .name = "symlink", .linkage = common.linkage, .visibility = common.visibility }); | 41 | symbol(&symlinkLinux, "symlink"); |
| 39 | @export(&symlinkatLinux, .{ .name = "symlinkat", .linkage = common.linkage, .visibility = common.visibility }); | 42 | symbol(&symlinkatLinux, "symlinkat"); |
| 40 | @export(&syncLinux, .{ .name = "sync", .linkage = common.linkage, .visibility = common.visibility }); | 43 | symbol(&syncLinux, "sync"); |
| 41 | @export(&unlinkLinux, .{ .name = "unlink", .linkage = common.linkage, .visibility = common.visibility }); | 44 | symbol(&unlinkLinux, "unlink"); |
| 42 | @export(&unlinkatLinux, .{ .name = "unlinkat", .linkage = common.linkage, .visibility = common.visibility }); | 45 | symbol(&unlinkatLinux, "unlinkat"); |
| 43 | 46 | ||
| 44 | @export(&execveLinux, .{ .name = "execve", .linkage = common.linkage, .visibility = common.visibility }); | 47 | symbol(&execveLinux, "execve"); |
| 45 | } | 48 | } |
| 46 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 49 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 47 | @export(&swab, .{ .name = "swab", .linkage = common.linkage, .visibility = common.visibility }); | 50 | symbol(&swab, "swab"); |
| 48 | } | 51 | } |
| 49 | } | 52 | } |
| 50 | 53 | ||
| ... | @@ -53,31 +56,31 @@ fn _exit(exit_code: c_int) callconv(.c) noreturn { | ... | @@ -53,31 +56,31 @@ fn _exit(exit_code: c_int) callconv(.c) noreturn { |
| 53 | } | 56 | } |
| 54 | 57 | ||
| 55 | fn accessLinux(path: [*:0]const c_char, amode: c_int) callconv(.c) c_int { | 58 | fn accessLinux(path: [*:0]const c_char, amode: c_int) callconv(.c) c_int { |
| 56 | return common.errno(linux.access(@ptrCast(path), @bitCast(amode))); | 59 | return errno(linux.access(@ptrCast(path), @bitCast(amode))); |
| 57 | } | 60 | } |
| 58 | 61 | ||
| 59 | fn acctLinux(path: [*:0]const c_char) callconv(.c) c_int { | 62 | fn acctLinux(path: [*:0]const c_char) callconv(.c) c_int { |
| 60 | return common.errno(linux.acct(@ptrCast(path))); | 63 | return errno(linux.acct(@ptrCast(path))); |
| 61 | } | 64 | } |
| 62 | 65 | ||
| 63 | fn chdirLinux(path: [*:0]const c_char) callconv(.c) c_int { | 66 | fn chdirLinux(path: [*:0]const c_char) callconv(.c) c_int { |
| 64 | return common.errno(linux.chdir(@ptrCast(path))); | 67 | return errno(linux.chdir(@ptrCast(path))); |
| 65 | } | 68 | } |
| 66 | 69 | ||
| 67 | fn chownLinux(path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t) callconv(.c) c_int { | 70 | fn chownLinux(path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t) callconv(.c) c_int { |
| 68 | return common.errno(linux.chown(@ptrCast(path), uid, gid)); | 71 | return errno(linux.chown(@ptrCast(path), uid, gid)); |
| 69 | } | 72 | } |
| 70 | 73 | ||
| 71 | fn fchownatLinux(fd: c_int, path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t, flags: c_int) callconv(.c) c_int { | 74 | fn fchownatLinux(fd: c_int, path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t, flags: c_int) callconv(.c) c_int { |
| 72 | return common.errno(linux.fchownat(fd, @ptrCast(path), uid, gid, @bitCast(flags))); | 75 | return errno(linux.fchownat(fd, @ptrCast(path), uid, gid, @bitCast(flags))); |
| 73 | } | 76 | } |
| 74 | 77 | ||
| 75 | fn lchownLinux(path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t) callconv(.c) c_int { | 78 | fn lchownLinux(path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t) callconv(.c) c_int { |
| 76 | return common.errno(linux.lchown(@ptrCast(path), uid, gid)); | 79 | return errno(linux.lchown(@ptrCast(path), uid, gid)); |
| 77 | } | 80 | } |
| 78 | 81 | ||
| 79 | fn chrootLinux(path: [*:0]const c_char) callconv(.c) c_int { | 82 | fn chrootLinux(path: [*:0]const c_char) callconv(.c) c_int { |
| 80 | return common.errno(linux.chroot(@ptrCast(path))); | 83 | return errno(linux.chroot(@ptrCast(path))); |
| 81 | } | 84 | } |
| 82 | 85 | ||
| 83 | fn ctermidLinux(maybe_path: ?[*]c_char) callconv(.c) [*:0]c_char { | 86 | fn ctermidLinux(maybe_path: ?[*]c_char) callconv(.c) [*:0]c_char { |
| ... | @@ -90,7 +93,7 @@ fn ctermidLinux(maybe_path: ?[*]c_char) callconv(.c) [*:0]c_char { | ... | @@ -90,7 +93,7 @@ fn ctermidLinux(maybe_path: ?[*]c_char) callconv(.c) [*:0]c_char { |
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | fn dupLinux(fd: c_int) callconv(.c) c_int { | 95 | fn dupLinux(fd: c_int) callconv(.c) c_int { |
| 93 | return common.errno(linux.dup(fd)); | 96 | return errno(linux.dup(fd)); |
| 94 | } | 97 | } |
| 95 | 98 | ||
| 96 | fn getegidLinux() callconv(.c) linux.gid_t { | 99 | fn getegidLinux() callconv(.c) linux.gid_t { |
| ... | @@ -106,11 +109,11 @@ fn getgidLinux() callconv(.c) linux.gid_t { | ... | @@ -106,11 +109,11 @@ fn getgidLinux() callconv(.c) linux.gid_t { |
| 106 | } | 109 | } |
| 107 | 110 | ||
| 108 | fn getgroupsLinux(size: c_int, list: ?[*]linux.gid_t) callconv(.c) c_int { | 111 | fn getgroupsLinux(size: c_int, list: ?[*]linux.gid_t) callconv(.c) c_int { |
| 109 | return common.errno(linux.getgroups(@intCast(size), list)); | 112 | return errno(linux.getgroups(@intCast(size), list)); |
| 110 | } | 113 | } |
| 111 | 114 | ||
| 112 | fn getpgidLinux(pid: linux.pid_t) callconv(.c) linux.pid_t { | 115 | fn getpgidLinux(pid: linux.pid_t) callconv(.c) linux.pid_t { |
| 113 | return common.errno(linux.getpgid(pid)); | 116 | return errno(linux.getpgid(pid)); |
| 114 | } | 117 | } |
| 115 | 118 | ||
| 116 | fn getpgrpLinux() callconv(.c) linux.pid_t { | 119 | fn getpgrpLinux() callconv(.c) linux.pid_t { |
| ... | @@ -118,7 +121,7 @@ fn getpgrpLinux() callconv(.c) linux.pid_t { | ... | @@ -118,7 +121,7 @@ fn getpgrpLinux() callconv(.c) linux.pid_t { |
| 118 | } | 121 | } |
| 119 | 122 | ||
| 120 | fn setpgidLinux(pid: linux.pid_t, pgid: linux.pid_t) callconv(.c) c_int { | 123 | fn setpgidLinux(pid: linux.pid_t, pgid: linux.pid_t) callconv(.c) c_int { |
| 121 | return common.errno(linux.setpgid(pid, pgid)); | 124 | return errno(linux.setpgid(pid, pgid)); |
| 122 | } | 125 | } |
| 123 | 126 | ||
| 124 | fn setpgrpLinux() callconv(.c) linux.pid_t { | 127 | fn setpgrpLinux() callconv(.c) linux.pid_t { |
| ... | @@ -134,7 +137,7 @@ fn getppidLinux() callconv(.c) linux.pid_t { | ... | @@ -134,7 +137,7 @@ fn getppidLinux() callconv(.c) linux.pid_t { |
| 134 | } | 137 | } |
| 135 | 138 | ||
| 136 | fn getsidLinux(pid: linux.pid_t) callconv(.c) linux.pid_t { | 139 | fn getsidLinux(pid: linux.pid_t) callconv(.c) linux.pid_t { |
| 137 | return common.errno(linux.getsid(pid)); | 140 | return errno(linux.getsid(pid)); |
| 138 | } | 141 | } |
| 139 | 142 | ||
| 140 | fn getuidLinux() callconv(.c) linux.uid_t { | 143 | fn getuidLinux() callconv(.c) linux.uid_t { |
| ... | @@ -142,31 +145,31 @@ fn getuidLinux() callconv(.c) linux.uid_t { | ... | @@ -142,31 +145,31 @@ fn getuidLinux() callconv(.c) linux.uid_t { |
| 142 | } | 145 | } |
| 143 | 146 | ||
| 144 | fn linkLinux(old: [*:0]const c_char, new: [*:0]const c_char) callconv(.c) c_int { | 147 | fn linkLinux(old: [*:0]const c_char, new: [*:0]const c_char) callconv(.c) c_int { |
| 145 | return common.errno(linux.link(@ptrCast(old), @ptrCast(new))); | 148 | return errno(linux.link(@ptrCast(old), @ptrCast(new))); |
| 146 | } | 149 | } |
| 147 | 150 | ||
| 148 | fn linkatLinux(old_fd: c_int, old: [*:0]const c_char, new_fd: c_int, new: [*:0]const c_char, flags: c_int) callconv(.c) c_int { | 151 | fn linkatLinux(old_fd: c_int, old: [*:0]const c_char, new_fd: c_int, new: [*:0]const c_char, flags: c_int) callconv(.c) c_int { |
| 149 | return common.errno(linux.linkat(old_fd, @ptrCast(old), new_fd, @ptrCast(new), @bitCast(flags))); | 152 | return errno(linux.linkat(old_fd, @ptrCast(old), new_fd, @ptrCast(new), @bitCast(flags))); |
| 150 | } | 153 | } |
| 151 | 154 | ||
| 152 | fn pipeLinux(fd: *[2]c_int) callconv(.c) c_int { | 155 | fn pipeLinux(fd: *[2]c_int) callconv(.c) c_int { |
| 153 | return common.errno(linux.pipe(@ptrCast(fd))); | 156 | return errno(linux.pipe(@ptrCast(fd))); |
| 154 | } | 157 | } |
| 155 | 158 | ||
| 156 | fn renameatLinux(old_fd: c_int, old: [*:0]const c_char, new_fd: c_int, new: [*:0]const c_char) callconv(.c) c_int { | 159 | fn renameatLinux(old_fd: c_int, old: [*:0]const c_char, new_fd: c_int, new: [*:0]const c_char) callconv(.c) c_int { |
| 157 | return common.errno(linux.renameat(old_fd, @ptrCast(old), new_fd, @ptrCast(new))); | 160 | return errno(linux.renameat(old_fd, @ptrCast(old), new_fd, @ptrCast(new))); |
| 158 | } | 161 | } |
| 159 | 162 | ||
| 160 | fn rmdirLinux(path: [*:0]const c_char) callconv(.c) c_int { | 163 | fn rmdirLinux(path: [*:0]const c_char) callconv(.c) c_int { |
| 161 | return common.errno(linux.rmdir(@ptrCast(path))); | 164 | return errno(linux.rmdir(@ptrCast(path))); |
| 162 | } | 165 | } |
| 163 | 166 | ||
| 164 | fn symlinkLinux(existing: [*:0]const c_char, new: [*:0]const c_char) callconv(.c) c_int { | 167 | fn symlinkLinux(existing: [*:0]const c_char, new: [*:0]const c_char) callconv(.c) c_int { |
| 165 | return common.errno(linux.symlink(@ptrCast(existing), @ptrCast(new))); | 168 | return errno(linux.symlink(@ptrCast(existing), @ptrCast(new))); |
| 166 | } | 169 | } |
| 167 | 170 | ||
| 168 | fn symlinkatLinux(existing: [*:0]const c_char, fd: c_int, new: [*:0]const c_char) callconv(.c) c_int { | 171 | fn symlinkatLinux(existing: [*:0]const c_char, fd: c_int, new: [*:0]const c_char) callconv(.c) c_int { |
| 169 | return common.errno(linux.symlinkat(@ptrCast(existing), fd, @ptrCast(new))); | 172 | return errno(linux.symlinkat(@ptrCast(existing), fd, @ptrCast(new))); |
| 170 | } | 173 | } |
| 171 | 174 | ||
| 172 | fn syncLinux() callconv(.c) void { | 175 | fn syncLinux() callconv(.c) void { |
| ... | @@ -174,15 +177,15 @@ fn syncLinux() callconv(.c) void { | ... | @@ -174,15 +177,15 @@ fn syncLinux() callconv(.c) void { |
| 174 | } | 177 | } |
| 175 | 178 | ||
| 176 | fn unlinkLinux(path: [*:0]const c_char) callconv(.c) c_int { | 179 | fn unlinkLinux(path: [*:0]const c_char) callconv(.c) c_int { |
| 177 | return common.errno(linux.unlink(@ptrCast(path))); | 180 | return errno(linux.unlink(@ptrCast(path))); |
| 178 | } | 181 | } |
| 179 | 182 | ||
| 180 | fn unlinkatLinux(fd: c_int, path: [*:0]const c_char, flags: c_int) callconv(.c) c_int { | 183 | fn unlinkatLinux(fd: c_int, path: [*:0]const c_char, flags: c_int) callconv(.c) c_int { |
| 181 | return common.errno(linux.unlinkat(fd, @ptrCast(path), @bitCast(flags))); | 184 | return errno(linux.unlinkat(fd, @ptrCast(path), @bitCast(flags))); |
| 182 | } | 185 | } |
| 183 | 186 | ||
| 184 | fn execveLinux(path: [*:0]const c_char, argv: [*:null]const ?[*:0]c_char, envp: [*:null]const ?[*:0]c_char) callconv(.c) c_int { | 187 | fn execveLinux(path: [*:0]const c_char, argv: [*:null]const ?[*:0]c_char, envp: [*:null]const ?[*:0]c_char) callconv(.c) c_int { |
| 185 | return common.errno(linux.execve(@ptrCast(path), @ptrCast(argv), @ptrCast(envp))); | 188 | return errno(linux.execve(@ptrCast(path), @ptrCast(argv), @ptrCast(envp))); |
| 186 | } | 189 | } |
| 187 | 190 | ||
| 188 | fn swab(noalias src_ptr: *const anyopaque, noalias dest_ptr: *anyopaque, n: isize) callconv(.c) void { | 191 | fn swab(noalias src_ptr: *const anyopaque, noalias dest_ptr: *anyopaque, n: isize) callconv(.c) void { |
lib/c/wchar.zig+34-32| ... | @@ -1,44 +1,46 @@ | ... | @@ -1,44 +1,46 @@ |
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("common.zig"); | ||
| 3 | const builtin = @import("builtin"); | 1 | const builtin = @import("builtin"); |
| 2 | |||
| 3 | const std = @import("std"); | ||
| 4 | const wint_t = std.c.wint_t; | 4 | const wint_t = std.c.wint_t; |
| 5 | const wchar_t = std.c.wchar_t; | 5 | const wchar_t = std.c.wchar_t; |
| 6 | 6 | ||
| 7 | const symbol = @import("../c.zig").symbol; | ||
| 8 | |||
| 7 | comptime { | 9 | comptime { |
| 8 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 10 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 9 | @export(&wmemchr, .{ .name = "wmemchr", .linkage = common.linkage, .visibility = common.visibility }); | 11 | symbol(&wmemchr, "wmemchr"); |
| 10 | @export(&wmemcmp, .{ .name = "wmemcmp", .linkage = common.linkage, .visibility = common.visibility }); | 12 | symbol(&wmemcmp, "wmemcmp"); |
| 11 | @export(&wmemcpy, .{ .name = "wmemcpy", .linkage = common.linkage, .visibility = common.visibility }); | 13 | symbol(&wmemcpy, "wmemcpy"); |
| 12 | @export(&wmemmove, .{ .name = "wmemmove", .linkage = common.linkage, .visibility = common.visibility }); | 14 | symbol(&wmemmove, "wmemmove"); |
| 13 | @export(&wmemset, .{ .name = "wmemset", .linkage = common.linkage, .visibility = common.visibility }); | 15 | symbol(&wmemset, "wmemset"); |
| 14 | @export(&wcslen, .{ .name = "wcslen", .linkage = common.linkage, .visibility = common.visibility }); | 16 | symbol(&wcslen, "wcslen"); |
| 15 | @export(&wcsnlen, .{ .name = "wcsnlen", .linkage = common.linkage, .visibility = common.visibility }); | 17 | symbol(&wcsnlen, "wcsnlen"); |
| 16 | @export(&wcscmp, .{ .name = "wcscmp", .linkage = common.linkage, .visibility = common.visibility }); | 18 | symbol(&wcscmp, "wcscmp"); |
| 17 | @export(&wcsncmp, .{ .name = "wcsncmp", .linkage = common.linkage, .visibility = common.visibility }); | 19 | symbol(&wcsncmp, "wcsncmp"); |
| 18 | @export(&wcpcpy, .{ .name = "wcpcpy", .linkage = common.linkage, .visibility = common.visibility }); | 20 | symbol(&wcpcpy, "wcpcpy"); |
| 19 | @export(&wcpncpy, .{ .name = "wcpncpy", .linkage = common.linkage, .visibility = common.visibility }); | 21 | symbol(&wcpncpy, "wcpncpy"); |
| 20 | @export(&wcscpy, .{ .name = "wcscpy", .linkage = common.linkage, .visibility = common.visibility }); | 22 | symbol(&wcscpy, "wcscpy"); |
| 21 | @export(&wcsncpy, .{ .name = "wcsncpy", .linkage = common.linkage, .visibility = common.visibility }); | 23 | symbol(&wcsncpy, "wcsncpy"); |
| 22 | @export(&wcscat, .{ .name = "wcscat", .linkage = common.linkage, .visibility = common.visibility }); | 24 | symbol(&wcscat, "wcscat"); |
| 23 | @export(&wcsncat, .{ .name = "wcsncat", .linkage = common.linkage, .visibility = common.visibility }); | 25 | symbol(&wcsncat, "wcsncat"); |
| 24 | @export(&wcschr, .{ .name = "wcschr", .linkage = common.linkage, .visibility = common.visibility }); | 26 | symbol(&wcschr, "wcschr"); |
| 25 | @export(&wcsrchr, .{ .name = "wcsrchr", .linkage = common.linkage, .visibility = common.visibility }); | 27 | symbol(&wcsrchr, "wcsrchr"); |
| 26 | @export(&wcsspn, .{ .name = "wcsspn", .linkage = common.linkage, .visibility = common.visibility }); | 28 | symbol(&wcsspn, "wcsspn"); |
| 27 | @export(&wcscspn, .{ .name = "wcscspn", .linkage = common.linkage, .visibility = common.visibility }); | 29 | symbol(&wcscspn, "wcscspn"); |
| 28 | @export(&wcspbrk, .{ .name = "wcspbrk", .linkage = common.linkage, .visibility = common.visibility }); | 30 | symbol(&wcspbrk, "wcspbrk"); |
| 29 | @export(&wcstok, .{ .name = "wcstok", .linkage = common.linkage, .visibility = common.visibility }); | 31 | symbol(&wcstok, "wcstok"); |
| 30 | @export(&wcsstr, .{ .name = "wcsstr", .linkage = common.linkage, .visibility = common.visibility }); | 32 | symbol(&wcsstr, "wcsstr"); |
| 31 | @export(&wcswcs, .{ .name = "wcswcs", .linkage = common.linkage, .visibility = common.visibility }); | 33 | symbol(&wcswcs, "wcswcs"); |
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | if (builtin.target.isMinGW()) { | 36 | if (builtin.target.isMinGW()) { |
| 35 | @export(&wmemchr, .{ .name = "wmemchr", .linkage = common.linkage, .visibility = common.visibility }); | 37 | symbol(&wmemchr, "wmemchr"); |
| 36 | @export(&wmemcmp, .{ .name = "wmemcmp", .linkage = common.linkage, .visibility = common.visibility }); | 38 | symbol(&wmemcmp, "wmemcmp"); |
| 37 | @export(&wmemcpy, .{ .name = "wmemcpy", .linkage = common.linkage, .visibility = common.visibility }); | 39 | symbol(&wmemcpy, "wmemcpy"); |
| 38 | @export(&wmempcpy, .{ .name = "wmempcpy", .linkage = common.linkage, .visibility = common.visibility }); | 40 | symbol(&wmempcpy, "wmempcpy"); |
| 39 | @export(&wmemmove, .{ .name = "wmemmove", .linkage = common.linkage, .visibility = common.visibility }); | 41 | symbol(&wmemmove, "wmemmove"); |
| 40 | @export(&wmemset, .{ .name = "wmemset", .linkage = common.linkage, .visibility = common.visibility }); | 42 | symbol(&wmemset, "wmemset"); |
| 41 | @export(&wcsnlen, .{ .name = "wcsnlen", .linkage = common.linkage, .visibility = common.visibility }); | 43 | symbol(&wcsnlen, "wcsnlen"); |
| 42 | } | 44 | } |
| 43 | } | 45 | } |
| 44 | 46 |