commit 097a62555e39e44ed403b73350c87e20c9753532 (tree)
parent 7432fb04d6e3c52b40e81911d6c608e4d17317df
Author: Andrew Kelley <andrew@ziglang.org>
Date: Tue, 7 May 2019 12:26:02 -0400
Merge pull request #2439 from LemonBoy/fixes-fixes-fixes
A batch of miscellaneous fixes
Diffstat:
7 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/std/io.zig b/std/io.zig
@@ -290,7 +290,7 @@ pub fn readFileAllocAligned(allocator: *mem.Allocator, path: []const u8, comptim
var file = try File.openRead(path);
defer file.close();
- const size = try file.getEndPos();
+ const size = try math.cast(usize, try file.getEndPos());
const buf = try allocator.alignedAlloc(u8, A, size);
errdefer allocator.free(buf);
diff --git a/std/os/linux.zig b/std/os/linux.zig
@@ -1392,17 +1392,19 @@ pub fn sched_getaffinity(pid: i32, set: []usize) usize {
return syscall3(SYS_sched_getaffinity, @bitCast(usize, isize(pid)), set.len * @sizeOf(usize), @ptrToInt(set.ptr));
}
-pub const epoll_data = packed union {
+pub const epoll_data = extern union {
ptr: usize,
fd: i32,
@"u32": u32,
@"u64": u64,
};
-pub const epoll_event = packed struct {
- events: u32,
- data: epoll_data,
-};
+// On x86_64 the structure is packed so that it matches the definition of its
+// 32bit counterpart
+pub const epoll_event = if (builtin.arch != .x86_64)
+ extern struct { events: u32, data: epoll_data }
+ else
+ packed struct { events: u32, data: epoll_data };
pub fn epoll_create() usize {
return epoll_create1(0);
diff --git a/std/special/compiler_rt/addXf3.zig b/std/special/compiler_rt/addXf3.zig
@@ -78,8 +78,8 @@ fn addXf3(comptime T: type, a: T, b: T) T {
const infRep = @bitCast(Z, std.math.inf(T));
// Detect if a or b is zero, infinity, or NaN.
- if (aAbs - Z(1) >= infRep - Z(1) or
- bAbs - Z(1) >= infRep - Z(1))
+ if (aAbs -% Z(1) >= infRep - Z(1) or
+ bAbs -% Z(1) >= infRep - Z(1))
{
// NaN + anything = qNaN
if (aAbs > infRep) return @bitCast(T, @bitCast(Z, a) | quietBit);
diff --git a/std/special/compiler_rt/arm/aeabi_dcmp.zig b/std/special/compiler_rt/arm/aeabi_dcmp.zig
@@ -87,7 +87,7 @@ inline fn aeabi_dcmp(comptime cond: ConditionalOperator) void {
.Ge => asm volatile (
\\ bl __ltdf2
\\ cmp r0, #0
- \\ blt 1f
+ \\ bge 1f
\\ movs r0, #0
\\ pop { r4, pc }
\\ 1:
diff --git a/std/special/compiler_rt/arm/aeabi_fcmp.zig b/std/special/compiler_rt/arm/aeabi_fcmp.zig
@@ -87,7 +87,7 @@ inline fn aeabi_fcmp(comptime cond: ConditionalOperator) void {
.Ge => asm volatile (
\\ bl __ltsf2
\\ cmp r0, #0
- \\ blt 1f
+ \\ bge 1f
\\ movs r0, #0
\\ pop { r4, pc }
\\ 1:
diff --git a/std/special/compiler_rt/extendXfYf2.zig b/std/special/compiler_rt/extendXfYf2.zig
@@ -3,20 +3,20 @@ const builtin = @import("builtin");
const is_test = builtin.is_test;
pub extern fn __extenddftf2(a: f64) f128 {
- return extendXfYf2(f128, f64, a);
+ return extendXfYf2(f128, f64, @bitCast(u64, a));
}
pub extern fn __extendsftf2(a: f32) f128 {
- return extendXfYf2(f128, f32, a);
+ return extendXfYf2(f128, f32, @bitCast(u32, a));
}
pub extern fn __extendhfsf2(a: u16) f32 {
- return extendXfYf2(f32, f16, @bitCast(f16, a));
+ return extendXfYf2(f32, f16, a);
}
const CHAR_BIT = 8;
-inline fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
+inline fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @typeInfo(src_t).Float.bits)) dst_t {
const src_rep_t = @IntType(false, @typeInfo(src_t).Float.bits);
const dst_rep_t = @IntType(false, @typeInfo(dst_t).Float.bits);
const srcSigBits = std.math.floatMantissaBits(src_t);
diff --git a/std/zig/render.zig b/std/zig/render.zig
@@ -748,7 +748,7 @@ fn renderExpression(
counting_stream.bytes_written = 0;
var dummy_col: usize = 0;
try renderExpression(allocator, &counting_stream.stream, tree, 0, &dummy_col, expr.*, Space.None);
- const width = counting_stream.bytes_written;
+ const width = @intCast(usize, counting_stream.bytes_written);
const col = i % row_size;
column_widths[col] = std.math.max(column_widths[col], width);
expr_widths[i] = width;