Merge pull request #2439 from LemonBoy/fixes-fixes-fixes

A batch of miscellaneous fixes
master
Andrew Kelley 2019-05-07 12:26:02 -04:00 committed by GitHub
commit 097a62555e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 15 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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:

View File

@ -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:

View File

@ -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);

View File

@ -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;