| ... | @@ -5169,6 +5169,34 @@ fn seq(c: u8) void { | ... | @@ -5169,6 +5169,34 @@ fn seq(c: u8) void { |
| 5169 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. | 5169 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. |
| 5170 | </p> | 5170 | </p> |
| 5171 | {#header_close#} | 5171 | {#header_close#} |
| | 5172 | {#header_open|@alignCast#} |
| | 5173 | <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: var) var{#endsyntax#}</pre> |
| | 5174 | <p> |
| | 5175 | {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#}, |
| | 5176 | {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#} |
| | 5177 | except with the alignment adjusted to the new value. |
| | 5178 | </p> |
| | 5179 | <p>A {#link|pointer alignment safety check|Incorrect Pointer Alignment#} is added |
| | 5180 | to the generated code to make sure the pointer is aligned as promised.</p> |
| | 5181 | |
| | 5182 | {#header_close#} |
| | 5183 | {#header_open|@alignOf#} |
| | 5184 | <pre>{#syntax#}@alignOf(comptime T: type) comptime_int{#endsyntax#}</pre> |
| | 5185 | <p> |
| | 5186 | This function returns the number of bytes that this type should be aligned to |
| | 5187 | for the current target to match the C ABI. When the child type of a pointer has |
| | 5188 | this alignment, the alignment can be omitted from the type. |
| | 5189 | </p> |
| | 5190 | <pre>{#syntax#}const assert = @import("std").debug.assert; |
| | 5191 | comptime { |
| | 5192 | assert(*u32 == *align(@alignOf(u32)) u32); |
| | 5193 | }{#endsyntax#}</pre> |
| | 5194 | <p> |
| | 5195 | The result is a target-specific compile time constant. It is guaranteed to be |
| | 5196 | less than or equal to {#link|@sizeOf(T)|@sizeOf#}. |
| | 5197 | </p> |
| | 5198 | {#see_also|Alignment#} |
| | 5199 | {#header_close#} |
| 5172 | {#header_open|@ArgType#} | 5200 | {#header_open|@ArgType#} |
| 5173 | <pre>{#syntax#}@ArgType(comptime T: type, comptime n: usize) type{#endsyntax#}</pre> | 5201 | <pre>{#syntax#}@ArgType(comptime T: type, comptime n: usize) type{#endsyntax#}</pre> |
| 5174 | <p> | 5202 | <p> |
| ... | @@ -5241,6 +5269,7 @@ fn seq(c: u8) void { | ... | @@ -5241,6 +5269,7 @@ fn seq(c: u8) void { |
| 5241 | Works at compile-time if {#syntax#}value{#endsyntax#} is known at compile time. It's a compile error to bitcast a struct to a scalar type of the same size since structs have undefined layout. However if the struct is packed then it works. | 5269 | Works at compile-time if {#syntax#}value{#endsyntax#} is known at compile time. It's a compile error to bitcast a struct to a scalar type of the same size since structs have undefined layout. However if the struct is packed then it works. |
| 5242 | </p> | 5270 | </p> |
| 5243 | {#header_close#} | 5271 | {#header_close#} |
| | 5272 | |
| 5244 | {#header_open|@bitOffsetOf#} | 5273 | {#header_open|@bitOffsetOf#} |
| 5245 | <pre>{#syntax#}@bitOffsetOf(comptime T: type, comptime field_name: [] const u8) comptime_int{#endsyntax#}</pre> | 5274 | <pre>{#syntax#}@bitOffsetOf(comptime T: type, comptime field_name: [] const u8) comptime_int{#endsyntax#}</pre> |
| 5246 | <p> | 5275 | <p> |
| ... | @@ -5253,52 +5282,6 @@ fn seq(c: u8) void { | ... | @@ -5253,52 +5282,6 @@ fn seq(c: u8) void { |
| 5253 | </p> | 5282 | </p> |
| 5254 | {#see_also|@byteOffsetOf#} | 5283 | {#see_also|@byteOffsetOf#} |
| 5255 | {#header_close#} | 5284 | {#header_close#} |
| 5256 | {#header_open|@breakpoint#} | | |
| 5257 | <pre>{#syntax#}@breakpoint(){#endsyntax#}</pre> | | |
| 5258 | <p> | | |
| 5259 | This function inserts a platform-specific debug trap instruction which causes | | |
| 5260 | debuggers to break there. | | |
| 5261 | </p> | | |
| 5262 | <p> | | |
| 5263 | This function is only valid within function scope. | | |
| 5264 | </p> | | |
| 5265 | | | |
| 5266 | {#header_close#} | | |
| 5267 | {#header_open|@byteOffsetOf#} | | |
| 5268 | <pre>{#syntax#}@byteOffsetOf(comptime T: type, comptime field_name: [] const u8) comptime_int{#endsyntax#}</pre> | | |
| 5269 | <p> | | |
| 5270 | Returns the byte offset of a field relative to its containing struct. | | |
| 5271 | </p> | | |
| 5272 | {#see_also|@bitOffsetOf#} | | |
| 5273 | {#header_close#} | | |
| 5274 | {#header_open|@alignCast#} | | |
| 5275 | <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: var) var{#endsyntax#}</pre> | | |
| 5276 | <p> | | |
| 5277 | {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#}, | | |
| 5278 | {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#} | | |
| 5279 | except with the alignment adjusted to the new value. | | |
| 5280 | </p> | | |
| 5281 | <p>A {#link|pointer alignment safety check|Incorrect Pointer Alignment#} is added | | |
| 5282 | to the generated code to make sure the pointer is aligned as promised.</p> | | |
| 5283 | | | |
| 5284 | {#header_close#} | | |
| 5285 | {#header_open|@alignOf#} | | |
| 5286 | <pre>{#syntax#}@alignOf(comptime T: type) comptime_int{#endsyntax#}</pre> | | |
| 5287 | <p> | | |
| 5288 | This function returns the number of bytes that this type should be aligned to | | |
| 5289 | for the current target to match the C ABI. When the child type of a pointer has | | |
| 5290 | this alignment, the alignment can be omitted from the type. | | |
| 5291 | </p> | | |
| 5292 | <pre>{#syntax#}const assert = @import("std").debug.assert; | | |
| 5293 | comptime { | | |
| 5294 | assert(*u32 == *align(@alignOf(u32)) u32); | | |
| 5295 | }{#endsyntax#}</pre> | | |
| 5296 | <p> | | |
| 5297 | The result is a target-specific compile time constant. It is guaranteed to be | | |
| 5298 | less than or equal to {#link|@sizeOf(T)|@sizeOf#}. | | |
| 5299 | </p> | | |
| 5300 | {#see_also|Alignment#} | | |
| 5301 | {#header_close#} | | |
| 5302 | | 5285 | |
| 5303 | {#header_open|@boolToInt#} | 5286 | {#header_open|@boolToInt#} |
| 5304 | <pre>{#syntax#}@boolToInt(value: bool) u1{#endsyntax#}</pre> | 5287 | <pre>{#syntax#}@boolToInt(value: bool) u1{#endsyntax#}</pre> |
| ... | @@ -5312,6 +5295,18 @@ comptime { | ... | @@ -5312,6 +5295,18 @@ comptime { |
| 5312 | </p> | 5295 | </p> |
| 5313 | {#header_close#} | 5296 | {#header_close#} |
| 5314 | | 5297 | |
| | 5298 | {#header_open|@breakpoint#} |
| | 5299 | <pre>{#syntax#}@breakpoint(){#endsyntax#}</pre> |
| | 5300 | <p> |
| | 5301 | This function inserts a platform-specific debug trap instruction which causes |
| | 5302 | debuggers to break there. |
| | 5303 | </p> |
| | 5304 | <p> |
| | 5305 | This function is only valid within function scope. |
| | 5306 | </p> |
| | 5307 | |
| | 5308 | {#header_close#} |
| | 5309 | |
| 5315 | {#header_open|@bswap#} | 5310 | {#header_open|@bswap#} |
| 5316 | <pre>{#syntax#}@bswap(comptime T: type, value: T) T{#endsyntax#}</pre> | 5311 | <pre>{#syntax#}@bswap(comptime T: type, value: T) T{#endsyntax#}</pre> |
| 5317 | <p>{#syntax#}T{#endsyntax#} must be an integer type with bit count evenly divisible by 8.</p> | 5312 | <p>{#syntax#}T{#endsyntax#} must be an integer type with bit count evenly divisible by 8.</p> |
| ... | @@ -5321,6 +5316,14 @@ comptime { | ... | @@ -5321,6 +5316,14 @@ comptime { |
| 5321 | </p> | 5316 | </p> |
| 5322 | {#header_close#} | 5317 | {#header_close#} |
| 5323 | | 5318 | |
| | 5319 | {#header_open|@byteOffsetOf#} |
| | 5320 | <pre>{#syntax#}@byteOffsetOf(comptime T: type, comptime field_name: [] const u8) comptime_int{#endsyntax#}</pre> |
| | 5321 | <p> |
| | 5322 | Returns the byte offset of a field relative to its containing struct. |
| | 5323 | </p> |
| | 5324 | {#see_also|@bitOffsetOf#} |
| | 5325 | {#header_close#} |
| | 5326 | |
| 5324 | {#header_open|@bytesToSlice#} | 5327 | {#header_open|@bytesToSlice#} |
| 5325 | <pre>{#syntax#}@bytesToSlice(comptime Element: type, bytes: []u8) []Element{#endsyntax#}</pre> | 5328 | <pre>{#syntax#}@bytesToSlice(comptime Element: type, bytes: []u8) []Element{#endsyntax#}</pre> |
| 5326 | <p> | 5329 | <p> |
| ... | @@ -5387,17 +5390,7 @@ comptime { | ... | @@ -5387,17 +5390,7 @@ comptime { |
| 5387 | </p> | 5390 | </p> |
| 5388 | {#see_also|Import from C Header File|@cImport|@cDefine|@cUndef#} | 5391 | {#see_also|Import from C Header File|@cImport|@cDefine|@cUndef#} |
| 5389 | {#header_close#} | 5392 | {#header_close#} |
| 5390 | {#header_open|@cUndef#} | 5393 | |
| 5391 | <pre>{#syntax#}@cUndef(comptime name: []u8){#endsyntax#}</pre> | | |
| 5392 | <p> | | |
| 5393 | This function can only occur inside {#syntax#}@cImport{#endsyntax#}. | | |
| 5394 | </p> | | |
| 5395 | <p> | | |
| 5396 | This appends <code>#undef $name</code> to the {#syntax#}@cImport{#endsyntax#} | | |
| 5397 | temporary buffer. | | |
| 5398 | </p> | | |
| 5399 | {#see_also|Import from C Header File|@cImport|@cDefine|@cInclude#} | | |
| 5400 | {#header_close#} | | |
| 5401 | {#header_open|@clz#} | 5394 | {#header_open|@clz#} |
| 5402 | <pre>{#syntax#}@clz(x: T) U{#endsyntax#}</pre> | 5395 | <pre>{#syntax#}@clz(x: T) U{#endsyntax#}</pre> |
| 5403 | <p> | 5396 | <p> |
| ... | @@ -5413,6 +5406,7 @@ comptime { | ... | @@ -5413,6 +5406,7 @@ comptime { |
| 5413 | </p> | 5406 | </p> |
| 5414 | {#see_also|@ctz|@popCount#} | 5407 | {#see_also|@ctz|@popCount#} |
| 5415 | {#header_close#} | 5408 | {#header_close#} |
| | 5409 | |
| 5416 | {#header_open|@cmpxchgStrong#} | 5410 | {#header_open|@cmpxchgStrong#} |
| 5417 | <pre>{#syntax#}@cmpxchgStrong(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T{#endsyntax#}</pre> | 5411 | <pre>{#syntax#}@cmpxchgStrong(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T{#endsyntax#}</pre> |
| 5418 | <p> | 5412 | <p> |
| ... | @@ -5468,6 +5462,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val | ... | @@ -5468,6 +5462,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5468 | <p>{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> | 5462 | <p>{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> |
| 5469 | {#see_also|Compile Variables|cmpxchgStrong#} | 5463 | {#see_also|Compile Variables|cmpxchgStrong#} |
| 5470 | {#header_close#} | 5464 | {#header_close#} |
| | 5465 | |
| 5471 | {#header_open|@compileError#} | 5466 | {#header_open|@compileError#} |
| 5472 | <pre>{#syntax#}@compileError(comptime msg: []u8){#endsyntax#}</pre> | 5467 | <pre>{#syntax#}@compileError(comptime msg: []u8){#endsyntax#}</pre> |
| 5473 | <p> | 5468 | <p> |
| ... | @@ -5480,6 +5475,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val | ... | @@ -5480,6 +5475,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5480 | and {#syntax#}comptime{#endsyntax#} functions. | 5475 | and {#syntax#}comptime{#endsyntax#} functions. |
| 5481 | </p> | 5476 | </p> |
| 5482 | {#header_close#} | 5477 | {#header_close#} |
| | 5478 | |
| 5483 | {#header_open|@compileLog#} | 5479 | {#header_open|@compileLog#} |
| 5484 | <pre>{#syntax#}@compileLog(args: ...){#endsyntax#}</pre> | 5480 | <pre>{#syntax#}@compileLog(args: ...){#endsyntax#}</pre> |
| 5485 | <p> | 5481 | <p> |
| ... | @@ -5534,6 +5530,7 @@ test "main" { | ... | @@ -5534,6 +5530,7 @@ test "main" { |
| 5534 | } | 5530 | } |
| 5535 | {#code_end#} | 5531 | {#code_end#} |
| 5536 | {#header_close#} | 5532 | {#header_close#} |
| | 5533 | |
| 5537 | {#header_open|@ctz#} | 5534 | {#header_open|@ctz#} |
| 5538 | <pre>{#syntax#}@ctz(x: T) U{#endsyntax#}</pre> | 5535 | <pre>{#syntax#}@ctz(x: T) U{#endsyntax#}</pre> |
| 5539 | <p> | 5536 | <p> |
| ... | @@ -5549,6 +5546,19 @@ test "main" { | ... | @@ -5549,6 +5546,19 @@ test "main" { |
| 5549 | </p> | 5546 | </p> |
| 5550 | {#see_also|@clz|@popCount#} | 5547 | {#see_also|@clz|@popCount#} |
| 5551 | {#header_close#} | 5548 | {#header_close#} |
| | 5549 | |
| | 5550 | {#header_open|@cUndef#} |
| | 5551 | <pre>{#syntax#}@cUndef(comptime name: []u8){#endsyntax#}</pre> |
| | 5552 | <p> |
| | 5553 | This function can only occur inside {#syntax#}@cImport{#endsyntax#}. |
| | 5554 | </p> |
| | 5555 | <p> |
| | 5556 | This appends <code>#undef $name</code> to the {#syntax#}@cImport{#endsyntax#} |
| | 5557 | temporary buffer. |
| | 5558 | </p> |
| | 5559 | {#see_also|Import from C Header File|@cImport|@cDefine|@cInclude#} |
| | 5560 | {#header_close#} |
| | 5561 | |
| 5552 | {#header_open|@divExact#} | 5562 | {#header_open|@divExact#} |
| 5553 | <pre>{#syntax#}@divExact(numerator: T, denominator: T) T{#endsyntax#}</pre> | 5563 | <pre>{#syntax#}@divExact(numerator: T, denominator: T) T{#endsyntax#}</pre> |
| 5554 | <p> | 5564 | <p> |
| ... | @@ -5615,14 +5625,6 @@ test "main" { | ... | @@ -5615,14 +5625,6 @@ test "main" { |
| 5615 | {#see_also|@intToEnum#} | 5625 | {#see_also|@intToEnum#} |
| 5616 | {#header_close#} | 5626 | {#header_close#} |
| 5617 | | 5627 | |
| 5618 | {#header_open|@errSetCast#} | | |
| 5619 | <pre>{#syntax#}@errSetCast(comptime T: DestType, value: var) DestType{#endsyntax#}</pre> | | |
| 5620 | <p> | | |
| 5621 | Converts an error value from one error set to another error set. Attempting to convert an error | | |
| 5622 | which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}. | | |
| 5623 | </p> | | |
| 5624 | {#header_close#} | | |
| 5625 | | | |
| 5626 | {#header_open|@errorName#} | 5628 | {#header_open|@errorName#} |
| 5627 | <pre>{#syntax#}@errorName(err: anyerror) []const u8{#endsyntax#}</pre> | 5629 | <pre>{#syntax#}@errorName(err: anyerror) []const u8{#endsyntax#}</pre> |
| 5628 | <p> | 5630 | <p> |
| ... | @@ -5665,6 +5667,14 @@ test "main" { | ... | @@ -5665,6 +5667,14 @@ test "main" { |
| 5665 | {#see_also|@intToError#} | 5667 | {#see_also|@intToError#} |
| 5666 | {#header_close#} | 5668 | {#header_close#} |
| 5667 | | 5669 | |
| | 5670 | {#header_open|@errSetCast#} |
| | 5671 | <pre>{#syntax#}@errSetCast(comptime T: DestType, value: var) DestType{#endsyntax#}</pre> |
| | 5672 | <p> |
| | 5673 | Converts an error value from one error set to another error set. Attempting to convert an error |
| | 5674 | which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}. |
| | 5675 | </p> |
| | 5676 | {#header_close#} |
| | 5677 | |
| 5668 | {#header_open|@export#} | 5678 | {#header_open|@export#} |
| 5669 | <pre>{#syntax#}@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) []const u8{#endsyntax#}</pre> | 5679 | <pre>{#syntax#}@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) []const u8{#endsyntax#}</pre> |
| 5670 | <p> | 5680 | <p> |
| ... | @@ -5733,6 +5743,7 @@ test "main" { | ... | @@ -5733,6 +5743,7 @@ test "main" { |
| 5733 | This function is only valid within function scope. | 5743 | This function is only valid within function scope. |
| 5734 | </p> | 5744 | </p> |
| 5735 | {#header_close#} | 5745 | {#header_close#} |
| | 5746 | |
| 5736 | {#header_open|@handle#} | 5747 | {#header_open|@handle#} |
| 5737 | <pre>{#syntax#}@handle(){#endsyntax#}</pre> | 5748 | <pre>{#syntax#}@handle(){#endsyntax#}</pre> |
| 5738 | <p> | 5749 | <p> |
| ... | @@ -5743,6 +5754,7 @@ test "main" { | ... | @@ -5743,6 +5754,7 @@ test "main" { |
| 5743 | This function is only valid within an async function scope. | 5754 | This function is only valid within an async function scope. |
| 5744 | </p> | 5755 | </p> |
| 5745 | {#header_close#} | 5756 | {#header_close#} |
| | 5757 | |
| 5746 | {#header_open|@import#} | 5758 | {#header_open|@import#} |
| 5747 | <pre>{#syntax#}@import(comptime path: []u8) (namespace){#endsyntax#}</pre> | 5759 | <pre>{#syntax#}@import(comptime path: []u8) (namespace){#endsyntax#}</pre> |
| 5748 | <p> | 5760 | <p> |
| ... | @@ -5763,6 +5775,7 @@ test "main" { | ... | @@ -5763,6 +5775,7 @@ test "main" { |
| 5763 | </ul> | 5775 | </ul> |
| 5764 | {#see_also|Compile Variables|@embedFile#} | 5776 | {#see_also|Compile Variables|@embedFile#} |
| 5765 | {#header_close#} | 5777 | {#header_close#} |
| | 5778 | |
| 5766 | {#header_open|@inlineCall#} | 5779 | {#header_open|@inlineCall#} |
| 5767 | <pre>{#syntax#}@inlineCall(function: X, args: ...) Y{#endsyntax#}</pre> | 5780 | <pre>{#syntax#}@inlineCall(function: X, args: ...) Y{#endsyntax#}</pre> |
| 5768 | <p> | 5781 | <p> |
| ... | @@ -5842,6 +5855,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } | ... | @@ -5842,6 +5855,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } |
| 5842 | bit count for an integer type is {#syntax#}65535{#endsyntax#}. | 5855 | bit count for an integer type is {#syntax#}65535{#endsyntax#}. |
| 5843 | </p> | 5856 | </p> |
| 5844 | {#header_close#} | 5857 | {#header_close#} |
| | 5858 | |
| 5845 | {#header_open|@memberCount#} | 5859 | {#header_open|@memberCount#} |
| 5846 | <pre>{#syntax#}@memberCount(comptime T: type) comptime_int{#endsyntax#}</pre> | 5860 | <pre>{#syntax#}@memberCount(comptime T: type) comptime_int{#endsyntax#}</pre> |
| 5847 | <p> | 5861 | <p> |
| ... | @@ -5868,6 +5882,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } | ... | @@ -5868,6 +5882,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } |
| 5868 | <pre>{#syntax#}@memberType(comptime T: type, comptime index: usize) type{#endsyntax#}</pre> | 5882 | <pre>{#syntax#}@memberType(comptime T: type, comptime index: usize) type{#endsyntax#}</pre> |
| 5869 | <p>Returns the field type of a struct or union.</p> | 5883 | <p>Returns the field type of a struct or union.</p> |
| 5870 | {#header_close#} | 5884 | {#header_close#} |
| | 5885 | |
| 5871 | {#header_open|@memcpy#} | 5886 | {#header_open|@memcpy#} |
| 5872 | <pre>{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}</pre> | 5887 | <pre>{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}</pre> |
| 5873 | <p> | 5888 | <p> |
| ... | @@ -5886,6 +5901,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } | ... | @@ -5886,6 +5901,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } |
| 5886 | <pre>{#syntax#}const mem = @import("std").mem; | 5901 | <pre>{#syntax#}const mem = @import("std").mem; |
| 5887 | mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre> | 5902 | mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre> |
| 5888 | {#header_close#} | 5903 | {#header_close#} |
| | 5904 | |
| 5889 | {#header_open|@memset#} | 5905 | {#header_open|@memset#} |
| 5890 | <pre>{#syntax#}@memset(dest: [*]u8, c: u8, byte_count: usize){#endsyntax#}</pre> | 5906 | <pre>{#syntax#}@memset(dest: [*]u8, c: u8, byte_count: usize){#endsyntax#}</pre> |
| 5891 | <p> | 5907 | <p> |
| ... | @@ -5903,6 +5919,7 @@ mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre> | ... | @@ -5903,6 +5919,7 @@ mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre> |
| 5903 | <pre>{#syntax#}const mem = @import("std").mem; | 5919 | <pre>{#syntax#}const mem = @import("std").mem; |
| 5904 | mem.set(u8, dest, c);{#endsyntax#}</pre> | 5920 | mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 5905 | {#header_close#} | 5921 | {#header_close#} |
| | 5922 | |
| 5906 | {#header_open|@mod#} | 5923 | {#header_open|@mod#} |
| 5907 | <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre> | 5924 | <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre> |
| 5908 | <p> | 5925 | <p> |
| ... | @@ -5916,6 +5933,7 @@ mem.set(u8, dest, c);{#endsyntax#}</pre> | ... | @@ -5916,6 +5933,7 @@ mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 5916 | <p>For a function that returns an error code, see {#syntax#}@import("std").math.mod{#endsyntax#}.</p> | 5933 | <p>For a function that returns an error code, see {#syntax#}@import("std").math.mod{#endsyntax#}.</p> |
| 5917 | {#see_also|@rem#} | 5934 | {#see_also|@rem#} |
| 5918 | {#header_close#} | 5935 | {#header_close#} |
| | 5936 | |
| 5919 | {#header_open|@mulWithOverflow#} | 5937 | {#header_open|@mulWithOverflow#} |
| 5920 | <pre>{#syntax#}@mulWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre> | 5938 | <pre>{#syntax#}@mulWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre> |
| 5921 | <p> | 5939 | <p> |
| ... | @@ -5924,6 +5942,7 @@ mem.set(u8, dest, c);{#endsyntax#}</pre> | ... | @@ -5924,6 +5942,7 @@ mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 5924 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. | 5942 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. |
| 5925 | </p> | 5943 | </p> |
| 5926 | {#header_close#} | 5944 | {#header_close#} |
| | 5945 | |
| 5927 | {#header_open|@newStackCall#} | 5946 | {#header_open|@newStackCall#} |
| 5928 | <pre>{#syntax#}@newStackCall(new_stack: []u8, function: var, args: ...) var{#endsyntax#}</pre> | 5947 | <pre>{#syntax#}@newStackCall(new_stack: []u8, function: var, args: ...) var{#endsyntax#}</pre> |
| 5929 | <p> | 5948 | <p> |
| ... | @@ -5960,6 +5979,7 @@ fn targetFunction(x: i32) usize { | ... | @@ -5960,6 +5979,7 @@ fn targetFunction(x: i32) usize { |
| 5960 | } | 5979 | } |
| 5961 | {#code_end#} | 5980 | {#code_end#} |
| 5962 | {#header_close#} | 5981 | {#header_close#} |
| | 5982 | |
| 5963 | {#header_open|@noInlineCall#} | 5983 | {#header_open|@noInlineCall#} |
| 5964 | <pre>{#syntax#}@noInlineCall(function: var, args: ...) var{#endsyntax#}</pre> | 5984 | <pre>{#syntax#}@noInlineCall(function: var, args: ...) var{#endsyntax#}</pre> |
| 5965 | <p> | 5985 | <p> |
| ... | @@ -5982,6 +6002,7 @@ fn add(a: i32, b: i32) i32 { | ... | @@ -5982,6 +6002,7 @@ fn add(a: i32, b: i32) i32 { |
| 5982 | </p> | 6002 | </p> |
| 5983 | {#see_also|@inlineCall#} | 6003 | {#see_also|@inlineCall#} |
| 5984 | {#header_close#} | 6004 | {#header_close#} |
| | 6005 | |
| 5985 | {#header_open|@OpaqueType#} | 6006 | {#header_open|@OpaqueType#} |
| 5986 | <pre>{#syntax#}@OpaqueType() type{#endsyntax#}</pre> | 6007 | <pre>{#syntax#}@OpaqueType() type{#endsyntax#}</pre> |
| 5987 | <p> | 6008 | <p> |
| ... | @@ -6005,6 +6026,7 @@ test "call foo" { | ... | @@ -6005,6 +6026,7 @@ test "call foo" { |
| 6005 | } | 6026 | } |
| 6006 | {#code_end#} | 6027 | {#code_end#} |
| 6007 | {#header_close#} | 6028 | {#header_close#} |
| | 6029 | |
| 6008 | {#header_open|@panic#} | 6030 | {#header_open|@panic#} |
| 6009 | <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre> | 6031 | <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre> |
| 6010 | <p> | 6032 | <p> |
| ... | @@ -6021,6 +6043,7 @@ test "call foo" { | ... | @@ -6021,6 +6043,7 @@ test "call foo" { |
| 6021 | </ul> | 6043 | </ul> |
| 6022 | {#see_also|Root Source File#} | 6044 | {#see_also|Root Source File#} |
| 6023 | {#header_close#} | 6045 | {#header_close#} |
| | 6046 | |
| 6024 | {#header_open|@popCount#} | 6047 | {#header_open|@popCount#} |
| 6025 | <pre>{#syntax#}@popCount(integer: var) var{#endsyntax#}</pre> | 6048 | <pre>{#syntax#}@popCount(integer: var) var{#endsyntax#}</pre> |
| 6026 | <p>Counts the number of bits set in an integer.</p> | 6049 | <p>Counts the number of bits set in an integer.</p> |
| ... | @@ -6031,12 +6054,14 @@ test "call foo" { | ... | @@ -6031,12 +6054,14 @@ test "call foo" { |
| 6031 | </p> | 6054 | </p> |
| 6032 | {#see_also|@ctz|@clz#} | 6055 | {#see_also|@ctz|@clz#} |
| 6033 | {#header_close#} | 6056 | {#header_close#} |
| | 6057 | |
| 6034 | {#header_open|@ptrCast#} | 6058 | {#header_open|@ptrCast#} |
| 6035 | <pre>{#syntax#}@ptrCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre> | 6059 | <pre>{#syntax#}@ptrCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre> |
| 6036 | <p> | 6060 | <p> |
| 6037 | Converts a pointer of one type to a pointer of another type. | 6061 | Converts a pointer of one type to a pointer of another type. |
| 6038 | </p> | 6062 | </p> |
| 6039 | {#header_close#} | 6063 | {#header_close#} |
| | 6064 | |
| 6040 | {#header_open|@ptrToInt#} | 6065 | {#header_open|@ptrToInt#} |
| 6041 | <pre>{#syntax#}@ptrToInt(value: var) usize{#endsyntax#}</pre> | 6066 | <pre>{#syntax#}@ptrToInt(value: var) usize{#endsyntax#}</pre> |
| 6042 | <p> | 6067 | <p> |
| ... | @@ -6051,6 +6076,7 @@ test "call foo" { | ... | @@ -6051,6 +6076,7 @@ test "call foo" { |
| 6051 | <p>To convert the other way, use {#link|@intToPtr#}</p> | 6076 | <p>To convert the other way, use {#link|@intToPtr#}</p> |
| 6052 | | 6077 | |
| 6053 | {#header_close#} | 6078 | {#header_close#} |
| | 6079 | |
| 6054 | {#header_open|@rem#} | 6080 | {#header_open|@rem#} |
| 6055 | <pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre> | 6081 | <pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre> |
| 6056 | <p> | 6082 | <p> |
| ... | @@ -6064,6 +6090,7 @@ test "call foo" { | ... | @@ -6064,6 +6090,7 @@ test "call foo" { |
| 6064 | <p>For a function that returns an error code, see {#syntax#}@import("std").math.rem{#endsyntax#}.</p> | 6090 | <p>For a function that returns an error code, see {#syntax#}@import("std").math.rem{#endsyntax#}.</p> |
| 6065 | {#see_also|@mod#} | 6091 | {#see_also|@mod#} |
| 6066 | {#header_close#} | 6092 | {#header_close#} |
| | 6093 | |
| 6067 | {#header_open|@returnAddress#} | 6094 | {#header_open|@returnAddress#} |
| 6068 | <pre>{#syntax#}@returnAddress(){#endsyntax#}</pre> | 6095 | <pre>{#syntax#}@returnAddress(){#endsyntax#}</pre> |
| 6069 | <p> | 6096 | <p> |
| ... | @@ -6084,19 +6111,14 @@ test "call foo" { | ... | @@ -6084,19 +6111,14 @@ test "call foo" { |
| 6084 | Ensures that a function will have a stack alignment of at least {#syntax#}alignment{#endsyntax#} bytes. | 6111 | Ensures that a function will have a stack alignment of at least {#syntax#}alignment{#endsyntax#} bytes. |
| 6085 | </p> | 6112 | </p> |
| 6086 | {#header_close#} | 6113 | {#header_close#} |
| | 6114 | |
| 6087 | {#header_open|@setCold#} | 6115 | {#header_open|@setCold#} |
| 6088 | <pre>{#syntax#}@setCold(is_cold: bool){#endsyntax#}</pre> | 6116 | <pre>{#syntax#}@setCold(is_cold: bool){#endsyntax#}</pre> |
| 6089 | <p> | 6117 | <p> |
| 6090 | Tells the optimizer that a function is rarely called. | 6118 | Tells the optimizer that a function is rarely called. |
| 6091 | </p> | 6119 | </p> |
| 6092 | {#header_close#} | 6120 | {#header_close#} |
| 6093 | {#header_open|@setRuntimeSafety#} | | |
| 6094 | <pre>{#syntax#}@setRuntimeSafety(safety_on: bool){#endsyntax#}</pre> | | |
| 6095 | <p> | | |
| 6096 | Sets whether runtime safety checks are on for the scope that contains the function call. | | |
| 6097 | </p> | | |
| 6098 | | 6121 | |
| 6099 | {#header_close#} | | |
| 6100 | {#header_open|@setEvalBranchQuota#} | 6122 | {#header_open|@setEvalBranchQuota#} |
| 6101 | <pre>{#syntax#}@setEvalBranchQuota(new_quota: usize){#endsyntax#}</pre> | 6123 | <pre>{#syntax#}@setEvalBranchQuota(new_quota: usize){#endsyntax#}</pre> |
| 6102 | <p> | 6124 | <p> |
| ... | @@ -6131,6 +6153,7 @@ test "foo" { | ... | @@ -6131,6 +6153,7 @@ test "foo" { |
| 6131 | | 6153 | |
| 6132 | {#see_also|comptime#} | 6154 | {#see_also|comptime#} |
| 6133 | {#header_close#} | 6155 | {#header_close#} |
| | 6156 | |
| 6134 | {#header_open|@setFloatMode#} | 6157 | {#header_open|@setFloatMode#} |
| 6135 | <pre>{#syntax#}@setFloatMode(mode: @import("builtin").FloatMode){#endsyntax#}</pre> | 6158 | <pre>{#syntax#}@setFloatMode(mode: @import("builtin").FloatMode){#endsyntax#}</pre> |
| 6136 | <p> | 6159 | <p> |
| ... | @@ -6165,6 +6188,7 @@ pub const FloatMode = enum { | ... | @@ -6165,6 +6188,7 @@ pub const FloatMode = enum { |
| 6165 | </p> | 6188 | </p> |
| 6166 | {#see_also|Floating Point Operations#} | 6189 | {#see_also|Floating Point Operations#} |
| 6167 | {#header_close#} | 6190 | {#header_close#} |
| | 6191 | |
| 6168 | {#header_open|@setGlobalLinkage#} | 6192 | {#header_open|@setGlobalLinkage#} |
| 6169 | <pre>{#syntax#}@setGlobalLinkage(global_variable_name, comptime linkage: GlobalLinkage){#endsyntax#}</pre> | 6193 | <pre>{#syntax#}@setGlobalLinkage(global_variable_name, comptime linkage: GlobalLinkage){#endsyntax#}</pre> |
| 6170 | <p> | 6194 | <p> |
| ... | @@ -6172,6 +6196,15 @@ pub const FloatMode = enum { | ... | @@ -6172,6 +6196,15 @@ pub const FloatMode = enum { |
| 6172 | </p> | 6196 | </p> |
| 6173 | {#see_also|Compile Variables#} | 6197 | {#see_also|Compile Variables#} |
| 6174 | {#header_close#} | 6198 | {#header_close#} |
| | 6199 | |
| | 6200 | {#header_open|@setRuntimeSafety#} |
| | 6201 | <pre>{#syntax#}@setRuntimeSafety(safety_on: bool){#endsyntax#}</pre> |
| | 6202 | <p> |
| | 6203 | Sets whether runtime safety checks are on for the scope that contains the function call. |
| | 6204 | </p> |
| | 6205 | |
| | 6206 | {#header_close#} |
| | 6207 | |
| 6175 | {#header_open|@shlExact#} | 6208 | {#header_open|@shlExact#} |
| 6176 | <pre>{#syntax#}@shlExact(value: T, shift_amt: Log2T) T{#endsyntax#}</pre> | 6209 | <pre>{#syntax#}@shlExact(value: T, shift_amt: Log2T) T{#endsyntax#}</pre> |
| 6177 | <p> | 6210 | <p> |
| ... | @@ -6184,6 +6217,7 @@ pub const FloatMode = enum { | ... | @@ -6184,6 +6217,7 @@ pub const FloatMode = enum { |
| 6184 | </p> | 6217 | </p> |
| 6185 | {#see_also|@shrExact|@shlWithOverflow#} | 6218 | {#see_also|@shrExact|@shlWithOverflow#} |
| 6186 | {#header_close#} | 6219 | {#header_close#} |
| | 6220 | |
| 6187 | {#header_open|@shlWithOverflow#} | 6221 | {#header_open|@shlWithOverflow#} |
| 6188 | <pre>{#syntax#}@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: *T) bool{#endsyntax#}</pre> | 6222 | <pre>{#syntax#}@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: *T) bool{#endsyntax#}</pre> |
| 6189 | <p> | 6223 | <p> |
| ... | @@ -6197,6 +6231,7 @@ pub const FloatMode = enum { | ... | @@ -6197,6 +6231,7 @@ pub const FloatMode = enum { |
| 6197 | </p> | 6231 | </p> |
| 6198 | {#see_also|@shlExact|@shrExact#} | 6232 | {#see_also|@shlExact|@shrExact#} |
| 6199 | {#header_close#} | 6233 | {#header_close#} |
| | 6234 | |
| 6200 | {#header_open|@shrExact#} | 6235 | {#header_open|@shrExact#} |
| 6201 | <pre>{#syntax#}@shrExact(value: T, shift_amt: Log2T) T{#endsyntax#}</pre> | 6236 | <pre>{#syntax#}@shrExact(value: T, shift_amt: Log2T) T{#endsyntax#}</pre> |
| 6202 | <p> | 6237 | <p> |
| ... | @@ -6238,6 +6273,7 @@ pub const FloatMode = enum { | ... | @@ -6238,6 +6273,7 @@ pub const FloatMode = enum { |
| 6238 | This is a low-level intrinsic. Most code can use {#syntax#}std.math.sqrt{#endsyntax#} instead. | 6273 | This is a low-level intrinsic. Most code can use {#syntax#}std.math.sqrt{#endsyntax#} instead. |
| 6239 | </p> | 6274 | </p> |
| 6240 | {#header_close#} | 6275 | {#header_close#} |
| | 6276 | |
| 6241 | {#header_open|@subWithOverflow#} | 6277 | {#header_open|@subWithOverflow#} |
| 6242 | <pre>{#syntax#}@subWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre> | 6278 | <pre>{#syntax#}@subWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre> |
| 6243 | <p> | 6279 | <p> |
| ... | @@ -6246,12 +6282,14 @@ pub const FloatMode = enum { | ... | @@ -6246,12 +6282,14 @@ pub const FloatMode = enum { |
| 6246 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. | 6282 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. |
| 6247 | </p> | 6283 | </p> |
| 6248 | {#header_close#} | 6284 | {#header_close#} |
| | 6285 | |
| 6249 | {#header_open|@tagName#} | 6286 | {#header_open|@tagName#} |
| 6250 | <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre> | 6287 | <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre> |
| 6251 | <p> | 6288 | <p> |
| 6252 | Converts an enum value or union value to a slice of bytes representing the name. | 6289 | Converts an enum value or union value to a slice of bytes representing the name. |
| 6253 | </p> | 6290 | </p> |
| 6254 | {#header_close#} | 6291 | {#header_close#} |
| | 6292 | |
| 6255 | {#header_open|@TagType#} | 6293 | {#header_open|@TagType#} |
| 6256 | <pre>{#syntax#}@TagType(T: type) type{#endsyntax#}</pre> | 6294 | <pre>{#syntax#}@TagType(T: type) type{#endsyntax#}</pre> |
| 6257 | <p> | 6295 | <p> |
| ... | @@ -6261,6 +6299,7 @@ pub const FloatMode = enum { | ... | @@ -6261,6 +6299,7 @@ pub const FloatMode = enum { |
| 6261 | For a union, returns the enum type that is used to store the tag value. | 6299 | For a union, returns the enum type that is used to store the tag value. |
| 6262 | </p> | 6300 | </p> |
| 6263 | {#header_close#} | 6301 | {#header_close#} |
| | 6302 | |
| 6264 | {#header_open|@This#} | 6303 | {#header_open|@This#} |
| 6265 | <pre>{#syntax#}@This() type{#endsyntax#}</pre> | 6304 | <pre>{#syntax#}@This() type{#endsyntax#}</pre> |
| 6266 | <p> | 6305 | <p> |
| ... | @@ -6296,6 +6335,7 @@ fn List(comptime T: type) type { | ... | @@ -6296,6 +6335,7 @@ fn List(comptime T: type) type { |
| 6296 | <a href="https://github.com/ziglang/zig/issues/1047">#1047</a> for details. | 6335 | <a href="https://github.com/ziglang/zig/issues/1047">#1047</a> for details. |
| 6297 | </p> | 6336 | </p> |
| 6298 | {#header_close#} | 6337 | {#header_close#} |
| | 6338 | |
| 6299 | {#header_open|@truncate#} | 6339 | {#header_open|@truncate#} |
| 6300 | <pre>{#syntax#}@truncate(comptime T: type, integer) T{#endsyntax#}</pre> | 6340 | <pre>{#syntax#}@truncate(comptime T: type, integer) T{#endsyntax#}</pre> |
| 6301 | <p> | 6341 | <p> |
| ... | @@ -6320,6 +6360,7 @@ const b: u8 = @truncate(u8, a); | ... | @@ -6320,6 +6360,7 @@ const b: u8 = @truncate(u8, a); |
| 6320 | </p> | 6360 | </p> |
| 6321 | | 6361 | |
| 6322 | {#header_close#} | 6362 | {#header_close#} |
| | 6363 | |
| 6323 | {#header_open|@typeId#} | 6364 | {#header_open|@typeId#} |
| 6324 | <pre>{#syntax#}@typeId(comptime T: type) @import("builtin").TypeId{#endsyntax#}</pre> | 6365 | <pre>{#syntax#}@typeId(comptime T: type) @import("builtin").TypeId{#endsyntax#}</pre> |
| 6325 | <p> | 6366 | <p> |
| ... | @@ -6354,6 +6395,7 @@ pub const TypeId = enum { | ... | @@ -6354,6 +6395,7 @@ pub const TypeId = enum { |
| 6354 | }; | 6395 | }; |
| 6355 | {#code_end#} | 6396 | {#code_end#} |
| 6356 | {#header_close#} | 6397 | {#header_close#} |
| | 6398 | |
| 6357 | {#header_open|@typeInfo#} | 6399 | {#header_open|@typeInfo#} |
| 6358 | <pre>{#syntax#}@typeInfo(comptime T: type) @import("builtin").TypeInfo{#endsyntax#}</pre> | 6400 | <pre>{#syntax#}@typeInfo(comptime T: type) @import("builtin").TypeInfo{#endsyntax#}</pre> |
| 6359 | <p> | 6401 | <p> |
| ... | @@ -6536,6 +6578,7 @@ pub const TypeInfo = union(TypeId) { | ... | @@ -6536,6 +6578,7 @@ pub const TypeInfo = union(TypeId) { |
| 6536 | }; | 6578 | }; |
| 6537 | {#code_end#} | 6579 | {#code_end#} |
| 6538 | {#header_close#} | 6580 | {#header_close#} |
| | 6581 | |
| 6539 | {#header_open|@typeName#} | 6582 | {#header_open|@typeName#} |
| 6540 | <pre>{#syntax#}@typeName(T: type) []u8{#endsyntax#}</pre> | 6583 | <pre>{#syntax#}@typeName(T: type) []u8{#endsyntax#}</pre> |
| 6541 | <p> | 6584 | <p> |
| ... | @@ -6543,6 +6586,7 @@ pub const TypeInfo = union(TypeId) { | ... | @@ -6543,6 +6586,7 @@ pub const TypeInfo = union(TypeId) { |
| 6543 | </p> | 6586 | </p> |
| 6544 | | 6587 | |
| 6545 | {#header_close#} | 6588 | {#header_close#} |
| | 6589 | |
| 6546 | {#header_open|@typeOf#} | 6590 | {#header_open|@typeOf#} |
| 6547 | <pre>{#syntax#}@typeOf(expression) type{#endsyntax#}</pre> | 6591 | <pre>{#syntax#}@typeOf(expression) type{#endsyntax#}</pre> |
| 6548 | <p> | 6592 | <p> |
| ... | @@ -6552,6 +6596,7 @@ pub const TypeInfo = union(TypeId) { | ... | @@ -6552,6 +6596,7 @@ pub const TypeInfo = union(TypeId) { |
| 6552 | | 6596 | |
| 6553 | {#header_close#} | 6597 | {#header_close#} |
| 6554 | {#header_close#} | 6598 | {#header_close#} |
| | 6599 | |
| 6555 | {#header_open|Build Mode#} | 6600 | {#header_open|Build Mode#} |
| 6556 | <p> | 6601 | <p> |
| 6557 | Zig has four build modes: | 6602 | Zig has four build modes: |