head 1.2; access; symbols pkgsrc-2020Q1:1.1.0.2 pkgsrc-2020Q1-base:1.1; locks; strict; comment @# @; 1.2 date 2020.04.18.08.08.07; author adam; state dead; branches; next 1.1; commitid 9DQvWpsXcrpLdQ4C; 1.1 date 2020.03.25.22.27.20; author nia; state Exp; branches; next ; commitid Uuaz9IKjBYLGJP1C; desc @@ 1.2 log @zig: updated to 0.6.0 Language Changes in 0.6.0: Improved names of error sets when using merge error sets operator (||). pub syntax for container fields is removed. Type coercion from *[0]T to E![]const T is now allowed. This is an unambiguous, safe cast. asm now accepts comptime-known values, rather than requiring string literal syntax. Removed compile error for peer result ?comptime_int and null. Ability to pass comptime types and non comptime types to same parameter. @@typeOf is renamed to @@TypeOf. zig fmt automatically performs the conversion, and the next release of Zig after this one will remove the automatic conversion. Ability to switch on pointer types. Multiline strings in test and library names are disallowed. Zig language no longer requires the expression a else unreachable with comptime a to produce a comptime result. Timon Kruiper implemented casting between [*c]T and ?[*:0]T on fn parameter. Timon Kruiper improved @@typeInfo to lazily resolve declarations. This way all the declarations in a namespace won't be resolved until the user actually uses the declarations slice in the builtin TypeInfo union. @@ptrCast supports casting a slice to a pointer. LemonBoy implemented peer type resolution between ?[]T and *[N]T. There is now peer type resolution between mixed-const []T and *[N]T. @ text @$NetBSD: patch-lib_std_thread.zig,v 1.1 2020/03/25 22:27:20 nia Exp $ NetBSD fixes. Based on: https://github.com/ziglang/zig/pull/4793 --- lib/std/thread.zig.orig 2019-09-30 15:40:00.000000000 +0000 +++ lib/std/thread.zig @@@@ -255,12 +255,13 @@@@ pub const Thread = struct { } break :blk l; }; - // Map the whole stack with no rw permissions to avoid committing the - // whole region right away + // NetBSD mprotect is very strict and doesn't allow to "upgrade" + // a PROT_NONE mapping to a RW one so let's allocate everything + // right away const mmap_slice = os.mmap( null, - mem.alignForward(mmap_len, mem.page_size), - os.PROT_NONE, + mmap_len, + os.PROT_READ | os.PROT_WRITE, os.MAP_PRIVATE | os.MAP_ANONYMOUS, -1, 0, @@@@ -272,10 +273,10 @@@@ pub const Thread = struct { }; errdefer os.munmap(mmap_slice); - // Map everything but the guard page as rw + // Remap the guard page with no permissions os.mprotect( - mmap_slice, - os.PROT_READ | os.PROT_WRITE, + mmap_slice[0..guard_end_offset], + os.PROT_NONE, ) catch |err| switch (err) { error.AccessDenied => unreachable, else => |e| return e, @@@@ -301,6 +302,12 @@@@ pub const Thread = struct { assert(c.pthread_attr_setstack(&attr, mmap_slice.ptr, stack_end_offset) == 0); + // Even though pthread's man pages state that the guard size is + // ignored when the stack address is explicitly given, on some + // plaforms such as NetBSD we still have to zero it to prevent + // random crashes in pthread_join calls + assert(c.pthread_attr_setguardsize(&attr, 0) == 0); + const err = c.pthread_create(&thread_ptr.data.handle, &attr, MainFuncs.posixThreadMain, @@intToPtr(*c_void, arg)); switch (err) { 0 => return thread_ptr, @ 1.1 log @zig: Update to 0.5.0. Unbreak. This version of zig supports the current version of llvm in pkgsrc (9). Some patches from TheLemonMan were backported by me to fix NetBSD support. Release notes: https://ziglang.org/download/0.5.0/release-notes.html @ text @d1 1 a1 1 $NetBSD$ @