aboutsummaryrefslogtreecommitdiff
path: root/lib/std/start.zig
AgeCommit message (Collapse)Author
2021-01-02std: Use {s} instead of {} when printing stringsLemonBoy
2020-12-31Year++Frank Denis
2020-12-18std.crypto.random: introduce fork safetyAndrew Kelley
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-18take advantage of std.os.linux.getauxvalAndrew Kelley
2020-12-18std: tlcsprng: cleanups & improvementsAndrew Kelley
* 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-18memory fences to make sure TLS init happensAndrew Kelley
2020-12-18start code: overwrite AT_RANDOM after we use itAndrew Kelley
2020-12-18std: introduce a thread-local CSPRNG for general useAndrew Kelley
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-11-24make start code more versatileAndrew Kelley
* always align the stack to 16. I saw an instance on x86_64 linux where it was needed. * detect at runtime if being interpreted by a dynamic loader and if so avoid clobbering the fs register.
2020-11-22Merge branch 'piepiepie' of https://github.com/LemonBoy/zig into pieAndrew Kelley
Conflicts: lib/std/dynamic_library.zig (fixed in this commit) src/all_types.hpp src/codegen.cpp src/link.cpp src/main.cpp Will manually apply the diffs to these deleted files to the new zig code in a followup commit.
2020-11-19Merge pull request #6829 from tadeokondrak/error-unsupported-callconvVeikka Tuominen
stage1: Compile error instead of falling back to C for unsupported cc
2020-11-19Add builtin.Signedness, use it instead of is_signedTadeo Kondrak
2020-11-19Update code to not use unsupported calling conventions for targetTadeo Kondrak
2020-11-16start.zig: call wWinMain with root's typeJonathan Marler
I have an alternative set of windows bindings I'm working on: https://github.com/marler8997/zig-os-windows. So I'm declaring my wWinMain function with my own HINSTANCE type rather than the one from std.os.windows. This change allows start to call wWinMain using any pointer type.
2020-11-09Windows TLS startup symbols are already provided by libcrt when linking ↵Alexandros Naskos
against libc
2020-10-27starting_stack_ptr -> argc_argv_ptr to reflect actual useKoakuma
2020-10-25Zero %i6 to terminate backchainKoakuma
2020-10-24Fix sparc64 argument loadingKoakuma
2020-10-24Add sp loadingKoakuma
2020-10-22Fix Compiler Error When Using wWinMain Entry-PointDixiE
The fix for #6715 introduced a new compiler error when attempting to use wWinMain as the application entry-point. The Windows API often relies on implicit casts between signed and unsigned variables. In this case, wWinMain returns an INT despite the fact this value is intended to feed into ExitProcess, which expects a UINT, so I've restored the bitcast from #5613.
2020-10-19std: Minor changes to startup codeLemonBoy
* Smaller startup sequence for ppc64 * Terminate the frame-pointer chain when executing _start * Make the stack traces work on ppc64 * Make the stack traces coloured on ppc64, some ioctls numbers are different and the whole set of constants should be audited.
2020-10-17fix compilation error when building with io_mode eventedAndrew Kelley
The merge of #5613 introduced a regression when building with io_mode evented, fixed in this commit. closes #6715
2020-10-15fixups regarding windows wide stringsAndrew Kelley
* remove GetModuleHandleA from kernel32.zig. use of A functions considered harmful. * make it a compile error to expose WinMain instead of wWinMain. same thing. * start code declares wWinMainCRTStartup instead of WinMainCRTStartup when it has the choice.
2020-10-15Merge branch '5002-fix-entrypoint-with-winmain' of ↵Andrew Kelley
https://github.com/AnthonyYoManz/zig into AnthonyYoManz-5002-fix-entrypoint-with-winmain
2020-09-18std: start: use std.log instead of stderrAndrew Kelley
When main returns an error code.
2020-09-10Merge pull request #5527 from shawnanastasio/ppc64leAndrew Kelley
Implement support for powerpc64{,le}
2020-09-07Fix compile when using EFI target (Fixes #6275)Peter Spiess-Knafl
2020-09-04update rest of testsVexu
2020-09-03update uses of deprecated type field accessVexu
2020-08-27ensure main return type is not i8Asherah Connor
Avoids a compile error from start.zig: /home/kivikakk/zig/build/lib/zig/std/start.zig:265:28: error: expected type 'u8', found 'i8' return result; ^ /home/kivikakk/zig/build/lib/zig/std/start.zig:265:28: note: unsigned 8-bit int cannot represent all possible signed 8-bit values return result;
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-07-20Merge branch 'master' of https://github.com/ziglang/zig into ↵Anthony Arian
5002-fix-entrypoint-with-winmain
2020-07-01Implement std.start for powerpc64leShawn Anastasio
This is a bit hacky since we end up doing more than just grabbing the stack pointer in the inline assembly block. Ideally _start would be implemented in pure asm for powerpc64le, but this will do for now. Still to be implemented is powerpc, powerpc64, and powerpc64 (ELFv2) support. The latter will just require correctly determing target ABI for powerpc64 and enabling the existing powerpc64le implementation for it.
2020-06-24@asyncCall now requires an argument tupleAlexandros Naskos
2020-06-15Implement WinMain Callers that Pass Valid ParamsAnthony Arian
2020-05-05zig fmtTadeo Kondrak
2020-04-24Add mips support to standard libraryTimon Kruiper
2020-03-28std: Minor changes to TLS handlingLemonBoy
* Always allocate an info block per-thread so that libc can store important stuff there. * Respect ABI-mandated alignment in more places. * Nicer code, use slices/pointers instead of raw addresses whenever possible.
2020-03-25Revert "Merge pull request #4807 from LemonBoy/tls-touchups"Andrew Kelley
This reverts commit ee6fda2297bf75432b8d7115ec4c60c213535bbe, reversing changes made to f313ab18aecea1ade0b6a90d671352a641ad351a. This caused a test failure: ``` behavior.misc.test "behavior-arm-linux-none-Debug-bare-multi thread local variable"...test failure /home/vsts/work/1/s/lib/std/testing.zig:191:14: 0x4608f in std.testing.expect (test) if (!ok) @panic("test failure"); ^ /home/vsts/work/1/s/test/stage1/behavior/misc.zig:616:11: 0x53e93 in behavior.misc.test "behavior-arm-linux-none-Debug-bare-multi thread local variable" (test) expect(S.t == 1235); ^ ```
2020-03-25std: Minor changes to TLS handlingLemonBoy
* Always allocate an info block per-thread so that libc can store important stuff there. * Respect ABI-mandated alignment in more places. * Nicer code, use slices/pointers instead of raw addresses whenever possible.
2020-03-20"generate .h files" feature is no longer supported in stage1Andrew Kelley
2020-03-12std/os/uefi: status reformNick Erdmann
2020-02-28introduce operating system version ranges as part of the targetAndrew Kelley
* re-introduce `std.build.Target` which is distinct from `std.Target`. `std.build.Target` wraps `std.Target` so that it can be annotated as "the native target" or an explicitly specified target. * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a struct which has the tag as well as version range information. * `std.elf` gains some more ELF header constants. * `std.Target.parse` gains the ability to parse operating system version ranges as well as glibc version. * Added `std.Target.isGnuLibC()`. * self-hosted dynamic linker detection and glibc version detection. This also adds the improved logic using `/usr/bin/env` rather than invoking the system C compiler to find the dynamic linker when zig is statically linked. Related: #2084 Note: this `/usr/bin/env` code is work-in-progress. * `-target-glibc` CLI option is removed in favor of the new `-target` syntax. Example: `-target x86_64-linux-gnu.2.27` closes #1907
2020-02-22update std lib to integrate with libc for environAndrew Kelley
closes #3511
2020-02-07Add wWinMain and wWinMainCRTStartup to fix #4376Jared Miller
2020-01-19Small cleanupsLemonBoy
2020-01-09Merge pull request #3955 from LemonBoy/fix-1528Andrew Kelley
Pointer arithmetic affects the alignment factor
2020-01-09New @export() handlingLemonBoy
Use a struct as second parameter to be future proof (and also allows to specify default values for the parameters) Closes #2679 as it was just a matter of a few lines of code.
2020-01-08Pointer arithmetic affects the alignment factorLemonBoy
Closes #1528
2020-01-06zig fmt and update `extern fn` to `callconv(.C)`Andrew Kelley