7596 Commits

Author SHA1 Message Date
Zachary Raineri
0461a64a93
change uses of std.builtin.Mode to OptimizeMode (#16745)
std.builtin.Mode is deprecated.
2023-08-09 14:39:34 -04:00
mllken
9676a43a5d linux: add setsid 2023-08-09 11:33:06 -07:00
Philipp Lühmann
d34201c849
std.json: stringify enum literals (#16742) 2023-08-08 23:26:46 +00:00
Andrew Kelley
36c57c3ba1
Merge pull request #16707 from marler8997/jsonStringifyBigNumbers
std.json: fix roundtrip stringify for large integers
2023-08-08 12:08:21 -07:00
Zachary Raineri
49244dc0ca
std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
Loris Cro
373e48c983
autodoc: new layout (#16715)
* autodoc: init guide TOC work

* autodoc: working guides toc navigation

* autodoc: more improvements

* autodoc: ui refinements

* autodoc: new layout and init descriptions for namespaces in std.zig
2023-08-06 18:12:05 +02:00
Jonathan Marler
2046880de8 std.json: josh review fixes
* renamed enum_big_numbers_quoted option to enum_nonportable_numbers_as_strings
* updated stringify doc to mention the option

I also reversed the logic to determine whether an integer is nonportable,
it seemed easier to reason about.

I also took a stab at applying the new option to floats, but, I got stuck
at trying to print large floats, not sure if Zig supports that yet.
2023-08-06 09:25:21 -06:00
Jacob Young
1cce539ddc json.stringify: properly implement RFC8259 recommendation
The previous magic numbers used `1 << 52`, which did not account for the
implicit leading one in the floating point format.  The RFC is correct
when it uses an exponent of 53.  Technically these exclusive endpoints
are also representable, but everyone including the RFC seems to use them
exclusively.

Also, delete special case optimizations related to the type which have
already been implemented in the zig compiler to produce comptime values
for tautological runtime comparisons.
2023-08-06 00:35:10 -04:00
Jonathan Marler
7dacf77745 std.json: fix roundtrip stringify for large integers
std.json follows interoperability recommendations from RFC8259 to limit
JSON number values to those that fit inside an f64.  However, since Zig
supports arbitrarily large JSON numbers, this breaks roundtrip data
congruence.

To appease both use cases, I've added an option `emit_big_numbers_quoted`
to StringifyOptions.  It's disabled by default which preserves roundtrip
but can be enabled to favor interoperability.
2023-08-05 21:56:00 -06:00
none
f3fbdf2b44 wyhash: keep tail bytes on iterative update
Update calls with input longer then one block must ensure that
last sixteen bytes are available when final is called.

Fixes #16695
2023-08-05 15:30:50 -07:00
Ryan Liptak
90fde14c5f std.testing.expectEqualSlices: On failure, print address for pointer types
When comparing slice elements, `std.meta.eql` is used which only compares pointer address and length to determine equality for pointer types. This previously led to confusing results where `expectEqualSlices` would appear to fail on seemingly equal slices (judging by the output of `expectEqualSlices`. For example:

try testing.expectEqualSlices(
    []const i64,
    &[_][]const i64{ &[_]i64{ 1, 2, 3 }, &[_]i64{ 5, 5, 5 } },
    &[_][]const i64{ &[_]i64{ 1, 2, 3 }, &[_]i64{ 5, 5, 5 } },
);

Previously, this would result in:

============ expected this output: =============  len: 2 (0x2)

[0]: { 1, 2, 3 }
[1]: { 5, 5, 5 }

============= instead found this: ==============  len: 2 (0x2)

[0]: { 1, 2, 3 }
[1]: { 5, 5, 5 }

================================================

After this commit, it will result in:

============ expected this output: =============  len: 2 (0x2)

[0]i64@7ff7e2773758: { 1, 2, 3 }
[1]i64@7ff7e2773770: { 5, 5, 5 }

============= instead found this: ==============  len: 2 (0x2)

[0]i64@7ff7e2773788: { 1, 2, 3 }
[1]i64@7ff7e27737a0: { 5, 5, 5 }

================================================
2023-08-05 11:54:26 -07:00
David Gonzalez Martin
9c05810be6 debug: expose module debug info deinitialization
Before this commit, you could use readElfDebugInfo independently with
one catch: the data is not freed since the deinitialization functions
for ModuleDebugInfo are private. This change makes them public so the
    users of such function and similar can free the memory after the
    debug symbols have been used.
2023-08-04 09:24:11 +02:00
Andrew Kelley
d0fd67cffe std.zig.system.NativePaths: remove bad framework dir
This path actually has nothing useful in it.
2023-08-03 09:52:15 -07:00
Andrew Kelley
c012f5d55d std.zig.system.darwin.isSdkInstalled: fix implementation
* don't assert that the child process doesn't crash
* don't give a false negative on warnings printed to stderr

Also fix getSdk from the same file in the same way
2023-08-03 09:52:15 -07:00
Andrew Kelley
e582a3642b std.zig.system.darwin: fix redundant names 2023-08-03 09:52:15 -07:00
Andrew Kelley
c94bbebb91 std.zig.system.NativePaths: simplify and integrate with Darwin SDK 2023-08-03 09:52:15 -07:00
Andrew Kelley
aef8bcf776 std.Build.Step.Compile: fine-grained system lib search control
For each library you can specify the preferred mode and search strategy.

The old way of setting global state is eliminated.
2023-08-03 09:52:15 -07:00
Andrew Kelley
f887b02518
Merge pull request #16359 from g-w1/plan9-more-std
Plan 9: more standard library support
2023-08-03 09:41:20 -07:00
Fabio Arnold
31979b1006 Fix compile error in addVcpkgPaths 2023-08-03 09:37:26 -07:00
mlugg
88fb4dab81 std.target: mark helper functions inline
This was discussed in #16597. It makes sense for most of the functions
in this file to be marked inline: many are simple helper functions so
inlining is likely a strict win, and having the return values be
comptime-known may improve userspace code in some cases by preventing it
from unintentionally checking properties of the target at runtime.

This changeset is somewhat conservative: the functions marked inline are
generally returning booleans or simple integers, and many are simple
one-line checks.
2023-08-03 09:37:10 -07:00
Mitchell Hashimoto
76f7b40e15 build: dupe library, rpath, and framework LazyPaths
Without duping, users could get some unexpected behavior if they used a
string with a lifetime that didn't persist throughout the full build,
i.e. if it wasn't heap allocated, or if it was explicitly freed.
2023-08-02 20:20:48 -07:00
Jacob G-W
d0fbfd3c9f Plan 9: add more features to std.os.plan9
* Replaces the exit assembly with the function from std.
* Reads the top-of-stack struct at program startup that can get information
  like the pid.
* Changes the read and write functions to use the Pread and Pwrite syscalls
  instead of the depreciated _READ and _WRITE
* Changes the openat function to use flags instead of perms.
  Plan9 does not support perms when opening, just when creating.
* Adds an errstr function to read the errstr buf created by the kernel
2023-08-02 18:19:07 -04:00
Jacob G-W
841b54f5e3 std: add SbrkAllocator and use it for Plan 9
Implements issue #6451.
This was needed to support allocation on Plan 9 and now other operating
systems like DOS can also use it.

It is a modified version of the WasmAllocator since wasm also uses a
sbrk-esque allocation system.

This commit also adds the necessary system bits for sbrk to work on plan 9.
2023-08-02 17:39:52 -04:00
Jacob G-W
b9aa1dcaf1 plan 9: filesystem support 2023-08-02 17:39:52 -04:00
Adam Goertz
9e19969e09 Remove math.ln in favor of @log 2023-08-02 12:00:14 -07:00
Andrew Kelley
4d7dd1689f CLI: stop special-casing LLVM, LLD, and Clang
Before:

-fLLVM, -fLLD, -fClang, -flibLLVM
-fno-LLVM, -fno-LLD, -fno-Clang, -fno-libLLVM

After:

-fllvm, -flld, -fclang, -flibllvm
-fno-llvm, -fno-lld, -fno-clang, -fno-libllvm
2023-08-01 20:32:54 -07:00
Kitty-Cricket Piapiac
d370005d34 std.process.totalSystemMemory: return correct error type on FreeBSD 2023-08-01 19:27:04 -07:00
Jacob Young
9e0a34f329 llvm: fix data layout calculation for experimental llvm targets
Closes #16616
2023-08-01 19:20:22 -07:00
Andrew Kelley
e84cda0ebf
Merge pull request #16622 from jacobly0/cbe-asm-compat
CBE: fix regressions and get new targets passing behavior tests
2023-07-31 15:34:32 -07:00
Andrew Kelley
04d5e07d40 std.c.openbsd: remove "msg_" prefixes from structs
Reapplies 8f14431bc883898aaf78cc985e2d90716187e882 which was reverted in
95e2605d30c15963c4d6bc9e39751031b0f52007.
2023-07-31 11:57:48 -07:00
Andrew Kelley
479fd2f721 std.c.openbsd: add PTHREAD_STACK_MIN
@semarie audited this definition.
2023-07-31 11:54:27 -07:00
Andrew Kelley
b1bde35651 std.c.openbsd: add ucontext_t for aarch64
Reapplies 1585ed637d101ed16adb6b9ebdfa465299bfdb13 which was reverted in
f3adbe249b0dfad91318916142a33619232a968f.

I removed use of `usingnamespace` in this commit.

@semarie audited this struct definition.
2023-07-31 11:51:08 -07:00
Andrew Kelley
235b9fc28a Revert "std: add FreeBSD's procctl api."
This reverts commit 2e2d37917d4227d6ab9c8e43b3619bc47ce56417.
2023-07-31 11:24:21 -07:00
Andrew Kelley
99c70ec24f Revert "std: add kinfo_vmentry for FreeBSD"
This reverts commit 4a0508e56c06456c367c57a7565b9f757f2ff663.
2023-07-31 11:24:14 -07:00
Andrew Kelley
68134e56cb Revert "std add getrandom to solato solaris based systems"
This reverts commit 56d800ff7e65897d8ff9ede8e8194af4d08f0df5.
2023-07-31 11:24:09 -07:00
Andrew Kelley
a18a116bda Revert "std: add shm_create_largepage for FreeBSD, completing MFD* constants."
This reverts commit 7b908e173fa6034dc92e6b73c4264dc44706bd32.
2023-07-31 11:24:04 -07:00
Andrew Kelley
c0ac1411db Revert "std: freebsd update proposal"
This reverts commit 2568da2f41d3403b2cd91bbb84862c86932b63e6.
2023-07-31 11:23:56 -07:00
Andrew Kelley
26777d98fe Revert "std: adding freebsd's elf_aux_info api"
This reverts commit 83970b6d916a1526869aba2680d5017d495df12a.
2023-07-31 11:23:49 -07:00
Andrew Kelley
b5df1bfcdb Revert "os: expand sched_getaffinity wrapper and update freebsd's cpuset api flags."
This reverts commit dbdafb6cc503ce5820713dfa79cc956438b7957a.
2023-07-31 11:23:38 -07:00
Andrew Kelley
14353590f2 Revert "std: adding netbsd's pthread to cpu affinity api"
This reverts commit 3f259d35502ed5a8bdb6bbc22f9adb39d610b006.
2023-07-31 11:23:33 -07:00
Andrew Kelley
a2439e161b Revert "std: enriching malloc api on freebsd."
This reverts commit 9140249d2993d9d9f4c92b2892db421e1e0fb7ae.
2023-07-31 11:21:50 -07:00
Andrew Kelley
c7f2a7ea82 Revert "std: add a subset of the macOs's libproc api."
This reverts commit 7b0e015eb42272d84396f44fc904ab79f38dd696.
2023-07-31 11:20:57 -07:00
Andrew Kelley
aa5808c26c Revert "std: add accept_filter struct to make use of SO_ACCEPTFILTER socket option"
This reverts commit 1d322fe5102368f80fd4d00dcbbe3dca9e6306f8.
2023-07-31 11:20:53 -07:00
Andrew Kelley
62deaaacd5 Revert "std: mcontext layout for x86 and fixing few x86_64 fields types for"
This reverts commit 9691cded95afa53f17bfc50edc371d4fe673b56a.
2023-07-31 11:20:49 -07:00
Andrew Kelley
963b2a2a4d Revert "std: adding FreeBSD's sched wrappers"
This reverts commit 9ef615104acb0f7cfed8f871404679a7df5571fe.
2023-07-31 11:20:44 -07:00
Andrew Kelley
5f101b253e Revert "std: adding sigevent to supported platforms."
This reverts commit 23c4f55a612842d8544a9dfe604a9caf1ca39697.
2023-07-31 11:20:39 -07:00
Andrew Kelley
86388e3c32 Revert "std.os: sysctl* wrappers, better warning at compile time"
This reverts commit c66151a22619b4f3ce028076c67f495ff5f99d2c.
2023-07-31 11:20:31 -07:00
Andrew Kelley
70d1bb8049 Revert "std.process: further totalSystemMemory portage"
This reverts commit 5c70d7bc723a8e0e47018d3606285005c280ddb8.
2023-07-31 11:20:21 -07:00
Andrew Kelley
c6ec217e23 Revert "std.c: add find_path for haiku"
This reverts commit 1084590ec4939ed0aba5574eb835a07783301a8c.
2023-07-31 11:18:19 -07:00
Andrew Kelley
6bb776bb73 Revert "std.os: selfExePath implementation for haiku"
This reverts commit 7439eb5e99ba98bbdb2a0d0d71535e57d13f3c6e.
2023-07-31 11:18:15 -07:00