Skip to content

Commit

Permalink
update zig sources to 0.10.0-dev.2929+6a3a0fe7a
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jul 8, 2022
1 parent 0c5843a commit a642353
Show file tree
Hide file tree
Showing 112 changed files with 1,994 additions and 1,706 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ to find and inspect the patch diffs.

* LLVM, LLD, Clang 14.0.6
* zlib 1.2.12
* Zig 0.10.0-dev.2876+fbd6c8832
* zig 0.10.0-dev.2929+6a3a0fe7a

For other versions, check the git tags of this repository.

Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TARGET="$2" # Example: riscv64-linux-gnu
MCPU="$3" # Examples: `baseline`, `native`, `generic+v7a`, or `arm1176jzf_s`

ROOTDIR="$(pwd)"
ZIG_VERSION="0.10.0-dev.2876+fbd6c8832"
ZIG_VERSION="0.10.0-dev.2929+6a3a0fe7a"

TARGET_OS_AND_ABI=${TARGET#*-} # Example: linux-gnu

Expand Down
6 changes: 6 additions & 0 deletions zig/doc/langref.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -9383,6 +9383,12 @@ const std = @import("std");
const expect = std.testing.expect;

test "vector @reduce" {
// This test regressed with LLVM 14:
// https://github.com/llvm/llvm-project/issues/55522
// We'll skip this test unless the self-hosted compiler is being used.
// After LLVM 15 is released we can delete this line.
if (@import("builtin").zig_backend == .stage1) return;

const value = @Vector(4, i32){ 1, -1, 1, -1 };
const result = value > @splat(4, @as(i32, 0));
// result is { true, false, true, false };
Expand Down
2 changes: 1 addition & 1 deletion zig/lib/compiler_rt/common.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub const want_ppc_abi = builtin.cpu.arch.isPPC() or builtin.cpu.arch.isPPC64();
/// x86_64-windows-msvc => true
/// any-macos-any => false
pub const gnu_f16_abi = switch (builtin.cpu.arch) {
.wasm32, .wasm64 => false,
.wasm32, .wasm64, .riscv64, .riscv32 => false,

.arm, .armeb, .thumb, .thumbeb => switch (builtin.abi) {
.eabi, .eabihf => false,
Expand Down
9 changes: 9 additions & 0 deletions zig/lib/compiler_rt/mulo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ pub fn __mulodi4(a: i64, b: i64, overflow: *c_int) callconv(.C) i64 {
}

pub fn __muloti4(a: i128, b: i128, overflow: *c_int) callconv(.C) i128 {
switch (builtin.zig_backend) {
.stage1, .stage2_llvm => {
// Workaround for https://github.com/llvm/llvm-project/issues/56403
// When we call the genericSmall implementation instead, LLVM optimizer
// optimizes __muloti4 to a call to itself.
return muloXi4_genericFast(i128, a, b, overflow);
},
else => {},
}
if (2 * @bitSizeOf(i128) <= @bitSizeOf(usize)) {
return muloXi4_genericFast(i128, a, b, overflow);
} else {
Expand Down
1 change: 1 addition & 0 deletions zig/lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ pub fn panicOutOfBounds(index: usize, len: usize) noreturn {

pub noinline fn returnError(maybe_st: ?*StackTrace) void {
@setCold(true);
@setRuntimeSafety(false);
const st = maybe_st orelse return;
addErrRetTraceAddr(st, @returnAddress());
}
Expand Down
20 changes: 16 additions & 4 deletions zig/lib/std/crypto/ecdsa.zig
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
}

/// Encode the public key using the compressed SEC-1 format.
pub fn toCompressedSec1(p: Curve) [compressed_sec1_encoded_length]u8 {
return p.toCompressedSec1();
pub fn toCompressedSec1(pk: PublicKey) [compressed_sec1_encoded_length]u8 {
return pk.p.toCompressedSec1();
}

/// Encoding the public key using the uncompressed SEC-1 format.
pub fn toUncompressedSec1(p: Curve) [uncompressed_sec1_encoded_length]u8 {
return p.toUncompressedSec1();
pub fn toUncompressedSec1(pk: PublicKey) [uncompressed_sec1_encoded_length]u8 {
return pk.p.toUncompressedSec1();
}
};

Expand Down Expand Up @@ -743,3 +743,15 @@ fn tvTry(vector: TestVector) !void {
const sig = try Scheme.Signature.fromDer(sig_der);
try sig.verify(msg, pk);
}

test "ECDSA - Sec1 encoding/decoding" {
const Scheme = EcdsaP384Sha384;
const kp = try Scheme.KeyPair.create(null);
const pk = kp.public_key;
const pk_compressed_sec1 = pk.toCompressedSec1();
const pk_recovered1 = try Scheme.PublicKey.fromSec1(&pk_compressed_sec1);
try testing.expectEqualSlices(u8, &pk_recovered1.toCompressedSec1(), &pk_compressed_sec1);
const pk_uncompressed_sec1 = pk.toUncompressedSec1();
const pk_recovered2 = try Scheme.PublicKey.fromSec1(&pk_uncompressed_sec1);
try testing.expectEqualSlices(u8, &pk_recovered2.toUncompressedSec1(), &pk_uncompressed_sec1);
}
4 changes: 2 additions & 2 deletions zig/lib/std/fmt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2124,11 +2124,11 @@ test "pointer" {
try expectFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", .{value});
}
{
const value = @intToPtr(*const fn () void, 0xdeadbeef);
const value = @intToPtr(*align(1) const fn () void, 0xdeadbeef);
try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
}
{
const value = @intToPtr(*const fn () void, 0xdeadbeef);
const value = @intToPtr(*align(1) const fn () void, 0xdeadbeef);
try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
}
}
Expand Down
24 changes: 18 additions & 6 deletions zig/lib/std/fmt/parse_float.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub const parseFloat = @import("parse_float/parse_float.zig").parseFloat;
pub const ParseFloatError = @import("parse_float/parse_float.zig").ParseFloatError;

const builtin = @import("builtin");
const std = @import("std");
const math = std.math;
const testing = std.testing;
Expand All @@ -14,8 +15,6 @@ const epsilon = 1e-7;

test "fmt.parseFloat" {
inline for ([_]type{ f16, f32, f64, f128 }) |T| {
const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);

try testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
try testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));
try testing.expectError(error.InvalidCharacter, parseFloat(T, "1abc"));
Expand All @@ -40,10 +39,6 @@ test "fmt.parseFloat" {
try expectEqual(try parseFloat(T, "1e-5000"), 0);
try expectEqual(try parseFloat(T, "1e+5000"), std.math.inf(T));

try expectEqual(@bitCast(Z, try parseFloat(T, "nAn")), @bitCast(Z, std.math.nan(T)));
try expectEqual(try parseFloat(T, "inF"), std.math.inf(T));
try expectEqual(try parseFloat(T, "-INF"), -std.math.inf(T));

try expectEqual(try parseFloat(T, "0.4e0066999999999999999999999999999999999999999999999999999"), std.math.inf(T));
try expect(approxEqAbs(T, try parseFloat(T, "0_1_2_3_4_5_6.7_8_9_0_0_0e0_0_1_0"), @as(T, 123456.789000e10), epsilon));

Expand Down Expand Up @@ -74,6 +69,23 @@ test "fmt.parseFloat" {
}
}

test "fmt.parseFloat nan and inf" {
if ((builtin.zig_backend == .stage1 or builtin.zig_backend == .stage2_llvm) and
builtin.cpu.arch == .aarch64)
{
// https://github.com/ziglang/zig/issues/12027
return error.SkipZigTest;
}

inline for ([_]type{ f16, f32, f64, f128 }) |T| {
const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);

try expectEqual(@bitCast(Z, try parseFloat(T, "nAn")), @bitCast(Z, std.math.nan(T)));
try expectEqual(try parseFloat(T, "inF"), std.math.inf(T));
try expectEqual(try parseFloat(T, "-INF"), -std.math.inf(T));
}
}

test "fmt.parseFloat #11169" {
try expectEqual(try parseFloat(f128, "9007199254740993.0"), 9007199254740993.0);
}
Expand Down
Loading

0 comments on commit a642353

Please sign in to comment.