Commit graph

24636 commits

Author SHA1 Message Date
Josh Wolfe
32cb9462ff
std: Support user-provided jsonParse method. Unify json.Parser and json.parse* (#15705) 2023-06-19 11:21:37 -04:00
Manlio Perillo
423d7b848b test/src/Cases: fix incorrect code to find zig_lib_directory
The runCases function incorrectly called the introspect.findZigLibDir
function, causing a possible error, depending on the location of the
local cache directory, since the current executable is check-case.

Use findZigLibDirFromSelfExe, passing the zig_exe_path argument.

The current CI scripts work correctly because ZIG_LOCAL_CACHE_DIR is set
to "$(pwd)/zig-local-cache".

Fixes #15044
2023-06-18 18:20:42 -07:00
Jan Philipp Hafer
539e0b0469 compiler_rt: fixup exports of PPC routines
PPC targets can also use the functionality-equivalent standard routine, so
unconditionally export the standard routine.

Fixup of #16054 merged in f043071cdf.
2023-06-18 15:27:47 -07: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
Arya-Elfren
c13ac52972 Fix a confusing comment in langref.html.in 2023-06-18 09:19:23 -07:00
David CARLIER
54ea0bbcdd std.c: exposing timer api 2023-06-18 08:09:42 -07:00
Loris Cro
c17a8df2fa
Merge pull request #16087 from der-teufel-programming/master
autodoc: Fix rendering of function arguments named `_`
2023-06-18 16:43:30 +02:00
Krzysztof Wolicki
e9da87866c autodoc: Fix rendering of function arguments named _ 2023-06-18 14:41:49 +00:00
Loris Cro
3180a371e8
Merge pull request #16086 from der-teufel-programming/master
autodoc: Handle more InternPool.Index types properly in Autodoc
2023-06-18 16:21:16 +02:00
Krzysztof Wolicki
e7fd70a951 autodoc: Handle more InternPool.Index types properly in Autodoc 2023-06-18 14:07:09 +00:00
Loris Cro
329a585fbe
Merge pull request #15512 from cryptocode/autodoc-searchkey
autodoc: Add / as an alternative search key
2023-06-18 09:06:51 +02:00
Loris Cro
216ef10dc4
Merge branch 'master' into autodoc-searchkey 2023-06-18 09:06:40 +02: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
e23d48e61a
Merge pull request #15511 from mikdusan/netbsd-pkgsrc
netbsd: pkgsrc
2023-06-17 14:22:43 -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
Andrew Kelley
8d0a8c2859
Merge pull request #15265 from tiehuis/optimize-udivmod
optimize udivmod
2023-06-17 14:19:07 -07:00
Andrew Kelley
8a6c3d26c1
Merge pull request #15010 from xxxbxxx/zlib-compress
Add zlib stream writer
2023-06-17 14:14:16 -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
Andrew Kelley
9370fb8b81
Merge pull request #14844 from perillo/fix-issue-13280
Fix issue 13280
2023-06-17 13:37:28 -07:00
Manlio Perillo
366e3c657f
Langref misc fix and improvement (#14695)
* langref: improve the Hello World section

Clarify that a Zig source file must have the .zig extension.

Fix a typo.

* langref: improve the Comments section

  - Document how doc comments are used by -femit-docs
  - Rename "Doc comments" to "Doc Comments", for consistency
  - Clarify that placing a doc comment in an unexpected place is a
    compiler error and add two incorrect examples
  - Document the current Autodoc behavior, when normal comments are
    interleaved with doc comments
  - Rewrite the documentation for top-level doc comments

* langref: improve the Zig Test section

Document that the test name can also be an identifier, in addition to a
string literal.

Update the test output for the first test.

Closes #14085
2023-06-17 16:35:50 -04: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
Marc Tiehuis
5baa05664e wyhash: support comptime usage
Closes #16070.
2023-06-17 12:06:40 -07:00
Evin Yulo
6f766fbf00 privatize std.mem.writePackedInt{Big, Little}
These are unnecessary since writePackedInt accepts an endian parameter.
2023-06-17 06:35:30 -07:00
Jan Philipp Hafer
f043071cdf compiler_rt: add missing PPC routines
Adds conditional exports
- __fixkfti
- __fixunskfti
- __floattikf
- __negkf2
- __mulkc3
- __divkc3
- __powikf2
and adjusts tools/gen_stubs.zig.

From https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html:
"When long double transitions to __float128 on PowerPC in the future,
__ibm128 will remain for use in conversions between the two types."

Hence `__extendkftf2` and `__trunctfkf2` for conversion are superfluous
and only using f128 for `kf` routines is justified.

Closes #16057.
2023-06-16 23:37:50 -07:00
John Zhang
e95fc2023f Change outdated filename in langref 2023-06-16 23:12:45 -07:00
Andrew Kelley
a10ddba921
Merge pull request #16064 from Luukdegram/wasm-linker
wasm/linker: symbol resolution improvements
2023-06-16 22:03:35 -07:00
Gregory Mullen
abfa215882 add additional errno (INTR) to tcset,getpgrp calls
Missed this originally because I was only able to trigger it when
SA_RESTART was missing from the sigaction handlers. I'm unconvinced this
is actually a sane way for stdlib to behave (see #15664). But this does
duplicate the existing behavior throughout os.zig which IMO should be
prioritized here.
2023-06-16 22:02:36 -07:00
Andrew Kelley
78c8cb4225
Merge pull request #16003 from g-w1/plan9-lazy-syms
Plan9: lots of fixes
2023-06-16 21:57:33 -07:00
Marc Tiehuis
59a6f482e2 disable udivmod asm divq on windows 2023-06-17 13:50:05 +12:00
Marc Tiehuis
947dd36341 optimize udivmod
See https://reviews.llvm.org/D81809 for upstream description.

In summary this is ~10x improvement for small divisors and similar
performance for equal divisors.

Closes #13523.
2023-06-17 13:50:04 +12:00
Veikka Tuominen
0f5aff3441 zig build: add option to only print failed steps
The motivating case for this is that currently when a test fails
the CI log will include ~5k lines of listing steps that succeeded.
2023-06-16 15:17:59 -07:00
Andrew Kelley
537104fd9d
Merge pull request #16025 from mlugg/feat/remove-std-math-minmax
Consider bounds when refining @min/@max result type; deprecate std.math.{min,max,min3,max3}
2023-06-16 13:45:33 -07:00
mlugg
2af5bd8aa8 Autodoc: fix crash when walking @min/@max with two operands
This was causing CI failures after the previous commit.
2023-06-16 13:44:25 -07:00
r00ster91
2593156068 migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -07:00
mlugg
22c6b6c9a9 Update zig1.wasm
This is needed in order to remove math.{min,max} from std in favour of
the builtins, since the builtins need the behavior fix from the previous
commit.

Note from Andrew: I updated this commit with zig1.wasm built by me.

Signed-off-by: Andrew Kelley <andrew@ziglang.org>
2023-06-16 13:43:32 -07:00
mlugg
c4cc796695 Sema: consider type bounds when refining result type of @min/@max
I achieved this through a major refactor of the logic of analyzeMinMax.
This change should be compatible with vectors of comptime_int, which
Andrew said are supposed to work (but which currently do not).
2023-06-16 13:33:31 -07:00
Luuk de Gram
44b322ce64
wasm-linker: correctly resolve undefined functions
We now resolve undefined symbols during incremental-compilation
where we discard the current symbol if we detect we found
an existing symbol which is not the one currently being updated.
The symbol will always be discarded in favor of the existing symbol
in such a case.
2023-06-16 17:16:56 +02:00
Luuk de Gram
e3db210cf1
wasm: support calling alias'd function pointers
When lowering a decl value we verify whether its owner decl index
equals to the decl index of the decl being lowered. When this is not
the case, we are lowering an alias. So instead, we will now lower
the owner decl instead and call its symbol to ensure its type
is being correctly generated.
2023-06-16 17:16:56 +02:00
Luuk de Gram
1cfad29f10
codegen: fix union padding
This regressed during the internpool merges. This commit
reinstates the padding logic for unions.
2023-06-16 17:16:56 +02:00
Luuk de Gram
098b0b50ab
wasm: fix lowerParentPtr offsets
The was incorrectly merged during internPool. This commit forward
fixes that and reinstates the correct logic.
2023-06-16 17:16:56 +02:00
Luuk de Gram
729f822e31
wasm-linker: correctly resolve exported symbols
When compiling Zig code using the Wasm backend, we would previously
incorrectly resolve exported symbols as it would not correctly remove
existing symbols if they were to be overwritten. This meant that
undefined symbols could cause collisions although they should be
resolved by the exported symbol.
2023-06-16 17:16:55 +02:00
Jacob G-W
5343a2f566 plan9: revamp the relocation system to allow decl refs 2023-06-16 08:34:30 -04:00
Jacob G-W
4dac9f54dd plan9: flesh out stdlib enough to allow not using simplified start logic 2023-06-16 08:34:30 -04:00