Skip to content

Commit 091c200

Browse files
Merge branch 'ziglang:master' into fmt.defaultchar
2 parents b5ef309 + 88bb0fd commit 091c200

38 files changed

+888
-503
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,10 @@ if(NOT "${ZIG_TARGET_DYNAMIC_LINKER}" STREQUAL "")
970970
list(APPEND ZIG_BUILD_ARGS "-Ddynamic-linker=${ZIG_TARGET_DYNAMIC_LINKER}")
971971
endif()
972972

973+
if(MINGW AND "${ZIG_HOST_TARGET_ARCH}" STREQUAL "x86")
974+
list(APPEND ZIG_BUILD_ARGS --maxrss 7000000000)
975+
endif()
976+
973977

974978
add_custom_target(stage3 ALL
975979
DEPENDS "${PROJECT_BINARY_DIR}/stage3/bin/zig"

doc/langref.html.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,16 +1935,18 @@ or
19351935
<li>{#syntax#}*T{#endsyntax#} - single-item pointer to exactly one item.
19361936
<ul>
19371937
<li>Supports deref syntax: {#syntax#}ptr.*{#endsyntax#}</li>
1938+
<li>Supports pointer subtraction: {#syntax#}ptr - ptr{#endsyntax#}</li>
19381939
</ul>
19391940
</li>
19401941
<li>{#syntax#}[*]T{#endsyntax#} - many-item pointer to unknown number of items.
19411942
<ul>
19421943
<li>Supports index syntax: {#syntax#}ptr[i]{#endsyntax#}</li>
19431944
<li>Supports slice syntax: {#syntax#}ptr[start..end]{#endsyntax#} and {#syntax#}ptr[start..]{#endsyntax#}</li>
1944-
<li>Supports pointer arithmetic: {#syntax#}ptr + x{#endsyntax#}, {#syntax#}ptr - x{#endsyntax#}</li>
1945-
<li>{#syntax#}T{#endsyntax#} must have a known size, which means that it cannot be
1946-
{#syntax#}anyopaque{#endsyntax#} or any other {#link|opaque type|opaque#}.</li>
1945+
<li>Supports pointer-integer arithmetic: {#syntax#}ptr + int{#endsyntax#}, {#syntax#}ptr - int{#endsyntax#}</li>
1946+
<li>Supports pointer subtraction: {#syntax#}ptr - ptr{#endsyntax#}</li>
19471947
</ul>
1948+
{#syntax#}T{#endsyntax#} must have a known size, which means that it cannot be
1949+
{#syntax#}anyopaque{#endsyntax#} or any other {#link|opaque type|opaque#}.
19481950
</li>
19491951
</ul>
19501952
<p>These types are closely related to {#link|Arrays#} and {#link|Slices#}:</p>
@@ -1954,6 +1956,7 @@ or
19541956
<li>Supports index syntax: {#syntax#}array_ptr[i]{#endsyntax#}</li>
19551957
<li>Supports slice syntax: {#syntax#}array_ptr[start..end]{#endsyntax#}</li>
19561958
<li>Supports len property: {#syntax#}array_ptr.len{#endsyntax#}</li>
1959+
<li>Supports pointer subtraction: {#syntax#}array_ptr - array_ptr{#endsyntax#}</li>
19571960
</ul>
19581961
</li>
19591962
</ul>

doc/langref/test_pointer_arithmetic.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ test "pointer arithmetic with many-item pointer" {
1111
// slicing a many-item pointer without an end is equivalent to
1212
// pointer arithmetic: `ptr[start..] == ptr + start`
1313
try expect(ptr[1..] == ptr + 1);
14+
15+
// subtraction between any two pointers except slices based on element size is supported
16+
try expect(&ptr[1] - &ptr[0] == 1);
1417
}
1518

1619
test "pointer arithmetic with slices" {

lib/init/build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
// // build root. In this case the package's hash is irrelevant and therefore not
4646
// // computed. This field and `url` are mutually exclusive.
4747
// .path = "foo",
48-
48+
//
4949
// // When this is set to `true`, a package is declared to be lazily
5050
// // fetched. This makes the dependency only get fetched if it is
5151
// // actually used.

lib/std/Progress.zig

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -669,14 +669,8 @@ fn appendTreeSymbol(symbol: TreeSymbol, buf: []u8, start_i: usize) usize {
669669
fn clearWrittenWithEscapeCodes() anyerror!void {
670670
if (!global_progress.need_clear) return;
671671

672-
var i: usize = 0;
673-
const buf = global_progress.draw_buffer;
674-
675-
buf[i..][0..clear.len].* = clear.*;
676-
i += clear.len;
677-
678672
global_progress.need_clear = false;
679-
try write(buf[0..i]);
673+
try write(clear);
680674
}
681675

682676
/// U+25BA or ►

lib/std/Thread.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ const WindowsThreadImpl = struct {
554554
0,
555555
null,
556556
) orelse {
557-
const errno = windows.kernel32.GetLastError();
557+
const errno = windows.GetLastError();
558558
return windows.unexpectedError(errno);
559559
};
560560

lib/std/Thread/Condition.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const WindowsImpl = struct {
178178

179179
// Return error.Timeout if we know the timeout elapsed correctly.
180180
if (rc == os.windows.FALSE) {
181-
assert(os.windows.kernel32.GetLastError() == .TIMEOUT);
181+
assert(os.windows.GetLastError() == .TIMEOUT);
182182
if (!timeout_overflowed) return error.Timeout;
183183
}
184184
}

lib/std/c.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,9 +1912,10 @@ pub const LC = enum(c_int) {
19121912
TELEPHONE = 10,
19131913
MEASUREMENT = 11,
19141914
IDENTIFICATION = 12,
1915+
_,
19151916
};
19161917

1917-
pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) [*:0]const u8;
1918+
pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8;
19181919

19191920
pub const getcontext = if (builtin.target.isAndroid())
19201921
@compileError("android bionic libc does not implement getcontext")

lib/std/crypto/Certificate/Bundle.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {
132132
cb.map.clearRetainingCapacity();
133133

134134
const w = std.os.windows;
135-
const GetLastError = w.kernel32.GetLastError;
135+
const GetLastError = w.GetLastError;
136136
const root = [4:0]u16{ 'R', 'O', 'O', 'T' };
137137
const store = w.crypt32.CertOpenSystemStoreW(null, &root) orelse switch (GetLastError()) {
138138
.FILE_NOT_FOUND => return error.FileNotFound,

lib/std/debug.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ pub const DebugInfo = struct {
17811781

17821782
const handle = windows.kernel32.CreateToolhelp32Snapshot(windows.TH32CS_SNAPMODULE | windows.TH32CS_SNAPMODULE32, 0);
17831783
if (handle == windows.INVALID_HANDLE_VALUE) {
1784-
switch (windows.kernel32.GetLastError()) {
1784+
switch (windows.GetLastError()) {
17851785
else => |err| return windows.unexpectedError(err),
17861786
}
17871787
}

0 commit comments

Comments
 (0)