Commit Graph

3705 Commits

Author SHA1 Message Date
Andrew Kelley
16a2562c3f zig fmt: implement container decls 2021-02-05 15:47:18 -07:00
Andrew Kelley
cf42ae178d std.MultiArrayList: use @memset builtin for undefined
See comment for more details
2021-02-05 15:45:33 -07:00
Isaac Freund
0f3fa4d654 zig fmt: array types 2021-02-05 11:36:19 -08:00
Isaac Freund
6f3b93e2e8 zig fmt: struct and anon array initialization 2021-02-05 10:51:45 -08:00
Isaac Freund
3e960cfffe zig fmt: float literal with exponent 2021-02-05 10:51:45 -08:00
Isaac Freund
0b4bb9b84f std.MultiArrayList: implement review comments 2021-02-05 10:51:45 -08:00
Luuk de Gram
36df6a008f
Ensure function indices are correct and fix a memory leak 2021-02-05 18:06:25 +01:00
Luuk de Gram
aa3e0ff454
Create type declarations for extern functions and write the 'import' section 2021-02-05 18:06:20 +01:00
Andrew Kelley
7069459a76 zig fmt: implement struct init 2021-02-04 19:59:06 -07:00
Andrew Kelley
8e46d06650 zig fmt: implement fn protos and defers 2021-02-04 16:38:29 -07:00
Michael Dusan
300ebbd560 target: map zig ppc32 → llvm ppc
- llvm does not accept `ppc32` as a CPU type

closes #7947
2021-02-04 14:22:38 -08:00
Asherah Connor
4428acf0f7 zig fmt: deref, unwrap optional 2021-02-04 10:49:45 -08:00
Koakuma
448a28325c Fix previous %fp calculation 2021-02-05 00:28:07 +07:00
Koakuma
1eb2e48014 std.debug.StackIterator: account for SPARC %fp quirk
On SPARC, previous %fp is saved with a 14 slots offset from current %fp+bias.
Also account for the bias constant at the new_fp calculation.
2021-02-04 20:51:41 +07:00
Andrew Kelley
725adf8332 zig fmt: builtin calls and array access 2021-02-03 22:12:11 -07:00
Andrew Kelley
f5279cbada zig fmt: implement top-level fields 2021-02-03 17:02:12 -07:00
Rocknest
2d447b57cc fix typo in comment 2021-02-02 20:07:08 -08:00
Andrew Kelley
1a83b29bea zig fmt: implement if, call, field access, assignment 2021-02-02 21:05:53 -07:00
Frank Denis
7a01d396ee siphash: update the link to the SipHash paper 2021-02-02 11:17:14 +02:00
Andrew Kelley
0c6b98b825 zig fmt: implement simple test with doc comments 2021-02-01 21:31:41 -07:00
Andrew Kelley
272a0ab359 zig fmt: implement "line comment followed by top-level comptime" 2021-02-01 20:11:55 -07:00
Andrew Kelley
20554d32c0 zig fmt: start reworking with new memory layout
* start implementation of ast.Tree.firstToken and lastToken
 * clarify some ast.Node doc comments
 * reimplement renderToken
2021-02-01 17:23:49 -07:00
Andrew Kelley
102d954220
Merge pull request #7827 from Snektron/spirv-setup
Stage 2: SPIR-V setup
2021-02-01 12:49:51 -08:00
Jonathan Marler
06b29c8546 std.json large number support 2021-02-01 12:40:49 -08:00
Martin Wickham
1032a69321 Dupe strings on all public api points for std.build 2021-02-01 12:31:24 -08:00
Luuk de Gram
c0685458a2 Define wasm constants
Update link.Wasm.zig to use std.wasm for its constants

Make opcodes u8 and non-exhaustive

Update test and rename 'spec' to 'wasm'
2021-02-01 12:28:25 -08:00
Cameron Conn
683d3f7242
Don't read more bytes than exist in MsfStream (#7839) 2021-02-01 15:27:39 -05:00
Vincent Rischmann
16905d96f7
Fixes for std.Thread.Condition (#7883)
* thread/condition: fix PthreadCondition compilation

* thread/condition: add wait, signal and broadcast

This is like std.Thread.Mutex which forwards calls to `impl`; avoids
having to call `cond.impl` every time.

* thread/condition: initialize the implementation
2021-02-01 15:16:39 -05:00
Andrew Kelley
66c0fe4f90
Merge pull request #7922 from daurnimator/comptime-json-fields
std.json support for comptime fields
2021-02-01 12:11:36 -08:00
Frank Denis
a03f9548d3 std/math/big/int: normalize after a right shift
After a right shift, top limbs may be all zero. However, without
normalization, the number of limbs is not going to change.

In order to check if a big number is zero, we used to assume that the
number of limbs is 1. Which may not be the case after right shifts,
even if the actual value is zero.

- Normalize after a right shift
- Add a test for that issue
- Check all the limbs in `eqlZero()`. It may not be necessary if
callers always remember to normalize before calling the function.
But checking all the limbs is very cheap and makes the function less
bug-prone.
2021-02-01 12:10:01 -08:00
Andrew Kelley
bf8fafc37d stage2: tokenizer does not emit line comments anymore
only std.zig.render cares about these, and it can find them in the
original source easily enough.
2021-01-31 21:57:48 -07:00
daurnimator
e0a04e7f67
allow more complex comptime fields in std.json 2021-02-01 01:01:50 +11:00
daurnimator
f88bb56ee5
std.json union handling should bubble up AllocationRequired 2021-02-01 01:00:15 +11:00
daurnimator
33c0a01b08
std.json support for comptime fields
Closes #6231
2021-01-31 23:41:32 +11:00
Veikka Tuominen
fdc875ed00
Merge pull request #7750 from tadeokondrak/6609-tagtype-tag
Remove @TagType; std.meta.TagType -> std.meta.Tag
2021-01-31 12:37:12 +02:00
Andrew Kelley
4dca99d3f6 stage2: rework AST memory layout
This is a proof-of-concept of switching to a new memory layout for
tokens and AST nodes. The goal is threefold:

 * smaller memory footprint
 * faster performance for tokenization and parsing
 * most importantly, a proof-of-concept that can be also applied to ZIR
   and TZIR to improve the entire compiler pipeline in this way.

I had a few key insights here:

 * Underlying premise: using less memory will make things faster, because
   of fewer allocations and better cache utilization. Also using less
   memory is valuable in and of itself.
 * Using a Struct-Of-Arrays for tokens and AST nodes, saves the bytes of
   padding between the enum tag (which kind of token is it; which kind
   of AST node is it) and the next fields in the struct. It also improves
   cache coherence, since one can peek ahead in the tokens array without
   having to load the source locations of tokens.
 * Token memory can be conserved by only having the tag (1 byte) and byte
   offset (4 bytes) for a total of 5 bytes per token. It is not necessary
   to store the token ending byte offset because one can always re-tokenize
   later, but also most tokens the length can be trivially determined from
   the tag alone, and for ones where it doesn't, string literals for
   example, one must parse the string literal again later anyway in
   astgen, making it free to re-tokenize.
 * AST nodes do not actually need to store more than 1 token index because
   one can poke left and right in the tokens array very cheaply.

So far we are left with one big problem though: how can we put AST nodes
into an array, since different AST nodes are different sizes?

This is where my key observation comes in: one can have a hash table for
the extra data for the less common AST nodes! But it gets even better than
that:

I defined this data that is always present for every AST Node:

 * tag (1 byte)
   - which AST node is it
 * main_token (4 bytes, index into tokens array)
   - the tag determines which token this points to
 * struct{lhs: u32, rhs: u32}
   - enough to store 2 indexes to other AST nodes, the tag determines
     how to interpret this data

You can see how a binary operation, such as `a * b` would fit into this
structure perfectly. A unary operation, such as `*a` would also fit,
and leave `rhs` unused. So this is a total of 13 bytes per AST node.
And again, we don't have to pay for the padding to round up to 16 because
we store in struct-of-arrays format.

I made a further observation: the only kind of data AST nodes need to
store other than the main_token is indexes to sub-expressions. That's it.
The only purpose of an AST is to bring a tree structure to a list of tokens.
This observation means all the data that nodes store are only sets of u32
indexes to other nodes. The other tokens can be found later by the compiler,
by poking around in the tokens array, which again is super fast because it
is struct-of-arrays, so you often only need to look at the token tags array,
which is an array of bytes, very cache friendly.

So for nearly every kind of AST node, you can store it in 13 bytes. For the
rarer AST nodes that have 3 or more indexes to other nodes to store, either
the lhs or the rhs will be repurposed to be an index into an extra_data array
which contains the extra AST node indexes. In other words, no hash table needed,
it's just 1 big ArrayList with the extra data for AST Nodes.

Final observation, no need to have a canonical tag for a given AST. For example:
The expression `foo(bar)` is a function call. Function calls can have any
number of parameters. However in this example, we can encode the function
call into the AST with a tag called `FunctionCallOnlyOneParam`, and use lhs
for the function expr and rhs for the only parameter expr. Meanwhile if the
code was `foo(bar, baz)` then the AST node would have to be `FunctionCall`
with lhs still being the function expr, but rhs being the index into
`extra_data`. Then because the tag is `FunctionCall` it means
`extra_data[rhs]` is the "start" and `extra_data[rhs+1]` is the "end".
Now the range `extra_data[start..end]` describes the list of parameters
to the function.

Point being, you only have to pay for the extra bytes if the AST actually
requires it. There's no limit to the number of different AST tag encodings.

Preliminary results:

 * 15% improvement on cache-misses
 * 28% improvement on total instructions executed
 * 26% improvement on total CPU cycles
 * 22% improvement on wall clock time

This is 1/4 items on the checklist before this can actually be merged:

 * [x] parser
 * [ ] render (zig fmt)
 * [ ] astgen
 * [ ] translate-c
2021-01-30 20:16:59 -07:00
Andrew Kelley
766b315b38 std.GeneralPurposeAllocator: logging improvements
It now uses the log scope "gpa" instead of "std".

Additionally, there is a new config option `verbose_log` which enables
info log messages for every allocation. Can be useful when debugging.
This option is off by default.
2021-01-30 20:15:26 -07:00
Andrew Kelley
0808d98e10 add std.MultiArrayList
Also known as "Struct-Of-Arrays" or "SOA". The purpose of this data
structure is to provide a similar API to ArrayList but instead of
the element type being a struct, the fields of the struct are in N
different arrays, all with the same length and capacity.

Having this abstraction means we can put them in the same allocation,
avoiding overhead with the allocator. It also saves a tiny bit of
overhead from the redundant capacity and length fields, since each
struct element shares the same value.

This is an alternate implementation to #7854.
2021-01-30 20:12:13 -07:00
Tadeo Kondrak
0b5f3c2ef9
Replace @TagType uses, mostly with std.meta.Tag 2021-01-30 22:26:44 +02:00
rgreenblatt
78d2f2b819 FromWriteFileStep for all LibExeObjStep types 2021-01-30 17:50:41 +02:00
Tadeo Kondrak
b7767eb834
std.meta: rename TagPayloadType to TagPayload 2021-01-30 13:19:52 +02:00
Tadeo Kondrak
68ec54f386
std.meta: rename TagType to Tag 2021-01-30 13:19:52 +02:00
Dmitry Atamanov
290efc0747
Improve error messages in std.fmt (#7898) 2021-01-30 13:12:44 +02:00
Martin Wickham
3d4eeafb47 Fill out more cases for std.meta.sizeof 2021-01-30 11:13:20 +02:00
Asherah Connor
e8740a90b9 complete {Z} deprecation in std.fmt.formatIntValue
formatZigEscapes doesn't exist any more.
2021-01-29 20:46:39 +02:00
root
236db6232f Fix interger overflow when calling joinZ with empty slices 2021-01-27 12:01:18 +02:00
Jakub Konka
79730e6f5c macho: add arm64 relocation type enum 2021-01-26 08:11:31 +01:00
Joran Dirk Greef
881ecdc72f Add MAX_RW_COUNT limit to std.os.pread()
Fixes: https://github.com/ziglang/zig/issues/7805
2021-01-25 10:41:38 -08:00
Timon Kruiper
e23bc1f76a render: fix bug when rendering struct initializer with length 1
This crashed the compiler when running translate-c. See the added test.
2021-01-25 10:40:00 -08:00
Andrew Kelley
4ca1f4ec2e
Merge pull request #7846 from LemonBoy/filtertest
stage1: don't filter test blocks with empty label
2021-01-25 10:39:11 -08:00
Joran Dirk Greef
68a040aec7 linux: add fallocate() to io_uring 2021-01-25 10:34:20 -08:00
Timon Kruiper
9238d12537 windows: make sure to handle PATH_NOT_FOUND when deleting files
Fixes #7879
2021-01-25 10:33:08 -08:00
Andrew Kelley
2b321c25ce std.Progress: call refreshWithHeldLock as appropriate 2021-01-24 12:22:17 -07:00
Timon Kruiper
4f7d76f19c fix windows bug in Progress.zig
This bug caused the compiler to deadlock when multiple c objects
were build in parallel.

Thanks @kprotty for finding this bug!
2021-01-24 12:20:51 -07:00
LemonBoy
134f5fd3d6 std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
LemonBoy
ac004e1bf1 stage1: Allow nameless test blocks
Nameless blocks are never filtered, the test prefix is still applied.
2021-01-22 15:46:58 +01:00
Jakub Konka
843d91e75d Bring back stack trace printing on ARM Darwin
This temporary patch fixes a segfault caused by miscompilation
by the LLD when generating stubs for initialization of thread local
storage. We effectively bypass TLS in the default panic handler
so that no segfault is generated and the stack trace is correctly
reported back to the user.

Note that, this is linked directly to a bigger issue with LLD
ziglang/zig#7527 and when resolved, we only need to remove the
`comptime` code path introduced with this patch to use the default
panic handler that relies on TLS.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2021-01-21 23:20:42 +01:00
Andrew Kelley
d5d0619aac stage2: ELF: avoid multiplication for ideal capacity
ideal capacity is now determined by e.g.
x += x / f
rather than
x = x * b / a

This turns a multiplication into an addition, making it less likely to
overflow the integer. This commit also introduces padToIdeal() which
does saturating arithmetic so that no overflow is possible when
calculating ideal capacity.

closes #7830
2021-01-19 13:47:51 -07:00
Robin Voetter
02c138fe70 SPIR-V: Add glsl450 and vulkan spir-v operating system definitions 2021-01-19 15:28:17 +01:00
Robin Voetter
ab607d455e SPIR-V: Initial architecture definitions and setup 2021-01-19 15:28:17 +01:00
Andrew Kelley
0353c9601a
Merge pull request #7814 from LemonBoy/fix-7760
std: Fixed pipe2 fallback
2021-01-18 11:49:42 -08:00
Julian Maingot
384ccaa27a stage2: use %type not @type for libc stubs
Missed a couple places last time so just doing the rest.
2021-01-18 11:04:33 -08:00
Julian Maingot
4c5f69a065 update error return doc
Docs were out of sync with code
2021-01-18 11:04:33 -08:00
LemonBoy
6418f9ae91 std: Add missing cast when calling fcntl w/ constant args
comptime_int arguments are a big no no.
2021-01-18 18:02:09 +01:00
LemonBoy
f33bac2b12 std: define pipe2 only for os that support it 2021-01-18 17:24:26 +01:00
LemonBoy
9d18df142c std: Fixed pipe2 fallback
Use both F_SETFD and F_SETFL depending on what flag we're setting.

Closes #7760
2021-01-18 14:52:35 +01:00
Andrew Kelley
8436134499 std.ArrayHashMap: add "AssertDiscard" function variants
* Add `swapRemoveAssertDiscard`
 * Add `orderedRemoveAssertDiscard`
 * Deprecate `removeAssertDiscard`
2021-01-16 22:49:20 -07:00
Andrew Kelley
1f65828ec6
Merge pull request #7716 from koachan/sparc64-libs
stage1: SPARCv9 f128 enablement
2021-01-16 12:10:03 -08:00
Guillaume Ballet
f7d7cb6268 crypto: add legacy keccak hash functions 2021-01-15 12:36:38 -08:00
Koakuma
1d67ab8823 Fix _Qp_cmp definition 2021-01-15 19:07:39 +07:00
Koakuma
bbb58b10f6 Add compiler-rt stub for SPARC CPUs 2021-01-15 19:07:38 +07:00
Andrew Kelley
19f893c6bb std.Thread: avoid compile errors for single-threaded OS's 2021-01-14 22:42:29 -07:00
Andrew Kelley
ad301d687a fix namespace of kernel32 function calls 2021-01-14 21:42:49 -07:00
Andrew Kelley
9e1aeda3bf std.Thread.StaticResetEvent: call spinLoopHint appropriately 2021-01-14 21:34:30 -07:00
Andrew Kelley
9698ea3173 std.Thread.Mutex: restore the "Held" API
so that std.Thread.Mutex.Dummy can be used as a drop in replacement.
2021-01-14 21:28:22 -07:00
Andrew Kelley
a9667b5a85 organize std lib concurrency primitives and add RwLock
* move concurrency primitives that always operate on kernel threads to
   the std.Thread namespace
 * remove std.SpinLock. Nobody should use this in a non-freestanding
   environment; the other primitives are always preferable. In
   freestanding, it will be necessary to put custom spin logic in there,
   so there are no use cases for a std lib version.
 * move some std lib files to the top level fields convention
 * add std.Thread.spinLoopHint
 * add std.Thread.Condition
 * add std.Thread.Semaphore
 * new implementation of std.Thread.Mutex for Windows and non-pthreads Linux
 * add std.Thread.RwLock

Implementations provided by @kprotty
2021-01-14 20:41:37 -07:00
Asherah Connor
affb57aad9 use interfaces 2021-01-15 10:34:53 +11:00
Asherah Connor
9168b217b2 fix SectionHeaderIterator impl 2021-01-14 17:52:06 +11:00
Asherah Connor
32d69d70cf expose phdr, shdr parsing 2021-01-14 15:30:28 +11:00
Asherah Connor
49ab6bb429 std.elf: actually pass the pointer 2021-01-14 14:38:52 +11:00
Asherah Connor
1cea88917c std.elf: call it Header.parse 2021-01-14 14:38:52 +11:00
Asherah Connor
e6cdf9cebf std.elf: make Header pub 2021-01-14 14:38:52 +11:00
Asherah Connor
23fb19fe41 std.elf: expose parsing decoupled from std.fs.File 2021-01-14 14:38:52 +11:00
Asherah Connor
2b0e3ee228
std.os.uefi.protocols.FileProtocol: fix and expose get_position, set_position (#7762) 2021-01-13 21:46:22 -05:00
Jay Petacat
a021c7b1b2 Move fmt.testFmt to testing.expectFmt 2021-01-12 18:13:29 -08:00
Bill Nagel
2c79d669a7 add missing ECONNRESET from getsockoptError 2021-01-12 18:11:58 -08:00
Andrew Kelley
70c608add8
Merge pull request #7577 from semarie/emutls
implement emutls inside compiler_rt.zig
2021-01-12 17:54:02 -08:00
Andrew Kelley
e564d2ca3c
Merge pull request #7714 from mikdusan/target-macos
macos: reimplement OS version detection
2021-01-12 16:45:50 -08:00
Bill Nagel
1e2be14b6b define nfds_t for windows 2021-01-12 16:37:58 -08:00
Sébastien Marie
d7aa7dbab2 implement emutls in compiler_rt 2021-01-12 05:39:46 +00:00
Sébastien Marie
ebf2a7e9b9 add pthread_key functions 2021-01-12 05:39:46 +00:00
Andrew Kelley
8ea2b40e5f std.event.Loop: fix race condition when starting the time wheel
closes #7572
2021-01-11 22:23:03 -07:00
Andrew Kelley
5b2a79848c stage2: cleanups regarding red zone CLI flags
* CLI: change to -mred-zone and -mno-red-zone to match gcc/clang.
 * build.zig: remove the double negative and make it an optional bool.
   This follows precedent from other flags, allowing the compiler CLI to
   be the decider of what is default instead of duplicating the default
   value into the build system code.
 * Compilation: make it an optional `want_red_zone` instead of a
   `no_red_zone` bool. The default is decided by a call to
   `target_util.hasRedZone`.
 * When creating a Clang command line, put -mred-zone on the command
   line if we are forcing it to be enabled.
 * Update update_clang_options.zig with respect to the recent {s}/{} format changes.
 * `zig cc` integration with red zone preference.
2021-01-11 22:07:21 -07:00
Lee Cannon
8932c2d745 Added support for no red zone 2021-01-11 22:07:14 -07:00
Michael Dusan
4c3de99253
more fixups
- clarify comments
- `NativeTargetInfo.detect()` propagate macOS errors
- `macos.detect()` drop `std.log` usage
2021-01-11 20:58:31 -05:00
Michael Dusan
f2be1fb23e
macos: reimplement OS version detection
The macOS version is now obtained by parsing `SystemVersion.plist`.

Test cases added for plist files that date back to '2005 Panther and up
to the recent '2020 Big Sur 11.1 release of macOS.

Thus we are now able to reliably identify 10.3...11.1 and higher.

- drop use of kern.osproductversion sysctl
- drop use of kern.osversion sysctl (fallback)
- drop kern.osversion tests
- add `lib.std.zig.system.detect()`
- add minimalistic parser for `SystemVersion.plist`
- add test cases for { 10.3, 10.3.9, 10.15.6, 11.0, 11.1 }

closes #7569
2021-01-11 19:54:56 -05:00
Rohlem
c96272f618 std.os.windows.GetFinalPathNameByHandle: remove intermediate buffers
... and mem.copy operations. Requires slightly larger input buffers than result length. Add helper functions std.mem.alignInBytes and std.mem.alignInSlice.
2021-01-11 17:48:19 -07:00
Rohlem
f301a8467c std.os.windows.GetFinalPathNameByHandle: remove QueryInformationFile code path 2021-01-11 17:48:18 -07:00
Rohlem
cb20503990 std.os.windows.GetFinalPathNameByHandle: address non-structural review comments 2021-01-11 17:48:18 -07:00
Rohlem
64c5f4979e std.os.windows.GetFinalPathNameByHandle: replace kernel32 by ntdll call
Removes the call to kernel32.GetFinalPathNameByHandleW in favor of NtQueryObject, which means we can reuse the other codepath's logic for DOS naming.
2021-01-11 17:48:18 -07:00
Rohlem
964bbcd0b1 introduce std.os.windows.QueryObjectName 2021-01-11 17:48:18 -07:00
Rohlem
09dc651476 std.os.windows.GetFinalPathNameByHandle: add test 2021-01-11 17:48:18 -07:00
Rohlem
450e467201 std.os.windows.GetFinalPathNameByHandle: reintroduce kernel32 for compatibility
The NtQueryInformationFile with .FileNormalizedNameInformation is only available in Windows 10 1803 (rs4) and later, however there is probably still another route we can go via ntdll.
2021-01-11 17:48:18 -07:00
Rohlem
4b280ac7e9 add std.zig.system.windows version check utility functions 2021-01-11 17:48:17 -07:00
Rohlem
2922a48309 move windows runtime version detection into std.zig.system.windows 2021-01-11 17:48:16 -07:00
Jonathan Knezek
fc10c9c4ce
Add std.fmt.formatDuration and std.fmt.duration (#7297)
`formatDuration` works on a writer, and `duration` wraps a u64 to allow pleasant injection into format strings.
2021-01-11 19:15:56 -05:00
Andrew Kelley
4f5fa90d6d
Merge pull request #7195 from Aransentin/master
A win32-api proposal, implemented for user32.zig
2021-01-11 16:02:40 -08:00
Andrew Kelley
d68adc5382 std.EarlyEOFReader: rename to LimitedReader 2021-01-11 16:51:56 -07:00
daurnimator
01d1a8a783 std: use fifo.pump in writeFileAllUnseekable 2021-01-11 16:48:56 -07:00
daurnimator
e873668d38 std: add LimitedReader: reader that returns EOF early 2021-01-11 16:48:30 -07:00
daurnimator
8695b9fbe7 std: use reader.skipBytes to avoid infinite loop in writeFileAllUnseekable
skipBytes correctly handles EOF for us
2021-01-11 16:47:48 -07:00
daurnimator
0ab8ae944c std: reader.skipBytes's num_bytes should be a u64 2021-01-11 16:47:48 -07:00
Vincent Rischmann
3468872d83 os/bits/linux: add the termios cc bits 2021-01-11 15:39:36 -08:00
Andrew Kelley
ec9158305d
Merge pull request #7124 from LemonBoy/netstuff1
std: Decouple network streams from fs.File
2021-01-11 15:35:00 -08:00
Andrew Kelley
0c8e2c987d std CityHash: disable memory-expensive tests for now 2021-01-11 13:58:06 -07:00
Martin Wickham
21213127ec Modify cityhash to work at comptime 2021-01-11 13:52:52 -07:00
Andrew Kelley
73b17474d7
Merge pull request #7134 from alexnask/fix_std_fs_watch
The std.fs.Watch rewrite PR
2021-01-11 12:45:36 -08:00
LemonBoy
34720da3d0 Apparently unix sockets are supported on Windows
Starting from Windows 10 build 17063.
2021-01-11 21:43:15 +01:00
LemonBoy
d0beb4badb Let the kernel pick a random port
Avoid errors if the socket enters the TIME_WAIT state and we need to
re-execute this test before the OS releases it.

This problem was not really a problem before since the accept()-ed
socket was never closed on the server-side.
2021-01-11 21:43:14 +01:00
LemonBoy
676d7fc63c std: Add a small test for i/o on unix sockets 2021-01-11 21:43:13 +01:00
LemonBoy
89d6317b93 std: Decouple network streams from fs.File
The overlap between files and sockets is minimal and lumping them
together means supporting only a small subset of the functionalities
provided by the OS.
Moreover the socket and file handles are not always interchangeable: on
Windows one should use Winsock's close() call rather than the one used
for common files.
2021-01-11 21:43:09 +01:00
Travis
cc2981edfc update path.join to recognize any separators that isSep does 2021-01-11 11:15:34 -08:00
Andrew Kelley
169810b20f zig fmt 2021-01-10 19:04:10 -07:00
Adam Goertz
0f32de77c9 impl lossyCast #5080 2021-01-10 19:02:41 -07:00
Vincent Rischmann
2117489e05 debug: don't fail printLineInfo if the source file is not readable
Without this dumping a stacktrace fails with this:

    Unable to dump stack trace: AccessDenied
2021-01-10 17:46:15 -08:00
Andrew Kelley
29928af600
Merge pull request #7729 from jayschwa/remove-deprecated-stream
Remove deprecated stream aliases
2021-01-09 13:04:08 -08:00
Jay Petacat
a0ad2dee6a builtin: Add zig_version
This will enable code to perform version checks and make it easier to
support multiple versions of Zig.

Within the SemVer implementation, an intermediate value needed to be
coerced to a slice to workaround a comptime bug.

Closes #6466
2021-01-09 12:50:39 -08:00
xackus
e4b8148e9c Fix system library path detection on linux
Uses the NativeTargetInfo results instead of std.Target.current.
2021-01-08 20:07:59 -07:00
Sobeston
95e66a915b added mem.containsAtLeast 2021-01-08 18:12:30 -08:00
Jakub Konka
7e0e27e738 libstd: add missing MachO rebase opcodes in macho.zig 2021-01-08 23:41:51 +01:00
Jay Petacat
e72472d953 io: FindByteOutStream to FindByteWriter
See #4917
2021-01-08 16:54:56 -05:00
Jay Petacat
1595ce273e Remove deprecated stream aliases 2021-01-08 16:54:56 -05:00
Julius Putra Tanu Setiaji
2b3b355a23 Add compileError message for StringHashMap in AutoHashMap 2021-01-07 23:51:53 -08:00
Andrew Kelley
3fdffe85c0
Merge pull request #7720 from Snektron/sockopt
Some sockopt stuff
2021-01-07 23:50:34 -08:00
Jonathan Marler
31802c6c68 remove z/Z format specifiers
Zig's format system is flexible enough to add custom formatters.  This PR removes the new z/Z format specifiers that were added for printing Zig identifiers and replaces them with custom formatters.
2021-01-07 23:49:22 -08:00
Jay Petacat
a9b505fa77 Reduce use of deprecated IO types
Related: #4917
2021-01-07 23:48:58 -08:00
Michael Dusan
8e9a1ac364 builder: propagate env_map for child processes 2021-01-07 23:48:24 -08:00
Robin Voetter
ec7adeda2b Add EPERM to std.os.setsockopt 2021-01-08 02:34:42 +01:00
Robin Voetter
83fad7d4f7 Add IP_ constants 2021-01-08 01:35:52 +01:00
Jonathan Marler
f1ef0a80f1 fix LRESULT and LPARAM typedefs
LRESULT and LPARAM are currently typedef'd as ?*c_void, however, they are supposed to be typedef'd as LONG_PTR which is equivalent to isize in Zig.
2021-01-06 16:41:40 -08:00
Andrew Kelley
2f58efcc1f std.SpinLock: flatten and remove init/deinit
structs which are intended to be directly initialized and support static
initialization should not have init/deinit methods.
2021-01-06 17:36:06 -07:00
Andrew Kelley
d7d905696c
Merge pull request #7622 from tetsuo-cpp/array-hash-map-improvements
std: Support equivalent ArrayList operations in ArrayHashMap
2021-01-06 16:32:23 -08:00
BinaryWarlock
148c887ace spinlock: Default SpinLock.state to .Unlocked to allow default struct initialization
std.Mutex, which is struct initialized, is possibly defined to be std.SpinLock.
2021-01-06 15:54:30 -08:00
Andreas Karlsson
50af87a9e3 Fix example code in comments for asc and desc 2021-01-06 15:53:53 -08:00
Andrew Kelley
e1811f72eb stage2: link.C: use pwritev 2021-01-05 17:41:14 -07:00
Andrew Kelley
7b8cede61f stage2: rework the C backend
* std.ArrayList gains `moveToUnmanaged` and dead code
   `ArrayListUnmanaged.appendWrite` is deleted.
 * emit_h state is attached to Module rather than Compilation.
 * remove the implementation of emit-h because it did not properly
   integrate with incremental compilation. I will re-implement it
   in a follow-up commit.
 * Compilation: use the .codegen_failure tag rather than
   .dependency_failure tag for when `bin_file.updateDecl` fails.

C backend:
 * Use a CValue tagged union instead of strings for C values.
 * Cleanly separate state into Object and DeclGen:
   - Object is present only when generating a .c file
   - DeclGen is present for both generating a .c and .h
 * Move some functions into their respective Object/DeclGen namespace.
 * Forward decls are managed by the incremental compilation frontend; C
   backend no longer renders function signatures based on callsites.
   For simplicity, all functions always get forward decls.
 * Constants are managed by the incremental compilation frontend. C
   backend no longer has a "constants" section.
 * Participate in incremental compilation. Each Decl gets an ArrayList
   for its generated C code and it is updated when the Decl is updated.
   During flush(), all these are joined together in the output file.
 * The new CValue tagged union is used to clean up using of assigning to
   locals without an additional pointer local.
 * Fix bug with bitcast of non-pointers making the memcpy destination
   immutable.
2021-01-05 17:41:14 -07:00
xackus
6c4924408b std.c add syslog 2021-01-05 13:09:40 -08:00
xackus
1640c357f4 freebsd, netbsd, dragonfly: add struct timeval 2021-01-05 13:07:25 -08:00
Alex Cameron
d92ea56884 std: Support equivalent ArrayList operations in ArrayHashMap 2021-01-06 00:55:51 +11:00
Alex Cameron
89286376c6 std: Rename ArrayList shrink => shrinkAndFree 2021-01-06 00:55:51 +11:00
Andrew Kelley
3e8aaee829 std: skip more tests on Windows to save CI memory
I've enabled only the tests that check things specific to Windows that
are not tested by other systems.
2021-01-04 22:25:04 -07:00
Andrew Kelley
16896a9d8b ci: skip crypto tests on windows
Trying to buy us more time on the Windows CI.
2021-01-04 15:57:54 -07:00
Andrew Kelley
66e5e92a3e
Merge pull request #7592 from LemonBoy/fix-7188
Allow variable captures on multi-prong switch arms
2021-01-04 14:23:01 -08:00
Evan Haas
d95724454c Allow dollar sign $ in identifiers in translate-c
In strictly conforming C, identifiers cannot container dollar signs.
However GCC and Clang allow them by default, so translate-c should
handle them. See http://gcc.gnu.org/onlinedocs/cpp/Tokenization.html
I encountered this in the wild in windows.h

Fixes #7585
2021-01-04 14:14:04 -08:00
Felix (xq) Queißner
819f2a01a1 Fixes missing error prong in std.os.send. 2021-01-04 14:03:39 -08:00
J.C. Moyer
fc3508b7e8 Fix off-by-one error in SinglyLinkedList.len() and add associated tests 2021-01-04 14:03:21 -08:00
xackus
a93c123f83 std.c: add some noalias 2021-01-04 14:02:42 -08:00
Andrew Kelley
fc38b42521 Revert "Fix #7296:"
This broke build scripts that wanted to refer to `exe_dir` or
`install_path`.

There has also been some pushback and discussion on this breaking
change. I think it should be re-evaluated.

This reverts commit a1a1929cf4.
2021-01-04 13:49:17 -07:00
Frank Denis
4400d2d7ab std/crypto: add BLAKE2-160 types and tests 2021-01-03 19:53:30 -08:00
daurnimator
e4c4a0a5f6 Improve uring definitions 2021-01-03 19:52:20 -08:00
Frank Denis
5aac2fc281 std/crypto: properly support arbitrary output sizes
Fixes #7657
2021-01-02 22:32:57 -08:00
Andrew Kelley
683814190b
Merge pull request #7612 from g-w1/do-7296
Implement #7296
2021-01-02 22:05:31 -08:00
Andrew Kelley
974c008a0e convert more {} to {d} and {s} 2021-01-02 19:03:14 -07:00
LemonBoy
5b981b1be7 Remove some unwanted changes
Leftovers after a long rebase.
2021-01-02 17:12:58 -07:00
LemonBoy
608a73efb1 Decrement max_depth when printing slice elements 2021-01-02 17:12:57 -07:00
LemonBoy
1fbe89dc2e langref: Update langref to use {s} 2021-01-02 17:12:57 -07:00
LemonBoy
1ca2deca33 std: Disable the special casing of {} for u8 slices/arrays
Unless {s} is specified the contents won't be treated as a string.
2021-01-02 17:12:57 -07:00
LemonBoy
4420afe64d tests: Use {s} instead of {} when formatting strings 2021-01-02 17:12:57 -07:00
LemonBoy
1c13ca5a05 stage2: Use {s} instead of {} when formatting strings 2021-01-02 17:12:57 -07:00
LemonBoy
dd973fb365 std: Use {s} instead of {} when printing strings 2021-01-02 17:12:57 -07:00
LemonBoy
5a06fdfa55 Use same brace pairs for arrays/slices/vectors 2021-01-02 17:12:57 -07:00
LemonBoy
d4a8fc8b67 Small cleanup 2021-01-02 17:12:57 -07:00
data-man
2b5e93fd3e Add formatting for arrays 2021-01-02 17:12:57 -07:00
LemonBoy
6f53653db1 std: Refactor the slice formatting code
Also fix the `*` specifier for more types, print an error message if we
can't show the value address.
2021-01-02 17:12:57 -07:00
ryuukk
5275280ede Formatting fix 2021-01-02 17:12:57 -07:00
ryuukk
1d97747665 Pretty print Slices
This code is adapted from pixelherodev paste from IRC

I have added a new fmt option to handle printing slice values ``{v}`` or ``{V}``

While i think it can be made the default, i want your opinion about it

```zig
    var slicea = [0]u32{};
    var sliceb = [3]u32{ 1, 2, 3 };

    std.log.info("Content: {v}", .{slicea});
    std.log.info("Content: {v}", .{sliceb});
```

will print:

```
info: Content: []
info: Content: [1, 2, 3]
```

Question:

Should we drop ``{v}`` and make it the default behavior?
2021-01-02 17:12:57 -07:00
Cameron Conn
db1e97d4b1
Improve documentation for ArrayList, ArrayListUnmanaged, etc. (#7624)
* Improve ArrayList & co documentation

- Added doc comments about the validity of references to elements in
an ArrayList and how they may become invalid after resizing operations.
- This should help users avoid footguns in future.

* Improve ArrayListUnmanaged & co's documentation

- Port improved documentation from ArrayList and ArrayList aligned to
  their unmanaged counterparts.
- Made documentation for ArrayListUnmanaged & co more inclusive and
  up-to-date.
- Made documentation more consistent with `ArrayList`.

* Corrections on ArrayList documentation.

- Remove incorrect/unpreferred wording on ArrayList vs
  ArrayListUnmanaged.
- Fix notes about the alignment of ArrayListAligned
- Be more verbose with warnings on when pointers are invalidated.
- Copy+paste a few warnings

* add warning to replaceRange

* revert changes to append documentation
2021-01-02 19:06:51 -05:00
Andrew Kelley
44c9bf559b std: disable a couple tests on windows
They are passing but we're hitting OOM on the Windows CI server. This is
to buy us more time until stage2 rescues us from the CI memory crisis.
2021-01-02 12:21:19 -07:00
Jakub Konka
763d807377 Duplicate OSAtomic.h between aarch64 and x86_64
The reason this is required is for two reasons: 1) the libc
targeting `aarch64` macOS is slightly newer than that targeting
`x86_64`, and 2) `OSAtomic.h` uses relative imports rather than
system-wide imports for accompanying headers which clearly is an
oversight on Apple's part. Until such time when `libkern` headers
between `x86_64` and `aarch64` are identical, this will require a
manual intervention to duplicate the relevant headers between the
respective architectures.
2021-01-02 15:30:14 +01:00
Jakub Konka
91a35e1a92 Detect native iframework dirs on macOS
This commit adds default search paths for system frameworks
on macOS while also adding `-isysroot` for OS versions at least BigSur.
Since BigSur (11.0.1), neither headers nor libs exist in standard
root locations (`/usr/include`, `/System/Library/Frameworks`). Instead, they
are now exclusively part of the installed developer toolchain (either
via XCode.app or CLT), and specifying `-isysroot` allows us to keep
using universal search paths such as `/System/Library/Frameworks` while
only changing the include flag from `-iframework` to
`-iframeworkwithsysroot`.
2021-01-02 15:29:05 +01:00
Sébastien Marie
a9c75a2b48 openbsd: add pollfd interface 2021-01-01 20:05:19 -08:00
Isaac Freund
d3ecbbebd3 std/build: assert that install paths are relative
If absolute paths are passed they will work unless $DESTDIR is set,
which causes subtly broken build.zig's.
2021-01-01 18:57:23 -08:00
daurnimator
bbab5e19b4 std: loop in trailer flags can be indexing operation 2021-01-01 15:48:48 -07:00
daurnimator
4387e50d4f std: use FieldEnum from TrailerFlags 2021-01-01 15:48:48 -07:00
daurnimator
9c97a07f18 std: have std.meta.fieldInfo take an enum rather than a string 2021-01-01 15:48:46 -07:00
daurnimator
73bf2e1525 std: add std.meta.FieldEnum 2021-01-01 15:48:04 -07:00
Andrew Kelley
c24540d263 std.debug: adjust panic message
also extern "c" instead of extern "pthread"
2021-01-01 14:56:26 -07:00
LemonBoy
c9756ca0e1 std: Show the panicking thread ID
Annotate the panic message with the thread ID to know who's the culprit.
2021-01-01 14:54:53 -07:00
Andrew Kelley
99203e4177
Merge pull request #7578 from vrischmann/walker
fix segfault in std.fs.Walker
2021-01-01 13:28:01 -08:00
Andrew Kelley
4cc374c639
Merge pull request #7634 from daurnimator/packed-init-all-to
Add PackedIntArray .initAllTo function
2021-01-01 13:23:18 -08:00
daurnimator
aa631cfd1f
Build errors should be followed by two newlines 2021-01-02 04:13:08 +11:00
daurnimator
b3c9dfc9cc
Don't process.exit() on invalid option use .markInvalidUserInput 2021-01-02 04:09:59 +11:00
daurnimator
ad1780959d
std/build.zig: use (existing) warn function alias 2021-01-02 04:01:21 +11:00
daurnimator
03e2c53747
Add workaround in PackedIntArray .initAllTo for #7635 2021-01-02 01:10:47 +11:00
daurnimator
31ba9d569b
Add PackedIntArray .initAllTo function 2021-01-02 00:52:47 +11:00
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
LemonBoy
2561168adb std: Clean up some tests
No functional changes, remove some dead code.
2020-12-30 09:42:21 +01: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
Vincent Rischmann
9c53564af1 fs: fix segfault in Walker.next
`top` might point to invalid memory after a call to self.stack.append
which causes a segfault.

Prevent this by recomputing `top`.

Fixes #7560
2020-12-28 18:14:27 +01:00
Vincent Rischmann
399c428cb0 fs: add a test for the walker
Written like this it triggers the segfault reported in #7560
2020-12-28 18:14:27 +01: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
Andrew Kelley
9f33984119
Merge pull request #7520 from ziglang/tsan
add support for TSAN
2020-12-24 15:17:52 -08:00
Andrew Kelley
894434988d libunwind: fix compile errors and warnings for 32-bit arm 2020-12-24 13:31:41 -07: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
3002856a7f libunwind: add __gcc_personality_v0 symbol 2020-12-24 01:18:48 -07:00
Andrew Kelley
8219d92987 stage2: fix Cache deadlock and build more of TSAN
* rename is_compiler_rt_or_libc to skip_linker_dependencies
   and set it to `true` for all sub-Compilations. I believe
   this resolves the deadlock we were experiencing on Drone
   CI and on some users' computers. I will remove the CI workaround in
   a follow-up commit.
 * enabling TSAN automatically causes the Compilation to link against
   libc++ even if not requested, because TSAN depends on libc++.
 * add -fno-rtti flags where appropriate when building TSAN objects.
   Thanks Firefox317 for pointing this out.
 * TSAN support: resolve all the undefined symbols. We are still seeing
   a dependency on __gcc_personality_v0 but will resolve this one in a
   follow-up commit.
 * static libs do not try to build libc++ or libc++abi.
2020-12-24 01:18:48 -07:00
Andrew Kelley
42b4a48bc9 WIP start adding support for TSAN 2020-12-24 01:18:47 -07: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 f2ab9512af.

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