12381 Commits

Author SHA1 Message Date
Evan Haas
1702b413f7 translate-c: ensure bools are cast to int when necessary
Fixes two scenarios where @boolToInt() calls were missing:

1. Boolean expression cast to different-size int (char, long, etc)
2. Boolean expression used as parameter for function with int argument
2021-01-15 12:35:54 -08:00
Andrew Kelley
35686262f5
Merge pull request #7785 from ziglang/std-thread-primitives
organize std lib concurrency primitives and add RwLock
2021-01-15 12:31:17 -08:00
Jakub Konka
2faf8c53d2 macho: use target arch page_size for codesig
It turns out I was wrong and we can set the page size to the actual
page size used by the target architecture when dividing the binary
into chunks and calculating a hash of each chunk for embedding within
the adhoc code signature. This shaves of a considerable amount of bytes
since we divide the code signature section by at least 2x.

I've also unified the `write` interface of `CodeSignature` struct to
follow that used in every other bit of `MachO`; namely, the functions
now accept a writer instead of a buffer, therefore, there is no need
to manually track where to write each struct field anymore.
2021-01-15 08:16:47 +01: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
2b0e3ee228
std.os.uefi.protocols.FileProtocol: fix and expose get_position, set_position (#7762) 2021-01-13 21:46:22 -05:00
Andrew Kelley
ec1541de26
Merge pull request #7746 from kubkon/macho-extern-fn
macho: extern functions come to MachO!
2021-01-13 15:11:35 -08:00
Jakub Konka
2128149325 macho: update DebugSymbols to include DATA_CONST seg 2021-01-13 23:56:05 +01:00
Jakub Konka
4ffa8952cc macho: add x86_64 tests 2021-01-13 23:55:56 +01:00
Jakub Konka
2ea0901dd6 macho: properly populate offset into lazy bind info 2021-01-13 23:55:48 +01:00
Jakub Konka
f0d7ec6f33 macho: add x86_64 support 2021-01-13 23:55:37 +01:00
Jakub Konka
1b91a9f4c8 macho: bring back lld cc hot-fix 2021-01-13 23:55:28 +01:00
Jakub Konka
7d40aaad2b macho: document more code + add test case 2021-01-13 23:55:18 +01:00
Jakub Konka
b86d0e488b macho: refactor writing and managing externs 2021-01-13 23:55:06 +01:00
Jakub Konka
21c7217e09 macho: memorize start of stubs in helper 2021-01-13 23:54:56 +01:00
Jakub Konka
44a052a65f macho: write out stubs for new externs only 2021-01-13 23:54:46 +01:00
Jakub Konka
2f7cd71193 macho: fully working PoC with main and exit 2021-01-13 23:54:31 +01:00
Jakub Konka
bb691ea16b macho: first working draft of externs on macOS 2021-01-13 23:54:22 +01:00
Jakub Konka
6d2a6513f9 macho: write out binding info 2021-01-13 23:54:11 +01:00
Jakub Konka
5ae82956aa macho: write out rebase info 2021-01-13 23:54:01 +01:00
Jakub Konka
f44732c1b0 macho: populate stubs and stub_helper 2021-01-13 23:53:46 +01:00
Jakub Konka
51a13f8ea6 macho: add missing data sections 2021-01-13 23:53:36 +01:00
Jakub Konka
3d07f057b1 macho: prealloc DATA_CONST and DATA segments 2021-01-13 23:53:25 +01:00
Jakub Konka
5487dd13ea stage2: lay the groundwork in prep for extern fn
This commit lays the groundwork in preparation for implementing
handling of extern functions in various backends.
2021-01-13 14:51:23 -08: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
LemonBoy
65b7d2b4e1 stage1: Resolve alignment earlier in @alignCast
Fixes #7744
2021-01-12 16:36:51 -08:00
Andrew Kelley
ffc8a43dfb ci: stop directly pushing web page stuff to s3
This is now handled by the www.ziglang.org repo deploy script.
2021-01-12 17:27:36 -07:00
Andrew Kelley
23c6cca24d ci: give the updated website content to the website repo
and use master branch not hugo-redesign branch
2021-01-12 13:26:52 -07:00
Andrew Kelley
166e9ea689 ci: add stdDocs to downloads/index.json for master branch 2021-01-12 12:52:59 -07: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
0edde40c25 Merge 'Add support for no red zone'
Merges #7511
2021-01-11 22:07:47 -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
Andrew Kelley
56c03881eb Merge branch 'rohlem-fix-GetFinalPathNameByHandle-before-win10_rs4'
Merges #7379
2021-01-11 17:48:33 -07: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