Merge pull request #1169 from paoda/master

chore: update master version data
This commit is contained in:
Lee Cannon 2023-05-04 01:47:54 -07:00 committed by GitHub
commit 28863f4158
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 31 deletions

View File

@ -1060,52 +1060,40 @@ pub const builtins = [_]Builtin{
}, },
.{ .{
.name = "@memcpy", .name = "@memcpy",
.signature = "@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize) void", .signature = "@memcpy(noalias dest, noalias source) void",
.snippet = "@memcpy(${1:noalias dest: [*]u8}, ${2:noalias source: [*]const u8}, ${3:byte_count: usize})", .snippet = "@memcpy(${1:noalias dest}, ${2:noalias source})",
.documentation = .documentation =
\\This function copies bytes from one region of memory to another. `dest` and `source` are both pointers and must not overlap. \\This function copies bytes from one region of memory to another.
\\ \\
\\This function is a low level intrinsic with no safety mechanisms. Most code should not use this function, instead using something like this: \\`dest` must be a mutable slice, a mutable pointer to an array, or a mutable many-item [pointer](https://ziglang.org/documentation/master/#Pointers). It may have any alignment, and it may have any element type.
\\ \\
\\`for (dest, source[0..byte_count]) |*d, s| d.* = s;` \\Likewise, `source` must be a mutable slice, a mutable pointer to an array, or a mutable many-item [pointer](https://ziglang.org/documentation/master/#Pointers). It may have any alignment, and it may have any element type.
\\The optimizer is intelligent enough to turn the above snippet into a memcpy.
\\ \\
\\There is also a standard library function for this: \\The `source` element type must support [Type Coercion](https://ziglang.org/documentation/master/#Type-Coercion) into the `dest` element type. The element types may have different ABI size, however, that may incur a performance penalty.
\\ \\
\\```zig \\Similar to [for](https://ziglang.org/documentation/master/#for) loops, at least one of `source` and `dest` must provide a length, and if two lengths are provided, they must be equal.
\\const mem = @import("std").mem; \\
\\mem.copy(u8, dest[0..byte_count], source[0..byte_count]); \\Finally, the two memory regions must not overlap.
\\```
, ,
.arguments = &.{ .arguments = &.{
"noalias dest: [*]u8", "noalias dest",
"noalias source: [*]const u8", "noalias source",
"byte_count: usize",
}, },
}, },
.{ .{
.name = "@memset", .name = "@memset",
.signature = "@memset(dest: [*]u8, c: u8, byte_count: usize) void", .signature = "@memset(dest, elem) void",
.snippet = "@memset(${1:dest: [*]u8}, ${2:c: u8}, ${3:byte_count: usize})", .snippet = "@memset(${1:dest}, ${2:elem})",
.documentation = .documentation =
\\This function sets a region of memory to `c`. `dest` is a pointer. \\This function sets all the elements of a memory region to `elem`.
\\ \\
\\This function is a low level intrinsic with no safety mechanisms. Most code should not use this function, instead using something like this: \\`dest` must be a mutable slice or a mutable pointer to an array. It may have any alignment, and it may have any element type.
\\ \\
\\`for (dest[0..byte_count]) |*b| b.* = c;` \\`elem` is coerced to the element type of `dest`.
\\The optimizer is intelligent enough to turn the above snippet into a memset.
\\
\\There is also a standard library function for this:
\\
\\```zig
\\const mem = @import("std").mem;
\\mem.set(u8, dest, c);
\\```
, ,
.arguments = &.{ .arguments = &.{
"dest: [*]u8", "dest",
"c: u8", "elem",
"byte_count: usize",
}, },
}, },
.{ .{

View File

@ -55,7 +55,7 @@ test "inlayhints - builtin call" {
\\const _ = @intCast(<DestType>u32,<int>5); \\const _ = @intCast(<DestType>u32,<int>5);
); );
try testInlayHints( try testInlayHints(
\\const _ = @memcpy(<dest>null,<source>null,<byte_count>0); \\const _ = @memcpy(<dest>"",<source>"");
); );
try testInlayHints( try testInlayHints(