mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std: remove redundant comptime keyword
@g-w1's fancy new compile error in action
This commit is contained in:
parent
0c71d2fdc1
commit
c60d8f017e
12 changed files with 26 additions and 26 deletions
|
|
@ -226,12 +226,12 @@ pub const Edwards25519 = struct {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const basePointPc = comptime pc: {
|
const basePointPc = pc: {
|
||||||
@setEvalBranchQuota(10000);
|
@setEvalBranchQuota(10000);
|
||||||
break :pc precompute(Edwards25519.basePoint, 15);
|
break :pc precompute(Edwards25519.basePoint, 15);
|
||||||
};
|
};
|
||||||
|
|
||||||
const basePointPc8 = comptime pc: {
|
const basePointPc8 = pc: {
|
||||||
@setEvalBranchQuota(10000);
|
@setEvalBranchQuota(10000);
|
||||||
break :pc precompute(Edwards25519.basePoint, 8);
|
break :pc precompute(Edwards25519.basePoint, 8);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ pub const Fe = struct {
|
||||||
return _carry128(&r);
|
return _carry128(&r);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _sq(a: Fe, double: comptime bool) callconv(.Inline) Fe {
|
fn _sq(a: Fe, double: bool) callconv(.Inline) Fe {
|
||||||
var ax: [5]u128 = undefined;
|
var ax: [5]u128 = undefined;
|
||||||
var r: [5]u128 = undefined;
|
var r: [5]u128 = undefined;
|
||||||
comptime var i = 0;
|
comptime var i = 0;
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ const std = @import("../std.zig");
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const builtin = std.builtin;
|
const builtin = std.builtin;
|
||||||
|
|
||||||
const has_aesni = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
|
const has_aesni = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
|
||||||
const has_avx = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
|
const has_avx = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
|
||||||
const has_armaes = comptime std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
|
const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
|
||||||
const impl = if (std.Target.current.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
|
const impl = if (std.Target.current.cpu.arch == .x86_64 and has_aesni and has_avx) impl: {
|
||||||
break :impl @import("aes/aesni.zig");
|
break :impl @import("aes/aesni.zig");
|
||||||
} else if (std.Target.current.cpu.arch == .aarch64 and has_armaes)
|
} else if (std.Target.current.cpu.arch == .aarch64 and has_armaes)
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,8 @@ fn AesOcb(comptime Aes: anytype) type {
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
const has_aesni = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
|
const has_aesni = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .aes);
|
||||||
const has_armaes = comptime std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
|
const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
|
||||||
const wb: usize = if ((std.Target.current.cpu.arch == .x86_64 and has_aesni) or (std.Target.current.cpu.arch == .aarch64 and has_armaes)) 4 else 0;
|
const wb: usize = if ((std.Target.current.cpu.arch == .x86_64 and has_aesni) or (std.Target.current.cpu.arch == .aarch64 and has_armaes)) 4 else 0;
|
||||||
|
|
||||||
/// c: ciphertext: output buffer should be of size m.len
|
/// c: ciphertext: output buffer should be of size m.len
|
||||||
|
|
|
||||||
|
|
@ -137,9 +137,9 @@ pub const Ghash = struct {
|
||||||
return z0 | z1 | z2 | z3;
|
return z0 | z1 | z2 | z3;
|
||||||
}
|
}
|
||||||
|
|
||||||
const has_pclmul = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .pclmul);
|
const has_pclmul = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .pclmul);
|
||||||
const has_avx = comptime std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
|
const has_avx = std.Target.x86.featureSetHas(std.Target.current.cpu.features, .avx);
|
||||||
const has_armaes = comptime std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
|
const has_armaes = std.Target.aarch64.featureSetHas(std.Target.current.cpu.features, .aes);
|
||||||
const clmul = if (std.Target.current.cpu.arch == .x86_64 and has_pclmul and has_avx) impl: {
|
const clmul = if (std.Target.current.cpu.arch == .x86_64 and has_pclmul and has_avx) impl: {
|
||||||
break :impl clmul_pclmul;
|
break :impl clmul_pclmul;
|
||||||
} else if (std.Target.current.cpu.arch == .aarch64 and has_armaes) impl: {
|
} else if (std.Target.current.cpu.arch == .aarch64 and has_armaes) impl: {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const debug = std.debug;
|
||||||
///
|
///
|
||||||
/// Important: the counter mode doesn't provide authenticated encryption: the ciphertext can be trivially modified without this being detected.
|
/// Important: the counter mode doesn't provide authenticated encryption: the ciphertext can be trivially modified without this being detected.
|
||||||
/// As a result, applications should generally never use it directly, but only in a construction that includes a MAC.
|
/// As a result, applications should generally never use it directly, but only in a construction that includes a MAC.
|
||||||
pub fn ctr(comptime BlockCipher: anytype, block_cipher: BlockCipher, dst: []u8, src: []const u8, iv: [BlockCipher.block_length]u8, endian: comptime builtin.Endian) void {
|
pub fn ctr(comptime BlockCipher: anytype, block_cipher: BlockCipher, dst: []u8, src: []const u8, iv: [BlockCipher.block_length]u8, endian: builtin.Endian) void {
|
||||||
debug.assert(dst.len >= src.len);
|
debug.assert(dst.len >= src.len);
|
||||||
const block_length = BlockCipher.block_length;
|
const block_length = BlockCipher.block_length;
|
||||||
var counter: [BlockCipher.block_length]u8 = undefined;
|
var counter: [BlockCipher.block_length]u8 = undefined;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ pub const Poly1305 = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn blocks(st: *Poly1305, m: []const u8, last: comptime bool) void {
|
fn blocks(st: *Poly1305, m: []const u8, last: bool) void {
|
||||||
const hibit: u64 = if (last) 0 else 1 << 40;
|
const hibit: u64 = if (last) 0 else 1 << 40;
|
||||||
const r0 = st.r[0];
|
const r0 = st.r[0];
|
||||||
const r1 = st.r[1];
|
const r1 = st.r[1];
|
||||||
|
|
|
||||||
|
|
@ -353,18 +353,18 @@ pub const StackIterator = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Offset of the saved BP wrt the frame pointer.
|
// Offset of the saved BP wrt the frame pointer.
|
||||||
const fp_offset = if (comptime native_arch.isRISCV())
|
const fp_offset = if (native_arch.isRISCV())
|
||||||
// On RISC-V the frame pointer points to the top of the saved register
|
// On RISC-V the frame pointer points to the top of the saved register
|
||||||
// area, on pretty much every other architecture it points to the stack
|
// area, on pretty much every other architecture it points to the stack
|
||||||
// slot where the previous frame pointer is saved.
|
// slot where the previous frame pointer is saved.
|
||||||
2 * @sizeOf(usize)
|
2 * @sizeOf(usize)
|
||||||
else if (comptime native_arch.isSPARC())
|
else if (native_arch.isSPARC())
|
||||||
// On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS.
|
// On SPARC the previous frame pointer is stored at 14 slots past %fp+BIAS.
|
||||||
14 * @sizeOf(usize)
|
14 * @sizeOf(usize)
|
||||||
else
|
else
|
||||||
0;
|
0;
|
||||||
|
|
||||||
const fp_bias = if (comptime native_arch.isSPARC())
|
const fp_bias = if (native_arch.isSPARC())
|
||||||
// On SPARC frame pointers are biased by a constant.
|
// On SPARC frame pointers are biased by a constant.
|
||||||
2047
|
2047
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ pub const Crc32 = Crc32WithPoly(.IEEE);
|
||||||
pub fn Crc32WithPoly(comptime poly: Polynomial) type {
|
pub fn Crc32WithPoly(comptime poly: Polynomial) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
const lookup_tables = comptime block: {
|
const lookup_tables = block: {
|
||||||
@setEvalBranchQuota(20000);
|
@setEvalBranchQuota(20000);
|
||||||
var tables: [8][256]u32 = undefined;
|
var tables: [8][256]u32 = undefined;
|
||||||
|
|
||||||
|
|
@ -128,7 +128,7 @@ test "crc32 castagnoli" {
|
||||||
pub fn Crc32SmallWithPoly(comptime poly: Polynomial) type {
|
pub fn Crc32SmallWithPoly(comptime poly: Polynomial) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
const lookup_table = comptime block: {
|
const lookup_table = block: {
|
||||||
var table: [16]u32 = undefined;
|
var table: [16]u32 = undefined;
|
||||||
|
|
||||||
for (table) |*e, i| {
|
for (table) |*e, i| {
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,17 @@ const CAllocator = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usingnamespace if (comptime @hasDecl(c, "malloc_size"))
|
usingnamespace if (@hasDecl(c, "malloc_size"))
|
||||||
struct {
|
struct {
|
||||||
pub const supports_malloc_size = true;
|
pub const supports_malloc_size = true;
|
||||||
pub const malloc_size = c.malloc_size;
|
pub const malloc_size = c.malloc_size;
|
||||||
}
|
}
|
||||||
else if (comptime @hasDecl(c, "malloc_usable_size"))
|
else if (@hasDecl(c, "malloc_usable_size"))
|
||||||
struct {
|
struct {
|
||||||
pub const supports_malloc_size = true;
|
pub const supports_malloc_size = true;
|
||||||
pub const malloc_size = c.malloc_usable_size;
|
pub const malloc_size = c.malloc_usable_size;
|
||||||
}
|
}
|
||||||
else if (comptime @hasDecl(c, "_msize"))
|
else if (@hasDecl(c, "_msize"))
|
||||||
struct {
|
struct {
|
||||||
pub const supports_malloc_size = true;
|
pub const supports_malloc_size = true;
|
||||||
pub const malloc_size = c._msize;
|
pub const malloc_size = c._msize;
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
|
||||||
pub const Reader = io.Reader(*Self, Error, read);
|
pub const Reader = io.Reader(*Self, Error, read);
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
const u8_bit_count = comptime meta.bitCount(u8);
|
const u8_bit_count = meta.bitCount(u8);
|
||||||
const u7_bit_count = comptime meta.bitCount(u7);
|
const u7_bit_count = meta.bitCount(u7);
|
||||||
const u4_bit_count = comptime meta.bitCount(u4);
|
const u4_bit_count = meta.bitCount(u4);
|
||||||
|
|
||||||
pub fn init(forward_reader: ReaderType) Self {
|
pub fn init(forward_reader: ReaderType) Self {
|
||||||
return Self{
|
return Self{
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
|
||||||
pub const Writer = io.Writer(*Self, Error, write);
|
pub const Writer = io.Writer(*Self, Error, write);
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
const u8_bit_count = comptime meta.bitCount(u8);
|
const u8_bit_count = meta.bitCount(u8);
|
||||||
const u4_bit_count = comptime meta.bitCount(u4);
|
const u4_bit_count = meta.bitCount(u4);
|
||||||
|
|
||||||
pub fn init(forward_writer: WriterType) Self {
|
pub fn init(forward_writer: WriterType) Self {
|
||||||
return Self{
|
return Self{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue