Commit Graph

391 Commits

Author SHA1 Message Date
Aaron Ang 9db3e23e80 std.math.big: require sufficient capacity for aliased params 2025-12-27 20:38:33 +01:00
Alex Rønne Petersen aa0249d74e Merge pull request 'std.ascii: rename indexOf functions to find' (#30101) from adria/zig:indexof-find into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30101
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
Reviewed-by: mlugg <mlugg@noreply.codeberg.org>
2025-12-22 12:50:46 +01:00
Alex Rønne Petersen 647866dd63 std.math: disable hypot tests on non-Debug powerpc64
https://github.com/llvm/llvm-project/issues/171869
2025-12-16 06:23:11 +01:00
Adrià Arrufat 02c5f05e2f std: replace usages of std.mem.indexOf with std.mem.find 2025-12-05 14:31:27 +01:00
unplanned 688af04725 math.big: stronger asserts to reduce risks of aliasing 2025-12-04 10:28:42 +01:00
unplanned 73e82332d0 big.Mutable.setString optimization and simplification 2025-12-04 10:28:31 +01:00
unplanned c6a1444864 std.math.big.int.int_test: replace mem.eql by expectEqualSlices 2025-12-04 01:12:50 +01:00
unplanned ded4e12559 big.Const.dump: fixed error 2025-12-04 01:12:34 +01:00
Justus Klausecker e5c2df9f17 std.math.big.int: fix format functions 2025-11-23 09:52:43 -08:00
Ali Cheraghi dec1163fbb all: replace all @Type usages
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-11-22 22:42:38 +00:00
Alex Rønne Petersen 9ab7eec23e represent Mac Catalyst as aarch64-maccatalyst-none rather than aarch64-ios-macabi
Apple's own headers and tbd files prefer to think of Mac Catalyst as a distinct
OS target. Earlier, when DriverKit support was added to LLVM, it was represented
a distinct OS. So why Apple decided to only represent Mac Catalyst as an ABI in
the target triple is beyond me. But this isn't the first time they've ignored
established target triple norms (see: armv7k and aarch64_32) and it probably
won't be the last.

While doing this, I also audited all Darwin OS prongs throughout the codebase
and made sure they cover all the tags.
2025-11-14 11:33:35 +01:00
Jacob Young 2e31077fe0 Coff: implement threadlocal variables 2025-10-10 22:47:47 -07:00
Alex Rønne Petersen 35d2b1e99a std.math.modf: disable vector test on LoongArch with LSX
https://github.com/llvm/llvm-project/issues/159529
2025-09-18 12:42:24 +02:00
mlugg 32a1aabff7 std.math.big.int: normalize zero result for small multiplications
Resolves: #25221
2025-09-13 17:13:27 +01:00
Andrew Kelley b7104231af Merge pull request #25077 from ziglang/GenericReader
std.Io: delete GenericReader, AnyReader, FixedBufferStream; and related API breakage
2025-08-30 12:43:52 -07:00
Alex Rønne Petersen af78c55676 std: skip some failing tests on hexagon 2025-08-30 06:36:41 +02:00
Andrew Kelley 79f267f6b9 std.Io: delete GenericReader
and delete deprecated alias std.io
2025-08-29 17:14:26 -07:00
Becker A. 718ee31e21 Update powi.zig to fix docstring formatting
Without this change, the docs are formatted s.t. the text "Edge case rules ordered by precedence:" is appended onto the prior line of text "Underflow: Absolute value of result smaller than 1", instead of getting its own line.
2025-08-24 22:59:08 +02:00
Rue ee85c8b6d0 re-enable std.math.modf vector tests (#24786)
* re-enable std.math.modf vector tests
* re-disable std.math.modf vector tests for `aarch64-macos`
* re-disable for s390x architecture
2025-08-16 02:36:09 +00:00
Andrew Kelley 749f10af49 std.ArrayList: make unmanaged the default 2025-08-11 15:52:49 -07:00
Andrew Kelley 6f545683f3 std: replace various mem copies with @memmove 2025-08-05 09:56:02 -07:00
mlugg 64bf8bb146 std: stop relying on precision-losing coercions 2025-07-31 10:57:04 +01:00
Jacob Young 5060ab99c9 aarch64: add new from scratch self-hosted backend 2025-07-22 19:43:47 -07:00
Lewis Gaul 03dfd2ecc3 Make sure to test the sign of the zero results 2025-07-17 05:04:59 +02:00
Lewis Gaul 7abb170f59 Add tests for math.expm1(), fixing bug in 32-bit function 2025-07-17 05:04:59 +02:00
Lewis Gaul f34b26231e Add tests for math.log1p() 2025-07-17 05:04:59 +02:00
Linus Groh eb37552536 Remove numerous things deprecated during the 0.14 release cycle
Basically everything that has a direct replacement or no uses left.

Notable omissions:

- std.ArrayHashMap: Too much fallout, needs a separate cleanup.
- std.debug.runtime_safety: Too much fallout.
- std.heap.GeneralPurposeAllocator: Lots of references to it remain, not
  a simple find and replace as "debug allocator" is not equivalent to
  "general purpose allocator".
- std.io.Reader: Is being reworked at the moment.
- std.unicode.utf8Decode(): No replacement, needs a new API first.
- Manifest backwards compat options: Removal would break test data used
  by TestFetchBuilder.
- panic handler needs to be a namespace: Many tests still rely on it
  being a function, needs a separate cleanup.
2025-07-11 08:17:43 +02:00
Andrew Kelley 51a9a6aab6 std: replace formatInteger with formatNumber 2025-07-09 14:54:54 -07:00
Andrew Kelley 83c4000319 std: revert big int test to master branch
oops, it depends on usize
2025-07-08 08:36:04 -07:00
Andrew Kelley 7e2a26c0c4 std.io.Writer.printValue: rework logic
Alignment and fill options only apply to numbers.

Rework the implementation to mainly branch on the format string rather
than the type information. This is more straightforward to maintain and
more straightforward for comptime evaluation.

Enums support being printed as decimal, hexadecimal, octal, and binary.

`formatInteger` is another possible format method that is
unconditionally called when the value type is struct and one of the
integer-printing format specifiers are used.
2025-07-07 22:43:53 -07:00
Andrew Kelley 5378fdb153 std.fmt: fully remove format string from format methods
Introduces `std.fmt.alt` which is a helper for calling alternate format
methods besides one named "format".
2025-07-07 22:43:53 -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
Jacob Young 1f98c98fff x86_64: increase passing test coverage on windows
Now that codegen has no references to linker state this is much easier.

Closes #24153
2025-06-19 18:41:12 -04:00
mlugg e498d8da3c std: disable test on LLVM (#24191) 2025-06-15 22:15:06 +01:00
Jacob Young 6b41beb370 big.int: implement float conversions
These conversion routines accept a `round` argument to control how the
result is rounded and return whether the result is exact. Most callers
wanted this functionality and had hacks around it being missing.

Also delete `std.math.big.rational` because it was only being used for
float conversion, and using rationals for that is a lot more complex
than necessary. It also required an allocator, whereas the new integer
routines only need to be passed enough memory to store the result.
2025-06-15 14:15:18 -04:00
Jacob Young 58d2bd601e x86_64: rewrite scalar <<|
Closes #23035
2025-05-17 18:00:17 -04:00
samy007 8ae9ac6df4 improve test syntax for better stack trace in case of failure 2025-04-16 11:10:22 +02:00
samy007 c813b6a900 std.math.big: add and update tests 2025-04-14 22:54:10 +02:00
samy007 b08924e938 std.math.big.int: changed llshr and llshl implementation 2025-04-14 20:46:06 +02:00
samy007 b635b37249 std.math.big.int: remove setRuntimeSafety 2025-04-13 21:07:11 +02:00
homersimpsons 95fdbc579f pow: fix typo 0 instead of inf 2025-04-05 21:20:10 +02:00
Alex Rønne Petersen cb8d7a8110 Merge pull request #23310 from Rexicon226/fix-23309
big.int: return normalized results from `{add,sub}Carry`
2025-03-25 18:44:35 +01:00
oittaa c1db72cdbc std.math: Add least common multiple (lcm) 2025-03-24 16:07:40 +01:00
David Rubin ae442e2c29 big.int: return normalized results from {add,sub}Carry 2025-03-24 06:58:01 -07:00
Jacob Young aff2be01c9 big.int: fix negative multi-limb shift right adjust crash 2025-03-21 21:51:08 -04:00
Jacob Young ed284c1f98 big.int: fix yet another truncate bug
Too many bugs have been found with `truncate` at this point, so it was
rewritten from scratch.

Based on the doc comment, the utility of `convertToTwosComplement` over
`r.truncate(a, .unsigned, bit_count)` is unclear and it has a subtle
behavior difference that is almost certainly a bug, so it was deleted.
2025-03-21 21:51:08 -04:00
Linus Groh c44f4501e7 std.math.big.int: Support strings up to base 36
Co-Authored-By: samy007 <samy2014@free.fr>
2025-02-23 11:25:35 +00:00
Jacob Young ebea56d279 x86_64: rewrite scalar @ctz 2025-02-18 09:47:44 -05: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
Jacob Young c58e60a042 x86_64: rewrite scalar @truncate 2025-02-06 16:14:53 -05:00