Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
215 changes: 121 additions & 94 deletions doc/langref.html.in

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/build_runner.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn main() !void {
};
const arena = thread_safe_arena.allocator();

var args = try process.argsAlloc(arena);
const args = try process.argsAlloc(arena);

// skip my own exe name
var arg_idx: usize = 1;
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/absvdi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const testing = @import("std").testing;
const __absvdi2 = @import("absvdi2.zig").__absvdi2;

fn test__absvdi2(a: i64, expected: i64) !void {
var result = __absvdi2(a);
const result = __absvdi2(a);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/absvsi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const testing = @import("std").testing;
const __absvsi2 = @import("absvsi2.zig").__absvsi2;

fn test__absvsi2(a: i32, expected: i32) !void {
var result = __absvsi2(a);
const result = __absvsi2(a);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/absvti2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const testing = @import("std").testing;
const __absvti2 = @import("absvti2.zig").__absvti2;

fn test__absvti2(a: i128, expected: i128) !void {
var result = __absvti2(a);
const result = __absvti2(a);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/addo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ comptime {
inline fn addoXi4_generic(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST {
@setRuntimeSafety(builtin.is_test);
overflow.* = 0;
var sum: ST = a +% b;
const sum: ST = a +% b;
// Hackers Delight: section Overflow Detection, subsection Signed Add/Subtract
// Let sum = a +% b == a + b + carry == wraparound addition.
// Overflow in a+b+carry occurs, iff a and b have opposite signs
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/addodi4_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const math = std.math;
fn test__addodi4(a: i64, b: i64) !void {
var result_ov: c_int = undefined;
var expected_ov: c_int = undefined;
var result = addv.__addodi4(a, b, &result_ov);
var expected: i64 = simple_addodi4(a, b, &expected_ov);
const result = addv.__addodi4(a, b, &result_ov);
const expected: i64 = simple_addodi4(a, b, &expected_ov);
try testing.expectEqual(expected, result);
try testing.expectEqual(expected_ov, result_ov);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/addosi4_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const testing = @import("std").testing;
fn test__addosi4(a: i32, b: i32) !void {
var result_ov: c_int = undefined;
var expected_ov: c_int = undefined;
var result = addv.__addosi4(a, b, &result_ov);
var expected: i32 = simple_addosi4(a, b, &expected_ov);
const result = addv.__addosi4(a, b, &result_ov);
const expected: i32 = simple_addosi4(a, b, &expected_ov);
try testing.expectEqual(expected, result);
try testing.expectEqual(expected_ov, result_ov);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/addoti4_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const math = std.math;
fn test__addoti4(a: i128, b: i128) !void {
var result_ov: c_int = undefined;
var expected_ov: c_int = undefined;
var result = addv.__addoti4(a, b, &result_ov);
var expected: i128 = simple_addoti4(a, b, &expected_ov);
const result = addv.__addoti4(a, b, &result_ov);
const expected: i128 = simple_addoti4(a, b, &expected_ov);
try testing.expectEqual(expected, result);
try testing.expectEqual(expected_ov, result_ov);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/bswapdi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const bswap = @import("bswap.zig");
const testing = @import("std").testing;

fn test__bswapdi2(a: u64, expected: u64) !void {
var result = bswap.__bswapdi2(a);
const result = bswap.__bswapdi2(a);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/bswapsi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const bswap = @import("bswap.zig");
const testing = @import("std").testing;

fn test__bswapsi2(a: u32, expected: u32) !void {
var result = bswap.__bswapsi2(a);
const result = bswap.__bswapsi2(a);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/bswapti2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const bswap = @import("bswap.zig");
const testing = @import("std").testing;

fn test__bswapti2(a: u128, expected: u128) !void {
var result = bswap.__bswapti2(a);
const result = bswap.__bswapti2(a);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/ceil.zig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn __ceilh(x: f16) callconv(.C) f16 {

pub fn ceilf(x: f32) callconv(.C) f32 {
var u: u32 = @bitCast(x);
var e = @as(i32, @intCast((u >> 23) & 0xFF)) - 0x7F;
const e = @as(i32, @intCast((u >> 23) & 0xFF)) - 0x7F;
var m: u32 = undefined;

// TODO: Shouldn't need this explicit check.
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/clzdi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const clz = @import("count0bits.zig");
const testing = @import("std").testing;

fn test__clzdi2(a: u64, expected: i64) !void {
var x: i64 = @bitCast(a);
var result = clz.__clzdi2(x);
const x: i64 = @bitCast(a);
const result = clz.__clzdi2(x);
try testing.expectEqual(expected, result);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/clzti2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const clz = @import("count0bits.zig");
const testing = @import("std").testing;

fn test__clzti2(a: u128, expected: i64) !void {
var x: i128 = @bitCast(a);
var result = clz.__clzti2(x);
const x: i128 = @bitCast(a);
const result = clz.__clzti2(x);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/cmpdi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const cmp = @import("cmp.zig");
const testing = @import("std").testing;

fn test__cmpdi2(a: i64, b: i64, expected: i64) !void {
var result = cmp.__cmpdi2(a, b);
const result = cmp.__cmpdi2(a, b);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/cmpsi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const cmp = @import("cmp.zig");
const testing = @import("std").testing;

fn test__cmpsi2(a: i32, b: i32, expected: i32) !void {
var result = cmp.__cmpsi2(a, b);
const result = cmp.__cmpsi2(a, b);
try testing.expectEqual(expected, result);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/cmpti2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const cmp = @import("cmp.zig");
const testing = @import("std").testing;

fn test__cmpti2(a: i128, b: i128, expected: i128) !void {
var result = cmp.__cmpti2(a, b);
const result = cmp.__cmpti2(a, b);
try testing.expectEqual(expected, result);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/ctzdi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const ctz = @import("count0bits.zig");
const testing = @import("std").testing;

fn test__ctzdi2(a: u64, expected: i32) !void {
var x: i64 = @bitCast(a);
var result = ctz.__ctzdi2(x);
const x: i64 = @bitCast(a);
const result = ctz.__ctzdi2(x);
try testing.expectEqual(expected, result);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/ctzsi2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const ctz = @import("count0bits.zig");
const testing = @import("std").testing;

fn test__ctzsi2(a: u32, expected: i32) !void {
var x: i32 = @bitCast(a);
var result = ctz.__ctzsi2(x);
const x: i32 = @bitCast(a);
const result = ctz.__ctzsi2(x);
try testing.expectEqual(expected, result);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/ctzti2_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const ctz = @import("count0bits.zig");
const testing = @import("std").testing;

fn test__ctzti2(a: u128, expected: i32) !void {
var x: i128 = @bitCast(a);
var result = ctz.__ctzti2(x);
const x: i128 = @bitCast(a);
const result = ctz.__ctzti2(x);
try testing.expectEqual(expected, result);
}

Expand Down
40 changes: 20 additions & 20 deletions lib/compiler_rt/divc3_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ test {

fn testDiv(comptime T: type, comptime f: fn (T, T, T, T) callconv(.C) Complex(T)) !void {
{
var a: T = 1.0;
var b: T = 0.0;
var c: T = -1.0;
var d: T = 0.0;
const a: T = 1.0;
const b: T = 0.0;
const c: T = -1.0;
const d: T = 0.0;

const result = f(a, b, c, d);
try expect(result.real == -1.0);
try expect(result.imag == 0.0);
}
{
var a: T = 1.0;
var b: T = 0.0;
var c: T = -4.0;
var d: T = 0.0;
const a: T = 1.0;
const b: T = 0.0;
const c: T = -4.0;
const d: T = 0.0;

const result = f(a, b, c, d);
try expect(result.real == -0.25);
Expand All @@ -41,10 +41,10 @@ fn testDiv(comptime T: type, comptime f: fn (T, T, T, T) callconv(.C) Complex(T)
{
// if the first operand is an infinity and the second operand is a finite number, then the
// result of the / operator is an infinity;
var a: T = -math.inf(T);
var b: T = 0.0;
var c: T = -4.0;
var d: T = 1.0;
const a: T = -math.inf(T);
const b: T = 0.0;
const c: T = -4.0;
const d: T = 1.0;

const result = f(a, b, c, d);
try expect(result.real == math.inf(T));
Expand All @@ -53,10 +53,10 @@ fn testDiv(comptime T: type, comptime f: fn (T, T, T, T) callconv(.C) Complex(T)
{
// if the first operand is a finite number and the second operand is an infinity, then the
// result of the / operator is a zero;
var a: T = 17.2;
var b: T = 0.0;
var c: T = -math.inf(T);
var d: T = 0.0;
const a: T = 17.2;
const b: T = 0.0;
const c: T = -math.inf(T);
const d: T = 0.0;

const result = f(a, b, c, d);
try expect(result.real == -0.0);
Expand All @@ -65,10 +65,10 @@ fn testDiv(comptime T: type, comptime f: fn (T, T, T, T) callconv(.C) Complex(T)
{
// if the first operand is a nonzero finite number or an infinity and the second operand is
// a zero, then the result of the / operator is an infinity
var a: T = 1.1;
var b: T = 0.1;
var c: T = 0.0;
var d: T = 0.0;
const a: T = 1.1;
const b: T = 0.1;
const c: T = 0.0;
const d: T = 0.0;

const result = f(a, b, c, d);
try expect(result.real == math.inf(T));
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler_rt/divxf3.zig
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
// Two cases: quotient is in [0.5, 1.0) or quotient is in [1.0, 2.0).
// Right shift the quotient if it falls in the [1,2) range and adjust the
// exponent accordingly.
var quotient: u64 = if (quotient128 < (integerBit << 1)) b: {
const quotient: u64 = if (quotient128 < (integerBit << 1)) b: {
quotientExponent -= 1;
break :b @intCast(quotient128);
} else @intCast(quotient128 >> 1);
Expand All @@ -177,7 +177,7 @@ pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 {
//
// If r is greater than 1/2 ulp(q)*b, then q rounds up. Otherwise, we
// already have the correct result. The exact halfway case cannot occur.
var residual: u64 = -%(quotient *% q63b);
const residual: u64 = -%(quotient *% q63b);

const writtenExponent = quotientExponent + exponentBias;
if (writtenExponent >= maxExponent) {
Expand Down
22 changes: 11 additions & 11 deletions lib/compiler_rt/emutls.zig
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ const simple_allocator = struct {

/// Resize a slice.
pub fn reallocSlice(comptime T: type, slice: []T, len: usize) []T {
var c_ptr: *anyopaque = @ptrCast(slice.ptr);
var new_array: [*]T = @ptrCast(@alignCast(std.c.realloc(c_ptr, @sizeOf(T) * len) orelse abort()));
const c_ptr: *anyopaque = @ptrCast(slice.ptr);
const new_array: [*]T = @ptrCast(@alignCast(std.c.realloc(c_ptr, @sizeOf(T) * len) orelse abort()));
return new_array[0..len];
}

Expand All @@ -78,7 +78,7 @@ const ObjectArray = struct {

/// create a new ObjectArray with n slots. must call deinit() to deallocate.
pub fn init(n: usize) *ObjectArray {
var array = simple_allocator.alloc(ObjectArray);
const array = simple_allocator.alloc(ObjectArray);

array.* = ObjectArray{
.slots = simple_allocator.allocSlice(?ObjectPointer, n),
Expand Down Expand Up @@ -166,7 +166,7 @@ const current_thread_storage = struct {
const size = @max(16, index);

// create a new array and store it.
var array: *ObjectArray = ObjectArray.init(size);
const array: *ObjectArray = ObjectArray.init(size);
current_thread_storage.setspecific(array);
return array;
}
Expand Down Expand Up @@ -304,13 +304,13 @@ const emutls_control = extern struct {
test "simple_allocator" {
if (!builtin.link_libc or builtin.os.tag != .openbsd) return error.SkipZigTest;

var data1: *[64]u8 = simple_allocator.alloc([64]u8);
const data1: *[64]u8 = simple_allocator.alloc([64]u8);
defer simple_allocator.free(data1);
for (data1) |*c| {
c.* = 0xff;
}

var data2: [*]u8 = simple_allocator.advancedAlloc(@alignOf(u8), 64);
const data2: [*]u8 = simple_allocator.advancedAlloc(@alignOf(u8), 64);
defer simple_allocator.free(data2);
for (data2[0..63]) |*c| {
c.* = 0xff;
Expand All @@ -324,15 +324,15 @@ test "__emutls_get_address zeroed" {
try expect(ctl.object.index == 0);

// retrieve a variable from ctl
var x: *usize = @ptrCast(@alignCast(__emutls_get_address(&ctl)));
const x: *usize = @ptrCast(@alignCast(__emutls_get_address(&ctl)));
try expect(ctl.object.index != 0); // index has been allocated for this ctl
try expect(x.* == 0); // storage has been zeroed

// modify the storage
x.* = 1234;

// retrieve a variable from ctl (same ctl)
var y: *usize = @ptrCast(@alignCast(__emutls_get_address(&ctl)));
const y: *usize = @ptrCast(@alignCast(__emutls_get_address(&ctl)));

try expect(y.* == 1234); // same content that x.*
try expect(x == y); // same pointer
Expand All @@ -345,7 +345,7 @@ test "__emutls_get_address with default_value" {
var ctl = emutls_control.init(usize, &value);
try expect(ctl.object.index == 0);

var x: *usize = @ptrCast(@alignCast(__emutls_get_address(&ctl)));
const x: *usize = @ptrCast(@alignCast(__emutls_get_address(&ctl)));
try expect(ctl.object.index != 0);
try expect(x.* == 5678); // storage initialized with default value

Expand All @@ -354,7 +354,7 @@ test "__emutls_get_address with default_value" {

try expect(value == 5678); // the default value didn't change

var y: *usize = @ptrCast(@alignCast(__emutls_get_address(&ctl)));
const y: *usize = @ptrCast(@alignCast(__emutls_get_address(&ctl)));
try expect(y.* == 9012); // the modified storage persists
}

Expand All @@ -364,7 +364,7 @@ test "test default_value with differents sizes" {
const testType = struct {
fn _testType(comptime T: type, value: T) !void {
var ctl = emutls_control.init(T, &value);
var x = ctl.get_typed_pointer(T);
const x = ctl.get_typed_pointer(T);
try expect(x.* == value);
}
}._testType;
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/exp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn exp(x_: f64) callconv(.C) f64 {
const P5: f64 = 4.13813679705723846039e-08;

var x = x_;
var ux: u64 = @bitCast(x);
const ux: u64 = @bitCast(x);
var hx = ux >> 32;
const sign: i32 = @intCast(hx >> 31);
hx &= 0x7FFFFFFF;
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler_rt/exp2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 {
const P3: f32 = 0x1.c6b348p-5;
const P4: f32 = 0x1.3b2c9cp-7;

var u: u32 = @bitCast(x);
const u: u32 = @bitCast(x);
const ix = u & 0x7FFFFFFF;

// |x| > 126
Expand Down
Loading