| author | |
| committer | |
| log | d3565ed6b48c9c66128f181e7b90b5348504cb3f |
| tree | 99a03080830c1f9433046427feb18f90cade6c09 |
| parent | d98f09e4f67fb2848be6052466db035450326605 |
| parent | bb4f4c043e7dde4e8b9fcbf0af9329d3fd08ff7b |
| signature |
Replace inline fn with callconv(.Inline)51 files changed, 326 insertions(+), 332 deletions(-)
doc/langref.html.in+2-2| ... | ... | @@ -4240,9 +4240,9 @@ fn _start() callconv(.Naked) noreturn { |
| 4240 | 4240 | abort(); |
| 4241 | 4241 | } |
| 4242 | 4242 | |
| 4243 | // The inline specifier forces a function to be inlined at all call sites. | |
| 4243 | // The inline calling convention forces a function to be inlined at all call sites. | |
| 4244 | 4244 | // If the function cannot be inlined, it is a compile-time error. |
| 4245 | inline fn shiftLeftOne(a: u32) u32 { | |
| 4245 | fn shiftLeftOne(a: u32) callconv(.Inline) u32 { | |
| 4246 | 4246 | return a << 1; |
| 4247 | 4247 | } |
| 4248 | 4248 |
lib/std/builtin.zig+2-9| ... | ... | @@ -155,6 +155,7 @@ pub const CallingConvention = enum { |
| 155 | 155 | C, |
| 156 | 156 | Naked, |
| 157 | 157 | Async, |
| 158 | Inline, | |
| 158 | 159 | Interrupt, |
| 159 | 160 | Signal, |
| 160 | 161 | Stdcall, |
| ... | ... | @@ -404,21 +405,13 @@ pub const TypeInfo = union(enum) { |
| 404 | 405 | /// therefore must be kept in sync with the compiler implementation. |
| 405 | 406 | pub const FnDecl = struct { |
| 406 | 407 | fn_type: type, |
| 407 | inline_type: Inline, | |
| 408 | is_noinline: bool, | |
| 408 | 409 | is_var_args: bool, |
| 409 | 410 | is_extern: bool, |
| 410 | 411 | is_export: bool, |
| 411 | 412 | lib_name: ?[]const u8, |
| 412 | 413 | return_type: type, |
| 413 | 414 | arg_names: []const []const u8, |
| 414 | ||
| 415 | /// This data structure is used by the Zig language code generation and | |
| 416 | /// therefore must be kept in sync with the compiler implementation. | |
| 417 | pub const Inline = enum { | |
| 418 | Auto, | |
| 419 | Always, | |
| 420 | Never, | |
| 421 | }; | |
| 422 | 415 | }; |
| 423 | 416 | }; |
| 424 | 417 | }; |
lib/std/c/builtins.zig+49-49| ... | ... | @@ -6,70 +6,70 @@ |
| 6 | 6 | |
| 7 | 7 | const std = @import("std"); |
| 8 | 8 | |
| 9 | pub inline fn __builtin_bswap16(val: u16) callconv(.C) u16 { return @byteSwap(u16, val); } | |
| 10 | pub inline fn __builtin_bswap32(val: u32) callconv(.C) u32 { return @byteSwap(u32, val); } | |
| 11 | pub inline fn __builtin_bswap64(val: u64) callconv(.C) u64 { return @byteSwap(u64, val); } | |
| 9 | pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 { return @byteSwap(u16, val); } | |
| 10 | pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 { return @byteSwap(u32, val); } | |
| 11 | pub fn __builtin_bswap64(val: u64) callconv(.Inline) u64 { return @byteSwap(u64, val); } | |
| 12 | 12 | |
| 13 | pub inline fn __builtin_signbit(val: f64) callconv(.C) c_int { return @boolToInt(std.math.signbit(val)); } | |
| 14 | pub inline fn __builtin_signbitf(val: f32) callconv(.C) c_int { return @boolToInt(std.math.signbit(val)); } | |
| 13 | pub fn __builtin_signbit(val: f64) callconv(.Inline) c_int { return @boolToInt(std.math.signbit(val)); } | |
| 14 | pub fn __builtin_signbitf(val: f32) callconv(.Inline) c_int { return @boolToInt(std.math.signbit(val)); } | |
| 15 | 15 | |
| 16 | pub inline fn __builtin_popcount(val: c_uint) callconv(.C) c_int { | |
| 16 | pub fn __builtin_popcount(val: c_uint) callconv(.Inline) c_int { | |
| 17 | 17 | // popcount of a c_uint will never exceed the capacity of a c_int |
| 18 | 18 | @setRuntimeSafety(false); |
| 19 | 19 | return @bitCast(c_int, @as(c_uint, @popCount(c_uint, val))); |
| 20 | 20 | } |
| 21 | pub inline fn __builtin_ctz(val: c_uint) callconv(.C) c_int { | |
| 21 | pub fn __builtin_ctz(val: c_uint) callconv(.Inline) c_int { | |
| 22 | 22 | // Returns the number of trailing 0-bits in val, starting at the least significant bit position. |
| 23 | 23 | // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint |
| 24 | 24 | @setRuntimeSafety(false); |
| 25 | 25 | return @bitCast(c_int, @as(c_uint, @ctz(c_uint, val))); |
| 26 | 26 | } |
| 27 | pub inline fn __builtin_clz(val: c_uint) callconv(.C) c_int { | |
| 27 | pub fn __builtin_clz(val: c_uint) callconv(.Inline) c_int { | |
| 28 | 28 | // Returns the number of leading 0-bits in x, starting at the most significant bit position. |
| 29 | 29 | // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint |
| 30 | 30 | @setRuntimeSafety(false); |
| 31 | 31 | return @bitCast(c_int, @as(c_uint, @clz(c_uint, val))); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | pub inline fn __builtin_sqrt(val: f64) callconv(.C) f64 { return @sqrt(val); } | |
| 35 | pub inline fn __builtin_sqrtf(val: f32) callconv(.C) f32 { return @sqrt(val); } | |
| 36 | ||
| 37 | pub inline fn __builtin_sin(val: f64) callconv(.C) f64 { return @sin(val); } | |
| 38 | pub inline fn __builtin_sinf(val: f32) callconv(.C) f32 { return @sin(val); } | |
| 39 | pub inline fn __builtin_cos(val: f64) callconv(.C) f64 { return @cos(val); } | |
| 40 | pub inline fn __builtin_cosf(val: f32) callconv(.C) f32 { return @cos(val); } | |
| 41 | ||
| 42 | pub inline fn __builtin_exp(val: f64) callconv(.C) f64 { return @exp(val); } | |
| 43 | pub inline fn __builtin_expf(val: f32) callconv(.C) f32 { return @exp(val); } | |
| 44 | pub inline fn __builtin_exp2(val: f64) callconv(.C) f64 { return @exp2(val); } | |
| 45 | pub inline fn __builtin_exp2f(val: f32) callconv(.C) f32 { return @exp2(val); } | |
| 46 | pub inline fn __builtin_log(val: f64) callconv(.C) f64 { return @log(val); } | |
| 47 | pub inline fn __builtin_logf(val: f32) callconv(.C) f32 { return @log(val); } | |
| 48 | pub inline fn __builtin_log2(val: f64) callconv(.C) f64 { return @log2(val); } | |
| 49 | pub inline fn __builtin_log2f(val: f32) callconv(.C) f32 { return @log2(val); } | |
| 50 | pub inline fn __builtin_log10(val: f64) callconv(.C) f64 { return @log10(val); } | |
| 51 | pub inline fn __builtin_log10f(val: f32) callconv(.C) f32 { return @log10(val); } | |
| 34 | pub fn __builtin_sqrt(val: f64) callconv(.Inline) f64 { return @sqrt(val); } | |
| 35 | pub fn __builtin_sqrtf(val: f32) callconv(.Inline) f32 { return @sqrt(val); } | |
| 36 | ||
| 37 | pub fn __builtin_sin(val: f64) callconv(.Inline) f64 { return @sin(val); } | |
| 38 | pub fn __builtin_sinf(val: f32) callconv(.Inline) f32 { return @sin(val); } | |
| 39 | pub fn __builtin_cos(val: f64) callconv(.Inline) f64 { return @cos(val); } | |
| 40 | pub fn __builtin_cosf(val: f32) callconv(.Inline) f32 { return @cos(val); } | |
| 41 | ||
| 42 | pub fn __builtin_exp(val: f64) callconv(.Inline) f64 { return @exp(val); } | |
| 43 | pub fn __builtin_expf(val: f32) callconv(.Inline) f32 { return @exp(val); } | |
| 44 | pub fn __builtin_exp2(val: f64) callconv(.Inline) f64 { return @exp2(val); } | |
| 45 | pub fn __builtin_exp2f(val: f32) callconv(.Inline) f32 { return @exp2(val); } | |
| 46 | pub fn __builtin_log(val: f64) callconv(.Inline) f64 { return @log(val); } | |
| 47 | pub fn __builtin_logf(val: f32) callconv(.Inline) f32 { return @log(val); } | |
| 48 | pub fn __builtin_log2(val: f64) callconv(.Inline) f64 { return @log2(val); } | |
| 49 | pub fn __builtin_log2f(val: f32) callconv(.Inline) f32 { return @log2(val); } | |
| 50 | pub fn __builtin_log10(val: f64) callconv(.Inline) f64 { return @log10(val); } | |
| 51 | pub fn __builtin_log10f(val: f32) callconv(.Inline) f32 { return @log10(val); } | |
| 52 | 52 | |
| 53 | 53 | // Standard C Library bug: The absolute value of the most negative integer remains negative. |
| 54 | pub inline fn __builtin_abs(val: c_int) callconv(.C) c_int { return std.math.absInt(val) catch std.math.minInt(c_int); } | |
| 55 | pub inline fn __builtin_fabs(val: f64) callconv(.C) f64 { return @fabs(val); } | |
| 56 | pub inline fn __builtin_fabsf(val: f32) callconv(.C) f32 { return @fabs(val); } | |
| 57 | ||
| 58 | pub inline fn __builtin_floor(val: f64) callconv(.C) f64 { return @floor(val); } | |
| 59 | pub inline fn __builtin_floorf(val: f32) callconv(.C) f32 { return @floor(val); } | |
| 60 | pub inline fn __builtin_ceil(val: f64) callconv(.C) f64 { return @ceil(val); } | |
| 61 | pub inline fn __builtin_ceilf(val: f32) callconv(.C) f32 { return @ceil(val); } | |
| 62 | pub inline fn __builtin_trunc(val: f64) callconv(.C) f64 { return @trunc(val); } | |
| 63 | pub inline fn __builtin_truncf(val: f32) callconv(.C) f32 { return @trunc(val); } | |
| 64 | pub inline fn __builtin_round(val: f64) callconv(.C) f64 { return @round(val); } | |
| 65 | pub inline fn __builtin_roundf(val: f32) callconv(.C) f32 { return @round(val); } | |
| 66 | ||
| 67 | pub inline fn __builtin_strlen(s: [*c]const u8) callconv(.C) usize { return std.mem.lenZ(s); } | |
| 68 | pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.C) c_int { | |
| 54 | pub fn __builtin_abs(val: c_int) callconv(.Inline) c_int { return std.math.absInt(val) catch std.math.minInt(c_int); } | |
| 55 | pub fn __builtin_fabs(val: f64) callconv(.Inline) f64 { return @fabs(val); } | |
| 56 | pub fn __builtin_fabsf(val: f32) callconv(.Inline) f32 { return @fabs(val); } | |
| 57 | ||
| 58 | pub fn __builtin_floor(val: f64) callconv(.Inline) f64 { return @floor(val); } | |
| 59 | pub fn __builtin_floorf(val: f32) callconv(.Inline) f32 { return @floor(val); } | |
| 60 | pub fn __builtin_ceil(val: f64) callconv(.Inline) f64 { return @ceil(val); } | |
| 61 | pub fn __builtin_ceilf(val: f32) callconv(.Inline) f32 { return @ceil(val); } | |
| 62 | pub fn __builtin_trunc(val: f64) callconv(.Inline) f64 { return @trunc(val); } | |
| 63 | pub fn __builtin_truncf(val: f32) callconv(.Inline) f32 { return @trunc(val); } | |
| 64 | pub fn __builtin_round(val: f64) callconv(.Inline) f64 { return @round(val); } | |
| 65 | pub fn __builtin_roundf(val: f32) callconv(.Inline) f32 { return @round(val); } | |
| 66 | ||
| 67 | pub fn __builtin_strlen(s: [*c]const u8) callconv(.Inline) usize { return std.mem.lenZ(s); } | |
| 68 | pub fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.Inline) c_int { | |
| 69 | 69 | return @as(c_int, std.cstr.cmp(s1, s2)); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.C) usize { | |
| 72 | pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) usize { | |
| 73 | 73 | // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html |
| 74 | 74 | // If it is not possible to determine which objects ptr points to at compile time, |
| 75 | 75 | // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 |
| ... | ... | @@ -79,37 +79,37 @@ pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.C) |
| 79 | 79 | unreachable; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | pub inline fn __builtin___memset_chk( | |
| 82 | pub fn __builtin___memset_chk( | |
| 83 | 83 | dst: ?*c_void, |
| 84 | 84 | val: c_int, |
| 85 | 85 | len: usize, |
| 86 | 86 | remaining: usize, |
| 87 | ) callconv(.C) ?*c_void { | |
| 87 | ) callconv(.Inline) ?*c_void { | |
| 88 | 88 | if (len > remaining) @panic("std.c.builtins.memset_chk called with len > remaining"); |
| 89 | 89 | return __builtin_memset(dst, val, len); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | pub inline fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) callconv(.C) ?*c_void { | |
| 92 | pub fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) callconv(.Inline) ?*c_void { | |
| 93 | 93 | const dst_cast = @ptrCast([*c]u8, dst); |
| 94 | 94 | @memset(dst_cast, @bitCast(u8, @truncate(i8, val)), len); |
| 95 | 95 | return dst; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | pub inline fn __builtin___memcpy_chk( | |
| 98 | pub fn __builtin___memcpy_chk( | |
| 99 | 99 | noalias dst: ?*c_void, |
| 100 | 100 | noalias src: ?*const c_void, |
| 101 | 101 | len: usize, |
| 102 | 102 | remaining: usize, |
| 103 | ) callconv(.C) ?*c_void { | |
| 103 | ) callconv(.Inline) ?*c_void { | |
| 104 | 104 | if (len > remaining) @panic("std.c.builtins.memcpy_chk called with len > remaining"); |
| 105 | 105 | return __builtin_memcpy(dst, src, len); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | pub inline fn __builtin_memcpy( | |
| 108 | pub fn __builtin_memcpy( | |
| 109 | 109 | noalias dst: ?*c_void, |
| 110 | 110 | noalias src: ?*const c_void, |
| 111 | 111 | len: usize, |
| 112 | ) callconv(.C) ?*c_void { | |
| 112 | ) callconv(.Inline) ?*c_void { | |
| 113 | 113 | const dst_cast = @ptrCast([*c]u8, dst); |
| 114 | 114 | const src_cast = @ptrCast([*c]const u8, src); |
| 115 | 115 |
lib/std/compress/deflate.zig+1-1| ... | ... | @@ -209,7 +209,7 @@ pub fn InflateStream(comptime ReaderType: type) type { |
| 209 | 209 | |
| 210 | 210 | // Insert a single byte into the window. |
| 211 | 211 | // Assumes there's enough space. |
| 212 | inline fn appendUnsafe(self: *WSelf, value: u8) void { | |
| 212 | fn appendUnsafe(self: *WSelf, value: u8) callconv(.Inline) void { | |
| 213 | 213 | self.buf[self.wi] = value; |
| 214 | 214 | self.wi = (self.wi + 1) & (self.buf.len - 1); |
| 215 | 215 | self.el += 1; |
lib/std/crypto/25519/curve25519.zig+2-2| ... | ... | @@ -15,12 +15,12 @@ pub const Curve25519 = struct { |
| 15 | 15 | x: Fe, |
| 16 | 16 | |
| 17 | 17 | /// Decode a Curve25519 point from its compressed (X) coordinates. |
| 18 | pub inline fn fromBytes(s: [32]u8) Curve25519 { | |
| 18 | pub fn fromBytes(s: [32]u8) callconv(.Inline) Curve25519 { | |
| 19 | 19 | return .{ .x = Fe.fromBytes(s) }; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /// Encode a Curve25519 point. |
| 23 | pub inline fn toBytes(p: Curve25519) [32]u8 { | |
| 23 | pub fn toBytes(p: Curve25519) callconv(.Inline) [32]u8 { | |
| 24 | 24 | return p.x.toBytes(); |
| 25 | 25 | } |
| 26 | 26 |
lib/std/crypto/25519/edwards25519.zig+3-3| ... | ... | @@ -92,7 +92,7 @@ pub const Edwards25519 = struct { |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /// Flip the sign of the X coordinate. |
| 95 | pub inline fn neg(p: Edwards25519) Edwards25519 { | |
| 95 | pub fn neg(p: Edwards25519) callconv(.Inline) Edwards25519 { | |
| 96 | 96 | return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() }; |
| 97 | 97 | } |
| 98 | 98 | |
| ... | ... | @@ -137,14 +137,14 @@ pub const Edwards25519 = struct { |
| 137 | 137 | return p.add(q.neg()); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | inline fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) void { | |
| 140 | fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) callconv(.Inline) void { | |
| 141 | 141 | p.x.cMov(a.x, c); |
| 142 | 142 | p.y.cMov(a.y, c); |
| 143 | 143 | p.z.cMov(a.z, c); |
| 144 | 144 | p.t.cMov(a.t, c); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | inline fn pcSelect(comptime n: usize, pc: [n]Edwards25519, b: u8) Edwards25519 { | |
| 147 | fn pcSelect(comptime n: usize, pc: [n]Edwards25519, b: u8) callconv(.Inline) Edwards25519 { | |
| 148 | 148 | var t = Edwards25519.identityElement; |
| 149 | 149 | comptime var i: u8 = 1; |
| 150 | 150 | inline while (i < pc.len) : (i += 1) { |
lib/std/crypto/25519/field.zig+14-14| ... | ... | @@ -52,7 +52,7 @@ pub const Fe = struct { |
| 52 | 52 | pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } }; |
| 53 | 53 | |
| 54 | 54 | /// Return true if the field element is zero |
| 55 | pub inline fn isZero(fe: Fe) bool { | |
| 55 | pub fn isZero(fe: Fe) callconv(.Inline) bool { | |
| 56 | 56 | var reduced = fe; |
| 57 | 57 | reduced.reduce(); |
| 58 | 58 | const limbs = reduced.limbs; |
| ... | ... | @@ -60,7 +60,7 @@ pub const Fe = struct { |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /// Return true if both field elements are equivalent |
| 63 | pub inline fn equivalent(a: Fe, b: Fe) bool { | |
| 63 | pub fn equivalent(a: Fe, b: Fe) callconv(.Inline) bool { | |
| 64 | 64 | return a.sub(b).isZero(); |
| 65 | 65 | } |
| 66 | 66 | |
| ... | ... | @@ -164,7 +164,7 @@ pub const Fe = struct { |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /// Add a field element |
| 167 | pub inline fn add(a: Fe, b: Fe) Fe { | |
| 167 | pub fn add(a: Fe, b: Fe) callconv(.Inline) Fe { | |
| 168 | 168 | var fe: Fe = undefined; |
| 169 | 169 | comptime var i = 0; |
| 170 | 170 | inline while (i < 5) : (i += 1) { |
| ... | ... | @@ -174,7 +174,7 @@ pub const Fe = struct { |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /// Substract a field elememnt |
| 177 | pub inline fn sub(a: Fe, b: Fe) Fe { | |
| 177 | pub fn sub(a: Fe, b: Fe) callconv(.Inline) Fe { | |
| 178 | 178 | var fe = b; |
| 179 | 179 | comptime var i = 0; |
| 180 | 180 | inline while (i < 4) : (i += 1) { |
| ... | ... | @@ -193,17 +193,17 @@ pub const Fe = struct { |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /// Negate a field element |
| 196 | pub inline fn neg(a: Fe) Fe { | |
| 196 | pub fn neg(a: Fe) callconv(.Inline) Fe { | |
| 197 | 197 | return zero.sub(a); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /// Return true if a field element is negative |
| 201 | pub inline fn isNegative(a: Fe) bool { | |
| 201 | pub fn isNegative(a: Fe) callconv(.Inline) bool { | |
| 202 | 202 | return (a.toBytes()[0] & 1) != 0; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /// Conditonally replace a field element with `a` if `c` is positive |
| 206 | pub inline fn cMov(fe: *Fe, a: Fe, c: u64) void { | |
| 206 | pub fn cMov(fe: *Fe, a: Fe, c: u64) callconv(.Inline) void { | |
| 207 | 207 | const mask: u64 = 0 -% c; |
| 208 | 208 | var x = fe.*; |
| 209 | 209 | comptime var i = 0; |
| ... | ... | @@ -244,7 +244,7 @@ pub const Fe = struct { |
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | inline fn _carry128(r: *[5]u128) Fe { | |
| 247 | fn _carry128(r: *[5]u128) callconv(.Inline) Fe { | |
| 248 | 248 | var rs: [5]u64 = undefined; |
| 249 | 249 | comptime var i = 0; |
| 250 | 250 | inline while (i < 4) : (i += 1) { |
| ... | ... | @@ -265,7 +265,7 @@ pub const Fe = struct { |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /// Multiply two field elements |
| 268 | pub inline fn mul(a: Fe, b: Fe) Fe { | |
| 268 | pub fn mul(a: Fe, b: Fe) callconv(.Inline) Fe { | |
| 269 | 269 | var ax: [5]u128 = undefined; |
| 270 | 270 | var bx: [5]u128 = undefined; |
| 271 | 271 | var a19: [5]u128 = undefined; |
| ... | ... | @@ -288,7 +288,7 @@ pub const Fe = struct { |
| 288 | 288 | return _carry128(&r); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | inline fn _sq(a: Fe, double: comptime bool) Fe { | |
| 291 | fn _sq(a: Fe, double: comptime bool) callconv(.Inline) Fe { | |
| 292 | 292 | var ax: [5]u128 = undefined; |
| 293 | 293 | var r: [5]u128 = undefined; |
| 294 | 294 | comptime var i = 0; |
| ... | ... | @@ -317,17 +317,17 @@ pub const Fe = struct { |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /// Square a field element |
| 320 | pub inline fn sq(a: Fe) Fe { | |
| 320 | pub fn sq(a: Fe) callconv(.Inline) Fe { | |
| 321 | 321 | return _sq(a, false); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /// Square and double a field element |
| 325 | pub inline fn sq2(a: Fe) Fe { | |
| 325 | pub fn sq2(a: Fe) callconv(.Inline) Fe { | |
| 326 | 326 | return _sq(a, true); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /// Multiply a field element with a small (32-bit) integer |
| 330 | pub inline fn mul32(a: Fe, comptime n: u32) Fe { | |
| 330 | pub fn mul32(a: Fe, comptime n: u32) callconv(.Inline) Fe { | |
| 331 | 331 | const sn = @intCast(u128, n); |
| 332 | 332 | var fe: Fe = undefined; |
| 333 | 333 | var x: u128 = 0; |
| ... | ... | @@ -342,7 +342,7 @@ pub const Fe = struct { |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /// Square a field element `n` times |
| 345 | inline fn sqn(a: Fe, comptime n: comptime_int) Fe { | |
| 345 | fn sqn(a: Fe, comptime n: comptime_int) callconv(.Inline) Fe { | |
| 346 | 346 | var i: usize = 0; |
| 347 | 347 | var fe = a; |
| 348 | 348 | while (i < n) : (i += 1) { |
lib/std/crypto/25519/ristretto255.zig+4-4| ... | ... | @@ -42,7 +42,7 @@ pub const Ristretto255 = struct { |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /// Reject the neutral element. |
| 45 | pub inline fn rejectIdentity(p: Ristretto255) !void { | |
| 45 | pub fn rejectIdentity(p: Ristretto255) callconv(.Inline) !void { | |
| 46 | 46 | return p.p.rejectIdentity(); |
| 47 | 47 | } |
| 48 | 48 | |
| ... | ... | @@ -141,19 +141,19 @@ pub const Ristretto255 = struct { |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /// Double a Ristretto255 element. |
| 144 | pub inline fn dbl(p: Ristretto255) Ristretto255 { | |
| 144 | pub fn dbl(p: Ristretto255) callconv(.Inline) Ristretto255 { | |
| 145 | 145 | return .{ .p = p.p.dbl() }; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /// Add two Ristretto255 elements. |
| 149 | pub inline fn add(p: Ristretto255, q: Ristretto255) Ristretto255 { | |
| 149 | pub fn add(p: Ristretto255, q: Ristretto255) callconv(.Inline) Ristretto255 { | |
| 150 | 150 | return .{ .p = p.p.add(q.p) }; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /// Multiply a Ristretto255 element with a scalar. |
| 154 | 154 | /// Return error.WeakPublicKey if the resulting element is |
| 155 | 155 | /// the identity element. |
| 156 | pub inline fn mul(p: Ristretto255, s: [encoded_length]u8) !Ristretto255 { | |
| 156 | pub fn mul(p: Ristretto255, s: [encoded_length]u8) callconv(.Inline) !Ristretto255 { | |
| 157 | 157 | return Ristretto255{ .p = try p.p.mul(s) }; |
| 158 | 158 | } |
| 159 | 159 |
lib/std/crypto/25519/scalar.zig+1-1| ... | ... | @@ -46,7 +46,7 @@ pub fn reduce64(s: [64]u8) [32]u8 { |
| 46 | 46 | |
| 47 | 47 | /// Perform the X25519 "clamping" operation. |
| 48 | 48 | /// The scalar is then guaranteed to be a multiple of the cofactor. |
| 49 | pub inline fn clamp(s: *[32]u8) void { | |
| 49 | pub fn clamp(s: *[32]u8) callconv(.Inline) void { | |
| 50 | 50 | s[0] &= 248; |
| 51 | 51 | s[31] = (s[31] & 127) | 64; |
| 52 | 52 | } |
lib/std/crypto/aegis.zig+2-2| ... | ... | @@ -35,7 +35,7 @@ const State128L = struct { |
| 35 | 35 | return state; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | inline fn update(state: *State128L, d1: AesBlock, d2: AesBlock) void { | |
| 38 | fn update(state: *State128L, d1: AesBlock, d2: AesBlock) callconv(.Inline) void { | |
| 39 | 39 | const blocks = &state.blocks; |
| 40 | 40 | const tmp = blocks[7]; |
| 41 | 41 | comptime var i: usize = 7; |
| ... | ... | @@ -207,7 +207,7 @@ const State256 = struct { |
| 207 | 207 | return state; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | inline fn update(state: *State256, d: AesBlock) void { | |
| 210 | fn update(state: *State256, d: AesBlock) callconv(.Inline) void { | |
| 211 | 211 | const blocks = &state.blocks; |
| 212 | 212 | const tmp = blocks[5].encrypt(blocks[0]); |
| 213 | 213 | comptime var i: usize = 5; |
lib/std/crypto/aes/aesni.zig+16-16| ... | ... | @@ -19,24 +19,24 @@ pub const Block = struct { |
| 19 | 19 | repr: BlockVec, |
| 20 | 20 | |
| 21 | 21 | /// Convert a byte sequence into an internal representation. |
| 22 | pub inline fn fromBytes(bytes: *const [16]u8) Block { | |
| 22 | pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { | |
| 23 | 23 | const repr = mem.bytesToValue(BlockVec, bytes); |
| 24 | 24 | return Block{ .repr = repr }; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /// Convert the internal representation of a block into a byte sequence. |
| 28 | pub inline fn toBytes(block: Block) [16]u8 { | |
| 28 | pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { | |
| 29 | 29 | return mem.toBytes(block.repr); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /// XOR the block with a byte sequence. |
| 33 | pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { | |
| 33 | pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { | |
| 34 | 34 | const x = block.repr ^ fromBytes(bytes).repr; |
| 35 | 35 | return mem.toBytes(x); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /// Encrypt a block with a round key. |
| 39 | pub inline fn encrypt(block: Block, round_key: Block) Block { | |
| 39 | pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { | |
| 40 | 40 | return Block{ |
| 41 | 41 | .repr = asm ( |
| 42 | 42 | \\ vaesenc %[rk], %[in], %[out] |
| ... | ... | @@ -48,7 +48,7 @@ pub const Block = struct { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /// Encrypt a block with the last round key. |
| 51 | pub inline fn encryptLast(block: Block, round_key: Block) Block { | |
| 51 | pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { | |
| 52 | 52 | return Block{ |
| 53 | 53 | .repr = asm ( |
| 54 | 54 | \\ vaesenclast %[rk], %[in], %[out] |
| ... | ... | @@ -60,7 +60,7 @@ pub const Block = struct { |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /// Decrypt a block with a round key. |
| 63 | pub inline fn decrypt(block: Block, inv_round_key: Block) Block { | |
| 63 | pub fn decrypt(block: Block, inv_round_key: Block) callconv(.Inline) Block { | |
| 64 | 64 | return Block{ |
| 65 | 65 | .repr = asm ( |
| 66 | 66 | \\ vaesdec %[rk], %[in], %[out] |
| ... | ... | @@ -72,7 +72,7 @@ pub const Block = struct { |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /// Decrypt a block with the last round key. |
| 75 | pub inline fn decryptLast(block: Block, inv_round_key: Block) Block { | |
| 75 | pub fn decryptLast(block: Block, inv_round_key: Block) callconv(.Inline) Block { | |
| 76 | 76 | return Block{ |
| 77 | 77 | .repr = asm ( |
| 78 | 78 | \\ vaesdeclast %[rk], %[in], %[out] |
| ... | ... | @@ -84,17 +84,17 @@ pub const Block = struct { |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /// Apply the bitwise XOR operation to the content of two blocks. |
| 87 | pub inline fn xorBlocks(block1: Block, block2: Block) Block { | |
| 87 | pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 88 | 88 | return Block{ .repr = block1.repr ^ block2.repr }; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /// Apply the bitwise AND operation to the content of two blocks. |
| 92 | pub inline fn andBlocks(block1: Block, block2: Block) Block { | |
| 92 | pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 93 | 93 | return Block{ .repr = block1.repr & block2.repr }; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /// Apply the bitwise OR operation to the content of two blocks. |
| 97 | pub inline fn orBlocks(block1: Block, block2: Block) Block { | |
| 97 | pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 98 | 98 | return Block{ .repr = block1.repr | block2.repr }; |
| 99 | 99 | } |
| 100 | 100 | |
| ... | ... | @@ -114,7 +114,7 @@ pub const Block = struct { |
| 114 | 114 | }; |
| 115 | 115 | |
| 116 | 116 | /// Encrypt multiple blocks in parallel, each their own round key. |
| 117 | pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { | |
| 117 | pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { | |
| 118 | 118 | comptime var i = 0; |
| 119 | 119 | var out: [count]Block = undefined; |
| 120 | 120 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -124,7 +124,7 @@ pub const Block = struct { |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /// Decrypt multiple blocks in parallel, each their own round key. |
| 127 | pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { | |
| 127 | pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { | |
| 128 | 128 | comptime var i = 0; |
| 129 | 129 | var out: [count]Block = undefined; |
| 130 | 130 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -134,7 +134,7 @@ pub const Block = struct { |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /// Encrypt multiple blocks in parallel with the same round key. |
| 137 | pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { | |
| 137 | pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | |
| 138 | 138 | comptime var i = 0; |
| 139 | 139 | var out: [count]Block = undefined; |
| 140 | 140 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -144,7 +144,7 @@ pub const Block = struct { |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /// Decrypt multiple blocks in parallel with the same round key. |
| 147 | pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { | |
| 147 | pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | |
| 148 | 148 | comptime var i = 0; |
| 149 | 149 | var out: [count]Block = undefined; |
| 150 | 150 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -154,7 +154,7 @@ pub const Block = struct { |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /// Encrypt multiple blocks in parallel with the same last round key. |
| 157 | pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { | |
| 157 | pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | |
| 158 | 158 | comptime var i = 0; |
| 159 | 159 | var out: [count]Block = undefined; |
| 160 | 160 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -164,7 +164,7 @@ pub const Block = struct { |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /// Decrypt multiple blocks in parallel with the same last round key. |
| 167 | pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { | |
| 167 | pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | |
| 168 | 168 | comptime var i = 0; |
| 169 | 169 | var out: [count]Block = undefined; |
| 170 | 170 | inline while (i < count) : (i += 1) { |
lib/std/crypto/aes/armcrypto.zig+16-16| ... | ... | @@ -19,18 +19,18 @@ pub const Block = struct { |
| 19 | 19 | repr: BlockVec, |
| 20 | 20 | |
| 21 | 21 | /// Convert a byte sequence into an internal representation. |
| 22 | pub inline fn fromBytes(bytes: *const [16]u8) Block { | |
| 22 | pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { | |
| 23 | 23 | const repr = mem.bytesToValue(BlockVec, bytes); |
| 24 | 24 | return Block{ .repr = repr }; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /// Convert the internal representation of a block into a byte sequence. |
| 28 | pub inline fn toBytes(block: Block) [16]u8 { | |
| 28 | pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { | |
| 29 | 29 | return mem.toBytes(block.repr); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /// XOR the block with a byte sequence. |
| 33 | pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { | |
| 33 | pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { | |
| 34 | 34 | const x = block.repr ^ fromBytes(bytes).repr; |
| 35 | 35 | return mem.toBytes(x); |
| 36 | 36 | } |
| ... | ... | @@ -38,7 +38,7 @@ pub const Block = struct { |
| 38 | 38 | const zero = Vector(2, u64){ 0, 0 }; |
| 39 | 39 | |
| 40 | 40 | /// Encrypt a block with a round key. |
| 41 | pub inline fn encrypt(block: Block, round_key: Block) Block { | |
| 41 | pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { | |
| 42 | 42 | return Block{ |
| 43 | 43 | .repr = asm ( |
| 44 | 44 | \\ mov %[out].16b, %[in].16b |
| ... | ... | @@ -54,7 +54,7 @@ pub const Block = struct { |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /// Encrypt a block with the last round key. |
| 57 | pub inline fn encryptLast(block: Block, round_key: Block) Block { | |
| 57 | pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { | |
| 58 | 58 | return Block{ |
| 59 | 59 | .repr = asm ( |
| 60 | 60 | \\ mov %[out].16b, %[in].16b |
| ... | ... | @@ -69,7 +69,7 @@ pub const Block = struct { |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /// Decrypt a block with a round key. |
| 72 | pub inline fn decrypt(block: Block, inv_round_key: Block) Block { | |
| 72 | pub fn decrypt(block: Block, inv_round_key: Block) callconv(.Inline) Block { | |
| 73 | 73 | return Block{ |
| 74 | 74 | .repr = asm ( |
| 75 | 75 | \\ mov %[out].16b, %[in].16b |
| ... | ... | @@ -85,7 +85,7 @@ pub const Block = struct { |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /// Decrypt a block with the last round key. |
| 88 | pub inline fn decryptLast(block: Block, inv_round_key: Block) Block { | |
| 88 | pub fn decryptLast(block: Block, inv_round_key: Block) callconv(.Inline) Block { | |
| 89 | 89 | return Block{ |
| 90 | 90 | .repr = asm ( |
| 91 | 91 | \\ mov %[out].16b, %[in].16b |
| ... | ... | @@ -100,17 +100,17 @@ pub const Block = struct { |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /// Apply the bitwise XOR operation to the content of two blocks. |
| 103 | pub inline fn xorBlocks(block1: Block, block2: Block) Block { | |
| 103 | pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 104 | 104 | return Block{ .repr = block1.repr ^ block2.repr }; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /// Apply the bitwise AND operation to the content of two blocks. |
| 108 | pub inline fn andBlocks(block1: Block, block2: Block) Block { | |
| 108 | pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 109 | 109 | return Block{ .repr = block1.repr & block2.repr }; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /// Apply the bitwise OR operation to the content of two blocks. |
| 113 | pub inline fn orBlocks(block1: Block, block2: Block) Block { | |
| 113 | pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 114 | 114 | return Block{ .repr = block1.repr | block2.repr }; |
| 115 | 115 | } |
| 116 | 116 | |
| ... | ... | @@ -120,7 +120,7 @@ pub const Block = struct { |
| 120 | 120 | pub const optimal_parallel_blocks = 8; |
| 121 | 121 | |
| 122 | 122 | /// Encrypt multiple blocks in parallel, each their own round key. |
| 123 | pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { | |
| 123 | pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { | |
| 124 | 124 | comptime var i = 0; |
| 125 | 125 | var out: [count]Block = undefined; |
| 126 | 126 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -130,7 +130,7 @@ pub const Block = struct { |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /// Decrypt multiple blocks in parallel, each their own round key. |
| 133 | pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { | |
| 133 | pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { | |
| 134 | 134 | comptime var i = 0; |
| 135 | 135 | var out: [count]Block = undefined; |
| 136 | 136 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -140,7 +140,7 @@ pub const Block = struct { |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /// Encrypt multiple blocks in parallel with the same round key. |
| 143 | pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { | |
| 143 | pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | |
| 144 | 144 | comptime var i = 0; |
| 145 | 145 | var out: [count]Block = undefined; |
| 146 | 146 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -150,7 +150,7 @@ pub const Block = struct { |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /// Decrypt multiple blocks in parallel with the same round key. |
| 153 | pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { | |
| 153 | pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | |
| 154 | 154 | comptime var i = 0; |
| 155 | 155 | var out: [count]Block = undefined; |
| 156 | 156 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -160,7 +160,7 @@ pub const Block = struct { |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /// Encrypt multiple blocks in parallel with the same last round key. |
| 163 | pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { | |
| 163 | pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | |
| 164 | 164 | comptime var i = 0; |
| 165 | 165 | var out: [count]Block = undefined; |
| 166 | 166 | inline while (i < count) : (i += 1) { |
| ... | ... | @@ -170,7 +170,7 @@ pub const Block = struct { |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /// Decrypt multiple blocks in parallel with the same last round key. |
| 173 | pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { | |
| 173 | pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { | |
| 174 | 174 | comptime var i = 0; |
| 175 | 175 | var out: [count]Block = undefined; |
| 176 | 176 | inline while (i < count) : (i += 1) { |
lib/std/crypto/aes/soft.zig+10-10| ... | ... | @@ -18,7 +18,7 @@ pub const Block = struct { |
| 18 | 18 | repr: BlockVec align(16), |
| 19 | 19 | |
| 20 | 20 | /// Convert a byte sequence into an internal representation. |
| 21 | pub inline fn fromBytes(bytes: *const [16]u8) Block { | |
| 21 | pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { | |
| 22 | 22 | const s0 = mem.readIntBig(u32, bytes[0..4]); |
| 23 | 23 | const s1 = mem.readIntBig(u32, bytes[4..8]); |
| 24 | 24 | const s2 = mem.readIntBig(u32, bytes[8..12]); |
| ... | ... | @@ -27,7 +27,7 @@ pub const Block = struct { |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /// Convert the internal representation of a block into a byte sequence. |
| 30 | pub inline fn toBytes(block: Block) [16]u8 { | |
| 30 | pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { | |
| 31 | 31 | var bytes: [16]u8 = undefined; |
| 32 | 32 | mem.writeIntBig(u32, bytes[0..4], block.repr[0]); |
| 33 | 33 | mem.writeIntBig(u32, bytes[4..8], block.repr[1]); |
| ... | ... | @@ -37,7 +37,7 @@ pub const Block = struct { |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /// XOR the block with a byte sequence. |
| 40 | pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { | |
| 40 | pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { | |
| 41 | 41 | const block_bytes = block.toBytes(); |
| 42 | 42 | var x: [16]u8 = undefined; |
| 43 | 43 | comptime var i: usize = 0; |
| ... | ... | @@ -48,7 +48,7 @@ pub const Block = struct { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /// Encrypt a block with a round key. |
| 51 | pub inline fn encrypt(block: Block, round_key: Block) Block { | |
| 51 | pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { | |
| 52 | 52 | const src = &block.repr; |
| 53 | 53 | |
| 54 | 54 | const s0 = block.repr[0]; |
| ... | ... | @@ -65,7 +65,7 @@ pub const Block = struct { |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /// Encrypt a block with the last round key. |
| 68 | pub inline fn encryptLast(block: Block, round_key: Block) Block { | |
| 68 | pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { | |
| 69 | 69 | const src = &block.repr; |
| 70 | 70 | |
| 71 | 71 | const t0 = block.repr[0]; |
| ... | ... | @@ -87,7 +87,7 @@ pub const Block = struct { |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /// Decrypt a block with a round key. |
| 90 | pub inline fn decrypt(block: Block, round_key: Block) Block { | |
| 90 | pub fn decrypt(block: Block, round_key: Block) callconv(.Inline) Block { | |
| 91 | 91 | const src = &block.repr; |
| 92 | 92 | |
| 93 | 93 | const s0 = block.repr[0]; |
| ... | ... | @@ -104,7 +104,7 @@ pub const Block = struct { |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /// Decrypt a block with the last round key. |
| 107 | pub inline fn decryptLast(block: Block, round_key: Block) Block { | |
| 107 | pub fn decryptLast(block: Block, round_key: Block) callconv(.Inline) Block { | |
| 108 | 108 | const src = &block.repr; |
| 109 | 109 | |
| 110 | 110 | const t0 = block.repr[0]; |
| ... | ... | @@ -126,7 +126,7 @@ pub const Block = struct { |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /// Apply the bitwise XOR operation to the content of two blocks. |
| 129 | pub inline fn xorBlocks(block1: Block, block2: Block) Block { | |
| 129 | pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 130 | 130 | var x: BlockVec = undefined; |
| 131 | 131 | comptime var i = 0; |
| 132 | 132 | inline while (i < 4) : (i += 1) { |
| ... | ... | @@ -136,7 +136,7 @@ pub const Block = struct { |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /// Apply the bitwise AND operation to the content of two blocks. |
| 139 | pub inline fn andBlocks(block1: Block, block2: Block) Block { | |
| 139 | pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 140 | 140 | var x: BlockVec = undefined; |
| 141 | 141 | comptime var i = 0; |
| 142 | 142 | inline while (i < 4) : (i += 1) { |
| ... | ... | @@ -146,7 +146,7 @@ pub const Block = struct { |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /// Apply the bitwise OR operation to the content of two blocks. |
| 149 | pub inline fn orBlocks(block1: Block, block2: Block) Block { | |
| 149 | pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { | |
| 150 | 150 | var x: BlockVec = undefined; |
| 151 | 151 | comptime var i = 0; |
| 152 | 152 | inline while (i < 4) : (i += 1) { |
lib/std/crypto/blake3.zig+3-3| ... | ... | @@ -66,7 +66,7 @@ const CompressVectorized = struct { |
| 66 | 66 | const Lane = Vector(4, u32); |
| 67 | 67 | const Rows = [4]Lane; |
| 68 | 68 | |
| 69 | inline fn g(comptime even: bool, rows: *Rows, m: Lane) void { | |
| 69 | fn g(comptime even: bool, rows: *Rows, m: Lane) callconv(.Inline) void { | |
| 70 | 70 | rows[0] +%= rows[1] +% m; |
| 71 | 71 | rows[3] ^= rows[0]; |
| 72 | 72 | rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16); |
| ... | ... | @@ -75,13 +75,13 @@ const CompressVectorized = struct { |
| 75 | 75 | rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | inline fn diagonalize(rows: *Rows) void { | |
| 78 | fn diagonalize(rows: *Rows) callconv(.Inline) void { | |
| 79 | 79 | rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 }); |
| 80 | 80 | rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 }); |
| 81 | 81 | rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 }); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | inline fn undiagonalize(rows: *Rows) void { | |
| 84 | fn undiagonalize(rows: *Rows) callconv(.Inline) void { | |
| 85 | 85 | rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 }); |
| 86 | 86 | rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 }); |
| 87 | 87 | rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 3, 0, 1, 2 }); |
lib/std/crypto/chacha20.zig+6-6| ... | ... | @@ -35,7 +35,7 @@ const ChaCha20VecImpl = struct { |
| 35 | 35 | }; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | inline fn chacha20Core(x: *BlockVec, input: BlockVec) void { | |
| 38 | fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void { | |
| 39 | 39 | x.* = input; |
| 40 | 40 | |
| 41 | 41 | var r: usize = 0; |
| ... | ... | @@ -80,7 +80,7 @@ const ChaCha20VecImpl = struct { |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | inline fn hashToBytes(out: *[64]u8, x: BlockVec) void { | |
| 83 | fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void { | |
| 84 | 84 | var i: usize = 0; |
| 85 | 85 | while (i < 4) : (i += 1) { |
| 86 | 86 | mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]); |
| ... | ... | @@ -90,7 +90,7 @@ const ChaCha20VecImpl = struct { |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void { | |
| 93 | fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void { | |
| 94 | 94 | x[0] +%= ctx[0]; |
| 95 | 95 | x[1] +%= ctx[1]; |
| 96 | 96 | x[2] +%= ctx[2]; |
| ... | ... | @@ -190,7 +190,7 @@ const ChaCha20NonVecImpl = struct { |
| 190 | 190 | }; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | inline fn chacha20Core(x: *BlockVec, input: BlockVec) void { | |
| 193 | fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void { | |
| 194 | 194 | x.* = input; |
| 195 | 195 | |
| 196 | 196 | const rounds = comptime [_]QuarterRound{ |
| ... | ... | @@ -219,7 +219,7 @@ const ChaCha20NonVecImpl = struct { |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | inline fn hashToBytes(out: *[64]u8, x: BlockVec) void { | |
| 222 | fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void { | |
| 223 | 223 | var i: usize = 0; |
| 224 | 224 | while (i < 4) : (i += 1) { |
| 225 | 225 | mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0]); |
| ... | ... | @@ -229,7 +229,7 @@ const ChaCha20NonVecImpl = struct { |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void { | |
| 232 | fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void { | |
| 233 | 233 | var i: usize = 0; |
| 234 | 234 | while (i < 16) : (i += 1) { |
| 235 | 235 | x[i] +%= ctx[i]; |
lib/std/crypto/ghash.zig+2-2| ... | ... | @@ -95,7 +95,7 @@ pub const Ghash = struct { |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | inline fn clmul_pclmul(x: u64, y: u64) u64 { | |
| 98 | fn clmul_pclmul(x: u64, y: u64) callconv(.Inline) u64 { | |
| 99 | 99 | const Vector = std.meta.Vector; |
| 100 | 100 | const product = asm ( |
| 101 | 101 | \\ vpclmulqdq $0x00, %[x], %[y], %[out] |
| ... | ... | @@ -106,7 +106,7 @@ pub const Ghash = struct { |
| 106 | 106 | return product[0]; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | inline fn clmul_pmull(x: u64, y: u64) u64 { | |
| 109 | fn clmul_pmull(x: u64, y: u64) callconv(.Inline) u64 { | |
| 110 | 110 | const Vector = std.meta.Vector; |
| 111 | 111 | const product = asm ( |
| 112 | 112 | \\ pmull %[out].1q, %[x].1d, %[y].1d |
lib/std/crypto/gimli.zig+2-2| ... | ... | @@ -48,7 +48,7 @@ pub const State = struct { |
| 48 | 48 | return mem.asBytes(&self.data); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | inline fn endianSwap(self: *Self) void { | |
| 51 | fn endianSwap(self: *Self) callconv(.Inline) void { | |
| 52 | 52 | for (self.data) |*w| { |
| 53 | 53 | w.* = mem.littleToNative(u32, w.*); |
| 54 | 54 | } |
| ... | ... | @@ -116,7 +116,7 @@ pub const State = struct { |
| 116 | 116 | |
| 117 | 117 | const Lane = Vector(4, u32); |
| 118 | 118 | |
| 119 | inline fn shift(x: Lane, comptime n: comptime_int) Lane { | |
| 119 | fn shift(x: Lane, comptime n: comptime_int) callconv(.Inline) Lane { | |
| 120 | 120 | return x << @splat(4, @as(u5, n)); |
| 121 | 121 | } |
| 122 | 122 |
lib/std/crypto/salsa20.zig+3-3| ... | ... | @@ -37,7 +37,7 @@ const Salsa20VecImpl = struct { |
| 37 | 37 | }; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) void { | |
| 40 | fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) callconv(.Inline) void { | |
| 41 | 41 | const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] }; |
| 42 | 42 | const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] }; |
| 43 | 43 | const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] }; |
| ... | ... | @@ -211,7 +211,7 @@ const Salsa20NonVecImpl = struct { |
| 211 | 211 | d: u6, |
| 212 | 212 | }; |
| 213 | 213 | |
| 214 | inline fn Rp(a: usize, b: usize, c: usize, d: u6) QuarterRound { | |
| 214 | fn Rp(a: usize, b: usize, c: usize, d: u6) callconv(.Inline) QuarterRound { | |
| 215 | 215 | return QuarterRound{ |
| 216 | 216 | .a = a, |
| 217 | 217 | .b = b, |
| ... | ... | @@ -220,7 +220,7 @@ const Salsa20NonVecImpl = struct { |
| 220 | 220 | }; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) void { | |
| 223 | fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) callconv(.Inline) void { | |
| 224 | 224 | const arx_steps = comptime [_]QuarterRound{ |
| 225 | 225 | Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18), |
| 226 | 226 | 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| ... | ... | @@ -720,10 +720,10 @@ pub const Elf32_Rel = extern struct { |
| 720 | 720 | r_offset: Elf32_Addr, |
| 721 | 721 | r_info: Elf32_Word, |
| 722 | 722 | |
| 723 | pub inline fn r_sym(self: @This()) u24 { | |
| 723 | pub fn r_sym(self: @This()) callconv(.Inline) u24 { | |
| 724 | 724 | return @truncate(u24, self.r_info >> 8); |
| 725 | 725 | } |
| 726 | pub inline fn r_type(self: @This()) u8 { | |
| 726 | pub fn r_type(self: @This()) callconv(.Inline) u8 { | |
| 727 | 727 | return @truncate(u8, self.r_info & 0xff); |
| 728 | 728 | } |
| 729 | 729 | }; |
| ... | ... | @@ -731,10 +731,10 @@ pub const Elf64_Rel = extern struct { |
| 731 | 731 | r_offset: Elf64_Addr, |
| 732 | 732 | r_info: Elf64_Xword, |
| 733 | 733 | |
| 734 | pub inline fn r_sym(self: @This()) u32 { | |
| 734 | pub fn r_sym(self: @This()) callconv(.Inline) u32 { | |
| 735 | 735 | return @truncate(u32, self.r_info >> 32); |
| 736 | 736 | } |
| 737 | pub inline fn r_type(self: @This()) u32 { | |
| 737 | pub fn r_type(self: @This()) callconv(.Inline) u32 { | |
| 738 | 738 | return @truncate(u32, self.r_info & 0xffffffff); |
| 739 | 739 | } |
| 740 | 740 | }; |
| ... | ... | @@ -743,10 +743,10 @@ pub const Elf32_Rela = extern struct { |
| 743 | 743 | r_info: Elf32_Word, |
| 744 | 744 | r_addend: Elf32_Sword, |
| 745 | 745 | |
| 746 | pub inline fn r_sym(self: @This()) u24 { | |
| 746 | pub fn r_sym(self: @This()) callconv(.Inline) u24 { | |
| 747 | 747 | return @truncate(u24, self.r_info >> 8); |
| 748 | 748 | } |
| 749 | pub inline fn r_type(self: @This()) u8 { | |
| 749 | pub fn r_type(self: @This()) callconv(.Inline) u8 { | |
| 750 | 750 | return @truncate(u8, self.r_info & 0xff); |
| 751 | 751 | } |
| 752 | 752 | }; |
| ... | ... | @@ -755,10 +755,10 @@ pub const Elf64_Rela = extern struct { |
| 755 | 755 | r_info: Elf64_Xword, |
| 756 | 756 | r_addend: Elf64_Sxword, |
| 757 | 757 | |
| 758 | pub inline fn r_sym(self: @This()) u32 { | |
| 758 | pub fn r_sym(self: @This()) callconv(.Inline) u32 { | |
| 759 | 759 | return @truncate(u32, self.r_info >> 32); |
| 760 | 760 | } |
| 761 | pub inline fn r_type(self: @This()) u32 { | |
| 761 | pub fn r_type(self: @This()) callconv(.Inline) u32 { | |
| 762 | 762 | return @truncate(u32, self.r_info & 0xffffffff); |
| 763 | 763 | } |
| 764 | 764 | }; |
lib/std/fmt/parse_float.zig+4-4| ... | ... | @@ -52,21 +52,21 @@ const Z96 = struct { |
| 52 | 52 | d2: u32, |
| 53 | 53 | |
| 54 | 54 | // d = s >> 1 |
| 55 | inline fn shiftRight1(d: *Z96, s: Z96) void { | |
| 55 | fn shiftRight1(d: *Z96, s: Z96) callconv(.Inline) void { | |
| 56 | 56 | d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31); |
| 57 | 57 | d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31); |
| 58 | 58 | d.d2 = s.d2 >> 1; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // d = s << 1 |
| 62 | inline fn shiftLeft1(d: *Z96, s: Z96) void { | |
| 62 | fn shiftLeft1(d: *Z96, s: Z96) callconv(.Inline) void { | |
| 63 | 63 | d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31); |
| 64 | 64 | d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31); |
| 65 | 65 | d.d0 = s.d0 << 1; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // d += s |
| 69 | inline fn add(d: *Z96, s: Z96) void { | |
| 69 | fn add(d: *Z96, s: Z96) callconv(.Inline) void { | |
| 70 | 70 | var w = @as(u64, d.d0) + @as(u64, s.d0); |
| 71 | 71 | d.d0 = @truncate(u32, w); |
| 72 | 72 | |
| ... | ... | @@ -80,7 +80,7 @@ const Z96 = struct { |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // d -= s |
| 83 | inline fn sub(d: *Z96, s: Z96) void { | |
| 83 | fn sub(d: *Z96, s: Z96) callconv(.Inline) void { | |
| 84 | 84 | var w = @as(u64, d.d0) -% @as(u64, s.d0); |
| 85 | 85 | d.d0 = @truncate(u32, w); |
| 86 | 86 |
lib/std/hash/cityhash.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | const std = @import("std"); |
| 7 | 7 | const builtin = @import("builtin"); |
| 8 | 8 | |
| 9 | inline fn offsetPtr(ptr: [*]const u8, offset: usize) [*]const u8 { | |
| 9 | fn offsetPtr(ptr: [*]const u8, offset: usize) callconv(.Inline) [*]const u8 { | |
| 10 | 10 | // ptr + offset doesn't work at comptime so we need this instead. |
| 11 | 11 | return @ptrCast([*]const u8, &ptr[offset]); |
| 12 | 12 | } |
lib/std/os/bits/freebsd.zig+4-4| ... | ... | @@ -815,16 +815,16 @@ pub const sigval = extern union { |
| 815 | 815 | pub const _SIG_WORDS = 4; |
| 816 | 816 | pub const _SIG_MAXSIG = 128; |
| 817 | 817 | |
| 818 | pub inline fn _SIG_IDX(sig: usize) usize { | |
| 818 | pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize { | |
| 819 | 819 | return sig - 1; |
| 820 | 820 | } |
| 821 | pub inline fn _SIG_WORD(sig: usize) usize { | |
| 821 | pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize { | |
| 822 | 822 | return_SIG_IDX(sig) >> 5; |
| 823 | 823 | } |
| 824 | pub inline fn _SIG_BIT(sig: usize) usize { | |
| 824 | pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize { | |
| 825 | 825 | return 1 << (_SIG_IDX(sig) & 31); |
| 826 | 826 | } |
| 827 | pub inline fn _SIG_VALID(sig: usize) usize { | |
| 827 | pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize { | |
| 828 | 828 | return sig <= _SIG_MAXSIG and sig > 0; |
| 829 | 829 | } |
| 830 | 830 |
lib/std/os/bits/netbsd.zig+4-4| ... | ... | @@ -796,16 +796,16 @@ pub const _ksiginfo = extern struct { |
| 796 | 796 | pub const _SIG_WORDS = 4; |
| 797 | 797 | pub const _SIG_MAXSIG = 128; |
| 798 | 798 | |
| 799 | pub inline fn _SIG_IDX(sig: usize) usize { | |
| 799 | pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize { | |
| 800 | 800 | return sig - 1; |
| 801 | 801 | } |
| 802 | pub inline fn _SIG_WORD(sig: usize) usize { | |
| 802 | pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize { | |
| 803 | 803 | return_SIG_IDX(sig) >> 5; |
| 804 | 804 | } |
| 805 | pub inline fn _SIG_BIT(sig: usize) usize { | |
| 805 | pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize { | |
| 806 | 806 | return 1 << (_SIG_IDX(sig) & 31); |
| 807 | 807 | } |
| 808 | pub inline fn _SIG_VALID(sig: usize) usize { | |
| 808 | pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize { | |
| 809 | 809 | return sig <= _SIG_MAXSIG and sig > 0; |
| 810 | 810 | } |
| 811 | 811 |
lib/std/os/linux.zig+1-1| ... | ... | @@ -126,7 +126,7 @@ pub fn fork() usize { |
| 126 | 126 | /// It is advised to avoid this function and use clone instead, because |
| 127 | 127 | /// the compiler is not aware of how vfork affects control flow and you may |
| 128 | 128 | /// see different results in optimized builds. |
| 129 | pub inline fn vfork() usize { | |
| 129 | pub fn vfork() callconv(.Inline) usize { | |
| 130 | 130 | return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork}); |
| 131 | 131 | } |
| 132 | 132 |
lib/std/os/linux/tls.zig+1-1| ... | ... | @@ -300,7 +300,7 @@ fn initTLS() void { |
| 300 | 300 | }; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | inline fn alignPtrCast(comptime T: type, ptr: [*]u8) *T { | |
| 303 | fn alignPtrCast(comptime T: type, ptr: [*]u8) callconv(.Inline) *T { | |
| 304 | 304 | return @ptrCast(*T, @alignCast(@alignOf(*T), ptr)); |
| 305 | 305 | } |
| 306 | 306 |
lib/std/os/windows.zig+1-1| ... | ... | @@ -1669,7 +1669,7 @@ pub fn wToPrefixedFileW(s: []const u16) !PathSpace { |
| 1669 | 1669 | return path_space; |
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | inline fn MAKELANGID(p: c_ushort, s: c_ushort) LANGID { | |
| 1672 | fn MAKELANGID(p: c_ushort, s: c_ushort) callconv(.Inline) LANGID { | |
| 1673 | 1673 | return (s << 10) | p; |
| 1674 | 1674 | } |
| 1675 | 1675 |
lib/std/start.zig+2-2| ... | ... | @@ -262,7 +262,7 @@ const bad_main_ret = "expected return type of main to be 'void', '!void', 'noret |
| 262 | 262 | |
| 263 | 263 | // This is marked inline because for some reason LLVM in release mode fails to inline it, |
| 264 | 264 | // and we want fewer call frames in stack traces. |
| 265 | inline fn initEventLoopAndCallMain() u8 { | |
| 265 | fn initEventLoopAndCallMain() callconv(.Inline) u8 { | |
| 266 | 266 | if (std.event.Loop.instance) |loop| { |
| 267 | 267 | if (!@hasDecl(root, "event_loop")) { |
| 268 | 268 | loop.init() catch |err| { |
| ... | ... | @@ -291,7 +291,7 @@ inline fn initEventLoopAndCallMain() u8 { |
| 291 | 291 | // and we want fewer call frames in stack traces. |
| 292 | 292 | // TODO This function is duplicated from initEventLoopAndCallMain instead of using generics |
| 293 | 293 | // because it is working around stage1 compiler bugs. |
| 294 | inline fn initEventLoopAndCallWinMain() std.os.windows.INT { | |
| 294 | fn initEventLoopAndCallWinMain() callconv(.Inline) std.os.windows.INT { | |
| 295 | 295 | if (std.event.Loop.instance) |loop| { |
| 296 | 296 | if (!@hasDecl(root, "event_loop")) { |
| 297 | 297 | loop.init() catch |err| { |
lib/std/zig/ast.zig+9| ... | ... | @@ -1357,6 +1357,7 @@ pub const Node = struct { |
| 1357 | 1357 | extern_export_inline_token: TokenIndex, |
| 1358 | 1358 | is_extern_prototype: void, // TODO: Remove once extern fn rewriting is |
| 1359 | 1359 | is_async: void, // TODO: remove once async fn rewriting is |
| 1360 | is_inline: void, // TODO: remove once inline fn rewriting is | |
| 1360 | 1361 | }); |
| 1361 | 1362 | |
| 1362 | 1363 | pub const RequiredFields = struct { |
| ... | ... | @@ -1523,6 +1524,14 @@ pub const Node = struct { |
| 1523 | 1524 | self.setTrailer(.is_async, value); |
| 1524 | 1525 | } |
| 1525 | 1526 | |
| 1527 | pub fn getIsInline(self: *const FnProto) ?void { | |
| 1528 | return self.getTrailer(.is_inline); | |
| 1529 | } | |
| 1530 | ||
| 1531 | pub fn setIsInline(self: *FnProto, value: void) void { | |
| 1532 | self.setTrailer(.is_inline, value); | |
| 1533 | } | |
| 1534 | ||
| 1526 | 1535 | fn getTrailer(self: *const FnProto, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) { |
| 1527 | 1536 | const trailers_start = @alignCast( |
| 1528 | 1537 | @alignOf(ParamDecl), |
lib/std/zig/parse.zig+9-2| ... | ... | @@ -493,9 +493,15 @@ const Parser = struct { |
| 493 | 493 | extern_export_inline_token: ?TokenIndex = null, |
| 494 | 494 | lib_name: ?*Node = null, |
| 495 | 495 | }) !?*Node { |
| 496 | // TODO: Remove once extern/async fn rewriting is | |
| 497 | var is_async: ?void = null; | |
| 496 | // TODO: Remove once extern/async/inline fn rewriting is | |
| 498 | 497 | var is_extern_prototype: ?void = null; |
| 498 | var is_async: ?void = null; | |
| 499 | var is_inline: ?void = null; | |
| 500 | if (fields.extern_export_inline_token != null and | |
| 501 | p.token_ids[fields.extern_export_inline_token.?] == .Keyword_inline) | |
| 502 | { | |
| 503 | is_inline = {}; | |
| 504 | } | |
| 499 | 505 | const cc_token: ?TokenIndex = blk: { |
| 500 | 506 | if (p.eatToken(.Keyword_extern)) |token| { |
| 501 | 507 | is_extern_prototype = {}; |
| ... | ... | @@ -573,6 +579,7 @@ const Parser = struct { |
| 573 | 579 | .callconv_expr = callconv_expr, |
| 574 | 580 | .is_extern_prototype = is_extern_prototype, |
| 575 | 581 | .is_async = is_async, |
| 582 | .is_inline = is_inline, | |
| 576 | 583 | }); |
| 577 | 584 | std.mem.copy(Node.FnProto.ParamDecl, fn_proto_node.params(), params); |
| 578 | 585 |
lib/std/zig/parser_test.zig+3-3| ... | ... | @@ -2355,17 +2355,17 @@ test "zig fmt: functions" { |
| 2355 | 2355 | \\extern fn puts(s: *const u8) c_int; |
| 2356 | 2356 | \\extern "c" fn puts(s: *const u8) c_int; |
| 2357 | 2357 | \\export fn puts(s: *const u8) c_int; |
| 2358 | \\inline fn puts(s: *const u8) c_int; | |
| 2358 | \\fn puts(s: *const u8) callconv(.Inline) c_int; | |
| 2359 | 2359 | \\noinline fn puts(s: *const u8) c_int; |
| 2360 | 2360 | \\pub extern fn puts(s: *const u8) c_int; |
| 2361 | 2361 | \\pub extern "c" fn puts(s: *const u8) c_int; |
| 2362 | 2362 | \\pub export fn puts(s: *const u8) c_int; |
| 2363 | \\pub inline fn puts(s: *const u8) c_int; | |
| 2363 | \\pub fn puts(s: *const u8) callconv(.Inline) c_int; | |
| 2364 | 2364 | \\pub noinline fn puts(s: *const u8) c_int; |
| 2365 | 2365 | \\pub extern fn puts(s: *const u8) align(2 + 2) c_int; |
| 2366 | 2366 | \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int; |
| 2367 | 2367 | \\pub export fn puts(s: *const u8) align(2 + 2) c_int; |
| 2368 | \\pub inline fn puts(s: *const u8) align(2 + 2) c_int; | |
| 2368 | \\pub fn puts(s: *const u8) align(2 + 2) callconv(.Inline) c_int; | |
| 2369 | 2369 | \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int; |
| 2370 | 2370 | \\ |
| 2371 | 2371 | ); |
lib/std/zig/render.zig+3-1| ... | ... | @@ -1558,7 +1558,7 @@ fn renderExpression( |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | 1560 | if (fn_proto.getExternExportInlineToken()) |extern_export_inline_token| { |
| 1561 | if (fn_proto.getIsExternPrototype() == null) | |
| 1561 | if (fn_proto.getIsExternPrototype() == null and fn_proto.getIsInline() == null) | |
| 1562 | 1562 | try renderToken(tree, ais, extern_export_inline_token, Space.Space); // extern/export/inline |
| 1563 | 1563 | } |
| 1564 | 1564 | |
| ... | ... | @@ -1664,6 +1664,8 @@ fn renderExpression( |
| 1664 | 1664 | try ais.writer().writeAll("callconv(.C) "); |
| 1665 | 1665 | } else if (fn_proto.getIsAsync() != null) { |
| 1666 | 1666 | try ais.writer().writeAll("callconv(.Async) "); |
| 1667 | } else if (fn_proto.getIsInline() != null) { | |
| 1668 | try ais.writer().writeAll("callconv(.Inline) "); | |
| 1667 | 1669 | } |
| 1668 | 1670 | |
| 1669 | 1671 | switch (fn_proto.return_type) { |
lib/std/zig/system/x86.zig+2-2| ... | ... | @@ -19,11 +19,11 @@ fn setFeature(cpu: *Target.Cpu, feature: Target.x86.Feature, enabled: bool) void |
| 19 | 19 | if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | inline fn bit(input: u32, offset: u5) bool { | |
| 22 | fn bit(input: u32, offset: u5) callconv(.Inline) bool { | |
| 23 | 23 | return (input >> offset) & 1 != 0; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | inline fn hasMask(input: u32, mask: u32) bool { | |
| 26 | fn hasMask(input: u32, mask: u32) callconv(.Inline) bool { | |
| 27 | 27 | return (input & mask) == mask; |
| 28 | 28 | } |
| 29 | 29 |
src/Module.zig+19-16| ... | ... | @@ -1087,14 +1087,23 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool { |
| 1087 | 1087 | if (fn_proto.getSectionExpr()) |sect_expr| { |
| 1088 | 1088 | return self.failNode(&fn_type_scope.base, sect_expr, "TODO implement function section expression", .{}); |
| 1089 | 1089 | } |
| 1090 | if (fn_proto.getCallconvExpr()) |callconv_expr| { | |
| 1091 | return self.failNode( | |
| 1092 | &fn_type_scope.base, | |
| 1093 | callconv_expr, | |
| 1094 | "TODO implement function calling convention expression", | |
| 1095 | .{}, | |
| 1096 | ); | |
| 1097 | } | |
| 1090 | ||
| 1091 | const enum_literal_type = try astgen.addZIRInstConst(self, &fn_type_scope.base, fn_src, .{ | |
| 1092 | .ty = Type.initTag(.type), | |
| 1093 | .val = Value.initTag(.enum_literal_type), | |
| 1094 | }); | |
| 1095 | const enum_literal_type_rl: astgen.ResultLoc = .{ .ty = enum_literal_type }; | |
| 1096 | const cc = if (fn_proto.getCallconvExpr()) |callconv_expr| | |
| 1097 | try astgen.expr(self, &fn_type_scope.base, enum_literal_type_rl, callconv_expr) | |
| 1098 | else | |
| 1099 | try astgen.addZIRInstConst(self, &fn_type_scope.base, fn_src, .{ | |
| 1100 | .ty = Type.initTag(.enum_literal), | |
| 1101 | .val = try Value.Tag.enum_literal.create( | |
| 1102 | &fn_type_scope_arena.allocator, | |
| 1103 | try fn_type_scope_arena.allocator.dupe(u8, "Unspecified"), | |
| 1104 | ), | |
| 1105 | }); | |
| 1106 | ||
| 1098 | 1107 | const return_type_expr = switch (fn_proto.return_type) { |
| 1099 | 1108 | .Explicit => |node| node, |
| 1100 | 1109 | .InferErrorSet => |node| return self.failNode(&fn_type_scope.base, node, "TODO implement inferred error sets", .{}), |
| ... | ... | @@ -1105,6 +1114,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool { |
| 1105 | 1114 | const fn_type_inst = try astgen.addZIRInst(self, &fn_type_scope.base, fn_src, zir.Inst.FnType, .{ |
| 1106 | 1115 | .return_type = return_type_inst, |
| 1107 | 1116 | .param_types = param_types, |
| 1117 | .cc = cc, | |
| 1108 | 1118 | }, .{}); |
| 1109 | 1119 | |
| 1110 | 1120 | if (std.builtin.mode == .Debug and self.comp.verbose_ir) { |
| ... | ... | @@ -1230,14 +1240,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool { |
| 1230 | 1240 | }; |
| 1231 | 1241 | }; |
| 1232 | 1242 | |
| 1233 | const is_inline = blk: { | |
| 1234 | if (fn_proto.getExternExportInlineToken()) |maybe_inline_token| { | |
| 1235 | if (tree.token_ids[maybe_inline_token] == .Keyword_inline) { | |
| 1236 | break :blk true; | |
| 1237 | } | |
| 1238 | } | |
| 1239 | break :blk false; | |
| 1240 | }; | |
| 1243 | const is_inline = fn_type.fnCallingConvention() == .Inline; | |
| 1241 | 1244 | const anal_state = ([2]Fn.Analysis{ .queued, .inline_only })[@boolToInt(is_inline)]; |
| 1242 | 1245 | |
| 1243 | 1246 | new_func.* = .{ |
src/link/MachO.zig+1-1| ... | ... | @@ -2366,7 +2366,7 @@ fn allocatedSizeLinkedit(self: *MachO, start: u64) u64 { |
| 2366 | 2366 | return min_pos - start; |
| 2367 | 2367 | } |
| 2368 | 2368 | |
| 2369 | inline fn checkForCollision(start: u64, end: u64, off: u64, size: u64) ?u64 { | |
| 2369 | fn checkForCollision(start: u64, end: u64, off: u64, size: u64) callconv(.Inline) ?u64 { | |
| 2370 | 2370 | const increased_size = padToIdeal(size); |
| 2371 | 2371 | const test_end = off + increased_size; |
| 2372 | 2372 | if (end > off and start < test_end) { |
src/stage1/all_types.hpp+3-9| ... | ... | @@ -74,6 +74,7 @@ enum CallingConvention { |
| 74 | 74 | CallingConventionC, |
| 75 | 75 | CallingConventionNaked, |
| 76 | 76 | CallingConventionAsync, |
| 77 | CallingConventionInline, | |
| 77 | 78 | CallingConventionInterrupt, |
| 78 | 79 | CallingConventionSignal, |
| 79 | 80 | CallingConventionStdcall, |
| ... | ... | @@ -703,12 +704,6 @@ enum NodeType { |
| 703 | 704 | NodeTypeAnyTypeField, |
| 704 | 705 | }; |
| 705 | 706 | |
| 706 | enum FnInline { | |
| 707 | FnInlineAuto, | |
| 708 | FnInlineAlways, | |
| 709 | FnInlineNever, | |
| 710 | }; | |
| 711 | ||
| 712 | 707 | struct AstNodeFnProto { |
| 713 | 708 | Buf *name; |
| 714 | 709 | ZigList<AstNode *> params; |
| ... | ... | @@ -725,13 +720,12 @@ struct AstNodeFnProto { |
| 725 | 720 | AstNode *callconv_expr; |
| 726 | 721 | Buf doc_comments; |
| 727 | 722 | |
| 728 | FnInline fn_inline; | |
| 729 | ||
| 730 | 723 | VisibMod visib_mod; |
| 731 | 724 | bool auto_err_set; |
| 732 | 725 | bool is_var_args; |
| 733 | 726 | bool is_extern; |
| 734 | 727 | bool is_export; |
| 728 | bool is_noinline; | |
| 735 | 729 | }; |
| 736 | 730 | |
| 737 | 731 | struct AstNodeFnDef { |
| ... | ... | @@ -1719,7 +1713,6 @@ struct ZigFn { |
| 1719 | 1713 | |
| 1720 | 1714 | LLVMValueRef valgrind_client_request_array; |
| 1721 | 1715 | |
| 1722 | FnInline fn_inline; | |
| 1723 | 1716 | FnAnalState anal_state; |
| 1724 | 1717 | |
| 1725 | 1718 | uint32_t align_bytes; |
| ... | ... | @@ -1728,6 +1721,7 @@ struct ZigFn { |
| 1728 | 1721 | bool calls_or_awaits_errorable_fn; |
| 1729 | 1722 | bool is_cold; |
| 1730 | 1723 | bool is_test; |
| 1724 | bool is_noinline; | |
| 1731 | 1725 | }; |
| 1732 | 1726 | |
| 1733 | 1727 | uint32_t fn_table_entry_hash(ZigFn*); |
src/stage1/analyze.cpp+15-5| ... | ... | @@ -973,6 +973,7 @@ const char *calling_convention_name(CallingConvention cc) { |
| 973 | 973 | case CallingConventionAPCS: return "APCS"; |
| 974 | 974 | case CallingConventionAAPCS: return "AAPCS"; |
| 975 | 975 | case CallingConventionAAPCSVFP: return "AAPCSVFP"; |
| 976 | case CallingConventionInline: return "Inline"; | |
| 976 | 977 | } |
| 977 | 978 | zig_unreachable(); |
| 978 | 979 | } |
| ... | ... | @@ -981,6 +982,7 @@ bool calling_convention_allows_zig_types(CallingConvention cc) { |
| 981 | 982 | switch (cc) { |
| 982 | 983 | case CallingConventionUnspecified: |
| 983 | 984 | case CallingConventionAsync: |
| 985 | case CallingConventionInline: | |
| 984 | 986 | return true; |
| 985 | 987 | case CallingConventionC: |
| 986 | 988 | case CallingConventionNaked: |
| ... | ... | @@ -1007,7 +1009,8 @@ ZigType *get_stack_trace_type(CodeGen *g) { |
| 1007 | 1009 | } |
| 1008 | 1010 | |
| 1009 | 1011 | bool want_first_arg_sret(CodeGen *g, FnTypeId *fn_type_id) { |
| 1010 | if (fn_type_id->cc == CallingConventionUnspecified) { | |
| 1012 | if (fn_type_id->cc == CallingConventionUnspecified | |
| 1013 | || fn_type_id->cc == CallingConventionInline) { | |
| 1011 | 1014 | return handle_is_ptr(g, fn_type_id->return_type); |
| 1012 | 1015 | } |
| 1013 | 1016 | if (fn_type_id->cc != CallingConventionC) { |
| ... | ... | @@ -1888,6 +1891,7 @@ Error emit_error_unless_callconv_allowed_for_target(CodeGen *g, AstNode *source_ |
| 1888 | 1891 | case CallingConventionC: |
| 1889 | 1892 | case CallingConventionNaked: |
| 1890 | 1893 | case CallingConventionAsync: |
| 1894 | case CallingConventionInline: | |
| 1891 | 1895 | break; |
| 1892 | 1896 | case CallingConventionInterrupt: |
| 1893 | 1897 | if (g->zig_target->arch != ZigLLVM_x86 |
| ... | ... | @@ -3587,7 +3591,7 @@ static void get_fully_qualified_decl_name(CodeGen *g, Buf *buf, Tld *tld, bool i |
| 3587 | 3591 | } |
| 3588 | 3592 | } |
| 3589 | 3593 | |
| 3590 | static ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value) { | |
| 3594 | static ZigFn *create_fn_raw(CodeGen *g, bool is_noinline) { | |
| 3591 | 3595 | ZigFn *fn_entry = heap::c_allocator.create<ZigFn>(); |
| 3592 | 3596 | fn_entry->ir_executable = heap::c_allocator.create<IrExecutableSrc>(); |
| 3593 | 3597 | |
| ... | ... | @@ -3597,7 +3601,7 @@ static ZigFn *create_fn_raw(CodeGen *g, FnInline inline_value) { |
| 3597 | 3601 | fn_entry->analyzed_executable.backward_branch_quota = &fn_entry->prealloc_backward_branch_quota; |
| 3598 | 3602 | fn_entry->analyzed_executable.fn_entry = fn_entry; |
| 3599 | 3603 | fn_entry->ir_executable->fn_entry = fn_entry; |
| 3600 | fn_entry->fn_inline = inline_value; | |
| 3604 | fn_entry->is_noinline = is_noinline; | |
| 3601 | 3605 | |
| 3602 | 3606 | return fn_entry; |
| 3603 | 3607 | } |
| ... | ... | @@ -3606,7 +3610,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) { |
| 3606 | 3610 | assert(proto_node->type == NodeTypeFnProto); |
| 3607 | 3611 | AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; |
| 3608 | 3612 | |
| 3609 | ZigFn *fn_entry = create_fn_raw(g, fn_proto->fn_inline); | |
| 3613 | ZigFn *fn_entry = create_fn_raw(g, fn_proto->is_noinline); | |
| 3610 | 3614 | |
| 3611 | 3615 | fn_entry->proto_node = proto_node; |
| 3612 | 3616 | fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr : |
| ... | ... | @@ -3739,6 +3743,12 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3739 | 3743 | fn_table_entry->type_entry = g->builtin_types.entry_invalid; |
| 3740 | 3744 | tld_fn->base.resolution = TldResolutionInvalid; |
| 3741 | 3745 | return; |
| 3746 | case CallingConventionInline: | |
| 3747 | add_node_error(g, fn_def_node, | |
| 3748 | buf_sprintf("exported function cannot be inline")); | |
| 3749 | fn_table_entry->type_entry = g->builtin_types.entry_invalid; | |
| 3750 | tld_fn->base.resolution = TldResolutionInvalid; | |
| 3751 | return; | |
| 3742 | 3752 | case CallingConventionC: |
| 3743 | 3753 | case CallingConventionNaked: |
| 3744 | 3754 | case CallingConventionInterrupt: |
| ... | ... | @@ -3774,7 +3784,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { |
| 3774 | 3784 | fn_table_entry->inferred_async_node = fn_table_entry->proto_node; |
| 3775 | 3785 | } |
| 3776 | 3786 | } else if (source_node->type == NodeTypeTestDecl) { |
| 3777 | ZigFn *fn_table_entry = create_fn_raw(g, FnInlineAuto); | |
| 3787 | ZigFn *fn_table_entry = create_fn_raw(g, false); | |
| 3778 | 3788 | |
| 3779 | 3789 | get_fully_qualified_decl_name(g, &fn_table_entry->symbol_name, &tld_fn->base, true); |
| 3780 | 3790 |
src/stage1/ast_render.cpp+3-8| ... | ... | @@ -123,13 +123,8 @@ static const char *export_string(bool is_export) { |
| 123 | 123 | // zig_unreachable(); |
| 124 | 124 | //} |
| 125 | 125 | |
| 126 | static 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(); | |
| 126 | static const char *inline_string(bool is_inline) { | |
| 127 | return is_inline ? "inline" : ""; | |
| 133 | 128 | } |
| 134 | 129 | |
| 135 | 130 | static const char *const_or_var_string(bool is_const) { |
| ... | ... | @@ -446,7 +441,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 446 | 441 | const char *pub_str = visib_mod_string(node->data.fn_proto.visib_mod); |
| 447 | 442 | const char *extern_str = extern_string(node->data.fn_proto.is_extern); |
| 448 | 443 | const char *export_str = export_string(node->data.fn_proto.is_export); |
| 449 | const char *inline_str = inline_string(node->data.fn_proto.fn_inline); | |
| 444 | const char *inline_str = inline_string(node->data.fn_proto.is_noinline); | |
| 450 | 445 | fprintf(ar->f, "%s%s%s%sfn ", pub_str, inline_str, export_str, extern_str); |
| 451 | 446 | if (node->data.fn_proto.name != nullptr) { |
| 452 | 447 | print_symbol(ar, node->data.fn_proto.name); |
src/stage1/codegen.cpp+18-28| ... | ... | @@ -159,6 +159,7 @@ static const char *get_mangled_name(CodeGen *g, const char *original_name) { |
| 159 | 159 | static ZigLLVM_CallingConv get_llvm_cc(CodeGen *g, CallingConvention cc) { |
| 160 | 160 | switch (cc) { |
| 161 | 161 | case CallingConventionUnspecified: |
| 162 | case CallingConventionInline: | |
| 162 | 163 | return ZigLLVM_Fast; |
| 163 | 164 | case CallingConventionC: |
| 164 | 165 | return ZigLLVM_C; |
| ... | ... | @@ -350,6 +351,7 @@ static bool cc_want_sret_attr(CallingConvention cc) { |
| 350 | 351 | return true; |
| 351 | 352 | case CallingConventionAsync: |
| 352 | 353 | case CallingConventionUnspecified: |
| 354 | case CallingConventionInline: | |
| 353 | 355 | return false; |
| 354 | 356 | } |
| 355 | 357 | zig_unreachable(); |
| ... | ... | @@ -452,20 +454,11 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) { |
| 452 | 454 | } |
| 453 | 455 | } |
| 454 | 456 | |
| 455 | switch (fn->fn_inline) { | |
| 456 | case FnInlineAlways: | |
| 457 | addLLVMFnAttr(llvm_fn, "alwaysinline"); | |
| 458 | g->inline_fns.append(fn); | |
| 459 | break; | |
| 460 | case FnInlineNever: | |
| 461 | addLLVMFnAttr(llvm_fn, "noinline"); | |
| 462 | break; | |
| 463 | case FnInlineAuto: | |
| 464 | if (fn->alignstack_value != 0) { | |
| 465 | addLLVMFnAttr(llvm_fn, "noinline"); | |
| 466 | } | |
| 467 | break; | |
| 468 | } | |
| 457 | if (cc == CallingConventionInline) | |
| 458 | addLLVMFnAttr(llvm_fn, "alwaysinline"); | |
| 459 | ||
| 460 | if (fn->is_noinline || (cc != CallingConventionInline && fn->alignstack_value != 0)) | |
| 461 | addLLVMFnAttr(llvm_fn, "noinline"); | |
| 469 | 462 | |
| 470 | 463 | if (cc == CallingConventionNaked) { |
| 471 | 464 | addLLVMFnAttr(llvm_fn, "naked"); |
| ... | ... | @@ -532,7 +525,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) { |
| 532 | 525 | addLLVMFnAttr(llvm_fn, "nounwind"); |
| 533 | 526 | add_uwtable_attr(g, llvm_fn); |
| 534 | 527 | addLLVMFnAttr(llvm_fn, "nobuiltin"); |
| 535 | if (codegen_have_frame_pointer(g) && fn->fn_inline != FnInlineAlways) { | |
| 528 | if (codegen_have_frame_pointer(g) && cc != CallingConventionInline) { | |
| 536 | 529 | ZigLLVMAddFunctionAttr(llvm_fn, "frame-pointer", "all"); |
| 537 | 530 | } |
| 538 | 531 | if (fn->section_name) { |
| ... | ... | @@ -9043,19 +9036,16 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { |
| 9043 | 9036 | static_assert(CallingConventionC == 1, ""); |
| 9044 | 9037 | static_assert(CallingConventionNaked == 2, ""); |
| 9045 | 9038 | static_assert(CallingConventionAsync == 3, ""); |
| 9046 | static_assert(CallingConventionInterrupt == 4, ""); | |
| 9047 | static_assert(CallingConventionSignal == 5, ""); | |
| 9048 | static_assert(CallingConventionStdcall == 6, ""); | |
| 9049 | static_assert(CallingConventionFastcall == 7, ""); | |
| 9050 | static_assert(CallingConventionVectorcall == 8, ""); | |
| 9051 | static_assert(CallingConventionThiscall == 9, ""); | |
| 9052 | static_assert(CallingConventionAPCS == 10, ""); | |
| 9053 | static_assert(CallingConventionAAPCS == 11, ""); | |
| 9054 | static_assert(CallingConventionAAPCSVFP == 12, ""); | |
| 9055 | ||
| 9056 | static_assert(FnInlineAuto == 0, ""); | |
| 9057 | static_assert(FnInlineAlways == 1, ""); | |
| 9058 | static_assert(FnInlineNever == 2, ""); | |
| 9039 | static_assert(CallingConventionInline == 4, ""); | |
| 9040 | static_assert(CallingConventionInterrupt == 5, ""); | |
| 9041 | static_assert(CallingConventionSignal == 6, ""); | |
| 9042 | static_assert(CallingConventionStdcall == 7, ""); | |
| 9043 | static_assert(CallingConventionFastcall == 8, ""); | |
| 9044 | static_assert(CallingConventionVectorcall == 9, ""); | |
| 9045 | static_assert(CallingConventionThiscall == 10, ""); | |
| 9046 | static_assert(CallingConventionAPCS == 11, ""); | |
| 9047 | static_assert(CallingConventionAAPCS == 12, ""); | |
| 9048 | static_assert(CallingConventionAAPCSVFP == 13, ""); | |
| 9059 | 9049 | |
| 9060 | 9050 | static_assert(BuiltinPtrSizeOne == 0, ""); |
| 9061 | 9051 | static_assert(BuiltinPtrSizeMany == 1, ""); |
src/stage1/ir.cpp+12-11| ... | ... | @@ -19000,7 +19000,7 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV |
| 19000 | 19000 | } else if (init_val->type->id == ZigTypeIdFn && |
| 19001 | 19001 | init_val->special != ConstValSpecialUndef && |
| 19002 | 19002 | init_val->data.x_ptr.special == ConstPtrSpecialFunction && |
| 19003 | init_val->data.x_ptr.data.fn.fn_entry->fn_inline == FnInlineAlways) | |
| 19003 | init_val->data.x_ptr.data.fn.fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionInline) | |
| 19004 | 19004 | { |
| 19005 | 19005 | var_class_requires_const = true; |
| 19006 | 19006 | if (!var->src_is_const && !is_comptime_var) { |
| ... | ... | @@ -19182,6 +19182,11 @@ static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport |
| 19182 | 19182 | buf_sprintf("exported function cannot be async")); |
| 19183 | 19183 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); |
| 19184 | 19184 | } break; |
| 19185 | case CallingConventionInline: { | |
| 19186 | ErrorMsg *msg = ir_add_error(ira, &target->base, | |
| 19187 | buf_sprintf("exported function cannot be inline")); | |
| 19188 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); | |
| 19189 | } break; | |
| 19185 | 19190 | case CallingConventionC: |
| 19186 | 19191 | case CallingConventionNaked: |
| 19187 | 19192 | case CallingConventionInterrupt: |
| ... | ... | @@ -21120,7 +21125,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 21120 | 21125 | if (type_is_invalid(return_type)) |
| 21121 | 21126 | return ira->codegen->invalid_inst_gen; |
| 21122 | 21127 | |
| 21123 | if (fn_entry != nullptr && fn_entry->fn_inline == FnInlineAlways && modifier == CallModifierNeverInline) { | |
| 21128 | if (fn_entry != nullptr && fn_type_id->cc == CallingConventionInline && modifier == CallModifierNeverInline) { | |
| 21124 | 21129 | ir_add_error(ira, source_instr, |
| 21125 | 21130 | buf_sprintf("no-inline call of inline function")); |
| 21126 | 21131 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -25219,10 +25224,6 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 25219 | 25224 | if ((err = type_resolve(ira->codegen, type_info_fn_decl_type, ResolveStatusSizeKnown))) |
| 25220 | 25225 | return err; |
| 25221 | 25226 | |
| 25222 | ZigType *type_info_fn_decl_inline_type = ir_type_info_get_type(ira, "Inline", type_info_fn_decl_type); | |
| 25223 | if ((err = type_resolve(ira->codegen, type_info_fn_decl_inline_type, ResolveStatusSizeKnown))) | |
| 25224 | return err; | |
| 25225 | ||
| 25226 | 25227 | resolve_container_usingnamespace_decls(ira->codegen, decls_scope); |
| 25227 | 25228 | |
| 25228 | 25229 | // The unresolved declarations are collected in a separate queue to avoid |
| ... | ... | @@ -25365,11 +25366,11 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigVa |
| 25365 | 25366 | fn_decl_fields[0]->special = ConstValSpecialStatic; |
| 25366 | 25367 | fn_decl_fields[0]->type = ira->codegen->builtin_types.entry_type; |
| 25367 | 25368 | fn_decl_fields[0]->data.x_type = fn_entry->type_entry; |
| 25368 | // inline_type: Data.FnDecl.Inline | |
| 25369 | ensure_field_index(fn_decl_val->type, "inline_type", 1); | |
| 25369 | // is_noinline: bool | |
| 25370 | ensure_field_index(fn_decl_val->type, "is_noinline", 1); | |
| 25370 | 25371 | fn_decl_fields[1]->special = ConstValSpecialStatic; |
| 25371 | fn_decl_fields[1]->type = type_info_fn_decl_inline_type; | |
| 25372 | bigint_init_unsigned(&fn_decl_fields[1]->data.x_enum_tag, fn_entry->fn_inline); | |
| 25372 | fn_decl_fields[1]->type = ira->codegen->builtin_types.entry_bool; | |
| 25373 | fn_decl_fields[1]->data.x_bool = fn_entry->is_noinline; | |
| 25373 | 25374 | // is_var_args: bool |
| 25374 | 25375 | ensure_field_index(fn_decl_val->type, "is_var_args", 2); |
| 25375 | 25376 | bool is_varargs = fn_node->is_var_args; |
| ... | ... | @@ -30957,7 +30958,7 @@ static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstS |
| 30957 | 30958 | return ira->codegen->invalid_inst_gen; |
| 30958 | 30959 | } |
| 30959 | 30960 | |
| 30960 | if (fn_entry->fn_inline == FnInlineAlways) { | |
| 30961 | if (fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionInline) { | |
| 30961 | 30962 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack in inline function")); |
| 30962 | 30963 | return ira->codegen->invalid_inst_gen; |
| 30963 | 30964 | } |
src/stage1/parser.cpp+3-14| ... | ... | @@ -693,8 +693,6 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B |
| 693 | 693 | Token *first = eat_token_if(pc, TokenIdKeywordExport); |
| 694 | 694 | if (first == nullptr) |
| 695 | 695 | first = eat_token_if(pc, TokenIdKeywordExtern); |
| 696 | if (first == nullptr) | |
| 697 | first = eat_token_if(pc, TokenIdKeywordInline); | |
| 698 | 696 | if (first == nullptr) |
| 699 | 697 | first = eat_token_if(pc, TokenIdKeywordNoInline); |
| 700 | 698 | if (first != nullptr) { |
| ... | ... | @@ -702,7 +700,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B |
| 702 | 700 | if (first->id == TokenIdKeywordExtern) |
| 703 | 701 | lib_name = eat_token_if(pc, TokenIdStringLiteral); |
| 704 | 702 | |
| 705 | if (first->id != TokenIdKeywordInline && first->id != TokenIdKeywordNoInline) { | |
| 703 | if (first->id != TokenIdKeywordNoInline) { | |
| 706 | 704 | Token *thread_local_kw = eat_token_if(pc, TokenIdKeywordThreadLocal); |
| 707 | 705 | AstNode *var_decl = ast_parse_var_decl(pc); |
| 708 | 706 | if (var_decl != nullptr) { |
| ... | ... | @@ -739,17 +737,8 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B |
| 739 | 737 | if (!fn_proto->data.fn_proto.is_extern) |
| 740 | 738 | fn_proto->data.fn_proto.is_extern = first->id == TokenIdKeywordExtern; |
| 741 | 739 | fn_proto->data.fn_proto.is_export = first->id == TokenIdKeywordExport; |
| 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 | } | |
| 740 | if (first->id == TokenIdKeywordNoInline) | |
| 741 | fn_proto->data.fn_proto.is_noinline = true; | |
| 753 | 742 | fn_proto->data.fn_proto.lib_name = token_buf(lib_name); |
| 754 | 743 | |
| 755 | 744 | AstNode *res = fn_proto; |
src/tracy.zig+1-1| ... | ... | @@ -31,7 +31,7 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct { |
| 31 | 31 | pub fn end(self: Ctx) void {} |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx { | |
| 34 | pub fn trace(comptime src: std.builtin.SourceLocation) callconv(.Inline) Ctx { | |
| 35 | 35 | if (!enable) return .{}; |
| 36 | 36 | |
| 37 | 37 | const loc: ___tracy_source_location_data = .{ |
src/translate_c.zig+12-4| ... | ... | @@ -4716,7 +4716,6 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a |
| 4716 | 4716 | const scope = &c.global_scope.base; |
| 4717 | 4717 | |
| 4718 | 4718 | const pub_tok = try appendToken(c, .Keyword_pub, "pub"); |
| 4719 | const inline_tok = try appendToken(c, .Keyword_inline, "inline"); | |
| 4720 | 4719 | const fn_tok = try appendToken(c, .Keyword_fn, "fn"); |
| 4721 | 4720 | const name_tok = try appendIdentifier(c, name); |
| 4722 | 4721 | _ = try appendToken(c, .LParen, "("); |
| ... | ... | @@ -4744,6 +4743,11 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a |
| 4744 | 4743 | |
| 4745 | 4744 | _ = try appendToken(c, .RParen, ")"); |
| 4746 | 4745 | |
| 4746 | _ = try appendToken(c, .Keyword_callconv, "callconv"); | |
| 4747 | _ = try appendToken(c, .LParen, "("); | |
| 4748 | const callconv_expr = try transCreateNodeEnumLiteral(c, "Inline"); | |
| 4749 | _ = try appendToken(c, .RParen, ")"); | |
| 4750 | ||
| 4747 | 4751 | const block_lbrace = try appendToken(c, .LBrace, "{"); |
| 4748 | 4752 | |
| 4749 | 4753 | const return_kw = try appendToken(c, .Keyword_return, "return"); |
| ... | ... | @@ -4783,8 +4787,8 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a |
| 4783 | 4787 | }, .{ |
| 4784 | 4788 | .visib_token = pub_tok, |
| 4785 | 4789 | .name_token = name_tok, |
| 4786 | .extern_export_inline_token = inline_tok, | |
| 4787 | 4790 | .body_node = &block.base, |
| 4791 | .callconv_expr = callconv_expr, | |
| 4788 | 4792 | }); |
| 4789 | 4793 | mem.copy(ast.Node.FnProto.ParamDecl, fn_proto.params(), fn_params.items); |
| 4790 | 4794 | return &fn_proto.base; |
| ... | ... | @@ -5734,7 +5738,6 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void { |
| 5734 | 5738 | const scope = &block_scope.base; |
| 5735 | 5739 | |
| 5736 | 5740 | const pub_tok = try appendToken(c, .Keyword_pub, "pub"); |
| 5737 | const inline_tok = try appendToken(c, .Keyword_inline, "inline"); | |
| 5738 | 5741 | const fn_tok = try appendToken(c, .Keyword_fn, "fn"); |
| 5739 | 5742 | const name_tok = try appendIdentifier(c, m.name); |
| 5740 | 5743 | _ = try appendToken(c, .LParen, "("); |
| ... | ... | @@ -5779,6 +5782,11 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void { |
| 5779 | 5782 | |
| 5780 | 5783 | _ = try appendToken(c, .RParen, ")"); |
| 5781 | 5784 | |
| 5785 | _ = try appendToken(c, .Keyword_callconv, "callconv"); | |
| 5786 | _ = try appendToken(c, .LParen, "("); | |
| 5787 | const callconv_expr = try transCreateNodeEnumLiteral(c, "Inline"); | |
| 5788 | _ = try appendToken(c, .RParen, ")"); | |
| 5789 | ||
| 5782 | 5790 | const type_of = try c.createBuiltinCall("@TypeOf", 1); |
| 5783 | 5791 | |
| 5784 | 5792 | const return_kw = try appendToken(c, .Keyword_return, "return"); |
| ... | ... | @@ -5810,9 +5818,9 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void { |
| 5810 | 5818 | .return_type = .{ .Explicit = &type_of.base }, |
| 5811 | 5819 | }, .{ |
| 5812 | 5820 | .visib_token = pub_tok, |
| 5813 | .extern_export_inline_token = inline_tok, | |
| 5814 | 5821 | .name_token = name_tok, |
| 5815 | 5822 | .body_node = block_node, |
| 5823 | .callconv_expr = callconv_expr, | |
| 5816 | 5824 | }); |
| 5817 | 5825 | mem.copy(ast.Node.FnProto.ParamDecl, fn_proto.params(), fn_params.items); |
| 5818 | 5826 |
src/type.zig+3-1| ... | ... | @@ -552,7 +552,9 @@ pub const Type = extern union { |
| 552 | 552 | if (i != 0) try out_stream.writeAll(", "); |
| 553 | 553 | try param_type.format("", .{}, out_stream); |
| 554 | 554 | } |
| 555 | try out_stream.writeAll(") "); | |
| 555 | try out_stream.writeAll(") callconv(."); | |
| 556 | try out_stream.writeAll(@tagName(payload.cc)); | |
| 557 | try out_stream.writeAll(")"); | |
| 556 | 558 | ty = payload.return_type; |
| 557 | 559 | continue; |
| 558 | 560 | }, |
src/zir.zig+3-6| ... | ... | @@ -863,9 +863,7 @@ pub const Inst = struct { |
| 863 | 863 | fn_type: *Inst, |
| 864 | 864 | body: Body, |
| 865 | 865 | }, |
| 866 | kw_args: struct { | |
| 867 | is_inline: bool = false, | |
| 868 | }, | |
| 866 | kw_args: struct {}, | |
| 869 | 867 | }; |
| 870 | 868 | |
| 871 | 869 | pub const FnType = struct { |
| ... | ... | @@ -875,10 +873,9 @@ pub const Inst = struct { |
| 875 | 873 | positionals: struct { |
| 876 | 874 | param_types: []*Inst, |
| 877 | 875 | return_type: *Inst, |
| 876 | cc: *Inst, | |
| 878 | 877 | }, |
| 879 | kw_args: struct { | |
| 880 | cc: std.builtin.CallingConvention = .Unspecified, | |
| 881 | }, | |
| 878 | kw_args: struct {}, | |
| 882 | 879 | }; |
| 883 | 880 | |
| 884 | 881 | pub const IntType = struct { |
src/zir_sema.zig+13-19| ... | ... | @@ -980,18 +980,8 @@ fn zirCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError!*Inst { |
| 980 | 980 | |
| 981 | 981 | const b = try mod.requireFunctionBlock(scope, inst.base.src); |
| 982 | 982 | const is_comptime_call = b.is_comptime or inst.kw_args.modifier == .compile_time; |
| 983 | const is_inline_call = is_comptime_call or inst.kw_args.modifier == .always_inline or blk: { | |
| 984 | // This logic will get simplified by | |
| 985 | // https://github.com/ziglang/zig/issues/6429 | |
| 986 | if (try mod.resolveDefinedValue(scope, func)) |func_val| { | |
| 987 | const module_fn = switch (func_val.tag()) { | |
| 988 | .function => func_val.castTag(.function).?.data, | |
| 989 | else => break :blk false, | |
| 990 | }; | |
| 991 | break :blk module_fn.state == .inline_only; | |
| 992 | } | |
| 993 | break :blk false; | |
| 994 | }; | |
| 983 | const is_inline_call = is_comptime_call or inst.kw_args.modifier == .always_inline or | |
| 984 | func.ty.fnCallingConvention() == .Inline; | |
| 995 | 985 | if (is_inline_call) { |
| 996 | 986 | const func_val = try mod.resolveConstValue(scope, func); |
| 997 | 987 | const module_fn = switch (func_val.tag()) { |
| ... | ... | @@ -1075,7 +1065,7 @@ fn zirFn(mod: *Module, scope: *Scope, fn_inst: *zir.Inst.Fn) InnerError!*Inst { |
| 1075 | 1065 | const fn_type = try resolveType(mod, scope, fn_inst.positionals.fn_type); |
| 1076 | 1066 | const new_func = try scope.arena().create(Module.Fn); |
| 1077 | 1067 | new_func.* = .{ |
| 1078 | .state = if (fn_inst.kw_args.is_inline) .inline_only else .queued, | |
| 1068 | .state = if (fn_type.fnCallingConvention() == .Inline) .inline_only else .queued, | |
| 1079 | 1069 | .zir = fn_inst.positionals.body, |
| 1080 | 1070 | .body = undefined, |
| 1081 | 1071 | .owner_decl = scope.ownerDecl().?, |
| ... | ... | @@ -1305,22 +1295,26 @@ fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!* |
| 1305 | 1295 | const tracy = trace(@src()); |
| 1306 | 1296 | defer tracy.end(); |
| 1307 | 1297 | const return_type = try resolveType(mod, scope, fntype.positionals.return_type); |
| 1298 | const cc_tv = try resolveInstConst(mod, scope, fntype.positionals.cc); | |
| 1299 | const cc_str = cc_tv.val.castTag(.enum_literal).?.data; | |
| 1300 | const cc = std.meta.stringToEnum(std.builtin.CallingConvention, cc_str) orelse | |
| 1301 | return mod.fail(scope, fntype.positionals.cc.src, "Unknown calling convention {s}", .{cc_str}); | |
| 1308 | 1302 | |
| 1309 | 1303 | // Hot path for some common function types. |
| 1310 | 1304 | if (fntype.positionals.param_types.len == 0) { |
| 1311 | if (return_type.zigTypeTag() == .NoReturn and fntype.kw_args.cc == .Unspecified) { | |
| 1305 | if (return_type.zigTypeTag() == .NoReturn and cc == .Unspecified) { | |
| 1312 | 1306 | return mod.constType(scope, fntype.base.src, Type.initTag(.fn_noreturn_no_args)); |
| 1313 | 1307 | } |
| 1314 | 1308 | |
| 1315 | if (return_type.zigTypeTag() == .Void and fntype.kw_args.cc == .Unspecified) { | |
| 1309 | if (return_type.zigTypeTag() == .Void and cc == .Unspecified) { | |
| 1316 | 1310 | return mod.constType(scope, fntype.base.src, Type.initTag(.fn_void_no_args)); |
| 1317 | 1311 | } |
| 1318 | 1312 | |
| 1319 | if (return_type.zigTypeTag() == .NoReturn and fntype.kw_args.cc == .Naked) { | |
| 1313 | if (return_type.zigTypeTag() == .NoReturn and cc == .Naked) { | |
| 1320 | 1314 | return mod.constType(scope, fntype.base.src, Type.initTag(.fn_naked_noreturn_no_args)); |
| 1321 | 1315 | } |
| 1322 | 1316 | |
| 1323 | if (return_type.zigTypeTag() == .Void and fntype.kw_args.cc == .C) { | |
| 1317 | if (return_type.zigTypeTag() == .Void and cc == .C) { | |
| 1324 | 1318 | return mod.constType(scope, fntype.base.src, Type.initTag(.fn_ccc_void_no_args)); |
| 1325 | 1319 | } |
| 1326 | 1320 | } |
| ... | ... | @@ -1337,9 +1331,9 @@ fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!* |
| 1337 | 1331 | } |
| 1338 | 1332 | |
| 1339 | 1333 | const fn_ty = try Type.Tag.function.create(arena, .{ |
| 1340 | .cc = fntype.kw_args.cc, | |
| 1341 | .return_type = return_type, | |
| 1342 | 1334 | .param_types = param_types, |
| 1335 | .return_type = return_type, | |
| 1336 | .cc = cc, | |
| 1343 | 1337 | }); |
| 1344 | 1338 | return mod.constType(scope, fntype.base.src, fn_ty); |
| 1345 | 1339 | } |
test/cli.zig+1-1| ... | ... | @@ -113,7 +113,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void { |
| 113 | 113 | \\ return num * num; |
| 114 | 114 | \\} |
| 115 | 115 | \\extern fn zig_panic() noreturn; |
| 116 | \\pub inline fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn { | |
| 116 | \\pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn { | |
| 117 | 117 | \\ zig_panic(); |
| 118 | 118 | \\} |
| 119 | 119 | ); |
test/compile_errors.zig+6-6| ... | ... | @@ -1648,7 +1648,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1648 | 1648 | \\ @call(.{ .modifier = .compile_time }, baz, .{}); |
| 1649 | 1649 | \\} |
| 1650 | 1650 | \\fn foo() void {} |
| 1651 | \\inline fn bar() void {} | |
| 1651 | \\fn bar() callconv(.Inline) void {} | |
| 1652 | 1652 | \\fn baz1() void {} |
| 1653 | 1653 | \\fn baz2() void {} |
| 1654 | 1654 | , &[_][]const u8{ |
| ... | ... | @@ -3944,7 +3944,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3944 | 3944 | \\export fn entry() void { |
| 3945 | 3945 | \\ var a = b; |
| 3946 | 3946 | \\} |
| 3947 | \\inline fn b() void { } | |
| 3947 | \\fn b() callconv(.Inline) void { } | |
| 3948 | 3948 | , &[_][]const u8{ |
| 3949 | 3949 | "tmp.zig:2:5: error: functions marked inline must be stored in const or comptime var", |
| 3950 | 3950 | "tmp.zig:4:1: note: declared here", |
| ... | ... | @@ -6782,11 +6782,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6782 | 6782 | // \\export fn foo() void { |
| 6783 | 6783 | // \\ bar(); |
| 6784 | 6784 | // \\} |
| 6785 | // \\inline fn bar() void { | |
| 6785 | // \\fn bar() callconv(.Inline) void { | |
| 6786 | 6786 | // \\ baz(); |
| 6787 | 6787 | // \\ quux(); |
| 6788 | 6788 | // \\} |
| 6789 | // \\inline fn baz() void { | |
| 6789 | // \\fn baz() callconv(.Inline) void { | |
| 6790 | 6790 | // \\ bar(); |
| 6791 | 6791 | // \\ quux(); |
| 6792 | 6792 | // \\} |
| ... | ... | @@ -6799,7 +6799,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6799 | 6799 | // \\export fn foo() void { |
| 6800 | 6800 | // \\ quux(@ptrToInt(bar)); |
| 6801 | 6801 | // \\} |
| 6802 | // \\inline fn bar() void { } | |
| 6802 | // \\fn bar() callconv(.Inline) void { } | |
| 6803 | 6803 | // \\extern fn quux(usize) void; |
| 6804 | 6804 | //, &[_][]const u8{ |
| 6805 | 6805 | // "tmp.zig:4:1: error: unable to inline function", |
| ... | ... | @@ -7207,7 +7207,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 7207 | 7207 | \\export fn entry() void { |
| 7208 | 7208 | \\ foo(); |
| 7209 | 7209 | \\} |
| 7210 | \\inline fn foo() void { | |
| 7210 | \\fn foo() callconv(.Inline) void { | |
| 7211 | 7211 | \\ @setAlignStack(16); |
| 7212 | 7212 | \\} |
| 7213 | 7213 | , &[_][]const u8{ |
test/stage1/behavior/fn.zig+1-1| ... | ... | @@ -113,7 +113,7 @@ test "assign inline fn to const variable" { |
| 113 | 113 | a(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | inline fn inlineFn() void {} | |
| 116 | fn inlineFn() callconv(.Inline) void {} | |
| 117 | 117 | |
| 118 | 118 | test "pass by non-copying value" { |
| 119 | 119 | expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3); |
test/stage2/cbe.zig+1-1| ... | ... | @@ -179,7 +179,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 179 | 179 | \\ return y - 1; |
| 180 | 180 | \\} |
| 181 | 181 | \\ |
| 182 | \\inline fn rec(n: usize) usize { | |
| 182 | \\fn rec(n: usize) callconv(.Inline) usize { | |
| 183 | 183 | \\ if (n <= 1) return n; |
| 184 | 184 | \\ return rec(n - 1); |
| 185 | 185 | \\} |
test/stage2/test.zig+5-5| ... | ... | @@ -255,7 +255,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 255 | 255 | \\ exit(y - 6); |
| 256 | 256 | \\} |
| 257 | 257 | \\ |
| 258 | \\inline fn add(a: usize, b: usize, c: usize) usize { | |
| 258 | \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize { | |
| 259 | 259 | \\ return a + b + c; |
| 260 | 260 | \\} |
| 261 | 261 | \\ |
| ... | ... | @@ -1228,7 +1228,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1228 | 1228 | \\ exit(y - 6); |
| 1229 | 1229 | \\} |
| 1230 | 1230 | \\ |
| 1231 | \\inline fn add(a: usize, b: usize, c: usize) usize { | |
| 1231 | \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize { | |
| 1232 | 1232 | \\ if (a == 10) @compileError("bad"); |
| 1233 | 1233 | \\ return a + b + c; |
| 1234 | 1234 | \\} |
| ... | ... | @@ -1251,7 +1251,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1251 | 1251 | \\ exit(y - 6); |
| 1252 | 1252 | \\} |
| 1253 | 1253 | \\ |
| 1254 | \\inline fn add(a: usize, b: usize, c: usize) usize { | |
| 1254 | \\fn add(a: usize, b: usize, c: usize) callconv(.Inline) usize { | |
| 1255 | 1255 | \\ if (a == 10) @compileError("bad"); |
| 1256 | 1256 | \\ return a + b + c; |
| 1257 | 1257 | \\} |
| ... | ... | @@ -1277,7 +1277,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1277 | 1277 | \\ exit(y - 21); |
| 1278 | 1278 | \\} |
| 1279 | 1279 | \\ |
| 1280 | \\inline fn fibonacci(n: usize) usize { | |
| 1280 | \\fn fibonacci(n: usize) callconv(.Inline) usize { | |
| 1281 | 1281 | \\ if (n <= 2) return n; |
| 1282 | 1282 | \\ return fibonacci(n - 2) + fibonacci(n - 1); |
| 1283 | 1283 | \\} |
| ... | ... | @@ -1300,7 +1300,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 1300 | 1300 | \\ exit(y - 21); |
| 1301 | 1301 | \\} |
| 1302 | 1302 | \\ |
| 1303 | \\inline fn fibonacci(n: usize) usize { | |
| 1303 | \\fn fibonacci(n: usize) callconv(.Inline) usize { | |
| 1304 | 1304 | \\ if (n <= 2) return n; |
| 1305 | 1305 | \\ return fibonacci(n - 2) + fibonacci(n - 1); |
| 1306 | 1306 | \\} |
test/translate_c.zig+16-16| ... | ... | @@ -43,7 +43,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 43 | 43 | , |
| 44 | 44 | \\pub const VALUE = ((((1 + (2 * 3)) + (4 * 5)) + 6) << 7) | @boolToInt(8 == 9); |
| 45 | 45 | , |
| 46 | \\pub inline fn _AL_READ3BYTES(p: anytype) @TypeOf(((@import("std").meta.cast([*c]u8, p)).* | (((@import("std").meta.cast([*c]u8, p)) + 1).* << 8)) | (((@import("std").meta.cast([*c]u8, p)) + 2).* << 16)) { | |
| 46 | \\pub fn _AL_READ3BYTES(p: anytype) callconv(.Inline) @TypeOf(((@import("std").meta.cast([*c]u8, p)).* | (((@import("std").meta.cast([*c]u8, p)) + 1).* << 8)) | (((@import("std").meta.cast([*c]u8, p)) + 2).* << 16)) { | |
| 47 | 47 | \\ return ((@import("std").meta.cast([*c]u8, p)).* | (((@import("std").meta.cast([*c]u8, p)) + 1).* << 8)) | (((@import("std").meta.cast([*c]u8, p)) + 2).* << 16); |
| 48 | 48 | \\} |
| 49 | 49 | }); |
| ... | ... | @@ -116,7 +116,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 116 | 116 | \\}; |
| 117 | 117 | \\pub const Color = struct_Color; |
| 118 | 118 | , |
| 119 | \\pub inline fn CLITERAL(type_1: anytype) @TypeOf(type_1) { | |
| 119 | \\pub fn CLITERAL(type_1: anytype) callconv(.Inline) @TypeOf(type_1) { | |
| 120 | 120 | \\ return type_1; |
| 121 | 121 | \\} |
| 122 | 122 | , |
| ... | ... | @@ -148,7 +148,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 148 | 148 | cases.add("correct semicolon after infixop", |
| 149 | 149 | \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) |
| 150 | 150 | , &[_][]const u8{ |
| 151 | \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf(((_fp.*._flags) & _IO_ERR_SEEN) != 0) { | |
| 151 | \\pub fn __ferror_unlocked_body(_fp: anytype) callconv(.Inline) @TypeOf(((_fp.*._flags) & _IO_ERR_SEEN) != 0) { | |
| 152 | 152 | \\ return ((_fp.*._flags) & _IO_ERR_SEEN) != 0; |
| 153 | 153 | \\} |
| 154 | 154 | }); |
| ... | ... | @@ -157,7 +157,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 157 | 157 | \\#define FOO(x) ((x >= 0) + (x >= 0)) |
| 158 | 158 | \\#define BAR 1 && 2 > 4 |
| 159 | 159 | , &[_][]const u8{ |
| 160 | \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= 0) + @boolToInt(x >= 0)) { | |
| 160 | \\pub fn FOO(x: anytype) callconv(.Inline) @TypeOf(@boolToInt(x >= 0) + @boolToInt(x >= 0)) { | |
| 161 | 161 | \\ return @boolToInt(x >= 0) + @boolToInt(x >= 0); |
| 162 | 162 | \\} |
| 163 | 163 | , |
| ... | ... | @@ -208,7 +208,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 208 | 208 | \\ break :blk bar; |
| 209 | 209 | \\}; |
| 210 | 210 | , |
| 211 | \\pub inline fn bar(x: anytype) @TypeOf(baz(1, 2)) { | |
| 211 | \\pub fn bar(x: anytype) callconv(.Inline) @TypeOf(baz(1, 2)) { | |
| 212 | 212 | \\ return blk: { |
| 213 | 213 | \\ _ = &x; |
| 214 | 214 | \\ _ = 3; |
| ... | ... | @@ -1590,13 +1590,13 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1590 | 1590 | , &[_][]const u8{ |
| 1591 | 1591 | \\pub extern var fn_ptr: ?fn () callconv(.C) void; |
| 1592 | 1592 | , |
| 1593 | \\pub inline fn foo() void { | |
| 1593 | \\pub fn foo() callconv(.Inline) void { | |
| 1594 | 1594 | \\ return fn_ptr.?(); |
| 1595 | 1595 | \\} |
| 1596 | 1596 | , |
| 1597 | 1597 | \\pub extern var fn_ptr2: ?fn (c_int, f32) callconv(.C) u8; |
| 1598 | 1598 | , |
| 1599 | \\pub inline fn bar(arg_1: c_int, arg_2: f32) u8 { | |
| 1599 | \\pub fn bar(arg_1: c_int, arg_2: f32) callconv(.Inline) u8 { | |
| 1600 | 1600 | \\ return fn_ptr2.?(arg_1, arg_2); |
| 1601 | 1601 | \\} |
| 1602 | 1602 | }); |
| ... | ... | @@ -1629,7 +1629,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1629 | 1629 | , |
| 1630 | 1630 | \\pub const glClearPFN = PFNGLCLEARPROC; |
| 1631 | 1631 | , |
| 1632 | \\pub inline fn glClearUnion(arg_2: GLbitfield) void { | |
| 1632 | \\pub fn glClearUnion(arg_2: GLbitfield) callconv(.Inline) void { | |
| 1633 | 1633 | \\ return glProcs.gl.Clear.?(arg_2); |
| 1634 | 1634 | \\} |
| 1635 | 1635 | , |
| ... | ... | @@ -1650,15 +1650,15 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1650 | 1650 | , &[_][]const u8{ |
| 1651 | 1651 | \\pub extern var c: c_int; |
| 1652 | 1652 | , |
| 1653 | \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * 2) { | |
| 1653 | \\pub fn BASIC(c_1: anytype) callconv(.Inline) @TypeOf(c_1 * 2) { | |
| 1654 | 1654 | \\ return c_1 * 2; |
| 1655 | 1655 | \\} |
| 1656 | 1656 | , |
| 1657 | \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) { | |
| 1657 | \\pub fn FOO(L: anytype, b: anytype) callconv(.Inline) @TypeOf(L + b) { | |
| 1658 | 1658 | \\ return L + b; |
| 1659 | 1659 | \\} |
| 1660 | 1660 | , |
| 1661 | \\pub inline fn BAR() @TypeOf(c * c) { | |
| 1661 | \\pub fn BAR() callconv(.Inline) @TypeOf(c * c) { | |
| 1662 | 1662 | \\ return c * c; |
| 1663 | 1663 | \\} |
| 1664 | 1664 | }); |
| ... | ... | @@ -2310,7 +2310,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2310 | 2310 | cases.add("macro call", |
| 2311 | 2311 | \\#define CALL(arg) bar(arg) |
| 2312 | 2312 | , &[_][]const u8{ |
| 2313 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) { | |
| 2313 | \\pub fn CALL(arg: anytype) callconv(.Inline) @TypeOf(bar(arg)) { | |
| 2314 | 2314 | \\ return bar(arg); |
| 2315 | 2315 | \\} |
| 2316 | 2316 | }); |
| ... | ... | @@ -2872,7 +2872,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2872 | 2872 | \\#define BAR (void*) a |
| 2873 | 2873 | \\#define BAZ (uint32_t)(2) |
| 2874 | 2874 | , &[_][]const u8{ |
| 2875 | \\pub inline fn FOO(bar: anytype) @TypeOf(baz((@import("std").meta.cast(?*c_void, baz)))) { | |
| 2875 | \\pub fn FOO(bar: anytype) callconv(.Inline) @TypeOf(baz((@import("std").meta.cast(?*c_void, baz)))) { | |
| 2876 | 2876 | \\ return baz((@import("std").meta.cast(?*c_void, baz))); |
| 2877 | 2877 | \\} |
| 2878 | 2878 | , |
| ... | ... | @@ -2914,11 +2914,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2914 | 2914 | \\#define MIN(a, b) ((b) < (a) ? (b) : (a)) |
| 2915 | 2915 | \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) |
| 2916 | 2916 | , &[_][]const u8{ |
| 2917 | \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) { | |
| 2917 | \\pub fn MIN(a: anytype, b: anytype) callconv(.Inline) @TypeOf(if (b < a) b else a) { | |
| 2918 | 2918 | \\ return if (b < a) b else a; |
| 2919 | 2919 | \\} |
| 2920 | 2920 | , |
| 2921 | \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) { | |
| 2921 | \\pub fn MAX(a: anytype, b: anytype) callconv(.Inline) @TypeOf(if (b > a) b else a) { | |
| 2922 | 2922 | \\ return if (b > a) b else a; |
| 2923 | 2923 | \\} |
| 2924 | 2924 | }); |
| ... | ... | @@ -3106,7 +3106,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3106 | 3106 | \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen) |
| 3107 | 3107 | \\ |
| 3108 | 3108 | , &[_][]const u8{ |
| 3109 | \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf((@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen) { | |
| 3109 | \\pub fn DefaultScreen(dpy: anytype) callconv(.Inline) @TypeOf((@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen) { | |
| 3110 | 3110 | \\ return (@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen; |
| 3111 | 3111 | \\} |
| 3112 | 3112 | }); |