authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-12 21:03:36-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-13 02:47:16-04:00
loge2fe1907ecac075e4d4a37776359144318b6055a
treefa8289bc558540dfe7fcfdc0d06eb99f0e189396
parent856a9c2e3120d9ffa1166eed13641600230946da

add c_char type

closes #875

11 files changed, 62 insertions(+), 2 deletions(-)

lib/std/start.zig+2-2
...@@ -512,7 +512,7 @@ fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 {...@@ -512,7 +512,7 @@ fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 {
512 return initEventLoopAndCallMain();512 return initEventLoopAndCallMain();
513}513}
514514
515fn main(c_argc: c_int, c_argv: [*][*:0]u8, c_envp: [*:null]?[*:0]u8) callconv(.C) c_int {515fn main(c_argc: c_int, c_argv: [*][*:0]c_char, c_envp: [*:null]?[*:0]c_char) callconv(.C) c_int {
516 var env_count: usize = 0;516 var env_count: usize = 0;
517 while (c_envp[env_count] != null) : (env_count += 1) {}517 while (c_envp[env_count] != null) : (env_count += 1) {}
518 const envp = @ptrCast([*][*:0]u8, c_envp)[0..env_count];518 const envp = @ptrCast([*][*:0]u8, c_envp)[0..env_count];
...@@ -527,7 +527,7 @@ fn main(c_argc: c_int, c_argv: [*][*:0]u8, c_envp: [*:null]?[*:0]u8) callconv(.C...@@ -527,7 +527,7 @@ fn main(c_argc: c_int, c_argv: [*][*:0]u8, c_envp: [*:null]?[*:0]u8) callconv(.C
527 return @call(.always_inline, callMainWithArgs, .{ @intCast(usize, c_argc), @ptrCast([*][*:0]u8, c_argv), envp });527 return @call(.always_inline, callMainWithArgs, .{ @intCast(usize, c_argc), @ptrCast([*][*:0]u8, c_argv), envp });
528}528}
529529
530fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]u8) callconv(.C) c_int {530fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.C) c_int {
531 std.os.argv = @ptrCast([*][*:0]u8, c_argv)[0..@intCast(usize, c_argc)];531 std.os.argv = @ptrCast([*][*:0]u8, c_argv)[0..@intCast(usize, c_argc)];
532 return @call(.always_inline, callMain, .{});532 return @call(.always_inline, callMain, .{});
533}533}
lib/std/target.zig+20
...@@ -1905,6 +1905,7 @@ pub const Target = struct {...@@ -1905,6 +1905,7 @@ pub const Target = struct {
1905 }1905 }
19061906
1907 pub const CType = enum {1907 pub const CType = enum {
1908 char,
1908 short,1909 short,
1909 ushort,1910 ushort,
1910 int,1911 int,
...@@ -1920,6 +1921,7 @@ pub const Target = struct {...@@ -1920,6 +1921,7 @@ pub const Target = struct {
19201921
1921 pub fn c_type_byte_size(t: Target, c_type: CType) u16 {1922 pub fn c_type_byte_size(t: Target, c_type: CType) u16 {
1922 return switch (c_type) {1923 return switch (c_type) {
1924 .char,
1923 .short,1925 .short,
1924 .ushort,1926 .ushort,
1925 .int,1927 .int,
...@@ -1948,21 +1950,25 @@ pub const Target = struct {...@@ -1948,21 +1950,25 @@ pub const Target = struct {
1948 switch (target.os.tag) {1950 switch (target.os.tag) {
1949 .freestanding, .other => switch (target.cpu.arch) {1951 .freestanding, .other => switch (target.cpu.arch) {
1950 .msp430 => switch (c_type) {1952 .msp430 => switch (c_type) {
1953 .char => return 8,
1951 .short, .ushort, .int, .uint => return 16,1954 .short, .ushort, .int, .uint => return 16,
1952 .float, .long, .ulong => return 32,1955 .float, .long, .ulong => return 32,
1953 .longlong, .ulonglong, .double, .longdouble => return 64,1956 .longlong, .ulonglong, .double, .longdouble => return 64,
1954 },1957 },
1955 .avr => switch (c_type) {1958 .avr => switch (c_type) {
1959 .char => return 8,
1956 .short, .ushort, .int, .uint => return 16,1960 .short, .ushort, .int, .uint => return 16,
1957 .long, .ulong, .float, .double, .longdouble => return 32,1961 .long, .ulong, .float, .double, .longdouble => return 32,
1958 .longlong, .ulonglong => return 64,1962 .longlong, .ulonglong => return 64,
1959 },1963 },
1960 .tce, .tcele => switch (c_type) {1964 .tce, .tcele => switch (c_type) {
1965 .char => return 8,
1961 .short, .ushort => return 16,1966 .short, .ushort => return 16,
1962 .int, .uint, .long, .ulong, .longlong, .ulonglong => return 32,1967 .int, .uint, .long, .ulong, .longlong, .ulonglong => return 32,
1963 .float, .double, .longdouble => return 32,1968 .float, .double, .longdouble => return 32,
1964 },1969 },
1965 .mips64, .mips64el => switch (c_type) {1970 .mips64, .mips64el => switch (c_type) {
1971 .char => return 8,
1966 .short, .ushort => return 16,1972 .short, .ushort => return 16,
1967 .int, .uint, .float => return 32,1973 .int, .uint, .float => return 32,
1968 .long, .ulong => return if (target.abi != .gnuabin32) 64 else 32,1974 .long, .ulong => return if (target.abi != .gnuabin32) 64 else 32,
...@@ -1970,6 +1976,7 @@ pub const Target = struct {...@@ -1970,6 +1976,7 @@ pub const Target = struct {
1970 .longdouble => return 128,1976 .longdouble => return 128,
1971 },1977 },
1972 .x86_64 => switch (c_type) {1978 .x86_64 => switch (c_type) {
1979 .char => return 8,
1973 .short, .ushort => return 16,1980 .short, .ushort => return 16,
1974 .int, .uint, .float => return 32,1981 .int, .uint, .float => return 32,
1975 .long, .ulong => switch (target.abi) {1982 .long, .ulong => switch (target.abi) {
...@@ -1980,6 +1987,7 @@ pub const Target = struct {...@@ -1980,6 +1987,7 @@ pub const Target = struct {
1980 .longdouble => return 80,1987 .longdouble => return 80,
1981 },1988 },
1982 else => switch (c_type) {1989 else => switch (c_type) {
1990 .char => return 8,
1983 .short, .ushort => return 16,1991 .short, .ushort => return 16,
1984 .int, .uint, .float => return 32,1992 .int, .uint, .float => return 32,
1985 .long, .ulong => return target.cpu.arch.ptrBitWidth(),1993 .long, .ulong => return target.cpu.arch.ptrBitWidth(),
...@@ -2036,21 +2044,25 @@ pub const Target = struct {...@@ -2036,21 +2044,25 @@ pub const Target = struct {
2036 .minix,2044 .minix,
2037 => switch (target.cpu.arch) {2045 => switch (target.cpu.arch) {
2038 .msp430 => switch (c_type) {2046 .msp430 => switch (c_type) {
2047 .char => return 8,
2039 .short, .ushort, .int, .uint => return 16,2048 .short, .ushort, .int, .uint => return 16,
2040 .long, .ulong, .float => return 32,2049 .long, .ulong, .float => return 32,
2041 .longlong, .ulonglong, .double, .longdouble => return 64,2050 .longlong, .ulonglong, .double, .longdouble => return 64,
2042 },2051 },
2043 .avr => switch (c_type) {2052 .avr => switch (c_type) {
2053 .char => return 8,
2044 .short, .ushort, .int, .uint => return 16,2054 .short, .ushort, .int, .uint => return 16,
2045 .long, .ulong, .float, .double, .longdouble => return 32,2055 .long, .ulong, .float, .double, .longdouble => return 32,
2046 .longlong, .ulonglong => return 64,2056 .longlong, .ulonglong => return 64,
2047 },2057 },
2048 .tce, .tcele => switch (c_type) {2058 .tce, .tcele => switch (c_type) {
2059 .char => return 8,
2049 .short, .ushort => return 16,2060 .short, .ushort => return 16,
2050 .int, .uint, .long, .ulong, .longlong, .ulonglong => return 32,2061 .int, .uint, .long, .ulong, .longlong, .ulonglong => return 32,
2051 .float, .double, .longdouble => return 32,2062 .float, .double, .longdouble => return 32,
2052 },2063 },
2053 .mips64, .mips64el => switch (c_type) {2064 .mips64, .mips64el => switch (c_type) {
2065 .char => return 8,
2054 .short, .ushort => return 16,2066 .short, .ushort => return 16,
2055 .int, .uint, .float => return 32,2067 .int, .uint, .float => return 32,
2056 .long, .ulong => return if (target.abi != .gnuabin32) 64 else 32,2068 .long, .ulong => return if (target.abi != .gnuabin32) 64 else 32,
...@@ -2058,6 +2070,7 @@ pub const Target = struct {...@@ -2058,6 +2070,7 @@ pub const Target = struct {
2058 .longdouble => if (target.os.tag == .freebsd) return 64 else return 128,2070 .longdouble => if (target.os.tag == .freebsd) return 64 else return 128,
2059 },2071 },
2060 .x86_64 => switch (c_type) {2072 .x86_64 => switch (c_type) {
2073 .char => return 8,
2061 .short, .ushort => return 16,2074 .short, .ushort => return 16,
2062 .int, .uint, .float => return 32,2075 .int, .uint, .float => return 32,
2063 .long, .ulong => switch (target.abi) {2076 .long, .ulong => switch (target.abi) {
...@@ -2068,6 +2081,7 @@ pub const Target = struct {...@@ -2068,6 +2081,7 @@ pub const Target = struct {
2068 .longdouble => return 80,2081 .longdouble => return 80,
2069 },2082 },
2070 else => switch (c_type) {2083 else => switch (c_type) {
2084 .char => return 8,
2071 .short, .ushort => return 16,2085 .short, .ushort => return 16,
2072 .int, .uint, .float => return 32,2086 .int, .uint, .float => return 32,
2073 .long, .ulong => return target.cpu.arch.ptrBitWidth(),2087 .long, .ulong => return target.cpu.arch.ptrBitWidth(),
...@@ -2128,6 +2142,7 @@ pub const Target = struct {...@@ -2128,6 +2142,7 @@ pub const Target = struct {
21282142
2129 .windows, .uefi => switch (target.cpu.arch) {2143 .windows, .uefi => switch (target.cpu.arch) {
2130 .x86 => switch (c_type) {2144 .x86 => switch (c_type) {
2145 .char => return 8,
2131 .short, .ushort => return 16,2146 .short, .ushort => return 16,
2132 .int, .uint, .float => return 32,2147 .int, .uint, .float => return 32,
2133 .long, .ulong => return 32,2148 .long, .ulong => return 32,
...@@ -2138,6 +2153,7 @@ pub const Target = struct {...@@ -2138,6 +2153,7 @@ pub const Target = struct {
2138 },2153 },
2139 },2154 },
2140 .x86_64 => switch (c_type) {2155 .x86_64 => switch (c_type) {
2156 .char => return 8,
2141 .short, .ushort => return 16,2157 .short, .ushort => return 16,
2142 .int, .uint, .float => return 32,2158 .int, .uint, .float => return 32,
2143 .long, .ulong => switch (target.abi) {2159 .long, .ulong => switch (target.abi) {
...@@ -2151,6 +2167,7 @@ pub const Target = struct {...@@ -2151,6 +2167,7 @@ pub const Target = struct {
2151 },2167 },
2152 },2168 },
2153 else => switch (c_type) {2169 else => switch (c_type) {
2170 .char => return 8,
2154 .short, .ushort => return 16,2171 .short, .ushort => return 16,
2155 .int, .uint, .float => return 32,2172 .int, .uint, .float => return 32,
2156 .long, .ulong => return 32,2173 .long, .ulong => return 32,
...@@ -2160,6 +2177,7 @@ pub const Target = struct {...@@ -2160,6 +2177,7 @@ pub const Target = struct {
2160 },2177 },
21612178
2162 .macos, .ios, .tvos, .watchos => switch (c_type) {2179 .macos, .ios, .tvos, .watchos => switch (c_type) {
2180 .char => return 8,
2163 .short, .ushort => return 16,2181 .short, .ushort => return 16,
2164 .int, .uint, .float => return 32,2182 .int, .uint, .float => return 32,
2165 .long, .ulong => switch (target.cpu.arch) {2183 .long, .ulong => switch (target.cpu.arch) {
...@@ -2182,6 +2200,7 @@ pub const Target = struct {...@@ -2182,6 +2200,7 @@ pub const Target = struct {
2182 },2200 },
21832201
2184 .nvcl, .cuda => switch (c_type) {2202 .nvcl, .cuda => switch (c_type) {
2203 .char => return 8,
2185 .short, .ushort => return 16,2204 .short, .ushort => return 16,
2186 .int, .uint, .float => return 32,2205 .int, .uint, .float => return 32,
2187 .long, .ulong => switch (target.cpu.arch) {2206 .long, .ulong => switch (target.cpu.arch) {
...@@ -2194,6 +2213,7 @@ pub const Target = struct {...@@ -2194,6 +2213,7 @@ pub const Target = struct {
2194 },2213 },
21952214
2196 .amdhsa, .amdpal => switch (c_type) {2215 .amdhsa, .amdpal => switch (c_type) {
2216 .char => return 8,
2197 .short, .ushort => return 16,2217 .short, .ushort => return 16,
2198 .int, .uint, .float => return 32,2218 .int, .uint, .float => return 32,
2199 .long, .ulong, .longlong, .ulonglong, .double => return 64,2219 .long, .ulong, .longlong, .ulonglong, .double => return 64,
lib/std/zig/primitives.zig+1
...@@ -11,6 +11,7 @@ pub const names = std.ComptimeStringMap(void, .{...@@ -11,6 +11,7 @@ pub const names = std.ComptimeStringMap(void, .{
11 .{"c_long"},11 .{"c_long"},
12 .{"c_longdouble"},12 .{"c_longdouble"},
13 .{"c_longlong"},13 .{"c_longlong"},
14 .{"c_char"},
14 .{"c_short"},15 .{"c_short"},
15 .{"c_uint"},16 .{"c_uint"},
16 .{"c_ulong"},17 .{"c_ulong"},
src/AstGen.zig+4
...@@ -9054,6 +9054,7 @@ const primitive_instrs = std.ComptimeStringMap(Zir.Inst.Ref, .{...@@ -9054,6 +9054,7 @@ const primitive_instrs = std.ComptimeStringMap(Zir.Inst.Ref, .{
9054 .{ "c_long", .c_long_type },9054 .{ "c_long", .c_long_type },
9055 .{ "c_longdouble", .c_longdouble_type },9055 .{ "c_longdouble", .c_longdouble_type },
9056 .{ "c_longlong", .c_longlong_type },9056 .{ "c_longlong", .c_longlong_type },
9057 .{ "c_char", .c_char_type },
9057 .{ "c_short", .c_short_type },9058 .{ "c_short", .c_short_type },
9058 .{ "c_uint", .c_uint_type },9059 .{ "c_uint", .c_uint_type },
9059 .{ "c_ulong", .c_ulong_type },9060 .{ "c_ulong", .c_ulong_type },
...@@ -9802,6 +9803,7 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In...@@ -9802,6 +9803,7 @@ fn nodeImpliesMoreThanOnePossibleValue(tree: *const Ast, start_node: Ast.Node.In
9802 .c_long_type,9803 .c_long_type,
9803 .c_longdouble_type,9804 .c_longdouble_type,
9804 .c_longlong_type,9805 .c_longlong_type,
9806 .c_char_type,
9805 .c_short_type,9807 .c_short_type,
9806 .c_uint_type,9808 .c_uint_type,
9807 .c_ulong_type,9809 .c_ulong_type,
...@@ -10047,6 +10049,7 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool {...@@ -10047,6 +10049,7 @@ fn nodeImpliesComptimeOnly(tree: *const Ast, start_node: Ast.Node.Index) bool {
10047 .c_long_type,10049 .c_long_type,
10048 .c_longdouble_type,10050 .c_longdouble_type,
10049 .c_longlong_type,10051 .c_longlong_type,
10052 .c_char_type,
10050 .c_short_type,10053 .c_short_type,
10051 .c_uint_type,10054 .c_uint_type,
10052 .c_ulong_type,10055 .c_ulong_type,
...@@ -10187,6 +10190,7 @@ fn rvalue(...@@ -10187,6 +10190,7 @@ fn rvalue(
10187 as_ty | @enumToInt(Zir.Inst.Ref.i64_type),10190 as_ty | @enumToInt(Zir.Inst.Ref.i64_type),
10188 as_ty | @enumToInt(Zir.Inst.Ref.usize_type),10191 as_ty | @enumToInt(Zir.Inst.Ref.usize_type),
10189 as_ty | @enumToInt(Zir.Inst.Ref.isize_type),10192 as_ty | @enumToInt(Zir.Inst.Ref.isize_type),
10193 as_ty | @enumToInt(Zir.Inst.Ref.c_char_type),
10190 as_ty | @enumToInt(Zir.Inst.Ref.c_short_type),10194 as_ty | @enumToInt(Zir.Inst.Ref.c_short_type),
10191 as_ty | @enumToInt(Zir.Inst.Ref.c_ushort_type),10195 as_ty | @enumToInt(Zir.Inst.Ref.c_ushort_type),
10192 as_ty | @enumToInt(Zir.Inst.Ref.c_int_type),10196 as_ty | @enumToInt(Zir.Inst.Ref.c_int_type),
src/Sema.zig+3
...@@ -30622,6 +30622,7 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -30622,6 +30622,7 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
30622 .i128,30622 .i128,
30623 .usize,30623 .usize,
30624 .isize,30624 .isize,
30625 .c_char,
30625 .c_short,30626 .c_short,
30626 .c_ushort,30627 .c_ushort,
30627 .c_int,30628 .c_int,
...@@ -32010,6 +32011,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -32010,6 +32011,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
32010 .i128,32011 .i128,
32011 .usize,32012 .usize,
32012 .isize,32013 .isize,
32014 .c_char,
32013 .c_short,32015 .c_short,
32014 .c_ushort,32016 .c_ushort,
32015 .c_int,32017 .c_int,
...@@ -32640,6 +32642,7 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {...@@ -32640,6 +32642,7 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
32640 .i128,32642 .i128,
32641 .usize,32643 .usize,
32642 .isize,32644 .isize,
32645 .c_char,
32643 .c_short,32646 .c_short,
32644 .c_ushort,32647 .c_ushort,
32645 .c_int,32648 .c_int,
src/TypedValue.zig+1
...@@ -92,6 +92,7 @@ pub fn print(...@@ -92,6 +92,7 @@ pub fn print(
92 .i128_type => return writer.writeAll("i128"),92 .i128_type => return writer.writeAll("i128"),
93 .isize_type => return writer.writeAll("isize"),93 .isize_type => return writer.writeAll("isize"),
94 .usize_type => return writer.writeAll("usize"),94 .usize_type => return writer.writeAll("usize"),
95 .c_char_type => return writer.writeAll("c_char"),
95 .c_short_type => return writer.writeAll("c_short"),96 .c_short_type => return writer.writeAll("c_short"),
96 .c_ushort_type => return writer.writeAll("c_ushort"),97 .c_ushort_type => return writer.writeAll("c_ushort"),
97 .c_int_type => return writer.writeAll("c_int"),98 .c_int_type => return writer.writeAll("c_int"),
src/Zir.zig+5
...@@ -2062,6 +2062,7 @@ pub const Inst = struct {...@@ -2062,6 +2062,7 @@ pub const Inst = struct {
2062 i128_type,2062 i128_type,
2063 usize_type,2063 usize_type,
2064 isize_type,2064 isize_type,
2065 c_char_type,
2065 c_short_type,2066 c_short_type,
2066 c_ushort_type,2067 c_ushort_type,
2067 c_int_type,2068 c_int_type,
...@@ -2201,6 +2202,10 @@ pub const Inst = struct {...@@ -2201,6 +2202,10 @@ pub const Inst = struct {
2201 .ty = Type.initTag(.type),2202 .ty = Type.initTag(.type),
2202 .val = Value.initTag(.isize_type),2203 .val = Value.initTag(.isize_type),
2203 },2204 },
2205 .c_char_type = .{
2206 .ty = Type.initTag(.type),
2207 .val = Value.initTag(.c_char_type),
2208 },
2204 .c_short_type = .{2209 .c_short_type = .{
2205 .ty = Type.initTag(.type),2210 .ty = Type.initTag(.type),
2206 .val = Value.initTag(.c_short_type),2211 .val = Value.initTag(.c_short_type),
src/codegen/c/type.zig+1
...@@ -1358,6 +1358,7 @@ pub const CType = extern union {...@@ -1358,6 +1358,7 @@ pub const CType = extern union {
1358 else if (ty.isAbiInt()) switch (ty.tag()) {1358 else if (ty.isAbiInt()) switch (ty.tag()) {
1359 .usize => self.init(.uintptr_t),1359 .usize => self.init(.uintptr_t),
1360 .isize => self.init(.intptr_t),1360 .isize => self.init(.intptr_t),
1361 .c_char => self.init(.char),
1361 .c_short => self.init(.short),1362 .c_short => self.init(.short),
1362 .c_ushort => self.init(.@"unsigned short"),1363 .c_ushort => self.init(.@"unsigned short"),
1363 .c_int => self.init(.int),1364 .c_int => self.init(.int),
src/type.zig+20
...@@ -47,6 +47,7 @@ pub const Type = extern union {...@@ -47,6 +47,7 @@ pub const Type = extern union {
47 .i128,47 .i128,
48 .usize,48 .usize,
49 .isize,49 .isize,
50 .c_char,
50 .c_short,51 .c_short,
51 .c_ushort,52 .c_ushort,
52 .c_int,53 .c_int,
...@@ -546,6 +547,7 @@ pub const Type = extern union {...@@ -546,6 +547,7 @@ pub const Type = extern union {
546 // Detect that e.g. u64 != usize, even if the bits match on a particular target.547 // Detect that e.g. u64 != usize, even if the bits match on a particular target.
547 .usize,548 .usize,
548 .isize,549 .isize,
550 .c_char,
549 .c_short,551 .c_short,
550 .c_ushort,552 .c_ushort,
551 .c_int,553 .c_int,
...@@ -946,6 +948,7 @@ pub const Type = extern union {...@@ -946,6 +948,7 @@ pub const Type = extern union {
946948
947 .usize,949 .usize,
948 .isize,950 .isize,
951 .c_char,
949 .c_short,952 .c_short,
950 .c_ushort,953 .c_ushort,
951 .c_int,954 .c_int,
...@@ -1292,6 +1295,7 @@ pub const Type = extern union {...@@ -1292,6 +1295,7 @@ pub const Type = extern union {
1292 .i128,1295 .i128,
1293 .usize,1296 .usize,
1294 .isize,1297 .isize,
1298 .c_char,
1295 .c_short,1299 .c_short,
1296 .c_ushort,1300 .c_ushort,
1297 .c_int,1301 .c_int,
...@@ -1584,6 +1588,7 @@ pub const Type = extern union {...@@ -1584,6 +1588,7 @@ pub const Type = extern union {
1584 .i128,1588 .i128,
1585 .usize,1589 .usize,
1586 .isize,1590 .isize,
1591 .c_char,
1587 .c_short,1592 .c_short,
1588 .c_ushort,1593 .c_ushort,
1589 .c_int,1594 .c_int,
...@@ -1974,6 +1979,7 @@ pub const Type = extern union {...@@ -1974,6 +1979,7 @@ pub const Type = extern union {
1974 .i128,1979 .i128,
1975 .usize,1980 .usize,
1976 .isize,1981 .isize,
1982 .c_char,
1977 .c_short,1983 .c_short,
1978 .c_ushort,1984 .c_ushort,
1979 .c_int,1985 .c_int,
...@@ -2290,6 +2296,7 @@ pub const Type = extern union {...@@ -2290,6 +2296,7 @@ pub const Type = extern union {
2290 .i64 => return Value.initTag(.i64_type),2296 .i64 => return Value.initTag(.i64_type),
2291 .usize => return Value.initTag(.usize_type),2297 .usize => return Value.initTag(.usize_type),
2292 .isize => return Value.initTag(.isize_type),2298 .isize => return Value.initTag(.isize_type),
2299 .c_char => return Value.initTag(.c_char_type),
2293 .c_short => return Value.initTag(.c_short_type),2300 .c_short => return Value.initTag(.c_short_type),
2294 .c_ushort => return Value.initTag(.c_ushort_type),2301 .c_ushort => return Value.initTag(.c_ushort_type),
2295 .c_int => return Value.initTag(.c_int_type),2302 .c_int => return Value.initTag(.c_int_type),
...@@ -2376,6 +2383,7 @@ pub const Type = extern union {...@@ -2376,6 +2383,7 @@ pub const Type = extern union {
2376 .i128,2383 .i128,
2377 .usize,2384 .usize,
2378 .isize,2385 .isize,
2386 .c_char,
2379 .c_short,2387 .c_short,
2380 .c_ushort,2388 .c_ushort,
2381 .c_int,2389 .c_int,
...@@ -2603,6 +2611,7 @@ pub const Type = extern union {...@@ -2603,6 +2611,7 @@ pub const Type = extern union {
2603 .i128,2611 .i128,
2604 .usize,2612 .usize,
2605 .isize,2613 .isize,
2614 .c_char,
2606 .c_short,2615 .c_short,
2607 .c_ushort,2616 .c_ushort,
2608 .c_int,2617 .c_int,
...@@ -2938,6 +2947,7 @@ pub const Type = extern union {...@@ -2938,6 +2947,7 @@ pub const Type = extern union {
2938 .anyframe_T,2947 .anyframe_T,
2939 => return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },2948 => return AbiAlignmentAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },
29402949
2950 .c_char => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.char) },
2941 .c_short => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.short) },2951 .c_short => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.short) },
2942 .c_ushort => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.ushort) },2952 .c_ushort => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.ushort) },
2943 .c_int => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.int) },2953 .c_int => return AbiAlignmentAdvanced{ .scalar = target.c_type_alignment(.int) },
...@@ -3435,6 +3445,7 @@ pub const Type = extern union {...@@ -3435,6 +3445,7 @@ pub const Type = extern union {
3435 else => return AbiSizeAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },3445 else => return AbiSizeAdvanced{ .scalar = @divExact(target.cpu.arch.ptrBitWidth(), 8) },
3436 },3446 },
34373447
3448 .c_char => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.char) },
3438 .c_short => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.short) },3449 .c_short => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.short) },
3439 .c_ushort => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.ushort) },3450 .c_ushort => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.ushort) },
3440 .c_int => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.int) },3451 .c_int => return AbiSizeAdvanced{ .scalar = target.c_type_byte_size(.int) },
...@@ -3742,6 +3753,7 @@ pub const Type = extern union {...@@ -3742,6 +3753,7 @@ pub const Type = extern union {
3742 .manyptr_const_u8_sentinel_0,3753 .manyptr_const_u8_sentinel_0,
3743 => return target.cpu.arch.ptrBitWidth(),3754 => return target.cpu.arch.ptrBitWidth(),
37443755
3756 .c_char => return target.c_type_bit_size(.char),
3745 .c_short => return target.c_type_bit_size(.short),3757 .c_short => return target.c_type_bit_size(.short),
3746 .c_ushort => return target.c_type_bit_size(.ushort),3758 .c_ushort => return target.c_type_bit_size(.ushort),
3747 .c_int => return target.c_type_bit_size(.int),3759 .c_int => return target.c_type_bit_size(.int),
...@@ -4553,6 +4565,7 @@ pub const Type = extern union {...@@ -4553,6 +4565,7 @@ pub const Type = extern union {
4553 .int_signed,4565 .int_signed,
4554 .i8,4566 .i8,
4555 .isize,4567 .isize,
4568 .c_char,
4556 .c_short,4569 .c_short,
4557 .c_int,4570 .c_int,
4558 .c_long,4571 .c_long,
...@@ -4625,6 +4638,7 @@ pub const Type = extern union {...@@ -4625,6 +4638,7 @@ pub const Type = extern union {
4625 .i128 => return .{ .signedness = .signed, .bits = 128 },4638 .i128 => return .{ .signedness = .signed, .bits = 128 },
4626 .usize => return .{ .signedness = .unsigned, .bits = target.cpu.arch.ptrBitWidth() },4639 .usize => return .{ .signedness = .unsigned, .bits = target.cpu.arch.ptrBitWidth() },
4627 .isize => return .{ .signedness = .signed, .bits = target.cpu.arch.ptrBitWidth() },4640 .isize => return .{ .signedness = .signed, .bits = target.cpu.arch.ptrBitWidth() },
4641 .c_char => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.char) },
4628 .c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },4642 .c_short => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },
4629 .c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },4643 .c_ushort => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },
4630 .c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },4644 .c_int => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },
...@@ -4664,6 +4678,7 @@ pub const Type = extern union {...@@ -4664,6 +4678,7 @@ pub const Type = extern union {
4664 return switch (self.tag()) {4678 return switch (self.tag()) {
4665 .usize,4679 .usize,
4666 .isize,4680 .isize,
4681 .c_char,
4667 .c_short,4682 .c_short,
4668 .c_ushort,4683 .c_ushort,
4669 .c_int,4684 .c_int,
...@@ -4921,6 +4936,7 @@ pub const Type = extern union {...@@ -4921,6 +4936,7 @@ pub const Type = extern union {
4921 .i128,4936 .i128,
4922 .usize,4937 .usize,
4923 .isize,4938 .isize,
4939 .c_char,
4924 .c_short,4940 .c_short,
4925 .c_ushort,4941 .c_ushort,
4926 .c_int,4942 .c_int,
...@@ -4964,6 +4980,7 @@ pub const Type = extern union {...@@ -4964,6 +4980,7 @@ pub const Type = extern union {
4964 .i128,4980 .i128,
4965 .usize,4981 .usize,
4966 .isize,4982 .isize,
4983 .c_char,
4967 .c_short,4984 .c_short,
4968 .c_ushort,4985 .c_ushort,
4969 .c_int,4986 .c_int,
...@@ -5155,6 +5172,7 @@ pub const Type = extern union {...@@ -5155,6 +5172,7 @@ pub const Type = extern union {
5155 .i128,5172 .i128,
5156 .usize,5173 .usize,
5157 .isize,5174 .isize,
5175 .c_char,
5158 .c_short,5176 .c_short,
5159 .c_ushort,5177 .c_ushort,
5160 .c_int,5178 .c_int,
...@@ -5993,6 +6011,7 @@ pub const Type = extern union {...@@ -5993,6 +6011,7 @@ pub const Type = extern union {
5993 i128,6011 i128,
5994 usize,6012 usize,
5995 isize,6013 isize,
6014 c_char,
5996 c_short,6015 c_short,
5997 c_ushort,6016 c_ushort,
5998 c_int,6017 c_int,
...@@ -6118,6 +6137,7 @@ pub const Type = extern union {...@@ -6118,6 +6137,7 @@ pub const Type = extern union {
6118 .i128,6137 .i128,
6119 .usize,6138 .usize,
6120 .isize,6139 .isize,
6140 .c_char,
6121 .c_short,6141 .c_short,
6122 .c_ushort,6142 .c_ushort,
6123 .c_int,6143 .c_int,
src/value.zig+5
...@@ -40,6 +40,7 @@ pub const Value = extern union {...@@ -40,6 +40,7 @@ pub const Value = extern union {
40 i128_type,40 i128_type,
41 usize_type,41 usize_type,
42 isize_type,42 isize_type,
43 c_char_type,
43 c_short_type,44 c_short_type,
44 c_ushort_type,45 c_ushort_type,
45 c_int_type,46 c_int_type,
...@@ -210,6 +211,7 @@ pub const Value = extern union {...@@ -210,6 +211,7 @@ pub const Value = extern union {
210 .i128_type,211 .i128_type,
211 .usize_type,212 .usize_type,
212 .isize_type,213 .isize_type,
214 .c_char_type,
213 .c_short_type,215 .c_short_type,
214 .c_ushort_type,216 .c_ushort_type,
215 .c_int_type,217 .c_int_type,
...@@ -413,6 +415,7 @@ pub const Value = extern union {...@@ -413,6 +415,7 @@ pub const Value = extern union {
413 .i128_type,415 .i128_type,
414 .usize_type,416 .usize_type,
415 .isize_type,417 .isize_type,
418 .c_char_type,
416 .c_short_type,419 .c_short_type,
417 .c_ushort_type,420 .c_ushort_type,
418 .c_int_type,421 .c_int_type,
...@@ -679,6 +682,7 @@ pub const Value = extern union {...@@ -679,6 +682,7 @@ pub const Value = extern union {
679 .i128_type => return out_stream.writeAll("i128"),682 .i128_type => return out_stream.writeAll("i128"),
680 .isize_type => return out_stream.writeAll("isize"),683 .isize_type => return out_stream.writeAll("isize"),
681 .usize_type => return out_stream.writeAll("usize"),684 .usize_type => return out_stream.writeAll("usize"),
685 .c_char_type => return out_stream.writeAll("c_char"),
682 .c_short_type => return out_stream.writeAll("c_short"),686 .c_short_type => return out_stream.writeAll("c_short"),
683 .c_ushort_type => return out_stream.writeAll("c_ushort"),687 .c_ushort_type => return out_stream.writeAll("c_ushort"),
684 .c_int_type => return out_stream.writeAll("c_int"),688 .c_int_type => return out_stream.writeAll("c_int"),
...@@ -919,6 +923,7 @@ pub const Value = extern union {...@@ -919,6 +923,7 @@ pub const Value = extern union {
919 .i128_type => Type.initTag(.i128),923 .i128_type => Type.initTag(.i128),
920 .usize_type => Type.initTag(.usize),924 .usize_type => Type.initTag(.usize),
921 .isize_type => Type.initTag(.isize),925 .isize_type => Type.initTag(.isize),
926 .c_char_type => Type.initTag(.c_char),
922 .c_short_type => Type.initTag(.c_short),927 .c_short_type => Type.initTag(.c_short),
923 .c_ushort_type => Type.initTag(.c_ushort),928 .c_ushort_type => Type.initTag(.c_ushort),
924 .c_int_type => Type.initTag(.c_int),929 .c_int_type => Type.initTag(.c_int),
stage1/zig1.wasm
Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ