3385 Commits

Author SHA1 Message Date
Andrew Kelley
b2f8631a3c ThreadPool: delete dead code
If this errdefer did get run it would constitute a race condition. So I
deleted the dead code for clarity.
2020-12-20 15:08:59 -07:00
Andrew Kelley
4964bb3282 std: move serialization to the std lib orphanage
std-lib-orphanage commit 633792839f6f838fa864cde6af015413ee713404
2020-12-20 15:08:06 -07:00
LemonBoy
84549b4267 stage1: Fix for generic fn monomorphization
Don't use the instantiation argument types to build the function
parameter array.

f416535768fc30195cad6cd481f73fd1e80082aa worked around the problem, this
commit solves it.
2020-12-19 19:45:48 -05:00
Vincent Rischmann
dd7b816d98 builder: implement float options 2020-12-20 01:24:59 +02:00
Jakub Konka
b090451646
Merge pull request #7318 from kubkon/cc-macho
stage1: cross compile to x86_64 and arm64 macOS from anywhere with LLVM
2020-12-19 12:13:03 +01:00
Andrew Kelley
f416535768 work around compiler bug regarding generic function slice alignment
See #7495
2020-12-18 18:30:06 -07:00
Andrew Kelley
53987c932c std.crypto.random: introduce fork safety
Everybody gets what they want!

 * AT_RANDOM is completely ignored.
 * On Linux, MADV_WIPEONFORK is used to provide fork safety.
 * On pthread systems, `pthread_atfork` is used to provide fork safety.
 * For systems that do not have the capability to provide fork safety,
   the implementation falls back to calling getrandom() every time.
 * If madvise is unavailable or returns an error, or pthread_atfork
   fails for whatever reason, it falls back to calling getrandom() every
   time.
 * Applications may choose to opt-out of fork safety.
 * Applications may choose to opt-in to unconditionally calling
   getrandom() for every call to std.crypto.random.fillFn.
 * Added `std.meta.globalOption`.
 * Added `std.os.madvise` and related bits.
 * Bumped up the size of the main thread TLS buffer. See the comment
   there for justification.
 * Simpler hot path in TLS initialization.
2020-12-18 15:54:01 -07:00
Andrew Kelley
2b8dcc76eb take advantage of std.os.linux.getauxval 2020-12-18 12:22:46 -07:00
Andrew Kelley
2e4b409f31 std: tlcsprng: cleanups & improvements
* get rid of the pointless fences
 * make seed_len 16 instead of 32, which is accurate since it was
   already padding the rest anyway; now we do 1 pad instead of 2.
 * secureZero to clear the AT_RANDOM auxval
 * add a flag root source files can use to disable the start code. This
   is in case people want to opt out of the initialization when they
   don't depend on it.
2020-12-18 12:22:46 -07:00
Andrew Kelley
228a0937a2 memory fences to make sure TLS init happens 2020-12-18 12:22:46 -07:00
Andrew Kelley
4dcd1e6059 start code: overwrite AT_RANDOM after we use it 2020-12-18 12:22:46 -07:00
Andrew Kelley
013efaf139 std: introduce a thread-local CSPRNG for general use
std.crypto.random

* cross platform, even freestanding
* can't fail. on initialization for some systems requires calling
  os.getrandom(), in which case there are rare but theoretically
  possible errors. The code panics in these cases, however the
  application may choose to override the default seed function and then
  handle the failure another way.
* thread-safe
* supports the full Random interface
* cryptographically secure
* no syscall required to initialize on Linux (AT_RANDOM)
* calls arc4random on systems that support it

`std.crypto.randomBytes` is removed in favor of `std.crypto.random.bytes`.

I moved some of the Random implementations into their own files in the
interest of organization.

stage2 no longer requires passing a RNG; instead it uses this API.

Closes #6704
2020-12-18 12:22:46 -07:00
LemonBoy
ce65533985 std: Properly fix the TLS alignment problem
ad05509 introduced a fix for the wrong problem, the logic to align the
start of main_thread_tls_buffer was already there but was flawed.

Fix it for good and avoid wasting too many bytes for alignment purposes.
2020-12-18 14:22:30 -05:00
Andrew Kelley
ad05509930 std: align(16) main_thread_tls_buffer
Before this change, thread local variables were landmines if LLVM
decided to optimize any writes to them using vector instructions.
2020-12-17 22:58:56 -07:00
Alexandros Naskos
16144a7a37
Add EV_ERROR to FreeBSD bits 2020-12-17 22:58:05 +02:00
Tau
9b86dde7b9 Add baudrate constants
This adds the missing baudrate constants for linux where I've used them
directly.
2020-12-17 19:17:10 +02:00
Luuk de Gram
d73f46b57c Fix StackFallbackAllocator 2020-12-17 19:09:29 +02:00
Dmitry Atamanov
e16997a66c
Add process_madvise to Linux syscalls (#7450) 2020-12-17 18:58:09 +02:00
LemonBoy
135f4791e5 std: Don't hash undefined bits
auto_hash must be extra careful when hashing integers whose bit size is
not a multiple of 8 as, when reinterpreted with mem.asBytes, may contain
undefined non-zero bits too.
2020-12-17 12:00:48 +01:00
Alexandros Naskos
85cc3f24a0
Only check for evented mode in windows.OpenFile when in async mode 2020-12-17 11:08:21 +02:00
Jakub Konka
2e7883c597 lld+macho: lld xcomp to x86_64 macos now works 2020-12-17 10:04:53 +01:00
data-man
d877eb0e8d Fix typo in math.order 2020-12-16 12:14:44 +02:00
Alexandros Naskos
aa6654a4b3
Fix compilation for MacOS 2020-12-16 00:47:41 +02:00
luna
0c33624a45
create SendToError (#7417)
* add SendToError

* remove error catch

* add missing SendToError entries

* add mappings to new errors for posix

* map windows sendto() errors
2020-12-15 14:56:42 -05:00
Sébastien Marie
8bf5a3a5c1 openbsd: correct few structs
- addrinfo: addr and canonname are switched (wrong layout)
- addrinfo, Flock, msghdr struct: use proper c_xxx type instead of fixed size. it should help using struct on all architectures supported by openbsd
2020-12-15 14:49:42 -05:00
LemonBoy
9e5869262a std: Bool has no definite representation too
The padding bits are undefined.
2020-12-14 20:06:46 +01:00
LemonBoy
44556bfebe std: non-byte-multiple sized integers have no definite representation
Closes #7445
2020-12-14 20:06:46 +01:00
Alexandros Naskos
da007f318b
Implement std.fs.Watch on Windows
Use unmanaged containers in std.fs.Watch
2020-12-14 21:03:50 +02:00
Alexandros Naskos
5112ab8233
Fixed std.fs.Watch implementation on Linux
Added .Deleted event to std.fs.Watch on Linux
2020-12-14 21:00:54 +02:00
data-man
8591f30b0d Add missed Linux syscalls 2020-12-14 18:22:28 +02:00
Jakub Konka
91e8be385c
Merge pull request #7411 from LemonBoy/sigaction-smoke
std: Improve sigaction interface
2020-12-14 17:16:55 +01:00
LemonBoy
a471a57560 std: Fix formatting of type values
Closes #7429
2020-12-13 23:21:23 -05:00
LemonBoy
d9e9390550 Fix compilation error on OpenBSD 2020-12-13 20:36:47 +01:00
LemonBoy
bb72b0e800 Fix compilation error on FreeBSD 2020-12-13 20:36:34 +01:00
LemonBoy
97ba3d9a66 std: Drop struct prefixes in FreeBSD siginfo
I'm not sure this prefix-free style is a good idea, but let's roll with
it for the moment.
2020-12-13 19:45:11 +01:00
Alex Cameron
7515922907 Fix Sigaction struct on FreeBSD. 2020-12-13 19:37:13 +01:00
LemonBoy
3a759fdb17 Disable sigaction test on i386 because of #7427 2020-12-13 19:35:40 +01:00
LemonBoy
3375a580be std: Update more siginfo bits for BSDs 2020-12-13 19:28:38 +01:00
LemonBoy
fc70db5ab5 std: Fixes for siginfo test on macos
Xnu's sigaction() only supports fetching a limited set of sa_flags, test
SA_SIGINFO instead of SA_RESETHAND as that's supported everywhere.

Add another check to make sure SA_RESETHAND works.

Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
2020-12-13 19:17:04 +01:00
Isaac Freund
078a64f8d9
std.CrossTarget: add isNativeAbi() 2020-12-13 00:40:35 +01:00
LemonBoy
629cc6cf28 std: Further siginfo refinements
* Define siginfo and sigaction for Darwin
* Define sigaction/handler union for maximum libc compatibility
* Minor correction to some type definitions
2020-12-12 16:44:10 +01:00
LemonBoy
1d9b28403a std: Correct check in signal test
Ooops.
2020-12-12 15:34:26 +01:00
LemonBoy
beae3cea17 std: Improve sigaction interface
Add a smoke test to prevent regressions.
2020-12-12 13:57:25 +01:00
Andrew Kelley
d569e37cb5 std.fs.path.extension: different behavior for ending dot
extension("a.") now returns "." instead of "".

This matches both Python and Node.js standard library behavior as well
as my personal opinion on how this function should be defined.

Apologies for missing this in the code review.
2020-12-11 18:20:57 -07:00
Andrew Kelley
52bc1442d6 std.fs.path.extension: add additional API guarantee
Added:

The returned slice is guaranteed to have its pointer
within the start and end pointer address range of `path`,
even if it is length zero.
2020-12-11 17:41:34 -07:00
Andrew Kelley
1852dc7e13
Merge pull request #7098 from MasterQ32/std.fs.path.extension
Implements std.fs.path.extension
2020-12-11 19:32:21 -05:00
LemonBoy
fa6449dac0 zig fmt: Fix alignment of initializer elements
Resetting `column_counter` is not needed as the effective column number
is calculated by taking that value modulo `row_size`.

Closes #7289
2020-12-11 02:34:44 -05:00
antlilja
26399b5249 Added global-cache argument to build system + removed extra args.
* Field global_cache_root was added to Builder struct along with
mandatory argument for build_runner.zig. Logic for using the custom
global cache was also added.

* The arguments --cache-dir and --global-cache-dir are no longer passed
directly through to build_runner.zig and are instead only passed through the
mandatory cache_root and global_cache_root arguments.
2020-12-10 18:06:19 -05:00
Andrew Kelley
a3de27ef3b
Merge pull request #7372 from LemonBoy/atomicint
Improvements for std.atomic.{Int,Bool}
2020-12-10 16:13:36 -05:00
Andrew Kelley
5a5389128d
Merge pull request #7369 from jorangreef/io_uring_timeout
Add io_uring TIMEOUT and TIMEOUT_REMOVE operations:
2020-12-10 15:45:38 -05:00