| author | |
| committer | |
| log | 1c636e2564e2fc2e8e4b6b1edbc782592ee3d2d7 |
| tree | 5311dc81615ff9efa2b4840070371f54182f8bee |
| parent | 9baf8917725ede02d9fc1aeebe253842174ee57b |
| parent | 563ea60a86a733f53f2394a11cb9ec4e56063fa3 |
| signature |
Support inline keyword as well as callconv(.Inline)52 files changed, 426 insertions(+), 411 deletions(-)
lib/std/Thread.zig+1-1| ... | @@ -68,7 +68,7 @@ else switch (std.Target.current.os.tag) { | ... | @@ -68,7 +68,7 @@ else switch (std.Target.current.os.tag) { |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | /// Signals the processor that it is inside a busy-wait spin-loop ("spin lock"). | 70 | /// Signals the processor that it is inside a busy-wait spin-loop ("spin lock"). |
| 71 | pub fn spinLoopHint() callconv(.Inline) void { | 71 | pub inline fn spinLoopHint() void { |
| 72 | switch (std.Target.current.cpu.arch) { | 72 | switch (std.Target.current.cpu.arch) { |
| 73 | .i386, .x86_64 => { | 73 | .i386, .x86_64 => { |
| 74 | asm volatile ("pause" ::: "memory"); | 74 | asm volatile ("pause" ::: "memory"); |
lib/std/bit_set.zig+5-5| ... | @@ -83,7 +83,7 @@ pub fn IntegerBitSet(comptime size: u16) type { | ... | @@ -83,7 +83,7 @@ pub fn IntegerBitSet(comptime size: u16) type { |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | /// Returns the number of bits in this bit set | 85 | /// Returns the number of bits in this bit set |
| 86 | pub fn capacity(self: Self) callconv(.Inline) usize { | 86 | pub inline fn capacity(self: Self) usize { |
| 87 | return bit_length; | 87 | return bit_length; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| ... | @@ -310,7 +310,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { | ... | @@ -310,7 +310,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | /// Returns the number of bits in this bit set | 312 | /// Returns the number of bits in this bit set |
| 313 | pub fn capacity(self: Self) callconv(.Inline) usize { | 313 | pub inline fn capacity(self: Self) usize { |
| 314 | return bit_length; | 314 | return bit_length; |
| 315 | } | 315 | } |
| 316 | 316 | ||
| ... | @@ -574,7 +574,7 @@ pub const DynamicBitSetUnmanaged = struct { | ... | @@ -574,7 +574,7 @@ pub const DynamicBitSetUnmanaged = struct { |
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | /// Returns the number of bits in this bit set | 576 | /// Returns the number of bits in this bit set |
| 577 | pub fn capacity(self: Self) callconv(.Inline) usize { | 577 | pub inline fn capacity(self: Self) usize { |
| 578 | return self.bit_length; | 578 | return self.bit_length; |
| 579 | } | 579 | } |
| 580 | 580 | ||
| ... | @@ -789,7 +789,7 @@ pub const DynamicBitSet = struct { | ... | @@ -789,7 +789,7 @@ pub const DynamicBitSet = struct { |
| 789 | } | 789 | } |
| 790 | 790 | ||
| 791 | /// Returns the number of bits in this bit set | 791 | /// Returns the number of bits in this bit set |
| 792 | pub fn capacity(self: Self) callconv(.Inline) usize { | 792 | pub inline fn capacity(self: Self) usize { |
| 793 | return self.unmanaged.capacity(); | 793 | return self.unmanaged.capacity(); |
| 794 | } | 794 | } |
| 795 | 795 | ||
| ... | @@ -969,7 +969,7 @@ fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) typ | ... | @@ -969,7 +969,7 @@ fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) typ |
| 969 | // isn't a next word. If the next word is the | 969 | // isn't a next word. If the next word is the |
| 970 | // last word, mask off the padding bits so we | 970 | // last word, mask off the padding bits so we |
| 971 | // don't visit them. | 971 | // don't visit them. |
| 972 | fn nextWord(self: *Self, comptime is_first_word: bool) callconv(.Inline) void { | 972 | inline fn nextWord(self: *Self, comptime is_first_word: bool) void { |
| 973 | var word = switch (direction) { | 973 | var word = switch (direction) { |
| 974 | .forward => self.words_remain[0], | 974 | .forward => self.words_remain[0], |
| 975 | .reverse => self.words_remain[self.words_remain.len - 1], | 975 | .reverse => self.words_remain[self.words_remain.len - 1], |
lib/std/c/builtins.zig+46-46| ... | @@ -6,136 +6,136 @@ | ... | @@ -6,136 +6,136 @@ |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | 8 | ||
| 9 | pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 { | 9 | pub inline fn __builtin_bswap16(val: u16) u16 { |
| 10 | return @byteSwap(u16, val); | 10 | return @byteSwap(u16, val); |
| 11 | } | 11 | } |
| 12 | pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 { | 12 | pub inline fn __builtin_bswap32(val: u32) u32 { |
| 13 | return @byteSwap(u32, val); | 13 | return @byteSwap(u32, val); |
| 14 | } | 14 | } |
| 15 | pub fn __builtin_bswap64(val: u64) callconv(.Inline) u64 { | 15 | pub inline fn __builtin_bswap64(val: u64) u64 { |
| 16 | return @byteSwap(u64, val); | 16 | return @byteSwap(u64, val); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | pub fn __builtin_signbit(val: f64) callconv(.Inline) c_int { | 19 | pub inline fn __builtin_signbit(val: f64) c_int { |
| 20 | return @boolToInt(std.math.signbit(val)); | 20 | return @boolToInt(std.math.signbit(val)); |
| 21 | } | 21 | } |
| 22 | pub fn __builtin_signbitf(val: f32) callconv(.Inline) c_int { | 22 | pub inline fn __builtin_signbitf(val: f32) c_int { |
| 23 | return @boolToInt(std.math.signbit(val)); | 23 | return @boolToInt(std.math.signbit(val)); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | pub fn __builtin_popcount(val: c_uint) callconv(.Inline) c_int { | 26 | pub inline fn __builtin_popcount(val: c_uint) c_int { |
| 27 | // popcount of a c_uint will never exceed the capacity of a c_int | 27 | // popcount of a c_uint will never exceed the capacity of a c_int |
| 28 | @setRuntimeSafety(false); | 28 | @setRuntimeSafety(false); |
| 29 | return @bitCast(c_int, @as(c_uint, @popCount(c_uint, val))); | 29 | return @bitCast(c_int, @as(c_uint, @popCount(c_uint, val))); |
| 30 | } | 30 | } |
| 31 | pub fn __builtin_ctz(val: c_uint) callconv(.Inline) c_int { | 31 | pub inline fn __builtin_ctz(val: c_uint) c_int { |
| 32 | // Returns the number of trailing 0-bits in val, starting at the least significant bit position. | 32 | // Returns the number of trailing 0-bits in val, starting at the least significant bit position. |
| 33 | // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint | 33 | // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint |
| 34 | @setRuntimeSafety(false); | 34 | @setRuntimeSafety(false); |
| 35 | return @bitCast(c_int, @as(c_uint, @ctz(c_uint, val))); | 35 | return @bitCast(c_int, @as(c_uint, @ctz(c_uint, val))); |
| 36 | } | 36 | } |
| 37 | pub fn __builtin_clz(val: c_uint) callconv(.Inline) c_int { | 37 | pub inline fn __builtin_clz(val: c_uint) c_int { |
| 38 | // Returns the number of leading 0-bits in x, starting at the most significant bit position. | 38 | // Returns the number of leading 0-bits in x, starting at the most significant bit position. |
| 39 | // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint | 39 | // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint |
| 40 | @setRuntimeSafety(false); | 40 | @setRuntimeSafety(false); |
| 41 | return @bitCast(c_int, @as(c_uint, @clz(c_uint, val))); | 41 | return @bitCast(c_int, @as(c_uint, @clz(c_uint, val))); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | pub fn __builtin_sqrt(val: f64) callconv(.Inline) f64 { | 44 | pub inline fn __builtin_sqrt(val: f64) f64 { |
| 45 | return @sqrt(val); | 45 | return @sqrt(val); |
| 46 | } | 46 | } |
| 47 | pub fn __builtin_sqrtf(val: f32) callconv(.Inline) f32 { | 47 | pub inline fn __builtin_sqrtf(val: f32) f32 { |
| 48 | return @sqrt(val); | 48 | return @sqrt(val); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | pub fn __builtin_sin(val: f64) callconv(.Inline) f64 { | 51 | pub inline fn __builtin_sin(val: f64) f64 { |
| 52 | return @sin(val); | 52 | return @sin(val); |
| 53 | } | 53 | } |
| 54 | pub fn __builtin_sinf(val: f32) callconv(.Inline) f32 { | 54 | pub inline fn __builtin_sinf(val: f32) f32 { |
| 55 | return @sin(val); | 55 | return @sin(val); |
| 56 | } | 56 | } |
| 57 | pub fn __builtin_cos(val: f64) callconv(.Inline) f64 { | 57 | pub inline fn __builtin_cos(val: f64) f64 { |
| 58 | return @cos(val); | 58 | return @cos(val); |
| 59 | } | 59 | } |
| 60 | pub fn __builtin_cosf(val: f32) callconv(.Inline) f32 { | 60 | pub inline fn __builtin_cosf(val: f32) f32 { |
| 61 | return @cos(val); | 61 | return @cos(val); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | pub fn __builtin_exp(val: f64) callconv(.Inline) f64 { | 64 | pub inline fn __builtin_exp(val: f64) f64 { |
| 65 | return @exp(val); | 65 | return @exp(val); |
| 66 | } | 66 | } |
| 67 | pub fn __builtin_expf(val: f32) callconv(.Inline) f32 { | 67 | pub inline fn __builtin_expf(val: f32) f32 { |
| 68 | return @exp(val); | 68 | return @exp(val); |
| 69 | } | 69 | } |
| 70 | pub fn __builtin_exp2(val: f64) callconv(.Inline) f64 { | 70 | pub inline fn __builtin_exp2(val: f64) f64 { |
| 71 | return @exp2(val); | 71 | return @exp2(val); |
| 72 | } | 72 | } |
| 73 | pub fn __builtin_exp2f(val: f32) callconv(.Inline) f32 { | 73 | pub inline fn __builtin_exp2f(val: f32) f32 { |
| 74 | return @exp2(val); | 74 | return @exp2(val); |
| 75 | } | 75 | } |
| 76 | pub fn __builtin_log(val: f64) callconv(.Inline) f64 { | 76 | pub inline fn __builtin_log(val: f64) f64 { |
| 77 | return @log(val); | 77 | return @log(val); |
| 78 | } | 78 | } |
| 79 | pub fn __builtin_logf(val: f32) callconv(.Inline) f32 { | 79 | pub inline fn __builtin_logf(val: f32) f32 { |
| 80 | return @log(val); | 80 | return @log(val); |
| 81 | } | 81 | } |
| 82 | pub fn __builtin_log2(val: f64) callconv(.Inline) f64 { | 82 | pub inline fn __builtin_log2(val: f64) f64 { |
| 83 | return @log2(val); | 83 | return @log2(val); |
| 84 | } | 84 | } |
| 85 | pub fn __builtin_log2f(val: f32) callconv(.Inline) f32 { | 85 | pub inline fn __builtin_log2f(val: f32) f32 { |
| 86 | return @log2(val); | 86 | return @log2(val); |
| 87 | } | 87 | } |
| 88 | pub fn __builtin_log10(val: f64) callconv(.Inline) f64 { | 88 | pub inline fn __builtin_log10(val: f64) f64 { |
| 89 | return @log10(val); | 89 | return @log10(val); |
| 90 | } | 90 | } |
| 91 | pub fn __builtin_log10f(val: f32) callconv(.Inline) f32 { | 91 | pub inline fn __builtin_log10f(val: f32) f32 { |
| 92 | return @log10(val); | 92 | return @log10(val); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | // Standard C Library bug: The absolute value of the most negative integer remains negative. | 95 | // Standard C Library bug: The absolute value of the most negative integer remains negative. |
| 96 | pub fn __builtin_abs(val: c_int) callconv(.Inline) c_int { | 96 | pub inline fn __builtin_abs(val: c_int) c_int { |
| 97 | return std.math.absInt(val) catch std.math.minInt(c_int); | 97 | return std.math.absInt(val) catch std.math.minInt(c_int); |
| 98 | } | 98 | } |
| 99 | pub fn __builtin_fabs(val: f64) callconv(.Inline) f64 { | 99 | pub inline fn __builtin_fabs(val: f64) f64 { |
| 100 | return @fabs(val); | 100 | return @fabs(val); |
| 101 | } | 101 | } |
| 102 | pub fn __builtin_fabsf(val: f32) callconv(.Inline) f32 { | 102 | pub inline fn __builtin_fabsf(val: f32) f32 { |
| 103 | return @fabs(val); | 103 | return @fabs(val); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | pub fn __builtin_floor(val: f64) callconv(.Inline) f64 { | 106 | pub inline fn __builtin_floor(val: f64) f64 { |
| 107 | return @floor(val); | 107 | return @floor(val); |
| 108 | } | 108 | } |
| 109 | pub fn __builtin_floorf(val: f32) callconv(.Inline) f32 { | 109 | pub inline fn __builtin_floorf(val: f32) f32 { |
| 110 | return @floor(val); | 110 | return @floor(val); |
| 111 | } | 111 | } |
| 112 | pub fn __builtin_ceil(val: f64) callconv(.Inline) f64 { | 112 | pub inline fn __builtin_ceil(val: f64) f64 { |
| 113 | return @ceil(val); | 113 | return @ceil(val); |
| 114 | } | 114 | } |
| 115 | pub fn __builtin_ceilf(val: f32) callconv(.Inline) f32 { | 115 | pub inline fn __builtin_ceilf(val: f32) f32 { |
| 116 | return @ceil(val); | 116 | return @ceil(val); |
| 117 | } | 117 | } |
| 118 | pub fn __builtin_trunc(val: f64) callconv(.Inline) f64 { | 118 | pub inline fn __builtin_trunc(val: f64) f64 { |
| 119 | return @trunc(val); | 119 | return @trunc(val); |
| 120 | } | 120 | } |
| 121 | pub fn __builtin_truncf(val: f32) callconv(.Inline) f32 { | 121 | pub inline fn __builtin_truncf(val: f32) f32 { |
| 122 | return @trunc(val); | 122 | return @trunc(val); |
| 123 | } | 123 | } |
| 124 | pub fn __builtin_round(val: f64) callconv(.Inline) f64 { | 124 | pub inline fn __builtin_round(val: f64) f64 { |
| 125 | return @round(val); | 125 | return @round(val); |
| 126 | } | 126 | } |
| 127 | pub fn __builtin_roundf(val: f32) callconv(.Inline) f32 { | 127 | pub inline fn __builtin_roundf(val: f32) f32 { |
| 128 | return @round(val); | 128 | return @round(val); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | pub fn __builtin_strlen(s: [*c]const u8) callconv(.Inline) usize { | 131 | pub inline fn __builtin_strlen(s: [*c]const u8) usize { |
| 132 | return std.mem.lenZ(s); | 132 | return std.mem.lenZ(s); |
| 133 | } | 133 | } |
| 134 | pub fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.Inline) c_int { | 134 | pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int { |
| 135 | return @as(c_int, std.cstr.cmp(s1, s2)); | 135 | return @as(c_int, std.cstr.cmp(s1, s2)); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) usize { | 138 | pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) usize { |
| 139 | // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html | 139 | // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html |
| 140 | // If it is not possible to determine which objects ptr points to at compile time, | 140 | // If it is not possible to determine which objects ptr points to at compile time, |
| 141 | // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 | 141 | // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 |
| ... | @@ -145,37 +145,37 @@ pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) u | ... | @@ -145,37 +145,37 @@ pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) u |
| 145 | unreachable; | 145 | unreachable; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | pub fn __builtin___memset_chk( | 148 | pub inline fn __builtin___memset_chk( |
| 149 | dst: ?*c_void, | 149 | dst: ?*c_void, |
| 150 | val: c_int, | 150 | val: c_int, |
| 151 | len: usize, | 151 | len: usize, |
| 152 | remaining: usize, | 152 | remaining: usize, |
| 153 | ) callconv(.Inline) ?*c_void { | 153 | ) ?*c_void { |
| 154 | if (len > remaining) @panic("std.c.builtins.memset_chk called with len > remaining"); | 154 | if (len > remaining) @panic("std.c.builtins.memset_chk called with len > remaining"); |
| 155 | return __builtin_memset(dst, val, len); | 155 | return __builtin_memset(dst, val, len); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | pub fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) callconv(.Inline) ?*c_void { | 158 | pub inline fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) ?*c_void { |
| 159 | const dst_cast = @ptrCast([*c]u8, dst); | 159 | const dst_cast = @ptrCast([*c]u8, dst); |
| 160 | @memset(dst_cast, @bitCast(u8, @truncate(i8, val)), len); | 160 | @memset(dst_cast, @bitCast(u8, @truncate(i8, val)), len); |
| 161 | return dst; | 161 | return dst; |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | pub fn __builtin___memcpy_chk( | 164 | pub inline fn __builtin___memcpy_chk( |
| 165 | noalias dst: ?*c_void, | 165 | noalias dst: ?*c_void, |
| 166 | noalias src: ?*const c_void, | 166 | noalias src: ?*const c_void, |
| 167 | len: usize, | 167 | len: usize, |
| 168 | remaining: usize, | 168 | remaining: usize, |
| 169 | ) callconv(.Inline) ?*c_void { | 169 | ) ?*c_void { |
| 170 | if (len > remaining) @panic("std.c.builtins.memcpy_chk called with len > remaining"); | 170 | if (len > remaining) @panic("std.c.builtins.memcpy_chk called with len > remaining"); |
| 171 | return __builtin_memcpy(dst, src, len); | 171 | return __builtin_memcpy(dst, src, len); |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | pub fn __builtin_memcpy( | 174 | pub inline fn __builtin_memcpy( |
| 175 | noalias dst: ?*c_void, | 175 | noalias dst: ?*c_void, |
| 176 | noalias src: ?*const c_void, | 176 | noalias src: ?*const c_void, |
| 177 | len: usize, | 177 | len: usize, |
| 178 | ) callconv(.Inline) ?*c_void { | 178 | ) ?*c_void { |
| 179 | const dst_cast = @ptrCast([*c]u8, dst); | 179 | const dst_cast = @ptrCast([*c]u8, dst); |
| 180 | const src_cast = @ptrCast([*c]const u8, src); | 180 | const src_cast = @ptrCast([*c]const u8, src); |
| 181 | 181 | ||
| ... | @@ -185,7 +185,7 @@ pub fn __builtin_memcpy( | ... | @@ -185,7 +185,7 @@ pub fn __builtin_memcpy( |
| 185 | 185 | ||
| 186 | /// The return value of __builtin_expect is `expr`. `c` is the expected value | 186 | /// The return value of __builtin_expect is `expr`. `c` is the expected value |
| 187 | /// of `expr` and is used as a hint to the compiler in C. Here it is unused. | 187 | /// of `expr` and is used as a hint to the compiler in C. Here it is unused. |
| 188 | pub fn __builtin_expect(expr: c_long, c: c_long) callconv(.Inline) c_long { | 188 | pub inline fn __builtin_expect(expr: c_long, c: c_long) c_long { |
| 189 | return expr; | 189 | return expr; |
| 190 | } | 190 | } |
| 191 | 191 |
lib/std/compress/deflate.zig+1-1| ... | @@ -209,7 +209,7 @@ pub fn InflateStream(comptime ReaderType: type) type { | ... | @@ -209,7 +209,7 @@ pub fn InflateStream(comptime ReaderType: type) type { |
| 209 | 209 | ||
| 210 | // Insert a single byte into the window. | 210 | // Insert a single byte into the window. |
| 211 | // Assumes there's enough space. | 211 | // Assumes there's enough space. |
| 212 | fn appendUnsafe(self: *WSelf, value: u8) callconv(.Inline) void { | 212 | inline fn appendUnsafe(self: *WSelf, value: u8) void { |
| 213 | self.buf[self.wi] = value; | 213 | self.buf[self.wi] = value; |
| 214 | self.wi = (self.wi + 1) & (self.buf.len - 1); | 214 | self.wi = (self.wi + 1) & (self.buf.len - 1); |
| 215 | self.el += 1; | 215 | self.el += 1; |
lib/std/crypto/25519/curve25519.zig+2-2| ... | @@ -20,12 +20,12 @@ pub const Curve25519 = struct { | ... | @@ -20,12 +20,12 @@ pub const Curve25519 = struct { |
| 20 | x: Fe, | 20 | x: Fe, |
| 21 | 21 | ||
| 22 | /// Decode a Curve25519 point from its compressed (X) coordinates. | 22 | /// Decode a Curve25519 point from its compressed (X) coordinates. |
| 23 | pub fn fromBytes(s: [32]u8) callconv(.Inline) Curve25519 { | 23 | pub inline fn fromBytes(s: [32]u8) Curve25519 { |
| 24 | return .{ .x = Fe.fromBytes(s) }; | 24 | return .{ .x = Fe.fromBytes(s) }; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | /// Encode a Curve25519 point. | 27 | /// Encode a Curve25519 point. |
| 28 | pub fn toBytes(p: Curve25519) callconv(.Inline) [32]u8 { | 28 | pub inline fn toBytes(p: Curve25519) [32]u8 { |
| 29 | return p.x.toBytes(); | 29 | return p.x.toBytes(); |
| 30 | } | 30 | } |
| 31 | 31 |
lib/std/crypto/25519/edwards25519.zig+3-3| ... | @@ -91,7 +91,7 @@ pub const Edwards25519 = struct { | ... | @@ -91,7 +91,7 @@ pub const Edwards25519 = struct { |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | /// Flip the sign of the X coordinate. | 93 | /// Flip the sign of the X coordinate. |
| 94 | pub fn neg(p: Edwards25519) callconv(.Inline) Edwards25519 { | 94 | pub inline fn neg(p: Edwards25519) Edwards25519 { |
| 95 | return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() }; | 95 | return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() }; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| ... | @@ -136,14 +136,14 @@ pub const Edwards25519 = struct { | ... | @@ -136,14 +136,14 @@ pub const Edwards25519 = struct { |
| 136 | return p.add(q.neg()); | 136 | return p.add(q.neg()); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) callconv(.Inline) void { | 139 | inline fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) void { |
| 140 | p.x.cMov(a.x, c); | 140 | p.x.cMov(a.x, c); |
| 141 | p.y.cMov(a.y, c); | 141 | p.y.cMov(a.y, c); |
| 142 | p.z.cMov(a.z, c); | 142 | p.z.cMov(a.z, c); |
| 143 | p.t.cMov(a.t, c); | 143 | p.t.cMov(a.t, c); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | fn pcSelect(comptime n: usize, pc: [n]Edwards25519, b: u8) callconv(.Inline) Edwards25519 { | 146 | inline fn pcSelect(comptime n: usize, pc: [n]Edwards25519, b: u8) Edwards25519 { |
| 147 | var t = Edwards25519.identityElement; | 147 | var t = Edwards25519.identityElement; |
| 148 | comptime var i: u8 = 1; | 148 | comptime var i: u8 = 1; |
| 149 | inline while (i < pc.len) : (i += 1) { | 149 | inline while (i < pc.len) : (i += 1) { |
lib/std/crypto/25519/field.zig+14-14| ... | @@ -56,7 +56,7 @@ pub const Fe = struct { | ... | @@ -56,7 +56,7 @@ pub const Fe = struct { |
| 56 | pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } }; | 56 | pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } }; |
| 57 | 57 | ||
| 58 | /// Return true if the field element is zero | 58 | /// Return true if the field element is zero |
| 59 | pub fn isZero(fe: Fe) callconv(.Inline) bool { | 59 | pub inline fn isZero(fe: Fe) bool { |
| 60 | var reduced = fe; | 60 | var reduced = fe; |
| 61 | reduced.reduce(); | 61 | reduced.reduce(); |
| 62 | const limbs = reduced.limbs; | 62 | const limbs = reduced.limbs; |
| ... | @@ -64,7 +64,7 @@ pub const Fe = struct { | ... | @@ -64,7 +64,7 @@ pub const Fe = struct { |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | /// Return true if both field elements are equivalent | 66 | /// Return true if both field elements are equivalent |
| 67 | pub fn equivalent(a: Fe, b: Fe) callconv(.Inline) bool { | 67 | pub inline fn equivalent(a: Fe, b: Fe) bool { |
| 68 | return a.sub(b).isZero(); | 68 | return a.sub(b).isZero(); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| ... | @@ -168,7 +168,7 @@ pub const Fe = struct { | ... | @@ -168,7 +168,7 @@ pub const Fe = struct { |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | /// Add a field element | 170 | /// Add a field element |
| 171 | pub fn add(a: Fe, b: Fe) callconv(.Inline) Fe { | 171 | pub inline fn add(a: Fe, b: Fe) Fe { |
| 172 | var fe: Fe = undefined; | 172 | var fe: Fe = undefined; |
| 173 | comptime var i = 0; | 173 | comptime var i = 0; |
| 174 | inline while (i < 5) : (i += 1) { | 174 | inline while (i < 5) : (i += 1) { |
| ... | @@ -178,7 +178,7 @@ pub const Fe = struct { | ... | @@ -178,7 +178,7 @@ pub const Fe = struct { |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | /// Substract a field elememnt | 180 | /// Substract a field elememnt |
| 181 | pub fn sub(a: Fe, b: Fe) callconv(.Inline) Fe { | 181 | pub inline fn sub(a: Fe, b: Fe) Fe { |
| 182 | var fe = b; | 182 | var fe = b; |
| 183 | comptime var i = 0; | 183 | comptime var i = 0; |
| 184 | inline while (i < 4) : (i += 1) { | 184 | inline while (i < 4) : (i += 1) { |
| ... | @@ -197,17 +197,17 @@ pub const Fe = struct { | ... | @@ -197,17 +197,17 @@ pub const Fe = struct { |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | /// Negate a field element | 199 | /// Negate a field element |
| 200 | pub fn neg(a: Fe) callconv(.Inline) Fe { | 200 | pub inline fn neg(a: Fe) Fe { |
| 201 | return zero.sub(a); | 201 | return zero.sub(a); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | /// Return true if a field element is negative | 204 | /// Return true if a field element is negative |
| 205 | pub fn isNegative(a: Fe) callconv(.Inline) bool { | 205 | pub inline fn isNegative(a: Fe) bool { |
| 206 | return (a.toBytes()[0] & 1) != 0; | 206 | return (a.toBytes()[0] & 1) != 0; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | /// Conditonally replace a field element with `a` if `c` is positive | 209 | /// Conditonally replace a field element with `a` if `c` is positive |
| 210 | pub fn cMov(fe: *Fe, a: Fe, c: u64) callconv(.Inline) void { | 210 | pub inline fn cMov(fe: *Fe, a: Fe, c: u64) void { |
| 211 | const mask: u64 = 0 -% c; | 211 | const mask: u64 = 0 -% c; |
| 212 | var x = fe.*; | 212 | var x = fe.*; |
| 213 | comptime var i = 0; | 213 | comptime var i = 0; |
| ... | @@ -248,7 +248,7 @@ pub const Fe = struct { | ... | @@ -248,7 +248,7 @@ pub const Fe = struct { |
| 248 | } | 248 | } |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | fn _carry128(r: *[5]u128) callconv(.Inline) Fe { | 251 | inline fn _carry128(r: *[5]u128) Fe { |
| 252 | var rs: [5]u64 = undefined; | 252 | var rs: [5]u64 = undefined; |
| 253 | comptime var i = 0; | 253 | comptime var i = 0; |
| 254 | inline while (i < 4) : (i += 1) { | 254 | inline while (i < 4) : (i += 1) { |
| ... | @@ -269,7 +269,7 @@ pub const Fe = struct { | ... | @@ -269,7 +269,7 @@ pub const Fe = struct { |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | /// Multiply two field elements | 271 | /// Multiply two field elements |
| 272 | pub fn mul(a: Fe, b: Fe) callconv(.Inline) Fe { | 272 | pub inline fn mul(a: Fe, b: Fe) Fe { |
| 273 | var ax: [5]u128 = undefined; | 273 | var ax: [5]u128 = undefined; |
| 274 | var bx: [5]u128 = undefined; | 274 | var bx: [5]u128 = undefined; |
| 275 | var a19: [5]u128 = undefined; | 275 | var a19: [5]u128 = undefined; |
| ... | @@ -292,7 +292,7 @@ pub const Fe = struct { | ... | @@ -292,7 +292,7 @@ pub const Fe = struct { |
| 292 | return _carry128(&r); | 292 | return _carry128(&r); |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | fn _sq(a: Fe, comptime double: bool) callconv(.Inline) Fe { | 295 | inline fn _sq(a: Fe, comptime double: bool) Fe { |
| 296 | var ax: [5]u128 = undefined; | 296 | var ax: [5]u128 = undefined; |
| 297 | var r: [5]u128 = undefined; | 297 | var r: [5]u128 = undefined; |
| 298 | comptime var i = 0; | 298 | comptime var i = 0; |
| ... | @@ -321,17 +321,17 @@ pub const Fe = struct { | ... | @@ -321,17 +321,17 @@ pub const Fe = struct { |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | /// Square a field element | 323 | /// Square a field element |
| 324 | pub fn sq(a: Fe) callconv(.Inline) Fe { | 324 | pub inline fn sq(a: Fe) Fe { |
| 325 | return _sq(a, false); | 325 | return _sq(a, false); |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | /// Square and double a field element | 328 | /// Square and double a field element |
| 329 | pub fn sq2(a: Fe) callconv(.Inline) Fe { | 329 | pub inline fn sq2(a: Fe) Fe { |
| 330 | return _sq(a, true); | 330 | return _sq(a, true); |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | /// Multiply a field element with a small (32-bit) integer | 333 | /// Multiply a field element with a small (32-bit) integer |
| 334 | pub fn mul32(a: Fe, comptime n: u32) callconv(.Inline) Fe { | 334 | pub inline fn mul32(a: Fe, comptime n: u32) Fe { |
| 335 | const sn = @intCast(u128, n); | 335 | const sn = @intCast(u128, n); |
| 336 | var fe: Fe = undefined; | 336 | var fe: Fe = undefined; |
| 337 | var x: u128 = 0; | 337 | var x: u128 = 0; |
| ... | @@ -346,7 +346,7 @@ pub const Fe = struct { | ... | @@ -346,7 +346,7 @@ pub const Fe = struct { |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | /// Square a field element `n` times | 348 | /// Square a field element `n` times |
| 349 | fn sqn(a: Fe, comptime n: comptime_int) callconv(.Inline) Fe { | 349 | inline fn sqn(a: Fe, comptime n: comptime_int) Fe { |
| 350 | var i: usize = 0; | 350 | var i: usize = 0; |
| 351 | var fe = a; | 351 | var fe = a; |
| 352 | while (i < n) : (i += 1) { | 352 | while (i < n) : (i += 1) { |
lib/std/crypto/25519/ristretto255.zig+4-4| ... | @@ -47,7 +47,7 @@ pub const Ristretto255 = struct { | ... | @@ -47,7 +47,7 @@ pub const Ristretto255 = struct { |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | /// Reject the neutral element. | 49 | /// Reject the neutral element. |
| 50 | pub fn rejectIdentity(p: Ristretto255) callconv(.Inline) IdentityElementError!void { | 50 | pub inline fn rejectIdentity(p: Ristretto255) IdentityElementError!void { |
| 51 | return p.p.rejectIdentity(); | 51 | return p.p.rejectIdentity(); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| ... | @@ -146,19 +146,19 @@ pub const Ristretto255 = struct { | ... | @@ -146,19 +146,19 @@ pub const Ristretto255 = struct { |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | /// Double a Ristretto255 element. | 148 | /// Double a Ristretto255 element. |
| 149 | pub fn dbl(p: Ristretto255) callconv(.Inline) Ristretto255 { | 149 | pub inline fn dbl(p: Ristretto255) Ristretto255 { |
| 150 | return .{ .p = p.p.dbl() }; | 150 | return .{ .p = p.p.dbl() }; |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | /// Add two Ristretto255 elements. | 153 | /// Add two Ristretto255 elements. |
| 154 | pub fn add(p: Ristretto255, q: Ristretto255) callconv(.Inline) Ristretto255 { | 154 | pub inline fn add(p: Ristretto255, q: Ristretto255) Ristretto255 { |
| 155 | return .{ .p = p.p.add(q.p) }; | 155 | return .{ .p = p.p.add(q.p) }; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | /// Multiply a Ristretto255 element with a scalar. | 158 | /// Multiply a Ristretto255 element with a scalar. |
| 159 | /// Return error.WeakPublicKey if the resulting element is | 159 | /// Return error.WeakPublicKey if the resulting element is |
| 160 | /// the identity element. | 160 | /// the identity element. |
| 161 | pub fn mul(p: Ristretto255, s: [encoded_length]u8) callconv(.Inline) (IdentityElementError || WeakPublicKeyError)!Ristretto255 { | 161 | pub inline fn mul(p: Ristretto255, s: [encoded_length]u8) (IdentityElementError || WeakPublicKeyError)!Ristretto255 { |
| 162 | return Ristretto255{ .p = try p.p.mul(s) }; | 162 | return Ristretto255{ .p = try p.p.mul(s) }; |
| 163 | } | 163 | } |
| 164 | 164 |
lib/std/crypto/25519/scalar.zig+1-1| ... | @@ -48,7 +48,7 @@ pub fn reduce64(s: [64]u8) [32]u8 { | ... | @@ -48,7 +48,7 @@ pub fn reduce64(s: [64]u8) [32]u8 { |
| 48 | 48 | ||
| 49 | /// Perform the X25519 "clamping" operation. | 49 | /// Perform the X25519 "clamping" operation. |
| 50 | /// The scalar is then guaranteed to be a multiple of the cofactor. | 50 | /// The scalar is then guaranteed to be a multiple of the cofactor. |
| 51 | pub fn clamp(s: *[32]u8) callconv(.Inline) void { | 51 | pub inline fn clamp(s: *[32]u8) void { |
| 52 | s[0] &= 248; | 52 | s[0] &= 248; |
| 53 | s[31] = (s[31] & 127) | 64; | 53 | s[31] = (s[31] & 127) | 64; |
| 54 | } | 54 | } |
lib/std/crypto/aegis.zig+2-2| ... | @@ -36,7 +36,7 @@ const State128L = struct { | ... | @@ -36,7 +36,7 @@ const State128L = struct { |
| 36 | return state; | 36 | return state; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | fn update(state: *State128L, d1: AesBlock, d2: AesBlock) callconv(.Inline) void { | 39 | inline fn update(state: *State128L, d1: AesBlock, d2: AesBlock) void { |
| 40 | const blocks = &state.blocks; | 40 | const blocks = &state.blocks; |
| 41 | const tmp = blocks[7]; | 41 | const tmp = blocks[7]; |
| 42 | comptime var i: usize = 7; | 42 | comptime var i: usize = 7; |
| ... | @@ -208,7 +208,7 @@ const State256 = struct { | ... | @@ -208,7 +208,7 @@ const State256 = struct { |
| 208 | return state; | 208 | return state; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | fn update(state: *State256, d: AesBlock) callconv(.Inline) void { | 211 | inline fn update(state: *State256, d: AesBlock) void { |
| 212 | const blocks = &state.blocks; | 212 | const blocks = &state.blocks; |
| 213 | const tmp = blocks[5].encrypt(blocks[0]); | 213 | const tmp = blocks[5].encrypt(blocks[0]); |
| 214 | comptime var i: usize = 5; | 214 | comptime var i: usize = 5; |
lib/std/crypto/aes/aesni.zig+16-16| ... | @@ -19,24 +19,24 @@ pub const Block = struct { | ... | @@ -19,24 +19,24 @@ pub const Block = struct { |
| 19 | repr: BlockVec, | 19 | repr: BlockVec, |
| 20 | 20 | ||
| 21 | /// Convert a byte sequence into an internal representation. | 21 | /// Convert a byte sequence into an internal representation. |
| 22 | pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { | 22 | pub inline fn fromBytes(bytes: *const [16]u8) Block { |
| 23 | const repr = mem.bytesToValue(BlockVec, bytes); | 23 | const repr = mem.bytesToValue(BlockVec, bytes); |
| 24 | return Block{ .repr = repr }; | 24 | return Block{ .repr = repr }; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | /// Convert the internal representation of a block into a byte sequence. | 27 | /// Convert the internal representation of a block into a byte sequence. |
| 28 | pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { | 28 | pub inline fn toBytes(block: Block) [16]u8 { |
| 29 | return mem.toBytes(block.repr); | 29 | return mem.toBytes(block.repr); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | /// XOR the block with a byte sequence. | 32 | /// XOR the block with a byte sequence. |
| 33 | pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { | 33 | pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { |
| 34 | const x = block.repr ^ fromBytes(bytes).repr; | 34 | const x = block.repr ^ fromBytes(bytes).repr; |
| 35 | return mem.toBytes(x); | 35 | return mem.toBytes(x); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | /// Encrypt a block with a round key. | 38 | /// Encrypt a block with a round key. |
| 39 | pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { | 39 | pub inline fn encrypt(block: Block, round_key: Block) Block { |
| 40 | return Block{ | 40 | return Block{ |
| 41 | .repr = asm ( | 41 | .repr = asm ( |
| 42 | \\ vaesenc %[rk], %[in], %[out] | 42 | \\ vaesenc %[rk], %[in], %[out] |
| ... | @@ -48,7 +48,7 @@ pub const Block = struct { | ... | @@ -48,7 +48,7 @@ pub const Block = struct { |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | /// Encrypt a block with the last round key. | 50 | /// Encrypt a block with the last round key. |
| 51 | pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { | 51 | pub inline fn encryptLast(block: Block, round_key: Block) Block { |
| 52 | return Block{ | 52 | return Block{ |
| 53 | .repr = asm ( | 53 | .repr = asm ( |
| 54 | \\ vaesenclast %[rk], %[in], %[out] | 54 | \\ vaesenclast %[rk], %[in], %[out] |
| ... | @@ -60,7 +60,7 @@ pub const Block = struct { | ... | @@ -60,7 +60,7 @@ pub const Block = struct { |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | /// Decrypt a block with a round key. | 62 | /// Decrypt a block with a round key. |
| 63 | pub fn decrypt(block: Block, inv_round_key: Block) callconv(.Inline) Block { | 63 | pub inline fn decrypt(block: Block, inv_round_key: Block) Block { |
| 64 | return Block{ | 64 | return Block{ |
| 65 | .repr = asm ( | 65 | .repr = asm ( |
| 66 | \\ vaesdec %[rk], %[in], %[out] | 66 | \\ vaesdec %[rk], %[in], %[out] |
| ... | @@ -72,7 +72,7 @@ pub const Block = struct { | ... | @@ -72,7 +72,7 @@ pub const Block = struct { |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | /// Decrypt a block with the last round key. | 74 | /// Decrypt a block with the last round key. |
| 75 | pub fn decryptLast(block: Block, inv_round_key: Block) callconv(.Inline) Block { | 75 | pub inline fn decryptLast(block: Block, inv_round_key: Block) Block { |
| 76 | return Block{ | 76 | return Block{ |
| 77 | .repr = asm ( | 77 | .repr = asm ( |
| 78 | \\ vaesdeclast %[rk], %[in], %[out] | 78 | \\ vaesdeclast %[rk], %[in], %[out] |
| ... | @@ -84,17 +84,17 @@ pub const Block = struct { | ... | @@ -84,17 +84,17 @@ pub const Block = struct { |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | /// Apply the bitwise XOR operation to the content of two blocks. | 86 | /// Apply the bitwise XOR operation to the content of two blocks. |
| 87 | pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 87 | pub inline fn xorBlocks(block1: Block, block2: Block) Block { |
| 88 | return Block{ .repr = block1.repr ^ block2.repr }; | 88 | return Block{ .repr = block1.repr ^ block2.repr }; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | /// Apply the bitwise AND operation to the content of two blocks. | 91 | /// Apply the bitwise AND operation to the content of two blocks. |
| 92 | pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 92 | pub inline fn andBlocks(block1: Block, block2: Block) Block { |
| 93 | return Block{ .repr = block1.repr & block2.repr }; | 93 | return Block{ .repr = block1.repr & block2.repr }; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /// Apply the bitwise OR operation to the content of two blocks. | 96 | /// Apply the bitwise OR operation to the content of two blocks. |
| 97 | pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 97 | pub inline fn orBlocks(block1: Block, block2: Block) Block { |
| 98 | return Block{ .repr = block1.repr | block2.repr }; | 98 | return Block{ .repr = block1.repr | block2.repr }; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| ... | @@ -114,7 +114,7 @@ pub const Block = struct { | ... | @@ -114,7 +114,7 @@ pub const Block = struct { |
| 114 | }; | 114 | }; |
| 115 | 115 | ||
| 116 | /// Encrypt multiple blocks in parallel, each their own round key. | 116 | /// Encrypt multiple blocks in parallel, each their own round key. |
| 117 | pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { | 117 | pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { |
| 118 | comptime var i = 0; | 118 | comptime var i = 0; |
| 119 | var out: [count]Block = undefined; | 119 | var out: [count]Block = undefined; |
| 120 | inline while (i < count) : (i += 1) { | 120 | inline while (i < count) : (i += 1) { |
| ... | @@ -124,7 +124,7 @@ pub const Block = struct { | ... | @@ -124,7 +124,7 @@ pub const Block = struct { |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | /// Decrypt multiple blocks in parallel, each their own round key. | 126 | /// Decrypt multiple blocks in parallel, each their own round key. |
| 127 | pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { | 127 | pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { |
| 128 | comptime var i = 0; | 128 | comptime var i = 0; |
| 129 | var out: [count]Block = undefined; | 129 | var out: [count]Block = undefined; |
| 130 | inline while (i < count) : (i += 1) { | 130 | inline while (i < count) : (i += 1) { |
| ... | @@ -134,7 +134,7 @@ pub const Block = struct { | ... | @@ -134,7 +134,7 @@ pub const Block = struct { |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | /// Encrypt multiple blocks in parallel with the same round key. | 136 | /// Encrypt multiple blocks in parallel with the same round key. |
| 137 | pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | 137 | pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { |
| 138 | comptime var i = 0; | 138 | comptime var i = 0; |
| 139 | var out: [count]Block = undefined; | 139 | var out: [count]Block = undefined; |
| 140 | inline while (i < count) : (i += 1) { | 140 | inline while (i < count) : (i += 1) { |
| ... | @@ -144,7 +144,7 @@ pub const Block = struct { | ... | @@ -144,7 +144,7 @@ pub const Block = struct { |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | /// Decrypt multiple blocks in parallel with the same round key. | 146 | /// Decrypt multiple blocks in parallel with the same round key. |
| 147 | pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | 147 | pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { |
| 148 | comptime var i = 0; | 148 | comptime var i = 0; |
| 149 | var out: [count]Block = undefined; | 149 | var out: [count]Block = undefined; |
| 150 | inline while (i < count) : (i += 1) { | 150 | inline while (i < count) : (i += 1) { |
| ... | @@ -154,7 +154,7 @@ pub const Block = struct { | ... | @@ -154,7 +154,7 @@ pub const Block = struct { |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | /// Encrypt multiple blocks in parallel with the same last round key. | 156 | /// Encrypt multiple blocks in parallel with the same last round key. |
| 157 | pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | 157 | pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { |
| 158 | comptime var i = 0; | 158 | comptime var i = 0; |
| 159 | var out: [count]Block = undefined; | 159 | var out: [count]Block = undefined; |
| 160 | inline while (i < count) : (i += 1) { | 160 | inline while (i < count) : (i += 1) { |
| ... | @@ -164,7 +164,7 @@ pub const Block = struct { | ... | @@ -164,7 +164,7 @@ pub const Block = struct { |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | /// Decrypt multiple blocks in parallel with the same last round key. | 166 | /// Decrypt multiple blocks in parallel with the same last round key. |
| 167 | pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | 167 | pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { |
| 168 | comptime var i = 0; | 168 | comptime var i = 0; |
| 169 | var out: [count]Block = undefined; | 169 | var out: [count]Block = undefined; |
| 170 | inline while (i < count) : (i += 1) { | 170 | inline while (i < count) : (i += 1) { |
lib/std/crypto/aes/armcrypto.zig+16-16| ... | @@ -19,18 +19,18 @@ pub const Block = struct { | ... | @@ -19,18 +19,18 @@ pub const Block = struct { |
| 19 | repr: BlockVec, | 19 | repr: BlockVec, |
| 20 | 20 | ||
| 21 | /// Convert a byte sequence into an internal representation. | 21 | /// Convert a byte sequence into an internal representation. |
| 22 | pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { | 22 | pub inline fn fromBytes(bytes: *const [16]u8) Block { |
| 23 | const repr = mem.bytesToValue(BlockVec, bytes); | 23 | const repr = mem.bytesToValue(BlockVec, bytes); |
| 24 | return Block{ .repr = repr }; | 24 | return Block{ .repr = repr }; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | /// Convert the internal representation of a block into a byte sequence. | 27 | /// Convert the internal representation of a block into a byte sequence. |
| 28 | pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { | 28 | pub inline fn toBytes(block: Block) [16]u8 { |
| 29 | return mem.toBytes(block.repr); | 29 | return mem.toBytes(block.repr); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | /// XOR the block with a byte sequence. | 32 | /// XOR the block with a byte sequence. |
| 33 | pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { | 33 | pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { |
| 34 | const x = block.repr ^ fromBytes(bytes).repr; | 34 | const x = block.repr ^ fromBytes(bytes).repr; |
| 35 | return mem.toBytes(x); | 35 | return mem.toBytes(x); |
| 36 | } | 36 | } |
| ... | @@ -38,7 +38,7 @@ pub const Block = struct { | ... | @@ -38,7 +38,7 @@ pub const Block = struct { |
| 38 | const zero = Vector(2, u64){ 0, 0 }; | 38 | const zero = Vector(2, u64){ 0, 0 }; |
| 39 | 39 | ||
| 40 | /// Encrypt a block with a round key. | 40 | /// Encrypt a block with a round key. |
| 41 | pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { | 41 | pub inline fn encrypt(block: Block, round_key: Block) Block { |
| 42 | return Block{ | 42 | return Block{ |
| 43 | .repr = asm ( | 43 | .repr = asm ( |
| 44 | \\ mov %[out].16b, %[in].16b | 44 | \\ mov %[out].16b, %[in].16b |
| ... | @@ -54,7 +54,7 @@ pub const Block = struct { | ... | @@ -54,7 +54,7 @@ pub const Block = struct { |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | /// Encrypt a block with the last round key. | 56 | /// Encrypt a block with the last round key. |
| 57 | pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { | 57 | pub inline fn encryptLast(block: Block, round_key: Block) Block { |
| 58 | return Block{ | 58 | return Block{ |
| 59 | .repr = asm ( | 59 | .repr = asm ( |
| 60 | \\ mov %[out].16b, %[in].16b | 60 | \\ mov %[out].16b, %[in].16b |
| ... | @@ -69,7 +69,7 @@ pub const Block = struct { | ... | @@ -69,7 +69,7 @@ pub const Block = struct { |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | /// Decrypt a block with a round key. | 71 | /// Decrypt a block with a round key. |
| 72 | pub fn decrypt(block: Block, inv_round_key: Block) callconv(.Inline) Block { | 72 | pub inline fn decrypt(block: Block, inv_round_key: Block) Block { |
| 73 | return Block{ | 73 | return Block{ |
| 74 | .repr = asm ( | 74 | .repr = asm ( |
| 75 | \\ mov %[out].16b, %[in].16b | 75 | \\ mov %[out].16b, %[in].16b |
| ... | @@ -85,7 +85,7 @@ pub const Block = struct { | ... | @@ -85,7 +85,7 @@ pub const Block = struct { |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | /// Decrypt a block with the last round key. | 87 | /// Decrypt a block with the last round key. |
| 88 | pub fn decryptLast(block: Block, inv_round_key: Block) callconv(.Inline) Block { | 88 | pub inline fn decryptLast(block: Block, inv_round_key: Block) Block { |
| 89 | return Block{ | 89 | return Block{ |
| 90 | .repr = asm ( | 90 | .repr = asm ( |
| 91 | \\ mov %[out].16b, %[in].16b | 91 | \\ mov %[out].16b, %[in].16b |
| ... | @@ -100,17 +100,17 @@ pub const Block = struct { | ... | @@ -100,17 +100,17 @@ pub const Block = struct { |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | /// Apply the bitwise XOR operation to the content of two blocks. | 102 | /// Apply the bitwise XOR operation to the content of two blocks. |
| 103 | pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 103 | pub inline fn xorBlocks(block1: Block, block2: Block) Block { |
| 104 | return Block{ .repr = block1.repr ^ block2.repr }; | 104 | return Block{ .repr = block1.repr ^ block2.repr }; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | /// Apply the bitwise AND operation to the content of two blocks. | 107 | /// Apply the bitwise AND operation to the content of two blocks. |
| 108 | pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 108 | pub inline fn andBlocks(block1: Block, block2: Block) Block { |
| 109 | return Block{ .repr = block1.repr & block2.repr }; | 109 | return Block{ .repr = block1.repr & block2.repr }; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | /// Apply the bitwise OR operation to the content of two blocks. | 112 | /// Apply the bitwise OR operation to the content of two blocks. |
| 113 | pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 113 | pub inline fn orBlocks(block1: Block, block2: Block) Block { |
| 114 | return Block{ .repr = block1.repr | block2.repr }; | 114 | return Block{ .repr = block1.repr | block2.repr }; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| ... | @@ -120,7 +120,7 @@ pub const Block = struct { | ... | @@ -120,7 +120,7 @@ pub const Block = struct { |
| 120 | pub const optimal_parallel_blocks = 8; | 120 | pub const optimal_parallel_blocks = 8; |
| 121 | 121 | ||
| 122 | /// Encrypt multiple blocks in parallel, each their own round key. | 122 | /// Encrypt multiple blocks in parallel, each their own round key. |
| 123 | pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { | 123 | pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { |
| 124 | comptime var i = 0; | 124 | comptime var i = 0; |
| 125 | var out: [count]Block = undefined; | 125 | var out: [count]Block = undefined; |
| 126 | inline while (i < count) : (i += 1) { | 126 | inline while (i < count) : (i += 1) { |
| ... | @@ -130,7 +130,7 @@ pub const Block = struct { | ... | @@ -130,7 +130,7 @@ pub const Block = struct { |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | /// Decrypt multiple blocks in parallel, each their own round key. | 132 | /// Decrypt multiple blocks in parallel, each their own round key. |
| 133 | pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { | 133 | pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { |
| 134 | comptime var i = 0; | 134 | comptime var i = 0; |
| 135 | var out: [count]Block = undefined; | 135 | var out: [count]Block = undefined; |
| 136 | inline while (i < count) : (i += 1) { | 136 | inline while (i < count) : (i += 1) { |
| ... | @@ -140,7 +140,7 @@ pub const Block = struct { | ... | @@ -140,7 +140,7 @@ pub const Block = struct { |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /// Encrypt multiple blocks in parallel with the same round key. | 142 | /// Encrypt multiple blocks in parallel with the same round key. |
| 143 | pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | 143 | pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { |
| 144 | comptime var i = 0; | 144 | comptime var i = 0; |
| 145 | var out: [count]Block = undefined; | 145 | var out: [count]Block = undefined; |
| 146 | inline while (i < count) : (i += 1) { | 146 | inline while (i < count) : (i += 1) { |
| ... | @@ -150,7 +150,7 @@ pub const Block = struct { | ... | @@ -150,7 +150,7 @@ pub const Block = struct { |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | /// Decrypt multiple blocks in parallel with the same round key. | 152 | /// Decrypt multiple blocks in parallel with the same round key. |
| 153 | pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | 153 | pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { |
| 154 | comptime var i = 0; | 154 | comptime var i = 0; |
| 155 | var out: [count]Block = undefined; | 155 | var out: [count]Block = undefined; |
| 156 | inline while (i < count) : (i += 1) { | 156 | inline while (i < count) : (i += 1) { |
| ... | @@ -160,7 +160,7 @@ pub const Block = struct { | ... | @@ -160,7 +160,7 @@ pub const Block = struct { |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | /// Encrypt multiple blocks in parallel with the same last round key. | 162 | /// Encrypt multiple blocks in parallel with the same last round key. |
| 163 | pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | 163 | pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { |
| 164 | comptime var i = 0; | 164 | comptime var i = 0; |
| 165 | var out: [count]Block = undefined; | 165 | var out: [count]Block = undefined; |
| 166 | inline while (i < count) : (i += 1) { | 166 | inline while (i < count) : (i += 1) { |
| ... | @@ -170,7 +170,7 @@ pub const Block = struct { | ... | @@ -170,7 +170,7 @@ pub const Block = struct { |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | /// Decrypt multiple blocks in parallel with the same last round key. | 172 | /// Decrypt multiple blocks in parallel with the same last round key. |
| 173 | pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | 173 | pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { |
| 174 | comptime var i = 0; | 174 | comptime var i = 0; |
| 175 | var out: [count]Block = undefined; | 175 | var out: [count]Block = undefined; |
| 176 | inline while (i < count) : (i += 1) { | 176 | inline while (i < count) : (i += 1) { |
lib/std/crypto/aes/soft.zig+10-10| ... | @@ -18,7 +18,7 @@ pub const Block = struct { | ... | @@ -18,7 +18,7 @@ pub const Block = struct { |
| 18 | repr: BlockVec align(16), | 18 | repr: BlockVec align(16), |
| 19 | 19 | ||
| 20 | /// Convert a byte sequence into an internal representation. | 20 | /// Convert a byte sequence into an internal representation. |
| 21 | pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { | 21 | pub inline fn fromBytes(bytes: *const [16]u8) Block { |
| 22 | const s0 = mem.readIntBig(u32, bytes[0..4]); | 22 | const s0 = mem.readIntBig(u32, bytes[0..4]); |
| 23 | const s1 = mem.readIntBig(u32, bytes[4..8]); | 23 | const s1 = mem.readIntBig(u32, bytes[4..8]); |
| 24 | const s2 = mem.readIntBig(u32, bytes[8..12]); | 24 | const s2 = mem.readIntBig(u32, bytes[8..12]); |
| ... | @@ -27,7 +27,7 @@ pub const Block = struct { | ... | @@ -27,7 +27,7 @@ pub const Block = struct { |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | /// Convert the internal representation of a block into a byte sequence. | 29 | /// Convert the internal representation of a block into a byte sequence. |
| 30 | pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { | 30 | pub inline fn toBytes(block: Block) [16]u8 { |
| 31 | var bytes: [16]u8 = undefined; | 31 | var bytes: [16]u8 = undefined; |
| 32 | mem.writeIntBig(u32, bytes[0..4], block.repr[0]); | 32 | mem.writeIntBig(u32, bytes[0..4], block.repr[0]); |
| 33 | mem.writeIntBig(u32, bytes[4..8], block.repr[1]); | 33 | mem.writeIntBig(u32, bytes[4..8], block.repr[1]); |
| ... | @@ -37,7 +37,7 @@ pub const Block = struct { | ... | @@ -37,7 +37,7 @@ pub const Block = struct { |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | /// XOR the block with a byte sequence. | 39 | /// XOR the block with a byte sequence. |
| 40 | pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { | 40 | pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { |
| 41 | const block_bytes = block.toBytes(); | 41 | const block_bytes = block.toBytes(); |
| 42 | var x: [16]u8 = undefined; | 42 | var x: [16]u8 = undefined; |
| 43 | comptime var i: usize = 0; | 43 | comptime var i: usize = 0; |
| ... | @@ -48,7 +48,7 @@ pub const Block = struct { | ... | @@ -48,7 +48,7 @@ pub const Block = struct { |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | /// Encrypt a block with a round key. | 50 | /// Encrypt a block with a round key. |
| 51 | pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { | 51 | pub inline fn encrypt(block: Block, round_key: Block) Block { |
| 52 | const src = &block.repr; | 52 | const src = &block.repr; |
| 53 | 53 | ||
| 54 | const s0 = block.repr[0]; | 54 | const s0 = block.repr[0]; |
| ... | @@ -65,7 +65,7 @@ pub const Block = struct { | ... | @@ -65,7 +65,7 @@ pub const Block = struct { |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | /// Encrypt a block with the last round key. | 67 | /// Encrypt a block with the last round key. |
| 68 | pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { | 68 | pub inline fn encryptLast(block: Block, round_key: Block) Block { |
| 69 | const src = &block.repr; | 69 | const src = &block.repr; |
| 70 | 70 | ||
| 71 | const t0 = block.repr[0]; | 71 | const t0 = block.repr[0]; |
| ... | @@ -87,7 +87,7 @@ pub const Block = struct { | ... | @@ -87,7 +87,7 @@ pub const Block = struct { |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | /// Decrypt a block with a round key. | 89 | /// Decrypt a block with a round key. |
| 90 | pub fn decrypt(block: Block, round_key: Block) callconv(.Inline) Block { | 90 | pub inline fn decrypt(block: Block, round_key: Block) Block { |
| 91 | const src = &block.repr; | 91 | const src = &block.repr; |
| 92 | 92 | ||
| 93 | const s0 = block.repr[0]; | 93 | const s0 = block.repr[0]; |
| ... | @@ -104,7 +104,7 @@ pub const Block = struct { | ... | @@ -104,7 +104,7 @@ pub const Block = struct { |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | /// Decrypt a block with the last round key. | 106 | /// Decrypt a block with the last round key. |
| 107 | pub fn decryptLast(block: Block, round_key: Block) callconv(.Inline) Block { | 107 | pub inline fn decryptLast(block: Block, round_key: Block) Block { |
| 108 | const src = &block.repr; | 108 | const src = &block.repr; |
| 109 | 109 | ||
| 110 | const t0 = block.repr[0]; | 110 | const t0 = block.repr[0]; |
| ... | @@ -126,7 +126,7 @@ pub const Block = struct { | ... | @@ -126,7 +126,7 @@ pub const Block = struct { |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | /// Apply the bitwise XOR operation to the content of two blocks. | 128 | /// Apply the bitwise XOR operation to the content of two blocks. |
| 129 | pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 129 | pub inline fn xorBlocks(block1: Block, block2: Block) Block { |
| 130 | var x: BlockVec = undefined; | 130 | var x: BlockVec = undefined; |
| 131 | comptime var i = 0; | 131 | comptime var i = 0; |
| 132 | inline while (i < 4) : (i += 1) { | 132 | inline while (i < 4) : (i += 1) { |
| ... | @@ -136,7 +136,7 @@ pub const Block = struct { | ... | @@ -136,7 +136,7 @@ pub const Block = struct { |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | /// Apply the bitwise AND operation to the content of two blocks. | 138 | /// Apply the bitwise AND operation to the content of two blocks. |
| 139 | pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 139 | pub inline fn andBlocks(block1: Block, block2: Block) Block { |
| 140 | var x: BlockVec = undefined; | 140 | var x: BlockVec = undefined; |
| 141 | comptime var i = 0; | 141 | comptime var i = 0; |
| 142 | inline while (i < 4) : (i += 1) { | 142 | inline while (i < 4) : (i += 1) { |
| ... | @@ -146,7 +146,7 @@ pub const Block = struct { | ... | @@ -146,7 +146,7 @@ pub const Block = struct { |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | /// Apply the bitwise OR operation to the content of two blocks. | 148 | /// Apply the bitwise OR operation to the content of two blocks. |
| 149 | pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | 149 | pub inline fn orBlocks(block1: Block, block2: Block) Block { |
| 150 | var x: BlockVec = undefined; | 150 | var x: BlockVec = undefined; |
| 151 | comptime var i = 0; | 151 | comptime var i = 0; |
| 152 | inline while (i < 4) : (i += 1) { | 152 | inline while (i < 4) : (i += 1) { |
lib/std/crypto/aes_ocb.zig+3-3| ... | @@ -33,7 +33,7 @@ fn AesOcb(comptime Aes: anytype) type { | ... | @@ -33,7 +33,7 @@ fn AesOcb(comptime Aes: anytype) type { |
| 33 | table: [56]Block align(16) = undefined, | 33 | table: [56]Block align(16) = undefined, |
| 34 | upto: usize, | 34 | upto: usize, |
| 35 | 35 | ||
| 36 | fn double(l: Block) callconv(.Inline) Block { | 36 | inline fn double(l: Block) Block { |
| 37 | const l_ = mem.readIntBig(u128, &l); | 37 | const l_ = mem.readIntBig(u128, &l); |
| 38 | const l_2 = (l_ << 1) ^ (0x87 & -%(l_ >> 127)); | 38 | const l_2 = (l_ << 1) ^ (0x87 & -%(l_ >> 127)); |
| 39 | var l2: Block = undefined; | 39 | var l2: Block = undefined; |
| ... | @@ -245,7 +245,7 @@ fn AesOcb(comptime Aes: anytype) type { | ... | @@ -245,7 +245,7 @@ fn AesOcb(comptime Aes: anytype) type { |
| 245 | }; | 245 | }; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | fn xorBlocks(x: Block, y: Block) callconv(.Inline) Block { | 248 | inline fn xorBlocks(x: Block, y: Block) Block { |
| 249 | var z: Block = x; | 249 | var z: Block = x; |
| 250 | for (z) |*v, i| { | 250 | for (z) |*v, i| { |
| 251 | v.* = x[i] ^ y[i]; | 251 | v.* = x[i] ^ y[i]; |
| ... | @@ -253,7 +253,7 @@ fn xorBlocks(x: Block, y: Block) callconv(.Inline) Block { | ... | @@ -253,7 +253,7 @@ fn xorBlocks(x: Block, y: Block) callconv(.Inline) Block { |
| 253 | return z; | 253 | return z; |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | fn xorWith(x: *Block, y: Block) callconv(.Inline) void { | 256 | inline fn xorWith(x: *Block, y: Block) void { |
| 257 | for (x) |*v, i| { | 257 | for (x) |*v, i| { |
| 258 | v.* ^= y[i]; | 258 | v.* ^= y[i]; |
| 259 | } | 259 | } |
lib/std/crypto/blake3.zig+3-3| ... | @@ -66,7 +66,7 @@ const CompressVectorized = struct { | ... | @@ -66,7 +66,7 @@ const CompressVectorized = struct { |
| 66 | const Lane = Vector(4, u32); | 66 | const Lane = Vector(4, u32); |
| 67 | const Rows = [4]Lane; | 67 | const Rows = [4]Lane; |
| 68 | 68 | ||
| 69 | fn g(comptime even: bool, rows: *Rows, m: Lane) callconv(.Inline) void { | 69 | inline fn g(comptime even: bool, rows: *Rows, m: Lane) void { |
| 70 | rows[0] +%= rows[1] +% m; | 70 | rows[0] +%= rows[1] +% m; |
| 71 | rows[3] ^= rows[0]; | 71 | rows[3] ^= rows[0]; |
| 72 | rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16); | 72 | rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16); |
| ... | @@ -75,13 +75,13 @@ const CompressVectorized = struct { | ... | @@ -75,13 +75,13 @@ const CompressVectorized = struct { |
| 75 | rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12); | 75 | rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | fn diagonalize(rows: *Rows) callconv(.Inline) void { | 78 | inline fn diagonalize(rows: *Rows) void { |
| 79 | rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 }); | 79 | rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 }); |
| 80 | rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 }); | 80 | rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 }); |
| 81 | rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 }); | 81 | rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 }); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | fn undiagonalize(rows: *Rows) callconv(.Inline) void { | 84 | inline fn undiagonalize(rows: *Rows) void { |
| 85 | rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 }); | 85 | rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 }); |
| 86 | rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 }); | 86 | rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 }); |
| 87 | rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 3, 0, 1, 2 }); | 87 | rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 3, 0, 1, 2 }); |
lib/std/crypto/chacha20.zig+6-6| ... | @@ -102,7 +102,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize) type { | ... | @@ -102,7 +102,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize) type { |
| 102 | }; | 102 | }; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void { | 105 | inline fn chacha20Core(x: *BlockVec, input: BlockVec) void { |
| 106 | x.* = input; | 106 | x.* = input; |
| 107 | 107 | ||
| 108 | var r: usize = 0; | 108 | var r: usize = 0; |
| ... | @@ -147,7 +147,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize) type { | ... | @@ -147,7 +147,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize) type { |
| 147 | } | 147 | } |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void { | 150 | inline fn hashToBytes(out: *[64]u8, x: BlockVec) void { |
| 151 | var i: usize = 0; | 151 | var i: usize = 0; |
| 152 | while (i < 4) : (i += 1) { | 152 | while (i < 4) : (i += 1) { |
| 153 | mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]); | 153 | mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]); |
| ... | @@ -157,7 +157,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize) type { | ... | @@ -157,7 +157,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize) type { |
| 157 | } | 157 | } |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void { | 160 | inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void { |
| 161 | x[0] +%= ctx[0]; | 161 | x[0] +%= ctx[0]; |
| 162 | x[1] +%= ctx[1]; | 162 | x[1] +%= ctx[1]; |
| 163 | x[2] +%= ctx[2]; | 163 | x[2] +%= ctx[2]; |
| ... | @@ -259,7 +259,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type { | ... | @@ -259,7 +259,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type { |
| 259 | }; | 259 | }; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void { | 262 | inline fn chacha20Core(x: *BlockVec, input: BlockVec) void { |
| 263 | x.* = input; | 263 | x.* = input; |
| 264 | 264 | ||
| 265 | const rounds = comptime [_]QuarterRound{ | 265 | const rounds = comptime [_]QuarterRound{ |
| ... | @@ -288,7 +288,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type { | ... | @@ -288,7 +288,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type { |
| 288 | } | 288 | } |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void { | 291 | inline fn hashToBytes(out: *[64]u8, x: BlockVec) void { |
| 292 | var i: usize = 0; | 292 | var i: usize = 0; |
| 293 | while (i < 4) : (i += 1) { | 293 | while (i < 4) : (i += 1) { |
| 294 | mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0]); | 294 | mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0]); |
| ... | @@ -298,7 +298,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type { | ... | @@ -298,7 +298,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type { |
| 298 | } | 298 | } |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void { | 301 | inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void { |
| 302 | var i: usize = 0; | 302 | var i: usize = 0; |
| 303 | while (i < 16) : (i += 1) { | 303 | while (i < 16) : (i += 1) { |
| 304 | x[i] +%= ctx[i]; | 304 | x[i] +%= ctx[i]; |
lib/std/crypto/ghash.zig+2-2| ... | @@ -95,7 +95,7 @@ pub const Ghash = struct { | ... | @@ -95,7 +95,7 @@ pub const Ghash = struct { |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | fn clmul_pclmul(x: u64, y: u64) callconv(.Inline) u64 { | 98 | inline fn clmul_pclmul(x: u64, y: u64) u64 { |
| 99 | const Vector = std.meta.Vector; | 99 | const Vector = std.meta.Vector; |
| 100 | const product = asm ( | 100 | const product = asm ( |
| 101 | \\ vpclmulqdq $0x00, %[x], %[y], %[out] | 101 | \\ vpclmulqdq $0x00, %[x], %[y], %[out] |
| ... | @@ -106,7 +106,7 @@ pub const Ghash = struct { | ... | @@ -106,7 +106,7 @@ pub const Ghash = struct { |
| 106 | return product[0]; | 106 | return product[0]; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | fn clmul_pmull(x: u64, y: u64) callconv(.Inline) u64 { | 109 | inline fn clmul_pmull(x: u64, y: u64) u64 { |
| 110 | const Vector = std.meta.Vector; | 110 | const Vector = std.meta.Vector; |
| 111 | const product = asm ( | 111 | const product = asm ( |
| 112 | \\ pmull %[out].1q, %[x].1d, %[y].1d | 112 | \\ pmull %[out].1q, %[x].1d, %[y].1d |
lib/std/crypto/gimli.zig+2-2| ... | @@ -49,7 +49,7 @@ pub const State = struct { | ... | @@ -49,7 +49,7 @@ pub const State = struct { |
| 49 | return mem.asBytes(&self.data); | 49 | return mem.asBytes(&self.data); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | fn endianSwap(self: *Self) callconv(.Inline) void { | 52 | inline fn endianSwap(self: *Self) void { |
| 53 | for (self.data) |*w| { | 53 | for (self.data) |*w| { |
| 54 | w.* = mem.littleToNative(u32, w.*); | 54 | w.* = mem.littleToNative(u32, w.*); |
| 55 | } | 55 | } |
| ... | @@ -117,7 +117,7 @@ pub const State = struct { | ... | @@ -117,7 +117,7 @@ pub const State = struct { |
| 117 | 117 | ||
| 118 | const Lane = Vector(4, u32); | 118 | const Lane = Vector(4, u32); |
| 119 | 119 | ||
| 120 | fn shift(x: Lane, comptime n: comptime_int) callconv(.Inline) Lane { | 120 | inline fn shift(x: Lane, comptime n: comptime_int) Lane { |
| 121 | return x << @splat(4, @as(u5, n)); | 121 | return x << @splat(4, @as(u5, n)); |
| 122 | } | 122 | } |
| 123 | 123 |
lib/std/crypto/pcurves/p256/p256_64.zig+4-4| ... | @@ -35,7 +35,7 @@ pub const Limbs = [4]u64; | ... | @@ -35,7 +35,7 @@ pub const Limbs = [4]u64; |
| 35 | /// Output Bounds: | 35 | /// Output Bounds: |
| 36 | /// out1: [0x0 ~> 0xffffffffffffffff] | 36 | /// out1: [0x0 ~> 0xffffffffffffffff] |
| 37 | /// out2: [0x0 ~> 0x1] | 37 | /// out2: [0x0 ~> 0x1] |
| 38 | fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { | 38 | inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { |
| 39 | @setRuntimeSafety(mode == .Debug); | 39 | @setRuntimeSafety(mode == .Debug); |
| 40 | 40 | ||
| 41 | var t: u64 = undefined; | 41 | var t: u64 = undefined; |
| ... | @@ -56,7 +56,7 @@ fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv( | ... | @@ -56,7 +56,7 @@ fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv( |
| 56 | /// Output Bounds: | 56 | /// Output Bounds: |
| 57 | /// out1: [0x0 ~> 0xffffffffffffffff] | 57 | /// out1: [0x0 ~> 0xffffffffffffffff] |
| 58 | /// out2: [0x0 ~> 0x1] | 58 | /// out2: [0x0 ~> 0x1] |
| 59 | fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { | 59 | inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { |
| 60 | @setRuntimeSafety(mode == .Debug); | 60 | @setRuntimeSafety(mode == .Debug); |
| 61 | 61 | ||
| 62 | var t: u64 = undefined; | 62 | var t: u64 = undefined; |
| ... | @@ -76,7 +76,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv | ... | @@ -76,7 +76,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv |
| 76 | /// Output Bounds: | 76 | /// Output Bounds: |
| 77 | /// out1: [0x0 ~> 0xffffffffffffffff] | 77 | /// out1: [0x0 ~> 0xffffffffffffffff] |
| 78 | /// out2: [0x0 ~> 0xffffffffffffffff] | 78 | /// out2: [0x0 ~> 0xffffffffffffffff] |
| 79 | fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void { | 79 | inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { |
| 80 | @setRuntimeSafety(mode == .Debug); | 80 | @setRuntimeSafety(mode == .Debug); |
| 81 | 81 | ||
| 82 | const x = @as(u128, arg1) * @as(u128, arg2); | 82 | const x = @as(u128, arg1) * @as(u128, arg2); |
| ... | @@ -94,7 +94,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void | ... | @@ -94,7 +94,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void |
| 94 | /// arg3: [0x0 ~> 0xffffffffffffffff] | 94 | /// arg3: [0x0 ~> 0xffffffffffffffff] |
| 95 | /// Output Bounds: | 95 | /// Output Bounds: |
| 96 | /// out1: [0x0 ~> 0xffffffffffffffff] | 96 | /// out1: [0x0 ~> 0xffffffffffffffff] |
| 97 | fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { | 97 | inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { |
| 98 | @setRuntimeSafety(mode == .Debug); | 98 | @setRuntimeSafety(mode == .Debug); |
| 99 | 99 | ||
| 100 | const mask = 0 -% @as(u64, arg1); | 100 | const mask = 0 -% @as(u64, arg1); |
lib/std/crypto/pcurves/p256/p256_scalar_64.zig+4-4| ... | @@ -35,7 +35,7 @@ pub const Limbs = [4]u64; | ... | @@ -35,7 +35,7 @@ pub const Limbs = [4]u64; |
| 35 | /// Output Bounds: | 35 | /// Output Bounds: |
| 36 | /// out1: [0x0 ~> 0xffffffffffffffff] | 36 | /// out1: [0x0 ~> 0xffffffffffffffff] |
| 37 | /// out2: [0x0 ~> 0x1] | 37 | /// out2: [0x0 ~> 0x1] |
| 38 | fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { | 38 | inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { |
| 39 | @setRuntimeSafety(mode == .Debug); | 39 | @setRuntimeSafety(mode == .Debug); |
| 40 | 40 | ||
| 41 | var t: u64 = undefined; | 41 | var t: u64 = undefined; |
| ... | @@ -56,7 +56,7 @@ fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv( | ... | @@ -56,7 +56,7 @@ fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv( |
| 56 | /// Output Bounds: | 56 | /// Output Bounds: |
| 57 | /// out1: [0x0 ~> 0xffffffffffffffff] | 57 | /// out1: [0x0 ~> 0xffffffffffffffff] |
| 58 | /// out2: [0x0 ~> 0x1] | 58 | /// out2: [0x0 ~> 0x1] |
| 59 | fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { | 59 | inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { |
| 60 | @setRuntimeSafety(mode == .Debug); | 60 | @setRuntimeSafety(mode == .Debug); |
| 61 | 61 | ||
| 62 | var t: u64 = undefined; | 62 | var t: u64 = undefined; |
| ... | @@ -76,7 +76,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv | ... | @@ -76,7 +76,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv |
| 76 | /// Output Bounds: | 76 | /// Output Bounds: |
| 77 | /// out1: [0x0 ~> 0xffffffffffffffff] | 77 | /// out1: [0x0 ~> 0xffffffffffffffff] |
| 78 | /// out2: [0x0 ~> 0xffffffffffffffff] | 78 | /// out2: [0x0 ~> 0xffffffffffffffff] |
| 79 | fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void { | 79 | inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { |
| 80 | @setRuntimeSafety(mode == .Debug); | 80 | @setRuntimeSafety(mode == .Debug); |
| 81 | 81 | ||
| 82 | const x = @as(u128, arg1) * @as(u128, arg2); | 82 | const x = @as(u128, arg1) * @as(u128, arg2); |
| ... | @@ -94,7 +94,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void | ... | @@ -94,7 +94,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void |
| 94 | /// arg3: [0x0 ~> 0xffffffffffffffff] | 94 | /// arg3: [0x0 ~> 0xffffffffffffffff] |
| 95 | /// Output Bounds: | 95 | /// Output Bounds: |
| 96 | /// out1: [0x0 ~> 0xffffffffffffffff] | 96 | /// out1: [0x0 ~> 0xffffffffffffffff] |
| 97 | fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void { | 97 | inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { |
| 98 | @setRuntimeSafety(mode == .Debug); | 98 | @setRuntimeSafety(mode == .Debug); |
| 99 | 99 | ||
| 100 | const mask = 0 -% @as(u64, arg1); | 100 | const mask = 0 -% @as(u64, arg1); |
lib/std/crypto/salsa20.zig+3-3| ... | @@ -41,7 +41,7 @@ const Salsa20VecImpl = struct { | ... | @@ -41,7 +41,7 @@ const Salsa20VecImpl = struct { |
| 41 | }; | 41 | }; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) callconv(.Inline) void { | 44 | inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) void { |
| 45 | const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] }; | 45 | const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] }; |
| 46 | const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] }; | 46 | const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] }; |
| 47 | const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] }; | 47 | const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] }; |
| ... | @@ -215,7 +215,7 @@ const Salsa20NonVecImpl = struct { | ... | @@ -215,7 +215,7 @@ const Salsa20NonVecImpl = struct { |
| 215 | d: u6, | 215 | d: u6, |
| 216 | }; | 216 | }; |
| 217 | 217 | ||
| 218 | fn Rp(a: usize, b: usize, c: usize, d: u6) callconv(.Inline) QuarterRound { | 218 | inline fn Rp(a: usize, b: usize, c: usize, d: u6) QuarterRound { |
| 219 | return QuarterRound{ | 219 | return QuarterRound{ |
| 220 | .a = a, | 220 | .a = a, |
| 221 | .b = b, | 221 | .b = b, |
| ... | @@ -224,7 +224,7 @@ const Salsa20NonVecImpl = struct { | ... | @@ -224,7 +224,7 @@ const Salsa20NonVecImpl = struct { |
| 224 | }; | 224 | }; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) callconv(.Inline) void { | 227 | inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) void { |
| 228 | const arx_steps = comptime [_]QuarterRound{ | 228 | const arx_steps = comptime [_]QuarterRound{ |
| 229 | Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18), | 229 | Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18), |
| 230 | Rp(9, 5, 1, 7), Rp(13, 9, 5, 9), Rp(1, 13, 9, 13), Rp(5, 1, 13, 18), | 230 | Rp(9, 5, 1, 7), Rp(13, 9, 5, 9), Rp(1, 13, 9, 13), Rp(5, 1, 13, 18), |
lib/std/elf.zig+8-8| ... | @@ -721,10 +721,10 @@ pub const Elf32_Rel = extern struct { | ... | @@ -721,10 +721,10 @@ pub const Elf32_Rel = extern struct { |
| 721 | r_offset: Elf32_Addr, | 721 | r_offset: Elf32_Addr, |
| 722 | r_info: Elf32_Word, | 722 | r_info: Elf32_Word, |
| 723 | 723 | ||
| 724 | pub fn r_sym(self: @This()) callconv(.Inline) u24 { | 724 | pub inline fn r_sym(self: @This()) u24 { |
| 725 | return @truncate(u24, self.r_info >> 8); | 725 | return @truncate(u24, self.r_info >> 8); |
| 726 | } | 726 | } |
| 727 | pub fn r_type(self: @This()) callconv(.Inline) u8 { | 727 | pub inline fn r_type(self: @This()) u8 { |
| 728 | return @truncate(u8, self.r_info & 0xff); | 728 | return @truncate(u8, self.r_info & 0xff); |
| 729 | } | 729 | } |
| 730 | }; | 730 | }; |
| ... | @@ -732,10 +732,10 @@ pub const Elf64_Rel = extern struct { | ... | @@ -732,10 +732,10 @@ pub const Elf64_Rel = extern struct { |
| 732 | r_offset: Elf64_Addr, | 732 | r_offset: Elf64_Addr, |
| 733 | r_info: Elf64_Xword, | 733 | r_info: Elf64_Xword, |
| 734 | 734 | ||
| 735 | pub fn r_sym(self: @This()) callconv(.Inline) u32 { | 735 | pub inline fn r_sym(self: @This()) u32 { |
| 736 | return @truncate(u32, self.r_info >> 32); | 736 | return @truncate(u32, self.r_info >> 32); |
| 737 | } | 737 | } |
| 738 | pub fn r_type(self: @This()) callconv(.Inline) u32 { | 738 | pub inline fn r_type(self: @This()) u32 { |
| 739 | return @truncate(u32, self.r_info & 0xffffffff); | 739 | return @truncate(u32, self.r_info & 0xffffffff); |
| 740 | } | 740 | } |
| 741 | }; | 741 | }; |
| ... | @@ -744,10 +744,10 @@ pub const Elf32_Rela = extern struct { | ... | @@ -744,10 +744,10 @@ pub const Elf32_Rela = extern struct { |
| 744 | r_info: Elf32_Word, | 744 | r_info: Elf32_Word, |
| 745 | r_addend: Elf32_Sword, | 745 | r_addend: Elf32_Sword, |
| 746 | 746 | ||
| 747 | pub fn r_sym(self: @This()) callconv(.Inline) u24 { | 747 | pub inline fn r_sym(self: @This()) u24 { |
| 748 | return @truncate(u24, self.r_info >> 8); | 748 | return @truncate(u24, self.r_info >> 8); |
| 749 | } | 749 | } |
| 750 | pub fn r_type(self: @This()) callconv(.Inline) u8 { | 750 | pub inline fn r_type(self: @This()) u8 { |
| 751 | return @truncate(u8, self.r_info & 0xff); | 751 | return @truncate(u8, self.r_info & 0xff); |
| 752 | } | 752 | } |
| 753 | }; | 753 | }; |
| ... | @@ -756,10 +756,10 @@ pub const Elf64_Rela = extern struct { | ... | @@ -756,10 +756,10 @@ pub const Elf64_Rela = extern struct { |
| 756 | r_info: Elf64_Xword, | 756 | r_info: Elf64_Xword, |
| 757 | r_addend: Elf64_Sxword, | 757 | r_addend: Elf64_Sxword, |
| 758 | 758 | ||
| 759 | pub fn r_sym(self: @This()) callconv(.Inline) u32 { | 759 | pub inline fn r_sym(self: @This()) u32 { |
| 760 | return @truncate(u32, self.r_info >> 32); | 760 | return @truncate(u32, self.r_info >> 32); |
| 761 | } | 761 | } |
| 762 | pub fn r_type(self: @This()) callconv(.Inline) u32 { | 762 | pub inline fn r_type(self: @This()) u32 { |
| 763 | return @truncate(u32, self.r_info & 0xffffffff); | 763 | return @truncate(u32, self.r_info & 0xffffffff); |
| 764 | } | 764 | } |
| 765 | }; | 765 | }; |
lib/std/fmt/parse_float.zig+4-4| ... | @@ -52,21 +52,21 @@ const Z96 = struct { | ... | @@ -52,21 +52,21 @@ const Z96 = struct { |
| 52 | d2: u32, | 52 | d2: u32, |
| 53 | 53 | ||
| 54 | // d = s >> 1 | 54 | // d = s >> 1 |
| 55 | fn shiftRight1(d: *Z96, s: Z96) callconv(.Inline) void { | 55 | inline fn shiftRight1(d: *Z96, s: Z96) void { |
| 56 | d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31); | 56 | d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31); |
| 57 | d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31); | 57 | d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31); |
| 58 | d.d2 = s.d2 >> 1; | 58 | d.d2 = s.d2 >> 1; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | // d = s << 1 | 61 | // d = s << 1 |
| 62 | fn shiftLeft1(d: *Z96, s: Z96) callconv(.Inline) void { | 62 | inline fn shiftLeft1(d: *Z96, s: Z96) void { |
| 63 | d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31); | 63 | d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31); |
| 64 | d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31); | 64 | d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31); |
| 65 | d.d0 = s.d0 << 1; | 65 | d.d0 = s.d0 << 1; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | // d += s | 68 | // d += s |
| 69 | fn add(d: *Z96, s: Z96) callconv(.Inline) void { | 69 | inline fn add(d: *Z96, s: Z96) void { |
| 70 | var w = @as(u64, d.d0) + @as(u64, s.d0); | 70 | var w = @as(u64, d.d0) + @as(u64, s.d0); |
| 71 | d.d0 = @truncate(u32, w); | 71 | d.d0 = @truncate(u32, w); |
| 72 | 72 | ||
| ... | @@ -80,7 +80,7 @@ const Z96 = struct { | ... | @@ -80,7 +80,7 @@ const Z96 = struct { |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | // d -= s | 82 | // d -= s |
| 83 | fn sub(d: *Z96, s: Z96) callconv(.Inline) void { | 83 | inline fn sub(d: *Z96, s: Z96) void { |
| 84 | var w = @as(u64, d.d0) -% @as(u64, s.d0); | 84 | var w = @as(u64, d.d0) -% @as(u64, s.d0); |
| 85 | d.d0 = @truncate(u32, w); | 85 | d.d0 = @truncate(u32, w); |
| 86 | 86 |
lib/std/hash/cityhash.zig+1-1| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | const std = @import("std"); | 6 | const std = @import("std"); |
| 7 | const builtin = std.builtin; | 7 | const builtin = std.builtin; |
| 8 | 8 | ||
| 9 | fn offsetPtr(ptr: [*]const u8, offset: usize) callconv(.Inline) [*]const u8 { | 9 | inline fn offsetPtr(ptr: [*]const u8, offset: usize) [*]const u8 { |
| 10 | // ptr + offset doesn't work at comptime so we need this instead. | 10 | // ptr + offset doesn't work at comptime so we need this instead. |
| 11 | return @ptrCast([*]const u8, &ptr[offset]); | 11 | return @ptrCast([*]const u8, &ptr[offset]); |
| 12 | } | 12 | } |
lib/std/json.zig+2-5| ... | @@ -2014,12 +2014,9 @@ test "parse into struct with duplicate field" { | ... | @@ -2014,12 +2014,9 @@ test "parse into struct with duplicate field" { |
| 2014 | const ballast = try testing.allocator.alloc(u64, 1); | 2014 | const ballast = try testing.allocator.alloc(u64, 1); |
| 2015 | defer testing.allocator.free(ballast); | 2015 | defer testing.allocator.free(ballast); |
| 2016 | 2016 | ||
| 2017 | const options_first = ParseOptions{ | 2017 | const options_first = ParseOptions{ .allocator = testing.allocator, .duplicate_field_behavior = .UseFirst }; |
| 2018 | .allocator = testing.allocator, | ||
| 2019 | .duplicate_field_behavior = .UseFirst | ||
| 2020 | }; | ||
| 2021 | 2018 | ||
| 2022 | const options_last = ParseOptions{ | 2019 | const options_last = ParseOptions{ |
| 2023 | .allocator = testing.allocator, | 2020 | .allocator = testing.allocator, |
| 2024 | .duplicate_field_behavior = .UseLast, | 2021 | .duplicate_field_behavior = .UseLast, |
| 2025 | }; | 2022 | }; |
lib/std/math.zig+1-1| ... | @@ -1334,7 +1334,7 @@ test "math.comptime" { | ... | @@ -1334,7 +1334,7 @@ test "math.comptime" { |
| 1334 | /// Returns a mask of all ones if value is true, | 1334 | /// Returns a mask of all ones if value is true, |
| 1335 | /// and a mask of all zeroes if value is false. | 1335 | /// and a mask of all zeroes if value is false. |
| 1336 | /// Compiles to one instruction for register sized integers. | 1336 | /// Compiles to one instruction for register sized integers. |
| 1337 | pub fn boolMask(comptime MaskInt: type, value: bool) callconv(.Inline) MaskInt { | 1337 | pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt { |
| 1338 | if (@typeInfo(MaskInt) != .Int) | 1338 | if (@typeInfo(MaskInt) != .Int) |
| 1339 | @compileError("boolMask requires an integer mask type."); | 1339 | @compileError("boolMask requires an integer mask type."); |
| 1340 | 1340 |
lib/std/math/complex.zig+1-1| ... | @@ -38,7 +38,7 @@ pub fn Complex(comptime T: type) type { | ... | @@ -38,7 +38,7 @@ pub fn Complex(comptime T: type) type { |
| 38 | 38 | ||
| 39 | /// Imaginary part. | 39 | /// Imaginary part. |
| 40 | im: T, | 40 | im: T, |
| 41 | 41 | ||
| 42 | /// Deprecated, use init() | 42 | /// Deprecated, use init() |
| 43 | pub const new = init; | 43 | pub const new = init; |
| 44 | 44 |
lib/std/os/bits/freebsd.zig+4-4| ... | @@ -823,16 +823,16 @@ pub const sigval = extern union { | ... | @@ -823,16 +823,16 @@ pub const sigval = extern union { |
| 823 | pub const _SIG_WORDS = 4; | 823 | pub const _SIG_WORDS = 4; |
| 824 | pub const _SIG_MAXSIG = 128; | 824 | pub const _SIG_MAXSIG = 128; |
| 825 | 825 | ||
| 826 | pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize { | 826 | pub inline fn _SIG_IDX(sig: usize) usize { |
| 827 | return sig - 1; | 827 | return sig - 1; |
| 828 | } | 828 | } |
| 829 | pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize { | 829 | pub inline fn _SIG_WORD(sig: usize) usize { |
| 830 | return_SIG_IDX(sig) >> 5; | 830 | return_SIG_IDX(sig) >> 5; |
| 831 | } | 831 | } |
| 832 | pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize { | 832 | pub inline fn _SIG_BIT(sig: usize) usize { |
| 833 | return 1 << (_SIG_IDX(sig) & 31); | 833 | return 1 << (_SIG_IDX(sig) & 31); |
| 834 | } | 834 | } |
| 835 | pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize { | 835 | pub inline fn _SIG_VALID(sig: usize) usize { |
| 836 | return sig <= _SIG_MAXSIG and sig > 0; | 836 | return sig <= _SIG_MAXSIG and sig > 0; |
| 837 | } | 837 | } |
| 838 | 838 |
lib/std/os/bits/haiku.zig+4-4| ... | @@ -721,16 +721,16 @@ pub const Sigaction = extern struct { | ... | @@ -721,16 +721,16 @@ pub const Sigaction = extern struct { |
| 721 | 721 | ||
| 722 | pub const _SIG_WORDS = 4; | 722 | pub const _SIG_WORDS = 4; |
| 723 | pub const _SIG_MAXSIG = 128; | 723 | pub const _SIG_MAXSIG = 128; |
| 724 | pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize { | 724 | pub inline fn _SIG_IDX(sig: usize) usize { |
| 725 | return sig - 1; | 725 | return sig - 1; |
| 726 | } | 726 | } |
| 727 | pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize { | 727 | pub inline fn _SIG_WORD(sig: usize) usize { |
| 728 | return_SIG_IDX(sig) >> 5; | 728 | return_SIG_IDX(sig) >> 5; |
| 729 | } | 729 | } |
| 730 | pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize { | 730 | pub inline fn _SIG_BIT(sig: usize) usize { |
| 731 | return 1 << (_SIG_IDX(sig) & 31); | 731 | return 1 << (_SIG_IDX(sig) & 31); |
| 732 | } | 732 | } |
| 733 | pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize { | 733 | pub inline fn _SIG_VALID(sig: usize) usize { |
| 734 | return sig <= _SIG_MAXSIG and sig > 0; | 734 | return sig <= _SIG_MAXSIG and sig > 0; |
| 735 | } | 735 | } |
| 736 | 736 |
lib/std/os/bits/netbsd.zig+4-4| ... | @@ -804,16 +804,16 @@ pub const _ksiginfo = extern struct { | ... | @@ -804,16 +804,16 @@ pub const _ksiginfo = extern struct { |
| 804 | pub const _SIG_WORDS = 4; | 804 | pub const _SIG_WORDS = 4; |
| 805 | pub const _SIG_MAXSIG = 128; | 805 | pub const _SIG_MAXSIG = 128; |
| 806 | 806 | ||
| 807 | pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize { | 807 | pub inline fn _SIG_IDX(sig: usize) usize { |
| 808 | return sig - 1; | 808 | return sig - 1; |
| 809 | } | 809 | } |
| 810 | pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize { | 810 | pub inline fn _SIG_WORD(sig: usize) usize { |
| 811 | return_SIG_IDX(sig) >> 5; | 811 | return_SIG_IDX(sig) >> 5; |
| 812 | } | 812 | } |
| 813 | pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize { | 813 | pub inline fn _SIG_BIT(sig: usize) usize { |
| 814 | return 1 << (_SIG_IDX(sig) & 31); | 814 | return 1 << (_SIG_IDX(sig) & 31); |
| 815 | } | 815 | } |
| 816 | pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize { | 816 | pub inline fn _SIG_VALID(sig: usize) usize { |
| 817 | return sig <= _SIG_MAXSIG and sig > 0; | 817 | return sig <= _SIG_MAXSIG and sig > 0; |
| 818 | } | 818 | } |
| 819 | 819 |
lib/std/os/linux.zig+1-1| ... | @@ -145,7 +145,7 @@ pub fn fork() usize { | ... | @@ -145,7 +145,7 @@ pub fn fork() usize { |
| 145 | /// It is advised to avoid this function and use clone instead, because | 145 | /// It is advised to avoid this function and use clone instead, because |
| 146 | /// the compiler is not aware of how vfork affects control flow and you may | 146 | /// the compiler is not aware of how vfork affects control flow and you may |
| 147 | /// see different results in optimized builds. | 147 | /// see different results in optimized builds. |
| 148 | pub fn vfork() callconv(.Inline) usize { | 148 | pub inline fn vfork() usize { |
| 149 | return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork}); | 149 | return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork}); |
| 150 | } | 150 | } |
| 151 | 151 |
lib/std/os/linux/tls.zig+1-1| ... | @@ -307,7 +307,7 @@ fn initTLS() void { | ... | @@ -307,7 +307,7 @@ fn initTLS() void { |
| 307 | }; | 307 | }; |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | fn alignPtrCast(comptime T: type, ptr: [*]u8) callconv(.Inline) *T { | 310 | inline fn alignPtrCast(comptime T: type, ptr: [*]u8) *T { |
| 311 | return @ptrCast(*T, @alignCast(@alignOf(T), ptr)); | 311 | return @ptrCast(*T, @alignCast(@alignOf(T), ptr)); |
| 312 | } | 312 | } |
| 313 | 313 |
lib/std/os/windows.zig+1-1| ... | @@ -1881,7 +1881,7 @@ pub fn wToPrefixedFileW(s: []const u16) !PathSpace { | ... | @@ -1881,7 +1881,7 @@ pub fn wToPrefixedFileW(s: []const u16) !PathSpace { |
| 1881 | return path_space; | 1881 | return path_space; |
| 1882 | } | 1882 | } |
| 1883 | 1883 | ||
| 1884 | fn MAKELANGID(p: c_ushort, s: c_ushort) callconv(.Inline) LANGID { | 1884 | inline fn MAKELANGID(p: c_ushort, s: c_ushort) LANGID { |
| 1885 | return (s << 10) | p; | 1885 | return (s << 10) | p; |
| 1886 | } | 1886 | } |
| 1887 | 1887 |
lib/std/start.zig+2-2| ... | @@ -375,7 +375,7 @@ const bad_main_ret = "expected return type of main to be 'void', '!void', 'noret | ... | @@ -375,7 +375,7 @@ const bad_main_ret = "expected return type of main to be 'void', '!void', 'noret |
| 375 | 375 | ||
| 376 | // This is marked inline because for some reason LLVM in release mode fails to inline it, | 376 | // This is marked inline because for some reason LLVM in release mode fails to inline it, |
| 377 | // and we want fewer call frames in stack traces. | 377 | // and we want fewer call frames in stack traces. |
| 378 | fn initEventLoopAndCallMain() callconv(.Inline) u8 { | 378 | inline fn initEventLoopAndCallMain() u8 { |
| 379 | if (std.event.Loop.instance) |loop| { | 379 | if (std.event.Loop.instance) |loop| { |
| 380 | if (!@hasDecl(root, "event_loop")) { | 380 | if (!@hasDecl(root, "event_loop")) { |
| 381 | loop.init() catch |err| { | 381 | loop.init() catch |err| { |
| ... | @@ -404,7 +404,7 @@ fn initEventLoopAndCallMain() callconv(.Inline) u8 { | ... | @@ -404,7 +404,7 @@ fn initEventLoopAndCallMain() callconv(.Inline) u8 { |
| 404 | // and we want fewer call frames in stack traces. | 404 | // and we want fewer call frames in stack traces. |
| 405 | // TODO This function is duplicated from initEventLoopAndCallMain instead of using generics | 405 | // TODO This function is duplicated from initEventLoopAndCallMain instead of using generics |
| 406 | // because it is working around stage1 compiler bugs. | 406 | // because it is working around stage1 compiler bugs. |
| 407 | fn initEventLoopAndCallWinMain() callconv(.Inline) std.os.windows.INT { | 407 | inline fn initEventLoopAndCallWinMain() std.os.windows.INT { |
| 408 | if (std.event.Loop.instance) |loop| { | 408 | if (std.event.Loop.instance) |loop| { |
| 409 | if (!@hasDecl(root, "event_loop")) { | 409 | if (!@hasDecl(root, "event_loop")) { |
| 410 | loop.init() catch |err| { | 410 | loop.init() catch |err| { |
lib/std/target/spirv.zig+55-110| ... | @@ -732,8 +732,7 @@ pub const all_features = blk: { | ... | @@ -732,8 +732,7 @@ pub const all_features = blk: { |
| 732 | result[@enumToInt(Feature.Matrix)] = .{ | 732 | result[@enumToInt(Feature.Matrix)] = .{ |
| 733 | .llvm_name = null, | 733 | .llvm_name = null, |
| 734 | .description = "Enable SPIR-V capability Matrix", | 734 | .description = "Enable SPIR-V capability Matrix", |
| 735 | .dependencies = featureSet(&[_]Feature{ | 735 | .dependencies = featureSet(&[_]Feature{}), |
| 736 | }), | ||
| 737 | }; | 736 | }; |
| 738 | result[@enumToInt(Feature.Shader)] = .{ | 737 | result[@enumToInt(Feature.Shader)] = .{ |
| 739 | .llvm_name = null, | 738 | .llvm_name = null, |
| ... | @@ -759,20 +758,17 @@ pub const all_features = blk: { | ... | @@ -759,20 +758,17 @@ pub const all_features = blk: { |
| 759 | result[@enumToInt(Feature.Addresses)] = .{ | 758 | result[@enumToInt(Feature.Addresses)] = .{ |
| 760 | .llvm_name = null, | 759 | .llvm_name = null, |
| 761 | .description = "Enable SPIR-V capability Addresses", | 760 | .description = "Enable SPIR-V capability Addresses", |
| 762 | .dependencies = featureSet(&[_]Feature{ | 761 | .dependencies = featureSet(&[_]Feature{}), |
| 763 | }), | ||
| 764 | }; | 762 | }; |
| 765 | result[@enumToInt(Feature.Linkage)] = .{ | 763 | result[@enumToInt(Feature.Linkage)] = .{ |
| 766 | .llvm_name = null, | 764 | .llvm_name = null, |
| 767 | .description = "Enable SPIR-V capability Linkage", | 765 | .description = "Enable SPIR-V capability Linkage", |
| 768 | .dependencies = featureSet(&[_]Feature{ | 766 | .dependencies = featureSet(&[_]Feature{}), |
| 769 | }), | ||
| 770 | }; | 767 | }; |
| 771 | result[@enumToInt(Feature.Kernel)] = .{ | 768 | result[@enumToInt(Feature.Kernel)] = .{ |
| 772 | .llvm_name = null, | 769 | .llvm_name = null, |
| 773 | .description = "Enable SPIR-V capability Kernel", | 770 | .description = "Enable SPIR-V capability Kernel", |
| 774 | .dependencies = featureSet(&[_]Feature{ | 771 | .dependencies = featureSet(&[_]Feature{}), |
| 775 | }), | ||
| 776 | }; | 772 | }; |
| 777 | result[@enumToInt(Feature.Vector16)] = .{ | 773 | result[@enumToInt(Feature.Vector16)] = .{ |
| 778 | .llvm_name = null, | 774 | .llvm_name = null, |
| ... | @@ -791,20 +787,17 @@ pub const all_features = blk: { | ... | @@ -791,20 +787,17 @@ pub const all_features = blk: { |
| 791 | result[@enumToInt(Feature.Float16)] = .{ | 787 | result[@enumToInt(Feature.Float16)] = .{ |
| 792 | .llvm_name = null, | 788 | .llvm_name = null, |
| 793 | .description = "Enable SPIR-V capability Float16", | 789 | .description = "Enable SPIR-V capability Float16", |
| 794 | .dependencies = featureSet(&[_]Feature{ | 790 | .dependencies = featureSet(&[_]Feature{}), |
| 795 | }), | ||
| 796 | }; | 791 | }; |
| 797 | result[@enumToInt(Feature.Float64)] = .{ | 792 | result[@enumToInt(Feature.Float64)] = .{ |
| 798 | .llvm_name = null, | 793 | .llvm_name = null, |
| 799 | .description = "Enable SPIR-V capability Float64", | 794 | .description = "Enable SPIR-V capability Float64", |
| 800 | .dependencies = featureSet(&[_]Feature{ | 795 | .dependencies = featureSet(&[_]Feature{}), |
| 801 | }), | ||
| 802 | }; | 796 | }; |
| 803 | result[@enumToInt(Feature.Int64)] = .{ | 797 | result[@enumToInt(Feature.Int64)] = .{ |
| 804 | .llvm_name = null, | 798 | .llvm_name = null, |
| 805 | .description = "Enable SPIR-V capability Int64", | 799 | .description = "Enable SPIR-V capability Int64", |
| 806 | .dependencies = featureSet(&[_]Feature{ | 800 | .dependencies = featureSet(&[_]Feature{}), |
| 807 | }), | ||
| 808 | }; | 801 | }; |
| 809 | result[@enumToInt(Feature.Int64Atomics)] = .{ | 802 | result[@enumToInt(Feature.Int64Atomics)] = .{ |
| 810 | .llvm_name = null, | 803 | .llvm_name = null, |
| ... | @@ -844,8 +837,7 @@ pub const all_features = blk: { | ... | @@ -844,8 +837,7 @@ pub const all_features = blk: { |
| 844 | result[@enumToInt(Feature.Groups)] = .{ | 837 | result[@enumToInt(Feature.Groups)] = .{ |
| 845 | .llvm_name = null, | 838 | .llvm_name = null, |
| 846 | .description = "Enable SPIR-V capability Groups", | 839 | .description = "Enable SPIR-V capability Groups", |
| 847 | .dependencies = featureSet(&[_]Feature{ | 840 | .dependencies = featureSet(&[_]Feature{}), |
| 848 | }), | ||
| 849 | }; | 841 | }; |
| 850 | result[@enumToInt(Feature.DeviceEnqueue)] = .{ | 842 | result[@enumToInt(Feature.DeviceEnqueue)] = .{ |
| 851 | .llvm_name = null, | 843 | .llvm_name = null, |
| ... | @@ -871,8 +863,7 @@ pub const all_features = blk: { | ... | @@ -871,8 +863,7 @@ pub const all_features = blk: { |
| 871 | result[@enumToInt(Feature.Int16)] = .{ | 863 | result[@enumToInt(Feature.Int16)] = .{ |
| 872 | .llvm_name = null, | 864 | .llvm_name = null, |
| 873 | .description = "Enable SPIR-V capability Int16", | 865 | .description = "Enable SPIR-V capability Int16", |
| 874 | .dependencies = featureSet(&[_]Feature{ | 866 | .dependencies = featureSet(&[_]Feature{}), |
| 875 | }), | ||
| 876 | }; | 867 | }; |
| 877 | result[@enumToInt(Feature.TessellationPointSize)] = .{ | 868 | result[@enumToInt(Feature.TessellationPointSize)] = .{ |
| 878 | .llvm_name = null, | 869 | .llvm_name = null, |
| ... | @@ -982,8 +973,7 @@ pub const all_features = blk: { | ... | @@ -982,8 +973,7 @@ pub const all_features = blk: { |
| 982 | result[@enumToInt(Feature.Int8)] = .{ | 973 | result[@enumToInt(Feature.Int8)] = .{ |
| 983 | .llvm_name = null, | 974 | .llvm_name = null, |
| 984 | .description = "Enable SPIR-V capability Int8", | 975 | .description = "Enable SPIR-V capability Int8", |
| 985 | .dependencies = featureSet(&[_]Feature{ | 976 | .dependencies = featureSet(&[_]Feature{}), |
| 986 | }), | ||
| 987 | }; | 977 | }; |
| 988 | result[@enumToInt(Feature.InputAttachment)] = .{ | 978 | result[@enumToInt(Feature.InputAttachment)] = .{ |
| 989 | .llvm_name = null, | 979 | .llvm_name = null, |
| ... | @@ -1009,8 +999,7 @@ pub const all_features = blk: { | ... | @@ -1009,8 +999,7 @@ pub const all_features = blk: { |
| 1009 | result[@enumToInt(Feature.Sampled1D)] = .{ | 999 | result[@enumToInt(Feature.Sampled1D)] = .{ |
| 1010 | .llvm_name = null, | 1000 | .llvm_name = null, |
| 1011 | .description = "Enable SPIR-V capability Sampled1D", | 1001 | .description = "Enable SPIR-V capability Sampled1D", |
| 1012 | .dependencies = featureSet(&[_]Feature{ | 1002 | .dependencies = featureSet(&[_]Feature{}), |
| 1013 | }), | ||
| 1014 | }; | 1003 | }; |
| 1015 | result[@enumToInt(Feature.Image1D)] = .{ | 1004 | result[@enumToInt(Feature.Image1D)] = .{ |
| 1016 | .llvm_name = null, | 1005 | .llvm_name = null, |
| ... | @@ -1029,8 +1018,7 @@ pub const all_features = blk: { | ... | @@ -1029,8 +1018,7 @@ pub const all_features = blk: { |
| 1029 | result[@enumToInt(Feature.SampledBuffer)] = .{ | 1018 | result[@enumToInt(Feature.SampledBuffer)] = .{ |
| 1030 | .llvm_name = null, | 1019 | .llvm_name = null, |
| 1031 | .description = "Enable SPIR-V capability SampledBuffer", | 1020 | .description = "Enable SPIR-V capability SampledBuffer", |
| 1032 | .dependencies = featureSet(&[_]Feature{ | 1021 | .dependencies = featureSet(&[_]Feature{}), |
| 1033 | }), | ||
| 1034 | }; | 1022 | }; |
| 1035 | result[@enumToInt(Feature.ImageBuffer)] = .{ | 1023 | result[@enumToInt(Feature.ImageBuffer)] = .{ |
| 1036 | .llvm_name = null, | 1024 | .llvm_name = null, |
| ... | @@ -1220,8 +1208,7 @@ pub const all_features = blk: { | ... | @@ -1220,8 +1208,7 @@ pub const all_features = blk: { |
| 1220 | result[@enumToInt(Feature.SubgroupBallotKHR)] = .{ | 1208 | result[@enumToInt(Feature.SubgroupBallotKHR)] = .{ |
| 1221 | .llvm_name = null, | 1209 | .llvm_name = null, |
| 1222 | .description = "Enable SPIR-V capability SubgroupBallotKHR", | 1210 | .description = "Enable SPIR-V capability SubgroupBallotKHR", |
| 1223 | .dependencies = featureSet(&[_]Feature{ | 1211 | .dependencies = featureSet(&[_]Feature{}), |
| 1224 | }), | ||
| 1225 | }; | 1212 | }; |
| 1226 | result[@enumToInt(Feature.DrawParameters)] = .{ | 1213 | result[@enumToInt(Feature.DrawParameters)] = .{ |
| 1227 | .llvm_name = null, | 1214 | .llvm_name = null, |
| ... | @@ -1255,8 +1242,7 @@ pub const all_features = blk: { | ... | @@ -1255,8 +1242,7 @@ pub const all_features = blk: { |
| 1255 | result[@enumToInt(Feature.SubgroupVoteKHR)] = .{ | 1242 | result[@enumToInt(Feature.SubgroupVoteKHR)] = .{ |
| 1256 | .llvm_name = null, | 1243 | .llvm_name = null, |
| 1257 | .description = "Enable SPIR-V capability SubgroupVoteKHR", | 1244 | .description = "Enable SPIR-V capability SubgroupVoteKHR", |
| 1258 | .dependencies = featureSet(&[_]Feature{ | 1245 | .dependencies = featureSet(&[_]Feature{}), |
| 1259 | }), | ||
| 1260 | }; | 1246 | }; |
| 1261 | result[@enumToInt(Feature.StorageBuffer16BitAccess)] = .{ | 1247 | result[@enumToInt(Feature.StorageBuffer16BitAccess)] = .{ |
| 1262 | .llvm_name = null, | 1248 | .llvm_name = null, |
| ... | @@ -1338,14 +1324,12 @@ pub const all_features = blk: { | ... | @@ -1338,14 +1324,12 @@ pub const all_features = blk: { |
| 1338 | result[@enumToInt(Feature.AtomicStorageOps)] = .{ | 1324 | result[@enumToInt(Feature.AtomicStorageOps)] = .{ |
| 1339 | .llvm_name = null, | 1325 | .llvm_name = null, |
| 1340 | .description = "Enable SPIR-V capability AtomicStorageOps", | 1326 | .description = "Enable SPIR-V capability AtomicStorageOps", |
| 1341 | .dependencies = featureSet(&[_]Feature{ | 1327 | .dependencies = featureSet(&[_]Feature{}), |
| 1342 | }), | ||
| 1343 | }; | 1328 | }; |
| 1344 | result[@enumToInt(Feature.SampleMaskPostDepthCoverage)] = .{ | 1329 | result[@enumToInt(Feature.SampleMaskPostDepthCoverage)] = .{ |
| 1345 | .llvm_name = null, | 1330 | .llvm_name = null, |
| 1346 | .description = "Enable SPIR-V capability SampleMaskPostDepthCoverage", | 1331 | .description = "Enable SPIR-V capability SampleMaskPostDepthCoverage", |
| 1347 | .dependencies = featureSet(&[_]Feature{ | 1332 | .dependencies = featureSet(&[_]Feature{}), |
| 1348 | }), | ||
| 1349 | }; | 1333 | }; |
| 1350 | result[@enumToInt(Feature.StorageBuffer8BitAccess)] = .{ | 1334 | result[@enumToInt(Feature.StorageBuffer8BitAccess)] = .{ |
| 1351 | .llvm_name = null, | 1335 | .llvm_name = null, |
| ... | @@ -1548,20 +1532,17 @@ pub const all_features = blk: { | ... | @@ -1548,20 +1532,17 @@ pub const all_features = blk: { |
| 1548 | result[@enumToInt(Feature.ImageFootprintNV)] = .{ | 1532 | result[@enumToInt(Feature.ImageFootprintNV)] = .{ |
| 1549 | .llvm_name = null, | 1533 | .llvm_name = null, |
| 1550 | .description = "Enable SPIR-V capability ImageFootprintNV", | 1534 | .description = "Enable SPIR-V capability ImageFootprintNV", |
| 1551 | .dependencies = featureSet(&[_]Feature{ | 1535 | .dependencies = featureSet(&[_]Feature{}), |
| 1552 | }), | ||
| 1553 | }; | 1536 | }; |
| 1554 | result[@enumToInt(Feature.FragmentBarycentricNV)] = .{ | 1537 | result[@enumToInt(Feature.FragmentBarycentricNV)] = .{ |
| 1555 | .llvm_name = null, | 1538 | .llvm_name = null, |
| 1556 | .description = "Enable SPIR-V capability FragmentBarycentricNV", | 1539 | .description = "Enable SPIR-V capability FragmentBarycentricNV", |
| 1557 | .dependencies = featureSet(&[_]Feature{ | 1540 | .dependencies = featureSet(&[_]Feature{}), |
| 1558 | }), | ||
| 1559 | }; | 1541 | }; |
| 1560 | result[@enumToInt(Feature.ComputeDerivativeGroupQuadsNV)] = .{ | 1542 | result[@enumToInt(Feature.ComputeDerivativeGroupQuadsNV)] = .{ |
| 1561 | .llvm_name = null, | 1543 | .llvm_name = null, |
| 1562 | .description = "Enable SPIR-V capability ComputeDerivativeGroupQuadsNV", | 1544 | .description = "Enable SPIR-V capability ComputeDerivativeGroupQuadsNV", |
| 1563 | .dependencies = featureSet(&[_]Feature{ | 1545 | .dependencies = featureSet(&[_]Feature{}), |
| 1564 | }), | ||
| 1565 | }; | 1546 | }; |
| 1566 | result[@enumToInt(Feature.FragmentDensityEXT)] = .{ | 1547 | result[@enumToInt(Feature.FragmentDensityEXT)] = .{ |
| 1567 | .llvm_name = null, | 1548 | .llvm_name = null, |
| ... | @@ -1580,8 +1561,7 @@ pub const all_features = blk: { | ... | @@ -1580,8 +1561,7 @@ pub const all_features = blk: { |
| 1580 | result[@enumToInt(Feature.GroupNonUniformPartitionedNV)] = .{ | 1561 | result[@enumToInt(Feature.GroupNonUniformPartitionedNV)] = .{ |
| 1581 | .llvm_name = null, | 1562 | .llvm_name = null, |
| 1582 | .description = "Enable SPIR-V capability GroupNonUniformPartitionedNV", | 1563 | .description = "Enable SPIR-V capability GroupNonUniformPartitionedNV", |
| 1583 | .dependencies = featureSet(&[_]Feature{ | 1564 | .dependencies = featureSet(&[_]Feature{}), |
| 1584 | }), | ||
| 1585 | }; | 1565 | }; |
| 1586 | result[@enumToInt(Feature.ShaderNonUniform)] = .{ | 1566 | result[@enumToInt(Feature.ShaderNonUniform)] = .{ |
| 1587 | .llvm_name = null, | 1567 | .llvm_name = null, |
| ... | @@ -1835,8 +1815,7 @@ pub const all_features = blk: { | ... | @@ -1835,8 +1815,7 @@ pub const all_features = blk: { |
| 1835 | result[@enumToInt(Feature.ComputeDerivativeGroupLinearNV)] = .{ | 1815 | result[@enumToInt(Feature.ComputeDerivativeGroupLinearNV)] = .{ |
| 1836 | .llvm_name = null, | 1816 | .llvm_name = null, |
| 1837 | .description = "Enable SPIR-V capability ComputeDerivativeGroupLinearNV", | 1817 | .description = "Enable SPIR-V capability ComputeDerivativeGroupLinearNV", |
| 1838 | .dependencies = featureSet(&[_]Feature{ | 1818 | .dependencies = featureSet(&[_]Feature{}), |
| 1839 | }), | ||
| 1840 | }; | 1819 | }; |
| 1841 | result[@enumToInt(Feature.RayTracingProvisionalKHR)] = .{ | 1820 | result[@enumToInt(Feature.RayTracingProvisionalKHR)] = .{ |
| 1842 | .llvm_name = null, | 1821 | .llvm_name = null, |
| ... | @@ -1890,38 +1869,32 @@ pub const all_features = blk: { | ... | @@ -1890,38 +1869,32 @@ pub const all_features = blk: { |
| 1890 | result[@enumToInt(Feature.SubgroupShuffleINTEL)] = .{ | 1869 | result[@enumToInt(Feature.SubgroupShuffleINTEL)] = .{ |
| 1891 | .llvm_name = null, | 1870 | .llvm_name = null, |
| 1892 | .description = "Enable SPIR-V capability SubgroupShuffleINTEL", | 1871 | .description = "Enable SPIR-V capability SubgroupShuffleINTEL", |
| 1893 | .dependencies = featureSet(&[_]Feature{ | 1872 | .dependencies = featureSet(&[_]Feature{}), |
| 1894 | }), | ||
| 1895 | }; | 1873 | }; |
| 1896 | result[@enumToInt(Feature.SubgroupBufferBlockIOINTEL)] = .{ | 1874 | result[@enumToInt(Feature.SubgroupBufferBlockIOINTEL)] = .{ |
| 1897 | .llvm_name = null, | 1875 | .llvm_name = null, |
| 1898 | .description = "Enable SPIR-V capability SubgroupBufferBlockIOINTEL", | 1876 | .description = "Enable SPIR-V capability SubgroupBufferBlockIOINTEL", |
| 1899 | .dependencies = featureSet(&[_]Feature{ | 1877 | .dependencies = featureSet(&[_]Feature{}), |
| 1900 | }), | ||
| 1901 | }; | 1878 | }; |
| 1902 | result[@enumToInt(Feature.SubgroupImageBlockIOINTEL)] = .{ | 1879 | result[@enumToInt(Feature.SubgroupImageBlockIOINTEL)] = .{ |
| 1903 | .llvm_name = null, | 1880 | .llvm_name = null, |
| 1904 | .description = "Enable SPIR-V capability SubgroupImageBlockIOINTEL", | 1881 | .description = "Enable SPIR-V capability SubgroupImageBlockIOINTEL", |
| 1905 | .dependencies = featureSet(&[_]Feature{ | 1882 | .dependencies = featureSet(&[_]Feature{}), |
| 1906 | }), | ||
| 1907 | }; | 1883 | }; |
| 1908 | result[@enumToInt(Feature.SubgroupImageMediaBlockIOINTEL)] = .{ | 1884 | result[@enumToInt(Feature.SubgroupImageMediaBlockIOINTEL)] = .{ |
| 1909 | .llvm_name = null, | 1885 | .llvm_name = null, |
| 1910 | .description = "Enable SPIR-V capability SubgroupImageMediaBlockIOINTEL", | 1886 | .description = "Enable SPIR-V capability SubgroupImageMediaBlockIOINTEL", |
| 1911 | .dependencies = featureSet(&[_]Feature{ | 1887 | .dependencies = featureSet(&[_]Feature{}), |
| 1912 | }), | ||
| 1913 | }; | 1888 | }; |
| 1914 | result[@enumToInt(Feature.RoundToInfinityINTEL)] = .{ | 1889 | result[@enumToInt(Feature.RoundToInfinityINTEL)] = .{ |
| 1915 | .llvm_name = null, | 1890 | .llvm_name = null, |
| 1916 | .description = "Enable SPIR-V capability RoundToInfinityINTEL", | 1891 | .description = "Enable SPIR-V capability RoundToInfinityINTEL", |
| 1917 | .dependencies = featureSet(&[_]Feature{ | 1892 | .dependencies = featureSet(&[_]Feature{}), |
| 1918 | }), | ||
| 1919 | }; | 1893 | }; |
| 1920 | result[@enumToInt(Feature.FloatingPointModeINTEL)] = .{ | 1894 | result[@enumToInt(Feature.FloatingPointModeINTEL)] = .{ |
| 1921 | .llvm_name = null, | 1895 | .llvm_name = null, |
| 1922 | .description = "Enable SPIR-V capability FloatingPointModeINTEL", | 1896 | .description = "Enable SPIR-V capability FloatingPointModeINTEL", |
| 1923 | .dependencies = featureSet(&[_]Feature{ | 1897 | .dependencies = featureSet(&[_]Feature{}), |
| 1924 | }), | ||
| 1925 | }; | 1898 | }; |
| 1926 | result[@enumToInt(Feature.IntegerFunctions2INTEL)] = .{ | 1899 | result[@enumToInt(Feature.IntegerFunctions2INTEL)] = .{ |
| 1927 | .llvm_name = null, | 1900 | .llvm_name = null, |
| ... | @@ -1933,38 +1906,32 @@ pub const all_features = blk: { | ... | @@ -1933,38 +1906,32 @@ pub const all_features = blk: { |
| 1933 | result[@enumToInt(Feature.FunctionPointersINTEL)] = .{ | 1906 | result[@enumToInt(Feature.FunctionPointersINTEL)] = .{ |
| 1934 | .llvm_name = null, | 1907 | .llvm_name = null, |
| 1935 | .description = "Enable SPIR-V capability FunctionPointersINTEL", | 1908 | .description = "Enable SPIR-V capability FunctionPointersINTEL", |
| 1936 | .dependencies = featureSet(&[_]Feature{ | 1909 | .dependencies = featureSet(&[_]Feature{}), |
| 1937 | }), | ||
| 1938 | }; | 1910 | }; |
| 1939 | result[@enumToInt(Feature.IndirectReferencesINTEL)] = .{ | 1911 | result[@enumToInt(Feature.IndirectReferencesINTEL)] = .{ |
| 1940 | .llvm_name = null, | 1912 | .llvm_name = null, |
| 1941 | .description = "Enable SPIR-V capability IndirectReferencesINTEL", | 1913 | .description = "Enable SPIR-V capability IndirectReferencesINTEL", |
| 1942 | .dependencies = featureSet(&[_]Feature{ | 1914 | .dependencies = featureSet(&[_]Feature{}), |
| 1943 | }), | ||
| 1944 | }; | 1915 | }; |
| 1945 | result[@enumToInt(Feature.AsmINTEL)] = .{ | 1916 | result[@enumToInt(Feature.AsmINTEL)] = .{ |
| 1946 | .llvm_name = null, | 1917 | .llvm_name = null, |
| 1947 | .description = "Enable SPIR-V capability AsmINTEL", | 1918 | .description = "Enable SPIR-V capability AsmINTEL", |
| 1948 | .dependencies = featureSet(&[_]Feature{ | 1919 | .dependencies = featureSet(&[_]Feature{}), |
| 1949 | }), | ||
| 1950 | }; | 1920 | }; |
| 1951 | result[@enumToInt(Feature.AtomicFloat32MinMaxEXT)] = .{ | 1921 | result[@enumToInt(Feature.AtomicFloat32MinMaxEXT)] = .{ |
| 1952 | .llvm_name = null, | 1922 | .llvm_name = null, |
| 1953 | .description = "Enable SPIR-V capability AtomicFloat32MinMaxEXT", | 1923 | .description = "Enable SPIR-V capability AtomicFloat32MinMaxEXT", |
| 1954 | .dependencies = featureSet(&[_]Feature{ | 1924 | .dependencies = featureSet(&[_]Feature{}), |
| 1955 | }), | ||
| 1956 | }; | 1925 | }; |
| 1957 | result[@enumToInt(Feature.AtomicFloat64MinMaxEXT)] = .{ | 1926 | result[@enumToInt(Feature.AtomicFloat64MinMaxEXT)] = .{ |
| 1958 | .llvm_name = null, | 1927 | .llvm_name = null, |
| 1959 | .description = "Enable SPIR-V capability AtomicFloat64MinMaxEXT", | 1928 | .description = "Enable SPIR-V capability AtomicFloat64MinMaxEXT", |
| 1960 | .dependencies = featureSet(&[_]Feature{ | 1929 | .dependencies = featureSet(&[_]Feature{}), |
| 1961 | }), | ||
| 1962 | }; | 1930 | }; |
| 1963 | result[@enumToInt(Feature.AtomicFloat16MinMaxEXT)] = .{ | 1931 | result[@enumToInt(Feature.AtomicFloat16MinMaxEXT)] = .{ |
| 1964 | .llvm_name = null, | 1932 | .llvm_name = null, |
| 1965 | .description = "Enable SPIR-V capability AtomicFloat16MinMaxEXT", | 1933 | .description = "Enable SPIR-V capability AtomicFloat16MinMaxEXT", |
| 1966 | .dependencies = featureSet(&[_]Feature{ | 1934 | .dependencies = featureSet(&[_]Feature{}), |
| 1967 | }), | ||
| 1968 | }; | 1935 | }; |
| 1969 | result[@enumToInt(Feature.VectorComputeINTEL)] = .{ | 1936 | result[@enumToInt(Feature.VectorComputeINTEL)] = .{ |
| 1970 | .llvm_name = null, | 1937 | .llvm_name = null, |
| ... | @@ -1976,50 +1943,42 @@ pub const all_features = blk: { | ... | @@ -1976,50 +1943,42 @@ pub const all_features = blk: { |
| 1976 | result[@enumToInt(Feature.VectorAnyINTEL)] = .{ | 1943 | result[@enumToInt(Feature.VectorAnyINTEL)] = .{ |
| 1977 | .llvm_name = null, | 1944 | .llvm_name = null, |
| 1978 | .description = "Enable SPIR-V capability VectorAnyINTEL", | 1945 | .description = "Enable SPIR-V capability VectorAnyINTEL", |
| 1979 | .dependencies = featureSet(&[_]Feature{ | 1946 | .dependencies = featureSet(&[_]Feature{}), |
| 1980 | }), | ||
| 1981 | }; | 1947 | }; |
| 1982 | result[@enumToInt(Feature.ExpectAssumeKHR)] = .{ | 1948 | result[@enumToInt(Feature.ExpectAssumeKHR)] = .{ |
| 1983 | .llvm_name = null, | 1949 | .llvm_name = null, |
| 1984 | .description = "Enable SPIR-V capability ExpectAssumeKHR", | 1950 | .description = "Enable SPIR-V capability ExpectAssumeKHR", |
| 1985 | .dependencies = featureSet(&[_]Feature{ | 1951 | .dependencies = featureSet(&[_]Feature{}), |
| 1986 | }), | ||
| 1987 | }; | 1952 | }; |
| 1988 | result[@enumToInt(Feature.SubgroupAvcMotionEstimationINTEL)] = .{ | 1953 | result[@enumToInt(Feature.SubgroupAvcMotionEstimationINTEL)] = .{ |
| 1989 | .llvm_name = null, | 1954 | .llvm_name = null, |
| 1990 | .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationINTEL", | 1955 | .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationINTEL", |
| 1991 | .dependencies = featureSet(&[_]Feature{ | 1956 | .dependencies = featureSet(&[_]Feature{}), |
| 1992 | }), | ||
| 1993 | }; | 1957 | }; |
| 1994 | result[@enumToInt(Feature.SubgroupAvcMotionEstimationIntraINTEL)] = .{ | 1958 | result[@enumToInt(Feature.SubgroupAvcMotionEstimationIntraINTEL)] = .{ |
| 1995 | .llvm_name = null, | 1959 | .llvm_name = null, |
| 1996 | .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationIntraINTEL", | 1960 | .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationIntraINTEL", |
| 1997 | .dependencies = featureSet(&[_]Feature{ | 1961 | .dependencies = featureSet(&[_]Feature{}), |
| 1998 | }), | ||
| 1999 | }; | 1962 | }; |
| 2000 | result[@enumToInt(Feature.SubgroupAvcMotionEstimationChromaINTEL)] = .{ | 1963 | result[@enumToInt(Feature.SubgroupAvcMotionEstimationChromaINTEL)] = .{ |
| 2001 | .llvm_name = null, | 1964 | .llvm_name = null, |
| 2002 | .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationChromaINTEL", | 1965 | .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationChromaINTEL", |
| 2003 | .dependencies = featureSet(&[_]Feature{ | 1966 | .dependencies = featureSet(&[_]Feature{}), |
| 2004 | }), | ||
| 2005 | }; | 1967 | }; |
| 2006 | result[@enumToInt(Feature.VariableLengthArrayINTEL)] = .{ | 1968 | result[@enumToInt(Feature.VariableLengthArrayINTEL)] = .{ |
| 2007 | .llvm_name = null, | 1969 | .llvm_name = null, |
| 2008 | .description = "Enable SPIR-V capability VariableLengthArrayINTEL", | 1970 | .description = "Enable SPIR-V capability VariableLengthArrayINTEL", |
| 2009 | .dependencies = featureSet(&[_]Feature{ | 1971 | .dependencies = featureSet(&[_]Feature{}), |
| 2010 | }), | ||
| 2011 | }; | 1972 | }; |
| 2012 | result[@enumToInt(Feature.FunctionFloatControlINTEL)] = .{ | 1973 | result[@enumToInt(Feature.FunctionFloatControlINTEL)] = .{ |
| 2013 | .llvm_name = null, | 1974 | .llvm_name = null, |
| 2014 | .description = "Enable SPIR-V capability FunctionFloatControlINTEL", | 1975 | .description = "Enable SPIR-V capability FunctionFloatControlINTEL", |
| 2015 | .dependencies = featureSet(&[_]Feature{ | 1976 | .dependencies = featureSet(&[_]Feature{}), |
| 2016 | }), | ||
| 2017 | }; | 1977 | }; |
| 2018 | result[@enumToInt(Feature.FPGAMemoryAttributesINTEL)] = .{ | 1978 | result[@enumToInt(Feature.FPGAMemoryAttributesINTEL)] = .{ |
| 2019 | .llvm_name = null, | 1979 | .llvm_name = null, |
| 2020 | .description = "Enable SPIR-V capability FPGAMemoryAttributesINTEL", | 1980 | .description = "Enable SPIR-V capability FPGAMemoryAttributesINTEL", |
| 2021 | .dependencies = featureSet(&[_]Feature{ | 1981 | .dependencies = featureSet(&[_]Feature{}), |
| 2022 | }), | ||
| 2023 | }; | 1982 | }; |
| 2024 | result[@enumToInt(Feature.FPFastMathModeINTEL)] = .{ | 1983 | result[@enumToInt(Feature.FPFastMathModeINTEL)] = .{ |
| 2025 | .llvm_name = null, | 1984 | .llvm_name = null, |
| ... | @@ -2031,80 +1990,67 @@ pub const all_features = blk: { | ... | @@ -2031,80 +1990,67 @@ pub const all_features = blk: { |
| 2031 | result[@enumToInt(Feature.ArbitraryPrecisionIntegersINTEL)] = .{ | 1990 | result[@enumToInt(Feature.ArbitraryPrecisionIntegersINTEL)] = .{ |
| 2032 | .llvm_name = null, | 1991 | .llvm_name = null, |
| 2033 | .description = "Enable SPIR-V capability ArbitraryPrecisionIntegersINTEL", | 1992 | .description = "Enable SPIR-V capability ArbitraryPrecisionIntegersINTEL", |
| 2034 | .dependencies = featureSet(&[_]Feature{ | 1993 | .dependencies = featureSet(&[_]Feature{}), |
| 2035 | }), | ||
| 2036 | }; | 1994 | }; |
| 2037 | result[@enumToInt(Feature.UnstructuredLoopControlsINTEL)] = .{ | 1995 | result[@enumToInt(Feature.UnstructuredLoopControlsINTEL)] = .{ |
| 2038 | .llvm_name = null, | 1996 | .llvm_name = null, |
| 2039 | .description = "Enable SPIR-V capability UnstructuredLoopControlsINTEL", | 1997 | .description = "Enable SPIR-V capability UnstructuredLoopControlsINTEL", |
| 2040 | .dependencies = featureSet(&[_]Feature{ | 1998 | .dependencies = featureSet(&[_]Feature{}), |
| 2041 | }), | ||
| 2042 | }; | 1999 | }; |
| 2043 | result[@enumToInt(Feature.FPGALoopControlsINTEL)] = .{ | 2000 | result[@enumToInt(Feature.FPGALoopControlsINTEL)] = .{ |
| 2044 | .llvm_name = null, | 2001 | .llvm_name = null, |
| 2045 | .description = "Enable SPIR-V capability FPGALoopControlsINTEL", | 2002 | .description = "Enable SPIR-V capability FPGALoopControlsINTEL", |
| 2046 | .dependencies = featureSet(&[_]Feature{ | 2003 | .dependencies = featureSet(&[_]Feature{}), |
| 2047 | }), | ||
| 2048 | }; | 2004 | }; |
| 2049 | result[@enumToInt(Feature.KernelAttributesINTEL)] = .{ | 2005 | result[@enumToInt(Feature.KernelAttributesINTEL)] = .{ |
| 2050 | .llvm_name = null, | 2006 | .llvm_name = null, |
| 2051 | .description = "Enable SPIR-V capability KernelAttributesINTEL", | 2007 | .description = "Enable SPIR-V capability KernelAttributesINTEL", |
| 2052 | .dependencies = featureSet(&[_]Feature{ | 2008 | .dependencies = featureSet(&[_]Feature{}), |
| 2053 | }), | ||
| 2054 | }; | 2009 | }; |
| 2055 | result[@enumToInt(Feature.FPGAKernelAttributesINTEL)] = .{ | 2010 | result[@enumToInt(Feature.FPGAKernelAttributesINTEL)] = .{ |
| 2056 | .llvm_name = null, | 2011 | .llvm_name = null, |
| 2057 | .description = "Enable SPIR-V capability FPGAKernelAttributesINTEL", | 2012 | .description = "Enable SPIR-V capability FPGAKernelAttributesINTEL", |
| 2058 | .dependencies = featureSet(&[_]Feature{ | 2013 | .dependencies = featureSet(&[_]Feature{}), |
| 2059 | }), | ||
| 2060 | }; | 2014 | }; |
| 2061 | result[@enumToInt(Feature.FPGAMemoryAccessesINTEL)] = .{ | 2015 | result[@enumToInt(Feature.FPGAMemoryAccessesINTEL)] = .{ |
| 2062 | .llvm_name = null, | 2016 | .llvm_name = null, |
| 2063 | .description = "Enable SPIR-V capability FPGAMemoryAccessesINTEL", | 2017 | .description = "Enable SPIR-V capability FPGAMemoryAccessesINTEL", |
| 2064 | .dependencies = featureSet(&[_]Feature{ | 2018 | .dependencies = featureSet(&[_]Feature{}), |
| 2065 | }), | ||
| 2066 | }; | 2019 | }; |
| 2067 | result[@enumToInt(Feature.FPGAClusterAttributesINTEL)] = .{ | 2020 | result[@enumToInt(Feature.FPGAClusterAttributesINTEL)] = .{ |
| 2068 | .llvm_name = null, | 2021 | .llvm_name = null, |
| 2069 | .description = "Enable SPIR-V capability FPGAClusterAttributesINTEL", | 2022 | .description = "Enable SPIR-V capability FPGAClusterAttributesINTEL", |
| 2070 | .dependencies = featureSet(&[_]Feature{ | 2023 | .dependencies = featureSet(&[_]Feature{}), |
| 2071 | }), | ||
| 2072 | }; | 2024 | }; |
| 2073 | result[@enumToInt(Feature.LoopFuseINTEL)] = .{ | 2025 | result[@enumToInt(Feature.LoopFuseINTEL)] = .{ |
| 2074 | .llvm_name = null, | 2026 | .llvm_name = null, |
| 2075 | .description = "Enable SPIR-V capability LoopFuseINTEL", | 2027 | .description = "Enable SPIR-V capability LoopFuseINTEL", |
| 2076 | .dependencies = featureSet(&[_]Feature{ | 2028 | .dependencies = featureSet(&[_]Feature{}), |
| 2077 | }), | ||
| 2078 | }; | 2029 | }; |
| 2079 | result[@enumToInt(Feature.FPGABufferLocationINTEL)] = .{ | 2030 | result[@enumToInt(Feature.FPGABufferLocationINTEL)] = .{ |
| 2080 | .llvm_name = null, | 2031 | .llvm_name = null, |
| 2081 | .description = "Enable SPIR-V capability FPGABufferLocationINTEL", | 2032 | .description = "Enable SPIR-V capability FPGABufferLocationINTEL", |
| 2082 | .dependencies = featureSet(&[_]Feature{ | 2033 | .dependencies = featureSet(&[_]Feature{}), |
| 2083 | }), | ||
| 2084 | }; | 2034 | }; |
| 2085 | result[@enumToInt(Feature.USMStorageClassesINTEL)] = .{ | 2035 | result[@enumToInt(Feature.USMStorageClassesINTEL)] = .{ |
| 2086 | .llvm_name = null, | 2036 | .llvm_name = null, |
| 2087 | .description = "Enable SPIR-V capability USMStorageClassesINTEL", | 2037 | .description = "Enable SPIR-V capability USMStorageClassesINTEL", |
| 2088 | .dependencies = featureSet(&[_]Feature{ | 2038 | .dependencies = featureSet(&[_]Feature{}), |
| 2089 | }), | ||
| 2090 | }; | 2039 | }; |
| 2091 | result[@enumToInt(Feature.IOPipesINTEL)] = .{ | 2040 | result[@enumToInt(Feature.IOPipesINTEL)] = .{ |
| 2092 | .llvm_name = null, | 2041 | .llvm_name = null, |
| 2093 | .description = "Enable SPIR-V capability IOPipesINTEL", | 2042 | .description = "Enable SPIR-V capability IOPipesINTEL", |
| 2094 | .dependencies = featureSet(&[_]Feature{ | 2043 | .dependencies = featureSet(&[_]Feature{}), |
| 2095 | }), | ||
| 2096 | }; | 2044 | }; |
| 2097 | result[@enumToInt(Feature.BlockingPipesINTEL)] = .{ | 2045 | result[@enumToInt(Feature.BlockingPipesINTEL)] = .{ |
| 2098 | .llvm_name = null, | 2046 | .llvm_name = null, |
| 2099 | .description = "Enable SPIR-V capability BlockingPipesINTEL", | 2047 | .description = "Enable SPIR-V capability BlockingPipesINTEL", |
| 2100 | .dependencies = featureSet(&[_]Feature{ | 2048 | .dependencies = featureSet(&[_]Feature{}), |
| 2101 | }), | ||
| 2102 | }; | 2049 | }; |
| 2103 | result[@enumToInt(Feature.FPGARegINTEL)] = .{ | 2050 | result[@enumToInt(Feature.FPGARegINTEL)] = .{ |
| 2104 | .llvm_name = null, | 2051 | .llvm_name = null, |
| 2105 | .description = "Enable SPIR-V capability FPGARegINTEL", | 2052 | .description = "Enable SPIR-V capability FPGARegINTEL", |
| 2106 | .dependencies = featureSet(&[_]Feature{ | 2053 | .dependencies = featureSet(&[_]Feature{}), |
| 2107 | }), | ||
| 2108 | }; | 2054 | }; |
| 2109 | result[@enumToInt(Feature.AtomicFloat32AddEXT)] = .{ | 2055 | result[@enumToInt(Feature.AtomicFloat32AddEXT)] = .{ |
| 2110 | .llvm_name = null, | 2056 | .llvm_name = null, |
| ... | @@ -2123,8 +2069,7 @@ pub const all_features = blk: { | ... | @@ -2123,8 +2069,7 @@ pub const all_features = blk: { |
| 2123 | result[@enumToInt(Feature.LongConstantCompositeINTEL)] = .{ | 2069 | result[@enumToInt(Feature.LongConstantCompositeINTEL)] = .{ |
| 2124 | .llvm_name = null, | 2070 | .llvm_name = null, |
| 2125 | .description = "Enable SPIR-V capability LongConstantCompositeINTEL", | 2071 | .description = "Enable SPIR-V capability LongConstantCompositeINTEL", |
| 2126 | .dependencies = featureSet(&[_]Feature{ | 2072 | .dependencies = featureSet(&[_]Feature{}), |
| 2127 | }), | ||
| 2128 | }; | 2073 | }; |
| 2129 | const ti = @typeInfo(Feature); | 2074 | const ti = @typeInfo(Feature); |
| 2130 | for (result) |*elem, i| { | 2075 | for (result) |*elem, i| { |
lib/std/zig/ast.zig+9-4| ... | @@ -459,7 +459,8 @@ pub const Tree = struct { | ... | @@ -459,7 +459,8 @@ pub const Tree = struct { |
| 459 | .keyword_extern, | 459 | .keyword_extern, |
| 460 | .keyword_export, | 460 | .keyword_export, |
| 461 | .keyword_pub, | 461 | .keyword_pub, |
| 462 | .keyword_threadlocal, | 462 | .keyword_inline, |
| 463 | .keyword_noinline, | ||
| 463 | .string_literal, | 464 | .string_literal, |
| 464 | => continue, | 465 | => continue, |
| 465 | 466 | ||
| ... | @@ -1833,7 +1834,7 @@ pub const Tree = struct { | ... | @@ -1833,7 +1834,7 @@ pub const Tree = struct { |
| 1833 | var result: full.FnProto = .{ | 1834 | var result: full.FnProto = .{ |
| 1834 | .ast = info, | 1835 | .ast = info, |
| 1835 | .visib_token = null, | 1836 | .visib_token = null, |
| 1836 | .extern_export_token = null, | 1837 | .extern_export_inline_token = null, |
| 1837 | .lib_name = null, | 1838 | .lib_name = null, |
| 1838 | .name_token = null, | 1839 | .name_token = null, |
| 1839 | .lparen = undefined, | 1840 | .lparen = undefined, |
| ... | @@ -1842,7 +1843,11 @@ pub const Tree = struct { | ... | @@ -1842,7 +1843,11 @@ pub const Tree = struct { |
| 1842 | while (i > 0) { | 1843 | while (i > 0) { |
| 1843 | i -= 1; | 1844 | i -= 1; |
| 1844 | switch (token_tags[i]) { | 1845 | switch (token_tags[i]) { |
| 1845 | .keyword_extern, .keyword_export => result.extern_export_token = i, | 1846 | .keyword_extern, |
| 1847 | .keyword_export, | ||
| 1848 | .keyword_inline, | ||
| 1849 | .keyword_noinline, | ||
| 1850 | => result.extern_export_inline_token = i, | ||
| 1846 | .keyword_pub => result.visib_token = i, | 1851 | .keyword_pub => result.visib_token = i, |
| 1847 | .string_literal => result.lib_name = i, | 1852 | .string_literal => result.lib_name = i, |
| 1848 | else => break, | 1853 | else => break, |
| ... | @@ -2123,7 +2128,7 @@ pub const full = struct { | ... | @@ -2123,7 +2128,7 @@ pub const full = struct { |
| 2123 | 2128 | ||
| 2124 | pub const FnProto = struct { | 2129 | pub const FnProto = struct { |
| 2125 | visib_token: ?TokenIndex, | 2130 | visib_token: ?TokenIndex, |
| 2126 | extern_export_token: ?TokenIndex, | 2131 | extern_export_inline_token: ?TokenIndex, |
| 2127 | lib_name: ?TokenIndex, | 2132 | lib_name: ?TokenIndex, |
| 2128 | name_token: ?TokenIndex, | 2133 | name_token: ?TokenIndex, |
| 2129 | lparen: TokenIndex, | 2134 | lparen: TokenIndex, |
lib/std/zig/parser_test.zig+27-7| ... | @@ -61,13 +61,33 @@ test "zig fmt: respect line breaks in struct field value declaration" { | ... | @@ -61,13 +61,33 @@ test "zig fmt: respect line breaks in struct field value declaration" { |
| 61 | ); | 61 | ); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | // TODO Remove this after zig 0.9.0 is released. | 64 | test "zig fmt: respect line breaks before functions" { |
| 65 | test "zig fmt: rewrite inline functions as callconv(.Inline)" { | 65 | try testCanonical( |
| 66 | try testTransform( | 66 | \\const std = @import("std"); |
| 67 | \\ | ||
| 67 | \\inline fn foo() void {} | 68 | \\inline fn foo() void {} |
| 68 | \\ | 69 | \\ |
| 69 | , | 70 | \\noinline fn foo() void {} |
| 71 | \\ | ||
| 72 | \\export fn foo() void {} | ||
| 73 | \\ | ||
| 74 | \\extern fn foo() void; | ||
| 75 | \\ | ||
| 76 | \\extern "foo" fn foo() void; | ||
| 77 | \\ | ||
| 78 | ); | ||
| 79 | } | ||
| 80 | |||
| 81 | test "zig fmt: rewrite callconv(.Inline) to the inline keyword" { | ||
| 82 | try testTransform( | ||
| 70 | \\fn foo() callconv(.Inline) void {} | 83 | \\fn foo() callconv(.Inline) void {} |
| 84 | \\const bar = .Inline; | ||
| 85 | \\fn foo() callconv(bar) void {} | ||
| 86 | \\ | ||
| 87 | , | ||
| 88 | \\inline fn foo() void {} | ||
| 89 | \\const bar = .Inline; | ||
| 90 | \\fn foo() callconv(bar) void {} | ||
| 71 | \\ | 91 | \\ |
| 72 | ); | 92 | ); |
| 73 | } | 93 | } |
| ... | @@ -2867,17 +2887,17 @@ test "zig fmt: functions" { | ... | @@ -2867,17 +2887,17 @@ test "zig fmt: functions" { |
| 2867 | \\extern fn puts(s: *const u8) c_int; | 2887 | \\extern fn puts(s: *const u8) c_int; |
| 2868 | \\extern "c" fn puts(s: *const u8) c_int; | 2888 | \\extern "c" fn puts(s: *const u8) c_int; |
| 2869 | \\export fn puts(s: *const u8) c_int; | 2889 | \\export fn puts(s: *const u8) c_int; |
| 2870 | \\fn puts(s: *const u8) callconv(.Inline) c_int; | 2890 | \\inline fn puts(s: *const u8) c_int; |
| 2871 | \\noinline fn puts(s: *const u8) c_int; | 2891 | \\noinline fn puts(s: *const u8) c_int; |
| 2872 | \\pub extern fn puts(s: *const u8) c_int; | 2892 | \\pub extern fn puts(s: *const u8) c_int; |
| 2873 | \\pub extern "c" fn puts(s: *const u8) c_int; | 2893 | \\pub extern "c" fn puts(s: *const u8) c_int; |
| 2874 | \\pub export fn puts(s: *const u8) c_int; | 2894 | \\pub export fn puts(s: *const u8) c_int; |
| 2875 | \\pub fn puts(s: *const u8) callconv(.Inline) c_int; | 2895 | \\pub inline fn puts(s: *const u8) c_int; |
| 2876 | \\pub noinline fn puts(s: *const u8) c_int; | 2896 | \\pub noinline fn puts(s: *const u8) c_int; |
| 2877 | \\pub extern fn puts(s: *const u8) align(2 + 2) c_int; | 2897 | \\pub extern fn puts(s: *const u8) align(2 + 2) c_int; |
| 2878 | \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int; | 2898 | \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int; |
| 2879 | \\pub export fn puts(s: *const u8) align(2 + 2) c_int; | 2899 | \\pub export fn puts(s: *const u8) align(2 + 2) c_int; |
| 2880 | \\pub fn puts(s: *const u8) align(2 + 2) callconv(.Inline) c_int; | 2900 | \\pub inline fn puts(s: *const u8) align(2 + 2) c_int; |
| 2881 | \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int; | 2901 | \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int; |
| 2882 | \\ | 2902 | \\ |
| 2883 | ); | 2903 | ); |
lib/std/zig/render.zig+18-11| ... | @@ -83,13 +83,23 @@ fn renderMember(gpa: *Allocator, ais: *Ais, tree: ast.Tree, decl: ast.Node.Index | ... | @@ -83,13 +83,23 @@ fn renderMember(gpa: *Allocator, ais: *Ais, tree: ast.Tree, decl: ast.Node.Index |
| 83 | } | 83 | } |
| 84 | } | 84 | } |
| 85 | while (i < fn_token) : (i += 1) { | 85 | while (i < fn_token) : (i += 1) { |
| 86 | if (token_tags[i] == .keyword_inline) { | ||
| 87 | // TODO remove this special case when 0.9.0 is released. | ||
| 88 | // See the commit that introduced this comment for more details. | ||
| 89 | continue; | ||
| 90 | } | ||
| 91 | try renderToken(ais, tree, i, .space); | 86 | try renderToken(ais, tree, i, .space); |
| 92 | } | 87 | } |
| 88 | switch (tree.nodes.items(.tag)[fn_proto]) { | ||
| 89 | .fn_proto_one, .fn_proto => { | ||
| 90 | const callconv_expr = if (tree.nodes.items(.tag)[fn_proto] == .fn_proto_one) | ||
| 91 | tree.extraData(datas[fn_proto].lhs, ast.Node.FnProtoOne).callconv_expr | ||
| 92 | else | ||
| 93 | tree.extraData(datas[fn_proto].lhs, ast.Node.FnProto).callconv_expr; | ||
| 94 | if (callconv_expr != 0 and tree.nodes.items(.tag)[callconv_expr] == .enum_literal) { | ||
| 95 | if (mem.eql(u8, "Inline", tree.tokenSlice(main_tokens[callconv_expr]))) { | ||
| 96 | try ais.writer().writeAll("inline "); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | }, | ||
| 100 | .fn_proto_simple, .fn_proto_multi => {}, | ||
| 101 | else => unreachable, | ||
| 102 | } | ||
| 93 | assert(datas[decl].rhs != 0); | 103 | assert(datas[decl].rhs != 0); |
| 94 | try renderExpression(gpa, ais, tree, fn_proto, .space); | 104 | try renderExpression(gpa, ais, tree, fn_proto, .space); |
| 95 | return renderExpression(gpa, ais, tree, datas[decl].rhs, space); | 105 | return renderExpression(gpa, ais, tree, datas[decl].rhs, space); |
| ... | @@ -1246,9 +1256,6 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full. | ... | @@ -1246,9 +1256,6 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full. |
| 1246 | const token_tags = tree.tokens.items(.tag); | 1256 | const token_tags = tree.tokens.items(.tag); |
| 1247 | const token_starts = tree.tokens.items(.start); | 1257 | const token_starts = tree.tokens.items(.start); |
| 1248 | 1258 | ||
| 1249 | const is_inline = fn_proto.ast.fn_token > 0 and | ||
| 1250 | token_tags[fn_proto.ast.fn_token - 1] == .keyword_inline; | ||
| 1251 | |||
| 1252 | const after_fn_token = fn_proto.ast.fn_token + 1; | 1259 | const after_fn_token = fn_proto.ast.fn_token + 1; |
| 1253 | const lparen = if (token_tags[after_fn_token] == .identifier) blk: { | 1260 | const lparen = if (token_tags[after_fn_token] == .identifier) blk: { |
| 1254 | try renderToken(ais, tree, fn_proto.ast.fn_token, .space); // fn | 1261 | try renderToken(ais, tree, fn_proto.ast.fn_token, .space); // fn |
| ... | @@ -1424,7 +1431,9 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full. | ... | @@ -1424,7 +1431,9 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full. |
| 1424 | try renderToken(ais, tree, section_rparen, .space); // ) | 1431 | try renderToken(ais, tree, section_rparen, .space); // ) |
| 1425 | } | 1432 | } |
| 1426 | 1433 | ||
| 1427 | if (fn_proto.ast.callconv_expr != 0) { | 1434 | if (fn_proto.ast.callconv_expr != 0 and |
| 1435 | !mem.eql(u8, "Inline", tree.tokenSlice(tree.nodes.items(.main_token)[fn_proto.ast.callconv_expr]))) | ||
| 1436 | { | ||
| 1428 | const callconv_lparen = tree.firstToken(fn_proto.ast.callconv_expr) - 1; | 1437 | const callconv_lparen = tree.firstToken(fn_proto.ast.callconv_expr) - 1; |
| 1429 | const callconv_rparen = tree.lastToken(fn_proto.ast.callconv_expr) + 1; | 1438 | const callconv_rparen = tree.lastToken(fn_proto.ast.callconv_expr) + 1; |
| 1430 | 1439 | ||
| ... | @@ -1432,8 +1441,6 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full. | ... | @@ -1432,8 +1441,6 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full. |
| 1432 | try renderToken(ais, tree, callconv_lparen, .none); // ( | 1441 | try renderToken(ais, tree, callconv_lparen, .none); // ( |
| 1433 | try renderExpression(gpa, ais, tree, fn_proto.ast.callconv_expr, .none); | 1442 | try renderExpression(gpa, ais, tree, fn_proto.ast.callconv_expr, .none); |
| 1434 | try renderToken(ais, tree, callconv_rparen, .space); // ) | 1443 | try renderToken(ais, tree, callconv_rparen, .space); // ) |
| 1435 | } else if (is_inline) { | ||
| 1436 | try ais.writer().writeAll("callconv(.Inline) "); | ||
| 1437 | } | 1444 | } |
| 1438 | 1445 | ||
| 1439 | if (token_tags[maybe_bang] == .bang) { | 1446 | if (token_tags[maybe_bang] == .bang) { |
lib/std/zig/system/x86.zig+2-2| ... | @@ -19,11 +19,11 @@ fn setFeature(cpu: *Target.Cpu, feature: Target.x86.Feature, enabled: bool) void | ... | @@ -19,11 +19,11 @@ fn setFeature(cpu: *Target.Cpu, feature: Target.x86.Feature, enabled: bool) void |
| 19 | if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx); | 19 | if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | fn bit(input: u32, offset: u5) callconv(.Inline) bool { | 22 | inline fn bit(input: u32, offset: u5) bool { |
| 23 | return (input >> offset) & 1 != 0; | 23 | return (input >> offset) & 1 != 0; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | fn hasMask(input: u32, mask: u32) callconv(.Inline) bool { | 26 | inline fn hasMask(input: u32, mask: u32) bool { |
| 27 | return (input & mask) == mask; | 27 | return (input & mask) == mask; |
| 28 | } | 28 | } |
| 29 | 29 |
src/AstGen.zig+32-14| ... | @@ -996,7 +996,7 @@ fn fnProtoExpr( | ... | @@ -996,7 +996,7 @@ fn fnProtoExpr( |
| 996 | const token_tags = tree.tokens.items(.tag); | 996 | const token_tags = tree.tokens.items(.tag); |
| 997 | 997 | ||
| 998 | const is_extern = blk: { | 998 | const is_extern = blk: { |
| 999 | const maybe_extern_token = fn_proto.extern_export_token orelse break :blk false; | 999 | const maybe_extern_token = fn_proto.extern_export_inline_token orelse break :blk false; |
| 1000 | break :blk token_tags[maybe_extern_token] == .keyword_extern; | 1000 | break :blk token_tags[maybe_extern_token] == .keyword_extern; |
| 1001 | }; | 1001 | }; |
| 1002 | assert(!is_extern); | 1002 | assert(!is_extern); |
| ... | @@ -2743,15 +2743,20 @@ fn fnDecl( | ... | @@ -2743,15 +2743,20 @@ fn fnDecl( |
| 2743 | }; | 2743 | }; |
| 2744 | defer decl_gz.instructions.deinit(gpa); | 2744 | defer decl_gz.instructions.deinit(gpa); |
| 2745 | 2745 | ||
| 2746 | // TODO: support noinline | ||
| 2746 | const is_pub = fn_proto.visib_token != null; | 2747 | const is_pub = fn_proto.visib_token != null; |
| 2747 | const is_export = blk: { | 2748 | const is_export = blk: { |
| 2748 | const maybe_export_token = fn_proto.extern_export_token orelse break :blk false; | 2749 | const maybe_export_token = fn_proto.extern_export_inline_token orelse break :blk false; |
| 2749 | break :blk token_tags[maybe_export_token] == .keyword_export; | 2750 | break :blk token_tags[maybe_export_token] == .keyword_export; |
| 2750 | }; | 2751 | }; |
| 2751 | const is_extern = blk: { | 2752 | const is_extern = blk: { |
| 2752 | const maybe_extern_token = fn_proto.extern_export_token orelse break :blk false; | 2753 | const maybe_extern_token = fn_proto.extern_export_inline_token orelse break :blk false; |
| 2753 | break :blk token_tags[maybe_extern_token] == .keyword_extern; | 2754 | break :blk token_tags[maybe_extern_token] == .keyword_extern; |
| 2754 | }; | 2755 | }; |
| 2756 | const has_inline_keyword = blk: { | ||
| 2757 | const maybe_inline_token = fn_proto.extern_export_inline_token orelse break :blk false; | ||
| 2758 | break :blk token_tags[maybe_inline_token] == .keyword_inline; | ||
| 2759 | }; | ||
| 2755 | const align_inst: Zir.Inst.Ref = if (fn_proto.ast.align_expr == 0) .none else inst: { | 2760 | const align_inst: Zir.Inst.Ref = if (fn_proto.ast.align_expr == 0) .none else inst: { |
| 2756 | break :inst try expr(&decl_gz, &decl_gz.base, align_rl, fn_proto.ast.align_expr); | 2761 | break :inst try expr(&decl_gz, &decl_gz.base, align_rl, fn_proto.ast.align_expr); |
| 2757 | }; | 2762 | }; |
| ... | @@ -2820,17 +2825,30 @@ fn fnDecl( | ... | @@ -2820,17 +2825,30 @@ fn fnDecl( |
| 2820 | fn_proto.ast.return_type, | 2825 | fn_proto.ast.return_type, |
| 2821 | ); | 2826 | ); |
| 2822 | 2827 | ||
| 2823 | const cc: Zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0) | 2828 | const cc: Zir.Inst.Ref = blk: { |
| 2824 | try AstGen.expr( | 2829 | if (fn_proto.ast.callconv_expr != 0) { |
| 2825 | &decl_gz, | 2830 | if (has_inline_keyword) { |
| 2826 | &decl_gz.base, | 2831 | return astgen.failNode( |
| 2827 | .{ .ty = .calling_convention_type }, | 2832 | fn_proto.ast.callconv_expr, |
| 2828 | fn_proto.ast.callconv_expr, | 2833 | "explicit callconv incompatible with inline keyword", |
| 2829 | ) | 2834 | .{}, |
| 2830 | else if (is_extern) // note: https://github.com/ziglang/zig/issues/5269 | 2835 | ); |
| 2831 | Zir.Inst.Ref.calling_convention_c | 2836 | } |
| 2832 | else | 2837 | break :blk try AstGen.expr( |
| 2833 | Zir.Inst.Ref.none; | 2838 | &decl_gz, |
| 2839 | &decl_gz.base, | ||
| 2840 | .{ .ty = .calling_convention_type }, | ||
| 2841 | fn_proto.ast.callconv_expr, | ||
| 2842 | ); | ||
| 2843 | } else if (is_extern) { | ||
| 2844 | // note: https://github.com/ziglang/zig/issues/5269 | ||
| 2845 | break :blk .calling_convention_c; | ||
| 2846 | } else if (has_inline_keyword) { | ||
| 2847 | break :blk .calling_convention_inline; | ||
| 2848 | } else { | ||
| 2849 | break :blk .none; | ||
| 2850 | } | ||
| 2851 | }; | ||
| 2834 | 2852 | ||
| 2835 | const func_inst: Zir.Inst.Ref = if (body_node == 0) func: { | 2853 | const func_inst: Zir.Inst.Ref = if (body_node == 0) func: { |
| 2836 | if (!is_extern) { | 2854 | if (!is_extern) { |
src/DepTokenizer.zig+1-4| ... | @@ -275,10 +275,7 @@ fn errorIllegalChar(comptime id: std.meta.Tag(Token), index: usize, char: u8) To | ... | @@ -275,10 +275,7 @@ fn errorIllegalChar(comptime id: std.meta.Tag(Token), index: usize, char: u8) To |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | fn finishTarget(must_resolve: bool, bytes: []const u8) Token { | 277 | fn finishTarget(must_resolve: bool, bytes: []const u8) Token { |
| 278 | return if (must_resolve) | 278 | return if (must_resolve) .{ .target_must_resolve = bytes } else .{ .target = bytes }; |
| 279 | .{ .target_must_resolve = bytes } | ||
| 280 | else | ||
| 281 | .{ .target = bytes }; | ||
| 282 | } | 279 | } |
| 283 | 280 | ||
| 284 | const State = enum { | 281 | const State = enum { |
src/Zir.zig+13| ... | @@ -1687,6 +1687,8 @@ pub const Inst = struct { | ... | @@ -1687,6 +1687,8 @@ pub const Inst = struct { |
| 1687 | one_usize, | 1687 | one_usize, |
| 1688 | /// `std.builtin.CallingConvention.C` | 1688 | /// `std.builtin.CallingConvention.C` |
| 1689 | calling_convention_c, | 1689 | calling_convention_c, |
| 1690 | /// `std.builtin.CallingConvention.Inline` | ||
| 1691 | calling_convention_inline, | ||
| 1690 | 1692 | ||
| 1691 | _, | 1693 | _, |
| 1692 | 1694 | ||
| ... | @@ -1954,6 +1956,10 @@ pub const Inst = struct { | ... | @@ -1954,6 +1956,10 @@ pub const Inst = struct { |
| 1954 | .ty = Type.initTag(.calling_convention), | 1956 | .ty = Type.initTag(.calling_convention), |
| 1955 | .val = .{ .ptr_otherwise = &calling_convention_c_payload.base }, | 1957 | .val = .{ .ptr_otherwise = &calling_convention_c_payload.base }, |
| 1956 | }, | 1958 | }, |
| 1959 | .calling_convention_inline = .{ | ||
| 1960 | .ty = Type.initTag(.calling_convention), | ||
| 1961 | .val = .{ .ptr_otherwise = &calling_convention_inline_payload.base }, | ||
| 1962 | }, | ||
| 1957 | }); | 1963 | }); |
| 1958 | }; | 1964 | }; |
| 1959 | 1965 | ||
| ... | @@ -1964,6 +1970,13 @@ pub const Inst = struct { | ... | @@ -1964,6 +1970,13 @@ pub const Inst = struct { |
| 1964 | .data = @enumToInt(std.builtin.CallingConvention.C), | 1970 | .data = @enumToInt(std.builtin.CallingConvention.C), |
| 1965 | }; | 1971 | }; |
| 1966 | 1972 | ||
| 1973 | /// We would like this to be const but `Value` wants a mutable pointer for | ||
| 1974 | /// its payload field. Nothing should mutate this though. | ||
| 1975 | var calling_convention_inline_payload: Value.Payload.U32 = .{ | ||
| 1976 | .base = .{ .tag = .enum_field_index }, | ||
| 1977 | .data = @enumToInt(std.builtin.CallingConvention.Inline), | ||
| 1978 | }; | ||
| 1979 | |||
| 1967 | /// All instructions have an 8-byte payload, which is contained within | 1980 | /// All instructions have an 8-byte payload, which is contained within |
| 1968 | /// this union. `Tag` determines which union field is active, as well as | 1981 | /// this union. `Tag` determines which union field is active, as well as |
| 1969 | /// how to interpret the data within. | 1982 | /// how to interpret the data within. |
src/libc_installation.zig+1-2| ... | @@ -286,8 +286,7 @@ pub const LibCInstallation = struct { | ... | @@ -286,8 +286,7 @@ pub const LibCInstallation = struct { |
| 286 | else if (is_haiku) | 286 | else if (is_haiku) |
| 287 | "posix/errno.h" | 287 | "posix/errno.h" |
| 288 | else | 288 | else |
| 289 | "sys/errno.h" | 289 | "sys/errno.h"; |
| 290 | ; | ||
| 291 | 290 | ||
| 292 | var path_i: usize = 0; | 291 | var path_i: usize = 0; |
| 293 | while (path_i < search_paths.items.len) : (path_i += 1) { | 292 | while (path_i < search_paths.items.len) : (path_i += 1) { |
src/link/MachO.zig+1-1| ... | @@ -2518,7 +2518,7 @@ fn allocatedSizeLinkedit(self: *MachO, start: u64) u64 { | ... | @@ -2518,7 +2518,7 @@ fn allocatedSizeLinkedit(self: *MachO, start: u64) u64 { |
| 2518 | return min_pos - start; | 2518 | return min_pos - start; |
| 2519 | } | 2519 | } |
| 2520 | 2520 | ||
| 2521 | fn checkForCollision(start: u64, end: u64, off: u64, size: u64) callconv(.Inline) ?u64 { | 2521 | inline fn checkForCollision(start: u64, end: u64, off: u64, size: u64) ?u64 { |
| 2522 | const increased_size = padToIdeal(size); | 2522 | const increased_size = padToIdeal(size); |
| 2523 | const test_end = off + increased_size; | 2523 | const test_end = off + increased_size; |
| 2524 | if (end > off and start < test_end) { | 2524 | if (end > off and start < test_end) { |
src/link/MachO/reloc/aarch64.zig+1-1| ... | @@ -585,7 +585,7 @@ pub const Parser = struct { | ... | @@ -585,7 +585,7 @@ pub const Parser = struct { |
| 585 | } | 585 | } |
| 586 | }; | 586 | }; |
| 587 | 587 | ||
| 588 | fn isArithmeticOp(inst: *const [4]u8) callconv(.Inline) bool { | 588 | inline fn isArithmeticOp(inst: *const [4]u8) bool { |
| 589 | const group_decode = @truncate(u5, inst[3]); | 589 | const group_decode = @truncate(u5, inst[3]); |
| 590 | return ((group_decode >> 2) == 4); | 590 | return ((group_decode >> 2) == 4); |
| 591 | } | 591 | } |
src/stage1/all_types.hpp+11-1| ... | @@ -714,6 +714,12 @@ enum NodeType { | ... | @@ -714,6 +714,12 @@ enum NodeType { |
| 714 | NodeTypeAnyTypeField, | 714 | NodeTypeAnyTypeField, |
| 715 | }; | 715 | }; |
| 716 | 716 | ||
| 717 | enum FnInline { | ||
| 718 | FnInlineAuto, | ||
| 719 | FnInlineAlways, | ||
| 720 | FnInlineNever, | ||
| 721 | }; | ||
| 722 | |||
| 717 | struct AstNodeFnProto { | 723 | struct AstNodeFnProto { |
| 718 | Buf *name; | 724 | Buf *name; |
| 719 | ZigList<AstNode *> params; | 725 | ZigList<AstNode *> params; |
| ... | @@ -729,12 +735,16 @@ struct AstNodeFnProto { | ... | @@ -729,12 +735,16 @@ struct AstNodeFnProto { |
| 729 | AstNode *callconv_expr; | 735 | AstNode *callconv_expr; |
| 730 | Buf doc_comments; | 736 | Buf doc_comments; |
| 731 | 737 | ||
| 738 | // This is set based only on the existence of a noinline or inline keyword. | ||
| 739 | // This is then resolved to an is_noinline bool and (potentially .Inline) | ||
| 740 | // calling convention in resolve_decl_fn() in analyze.cpp. | ||
| 741 | FnInline fn_inline; | ||
| 742 | |||
| 732 | VisibMod visib_mod; | 743 | VisibMod visib_mod; |
| 733 | bool auto_err_set; | 744 | bool auto_err_set; |
| 734 | bool is_var_args; | 745 | bool is_var_args; |
| 735 | bool is_extern; | 746 | bool is_extern; |
| 736 | bool is_export; | 747 | bool is_export; |
| 737 | bool is_noinline; | ||
| 738 | }; | 748 | }; |
| 739 | 749 | ||
| 740 | struct AstNodeFnDef { | 750 | struct AstNodeFnDef { |
src/stage1/analyze.cpp+7-1| ... | @@ -1638,6 +1638,9 @@ CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) { | ... | @@ -1638,6 +1638,9 @@ CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) { |
| 1638 | if (fn_proto->is_extern || fn_proto->is_export) | 1638 | if (fn_proto->is_extern || fn_proto->is_export) |
| 1639 | return CallingConventionC; | 1639 | return CallingConventionC; |
| 1640 | 1640 | ||
| 1641 | if (fn_proto->fn_inline == FnInlineAlways) | ||
| 1642 | return CallingConventionInline; | ||
| 1643 | |||
| 1641 | return CallingConventionUnspecified; | 1644 | return CallingConventionUnspecified; |
| 1642 | } | 1645 | } |
| 1643 | 1646 | ||
| ... | @@ -3649,7 +3652,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) { | ... | @@ -3649,7 +3652,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) { |
| 3649 | assert(proto_node->type == NodeTypeFnProto); | 3652 | assert(proto_node->type == NodeTypeFnProto); |
| 3650 | AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; | 3653 | AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; |
| 3651 | 3654 | ||
| 3652 | ZigFn *fn_entry = create_fn_raw(g, fn_proto->is_noinline); | 3655 | ZigFn *fn_entry = create_fn_raw(g, fn_proto->fn_inline == FnInlineNever); |
| 3653 | 3656 | ||
| 3654 | fn_entry->proto_node = proto_node; | 3657 | fn_entry->proto_node = proto_node; |
| 3655 | fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr : | 3658 | fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr : |
| ... | @@ -3742,6 +3745,9 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { | ... | @@ -3742,6 +3745,9 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3742 | 3745 | ||
| 3743 | CallingConvention cc; | 3746 | CallingConvention cc; |
| 3744 | if (fn_proto->callconv_expr != nullptr) { | 3747 | if (fn_proto->callconv_expr != nullptr) { |
| 3748 | if (fn_proto->fn_inline == FnInlineAlways) { | ||
| 3749 | add_node_error(g, fn_proto->callconv_expr, buf_sprintf("explicit callconv incompatible with inline keyword")); | ||
| 3750 | } | ||
| 3745 | ZigType *cc_enum_value = get_builtin_type(g, "CallingConvention"); | 3751 | ZigType *cc_enum_value = get_builtin_type(g, "CallingConvention"); |
| 3746 | 3752 | ||
| 3747 | ZigValue *result_val = analyze_const_value(g, child_scope, fn_proto->callconv_expr, | 3753 | ZigValue *result_val = analyze_const_value(g, child_scope, fn_proto->callconv_expr, |
src/stage1/ast_render.cpp+8-3| ... | @@ -123,8 +123,13 @@ static const char *export_string(bool is_export) { | ... | @@ -123,8 +123,13 @@ static const char *export_string(bool is_export) { |
| 123 | // zig_unreachable(); | 123 | // zig_unreachable(); |
| 124 | //} | 124 | //} |
| 125 | 125 | ||
| 126 | static const char *inline_string(bool is_inline) { | 126 | static const char *inline_string(FnInline fn_inline) { |
| 127 | return is_inline ? "inline" : ""; | 127 | switch (fn_inline) { |
| 128 | case FnInlineAlways: return "inline "; | ||
| 129 | case FnInlineNever: return "noinline "; | ||
| 130 | case FnInlineAuto: return ""; | ||
| 131 | } | ||
| 132 | zig_unreachable(); | ||
| 128 | } | 133 | } |
| 129 | 134 | ||
| 130 | static const char *const_or_var_string(bool is_const) { | 135 | static const char *const_or_var_string(bool is_const) { |
| ... | @@ -441,7 +446,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { | ... | @@ -441,7 +446,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 441 | const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod); | 446 | const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod); |
| 442 | const char *extern_str = extern_string(node->data.fn_proto.is_extern); | 447 | const char *extern_str = extern_string(node->data.fn_proto.is_extern); |
| 443 | const char *export_str = export_string(node->data.fn_proto.is_export); | 448 | const char *export_str = export_string(node->data.fn_proto.is_export); |
| 444 | const char *inline_str = inline_string(node->data.fn_proto.is_noinline); | 449 | const char *inline_str = inline_string(node->data.fn_proto.fn_inline); |
| 445 | fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str); | 450 | fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str); |
| 446 | if (node->data.fn_proto.name != nullptr) { | 451 | if (node->data.fn_proto.name != nullptr) { |
| 447 | print_symbol(ar, node->data.fn_proto.name); | 452 | print_symbol(ar, node->data.fn_proto.name); |
src/stage1/parser.cpp+14-3| ... | @@ -693,6 +693,8 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B | ... | @@ -693,6 +693,8 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B |
| 693 | Token *first = eat_token_if(pc, TokenIdKeywordExport); | 693 | Token *first = eat_token_if(pc, TokenIdKeywordExport); |
| 694 | if (first == nullptr) | 694 | if (first == nullptr) |
| 695 | first = eat_token_if(pc, TokenIdKeywordExtern); | 695 | first = eat_token_if(pc, TokenIdKeywordExtern); |
| 696 | if (first == nullptr) | ||
| 697 | first = eat_token_if(pc, TokenIdKeywordInline); | ||
| 696 | if (first == nullptr) | 698 | if (first == nullptr) |
| 697 | first = eat_token_if(pc, TokenIdKeywordNoInline); | 699 | first = eat_token_if(pc, TokenIdKeywordNoInline); |
| 698 | if (first != nullptr) { | 700 | if (first != nullptr) { |
| ... | @@ -700,7 +702,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B | ... | @@ -700,7 +702,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B |
| 700 | if (first->id == TokenIdKeywordExtern) | 702 | if (first->id == TokenIdKeywordExtern) |
| 701 | lib_name = eat_token_if(pc, TokenIdStringLiteral); | 703 | lib_name = eat_token_if(pc, TokenIdStringLiteral); |
| 702 | 704 | ||
| 703 | if (first->id != TokenIdKeywordNoInline) { | 705 | if (first->id != TokenIdKeywordNoInline && first->id != TokenIdKeywordInline) { |
| 704 | Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal); | 706 | Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal); |
| 705 | AstNode *var_decl = ast_parse_var_decl(pc); | 707 | AstNode *var_decl = ast_parse_var_decl(pc); |
| 706 | if (var_decl != nullptr) { | 708 | if (var_decl != nullptr) { |
| ... | @@ -737,8 +739,17 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B | ... | @@ -737,8 +739,17 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B |
| 737 | if (!fn_proto->data.fn_proto.is_extern) | 739 | if (!fn_proto->data.fn_proto.is_extern) |
| 738 | fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern; | 740 | fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern; |
| 739 | fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport; | 741 | fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport; |
| 740 | if (first->id == TokenIdKeywordNoInline) | 742 | switch (first->id) { |
| 741 | fn_proto->data.fn_proto.is_noinline = true; | 743 | case TokenIdKeywordInline: |
| 744 | fn_proto->data.fn_proto.fn_inline = FnInlineAlways; | ||
| 745 | break; | ||
| 746 | case TokenIdKeywordNoInline: | ||
| 747 | fn_proto->data.fn_proto.fn_inline = FnInlineNever; | ||
| 748 | break; | ||
| 749 | default: | ||
| 750 | fn_proto->data.fn_proto.fn_inline = FnInlineAuto; | ||
| 751 | break; | ||
| 752 | } | ||
| 742 | fn_proto->data.fn_proto.lib_name = token_buf(lib_name); | 753 | fn_proto->data.fn_proto.lib_name = token_buf(lib_name); |
| 743 | 754 | ||
| 744 | AstNode *res = fn_proto; | 755 | AstNode *res = fn_proto; |
src/tracy.zig+1-1| ... | @@ -31,7 +31,7 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct { | ... | @@ -31,7 +31,7 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct { |
| 31 | pub fn end(self: Ctx) void {} | 31 | pub fn end(self: Ctx) void {} |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | pub fn trace(comptime src: std.builtin.SourceLocation) callconv(.Inline) Ctx { | 34 | pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx { |
| 35 | if (!enable) return .{}; | 35 | if (!enable) return .{}; |
| 36 | 36 | ||
| 37 | const loc: ___tracy_source_location_data = .{ | 37 | const loc: ___tracy_source_location_data = .{ |
src/translate_c/ast.zig+14-32| ... | @@ -2689,6 +2689,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex { | ... | @@ -2689,6 +2689,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex { |
| 2689 | fn renderMacroFunc(c: *Context, node: Node) !NodeIndex { | 2689 | fn renderMacroFunc(c: *Context, node: Node) !NodeIndex { |
| 2690 | const payload = node.castTag(.pub_inline_fn).?.data; | 2690 | const payload = node.castTag(.pub_inline_fn).?.data; |
| 2691 | _ = try c.addToken(.keyword_pub, "pub"); | 2691 | _ = try c.addToken(.keyword_pub, "pub"); |
| 2692 | _ = try c.addToken(.keyword_inline, "inline"); | ||
| 2692 | const fn_token = try c.addToken(.keyword_fn, "fn"); | 2693 | const fn_token = try c.addToken(.keyword_fn, "fn"); |
| 2693 | _ = try c.addIdentifier(payload.name); | 2694 | _ = try c.addIdentifier(payload.name); |
| 2694 | 2695 | ||
| ... | @@ -2697,50 +2698,31 @@ fn renderMacroFunc(c: *Context, node: Node) !NodeIndex { | ... | @@ -2697,50 +2698,31 @@ fn renderMacroFunc(c: *Context, node: Node) !NodeIndex { |
| 2697 | var span: NodeSubRange = undefined; | 2698 | var span: NodeSubRange = undefined; |
| 2698 | if (params.items.len > 1) span = try c.listToSpan(params.items); | 2699 | if (params.items.len > 1) span = try c.listToSpan(params.items); |
| 2699 | 2700 | ||
| 2700 | const callconv_expr = blk: { | ||
| 2701 | _ = try c.addToken(.keyword_callconv, "callconv"); | ||
| 2702 | _ = try c.addToken(.l_paren, "("); | ||
| 2703 | _ = try c.addToken(.period, "."); | ||
| 2704 | const res = try c.addNode(.{ | ||
| 2705 | .tag = .enum_literal, | ||
| 2706 | .main_token = try c.addToken(.identifier, "Inline"), | ||
| 2707 | .data = undefined, | ||
| 2708 | }); | ||
| 2709 | _ = try c.addToken(.r_paren, ")"); | ||
| 2710 | break :blk res; | ||
| 2711 | }; | ||
| 2712 | const return_type_expr = try renderNodeGrouped(c, payload.return_type); | 2701 | const return_type_expr = try renderNodeGrouped(c, payload.return_type); |
| 2713 | 2702 | ||
| 2714 | const fn_proto = try blk: { | 2703 | const fn_proto = blk: { |
| 2715 | if (params.items.len < 2) | 2704 | if (params.items.len < 2) { |
| 2716 | break :blk c.addNode(.{ | 2705 | break :blk try c.addNode(.{ |
| 2717 | .tag = .fn_proto_one, | 2706 | .tag = .fn_proto_simple, |
| 2718 | .main_token = fn_token, | 2707 | .main_token = fn_token, |
| 2719 | .data = .{ | 2708 | .data = .{ |
| 2720 | .lhs = try c.addExtra(std.zig.ast.Node.FnProtoOne{ | 2709 | .lhs = params.items[0], |
| 2721 | .param = params.items[0], | ||
| 2722 | .align_expr = 0, | ||
| 2723 | .section_expr = 0, | ||
| 2724 | .callconv_expr = callconv_expr, | ||
| 2725 | }), | ||
| 2726 | .rhs = return_type_expr, | 2710 | .rhs = return_type_expr, |
| 2727 | }, | 2711 | }, |
| 2728 | }) | 2712 | }); |
| 2729 | else | 2713 | } else { |
| 2730 | break :blk c.addNode(.{ | 2714 | break :blk try c.addNode(.{ |
| 2731 | .tag = .fn_proto, | 2715 | .tag = .fn_proto_multi, |
| 2732 | .main_token = fn_token, | 2716 | .main_token = fn_token, |
| 2733 | .data = .{ | 2717 | .data = .{ |
| 2734 | .lhs = try c.addExtra(std.zig.ast.Node.FnProto{ | 2718 | .lhs = try c.addExtra(std.zig.ast.Node.SubRange{ |
| 2735 | .params_start = span.start, | 2719 | .start = span.start, |
| 2736 | .params_end = span.end, | 2720 | .end = span.end, |
| 2737 | .align_expr = 0, | ||
| 2738 | .section_expr = 0, | ||
| 2739 | .callconv_expr = callconv_expr, | ||
| 2740 | }), | 2721 | }), |
| 2741 | .rhs = return_type_expr, | 2722 | .rhs = return_type_expr, |
| 2742 | }, | 2723 | }, |
| 2743 | }); | 2724 | }); |
| 2725 | } | ||
| 2744 | }; | 2726 | }; |
| 2745 | return c.addNode(.{ | 2727 | return c.addNode(.{ |
| 2746 | .tag = .fn_decl, | 2728 | .tag = .fn_decl, |
test/translate_c.zig+29-29| ... | @@ -232,7 +232,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -232,7 +232,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 232 | cases.add("use cast param as macro fn return type", | 232 | cases.add("use cast param as macro fn return type", |
| 233 | \\#define MEM_PHYSICAL_TO_K0(x) (void*)((u32)(x) + SYS_BASE_CACHED) | 233 | \\#define MEM_PHYSICAL_TO_K0(x) (void*)((u32)(x) + SYS_BASE_CACHED) |
| 234 | , &[_][]const u8{ | 234 | , &[_][]const u8{ |
| 235 | \\pub fn MEM_PHYSICAL_TO_K0(x: anytype) callconv(.Inline) ?*c_void { | 235 | \\pub inline fn MEM_PHYSICAL_TO_K0(x: anytype) ?*c_void { |
| 236 | \\ return @import("std").meta.cast(?*c_void, @import("std").meta.cast(u32, x) + SYS_BASE_CACHED); | 236 | \\ return @import("std").meta.cast(?*c_void, @import("std").meta.cast(u32, x) + SYS_BASE_CACHED); |
| 237 | \\} | 237 | \\} |
| 238 | }); | 238 | }); |
| ... | @@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 273 | , | 273 | , |
| 274 | \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9)); | 274 | \\pub const VALUE = ((((@as(c_int, 1) + (@as(c_int, 2) * @as(c_int, 3))) + (@as(c_int, 4) * @as(c_int, 5))) + @as(c_int, 6)) << @as(c_int, 7)) | @boolToInt(@as(c_int, 8) == @as(c_int, 9)); |
| 275 | , | 275 | , |
| 276 | \\pub fn _AL_READ3BYTES(p: anytype) callconv(.Inline) @TypeOf((@import("std").meta.cast([*c]u8, p).* | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) { | 276 | \\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf((@import("std").meta.cast([*c]u8, p).* | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16))) { |
| 277 | \\ return (@import("std").meta.cast([*c]u8, p).* | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16)); | 277 | \\ return (@import("std").meta.cast([*c]u8, p).* | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 1)).* << @as(c_int, 8))) | ((@import("std").meta.cast([*c]u8, p) + @as(c_int, 2)).* << @as(c_int, 16)); |
| 278 | \\} | 278 | \\} |
| 279 | }); | 279 | }); |
| ... | @@ -345,7 +345,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -345,7 +345,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 345 | \\}; | 345 | \\}; |
| 346 | \\pub const Color = struct_Color; | 346 | \\pub const Color = struct_Color; |
| 347 | , | 347 | , |
| 348 | \\pub fn CLITERAL(type_1: anytype) callconv(.Inline) @TypeOf(type_1) { | 348 | \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) { |
| 349 | \\ return type_1; | 349 | \\ return type_1; |
| 350 | \\} | 350 | \\} |
| 351 | , | 351 | , |
| ... | @@ -380,7 +380,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -380,7 +380,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 380 | cases.add("correct semicolon after infixop", | 380 | cases.add("correct semicolon after infixop", |
| 381 | \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) | 381 | \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) |
| 382 | , &[_][]const u8{ | 382 | , &[_][]const u8{ |
| 383 | \\pub fn __ferror_unlocked_body(_fp: anytype) callconv(.Inline) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { | 383 | \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf((_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0)) { |
| 384 | \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); | 384 | \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0); |
| 385 | \\} | 385 | \\} |
| 386 | }); | 386 | }); |
| ... | @@ -389,7 +389,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -389,7 +389,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 389 | \\#define FOO(x) ((x >= 0) + (x >= 0)) | 389 | \\#define FOO(x) ((x >= 0) + (x >= 0)) |
| 390 | \\#define BAR 1 && 2 > 4 | 390 | \\#define BAR 1 && 2 > 4 |
| 391 | , &[_][]const u8{ | 391 | , &[_][]const u8{ |
| 392 | \\pub fn FOO(x: anytype) callconv(.Inline) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) { | 392 | \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0))) { |
| 393 | \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0)); | 393 | \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0)); |
| 394 | \\} | 394 | \\} |
| 395 | , | 395 | , |
| ... | @@ -438,7 +438,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -438,7 +438,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 438 | \\ break :blk bar; | 438 | \\ break :blk bar; |
| 439 | \\}; | 439 | \\}; |
| 440 | , | 440 | , |
| 441 | \\pub fn bar(x: anytype) callconv(.Inline) @TypeOf(baz(@as(c_int, 1), @as(c_int, 2))) { | 441 | \\pub inline fn bar(x: anytype) @TypeOf(baz(@as(c_int, 1), @as(c_int, 2))) { |
| 442 | \\ return blk: { | 442 | \\ return blk: { |
| 443 | \\ _ = &x; | 443 | \\ _ = &x; |
| 444 | \\ _ = @as(c_int, 3); | 444 | \\ _ = @as(c_int, 3); |
| ... | @@ -1782,13 +1782,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1782,13 +1782,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1782 | , &[_][]const u8{ | 1782 | , &[_][]const u8{ |
| 1783 | \\pub extern var fn_ptr: ?fn () callconv(.C) void; | 1783 | \\pub extern var fn_ptr: ?fn () callconv(.C) void; |
| 1784 | , | 1784 | , |
| 1785 | \\pub fn foo() callconv(.Inline) void { | 1785 | \\pub inline fn foo() void { |
| 1786 | \\ return fn_ptr.?(); | 1786 | \\ return fn_ptr.?(); |
| 1787 | \\} | 1787 | \\} |
| 1788 | , | 1788 | , |
| 1789 | \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8; | 1789 | \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8; |
| 1790 | , | 1790 | , |
| 1791 | \\pub fn bar(arg_1: c_int, arg_2: f32) callconv(.Inline) u8 { | 1791 | \\pub inline fn bar(arg_1: c_int, arg_2: f32) u8 { |
| 1792 | \\ return fn_ptr2.?(arg_1, arg_2); | 1792 | \\ return fn_ptr2.?(arg_1, arg_2); |
| 1793 | \\} | 1793 | \\} |
| 1794 | }); | 1794 | }); |
| ... | @@ -1821,7 +1821,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1821,7 +1821,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1821 | , | 1821 | , |
| 1822 | \\pub const glClearPFN = PFNGLCLEARPROC; | 1822 | \\pub const glClearPFN = PFNGLCLEARPROC; |
| 1823 | , | 1823 | , |
| 1824 | \\pub fn glClearUnion(arg_2: GLbitfield) callconv(.Inline) void { | 1824 | \\pub inline fn glClearUnion(arg_2: GLbitfield) void { |
| 1825 | \\ return glProcs.gl.Clear.?(arg_2); | 1825 | \\ return glProcs.gl.Clear.?(arg_2); |
| 1826 | \\} | 1826 | \\} |
| 1827 | , | 1827 | , |
| ... | @@ -1842,15 +1842,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1842,15 +1842,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1842 | , &[_][]const u8{ | 1842 | , &[_][]const u8{ |
| 1843 | \\pub extern var c: c_int; | 1843 | \\pub extern var c: c_int; |
| 1844 | , | 1844 | , |
| 1845 | \\pub fn BASIC(c_1: anytype) callconv(.Inline) @TypeOf(c_1 * @as(c_int, 2)) { | 1845 | \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * @as(c_int, 2)) { |
| 1846 | \\ return c_1 * @as(c_int, 2); | 1846 | \\ return c_1 * @as(c_int, 2); |
| 1847 | \\} | 1847 | \\} |
| 1848 | , | 1848 | , |
| 1849 | \\pub fn FOO(L: anytype, b: anytype) callconv(.Inline) @TypeOf(L + b) { | 1849 | \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) { |
| 1850 | \\ return L + b; | 1850 | \\ return L + b; |
| 1851 | \\} | 1851 | \\} |
| 1852 | , | 1852 | , |
| 1853 | \\pub fn BAR() callconv(.Inline) @TypeOf(c * c) { | 1853 | \\pub inline fn BAR() @TypeOf(c * c) { |
| 1854 | \\ return c * c; | 1854 | \\ return c * c; |
| 1855 | \\} | 1855 | \\} |
| 1856 | }); | 1856 | }); |
| ... | @@ -2549,7 +2549,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2549,7 +2549,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2549 | cases.add("macro call", | 2549 | cases.add("macro call", |
| 2550 | \\#define CALL(arg) bar(arg) | 2550 | \\#define CALL(arg) bar(arg) |
| 2551 | , &[_][]const u8{ | 2551 | , &[_][]const u8{ |
| 2552 | \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar(arg)) { | 2552 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) { |
| 2553 | \\ return bar(arg); | 2553 | \\ return bar(arg); |
| 2554 | \\} | 2554 | \\} |
| 2555 | }); | 2555 | }); |
| ... | @@ -2557,7 +2557,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2557,7 +2557,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2557 | cases.add("macro call with no args", | 2557 | cases.add("macro call with no args", |
| 2558 | \\#define CALL(arg) bar() | 2558 | \\#define CALL(arg) bar() |
| 2559 | , &[_][]const u8{ | 2559 | , &[_][]const u8{ |
| 2560 | \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar()) { | 2560 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar()) { |
| 2561 | \\ return bar(); | 2561 | \\ return bar(); |
| 2562 | \\} | 2562 | \\} |
| 2563 | }); | 2563 | }); |
| ... | @@ -3120,7 +3120,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3120,7 +3120,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3120 | \\#define BAR (void*) a | 3120 | \\#define BAR (void*) a |
| 3121 | \\#define BAZ (uint32_t)(2) | 3121 | \\#define BAZ (uint32_t)(2) |
| 3122 | , &[_][]const u8{ | 3122 | , &[_][]const u8{ |
| 3123 | \\pub fn FOO(bar: anytype) callconv(.Inline) @TypeOf(baz(@import("std").meta.cast(?*c_void, baz))) { | 3123 | \\pub inline fn FOO(bar: anytype) @TypeOf(baz(@import("std").meta.cast(?*c_void, baz))) { |
| 3124 | \\ return baz(@import("std").meta.cast(?*c_void, baz)); | 3124 | \\ return baz(@import("std").meta.cast(?*c_void, baz)); |
| 3125 | \\} | 3125 | \\} |
| 3126 | , | 3126 | , |
| ... | @@ -3160,11 +3160,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3160,11 +3160,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3160 | \\#define MIN(a, b) ((b) < (a) ? (b) : (a)) | 3160 | \\#define MIN(a, b) ((b) < (a) ? (b) : (a)) |
| 3161 | \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) | 3161 | \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) |
| 3162 | , &[_][]const u8{ | 3162 | , &[_][]const u8{ |
| 3163 | \\pub fn MIN(a: anytype, b: anytype) callconv(.Inline) @TypeOf(if (b < a) b else a) { | 3163 | \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) { |
| 3164 | \\ return if (b < a) b else a; | 3164 | \\ return if (b < a) b else a; |
| 3165 | \\} | 3165 | \\} |
| 3166 | , | 3166 | , |
| 3167 | \\pub fn MAX(a: anytype, b: anytype) callconv(.Inline) @TypeOf(if (b > a) b else a) { | 3167 | \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) { |
| 3168 | \\ return if (b > a) b else a; | 3168 | \\ return if (b > a) b else a; |
| 3169 | \\} | 3169 | \\} |
| 3170 | }); | 3170 | }); |
| ... | @@ -3351,7 +3351,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3351,7 +3351,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3351 | \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen) | 3351 | \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen) |
| 3352 | \\ | 3352 | \\ |
| 3353 | , &[_][]const u8{ | 3353 | , &[_][]const u8{ |
| 3354 | \\pub fn DefaultScreen(dpy: anytype) callconv(.Inline) @TypeOf(@import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen) { | 3354 | \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf(@import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen) { |
| 3355 | \\ return @import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen; | 3355 | \\ return @import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen; |
| 3356 | \\} | 3356 | \\} |
| 3357 | }); | 3357 | }); |
| ... | @@ -3501,17 +3501,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3501,17 +3501,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3501 | }); | 3501 | }); |
| 3502 | 3502 | ||
| 3503 | cases.add("global assembly", | 3503 | cases.add("global assembly", |
| 3504 | \\__asm__(".globl func\n\t" | 3504 | \\__asm__(".globl func\n\t" |
| 3505 | \\ ".type func, @function\n\t" | 3505 | \\ ".type func, @function\n\t" |
| 3506 | \\ "func:\n\t" | 3506 | \\ "func:\n\t" |
| 3507 | \\ ".cfi_startproc\n\t" | 3507 | \\ ".cfi_startproc\n\t" |
| 3508 | \\ "movl $42, %eax\n\t" | 3508 | \\ "movl $42, %eax\n\t" |
| 3509 | \\ "ret\n\t" | 3509 | \\ "ret\n\t" |
| 3510 | \\ ".cfi_endproc"); | 3510 | \\ ".cfi_endproc"); |
| 3511 | , &[_][]const u8{ | 3511 | , &[_][]const u8{ |
| 3512 | \\comptime { | 3512 | \\comptime { |
| 3513 | \\ asm (".globl func\n\t.type func, @function\n\tfunc:\n\t.cfi_startproc\n\tmovl $42, %eax\n\tret\n\t.cfi_endproc"); | 3513 | \\ asm (".globl func\n\t.type func, @function\n\tfunc:\n\t.cfi_startproc\n\tmovl $42, %eax\n\tret\n\t.cfi_endproc"); |
| 3514 | \\} | 3514 | \\} |
| 3515 | }); | 3515 | }); |
| 3516 | 3516 | ||
| 3517 | cases.add("Demote function that initializes opaque struct", | 3517 | cases.add("Demote function that initializes opaque struct", |