3190 Commits

Author SHA1 Message Date
g-w1
a1a1929cf4 Fix #7296:
* makes '$build_root/{install,debug}/' the default prefix. This makes it not '$pwd/zig-cache/'.
2020-12-31 20:02:07 -05:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
LemonBoy
2622575fde std: Remove duplicated code
Make osRequiresLibC call Os.requiresLibC, let's keep a single list of OS
that require the libc to be linked in.
2020-12-30 14:45:39 -08:00
LemonBoy
daed2ba2a0 std: Add more standard type definitions for FreeBSD
Closes #7550
2020-12-30 10:25:43 -08:00
Isaac Freund
3634d44d08 std: fix Reader.readUntilDelimiterOrEofAlloc() API
The current API does not allow the user to distinguish between EOF and
an empty line. Reader.readUntilDelimiterOrEof() gets this API right so
update readUntilDelimiterOrEofAlloc() to match it. Returning an optional
here additionally makes calling this in a loop much cleaner.

Remove readUntilDelimiterOrEofArrayList() as it no longer needed to
implement readUntilDelimiterOrEof() and has the same API issues
described without a clear way to fix them.
2020-12-29 19:09:36 -08:00
Andrew Kelley
8078d8cd3f std.ChildProcess: fix max_output_bytes handling
The previous logic had a false positive of returning an error when in
fact the maximum number of output bytes had not been exceeded.
2020-12-29 14:02:12 -07:00
Andrew Kelley
717cf00fe0 std.ChildProcess: improvements to collectOutputPosix
* read directly into the ArrayList buffers.
 * respect max_output_bytes

 * std.ArrayList:
   - make `allocatedSlice` public.
   - add `unusedCapacitySlice`.

I removed the Windows implementation of this stuff; I am doing a partial
merge of LemonBoy's patch with the understanding that a later patch can
add the Windows implementation after it is vetted.
2020-12-29 11:13:00 -07:00
LemonBoy
892b37cdae std: Use WINAPI instead of .Stdcall 2020-12-29 10:40:28 -07:00
LemonBoy
b297c2eae9 std: Fix compilation on FreeBSD/Darwin 2020-12-29 10:40:26 -07:00
LemonBoy
1667c937a0 std: Uniform polling logic for Windows and Unix
Keep polling until there are enough open handles, if the child process
terminates closing the handles or explicitly closes them we just quit
polling and wait for the process handle to signal the termination
condition.
2020-12-29 10:40:00 -07:00
LemonBoy
2c16a96686 std: Fix poll definitions for FreeBSD/Darwin 2020-12-29 10:40:00 -07:00
LemonBoy
dc810eb73b std: Avoid deadlocking in ChildProcess.exec
Reading stdin&stderr at different times may lead to nasty deadlocks (eg.
when stdout is read before stderr and the child process doesn't write
anything onto stdout).

Implement a polling mechanism to make sure this won't happen: we read
data from stderr/stdout as it becomes ready and then it's copied into an
ArrayList provided by the user, avoiding any kind of blocking read.
2020-12-29 10:40:00 -07:00
Frank Denis
8ab870cf56 std/crypto: increment the correct words for vectorized salsa20
Add a test for this by the way.

Fixes #7579
2020-12-28 21:28:39 -08:00
Andrew Kelley
78dcd1b23e std.process: update arg iterator tests
These tests asserted there were no args passed to the test binary, but
now there is an arg intentionally passed to the test binary, so the test
case needed to be updated.
2020-12-28 21:09:47 -07:00
Andrew Kelley
7ca9f3bc7b zig test: std.testing.zig_exe_path is now available
it will be set to the path of the zig executable which is running
`zig test`.
2020-12-28 20:00:34 -07:00
Isaac Freund
7ed499ec45 std/heap: fix documentation of raw_c_allocator
This is not in fact safe to use with GeneralPurposeAllocator as GPA
requires align(page_size) but raw_c_allocator provides only
@alignOf(std.c.max_align_t).
2020-12-28 16:15:04 +02:00
Veikka Tuominen
8aab1e2e8a
Merge pull request #7483 from indocomsoft/autohashmap
Make hasUniqueRepresentation false for slices
2020-12-28 01:13:23 +02:00
Veikka Tuominen
3fb0288d87
Merge pull request #7563 from ifreund/alloc-sent-cleanup
std: add test for createNullDelimitedEnvMap(), clean up sentinel handling for argv/environ
2020-12-28 01:08:12 +02:00
frmdstryr
dd86e9d78c Update event loop sendto error to SendToError 2020-12-28 01:00:23 +02:00
Isaac Freund
8000262e07
std: clean up sentinel handling for argv/environ 2020-12-27 14:23:59 +01:00
Isaac Freund
4d1096976a
std: add test for createNullDelimitedEnvMap() 2020-12-27 14:23:59 +01:00
Andrew Kelley
4cc4b54d25 std.event.Loop: fix regression with ResetEvent 2020-12-26 19:40:10 -07:00
Andrew Kelley
8fc765387f
Merge pull request #7449 from kristoff-it/macos-termios
add termios bits for darwin
2020-12-26 17:13:17 -08:00
Isaac Freund
988ddd1bed std: add c._exit() and use in ChildProcess
This issue with atexit() functions after forking isn't isolated to linux
I'm sure, the proper way to do this when linking libc is to use _exit(2)
2020-12-26 16:51:55 -08:00
Andrew Kelley
e5894221f7
Merge pull request #7553 from ziglang/fix-the-damn-deadlock
Fix the damn deadlock
2020-12-26 16:33:38 -08:00
Andrew Kelley
3f9588ca29 std: do not call malloc() between fork() and execv()
We were violating the POSIX standard which resulted in a deadlock on
musl v1.1.24 on aarch64 alpine linux, uncovered with the new ThreadPool
usage in the stage2 compiler.

std.os execv functions that accept an Allocator parameter are removed
because they are footguns. The POSIX standard does not allow calls to
malloc() between fork() and execv() and since it is common to both
(1) call execv() after fork() and (2) use std.heap.c_allocator,
Programmers are encouraged to go through the `std.process` API
instead, causing some dissonance when combined with `std.os` APIs.

I also slapped a big warning message on all the relevant doc comments.
2020-12-26 13:50:26 -07:00
Julius Putra Tanu Setiaji
f9506e9155 Handle unions in autoHash 2020-12-26 19:43:15 +08:00
lithdew
d20174ad88 builder: implement sanitize_thread option 2020-12-26 11:56:50 +02:00
Julius Putra Tanu Setiaji
d9133b9ae0 Also check whether structs contain slices 2020-12-26 12:58:52 +08:00
Julius Putra Tanu Setiaji
1df601d581 Make hasUniqueRepresentation false for slices 2020-12-26 11:57:09 +08:00
Sébastien Marie
c99c6c0a68 openbsd: add commonly used libc wrappers for pledge(2) and unveil(2) 2020-12-25 16:43:14 +02:00
Sébastien Marie
bc11528b8b openbsd: define sem_t as optional pointer on opaque {} 2020-12-25 16:20:22 +02:00
Veikka Tuominen
83646df2cc
Merge pull request #7531 from Vexu/orphanage
Move ArrayListSentineled to std lib orphanage
2020-12-24 10:59:37 +02:00
Andrew Kelley
0fd68f49e2
Merge pull request #7519 from ziglang/more-pthreads-integration
More pthreads integration
2020-12-24 00:15:33 -08:00
Andrew Kelley
87e4f7376a Revert "std.valgrind: add helgrind functions"
This reverts commit f2ab9512af0154a291ce11ab0a1298fbf778d751.

I did it wrong and didn't end up using these.
2020-12-24 01:14:41 -07:00
Andrew Kelley
c2b1c88953 std: fix compile errors introduced in previous commit 2020-12-23 20:49:38 -07:00
Andrew Kelley
177377b6e3 rework std.ResetEvent, improve std lib Darwin integration
* split std.ResetEvent into:
   - ResetEvent - requires init() at runtime and it can fail. Also
     requires deinit().
   - StaticResetEvent - can be statically initialized and requires no
     deinitialization. Initialization cannot fail.
 * the POSIX sem_t implementation can in fact fail on initialization
   because it is allowed to be implemented as a file descriptor.
 * Completely define, clarify, and explain in detail the semantics of
   these APIs. Remove the `isSet` function.
 * `ResetEvent.timedWait` returns an enum instead of a possible error.
 * `ResetEvent.init` takes a pointer to the ResetEvent instead of
   returning a copy.
 * On Darwin, `ResetEvent` is implemented using Grand Central Dispatch,
   which is exposed by libSystem.

stage2 changes:
 * ThreadPool: use a single, pre-initialized `ResetEvent` per worker.
 * WaitGroup: now requires init() and deinit() and init() can fail.
   - Add a `reset` function.
   - Compilation initializes one for the work queue in creation and
     re-uses it for every update.
   - Rename `stop` to `finish`.
   - Simplify the implementation based on the usage pattern.
2020-12-23 16:57:18 -08:00
frmdstryr
577b57784a Return encoded slice from base64 encode 2020-12-24 01:27:21 +02:00
Veikka Tuominen
7154882423
Merge pull request #7447 from LemonBoy/fix-7445
std: non-byte-multiple sized integers have no definite representation
2020-12-24 00:25:52 +02:00
Veikka Tuominen
e79acc24d3
std: clenup, fixes, fmt 2020-12-24 00:23:29 +02:00
Andrew Kelley
f4d82f0ad6 std.Progress: work around time going backwards 2020-12-23 13:36:21 -08:00
Andrew Kelley
485ec0884f restore std.ResetEvent.isSet functionality 2020-12-23 13:36:21 -08:00
Andrew Kelley
a368c0d099 std: add Darwin and FreeBSD sem_t bits 2020-12-23 13:36:21 -08:00
Andrew Kelley
b2e1bce240 minor code readability changes 2020-12-23 13:36:21 -08:00
Andrew Kelley
f2ab9512af std.valgrind: add helgrind functions 2020-12-23 13:36:21 -08:00
Andrew Kelley
19459840fe std.ResetEvent: pthreads sem_t cannot be statically initialized
because it is allowed for the implementation to use a file descriptor,
which would require making a syscall at runtime.
2020-12-23 13:36:21 -08:00
Andrew Kelley
028af97df4 std.ResetEvent: use sem_t when linking against pthreads 2020-12-23 13:36:21 -08:00
Andrew Kelley
4eb4d26fa1 std.Mutex: integrate with pthreads
When using pthreads for threading, std.Mutex uses pthread_mutex_t as the
implementation. This integrates better with tooling.
2020-12-23 13:36:21 -08:00
Sébastien Marie
6e2622661c openbsd: implement segfault handling on openbsd x86_64 2020-12-23 20:47:06 +02:00
Loris Cro
9bb0da6100 added comments, removed useless comptime keywords 2020-12-23 17:28:59 +01:00