112 Commits

Author SHA1 Message Date
Andrew Kelley
08efe0d598 Merge remote-tracking branch 'origin/flate' into wrangle-writer-buffering 2025-07-31 22:27:45 -07:00
Andrew Kelley
2024abda6a std.debug.Dwarf: work around API deficiency
need to supply a big enough buffer when working with decompression
2025-07-31 22:10:11 -07:00
Andrew Kelley
83513ade35 std.compress: rework flate to new I/O API 2025-07-31 22:10:11 -07:00
Andrew Kelley
51ebebcea3 Merge remote-tracking branch 'origin/master' into wrangle-writer-buffering 2025-07-16 18:19:56 -07:00
Andrew Kelley
76d04c1662 zig fmt 2025-07-16 10:27:39 -07:00
Andrew Kelley
6e6c68d889 Merge remote-tracking branch 'origin/master' into wrangle-writer-buffering 2025-07-10 16:11:10 -07:00
Andrew Kelley
0e37ff0d59 std.fmt: breaking API changes
added adapter to AnyWriter and GenericWriter to help bridge the gap
between old and new API

make std.testing.expectFmt work at compile-time

std.fmt no longer has a dependency on std.unicode. Formatted printing
was never properly unicode-aware. Now it no longer pretends to be.

Breakage/deprecations:
* std.fs.File.reader -> std.fs.File.deprecatedReader
* std.fs.File.writer -> std.fs.File.deprecatedWriter
* std.io.GenericReader -> std.io.Reader
* std.io.GenericWriter -> std.io.Writer
* std.io.AnyReader -> std.io.Reader
* std.io.AnyWriter -> std.io.Writer
* std.fmt.format -> std.fmt.deprecatedFormat
* std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape
* std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape
* std.fmt.fmtSliceHexLower -> {x}
* std.fmt.fmtSliceHexUpper -> {X}
* std.fmt.fmtIntSizeDec -> {B}
* std.fmt.fmtIntSizeBin -> {Bi}
* std.fmt.fmtDuration -> {D}
* std.fmt.fmtDurationSigned -> {D}
* {} -> {f} when there is a format method
* format method signature
  - anytype -> *std.io.Writer
  - inferred error set -> error{WriteFailed}
  - options -> (deleted)
* std.fmt.Formatted
  - now takes context type explicitly
  - no fmt string
2025-07-07 22:43:51 -07:00
Andrew Kelley
0b3f0124dc std.io: move getStdIn, getStdOut, getStdErr functions to fs.File
preparing to rearrange std.io namespace into an interface

how to upgrade:

std.io.getStdIn() -> std.fs.File.stdin()
std.io.getStdOut() -> std.fs.File.stdout()
std.io.getStdErr() -> std.fs.File.stderr()
2025-07-07 22:43:51 -07:00
Andrew Kelley
9f27d770a1 std.io: deprecated Reader/Writer; introduce new API 2025-07-07 22:43:51 -07:00
Andrew Kelley
9f8486170c std.http compiling again 2025-07-01 16:35:30 -07:00
Andrew Kelley
837f2bfc69 hello world compiling again 2025-07-01 16:35:30 -07:00
Andrew Kelley
1e2aab2f97 std: combine BufferedWriter into Writer 2025-07-01 16:35:29 -07:00
Andrew Kelley
3c98e2c826 std: combine BufferedReader into Reader 2025-07-01 16:35:29 -07:00
Andrew Kelley
da303bdaf1 std: fix a bunch of compilation errors 2025-07-01 16:35:29 -07:00
Andrew Kelley
06b44a0afa update git fetching logic to new reader/writer API
- flatten std.crypto.hash.Sha1 and give it a writable interface that
  optimizes splats
- flatten std.hash.crc and give it a writable interface that optimizes
  splats
- remove old writer impls from std.crypto
- add fs.File.Writer.moveToReader
- add fs.File.Writer.seekTo
- add std.io.Reader.Hashed and std.io.Writer.Hashed which are
  passthrough streams. Instead of passing through to null writer, use
  the writable interface implemented directly on hashers which doesn't
  have to account for passing through the data.
- add std.io.BufferedWriter.writeSplatAll
2025-07-01 16:35:29 -07:00
Andrew Kelley
4607770a57 std.debug.Dwarf.expression: partial rework
- use labeled continue
- avoid anytype
- avoid dependency on a "seeking" API
- simpler, more optimal VM interpreter loop
- progress decoupling from host machine
- type safety for opcodes. see #15556
2025-07-01 16:35:29 -07:00
Andrew Kelley
1bb75f9d62 stabilize readRemainingArrayList and readRemainingAlloc API 2025-07-01 16:35:28 -07:00
Andrew Kelley
cdd05df532 std.io.BufferedReader: don't use a BufferedWriter field
this is way better with readVec and the ability to call
`std.io.Reader.buffered`.
2025-07-01 16:35:27 -07:00
Andrew Kelley
00afaa4b18 std.io.BufferedReader: get rid of the @constCast
but it's pushed out to various callsites
2025-07-01 16:35:27 -07:00
Andrew Kelley
98f463ad59 revert introduction of @errorCast in this branch 2025-07-01 16:35:27 -07:00
Andrew Kelley
a4fdda6ae0 std.io: redo Reader and Writer yet again
explicit error sets ahoy matey

delete some sus APIs from File that need to be reworked
2025-07-01 16:35:27 -07:00
Jacob Young
d76c8d0bd2 Dwarf: cleanup and port to new std.io.BufferedReader API 2025-07-01 16:35:26 -07:00
Andrew Kelley
9dc0b4a98f back to the anyerror!usize vtable 2025-07-01 16:35:26 -07:00
Andrew Kelley
6ac7931bec std: hacking around with buffered reader / writer semantics
I think I'm going to back out these vtable changes in the next commit
2025-07-01 16:35:26 -07:00
Andrew Kelley
890a02c345 std.io: move getStdIn, getStdOut, getStdErr functions to fs.File
preparing to rearrange std.io namespace into an interface
2025-07-01 16:35:26 -07:00
Andrew Kelley
6c48aad991 update some more std lib API to new Reader/Writer
std.compress needs an audit, I see some problems
2025-07-01 16:35:26 -07:00
Andrew Kelley
57e1fc29d2 reader interface vecs and bufferedwriter arraylist 2025-07-01 16:35:26 -07:00
Andrew Kelley
00c6c836a6 std: start reworking std.io
hello world is compiling
2025-07-01 16:35:25 -07:00
Ali Cheraghi
1df79ab895 remove spirv cpu arch 2025-06-23 06:03:03 +02:00
Jacob Young
917640810e Target: pass and use locals by pointer instead of by value
This struct is larger than 256 bytes and code that copies it
consistently shows up in profiles of the compiler.
2025-06-19 11:45:06 -04:00
mlugg
fd72b38f68
std: remove old panic handlers after zig1.wasm update 2025-06-01 12:10:57 +01:00
mlugg
c1a5caa454
compiler: combine @intCast safety checks
`castTruncatedData` was a poorly worded error (all shrinking casts
"truncate bits", it's just that we assume those bits to be zext/sext of
the other bits!), and `negativeToUnsigned` was a pointless distinction
which forced the compiler to emit worse code (since two separate safety
checks were required for casting e.g. 'i32' to 'u16') and wasn't even
implemented correctly. This commit combines those safety panics into one
function, `integerOutOfBounds`. The name maybe isn't perfect, but that's
not hugely important; what matters is the new default message, which is
clearer than the old ones: "integer does not fit in destination type".
2025-06-01 12:10:57 +01:00
Jacob Young
4adb7eca6a debug: correctly detect missing entries in .eh_frame_hdr 2025-05-17 02:08:41 -04:00
Andrew Kelley
7bd3207921 make @memcpy and @memmove share panic handlers 2025-04-27 23:30:00 -07:00
dweiller
898ca82458 compiler: add @memmove builtin 2025-04-26 13:34:16 +10:00
Alec Fessler
1cc388d526 stdlib: handle EEXIST in mmap with FIXED_NOREPLACE. Fixes #21475 2025-02-24 04:36:14 -05:00
mlugg
5e20e9b449 Sema: allow @ptrCast of slices changing the length
Also, refactor `Sema.ptrCastFull` to not be a horrifying hellscape.
2025-02-23 08:28:58 +00:00
Andrew Kelley
eb3c7f5706 zig build fmt 2025-02-22 17:09:20 -08:00
Alex Rønne Petersen
481b7bf3f0
std.Target: Remove functions that just wrap component functions.
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look
at multiple components of the target. But functions like isWasm(), isDarwin(),
isGnu(), etc only exist to save 4-8 characters. I don't think this is a good
enough reason to keep them, especially given that:

* It's not immediately obvious to a reader whether target.isDarwin() means the
  same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar
  functions *do* look at multiple components.
* It's not clear where we would draw the line. The logical conclusion before
  this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(),
  Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand.
* It's nice to just have a single correct way of doing something.
2025-02-17 19:18:19 +01:00
Alex Rønne Petersen
b541a7af11
std.Target: Remove Cpu.Arch.spu_2.
This was for a hobby project that appears to be dormant for now. This can be
added back if the project is resumed in the future.
2025-02-17 19:17:55 +01:00
Meghan Denny
9142482372
std.ArrayList: popOrNull() -> pop() [v2] (#22720) 2025-02-10 04:21:31 +00:00
Andrew Kelley
284de7d957 adjust runtime page size APIs
* fix merge conflicts
* rename the declarations
* reword documentation
* extract FixedBufferAllocator to separate file
* take advantage of locals
* remove the assertion about max alignment in Allocator API, leaving it
  Allocator implementation defined
* fix non-inline function call in start logic

The GeneralPurposeAllocator implementation is totally broken because it
uses global state but I didn't address that in this commit.
2025-02-06 14:23:23 -08:00
Archbirdplus
439667be04 runtime page size detection
heap.zig: define new default page sizes
heap.zig: add min/max_page_size and their options
lib/std/c: add miscellaneous declarations
heap.zig: add pageSize() and its options
switch to new page sizes, especially in GPA/stdlib
mem.zig: remove page_size
2025-02-06 14:23:23 -08: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
mlugg
3232e59ab9
std: remove old declarations now a zig1 update has happened 2025-01-24 22:33:23 +00:00
mlugg
5a6666db55
all: update for panic.unwrapError and panic.call signature changes 2025-01-24 22:33:23 +00:00
mlugg
83991efe10
compiler: yet more panic handler changes
* `std.builtin.Panic` -> `std.builtin.panic`, because it is a namespace.
* `root.Panic` -> `root.panic` for the same reason. There are type
  checks so that we still allow the legacy `pub fn panic` strategy in
  the 0.14.0 release.
* `std.debug.SimplePanic` -> `std.debug.simple_panic`, same reason.
* `std.debug.NoPanic` -> `std.debug.no_panic`, same reason.
* `std.debug.FormattedPanic` is now a function `std.debug.FullPanic`
  which takes as input a `panicFn` and returns a namespace with all the
  panic functions. This handles the incredibly common case of just
  wanting to override how the message is printed, whilst keeping nice
  formatted panics.
* Remove `std.builtin.panic.messages`; now, every safety panic has its
  own function. This reduces binary bloat, as calls to these functions
  no longer need to prepare any arguments (aside from the error return
  trace).
* Remove some legacy declarations, since a zig1.wasm update has
  happened. Most of these were related to the panic handler, but a quick
  grep for "zig1" brought up a couple more results too.

Also, add some missing type checks to Sema.

Resolves: #22584

formatted -> full
2025-01-24 19:29:51 +00:00
Alex Rønne Petersen
180db2bf23
std.debug: Fall back to .eh_frame/.debug_frame if .eh_frame_hdr is incomplete.
When using the self-hosted backends, especially in incremental mode, the
.eh_frame_hdr section may be incomplete, so we can't treat it as authoritative.

Instead, if we started out intending to use .eh_frame_hdr but find that it's
incomplete, load .eh_frame/.debug_frame on demand and use that info going
forward.
2025-01-23 23:22:38 +00:00
Jacob Young
128658038d debug: fix std.debug.NoPanic compile errors 2025-01-18 17:33:10 -05:00
Jacob Young
63730441d0 x86_64: implement union access 2025-01-16 20:47:30 -05:00