Commit graph

360 commits

Author SHA1 Message Date
Ryan Liptak
98dd8856ef std.mem: Add countScalar 2025-10-03 16:29:09 -07:00
Andrew Kelley
14e227d8a6 std.mem: add cutLast and cutScalarLast 2025-09-25 11:38:38 -07:00
Andrew Kelley
97bef50dc3 std.mem: rename all "index of" functions
Moving towards our function naming convention of having one word per
concept and constructing function names out of concatenated concepts.
In `std.mem` the concepts are:
* "find" - return index of substring
* "pos" - starting index parameter
* "last" - search from the end
* "linear" - simple for loop rather than fancy algo
* "scalar" - substring is a single element
2025-09-25 11:28:58 -07:00
Andrew Kelley
3411b5e499 std.mem: add cut and cutScalar and example usage 2025-09-25 11:11:46 -07:00
Andrew Kelley
dd2f1cbebf std.mem: rename chomp to cut 2025-09-25 10:54:28 -07:00
Andrew Kelley
ac4d79e322 std.mem: introduce chompPrefix and chompSuffix 2025-09-25 10:50:41 -07:00
rpkak
4fb08986cb optimize std.mem.swap 2025-09-24 12:29:43 -07:00
Alex Rønne Petersen
e7f1624e6e
std.mem: work around LoongArch inline asm bug in doNotOptimizeAway()
https://github.com/llvm/llvm-project/issues/159200
2025-09-18 10:08:38 +02:00
Ryan Liptak
c330d2bdde mem.replace: Document that input/output cannot overlap 2025-09-17 20:12:03 -07:00
Andrew Kelley
dca4c302dd std.mem.indexOfSentinel: eliminate unnecessary @ptrCast
it was always unnecessary but now it's illegal
2025-09-07 20:23:36 -07:00
Frank Denis
02396f8d5c
Document std.mem.* functions (#25168)
* Document std.mem.* functions

Functions in std.mem are essential for virtually all applications,
yet many of them lacked documentation.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2025-09-06 18:55:57 -07:00
Jacob Young
d625158354 aarch64: implement more assembler instructions 2025-08-11 15:47:51 -07:00
Jacob Young
5060ab99c9 aarch64: add new from scratch self-hosted backend 2025-07-22 19:43:47 -07:00
Andrew Kelley
bd64bf0e47 std.mem: add byteSwapAllElements 2025-07-19 19:57:37 -07:00
Andrew Kelley
76d04c1662 zig fmt 2025-07-16 10:27:39 -07: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
1e1f026c83 std.mem.byteSwapAllFields: support slices 2025-07-07 22:43:52 -07:00
Ali Cheraghi
24bfefa75e std.mem.byteSwapAllFields: support untagged unions 2025-06-23 05:57:56 +02:00
Ali Cheraghi
872f68c9cb
rename spirv backend name
`stage2_spirv64` -> `stage2_spirv`
2025-06-16 13:22:19 +03:30
Alex Rønne Petersen
999777e73a compiler: Scaffold stage2_powerpc backend.
Nothing interesting here; literally just the bare minimum so I can work on this
on and off in a branch without worrying about merge conflicts in the non-backend
code.
2025-05-20 10:23:16 +02:00
Alex Rønne Petersen
bc3c50c21e
Merge pull request #23700 from sorairolake/rename-trims
chore(std.mem): Rename `trimLeft` and `trimRight` to `trimStart` and `trimEnd`
2025-05-12 17:11:52 +02:00
Shun Sakai
195471a98d
test(std.mem): Remove trimStart and trimEnd from test trim 2025-04-30 19:59:59 +09:00
Shun Sakai
5fc4448e45 chore(std.mem): Rename trimLeft and trimRight
Rename `trimLeft` to `trimStart`, and `trimRight` to `trimEnd`.
`trimLeft` and `trimRight` functions remain as deprecated aliases for
these new names.
2025-04-27 18:03:59 +09:00
dweiller
2e9c1553ef std: deprecate std.mem.copy{Forwards,Backwards} 2025-04-26 13:34:17 +10:00
Andrew Kelley
f32a5d349d std: eradicate u29 and embrace std.mem.Alignment 2025-04-13 02:20:32 -04:00
Alex Rønne Petersen
01b5e8b296
std: Disable some vector-related tests for hexagon.
See:

* https://github.com/llvm/llvm-project/issues/118879
* https://github.com/llvm/llvm-project/issues/134659
2025-04-11 02:28:35 +02:00
samy007
4595b1ee06 std.mem.bytesAsSlice: fix to support zero-bytes sized types
also added a test for json parsing of zero sized type
2025-03-24 22:08:05 +01:00
samy007
be483dabc8 fix: Allocator.remap now handles zero-bytes sized types 2025-03-24 22:05:57 +01:00
Andrew Kelley
faf256e429 std.mem.indexOfSentinel: don't ask the OS the page size
simply use page_size_min instead.

better yet, this logic would avoid depending on page size entirely...
2025-02-25 11:22:33 -08:00
David Rubin
fc77678339 mem: add @branchHint to indexOfSentinel
also seems to work around aarch64 LLVM miscompilation 🤔
2025-02-25 11:22:33 -08:00
Alex Rønne Petersen
c7e99b93a4 Revert "skip regressed LLVM 17 std lib test on powerpc"
This reverts commit 5b8af7a2a9.

Closes #16951.
2025-02-25 18:28:34 +01:00
LmanTW
13ad984b1f
std: add containsAtLeastScalar to mem (#22826) 2025-02-15 03:40:55 +01:00
andrewkraevskii
6fa7d5d4ad std.mem: add missing check to lastIndexOfLinear 2025-02-10 09:27:26 +01:00
Andrew Kelley
0d8166be3f std: update to new Allocator API 2025-02-06 14:23:23 -08:00
Andrew Kelley
5c63884539 add std.mem.Alignment API 2025-02-06 14:23:23 -08: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
Jacob Young
beadf702b8 x86_64: rewrite arithmetic 2025-01-16 20:42:08 -05:00
mlugg
9804cc8bc6
all: update to std.builtin.Type.{Pointer,Array,StructField} field renames 2025-01-16 12:49:58 +00:00
mlugg
d00e05f186
all: update to std.builtin.Type.Pointer.Size field renames
This was done by regex substitution with `sed`. I then manually went
over the entire diff and fixed any incorrect changes.

This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since
my regex happened to also trigger here. I opted to leave these changes
in, since they *are* a correct migration, even if they're not the one I
was trying to do!
2025-01-16 12:46:29 +00:00
axel escalada
ff4f2753e4
Improve first() documentation for split iterators
* remove  from doc., add explicit info when panic

* match convention for assert documentation, avoiding to use panic here
2025-01-04 13:45:12 +00:00
Andrew Kelley
4e380b89b8 std.mem: adjust semantics
* some kinds of types require comptime calls to eql
* don't rely on compare equal for undefined
2024-11-22 15:30:07 -08:00
Andrew Kelley
a3342cea18 std.mem.eql: make comparisons for zero-sized and non-sized types work
The `if (@sizeOf(T) == 0) return true;` check simply doesn't work for a number
of cases so that is removed and changed into `@sizeOf(T) != 0` and then
used in the `eqlBytes` check chain to make comparing `enum{}`s possible.

The rest special-cases for comptime-only types and undefined to make
those comparisons possible as well.

Fixes #19929
2024-11-22 15:10:51 -08:00
mlugg
24babde746
std.mem.asBytes: fix footgun when passing non-single pointer
I was just bitten by this footgun, where I actually wanted
`sliceAsBytes` but unintentionally used `asBytes`, which in practice
ignored all but the first element. Just add a comptime assertion to
trigger a compile error in this case.
2024-10-31 20:42:53 +00:00
poypoyan
0367f18cb9
std.mem.readVarInt: assert ReturnType is large enough (#20946)
Fixes #20521
2024-10-11 19:32:10 +00:00
PauloCampana
3e62cb5c90
Remove old deprecated symbols in std (#21584)
Also, actually run tests inside std/tar/writer.zig
2024-10-04 13:50:25 -07:00
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Jacob Young
ef11bc9899 Dwarf: rework self-hosted debug info from scratch
This is in preparation for incremental and actually being able to debug
executables built by the x86_64 backend.
2024-08-16 15:22:55 -04:00
clickingbuttons
da8fbcc2a9
std.mem.writeVarPackedInt: handle write_size == 0 (#19745)
Also move example comments into tests.
2024-08-15 06:03:29 +00:00
YANG Xudong
b8705ed652
loongarch: various architecture specific fixes (#20912) 2024-08-07 13:06:29 -07:00