Commit graph

10511 commits

Author SHA1 Message Date
Meghan Denny
3a4bb47fed std.meta.FieldType: use builtin and deprecate 2025-02-04 16:12:10 +00:00
Ryan Liptak
4041cc06d5 Allocator/Random: document that comparing ptr may result in illegal behavior
See #21756 and #17704
2025-02-03 17:07:28 -08:00
Ryan Liptak
b46f9945a8 process.Child.collectOutput: Switch to Allocator/ArrayListUnmanaged
Removes an inadvisable comparison of Allocator.ptr fields
2025-02-03 17:07:27 -08:00
Alex Rønne Petersen
08d661fcfd
Merge pull request #22725 from mrjbq7/timerfd_clockid_t
Fix timerfd_clockid_t on linux and freebsd
2025-02-03 22:51:13 +01:00
Matthew Lugg
317722b37b
Merge pull request #20271 from MasonRemaley/zon
ZON
2025-02-03 16:38:35 +00:00
Alex Rønne Petersen
e61acd8eb5
Merge pull request #22713 from mikdusan/openbsd
openbsd: fix stage3 link
2025-02-03 17:34:55 +01:00
John Benediktsson
7309a13bd8 std.c: fix timerfd_clockid_t.MONOTONIC on freebsd 2025-02-03 15:44:27 +01:00
John Benediktsson
d358ef804e std.c: use linux.timerfd_clockid_t 2025-02-03 15:44:27 +01:00
John Benediktsson
6a1b76a02c std.os.linux: re-add missing timerfd_create() constants 2025-02-03 15:44:27 +01:00
mlugg
dc5c827847
std.heap.GeneralPurposeAllocator: disable some tests on wasm32-wasi
The ZON PR (#20271) is causing these tests to inexplicably fail. It
doesn't seem like that PR is what's breaking GPA, so these tests are now
disabled. This is tracked by #22731.
2025-02-03 09:17:52 +00:00
Mason Remaley
13c6eb0d71
compiler,std: implement ZON support
This commit allows using ZON (Zig Object Notation) in a few ways.

* `@import` can be used to load ZON at comptime and convert it to a
  normal Zig value. In this case, `@import` must have a result type.
* `std.zon.parse` can be used to parse ZON at runtime, akin to the
  parsing logic in `std.json`.
* `std.zon.stringify` can be used to convert arbitrary data structures
  to ZON at runtime, again akin to `std.json`.
2025-02-03 09:14:37 +00:00
Andrew Kelley
963651bbf2
Merge pull request #22672 from jacobly0/x86_64-rewrite
x86_64: rewrite float conversions
2025-02-01 14:32:43 -08:00
Michael Dusan
1c288ee857
std.Target: bump semver min/max for BSDs and Apple 2025-02-01 14:47:10 -05:00
dweiller
cdc9d65b0d std.priority_queue: add useful functions from ArrayList API
The `ensureTotalCapacityPrecise`, `clearRetainingCapacity` and
`clearAndFree` functions from the ArrayList API are also useful for a
PriorityQueue.
2025-02-01 19:02:39 +01:00
mlugg
3924f173af compiler: do not propagate result type to try operand
This commit effectively reverts 9e683f0, and hence un-accepts #19777.
While nice in theory, this proposal turned out to have a few problems.

Firstly, supplying a result type implicitly coerces the operand to this
type -- that's the main point of result types! But for `try`, this is
actually a bad idea; we want a redundant `try` to be a compile error,
not to silently coerce the non-error value to an error union. In
practice, this didn't always happen, because the implementation was
buggy anyway; but when it did, it was really quite silly. For instance,
`try try ... try .{ ... }` was an accepted expression, with the inner
initializer being initially coerced to `E!E!...E!T`.

Secondly, the result type inference here didn't play nicely with
`return`. If you write `return try`, the operand would actually receive
a result type of `E!E!T`, since the `return` gave a result type of `E!T`
and the `try` wrapped it in *another* error union. More generally, the
problem here is that `try` doesn't know when it should or shouldn't
nest error unions. This occasionally broke code which looked like it
should work.

So, this commit prevents `try` from propagating result types through to
its operand. A key motivation for the original proposal here was decl
literals; so, as a special case, `try .foo(...)` is still an allowed
syntax form, caught by AstGen and specially lowered. This does open the
doors to allowing other special cases for decl literals in future, such
as `.foo(...) catch ...`, but those proposals are for another time.

Resolves: #21991
Resolves: #22633
2025-02-01 15:48:45 +00:00
Chris Boesch
58c00a829e
std.posix: Use separate clock ID enums for clock_gettime() and timerfd_create() (#22627) 2025-02-01 06:53:57 +00:00
Jacob Young
b9531f5de6 x86_64: rewrite float vector conversions 2025-01-31 23:00:34 -05:00
Michael Dusan
c44be99f1a debug: fix MemoryAccessor file leak
- patch authored by Jacob Young
- tested on alpine-aarch64, 3.21.0, qemu-system 9.2.0
- issue manifested on Alpine Linux aarch64 under qemu-system where
  zig2 fails during bootstrap: error.ProcessFdQuotaExceeded
2025-02-01 04:27:24 +01:00
Alex Kladov
4de2b1ea65 std: don't leak a process in Child.run in case of an error
Closes: #22433
2025-01-31 17:57:39 +01:00
John Benediktsson
c104e86442
std.os.linux: adding recvmmsg() (#22651) 2025-01-31 15:44:50 +00:00
Alex Rønne Petersen
6fcf8e6809
std.zig.target: Fix glibc runtime triple for x86-linux-gnu. 2025-01-31 14:00:32 +01:00
John Benediktsson
53598e36e8
std.posix: adding getsockopt (#22335) 2025-01-30 16:09:29 +00:00
Rui He
c0d85cda53
std.fs.File: limit initial_cap according to max_bytes in readToEndAllocOptions 2025-01-30 16:42:15 +01:00
GalaxyShard
a3ee5215bb
std.Build: Add option to specify language of CSourceFiles
Closes: #20655
2025-01-30 14:04:47 +01:00
Guillaume Wenzek
3348478fc3
Make -freference-trace work without colors
Currently -freference-trace only works when running from a terminal.
This is annoying if you're running in another environment or if you redirect the output.
But -freference-trace also works fine without the color, so change how the build runner is interpreting this option.
2025-01-30 13:02:06 +01:00
Andrew Kelley
fecdc53a48 delete std.heap.WasmPageAllocator
This allocator has no purpose since it cannot truly fulfill the role of
page allocation, and std.heap.wasm_allocator is better both in terms of
performance and code size.

This commit redefines `std.heap.page_allocator` to be less strict:

"On operating systems that support memory mapping, this allocator makes
a syscall directly for every allocation and free. Otherwise, it falls
back to the preferred singleton for the target. Thread-safe."

This now matches how it was actually being implemented, and matches its
use sites - which are mainly as the backing allocator for
`std.heap.ArenaAllocator`.
2025-01-29 21:10:20 -08:00
Michael Dusan
cd365b8b82 std: fix comptime SemanticVersion expr regression
- effects FreeBSD memfd and Windows DeleteFile
- regression: e5d5a8bc4e
2025-01-30 04:35:27 +01:00
Meghan Denny
7cef585f55 std.c: define more fields for darwin.AI 2025-01-30 01:44:45 +01:00
Alex Rønne Petersen
7d699be772 std.zig.target: Remove some library names from isLibCLibName() for MinGW.
These are system DLLs, most of which MinGW provides .def files for. It just so
happens that MinGW also has some static libraries by the same name which link in
some GUID definitions.

The remaining non-MinGW library names represent libraries that are always
statically linked, so if those are requested by the user, it makes sense to
error if libc is not linked. A future enhancement could be to compile those
independent of mingw32.lib, however.

Closes #22560.
2025-01-29 21:38:34 +01:00
Bing Sun
798bb0bc61
std.c: android bionic compatibility fixes (getrandom & getaddressinfo) (#22143)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-01-29 19:16:08 +00:00
mlugg
107b65ec5d Sema: explain why we tried to call an extern fn at comptime
I recently saw a user hit the "comptime call of extern function" error,
and get confused because they didn't know why the scope was `comptime`.
So, use `explainWhyBlockIsComptime` on this and related errors to add
all the relevant notes.

The added test case shows the motivating situation.
2025-01-29 18:43:24 +00:00
Alex Rønne Petersen
484f72311e
Merge pull request #22634 from nektro/patch-6
std.c: was missing more
2025-01-29 16:26:57 +01:00
Meghan Denny
0bf57b7114 std: mkdir(2) mode uses mode_t 2025-01-29 14:57:07 +01:00
David Rubin
898658e3a0 std.c: add msghdr and msghdr_const definitions for macos 2025-01-29 13:34:37 +01:00
Alex Rønne Petersen
7843deb16b std.zig.system.darwin: Add driverkit handling in getSdk(). 2025-01-29 09:25:06 +01:00
ThisPC
e528ab4709 std.testing.expectEqual: {any} in print and move tests 2025-01-29 09:19:07 +01:00
thejohnny5
78b7a446f0 std: add optional times pointer for futimes, futimens, utimes, utimensat 2025-01-29 09:17:20 +01:00
Meghan Denny
97ccf3504f std.c: was missing darwin.kevent64_s 2025-01-29 06:34:34 +01:00
Meghan Denny
0bbea1e848
std.c: was missing darwin.@"close$NOCANCEL" 2025-01-27 22:26:20 -08:00
Meghan Denny
1bfadc1381
std.c: was missing darwin.host_t 2025-01-27 21:40:23 -08:00
Meghan Denny
87b0e0821a
std.c: was missing darwin.natural_t 2025-01-27 21:38:25 -08:00
Alex Rønne Petersen
41e7604359
Merge pull request #22573 from sorairolake/fix-invisible-doccomments
Fix invisible doccomments at the start of source files to make them visible
2025-01-28 04:59:14 +01:00
John Benediktsson
884b1423a4 std.heap.memory_pool: make preheat() usable after init() 2025-01-28 00:06:54 +01:00
Andrew Kelley
df1fa36feb Revert "std.http.Server: add Request.getHeader() function (#21625)"
This reverts commit 21823d1b5d.

It's a bad API that could easily lead to O(N^2) logic.
2025-01-27 11:13:56 -08:00
dbubel
21823d1b5d
std.http.Server: add Request.getHeader() function (#21625) 2025-01-27 17:58:05 +00:00
Carter Snook
2043e8ae05
main: classify empty environment variables as unset
This matches existing well-specified conventions for e.g. NO_COLOR.

Closes #22380.
2025-01-27 17:53:32 +01:00
Alex Rønne Petersen
5647dd84c1 Revert d714cf3340 (#21273)
Turns out this was already fixed in #21964.

I have no idea why GitHub showed an incorrect diff in #21273, or how applying the diff to master was even possible, but here we are.
2025-01-26 20:52:29 -08:00
Shun Sakai
7599216341
std.zip: Include the last paragraph in top-level doc comments
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-01-27 12:24:36 +09:00
injuly
d714cf3340
std.c.darwin: Fix EXC.MASK compile error (#21273) 2025-01-26 19:56:14 +01:00
Fri3dNstuff
9c6d728b0c
std.meta: handle comptime fields in hasUniqueRepresentation (#22132) 2025-01-26 18:23:34 +00:00