Commit Graph

7241 Commits

Author SHA1 Message Date
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
mlugg
283d650973 fmt: add rewrite for cast builtin type parameters 2023-06-24 16:47:49 -07:00
David CARLIER
72dd22f262 std.c: fix few capcisum api calls, following-up on 6ae19fa.
only variadic calls are prefixed with underscores.

ref: 59833b089e/sys/sys/capsicum.h (L326)
2023-06-24 13:05:45 -07:00
Andrew Kelley
7ad1042279 Revert "fix parseInt failing when a correct base is given"
This reverts commit fa6cea22bf.

Apologies for the merge. I thought this was a bug fix, but I see that it
is implementing a proposal that I intended to reject.
2023-06-24 13:03:51 -07:00
Mikko Kaihlavirta
fa6cea22bf fix parseInt failing when a correct base is given 2023-06-24 13:02:45 -07:00
David CARLIER
ea1d64dae4 std.c: fix host_basic_info definition for darwin.
follow-up on ff59c45.

ref: a5e15eced0/lib/libc/include/any-macos-any/mach/host_info.h (L116)
2023-06-24 13:00:14 -07:00
David CARLIER
e9dd0a22f0 std.c: freebsd fix typo for PROC.PROCCTL_MD_MIN constant.
follow-up on 2e2d379.
2023-06-24 12:59:18 -07:00
r00ster91
d82ab4fd8a ErrorBundle: fix integer overflow printing caret 2023-06-23 23:58:21 -07:00
Andrew Kelley
b129f1b046
Merge pull request #16037 from Jan200101/PR/cmakedefine-fix
Correct cmakedefine implementation
2023-06-23 23:56:18 -07:00
Michael Dusan
1cf06706be openbsd: fix NativeTargetInfo semver
- supply ".0" as .Z component and satisfy semver X.Y.Z requirement
- previously only X.Y was supplied and semver parse failed
2023-06-23 23:41:29 -07:00
Zachary Raineri
148e2a5a89
Removed unnecessary return switch on void method
Removed an unnecessary "return switch" on the Atomic.store method
2023-06-24 05:12:07 +00:00
Ed Yu
8dcb4a3dc4 std.http: fix the http.Client.wait() hanging when there is 1 more byte left 2023-06-23 20:18:24 +02:00
Niles Salter
7d511d6428
[heapsort] Protect against integer overflow
(Firstly, I changed `n` to `b`, as that is less confusing. It's not a length, it's a right boundary.)

The invariant maintained is `cur < b`. In the worst case `2*cur + 1` results in a maximum of `2b`. Since `2b` is not guaranteed to be lower than `maxInt`, we have to add one overflow check to `siftDown` to make sure we avoid undefined behavior.

LLVM also seems to have a nicer time compiling this version of the function. It is about 2x faster in my tests (I think LLVM was stumped by the `child += @intFromBool` line), and adding/removing the overflow check has a negligible performance difference on my machine. Of course, we could check `2b <= maxInt` in the parent function, and dispatch to a version of the function without the overflow check in the common case, but that probably is not worth the code size just to eliminate a single instruction.
2023-06-22 17:32:28 +00:00
Andrew Kelley
93e54f2354
Merge pull request #16110 from dweiller/force-tty-color
std.io.tty: cleanup detectConfig
2023-06-22 06:54:15 -07:00
David CARLIER
64f0059cd3 std.c: update netbsd/openbsd mman constants 2023-06-22 10:21:48 +00:00
Niles Salter
82470d4f89 [priority_dequeue] Fix out-of-bounds access
This makes it so `first_child_index` will not be accessed when it is equal to `self.len`. (i.e. `self.items[self.len]` will not happen) The access itself was "safe" (as in, `self.len < self.items.len`) because we were only calling `doSiftDown` in the case where there was a stale value at `self.items[self.len]`. However, it is still technically a bug, and can manifest by an unnecessary comparison of a value to a copy of itself.
2023-06-22 02:03:53 -07:00
Niles Salter
ff5850183e [priority_deque] simplify & optimize isMinLayer
LLVM has trouble compiling the old implementation, (presumably) because `leading_zeros` is thought to be a `u7` rather than a `u6`, which means `63 - clz` is not equivalent to `63 ^ clz`, which means it can't deduce that the final condition can simply be flipped. (I am assuming `usize` is a `u64` here for ease of understanding, but it's the same for any power of 2)

https://zig.godbolt.org/z/Pbj4P7ob3

The new version is slightly better too because `isMinLayer(maxInt(usize))` is now well-defined behavior.
2023-06-22 01:57:28 -07:00
Piotr Sarna
438d680913 http: fix getting Transfer-Encoding value
The 'Content-Length' header was inspected by mistake,
which makes it effectively impossible to use chunked
Transfer-Encoding when using the http client.

Tested locally with a HTTP server - data is properly sent
with POST method and the proper encoding declared, after the fix.
2023-06-22 11:44:46 +03:00
dweiller
e45d24c0de rename ZIG_DEBUG_COLOR env variable to YES_COLOR 2023-06-22 10:29:45 +10:00
dweiller
e05412669c std.io.tty: add detectTtyConfigForce for forcing color 2023-06-22 10:29:45 +10:00
Jan200101
1864ba2ccc
std.Build: implement variable substitution 2023-06-21 21:51:07 +02:00
Jan200101
5177068c88
std.Build: correctly implement cmakedefine and cmakedefine01 2023-06-21 21:51:06 +02:00
jacobly0
e2eabbbc51
Merge pull request #16098 from ziglang/musl-v1.2.4
update musl from v1.2.3 to v1.2.4
2023-06-20 23:14:22 -04:00
Andrew Kelley
b77679039f
Merge pull request #15415 from ehaas/c-char-signedness
Set `c_char` signedness based on the target
2023-06-20 16:41:58 -07:00
Josh Wolfe
0f2339f55b
std: json.parseFromValue() (#15981) 2023-06-20 19:01:34 -04:00
Jacob Young
9eb008717b std: prevent random CI failures 2023-06-20 10:56:23 -07:00
Andrew Kelley
b20ccff515 std.os: update logic for 64-bit symbol choice
musl v1.2.4 dropped the "64"-suffixed aliases for legacy "LFS64" ("large
file support") interfaces, so this commit changes the corresponding Zig
logic to call the correct names.
2023-06-20 12:55:38 -04:00
Evan Haas
c205521aea
std.Target: c_char is unsigned on RISC-V 2023-06-20 08:27:55 -07:00
Evan Haas
657fe55711
std.Target: Add a function for determining char signedess
Copied from arocc c1955a4742/src/target.zig (L7)
2023-06-20 00:26:40 -07:00
Andrew Kelley
a72d634b73
Merge pull request #16046 from BratishkaErik/issue-6128
Renaming `@xtoy` to `@YfromX`
2023-06-19 22:36:24 -07:00
dweiller
c6e2e1ae4b std.fmt: fix error set of formatDuration 2023-06-19 15:20:49 -07:00
Andrew Kelley
7d6fcf0831
Merge pull request #15012 from xxxbxxx/objcpy-elf-compress
objcopy: add support for --compress-debug-sections
2023-06-19 13:15:40 -07:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
Eric Joldasov
a6c8ee5231 compiler: rename "@XToY" to "@YFromX", zig fmt: rewrite them
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:24 -07:00
Andrew Kelley
e6e8cacab9 std.mem.order: use for loop syntax
Not only does it look nicer, it's a performance enhancement for debug
builds since the safety checks are eliminated.
2023-06-19 12:07:32 -07:00
Josh Wolfe
32cb9462ff
std: Support user-provided jsonParse method. Unify json.Parser and json.parse* (#15705) 2023-06-19 11:21:37 -04:00
Xavier Bouchoux
c39191a086 objcopy: add support for --compress-debug-sections 2023-06-19 08:51:03 +02:00
Andrew Kelley
28862dd30c
Merge pull request #16080 from squeek502/windows-vt
windows: detect ANSI support in more terminals
2023-06-18 13:36:59 -07:00
Andrew Kelley
3ef91233ca
Merge pull request #15867 from devnexen/haiku_malloc_usable_size
std.c: haiku also supports malloc_usable_size to benefit zig's heap
2023-06-18 12:44:08 -07:00
r00ster91
2839e35d1c std.math.isPowerOfTwo: add tests and doc comment and improve assert
The assert is changed from `int != 0` to `int > 0` because negative
integers always return `false`.
Python's `math.log2` does the same and errors for 0 or negative integers.
2023-06-18 10:42:03 -07:00
David CARLIER
54ea0bbcdd std.c: exposing timer api 2023-06-18 08:09:42 -07:00
Ryan Liptak
5439f36c97 Remove unnecessary isatty call from supportsAnsiEscapeCodes
isatty on Windows is implemented as a isCygwinPty call and a GetConsoleMode call, so calling isatty just duplicates the function calls we already need to do in supportsAnsiEscapeCodes.
2023-06-17 23:36:10 -07:00
Christofer Nolander
59a12cd293 windows: detect ANSI support in more terminals 2023-06-17 23:30:17 -07:00
Mizuochi Keita
729a051e9e std.http: Fix segfault while redirecting
Make to avoid releasing request's connection twice.
Change the `Request.connection` field optional. This field is null while the connection is released.

Fixes #15965
2023-06-17 21:58:33 -07:00
Andrew Kelley
e3736baddb
Merge pull request #15501 from matu3ba/win_rmwithposix
std.windows: use posix semantics to delete files, if available
2023-06-17 14:21:15 -07:00
Xavier Bouchoux
67b3e07260 zlib: naming convention
Adress review comments from https://github.com/ziglang/zig/pull/13977
by using the same naming convention as zstd.

And by using `finish()` instead of `close()` for the finalisation of the compressed stream.
rationale:
  - it is not the same as how close() is usually used, since it must be called to flush and write the final bytes. And as such it may fail.
  - it is not the same `flush` in the deflate code, which allows to keep writting more bytes later, and doesn't write the final checksum.
  - it is the same name as used in the original zlib library (Z_FINISH)

Also, use a packed struct for the header, which seems a better fit.
2023-06-17 14:08:05 -07:00
dantecatalfamo
8b92354396 std: add zlib stream writer 2023-06-17 14:07:45 -07:00
r00ster91
6e84f46990 std: replace builtin.Version with SemanticVersion 2023-06-17 13:17:34 -07:00
Andrew Kelley
96acc204b2
Merge pull request #16052 from mikdusan/bsd-getdents
fix bad return types for BSDs getdents and debitrot openbsd
2023-06-17 13:01:52 -07:00
Motiejus Jakštys
d41111d7ef mem: rename align*Generic to mem.align*
Anecdote 1: The generic version is way more popular than the non-generic
one in Zig codebase:

     git grep -w alignForward | wc -l
    56
     git grep -w alignForwardGeneric | wc -l
    149

     git grep -w alignBackward | wc -l
    6
     git grep -w alignBackwardGeneric | wc -l
    15

Anecdote 2: In my project (turbonss) that does much arithmetic and
alignment I exclusively use the Generic functions.

Anecdote 3: we used only the Generic versions in the Macho Man's linker
workshop.
2023-06-17 12:49:13 -07:00