authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-22 20:56:30-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-05-22 20:56:30-04:00
log1c636e2564e2fc2e8e4b6b1edbc782592ee3d2d7
tree5311dc81615ff9efa2b4840070371f54182f8bee
parent9baf8917725ede02d9fc1aeebe253842174ee57b
parent563ea60a86a733f53f2394a11cb9ec4e56063fa3
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #8844 from ifreund/inline

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) {
6868};
6969
7070/// Signals the processor that it is inside a busy-wait spin-loop ("spin lock").
71pub fn spinLoopHint() callconv(.Inline) void {
71pub inline fn spinLoopHint() void {
7272 switch (std.Target.current.cpu.arch) {
7373 .i386, .x86_64 => {
7474 asm volatile ("pause" ::: "memory");
lib/std/bit_set.zig+5-5
......@@ -83,7 +83,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
8383 }
8484
8585 /// 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 {
8787 return bit_length;
8888 }
8989
......@@ -310,7 +310,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
310310 }
311311
312312 /// 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 {
314314 return bit_length;
315315 }
316316
......@@ -574,7 +574,7 @@ pub const DynamicBitSetUnmanaged = struct {
574574 }
575575
576576 /// 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 {
578578 return self.bit_length;
579579 }
580580
......@@ -789,7 +789,7 @@ pub const DynamicBitSet = struct {
789789 }
790790
791791 /// 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 {
793793 return self.unmanaged.capacity();
794794 }
795795
......@@ -969,7 +969,7 @@ fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) typ
969969 // isn't a next word. If the next word is the
970970 // last word, mask off the padding bits so we
971971 // 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 {
973973 var word = switch (direction) {
974974 .forward => self.words_remain[0],
975975 .reverse => self.words_remain[self.words_remain.len - 1],
lib/std/c/builtins.zig+46-46
......@@ -6,136 +6,136 @@
66
77const std = @import("std");
88
9pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 {
9pub inline fn __builtin_bswap16(val: u16) u16 {
1010 return @byteSwap(u16, val);
1111}
12pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 {
12pub inline fn __builtin_bswap32(val: u32) u32 {
1313 return @byteSwap(u32, val);
1414}
15pub fn __builtin_bswap64(val: u64) callconv(.Inline) u64 {
15pub inline fn __builtin_bswap64(val: u64) u64 {
1616 return @byteSwap(u64, val);
1717}
1818
19pub fn __builtin_signbit(val: f64) callconv(.Inline) c_int {
19pub inline fn __builtin_signbit(val: f64) c_int {
2020 return @boolToInt(std.math.signbit(val));
2121}
22pub fn __builtin_signbitf(val: f32) callconv(.Inline) c_int {
22pub inline fn __builtin_signbitf(val: f32) c_int {
2323 return @boolToInt(std.math.signbit(val));
2424}
2525
26pub fn __builtin_popcount(val: c_uint) callconv(.Inline) c_int {
26pub inline fn __builtin_popcount(val: c_uint) c_int {
2727 // popcount of a c_uint will never exceed the capacity of a c_int
2828 @setRuntimeSafety(false);
2929 return @bitCast(c_int, @as(c_uint, @popCount(c_uint, val)));
3030}
31pub fn __builtin_ctz(val: c_uint) callconv(.Inline) c_int {
31pub inline fn __builtin_ctz(val: c_uint) c_int {
3232 // Returns the number of trailing 0-bits in val, starting at the least significant bit position.
3333 // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint
3434 @setRuntimeSafety(false);
3535 return @bitCast(c_int, @as(c_uint, @ctz(c_uint, val)));
3636}
37pub fn __builtin_clz(val: c_uint) callconv(.Inline) c_int {
37pub inline fn __builtin_clz(val: c_uint) c_int {
3838 // Returns the number of leading 0-bits in x, starting at the most significant bit position.
3939 // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint
4040 @setRuntimeSafety(false);
4141 return @bitCast(c_int, @as(c_uint, @clz(c_uint, val)));
4242}
4343
44pub fn __builtin_sqrt(val: f64) callconv(.Inline) f64 {
44pub inline fn __builtin_sqrt(val: f64) f64 {
4545 return @sqrt(val);
4646}
47pub fn __builtin_sqrtf(val: f32) callconv(.Inline) f32 {
47pub inline fn __builtin_sqrtf(val: f32) f32 {
4848 return @sqrt(val);
4949}
5050
51pub fn __builtin_sin(val: f64) callconv(.Inline) f64 {
51pub inline fn __builtin_sin(val: f64) f64 {
5252 return @sin(val);
5353}
54pub fn __builtin_sinf(val: f32) callconv(.Inline) f32 {
54pub inline fn __builtin_sinf(val: f32) f32 {
5555 return @sin(val);
5656}
57pub fn __builtin_cos(val: f64) callconv(.Inline) f64 {
57pub inline fn __builtin_cos(val: f64) f64 {
5858 return @cos(val);
5959}
60pub fn __builtin_cosf(val: f32) callconv(.Inline) f32 {
60pub inline fn __builtin_cosf(val: f32) f32 {
6161 return @cos(val);
6262}
6363
64pub fn __builtin_exp(val: f64) callconv(.Inline) f64 {
64pub inline fn __builtin_exp(val: f64) f64 {
6565 return @exp(val);
6666}
67pub fn __builtin_expf(val: f32) callconv(.Inline) f32 {
67pub inline fn __builtin_expf(val: f32) f32 {
6868 return @exp(val);
6969}
70pub fn __builtin_exp2(val: f64) callconv(.Inline) f64 {
70pub inline fn __builtin_exp2(val: f64) f64 {
7171 return @exp2(val);
7272}
73pub fn __builtin_exp2f(val: f32) callconv(.Inline) f32 {
73pub inline fn __builtin_exp2f(val: f32) f32 {
7474 return @exp2(val);
7575}
76pub fn __builtin_log(val: f64) callconv(.Inline) f64 {
76pub inline fn __builtin_log(val: f64) f64 {
7777 return @log(val);
7878}
79pub fn __builtin_logf(val: f32) callconv(.Inline) f32 {
79pub inline fn __builtin_logf(val: f32) f32 {
8080 return @log(val);
8181}
82pub fn __builtin_log2(val: f64) callconv(.Inline) f64 {
82pub inline fn __builtin_log2(val: f64) f64 {
8383 return @log2(val);
8484}
85pub fn __builtin_log2f(val: f32) callconv(.Inline) f32 {
85pub inline fn __builtin_log2f(val: f32) f32 {
8686 return @log2(val);
8787}
88pub fn __builtin_log10(val: f64) callconv(.Inline) f64 {
88pub inline fn __builtin_log10(val: f64) f64 {
8989 return @log10(val);
9090}
91pub fn __builtin_log10f(val: f32) callconv(.Inline) f32 {
91pub inline fn __builtin_log10f(val: f32) f32 {
9292 return @log10(val);
9393}
9494
9595// Standard C Library bug: The absolute value of the most negative integer remains negative.
96pub fn __builtin_abs(val: c_int) callconv(.Inline) c_int {
96pub inline fn __builtin_abs(val: c_int) c_int {
9797 return std.math.absInt(val) catch std.math.minInt(c_int);
9898}
99pub fn __builtin_fabs(val: f64) callconv(.Inline) f64 {
99pub inline fn __builtin_fabs(val: f64) f64 {
100100 return @fabs(val);
101101}
102pub fn __builtin_fabsf(val: f32) callconv(.Inline) f32 {
102pub inline fn __builtin_fabsf(val: f32) f32 {
103103 return @fabs(val);
104104}
105105
106pub fn __builtin_floor(val: f64) callconv(.Inline) f64 {
106pub inline fn __builtin_floor(val: f64) f64 {
107107 return @floor(val);
108108}
109pub fn __builtin_floorf(val: f32) callconv(.Inline) f32 {
109pub inline fn __builtin_floorf(val: f32) f32 {
110110 return @floor(val);
111111}
112pub fn __builtin_ceil(val: f64) callconv(.Inline) f64 {
112pub inline fn __builtin_ceil(val: f64) f64 {
113113 return @ceil(val);
114114}
115pub fn __builtin_ceilf(val: f32) callconv(.Inline) f32 {
115pub inline fn __builtin_ceilf(val: f32) f32 {
116116 return @ceil(val);
117117}
118pub fn __builtin_trunc(val: f64) callconv(.Inline) f64 {
118pub inline fn __builtin_trunc(val: f64) f64 {
119119 return @trunc(val);
120120}
121pub fn __builtin_truncf(val: f32) callconv(.Inline) f32 {
121pub inline fn __builtin_truncf(val: f32) f32 {
122122 return @trunc(val);
123123}
124pub fn __builtin_round(val: f64) callconv(.Inline) f64 {
124pub inline fn __builtin_round(val: f64) f64 {
125125 return @round(val);
126126}
127pub fn __builtin_roundf(val: f32) callconv(.Inline) f32 {
127pub inline fn __builtin_roundf(val: f32) f32 {
128128 return @round(val);
129129}
130130
131pub fn __builtin_strlen(s: [*c]const u8) callconv(.Inline) usize {
131pub inline fn __builtin_strlen(s: [*c]const u8) usize {
132132 return std.mem.lenZ(s);
133133}
134pub fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.Inline) c_int {
134pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int {
135135 return @as(c_int, std.cstr.cmp(s1, s2));
136136}
137137
138pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) usize {
138pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) usize {
139139 // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
140140 // If it is not possible to determine which objects ptr points to at compile time,
141141 // __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
145145 unreachable;
146146}
147147
148pub fn __builtin___memset_chk(
148pub inline fn __builtin___memset_chk(
149149 dst: ?*c_void,
150150 val: c_int,
151151 len: usize,
152152 remaining: usize,
153) callconv(.Inline) ?*c_void {
153) ?*c_void {
154154 if (len > remaining) @panic("std.c.builtins.memset_chk called with len > remaining");
155155 return __builtin_memset(dst, val, len);
156156}
157157
158pub fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) callconv(.Inline) ?*c_void {
158pub inline fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) ?*c_void {
159159 const dst_cast = @ptrCast([*c]u8, dst);
160160 @memset(dst_cast, @bitCast(u8, @truncate(i8, val)), len);
161161 return dst;
162162}
163163
164pub fn __builtin___memcpy_chk(
164pub inline fn __builtin___memcpy_chk(
165165 noalias dst: ?*c_void,
166166 noalias src: ?*const c_void,
167167 len: usize,
168168 remaining: usize,
169) callconv(.Inline) ?*c_void {
169) ?*c_void {
170170 if (len > remaining) @panic("std.c.builtins.memcpy_chk called with len > remaining");
171171 return __builtin_memcpy(dst, src, len);
172172}
173173
174pub fn __builtin_memcpy(
174pub inline fn __builtin_memcpy(
175175 noalias dst: ?*c_void,
176176 noalias src: ?*const c_void,
177177 len: usize,
178) callconv(.Inline) ?*c_void {
178) ?*c_void {
179179 const dst_cast = @ptrCast([*c]u8, dst);
180180 const src_cast = @ptrCast([*c]const u8, src);
181181
......@@ -185,7 +185,7 @@ pub fn __builtin_memcpy(
185185
186186/// The return value of __builtin_expect is `expr`. `c` is the expected value
187187/// of `expr` and is used as a hint to the compiler in C. Here it is unused.
188pub fn __builtin_expect(expr: c_long, c: c_long) callconv(.Inline) c_long {
188pub inline fn __builtin_expect(expr: c_long, c: c_long) c_long {
189189 return expr;
190190}
191191
lib/std/compress/deflate.zig+1-1
......@@ -209,7 +209,7 @@ pub fn InflateStream(comptime ReaderType: type) type {
209209
210210 // Insert a single byte into the window.
211211 // Assumes there's enough space.
212 fn appendUnsafe(self: *WSelf, value: u8) callconv(.Inline) void {
212 inline fn appendUnsafe(self: *WSelf, value: u8) void {
213213 self.buf[self.wi] = value;
214214 self.wi = (self.wi + 1) & (self.buf.len - 1);
215215 self.el += 1;
lib/std/crypto/25519/curve25519.zig+2-2
......@@ -20,12 +20,12 @@ pub const Curve25519 = struct {
2020 x: Fe,
2121
2222 /// 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 {
2424 return .{ .x = Fe.fromBytes(s) };
2525 }
2626
2727 /// Encode a Curve25519 point.
28 pub fn toBytes(p: Curve25519) callconv(.Inline) [32]u8 {
28 pub inline fn toBytes(p: Curve25519) [32]u8 {
2929 return p.x.toBytes();
3030 }
3131
lib/std/crypto/25519/edwards25519.zig+3-3
......@@ -91,7 +91,7 @@ pub const Edwards25519 = struct {
9191 }
9292
9393 /// Flip the sign of the X coordinate.
94 pub fn neg(p: Edwards25519) callconv(.Inline) Edwards25519 {
94 pub inline fn neg(p: Edwards25519) Edwards25519 {
9595 return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() };
9696 }
9797
......@@ -136,14 +136,14 @@ pub const Edwards25519 = struct {
136136 return p.add(q.neg());
137137 }
138138
139 fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) callconv(.Inline) void {
139 inline fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) void {
140140 p.x.cMov(a.x, c);
141141 p.y.cMov(a.y, c);
142142 p.z.cMov(a.z, c);
143143 p.t.cMov(a.t, c);
144144 }
145145
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 {
147147 var t = Edwards25519.identityElement;
148148 comptime var i: u8 = 1;
149149 inline while (i < pc.len) : (i += 1) {
lib/std/crypto/25519/field.zig+14-14
......@@ -56,7 +56,7 @@ pub const Fe = struct {
5656 pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } };
5757
5858 /// 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 {
6060 var reduced = fe;
6161 reduced.reduce();
6262 const limbs = reduced.limbs;
......@@ -64,7 +64,7 @@ pub const Fe = struct {
6464 }
6565
6666 /// 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 {
6868 return a.sub(b).isZero();
6969 }
7070
......@@ -168,7 +168,7 @@ pub const Fe = struct {
168168 }
169169
170170 /// 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 {
172172 var fe: Fe = undefined;
173173 comptime var i = 0;
174174 inline while (i < 5) : (i += 1) {
......@@ -178,7 +178,7 @@ pub const Fe = struct {
178178 }
179179
180180 /// 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 {
182182 var fe = b;
183183 comptime var i = 0;
184184 inline while (i < 4) : (i += 1) {
......@@ -197,17 +197,17 @@ pub const Fe = struct {
197197 }
198198
199199 /// Negate a field element
200 pub fn neg(a: Fe) callconv(.Inline) Fe {
200 pub inline fn neg(a: Fe) Fe {
201201 return zero.sub(a);
202202 }
203203
204204 /// 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 {
206206 return (a.toBytes()[0] & 1) != 0;
207207 }
208208
209209 /// 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 {
211211 const mask: u64 = 0 -% c;
212212 var x = fe.*;
213213 comptime var i = 0;
......@@ -248,7 +248,7 @@ pub const Fe = struct {
248248 }
249249 }
250250
251 fn _carry128(r: *[5]u128) callconv(.Inline) Fe {
251 inline fn _carry128(r: *[5]u128) Fe {
252252 var rs: [5]u64 = undefined;
253253 comptime var i = 0;
254254 inline while (i < 4) : (i += 1) {
......@@ -269,7 +269,7 @@ pub const Fe = struct {
269269 }
270270
271271 /// 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 {
273273 var ax: [5]u128 = undefined;
274274 var bx: [5]u128 = undefined;
275275 var a19: [5]u128 = undefined;
......@@ -292,7 +292,7 @@ pub const Fe = struct {
292292 return _carry128(&r);
293293 }
294294
295 fn _sq(a: Fe, comptime double: bool) callconv(.Inline) Fe {
295 inline fn _sq(a: Fe, comptime double: bool) Fe {
296296 var ax: [5]u128 = undefined;
297297 var r: [5]u128 = undefined;
298298 comptime var i = 0;
......@@ -321,17 +321,17 @@ pub const Fe = struct {
321321 }
322322
323323 /// Square a field element
324 pub fn sq(a: Fe) callconv(.Inline) Fe {
324 pub inline fn sq(a: Fe) Fe {
325325 return _sq(a, false);
326326 }
327327
328328 /// Square and double a field element
329 pub fn sq2(a: Fe) callconv(.Inline) Fe {
329 pub inline fn sq2(a: Fe) Fe {
330330 return _sq(a, true);
331331 }
332332
333333 /// 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 {
335335 const sn = @intCast(u128, n);
336336 var fe: Fe = undefined;
337337 var x: u128 = 0;
......@@ -346,7 +346,7 @@ pub const Fe = struct {
346346 }
347347
348348 /// 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 {
350350 var i: usize = 0;
351351 var fe = a;
352352 while (i < n) : (i += 1) {
lib/std/crypto/25519/ristretto255.zig+4-4
......@@ -47,7 +47,7 @@ pub const Ristretto255 = struct {
4747 }
4848
4949 /// Reject the neutral element.
50 pub fn rejectIdentity(p: Ristretto255) callconv(.Inline) IdentityElementError!void {
50 pub inline fn rejectIdentity(p: Ristretto255) IdentityElementError!void {
5151 return p.p.rejectIdentity();
5252 }
5353
......@@ -146,19 +146,19 @@ pub const Ristretto255 = struct {
146146 }
147147
148148 /// Double a Ristretto255 element.
149 pub fn dbl(p: Ristretto255) callconv(.Inline) Ristretto255 {
149 pub inline fn dbl(p: Ristretto255) Ristretto255 {
150150 return .{ .p = p.p.dbl() };
151151 }
152152
153153 /// 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 {
155155 return .{ .p = p.p.add(q.p) };
156156 }
157157
158158 /// Multiply a Ristretto255 element with a scalar.
159159 /// Return error.WeakPublicKey if the resulting element is
160160 /// 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 {
162162 return Ristretto255{ .p = try p.p.mul(s) };
163163 }
164164
lib/std/crypto/25519/scalar.zig+1-1
......@@ -48,7 +48,7 @@ pub fn reduce64(s: [64]u8) [32]u8 {
4848
4949/// Perform the X25519 "clamping" operation.
5050/// The scalar is then guaranteed to be a multiple of the cofactor.
51pub fn clamp(s: *[32]u8) callconv(.Inline) void {
51pub inline fn clamp(s: *[32]u8) void {
5252 s[0] &= 248;
5353 s[31] = (s[31] & 127) | 64;
5454}
lib/std/crypto/aegis.zig+2-2
......@@ -36,7 +36,7 @@ const State128L = struct {
3636 return state;
3737 }
3838
39 fn update(state: *State128L, d1: AesBlock, d2: AesBlock) callconv(.Inline) void {
39 inline fn update(state: *State128L, d1: AesBlock, d2: AesBlock) void {
4040 const blocks = &state.blocks;
4141 const tmp = blocks[7];
4242 comptime var i: usize = 7;
......@@ -208,7 +208,7 @@ const State256 = struct {
208208 return state;
209209 }
210210
211 fn update(state: *State256, d: AesBlock) callconv(.Inline) void {
211 inline fn update(state: *State256, d: AesBlock) void {
212212 const blocks = &state.blocks;
213213 const tmp = blocks[5].encrypt(blocks[0]);
214214 comptime var i: usize = 5;
lib/std/crypto/aes/aesni.zig+16-16
......@@ -19,24 +19,24 @@ pub const Block = struct {
1919 repr: BlockVec,
2020
2121 /// 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 {
2323 const repr = mem.bytesToValue(BlockVec, bytes);
2424 return Block{ .repr = repr };
2525 }
2626
2727 /// 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 {
2929 return mem.toBytes(block.repr);
3030 }
3131
3232 /// 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 {
3434 const x = block.repr ^ fromBytes(bytes).repr;
3535 return mem.toBytes(x);
3636 }
3737
3838 /// 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 {
4040 return Block{
4141 .repr = asm (
4242 \\ vaesenc %[rk], %[in], %[out]
......@@ -48,7 +48,7 @@ pub const Block = struct {
4848 }
4949
5050 /// 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 {
5252 return Block{
5353 .repr = asm (
5454 \\ vaesenclast %[rk], %[in], %[out]
......@@ -60,7 +60,7 @@ pub const Block = struct {
6060 }
6161
6262 /// 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 {
6464 return Block{
6565 .repr = asm (
6666 \\ vaesdec %[rk], %[in], %[out]
......@@ -72,7 +72,7 @@ pub const Block = struct {
7272 }
7373
7474 /// 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 {
7676 return Block{
7777 .repr = asm (
7878 \\ vaesdeclast %[rk], %[in], %[out]
......@@ -84,17 +84,17 @@ pub const Block = struct {
8484 }
8585
8686 /// 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 {
8888 return Block{ .repr = block1.repr ^ block2.repr };
8989 }
9090
9191 /// 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 {
9393 return Block{ .repr = block1.repr & block2.repr };
9494 }
9595
9696 /// 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 {
9898 return Block{ .repr = block1.repr | block2.repr };
9999 }
100100
......@@ -114,7 +114,7 @@ pub const Block = struct {
114114 };
115115
116116 /// 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 {
118118 comptime var i = 0;
119119 var out: [count]Block = undefined;
120120 inline while (i < count) : (i += 1) {
......@@ -124,7 +124,7 @@ pub const Block = struct {
124124 }
125125
126126 /// 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 {
128128 comptime var i = 0;
129129 var out: [count]Block = undefined;
130130 inline while (i < count) : (i += 1) {
......@@ -134,7 +134,7 @@ pub const Block = struct {
134134 }
135135
136136 /// 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 {
138138 comptime var i = 0;
139139 var out: [count]Block = undefined;
140140 inline while (i < count) : (i += 1) {
......@@ -144,7 +144,7 @@ pub const Block = struct {
144144 }
145145
146146 /// 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 {
148148 comptime var i = 0;
149149 var out: [count]Block = undefined;
150150 inline while (i < count) : (i += 1) {
......@@ -154,7 +154,7 @@ pub const Block = struct {
154154 }
155155
156156 /// 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 {
158158 comptime var i = 0;
159159 var out: [count]Block = undefined;
160160 inline while (i < count) : (i += 1) {
......@@ -164,7 +164,7 @@ pub const Block = struct {
164164 }
165165
166166 /// 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 {
168168 comptime var i = 0;
169169 var out: [count]Block = undefined;
170170 inline while (i < count) : (i += 1) {
lib/std/crypto/aes/armcrypto.zig+16-16
......@@ -19,18 +19,18 @@ pub const Block = struct {
1919 repr: BlockVec,
2020
2121 /// 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 {
2323 const repr = mem.bytesToValue(BlockVec, bytes);
2424 return Block{ .repr = repr };
2525 }
2626
2727 /// 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 {
2929 return mem.toBytes(block.repr);
3030 }
3131
3232 /// 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 {
3434 const x = block.repr ^ fromBytes(bytes).repr;
3535 return mem.toBytes(x);
3636 }
......@@ -38,7 +38,7 @@ pub const Block = struct {
3838 const zero = Vector(2, u64){ 0, 0 };
3939
4040 /// 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 {
4242 return Block{
4343 .repr = asm (
4444 \\ mov %[out].16b, %[in].16b
......@@ -54,7 +54,7 @@ pub const Block = struct {
5454 }
5555
5656 /// 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 {
5858 return Block{
5959 .repr = asm (
6060 \\ mov %[out].16b, %[in].16b
......@@ -69,7 +69,7 @@ pub const Block = struct {
6969 }
7070
7171 /// 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 {
7373 return Block{
7474 .repr = asm (
7575 \\ mov %[out].16b, %[in].16b
......@@ -85,7 +85,7 @@ pub const Block = struct {
8585 }
8686
8787 /// 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 {
8989 return Block{
9090 .repr = asm (
9191 \\ mov %[out].16b, %[in].16b
......@@ -100,17 +100,17 @@ pub const Block = struct {
100100 }
101101
102102 /// 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 {
104104 return Block{ .repr = block1.repr ^ block2.repr };
105105 }
106106
107107 /// 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 {
109109 return Block{ .repr = block1.repr & block2.repr };
110110 }
111111
112112 /// 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 {
114114 return Block{ .repr = block1.repr | block2.repr };
115115 }
116116
......@@ -120,7 +120,7 @@ pub const Block = struct {
120120 pub const optimal_parallel_blocks = 8;
121121
122122 /// 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 {
124124 comptime var i = 0;
125125 var out: [count]Block = undefined;
126126 inline while (i < count) : (i += 1) {
......@@ -130,7 +130,7 @@ pub const Block = struct {
130130 }
131131
132132 /// 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 {
134134 comptime var i = 0;
135135 var out: [count]Block = undefined;
136136 inline while (i < count) : (i += 1) {
......@@ -140,7 +140,7 @@ pub const Block = struct {
140140 }
141141
142142 /// 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 {
144144 comptime var i = 0;
145145 var out: [count]Block = undefined;
146146 inline while (i < count) : (i += 1) {
......@@ -150,7 +150,7 @@ pub const Block = struct {
150150 }
151151
152152 /// 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 {
154154 comptime var i = 0;
155155 var out: [count]Block = undefined;
156156 inline while (i < count) : (i += 1) {
......@@ -160,7 +160,7 @@ pub const Block = struct {
160160 }
161161
162162 /// 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 {
164164 comptime var i = 0;
165165 var out: [count]Block = undefined;
166166 inline while (i < count) : (i += 1) {
......@@ -170,7 +170,7 @@ pub const Block = struct {
170170 }
171171
172172 /// 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 {
174174 comptime var i = 0;
175175 var out: [count]Block = undefined;
176176 inline while (i < count) : (i += 1) {
lib/std/crypto/aes/soft.zig+10-10
......@@ -18,7 +18,7 @@ pub const Block = struct {
1818 repr: BlockVec align(16),
1919
2020 /// 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 {
2222 const s0 = mem.readIntBig(u32, bytes[0..4]);
2323 const s1 = mem.readIntBig(u32, bytes[4..8]);
2424 const s2 = mem.readIntBig(u32, bytes[8..12]);
......@@ -27,7 +27,7 @@ pub const Block = struct {
2727 }
2828
2929 /// 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 {
3131 var bytes: [16]u8 = undefined;
3232 mem.writeIntBig(u32, bytes[0..4], block.repr[0]);
3333 mem.writeIntBig(u32, bytes[4..8], block.repr[1]);
......@@ -37,7 +37,7 @@ pub const Block = struct {
3737 }
3838
3939 /// 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 {
4141 const block_bytes = block.toBytes();
4242 var x: [16]u8 = undefined;
4343 comptime var i: usize = 0;
......@@ -48,7 +48,7 @@ pub const Block = struct {
4848 }
4949
5050 /// 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 {
5252 const src = &block.repr;
5353
5454 const s0 = block.repr[0];
......@@ -65,7 +65,7 @@ pub const Block = struct {
6565 }
6666
6767 /// 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 {
6969 const src = &block.repr;
7070
7171 const t0 = block.repr[0];
......@@ -87,7 +87,7 @@ pub const Block = struct {
8787 }
8888
8989 /// 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 {
9191 const src = &block.repr;
9292
9393 const s0 = block.repr[0];
......@@ -104,7 +104,7 @@ pub const Block = struct {
104104 }
105105
106106 /// 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 {
108108 const src = &block.repr;
109109
110110 const t0 = block.repr[0];
......@@ -126,7 +126,7 @@ pub const Block = struct {
126126 }
127127
128128 /// 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 {
130130 var x: BlockVec = undefined;
131131 comptime var i = 0;
132132 inline while (i < 4) : (i += 1) {
......@@ -136,7 +136,7 @@ pub const Block = struct {
136136 }
137137
138138 /// 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 {
140140 var x: BlockVec = undefined;
141141 comptime var i = 0;
142142 inline while (i < 4) : (i += 1) {
......@@ -146,7 +146,7 @@ pub const Block = struct {
146146 }
147147
148148 /// 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 {
150150 var x: BlockVec = undefined;
151151 comptime var i = 0;
152152 inline while (i < 4) : (i += 1) {
lib/std/crypto/aes_ocb.zig+3-3
......@@ -33,7 +33,7 @@ fn AesOcb(comptime Aes: anytype) type {
3333 table: [56]Block align(16) = undefined,
3434 upto: usize,
3535
36 fn double(l: Block) callconv(.Inline) Block {
36 inline fn double(l: Block) Block {
3737 const l_ = mem.readIntBig(u128, &l);
3838 const l_2 = (l_ << 1) ^ (0x87 & -%(l_ >> 127));
3939 var l2: Block = undefined;
......@@ -245,7 +245,7 @@ fn AesOcb(comptime Aes: anytype) type {
245245 };
246246}
247247
248fn xorBlocks(x: Block, y: Block) callconv(.Inline) Block {
248inline fn xorBlocks(x: Block, y: Block) Block {
249249 var z: Block = x;
250250 for (z) |*v, i| {
251251 v.* = x[i] ^ y[i];
......@@ -253,7 +253,7 @@ fn xorBlocks(x: Block, y: Block) callconv(.Inline) Block {
253253 return z;
254254}
255255
256fn xorWith(x: *Block, y: Block) callconv(.Inline) void {
256inline fn xorWith(x: *Block, y: Block) void {
257257 for (x) |*v, i| {
258258 v.* ^= y[i];
259259 }
lib/std/crypto/blake3.zig+3-3
......@@ -66,7 +66,7 @@ const CompressVectorized = struct {
6666 const Lane = Vector(4, u32);
6767 const Rows = [4]Lane;
6868
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 {
7070 rows[0] +%= rows[1] +% m;
7171 rows[3] ^= rows[0];
7272 rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16);
......@@ -75,13 +75,13 @@ const CompressVectorized = struct {
7575 rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12);
7676 }
7777
78 fn diagonalize(rows: *Rows) callconv(.Inline) void {
78 inline fn diagonalize(rows: *Rows) void {
7979 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 });
8080 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });
8181 rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 });
8282 }
8383
84 fn undiagonalize(rows: *Rows) callconv(.Inline) void {
84 inline fn undiagonalize(rows: *Rows) void {
8585 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 });
8686 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });
8787 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 {
102102 };
103103 }
104104
105 fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void {
105 inline fn chacha20Core(x: *BlockVec, input: BlockVec) void {
106106 x.* = input;
107107
108108 var r: usize = 0;
......@@ -147,7 +147,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize) type {
147147 }
148148 }
149149
150 fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void {
150 inline fn hashToBytes(out: *[64]u8, x: BlockVec) void {
151151 var i: usize = 0;
152152 while (i < 4) : (i += 1) {
153153 mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]);
......@@ -157,7 +157,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize) type {
157157 }
158158 }
159159
160 fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void {
160 inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {
161161 x[0] +%= ctx[0];
162162 x[1] +%= ctx[1];
163163 x[2] +%= ctx[2];
......@@ -259,7 +259,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type {
259259 };
260260 }
261261
262 fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void {
262 inline fn chacha20Core(x: *BlockVec, input: BlockVec) void {
263263 x.* = input;
264264
265265 const rounds = comptime [_]QuarterRound{
......@@ -288,7 +288,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type {
288288 }
289289 }
290290
291 fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void {
291 inline fn hashToBytes(out: *[64]u8, x: BlockVec) void {
292292 var i: usize = 0;
293293 while (i < 4) : (i += 1) {
294294 mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0]);
......@@ -298,7 +298,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type {
298298 }
299299 }
300300
301 fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void {
301 inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {
302302 var i: usize = 0;
303303 while (i < 16) : (i += 1) {
304304 x[i] +%= ctx[i];
lib/std/crypto/ghash.zig+2-2
......@@ -95,7 +95,7 @@ pub const Ghash = struct {
9595 }
9696 }
9797
98 fn clmul_pclmul(x: u64, y: u64) callconv(.Inline) u64 {
98 inline fn clmul_pclmul(x: u64, y: u64) u64 {
9999 const Vector = std.meta.Vector;
100100 const product = asm (
101101 \\ vpclmulqdq $0x00, %[x], %[y], %[out]
......@@ -106,7 +106,7 @@ pub const Ghash = struct {
106106 return product[0];
107107 }
108108
109 fn clmul_pmull(x: u64, y: u64) callconv(.Inline) u64 {
109 inline fn clmul_pmull(x: u64, y: u64) u64 {
110110 const Vector = std.meta.Vector;
111111 const product = asm (
112112 \\ pmull %[out].1q, %[x].1d, %[y].1d
lib/std/crypto/gimli.zig+2-2
......@@ -49,7 +49,7 @@ pub const State = struct {
4949 return mem.asBytes(&self.data);
5050 }
5151
52 fn endianSwap(self: *Self) callconv(.Inline) void {
52 inline fn endianSwap(self: *Self) void {
5353 for (self.data) |*w| {
5454 w.* = mem.littleToNative(u32, w.*);
5555 }
......@@ -117,7 +117,7 @@ pub const State = struct {
117117
118118 const Lane = Vector(4, u32);
119119
120 fn shift(x: Lane, comptime n: comptime_int) callconv(.Inline) Lane {
120 inline fn shift(x: Lane, comptime n: comptime_int) Lane {
121121 return x << @splat(4, @as(u5, n));
122122 }
123123
lib/std/crypto/pcurves/p256/p256_64.zig+4-4
......@@ -35,7 +35,7 @@ pub const Limbs = [4]u64;
3535/// Output Bounds:
3636/// out1: [0x0 ~> 0xffffffffffffffff]
3737/// out2: [0x0 ~> 0x1]
38fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void {
38inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
3939 @setRuntimeSafety(mode == .Debug);
4040
4141 var t: u64 = undefined;
......@@ -56,7 +56,7 @@ fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(
5656/// Output Bounds:
5757/// out1: [0x0 ~> 0xffffffffffffffff]
5858/// out2: [0x0 ~> 0x1]
59fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void {
59inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
6060 @setRuntimeSafety(mode == .Debug);
6161
6262 var t: u64 = undefined;
......@@ -76,7 +76,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv
7676/// Output Bounds:
7777/// out1: [0x0 ~> 0xffffffffffffffff]
7878/// out2: [0x0 ~> 0xffffffffffffffff]
79fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void {
79inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
8080 @setRuntimeSafety(mode == .Debug);
8181
8282 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
9494/// arg3: [0x0 ~> 0xffffffffffffffff]
9595/// Output Bounds:
9696/// out1: [0x0 ~> 0xffffffffffffffff]
97fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void {
97inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
9898 @setRuntimeSafety(mode == .Debug);
9999
100100 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;
3535/// Output Bounds:
3636/// out1: [0x0 ~> 0xffffffffffffffff]
3737/// out2: [0x0 ~> 0x1]
38fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void {
38inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
3939 @setRuntimeSafety(mode == .Debug);
4040
4141 var t: u64 = undefined;
......@@ -56,7 +56,7 @@ fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(
5656/// Output Bounds:
5757/// out1: [0x0 ~> 0xffffffffffffffff]
5858/// out2: [0x0 ~> 0x1]
59fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void {
59inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
6060 @setRuntimeSafety(mode == .Debug);
6161
6262 var t: u64 = undefined;
......@@ -76,7 +76,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) callconv
7676/// Output Bounds:
7777/// out1: [0x0 ~> 0xffffffffffffffff]
7878/// out2: [0x0 ~> 0xffffffffffffffff]
79fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) callconv(.Inline) void {
79inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
8080 @setRuntimeSafety(mode == .Debug);
8181
8282 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
9494/// arg3: [0x0 ~> 0xffffffffffffffff]
9595/// Output Bounds:
9696/// out1: [0x0 ~> 0xffffffffffffffff]
97fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) callconv(.Inline) void {
97inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
9898 @setRuntimeSafety(mode == .Debug);
9999
100100 const mask = 0 -% @as(u64, arg1);
lib/std/crypto/salsa20.zig+3-3
......@@ -41,7 +41,7 @@ const Salsa20VecImpl = struct {
4141 };
4242 }
4343
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 {
4545 const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] };
4646 const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] };
4747 const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] };
......@@ -215,7 +215,7 @@ const Salsa20NonVecImpl = struct {
215215 d: u6,
216216 };
217217
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 {
219219 return QuarterRound{
220220 .a = a,
221221 .b = b,
......@@ -224,7 +224,7 @@ const Salsa20NonVecImpl = struct {
224224 };
225225 }
226226
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 {
228228 const arx_steps = comptime [_]QuarterRound{
229229 Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18),
230230 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 {
721721 r_offset: Elf32_Addr,
722722 r_info: Elf32_Word,
723723
724 pub fn r_sym(self: @This()) callconv(.Inline) u24 {
724 pub inline fn r_sym(self: @This()) u24 {
725725 return @truncate(u24, self.r_info >> 8);
726726 }
727 pub fn r_type(self: @This()) callconv(.Inline) u8 {
727 pub inline fn r_type(self: @This()) u8 {
728728 return @truncate(u8, self.r_info & 0xff);
729729 }
730730};
......@@ -732,10 +732,10 @@ pub const Elf64_Rel = extern struct {
732732 r_offset: Elf64_Addr,
733733 r_info: Elf64_Xword,
734734
735 pub fn r_sym(self: @This()) callconv(.Inline) u32 {
735 pub inline fn r_sym(self: @This()) u32 {
736736 return @truncate(u32, self.r_info >> 32);
737737 }
738 pub fn r_type(self: @This()) callconv(.Inline) u32 {
738 pub inline fn r_type(self: @This()) u32 {
739739 return @truncate(u32, self.r_info & 0xffffffff);
740740 }
741741};
......@@ -744,10 +744,10 @@ pub const Elf32_Rela = extern struct {
744744 r_info: Elf32_Word,
745745 r_addend: Elf32_Sword,
746746
747 pub fn r_sym(self: @This()) callconv(.Inline) u24 {
747 pub inline fn r_sym(self: @This()) u24 {
748748 return @truncate(u24, self.r_info >> 8);
749749 }
750 pub fn r_type(self: @This()) callconv(.Inline) u8 {
750 pub inline fn r_type(self: @This()) u8 {
751751 return @truncate(u8, self.r_info & 0xff);
752752 }
753753};
......@@ -756,10 +756,10 @@ pub const Elf64_Rela = extern struct {
756756 r_info: Elf64_Xword,
757757 r_addend: Elf64_Sxword,
758758
759 pub fn r_sym(self: @This()) callconv(.Inline) u32 {
759 pub inline fn r_sym(self: @This()) u32 {
760760 return @truncate(u32, self.r_info >> 32);
761761 }
762 pub fn r_type(self: @This()) callconv(.Inline) u32 {
762 pub inline fn r_type(self: @This()) u32 {
763763 return @truncate(u32, self.r_info & 0xffffffff);
764764 }
765765};
lib/std/fmt/parse_float.zig+4-4
......@@ -52,21 +52,21 @@ const Z96 = struct {
5252 d2: u32,
5353
5454 // d = s >> 1
55 fn shiftRight1(d: *Z96, s: Z96) callconv(.Inline) void {
55 inline fn shiftRight1(d: *Z96, s: Z96) void {
5656 d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31);
5757 d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31);
5858 d.d2 = s.d2 >> 1;
5959 }
6060
6161 // d = s << 1
62 fn shiftLeft1(d: *Z96, s: Z96) callconv(.Inline) void {
62 inline fn shiftLeft1(d: *Z96, s: Z96) void {
6363 d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31);
6464 d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31);
6565 d.d0 = s.d0 << 1;
6666 }
6767
6868 // d += s
69 fn add(d: *Z96, s: Z96) callconv(.Inline) void {
69 inline fn add(d: *Z96, s: Z96) void {
7070 var w = @as(u64, d.d0) + @as(u64, s.d0);
7171 d.d0 = @truncate(u32, w);
7272
......@@ -80,7 +80,7 @@ const Z96 = struct {
8080 }
8181
8282 // d -= s
83 fn sub(d: *Z96, s: Z96) callconv(.Inline) void {
83 inline fn sub(d: *Z96, s: Z96) void {
8484 var w = @as(u64, d.d0) -% @as(u64, s.d0);
8585 d.d0 = @truncate(u32, w);
8686
lib/std/hash/cityhash.zig+1-1
......@@ -6,7 +6,7 @@
66const std = @import("std");
77const builtin = std.builtin;
88
9fn offsetPtr(ptr: [*]const u8, offset: usize) callconv(.Inline) [*]const u8 {
9inline fn offsetPtr(ptr: [*]const u8, offset: usize) [*]const u8 {
1010 // ptr + offset doesn't work at comptime so we need this instead.
1111 return @ptrCast([*]const u8, &ptr[offset]);
1212}
lib/std/json.zig+2-5
......@@ -2014,12 +2014,9 @@ test "parse into struct with duplicate field" {
20142014 const ballast = try testing.allocator.alloc(u64, 1);
20152015 defer testing.allocator.free(ballast);
20162016
2017 const options_first = ParseOptions{
2018 .allocator = testing.allocator,
2019 .duplicate_field_behavior = .UseFirst
2020 };
2017 const options_first = ParseOptions{ .allocator = testing.allocator, .duplicate_field_behavior = .UseFirst };
20212018
2022 const options_last = ParseOptions{
2019 const options_last = ParseOptions{
20232020 .allocator = testing.allocator,
20242021 .duplicate_field_behavior = .UseLast,
20252022 };
lib/std/math.zig+1-1
......@@ -1334,7 +1334,7 @@ test "math.comptime" {
13341334/// Returns a mask of all ones if value is true,
13351335/// and a mask of all zeroes if value is false.
13361336/// Compiles to one instruction for register sized integers.
1337pub fn boolMask(comptime MaskInt: type, value: bool) callconv(.Inline) MaskInt {
1337pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt {
13381338 if (@typeInfo(MaskInt) != .Int)
13391339 @compileError("boolMask requires an integer mask type.");
13401340
lib/std/math/complex.zig+1-1
......@@ -38,7 +38,7 @@ pub fn Complex(comptime T: type) type {
3838
3939 /// Imaginary part.
4040 im: T,
41
41
4242 /// Deprecated, use init()
4343 pub const new = init;
4444
lib/std/os/bits/freebsd.zig+4-4
......@@ -823,16 +823,16 @@ pub const sigval = extern union {
823823pub const _SIG_WORDS = 4;
824824pub const _SIG_MAXSIG = 128;
825825
826pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
826pub inline fn _SIG_IDX(sig: usize) usize {
827827 return sig - 1;
828828}
829pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
829pub inline fn _SIG_WORD(sig: usize) usize {
830830 return_SIG_IDX(sig) >> 5;
831831}
832pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
832pub inline fn _SIG_BIT(sig: usize) usize {
833833 return 1 << (_SIG_IDX(sig) & 31);
834834}
835pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
835pub inline fn _SIG_VALID(sig: usize) usize {
836836 return sig <= _SIG_MAXSIG and sig > 0;
837837}
838838
lib/std/os/bits/haiku.zig+4-4
......@@ -721,16 +721,16 @@ pub const Sigaction = extern struct {
721721
722722pub const _SIG_WORDS = 4;
723723pub const _SIG_MAXSIG = 128;
724pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
724pub inline fn _SIG_IDX(sig: usize) usize {
725725 return sig - 1;
726726}
727pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
727pub inline fn _SIG_WORD(sig: usize) usize {
728728 return_SIG_IDX(sig) >> 5;
729729}
730pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
730pub inline fn _SIG_BIT(sig: usize) usize {
731731 return 1 << (_SIG_IDX(sig) & 31);
732732}
733pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
733pub inline fn _SIG_VALID(sig: usize) usize {
734734 return sig <= _SIG_MAXSIG and sig > 0;
735735}
736736
lib/std/os/bits/netbsd.zig+4-4
......@@ -804,16 +804,16 @@ pub const _ksiginfo = extern struct {
804804pub const _SIG_WORDS = 4;
805805pub const _SIG_MAXSIG = 128;
806806
807pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
807pub inline fn _SIG_IDX(sig: usize) usize {
808808 return sig - 1;
809809}
810pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
810pub inline fn _SIG_WORD(sig: usize) usize {
811811 return_SIG_IDX(sig) >> 5;
812812}
813pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
813pub inline fn _SIG_BIT(sig: usize) usize {
814814 return 1 << (_SIG_IDX(sig) & 31);
815815}
816pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
816pub inline fn _SIG_VALID(sig: usize) usize {
817817 return sig <= _SIG_MAXSIG and sig > 0;
818818}
819819
lib/std/os/linux.zig+1-1
......@@ -145,7 +145,7 @@ pub fn fork() usize {
145145/// It is advised to avoid this function and use clone instead, because
146146/// the compiler is not aware of how vfork affects control flow and you may
147147/// see different results in optimized builds.
148pub fn vfork() callconv(.Inline) usize {
148pub inline fn vfork() usize {
149149 return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork});
150150}
151151
lib/std/os/linux/tls.zig+1-1
......@@ -307,7 +307,7 @@ fn initTLS() void {
307307 };
308308}
309309
310fn alignPtrCast(comptime T: type, ptr: [*]u8) callconv(.Inline) *T {
310inline fn alignPtrCast(comptime T: type, ptr: [*]u8) *T {
311311 return @ptrCast(*T, @alignCast(@alignOf(T), ptr));
312312}
313313
lib/std/os/windows.zig+1-1
......@@ -1881,7 +1881,7 @@ pub fn wToPrefixedFileW(s: []const u16) !PathSpace {
18811881 return path_space;
18821882}
18831883
1884fn MAKELANGID(p: c_ushort, s: c_ushort) callconv(.Inline) LANGID {
1884inline fn MAKELANGID(p: c_ushort, s: c_ushort) LANGID {
18851885 return (s << 10) | p;
18861886}
18871887
lib/std/start.zig+2-2
......@@ -375,7 +375,7 @@ const bad_main_ret = "expected return type of main to be 'void', '!void', 'noret
375375
376376// This is marked inline because for some reason LLVM in release mode fails to inline it,
377377// and we want fewer call frames in stack traces.
378fn initEventLoopAndCallMain() callconv(.Inline) u8 {
378inline fn initEventLoopAndCallMain() u8 {
379379 if (std.event.Loop.instance) |loop| {
380380 if (!@hasDecl(root, "event_loop")) {
381381 loop.init() catch |err| {
......@@ -404,7 +404,7 @@ fn initEventLoopAndCallMain() callconv(.Inline) u8 {
404404// and we want fewer call frames in stack traces.
405405// TODO This function is duplicated from initEventLoopAndCallMain instead of using generics
406406// because it is working around stage1 compiler bugs.
407fn initEventLoopAndCallWinMain() callconv(.Inline) std.os.windows.INT {
407inline fn initEventLoopAndCallWinMain() std.os.windows.INT {
408408 if (std.event.Loop.instance) |loop| {
409409 if (!@hasDecl(root, "event_loop")) {
410410 loop.init() catch |err| {
lib/std/target/spirv.zig+55-110
......@@ -732,8 +732,7 @@ pub const all_features = blk: {
732732 result[@enumToInt(Feature.Matrix)] = .{
733733 .llvm_name = null,
734734 .description = "Enable SPIR-V capability Matrix",
735 .dependencies = featureSet(&[_]Feature{
736 }),
735 .dependencies = featureSet(&[_]Feature{}),
737736 };
738737 result[@enumToInt(Feature.Shader)] = .{
739738 .llvm_name = null,
......@@ -759,20 +758,17 @@ pub const all_features = blk: {
759758 result[@enumToInt(Feature.Addresses)] = .{
760759 .llvm_name = null,
761760 .description = "Enable SPIR-V capability Addresses",
762 .dependencies = featureSet(&[_]Feature{
763 }),
761 .dependencies = featureSet(&[_]Feature{}),
764762 };
765763 result[@enumToInt(Feature.Linkage)] = .{
766764 .llvm_name = null,
767765 .description = "Enable SPIR-V capability Linkage",
768 .dependencies = featureSet(&[_]Feature{
769 }),
766 .dependencies = featureSet(&[_]Feature{}),
770767 };
771768 result[@enumToInt(Feature.Kernel)] = .{
772769 .llvm_name = null,
773770 .description = "Enable SPIR-V capability Kernel",
774 .dependencies = featureSet(&[_]Feature{
775 }),
771 .dependencies = featureSet(&[_]Feature{}),
776772 };
777773 result[@enumToInt(Feature.Vector16)] = .{
778774 .llvm_name = null,
......@@ -791,20 +787,17 @@ pub const all_features = blk: {
791787 result[@enumToInt(Feature.Float16)] = .{
792788 .llvm_name = null,
793789 .description = "Enable SPIR-V capability Float16",
794 .dependencies = featureSet(&[_]Feature{
795 }),
790 .dependencies = featureSet(&[_]Feature{}),
796791 };
797792 result[@enumToInt(Feature.Float64)] = .{
798793 .llvm_name = null,
799794 .description = "Enable SPIR-V capability Float64",
800 .dependencies = featureSet(&[_]Feature{
801 }),
795 .dependencies = featureSet(&[_]Feature{}),
802796 };
803797 result[@enumToInt(Feature.Int64)] = .{
804798 .llvm_name = null,
805799 .description = "Enable SPIR-V capability Int64",
806 .dependencies = featureSet(&[_]Feature{
807 }),
800 .dependencies = featureSet(&[_]Feature{}),
808801 };
809802 result[@enumToInt(Feature.Int64Atomics)] = .{
810803 .llvm_name = null,
......@@ -844,8 +837,7 @@ pub const all_features = blk: {
844837 result[@enumToInt(Feature.Groups)] = .{
845838 .llvm_name = null,
846839 .description = "Enable SPIR-V capability Groups",
847 .dependencies = featureSet(&[_]Feature{
848 }),
840 .dependencies = featureSet(&[_]Feature{}),
849841 };
850842 result[@enumToInt(Feature.DeviceEnqueue)] = .{
851843 .llvm_name = null,
......@@ -871,8 +863,7 @@ pub const all_features = blk: {
871863 result[@enumToInt(Feature.Int16)] = .{
872864 .llvm_name = null,
873865 .description = "Enable SPIR-V capability Int16",
874 .dependencies = featureSet(&[_]Feature{
875 }),
866 .dependencies = featureSet(&[_]Feature{}),
876867 };
877868 result[@enumToInt(Feature.TessellationPointSize)] = .{
878869 .llvm_name = null,
......@@ -982,8 +973,7 @@ pub const all_features = blk: {
982973 result[@enumToInt(Feature.Int8)] = .{
983974 .llvm_name = null,
984975 .description = "Enable SPIR-V capability Int8",
985 .dependencies = featureSet(&[_]Feature{
986 }),
976 .dependencies = featureSet(&[_]Feature{}),
987977 };
988978 result[@enumToInt(Feature.InputAttachment)] = .{
989979 .llvm_name = null,
......@@ -1009,8 +999,7 @@ pub const all_features = blk: {
1009999 result[@enumToInt(Feature.Sampled1D)] = .{
10101000 .llvm_name = null,
10111001 .description = "Enable SPIR-V capability Sampled1D",
1012 .dependencies = featureSet(&[_]Feature{
1013 }),
1002 .dependencies = featureSet(&[_]Feature{}),
10141003 };
10151004 result[@enumToInt(Feature.Image1D)] = .{
10161005 .llvm_name = null,
......@@ -1029,8 +1018,7 @@ pub const all_features = blk: {
10291018 result[@enumToInt(Feature.SampledBuffer)] = .{
10301019 .llvm_name = null,
10311020 .description = "Enable SPIR-V capability SampledBuffer",
1032 .dependencies = featureSet(&[_]Feature{
1033 }),
1021 .dependencies = featureSet(&[_]Feature{}),
10341022 };
10351023 result[@enumToInt(Feature.ImageBuffer)] = .{
10361024 .llvm_name = null,
......@@ -1220,8 +1208,7 @@ pub const all_features = blk: {
12201208 result[@enumToInt(Feature.SubgroupBallotKHR)] = .{
12211209 .llvm_name = null,
12221210 .description = "Enable SPIR-V capability SubgroupBallotKHR",
1223 .dependencies = featureSet(&[_]Feature{
1224 }),
1211 .dependencies = featureSet(&[_]Feature{}),
12251212 };
12261213 result[@enumToInt(Feature.DrawParameters)] = .{
12271214 .llvm_name = null,
......@@ -1255,8 +1242,7 @@ pub const all_features = blk: {
12551242 result[@enumToInt(Feature.SubgroupVoteKHR)] = .{
12561243 .llvm_name = null,
12571244 .description = "Enable SPIR-V capability SubgroupVoteKHR",
1258 .dependencies = featureSet(&[_]Feature{
1259 }),
1245 .dependencies = featureSet(&[_]Feature{}),
12601246 };
12611247 result[@enumToInt(Feature.StorageBuffer16BitAccess)] = .{
12621248 .llvm_name = null,
......@@ -1338,14 +1324,12 @@ pub const all_features = blk: {
13381324 result[@enumToInt(Feature.AtomicStorageOps)] = .{
13391325 .llvm_name = null,
13401326 .description = "Enable SPIR-V capability AtomicStorageOps",
1341 .dependencies = featureSet(&[_]Feature{
1342 }),
1327 .dependencies = featureSet(&[_]Feature{}),
13431328 };
13441329 result[@enumToInt(Feature.SampleMaskPostDepthCoverage)] = .{
13451330 .llvm_name = null,
13461331 .description = "Enable SPIR-V capability SampleMaskPostDepthCoverage",
1347 .dependencies = featureSet(&[_]Feature{
1348 }),
1332 .dependencies = featureSet(&[_]Feature{}),
13491333 };
13501334 result[@enumToInt(Feature.StorageBuffer8BitAccess)] = .{
13511335 .llvm_name = null,
......@@ -1548,20 +1532,17 @@ pub const all_features = blk: {
15481532 result[@enumToInt(Feature.ImageFootprintNV)] = .{
15491533 .llvm_name = null,
15501534 .description = "Enable SPIR-V capability ImageFootprintNV",
1551 .dependencies = featureSet(&[_]Feature{
1552 }),
1535 .dependencies = featureSet(&[_]Feature{}),
15531536 };
15541537 result[@enumToInt(Feature.FragmentBarycentricNV)] = .{
15551538 .llvm_name = null,
15561539 .description = "Enable SPIR-V capability FragmentBarycentricNV",
1557 .dependencies = featureSet(&[_]Feature{
1558 }),
1540 .dependencies = featureSet(&[_]Feature{}),
15591541 };
15601542 result[@enumToInt(Feature.ComputeDerivativeGroupQuadsNV)] = .{
15611543 .llvm_name = null,
15621544 .description = "Enable SPIR-V capability ComputeDerivativeGroupQuadsNV",
1563 .dependencies = featureSet(&[_]Feature{
1564 }),
1545 .dependencies = featureSet(&[_]Feature{}),
15651546 };
15661547 result[@enumToInt(Feature.FragmentDensityEXT)] = .{
15671548 .llvm_name = null,
......@@ -1580,8 +1561,7 @@ pub const all_features = blk: {
15801561 result[@enumToInt(Feature.GroupNonUniformPartitionedNV)] = .{
15811562 .llvm_name = null,
15821563 .description = "Enable SPIR-V capability GroupNonUniformPartitionedNV",
1583 .dependencies = featureSet(&[_]Feature{
1584 }),
1564 .dependencies = featureSet(&[_]Feature{}),
15851565 };
15861566 result[@enumToInt(Feature.ShaderNonUniform)] = .{
15871567 .llvm_name = null,
......@@ -1835,8 +1815,7 @@ pub const all_features = blk: {
18351815 result[@enumToInt(Feature.ComputeDerivativeGroupLinearNV)] = .{
18361816 .llvm_name = null,
18371817 .description = "Enable SPIR-V capability ComputeDerivativeGroupLinearNV",
1838 .dependencies = featureSet(&[_]Feature{
1839 }),
1818 .dependencies = featureSet(&[_]Feature{}),
18401819 };
18411820 result[@enumToInt(Feature.RayTracingProvisionalKHR)] = .{
18421821 .llvm_name = null,
......@@ -1890,38 +1869,32 @@ pub const all_features = blk: {
18901869 result[@enumToInt(Feature.SubgroupShuffleINTEL)] = .{
18911870 .llvm_name = null,
18921871 .description = "Enable SPIR-V capability SubgroupShuffleINTEL",
1893 .dependencies = featureSet(&[_]Feature{
1894 }),
1872 .dependencies = featureSet(&[_]Feature{}),
18951873 };
18961874 result[@enumToInt(Feature.SubgroupBufferBlockIOINTEL)] = .{
18971875 .llvm_name = null,
18981876 .description = "Enable SPIR-V capability SubgroupBufferBlockIOINTEL",
1899 .dependencies = featureSet(&[_]Feature{
1900 }),
1877 .dependencies = featureSet(&[_]Feature{}),
19011878 };
19021879 result[@enumToInt(Feature.SubgroupImageBlockIOINTEL)] = .{
19031880 .llvm_name = null,
19041881 .description = "Enable SPIR-V capability SubgroupImageBlockIOINTEL",
1905 .dependencies = featureSet(&[_]Feature{
1906 }),
1882 .dependencies = featureSet(&[_]Feature{}),
19071883 };
19081884 result[@enumToInt(Feature.SubgroupImageMediaBlockIOINTEL)] = .{
19091885 .llvm_name = null,
19101886 .description = "Enable SPIR-V capability SubgroupImageMediaBlockIOINTEL",
1911 .dependencies = featureSet(&[_]Feature{
1912 }),
1887 .dependencies = featureSet(&[_]Feature{}),
19131888 };
19141889 result[@enumToInt(Feature.RoundToInfinityINTEL)] = .{
19151890 .llvm_name = null,
19161891 .description = "Enable SPIR-V capability RoundToInfinityINTEL",
1917 .dependencies = featureSet(&[_]Feature{
1918 }),
1892 .dependencies = featureSet(&[_]Feature{}),
19191893 };
19201894 result[@enumToInt(Feature.FloatingPointModeINTEL)] = .{
19211895 .llvm_name = null,
19221896 .description = "Enable SPIR-V capability FloatingPointModeINTEL",
1923 .dependencies = featureSet(&[_]Feature{
1924 }),
1897 .dependencies = featureSet(&[_]Feature{}),
19251898 };
19261899 result[@enumToInt(Feature.IntegerFunctions2INTEL)] = .{
19271900 .llvm_name = null,
......@@ -1933,38 +1906,32 @@ pub const all_features = blk: {
19331906 result[@enumToInt(Feature.FunctionPointersINTEL)] = .{
19341907 .llvm_name = null,
19351908 .description = "Enable SPIR-V capability FunctionPointersINTEL",
1936 .dependencies = featureSet(&[_]Feature{
1937 }),
1909 .dependencies = featureSet(&[_]Feature{}),
19381910 };
19391911 result[@enumToInt(Feature.IndirectReferencesINTEL)] = .{
19401912 .llvm_name = null,
19411913 .description = "Enable SPIR-V capability IndirectReferencesINTEL",
1942 .dependencies = featureSet(&[_]Feature{
1943 }),
1914 .dependencies = featureSet(&[_]Feature{}),
19441915 };
19451916 result[@enumToInt(Feature.AsmINTEL)] = .{
19461917 .llvm_name = null,
19471918 .description = "Enable SPIR-V capability AsmINTEL",
1948 .dependencies = featureSet(&[_]Feature{
1949 }),
1919 .dependencies = featureSet(&[_]Feature{}),
19501920 };
19511921 result[@enumToInt(Feature.AtomicFloat32MinMaxEXT)] = .{
19521922 .llvm_name = null,
19531923 .description = "Enable SPIR-V capability AtomicFloat32MinMaxEXT",
1954 .dependencies = featureSet(&[_]Feature{
1955 }),
1924 .dependencies = featureSet(&[_]Feature{}),
19561925 };
19571926 result[@enumToInt(Feature.AtomicFloat64MinMaxEXT)] = .{
19581927 .llvm_name = null,
19591928 .description = "Enable SPIR-V capability AtomicFloat64MinMaxEXT",
1960 .dependencies = featureSet(&[_]Feature{
1961 }),
1929 .dependencies = featureSet(&[_]Feature{}),
19621930 };
19631931 result[@enumToInt(Feature.AtomicFloat16MinMaxEXT)] = .{
19641932 .llvm_name = null,
19651933 .description = "Enable SPIR-V capability AtomicFloat16MinMaxEXT",
1966 .dependencies = featureSet(&[_]Feature{
1967 }),
1934 .dependencies = featureSet(&[_]Feature{}),
19681935 };
19691936 result[@enumToInt(Feature.VectorComputeINTEL)] = .{
19701937 .llvm_name = null,
......@@ -1976,50 +1943,42 @@ pub const all_features = blk: {
19761943 result[@enumToInt(Feature.VectorAnyINTEL)] = .{
19771944 .llvm_name = null,
19781945 .description = "Enable SPIR-V capability VectorAnyINTEL",
1979 .dependencies = featureSet(&[_]Feature{
1980 }),
1946 .dependencies = featureSet(&[_]Feature{}),
19811947 };
19821948 result[@enumToInt(Feature.ExpectAssumeKHR)] = .{
19831949 .llvm_name = null,
19841950 .description = "Enable SPIR-V capability ExpectAssumeKHR",
1985 .dependencies = featureSet(&[_]Feature{
1986 }),
1951 .dependencies = featureSet(&[_]Feature{}),
19871952 };
19881953 result[@enumToInt(Feature.SubgroupAvcMotionEstimationINTEL)] = .{
19891954 .llvm_name = null,
19901955 .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationINTEL",
1991 .dependencies = featureSet(&[_]Feature{
1992 }),
1956 .dependencies = featureSet(&[_]Feature{}),
19931957 };
19941958 result[@enumToInt(Feature.SubgroupAvcMotionEstimationIntraINTEL)] = .{
19951959 .llvm_name = null,
19961960 .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationIntraINTEL",
1997 .dependencies = featureSet(&[_]Feature{
1998 }),
1961 .dependencies = featureSet(&[_]Feature{}),
19991962 };
20001963 result[@enumToInt(Feature.SubgroupAvcMotionEstimationChromaINTEL)] = .{
20011964 .llvm_name = null,
20021965 .description = "Enable SPIR-V capability SubgroupAvcMotionEstimationChromaINTEL",
2003 .dependencies = featureSet(&[_]Feature{
2004 }),
1966 .dependencies = featureSet(&[_]Feature{}),
20051967 };
20061968 result[@enumToInt(Feature.VariableLengthArrayINTEL)] = .{
20071969 .llvm_name = null,
20081970 .description = "Enable SPIR-V capability VariableLengthArrayINTEL",
2009 .dependencies = featureSet(&[_]Feature{
2010 }),
1971 .dependencies = featureSet(&[_]Feature{}),
20111972 };
20121973 result[@enumToInt(Feature.FunctionFloatControlINTEL)] = .{
20131974 .llvm_name = null,
20141975 .description = "Enable SPIR-V capability FunctionFloatControlINTEL",
2015 .dependencies = featureSet(&[_]Feature{
2016 }),
1976 .dependencies = featureSet(&[_]Feature{}),
20171977 };
20181978 result[@enumToInt(Feature.FPGAMemoryAttributesINTEL)] = .{
20191979 .llvm_name = null,
20201980 .description = "Enable SPIR-V capability FPGAMemoryAttributesINTEL",
2021 .dependencies = featureSet(&[_]Feature{
2022 }),
1981 .dependencies = featureSet(&[_]Feature{}),
20231982 };
20241983 result[@enumToInt(Feature.FPFastMathModeINTEL)] = .{
20251984 .llvm_name = null,
......@@ -2031,80 +1990,67 @@ pub const all_features = blk: {
20311990 result[@enumToInt(Feature.ArbitraryPrecisionIntegersINTEL)] = .{
20321991 .llvm_name = null,
20331992 .description = "Enable SPIR-V capability ArbitraryPrecisionIntegersINTEL",
2034 .dependencies = featureSet(&[_]Feature{
2035 }),
1993 .dependencies = featureSet(&[_]Feature{}),
20361994 };
20371995 result[@enumToInt(Feature.UnstructuredLoopControlsINTEL)] = .{
20381996 .llvm_name = null,
20391997 .description = "Enable SPIR-V capability UnstructuredLoopControlsINTEL",
2040 .dependencies = featureSet(&[_]Feature{
2041 }),
1998 .dependencies = featureSet(&[_]Feature{}),
20421999 };
20432000 result[@enumToInt(Feature.FPGALoopControlsINTEL)] = .{
20442001 .llvm_name = null,
20452002 .description = "Enable SPIR-V capability FPGALoopControlsINTEL",
2046 .dependencies = featureSet(&[_]Feature{
2047 }),
2003 .dependencies = featureSet(&[_]Feature{}),
20482004 };
20492005 result[@enumToInt(Feature.KernelAttributesINTEL)] = .{
20502006 .llvm_name = null,
20512007 .description = "Enable SPIR-V capability KernelAttributesINTEL",
2052 .dependencies = featureSet(&[_]Feature{
2053 }),
2008 .dependencies = featureSet(&[_]Feature{}),
20542009 };
20552010 result[@enumToInt(Feature.FPGAKernelAttributesINTEL)] = .{
20562011 .llvm_name = null,
20572012 .description = "Enable SPIR-V capability FPGAKernelAttributesINTEL",
2058 .dependencies = featureSet(&[_]Feature{
2059 }),
2013 .dependencies = featureSet(&[_]Feature{}),
20602014 };
20612015 result[@enumToInt(Feature.FPGAMemoryAccessesINTEL)] = .{
20622016 .llvm_name = null,
20632017 .description = "Enable SPIR-V capability FPGAMemoryAccessesINTEL",
2064 .dependencies = featureSet(&[_]Feature{
2065 }),
2018 .dependencies = featureSet(&[_]Feature{}),
20662019 };
20672020 result[@enumToInt(Feature.FPGAClusterAttributesINTEL)] = .{
20682021 .llvm_name = null,
20692022 .description = "Enable SPIR-V capability FPGAClusterAttributesINTEL",
2070 .dependencies = featureSet(&[_]Feature{
2071 }),
2023 .dependencies = featureSet(&[_]Feature{}),
20722024 };
20732025 result[@enumToInt(Feature.LoopFuseINTEL)] = .{
20742026 .llvm_name = null,
20752027 .description = "Enable SPIR-V capability LoopFuseINTEL",
2076 .dependencies = featureSet(&[_]Feature{
2077 }),
2028 .dependencies = featureSet(&[_]Feature{}),
20782029 };
20792030 result[@enumToInt(Feature.FPGABufferLocationINTEL)] = .{
20802031 .llvm_name = null,
20812032 .description = "Enable SPIR-V capability FPGABufferLocationINTEL",
2082 .dependencies = featureSet(&[_]Feature{
2083 }),
2033 .dependencies = featureSet(&[_]Feature{}),
20842034 };
20852035 result[@enumToInt(Feature.USMStorageClassesINTEL)] = .{
20862036 .llvm_name = null,
20872037 .description = "Enable SPIR-V capability USMStorageClassesINTEL",
2088 .dependencies = featureSet(&[_]Feature{
2089 }),
2038 .dependencies = featureSet(&[_]Feature{}),
20902039 };
20912040 result[@enumToInt(Feature.IOPipesINTEL)] = .{
20922041 .llvm_name = null,
20932042 .description = "Enable SPIR-V capability IOPipesINTEL",
2094 .dependencies = featureSet(&[_]Feature{
2095 }),
2043 .dependencies = featureSet(&[_]Feature{}),
20962044 };
20972045 result[@enumToInt(Feature.BlockingPipesINTEL)] = .{
20982046 .llvm_name = null,
20992047 .description = "Enable SPIR-V capability BlockingPipesINTEL",
2100 .dependencies = featureSet(&[_]Feature{
2101 }),
2048 .dependencies = featureSet(&[_]Feature{}),
21022049 };
21032050 result[@enumToInt(Feature.FPGARegINTEL)] = .{
21042051 .llvm_name = null,
21052052 .description = "Enable SPIR-V capability FPGARegINTEL",
2106 .dependencies = featureSet(&[_]Feature{
2107 }),
2053 .dependencies = featureSet(&[_]Feature{}),
21082054 };
21092055 result[@enumToInt(Feature.AtomicFloat32AddEXT)] = .{
21102056 .llvm_name = null,
......@@ -2123,8 +2069,7 @@ pub const all_features = blk: {
21232069 result[@enumToInt(Feature.LongConstantCompositeINTEL)] = .{
21242070 .llvm_name = null,
21252071 .description = "Enable SPIR-V capability LongConstantCompositeINTEL",
2126 .dependencies = featureSet(&[_]Feature{
2127 }),
2072 .dependencies = featureSet(&[_]Feature{}),
21282073 };
21292074 const ti = @typeInfo(Feature);
21302075 for (result) |*elem, i| {
lib/std/zig/ast.zig+9-4
......@@ -459,7 +459,8 @@ pub const Tree = struct {
459459 .keyword_extern,
460460 .keyword_export,
461461 .keyword_pub,
462 .keyword_threadlocal,
462 .keyword_inline,
463 .keyword_noinline,
463464 .string_literal,
464465 => continue,
465466
......@@ -1833,7 +1834,7 @@ pub const Tree = struct {
18331834 var result: full.FnProto = .{
18341835 .ast = info,
18351836 .visib_token = null,
1836 .extern_export_token = null,
1837 .extern_export_inline_token = null,
18371838 .lib_name = null,
18381839 .name_token = null,
18391840 .lparen = undefined,
......@@ -1842,7 +1843,11 @@ pub const Tree = struct {
18421843 while (i > 0) {
18431844 i -= 1;
18441845 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,
18461851 .keyword_pub => result.visib_token = i,
18471852 .string_literal => result.lib_name = i,
18481853 else => break,
......@@ -2123,7 +2128,7 @@ pub const full = struct {
21232128
21242129 pub const FnProto = struct {
21252130 visib_token: ?TokenIndex,
2126 extern_export_token: ?TokenIndex,
2131 extern_export_inline_token: ?TokenIndex,
21272132 lib_name: ?TokenIndex,
21282133 name_token: ?TokenIndex,
21292134 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" {
6161 );
6262}
6363
64// TODO Remove this after zig 0.9.0 is released.
65test "zig fmt: rewrite inline functions as callconv(.Inline)" {
66 try testTransform(
64test "zig fmt: respect line breaks before functions" {
65 try testCanonical(
66 \\const std = @import("std");
67 \\
6768 \\inline fn foo() void {}
6869 \\
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
81test "zig fmt: rewrite callconv(.Inline) to the inline keyword" {
82 try testTransform(
7083 \\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 {}
7191 \\
7292 );
7393}
......@@ -2867,17 +2887,17 @@ test "zig fmt: functions" {
28672887 \\extern fn puts(s: *const u8) c_int;
28682888 \\extern "c" fn puts(s: *const u8) c_int;
28692889 \\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;
28712891 \\noinline fn puts(s: *const u8) c_int;
28722892 \\pub extern fn puts(s: *const u8) c_int;
28732893 \\pub extern "c" fn puts(s: *const u8) c_int;
28742894 \\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;
28762896 \\pub noinline fn puts(s: *const u8) c_int;
28772897 \\pub extern fn puts(s: *const u8) align(2 + 2) c_int;
28782898 \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int;
28792899 \\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;
28812901 \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int;
28822902 \\
28832903 );
lib/std/zig/render.zig+18-11
......@@ -83,13 +83,23 @@ fn renderMember(gpa: *Allocator, ais: *Ais, tree: ast.Tree, decl: ast.Node.Index
8383 }
8484 }
8585 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 }
9186 try renderToken(ais, tree, i, .space);
9287 }
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 }
93103 assert(datas[decl].rhs != 0);
94104 try renderExpression(gpa, ais, tree, fn_proto, .space);
95105 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.
12461256 const token_tags = tree.tokens.items(.tag);
12471257 const token_starts = tree.tokens.items(.start);
12481258
1249 const is_inline = fn_proto.ast.fn_token > 0 and
1250 token_tags[fn_proto.ast.fn_token - 1] == .keyword_inline;
1251
12521259 const after_fn_token = fn_proto.ast.fn_token + 1;
12531260 const lparen = if (token_tags[after_fn_token] == .identifier) blk: {
12541261 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.
14241431 try renderToken(ais, tree, section_rparen, .space); // )
14251432 }
14261433
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 {
14281437 const callconv_lparen = tree.firstToken(fn_proto.ast.callconv_expr) - 1;
14291438 const callconv_rparen = tree.lastToken(fn_proto.ast.callconv_expr) + 1;
14301439
......@@ -1432,8 +1441,6 @@ fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full.
14321441 try renderToken(ais, tree, callconv_lparen, .none); // (
14331442 try renderExpression(gpa, ais, tree, fn_proto.ast.callconv_expr, .none);
14341443 try renderToken(ais, tree, callconv_rparen, .space); // )
1435 } else if (is_inline) {
1436 try ais.writer().writeAll("callconv(.Inline) ");
14371444 }
14381445
14391446 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
1919 if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx);
2020}
2121
22fn bit(input: u32, offset: u5) callconv(.Inline) bool {
22inline fn bit(input: u32, offset: u5) bool {
2323 return (input >> offset) & 1 != 0;
2424}
2525
26fn hasMask(input: u32, mask: u32) callconv(.Inline) bool {
26inline fn hasMask(input: u32, mask: u32) bool {
2727 return (input & mask) == mask;
2828}
2929
src/AstGen.zig+32-14
......@@ -996,7 +996,7 @@ fn fnProtoExpr(
996996 const token_tags = tree.tokens.items(.tag);
997997
998998 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;
10001000 break :blk token_tags[maybe_extern_token] == .keyword_extern;
10011001 };
10021002 assert(!is_extern);
......@@ -2743,15 +2743,20 @@ fn fnDecl(
27432743 };
27442744 defer decl_gz.instructions.deinit(gpa);
27452745
2746 // TODO: support noinline
27462747 const is_pub = fn_proto.visib_token != null;
27472748 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;
27492750 break :blk token_tags[maybe_export_token] == .keyword_export;
27502751 };
27512752 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;
27532754 break :blk token_tags[maybe_extern_token] == .keyword_extern;
27542755 };
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 };
27552760 const align_inst: Zir.Inst.Ref = if (fn_proto.ast.align_expr == 0) .none else inst: {
27562761 break :inst try expr(&decl_gz, &decl_gz.base, align_rl, fn_proto.ast.align_expr);
27572762 };
......@@ -2820,17 +2825,30 @@ fn fnDecl(
28202825 fn_proto.ast.return_type,
28212826 );
28222827
2823 const cc: Zir.Inst.Ref = if (fn_proto.ast.callconv_expr != 0)
2824 try AstGen.expr(
2825 &decl_gz,
2826 &decl_gz.base,
2827 .{ .ty = .calling_convention_type },
2828 fn_proto.ast.callconv_expr,
2829 )
2830 else if (is_extern) // note: https://github.com/ziglang/zig/issues/5269
2831 Zir.Inst.Ref.calling_convention_c
2832 else
2833 Zir.Inst.Ref.none;
2828 const cc: Zir.Inst.Ref = blk: {
2829 if (fn_proto.ast.callconv_expr != 0) {
2830 if (has_inline_keyword) {
2831 return astgen.failNode(
2832 fn_proto.ast.callconv_expr,
2833 "explicit callconv incompatible with inline keyword",
2834 .{},
2835 );
2836 }
2837 break :blk try AstGen.expr(
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 };
28342852
28352853 const func_inst: Zir.Inst.Ref = if (body_node == 0) func: {
28362854 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
275275}
276276
277277fn finishTarget(must_resolve: bool, bytes: []const u8) Token {
278 return if (must_resolve)
279 .{ .target_must_resolve = bytes }
280 else
281 .{ .target = bytes };
278 return if (must_resolve) .{ .target_must_resolve = bytes } else .{ .target = bytes };
282279}
283280
284281const State = enum {
src/Zir.zig+13
......@@ -1687,6 +1687,8 @@ pub const Inst = struct {
16871687 one_usize,
16881688 /// `std.builtin.CallingConvention.C`
16891689 calling_convention_c,
1690 /// `std.builtin.CallingConvention.Inline`
1691 calling_convention_inline,
16901692
16911693 _,
16921694
......@@ -1954,6 +1956,10 @@ pub const Inst = struct {
19541956 .ty = Type.initTag(.calling_convention),
19551957 .val = .{ .ptr_otherwise = &calling_convention_c_payload.base },
19561958 },
1959 .calling_convention_inline = .{
1960 .ty = Type.initTag(.calling_convention),
1961 .val = .{ .ptr_otherwise = &calling_convention_inline_payload.base },
1962 },
19571963 });
19581964 };
19591965
......@@ -1964,6 +1970,13 @@ pub const Inst = struct {
19641970 .data = @enumToInt(std.builtin.CallingConvention.C),
19651971 };
19661972
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
19671980 /// All instructions have an 8-byte payload, which is contained within
19681981 /// this union. `Tag` determines which union field is active, as well as
19691982 /// how to interpret the data within.
src/libc_installation.zig+1-2
......@@ -286,8 +286,7 @@ pub const LibCInstallation = struct {
286286 else if (is_haiku)
287287 "posix/errno.h"
288288 else
289 "sys/errno.h"
290 ;
289 "sys/errno.h";
291290
292291 var path_i: usize = 0;
293292 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 {
25182518 return min_pos - start;
25192519}
25202520
2521fn checkForCollision(start: u64, end: u64, off: u64, size: u64) callconv(.Inline) ?u64 {
2521inline fn checkForCollision(start: u64, end: u64, off: u64, size: u64) ?u64 {
25222522 const increased_size = padToIdeal(size);
25232523 const test_end = off + increased_size;
25242524 if (end > off and start < test_end) {
src/link/MachO/reloc/aarch64.zig+1-1
......@@ -585,7 +585,7 @@ pub const Parser = struct {
585585 }
586586};
587587
588fn isArithmeticOp(inst: *const [4]u8) callconv(.Inline) bool {
588inline fn isArithmeticOp(inst: *const [4]u8) bool {
589589 const group_decode = @truncate(u5, inst[3]);
590590 return ((group_decode >> 2) == 4);
591591}
src/stage1/all_types.hpp+11-1
......@@ -714,6 +714,12 @@ enum NodeType {
714714 NodeTypeAnyTypeField,
715715};
716716
717enum FnInline {
718 FnInlineAuto,
719 FnInlineAlways,
720 FnInlineNever,
721};
722
717723struct AstNodeFnProto {
718724 Buf *name;
719725 ZigList<AstNode *> params;
......@@ -729,12 +735,16 @@ struct AstNodeFnProto {
729735 AstNode *callconv_expr;
730736 Buf doc_comments;
731737
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
732743 VisibMod visib_mod;
733744 bool auto_err_set;
734745 bool is_var_args;
735746 bool is_extern;
736747 bool is_export;
737 bool is_noinline;
738748};
739749
740750struct AstNodeFnDef {
src/stage1/analyze.cpp+7-1
......@@ -1638,6 +1638,9 @@ CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) {
16381638 if (fn_proto->is_extern || fn_proto->is_export)
16391639 return CallingConventionC;
16401640
1641 if (fn_proto->fn_inline == FnInlineAlways)
1642 return CallingConventionInline;
1643
16411644 return CallingConventionUnspecified;
16421645}
16431646
......@@ -3649,7 +3652,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) {
36493652 assert(proto_node->type == NodeTypeFnProto);
36503653 AstNodeFnProto *fn_proto = &proto_node->data.fn_proto;
36513654
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);
36533656
36543657 fn_entry->proto_node = proto_node;
36553658 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) {
37423745
37433746 CallingConvention cc;
37443747 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 }
37453751 ZigType *cc_enum_value = get_builtin_type(g, "CallingConvention");
37463752
37473753 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) {
123123// zig_unreachable();
124124//}
125125
126static const char *inline_string(bool is_inline) {
127 return is_inline ? "inline" : "";
126static const char *inline_string(FnInline fn_inline) {
127 switch (fn_inline) {
128 case FnInlineAlways: return "inline ";
129 case FnInlineNever: return "noinline ";
130 case FnInlineAuto: return "";
131 }
132 zig_unreachable();
128133}
129134
130135static const char *const_or_var_string(bool is_const) {
......@@ -441,7 +446,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
441446 const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod);
442447 const char *extern_str = extern_string(node->data.fn_proto.is_extern);
443448 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);
445450 fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str);
446451 if (node->data.fn_proto.name != nullptr) {
447452 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
693693 Token *first = eat_token_if(pc, TokenIdKeywordExport);
694694 if (first == nullptr)
695695 first = eat_token_if(pc, TokenIdKeywordExtern);
696 if (first == nullptr)
697 first = eat_token_if(pc, TokenIdKeywordInline);
696698 if (first == nullptr)
697699 first = eat_token_if(pc, TokenIdKeywordNoInline);
698700 if (first != nullptr) {
......@@ -700,7 +702,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
700702 if (first->id == TokenIdKeywordExtern)
701703 lib_name = eat_token_if(pc, TokenIdStringLiteral);
702704
703 if (first->id != TokenIdKeywordNoInline) {
705 if (first->id != TokenIdKeywordNoInline && first->id != TokenIdKeywordInline) {
704706 Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal);
705707 AstNode *var_decl = ast_parse_var_decl(pc);
706708 if (var_decl != nullptr) {
......@@ -737,8 +739,17 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
737739 if (!fn_proto->data.fn_proto.is_extern)
738740 fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern;
739741 fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport;
740 if (first->id == TokenIdKeywordNoInline)
741 fn_proto->data.fn_proto.is_noinline = true;
742 switch (first->id) {
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 }
742753 fn_proto->data.fn_proto.lib_name = token_buf(lib_name);
743754
744755 AstNode *res = fn_proto;
src/tracy.zig+1-1
......@@ -31,7 +31,7 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct {
3131 pub fn end(self: Ctx) void {}
3232};
3333
34pub fn trace(comptime src: std.builtin.SourceLocation) callconv(.Inline) Ctx {
34pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
3535 if (!enable) return .{};
3636
3737 const loc: ___tracy_source_location_data = .{
src/translate_c/ast.zig+14-32
......@@ -2689,6 +2689,7 @@ fn renderFunc(c: *Context, node: Node) !NodeIndex {
26892689fn renderMacroFunc(c: *Context, node: Node) !NodeIndex {
26902690 const payload = node.castTag(.pub_inline_fn).?.data;
26912691 _ = try c.addToken(.keyword_pub, "pub");
2692 _ = try c.addToken(.keyword_inline, "inline");
26922693 const fn_token = try c.addToken(.keyword_fn, "fn");
26932694 _ = try c.addIdentifier(payload.name);
26942695
......@@ -2697,50 +2698,31 @@ fn renderMacroFunc(c: *Context, node: Node) !NodeIndex {
26972698 var span: NodeSubRange = undefined;
26982699 if (params.items.len > 1) span = try c.listToSpan(params.items);
26992700
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 };
27122701 const return_type_expr = try renderNodeGrouped(c, payload.return_type);
27132702
2714 const fn_proto = try blk: {
2715 if (params.items.len < 2)
2716 break :blk c.addNode(.{
2717 .tag = .fn_proto_one,
2703 const fn_proto = blk: {
2704 if (params.items.len < 2) {
2705 break :blk try c.addNode(.{
2706 .tag = .fn_proto_simple,
27182707 .main_token = fn_token,
27192708 .data = .{
2720 .lhs = try c.addExtra(std.zig.ast.Node.FnProtoOne{
2721 .param = params.items[0],
2722 .align_expr = 0,
2723 .section_expr = 0,
2724 .callconv_expr = callconv_expr,
2725 }),
2709 .lhs = params.items[0],
27262710 .rhs = return_type_expr,
27272711 },
2728 })
2729 else
2730 break :blk c.addNode(.{
2731 .tag = .fn_proto,
2712 });
2713 } else {
2714 break :blk try c.addNode(.{
2715 .tag = .fn_proto_multi,
27322716 .main_token = fn_token,
27332717 .data = .{
2734 .lhs = try c.addExtra(std.zig.ast.Node.FnProto{
2735 .params_start = span.start,
2736 .params_end = span.end,
2737 .align_expr = 0,
2738 .section_expr = 0,
2739 .callconv_expr = callconv_expr,
2718 .lhs = try c.addExtra(std.zig.ast.Node.SubRange{
2719 .start = span.start,
2720 .end = span.end,
27402721 }),
27412722 .rhs = return_type_expr,
27422723 },
27432724 });
2725 }
27442726 };
27452727 return c.addNode(.{
27462728 .tag = .fn_decl,
test/translate_c.zig+29-29
......@@ -232,7 +232,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
232232 cases.add("use cast param as macro fn return type",
233233 \\#define MEM_PHYSICAL_TO_K0(x) (void*)((u32)(x) + SYS_BASE_CACHED)
234234 , &[_][]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 {
236236 \\ return @import("std").meta.cast(?*c_void, @import("std").meta.cast(u32, x) + SYS_BASE_CACHED);
237237 \\}
238238 });
......@@ -273,7 +273,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
273273 ,
274274 \\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));
275275 ,
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))) {
277277 \\ 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));
278278 \\}
279279 });
......@@ -345,7 +345,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
345345 \\};
346346 \\pub const Color = struct_Color;
347347 ,
348 \\pub fn CLITERAL(type_1: anytype) callconv(.Inline) @TypeOf(type_1) {
348 \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) {
349349 \\ return type_1;
350350 \\}
351351 ,
......@@ -380,7 +380,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
380380 cases.add("correct semicolon after infixop",
381381 \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
382382 , &[_][]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)) {
384384 \\ return (_fp.*._flags & _IO_ERR_SEEN) != @as(c_int, 0);
385385 \\}
386386 });
......@@ -389,7 +389,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
389389 \\#define FOO(x) ((x >= 0) + (x >= 0))
390390 \\#define BAR 1 && 2 > 4
391391 , &[_][]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))) {
393393 \\ return @boolToInt(x >= @as(c_int, 0)) + @boolToInt(x >= @as(c_int, 0));
394394 \\}
395395 ,
......@@ -438,7 +438,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
438438 \\ break :blk bar;
439439 \\};
440440 ,
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))) {
442442 \\ return blk: {
443443 \\ _ = &x;
444444 \\ _ = @as(c_int, 3);
......@@ -1782,13 +1782,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
17821782 , &[_][]const u8{
17831783 \\pub extern var fn_ptr: ?fn () callconv(.C) void;
17841784 ,
1785 \\pub fn foo() callconv(.Inline) void {
1785 \\pub inline fn foo() void {
17861786 \\ return fn_ptr.?();
17871787 \\}
17881788 ,
17891789 \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8;
17901790 ,
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 {
17921792 \\ return fn_ptr2.?(arg_1, arg_2);
17931793 \\}
17941794 });
......@@ -1821,7 +1821,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
18211821 ,
18221822 \\pub const glClearPFN = PFNGLCLEARPROC;
18231823 ,
1824 \\pub fn glClearUnion(arg_2: GLbitfield) callconv(.Inline) void {
1824 \\pub inline fn glClearUnion(arg_2: GLbitfield) void {
18251825 \\ return glProcs.gl.Clear.?(arg_2);
18261826 \\}
18271827 ,
......@@ -1842,15 +1842,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
18421842 , &[_][]const u8{
18431843 \\pub extern var c: c_int;
18441844 ,
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)) {
18461846 \\ return c_1 * @as(c_int, 2);
18471847 \\}
18481848 ,
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) {
18501850 \\ return L + b;
18511851 \\}
18521852 ,
1853 \\pub fn BAR() callconv(.Inline) @TypeOf(c * c) {
1853 \\pub inline fn BAR() @TypeOf(c * c) {
18541854 \\ return c * c;
18551855 \\}
18561856 });
......@@ -2549,7 +2549,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
25492549 cases.add("macro call",
25502550 \\#define CALL(arg) bar(arg)
25512551 , &[_][]const u8{
2552 \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar(arg)) {
2552 \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) {
25532553 \\ return bar(arg);
25542554 \\}
25552555 });
......@@ -2557,7 +2557,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
25572557 cases.add("macro call with no args",
25582558 \\#define CALL(arg) bar()
25592559 , &[_][]const u8{
2560 \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar()) {
2560 \\pub inline fn CALL(arg: anytype) @TypeOf(bar()) {
25612561 \\ return bar();
25622562 \\}
25632563 });
......@@ -3120,7 +3120,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
31203120 \\#define BAR (void*) a
31213121 \\#define BAZ (uint32_t)(2)
31223122 , &[_][]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))) {
31243124 \\ return baz(@import("std").meta.cast(?*c_void, baz));
31253125 \\}
31263126 ,
......@@ -3160,11 +3160,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
31603160 \\#define MIN(a, b) ((b) < (a) ? (b) : (a))
31613161 \\#define MAX(a, b) ((b) > (a) ? (b) : (a))
31623162 , &[_][]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) {
31643164 \\ return if (b < a) b else a;
31653165 \\}
31663166 ,
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) {
31683168 \\ return if (b > a) b else a;
31693169 \\}
31703170 });
......@@ -3351,7 +3351,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
33513351 \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)
33523352 \\
33533353 , &[_][]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) {
33553355 \\ return @import("std").meta.cast(_XPrivDisplay, dpy).*.default_screen;
33563356 \\}
33573357 });
......@@ -3501,17 +3501,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
35013501 });
35023502
35033503 cases.add("global assembly",
3504 \\__asm__(".globl func\n\t"
3505 \\ ".type func, @function\n\t"
3506 \\ "func:\n\t"
3507 \\ ".cfi_startproc\n\t"
3508 \\ "movl $42, %eax\n\t"
3509 \\ "ret\n\t"
3510 \\ ".cfi_endproc");
3511 , &[_][]const u8{
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");
3514 \\}
3504 \\__asm__(".globl func\n\t"
3505 \\ ".type func, @function\n\t"
3506 \\ "func:\n\t"
3507 \\ ".cfi_startproc\n\t"
3508 \\ "movl $42, %eax\n\t"
3509 \\ "ret\n\t"
3510 \\ ".cfi_endproc");
3511 , &[_][]const u8{
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");
3514 \\}
35153515 });
35163516
35173517 cases.add("Demote function that initializes opaque struct",