| ... | ... | @@ -5169,6 +5169,34 @@ fn seq(c: u8) void { |
| 5169 | 5169 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. |
| 5170 | 5170 | </p> |
| 5171 | 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 | 5200 | {#header_open|@ArgType#} |
| 5173 | 5201 | <pre>{#syntax#}@ArgType(comptime T: type, comptime n: usize) type{#endsyntax#}</pre> |
| 5174 | 5202 | <p> |
| ... | ... | @@ -5241,6 +5269,7 @@ fn seq(c: u8) void { |
| 5241 | 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 | 5270 | </p> |
| 5243 | 5271 | {#header_close#} |
| 5272 | |
| 5244 | 5273 | {#header_open|@bitOffsetOf#} |
| 5245 | 5274 | <pre>{#syntax#}@bitOffsetOf(comptime T: type, comptime field_name: [] const u8) comptime_int{#endsyntax#}</pre> |
| 5246 | 5275 | <p> |
| ... | ... | @@ -5253,52 +5282,6 @@ fn seq(c: u8) void { |
| 5253 | 5282 | </p> |
| 5254 | 5283 | {#see_also|@byteOffsetOf#} |
| 5255 | 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 | 5286 | {#header_open|@boolToInt#} |
| 5304 | 5287 | <pre>{#syntax#}@boolToInt(value: bool) u1{#endsyntax#}</pre> |
| ... | ... | @@ -5312,6 +5295,18 @@ comptime { |
| 5312 | 5295 | </p> |
| 5313 | 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 | 5310 | {#header_open|@bswap#} |
| 5316 | 5311 | <pre>{#syntax#}@bswap(comptime T: type, value: T) T{#endsyntax#}</pre> |
| 5317 | 5312 | <p>{#syntax#}T{#endsyntax#} must be an integer type with bit count evenly divisible by 8.</p> |
| ... | ... | @@ -5321,6 +5316,14 @@ comptime { |
| 5321 | 5316 | </p> |
| 5322 | 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 | 5327 | {#header_open|@bytesToSlice#} |
| 5325 | 5328 | <pre>{#syntax#}@bytesToSlice(comptime Element: type, bytes: []u8) []Element{#endsyntax#}</pre> |
| 5326 | 5329 | <p> |
| ... | ... | @@ -5387,17 +5390,7 @@ comptime { |
| 5387 | 5390 | </p> |
| 5388 | 5391 | {#see_also|Import from C Header File|@cImport|@cDefine|@cUndef#} |
| 5389 | 5392 | {#header_close#} |
| 5390 | | {#header_open|@cUndef#} |
| 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#} |
| 5393 | |
| 5401 | 5394 | {#header_open|@clz#} |
| 5402 | 5395 | <pre>{#syntax#}@clz(x: T) U{#endsyntax#}</pre> |
| 5403 | 5396 | <p> |
| ... | ... | @@ -5413,6 +5406,7 @@ comptime { |
| 5413 | 5406 | </p> |
| 5414 | 5407 | {#see_also|@ctz|@popCount#} |
| 5415 | 5408 | {#header_close#} |
| 5409 | |
| 5416 | 5410 | {#header_open|@cmpxchgStrong#} |
| 5417 | 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 | 5412 | <p> |
| ... | ... | @@ -5468,6 +5462,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5468 | 5462 | <p>{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p> |
| 5469 | 5463 | {#see_also|Compile Variables|cmpxchgStrong#} |
| 5470 | 5464 | {#header_close#} |
| 5465 | |
| 5471 | 5466 | {#header_open|@compileError#} |
| 5472 | 5467 | <pre>{#syntax#}@compileError(comptime msg: []u8){#endsyntax#}</pre> |
| 5473 | 5468 | <p> |
| ... | ... | @@ -5480,6 +5475,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5480 | 5475 | and {#syntax#}comptime{#endsyntax#} functions. |
| 5481 | 5476 | </p> |
| 5482 | 5477 | {#header_close#} |
| 5478 | |
| 5483 | 5479 | {#header_open|@compileLog#} |
| 5484 | 5480 | <pre>{#syntax#}@compileLog(args: ...){#endsyntax#}</pre> |
| 5485 | 5481 | <p> |
| ... | ... | @@ -5534,6 +5530,7 @@ test "main" { |
| 5534 | 5530 | } |
| 5535 | 5531 | {#code_end#} |
| 5536 | 5532 | {#header_close#} |
| 5533 | |
| 5537 | 5534 | {#header_open|@ctz#} |
| 5538 | 5535 | <pre>{#syntax#}@ctz(x: T) U{#endsyntax#}</pre> |
| 5539 | 5536 | <p> |
| ... | ... | @@ -5549,6 +5546,19 @@ test "main" { |
| 5549 | 5546 | </p> |
| 5550 | 5547 | {#see_also|@clz|@popCount#} |
| 5551 | 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 | 5562 | {#header_open|@divExact#} |
| 5553 | 5563 | <pre>{#syntax#}@divExact(numerator: T, denominator: T) T{#endsyntax#}</pre> |
| 5554 | 5564 | <p> |
| ... | ... | @@ -5615,14 +5625,6 @@ test "main" { |
| 5615 | 5625 | {#see_also|@intToEnum#} |
| 5616 | 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 | 5628 | {#header_open|@errorName#} |
| 5627 | 5629 | <pre>{#syntax#}@errorName(err: anyerror) []const u8{#endsyntax#}</pre> |
| 5628 | 5630 | <p> |
| ... | ... | @@ -5665,6 +5667,14 @@ test "main" { |
| 5665 | 5667 | {#see_also|@intToError#} |
| 5666 | 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 | 5678 | {#header_open|@export#} |
| 5669 | 5679 | <pre>{#syntax#}@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) []const u8{#endsyntax#}</pre> |
| 5670 | 5680 | <p> |
| ... | ... | @@ -5733,6 +5743,7 @@ test "main" { |
| 5733 | 5743 | This function is only valid within function scope. |
| 5734 | 5744 | </p> |
| 5735 | 5745 | {#header_close#} |
| 5746 | |
| 5736 | 5747 | {#header_open|@handle#} |
| 5737 | 5748 | <pre>{#syntax#}@handle(){#endsyntax#}</pre> |
| 5738 | 5749 | <p> |
| ... | ... | @@ -5743,6 +5754,7 @@ test "main" { |
| 5743 | 5754 | This function is only valid within an async function scope. |
| 5744 | 5755 | </p> |
| 5745 | 5756 | {#header_close#} |
| 5757 | |
| 5746 | 5758 | {#header_open|@import#} |
| 5747 | 5759 | <pre>{#syntax#}@import(comptime path: []u8) (namespace){#endsyntax#}</pre> |
| 5748 | 5760 | <p> |
| ... | ... | @@ -5763,6 +5775,7 @@ test "main" { |
| 5763 | 5775 | </ul> |
| 5764 | 5776 | {#see_also|Compile Variables|@embedFile#} |
| 5765 | 5777 | {#header_close#} |
| 5778 | |
| 5766 | 5779 | {#header_open|@inlineCall#} |
| 5767 | 5780 | <pre>{#syntax#}@inlineCall(function: X, args: ...) Y{#endsyntax#}</pre> |
| 5768 | 5781 | <p> |
| ... | ... | @@ -5842,6 +5855,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } |
| 5842 | 5855 | bit count for an integer type is {#syntax#}65535{#endsyntax#}. |
| 5843 | 5856 | </p> |
| 5844 | 5857 | {#header_close#} |
| 5858 | |
| 5845 | 5859 | {#header_open|@memberCount#} |
| 5846 | 5860 | <pre>{#syntax#}@memberCount(comptime T: type) comptime_int{#endsyntax#}</pre> |
| 5847 | 5861 | <p> |
| ... | ... | @@ -5868,6 +5882,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } |
| 5868 | 5882 | <pre>{#syntax#}@memberType(comptime T: type, comptime index: usize) type{#endsyntax#}</pre> |
| 5869 | 5883 | <p>Returns the field type of a struct or union.</p> |
| 5870 | 5884 | {#header_close#} |
| 5885 | |
| 5871 | 5886 | {#header_open|@memcpy#} |
| 5872 | 5887 | <pre>{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}</pre> |
| 5873 | 5888 | <p> |
| ... | ... | @@ -5886,6 +5901,7 @@ fn add(a: i32, b: i32) i32 { return a + b; } |
| 5886 | 5901 | <pre>{#syntax#}const mem = @import("std").mem; |
| 5887 | 5902 | mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre> |
| 5888 | 5903 | {#header_close#} |
| 5904 | |
| 5889 | 5905 | {#header_open|@memset#} |
| 5890 | 5906 | <pre>{#syntax#}@memset(dest: [*]u8, c: u8, byte_count: usize){#endsyntax#}</pre> |
| 5891 | 5907 | <p> |
| ... | ... | @@ -5903,6 +5919,7 @@ mem.copy(u8, dest[0...byte_count], source[0...byte_count]);{#endsyntax#}</pre> |
| 5903 | 5919 | <pre>{#syntax#}const mem = @import("std").mem; |
| 5904 | 5920 | mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 5905 | 5921 | {#header_close#} |
| 5922 | |
| 5906 | 5923 | {#header_open|@mod#} |
| 5907 | 5924 | <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre> |
| 5908 | 5925 | <p> |
| ... | ... | @@ -5916,6 +5933,7 @@ mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 5916 | 5933 | <p>For a function that returns an error code, see {#syntax#}@import("std").math.mod{#endsyntax#}.</p> |
| 5917 | 5934 | {#see_also|@rem#} |
| 5918 | 5935 | {#header_close#} |
| 5936 | |
| 5919 | 5937 | {#header_open|@mulWithOverflow#} |
| 5920 | 5938 | <pre>{#syntax#}@mulWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre> |
| 5921 | 5939 | <p> |
| ... | ... | @@ -5924,6 +5942,7 @@ mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 5924 | 5942 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. |
| 5925 | 5943 | </p> |
| 5926 | 5944 | {#header_close#} |
| 5945 | |
| 5927 | 5946 | {#header_open|@newStackCall#} |
| 5928 | 5947 | <pre>{#syntax#}@newStackCall(new_stack: []u8, function: var, args: ...) var{#endsyntax#}</pre> |
| 5929 | 5948 | <p> |
| ... | ... | @@ -5960,6 +5979,7 @@ fn targetFunction(x: i32) usize { |
| 5960 | 5979 | } |
| 5961 | 5980 | {#code_end#} |
| 5962 | 5981 | {#header_close#} |
| 5982 | |
| 5963 | 5983 | {#header_open|@noInlineCall#} |
| 5964 | 5984 | <pre>{#syntax#}@noInlineCall(function: var, args: ...) var{#endsyntax#}</pre> |
| 5965 | 5985 | <p> |
| ... | ... | @@ -5982,6 +6002,7 @@ fn add(a: i32, b: i32) i32 { |
| 5982 | 6002 | </p> |
| 5983 | 6003 | {#see_also|@inlineCall#} |
| 5984 | 6004 | {#header_close#} |
| 6005 | |
| 5985 | 6006 | {#header_open|@OpaqueType#} |
| 5986 | 6007 | <pre>{#syntax#}@OpaqueType() type{#endsyntax#}</pre> |
| 5987 | 6008 | <p> |
| ... | ... | @@ -6005,6 +6026,7 @@ test "call foo" { |
| 6005 | 6026 | } |
| 6006 | 6027 | {#code_end#} |
| 6007 | 6028 | {#header_close#} |
| 6029 | |
| 6008 | 6030 | {#header_open|@panic#} |
| 6009 | 6031 | <pre>{#syntax#}@panic(message: []const u8) noreturn{#endsyntax#}</pre> |
| 6010 | 6032 | <p> |
| ... | ... | @@ -6021,6 +6043,7 @@ test "call foo" { |
| 6021 | 6043 | </ul> |
| 6022 | 6044 | {#see_also|Root Source File#} |
| 6023 | 6045 | {#header_close#} |
| 6046 | |
| 6024 | 6047 | {#header_open|@popCount#} |
| 6025 | 6048 | <pre>{#syntax#}@popCount(integer: var) var{#endsyntax#}</pre> |
| 6026 | 6049 | <p>Counts the number of bits set in an integer.</p> |
| ... | ... | @@ -6031,12 +6054,14 @@ test "call foo" { |
| 6031 | 6054 | </p> |
| 6032 | 6055 | {#see_also|@ctz|@clz#} |
| 6033 | 6056 | {#header_close#} |
| 6057 | |
| 6034 | 6058 | {#header_open|@ptrCast#} |
| 6035 | 6059 | <pre>{#syntax#}@ptrCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre> |
| 6036 | 6060 | <p> |
| 6037 | 6061 | Converts a pointer of one type to a pointer of another type. |
| 6038 | 6062 | </p> |
| 6039 | 6063 | {#header_close#} |
| 6064 | |
| 6040 | 6065 | {#header_open|@ptrToInt#} |
| 6041 | 6066 | <pre>{#syntax#}@ptrToInt(value: var) usize{#endsyntax#}</pre> |
| 6042 | 6067 | <p> |
| ... | ... | @@ -6051,6 +6076,7 @@ test "call foo" { |
| 6051 | 6076 | <p>To convert the other way, use {#link|@intToPtr#}</p> |
| 6052 | 6077 | |
| 6053 | 6078 | {#header_close#} |
| 6079 | |
| 6054 | 6080 | {#header_open|@rem#} |
| 6055 | 6081 | <pre>{#syntax#}@rem(numerator: T, denominator: T) T{#endsyntax#}</pre> |
| 6056 | 6082 | <p> |
| ... | ... | @@ -6064,6 +6090,7 @@ test "call foo" { |
| 6064 | 6090 | <p>For a function that returns an error code, see {#syntax#}@import("std").math.rem{#endsyntax#}.</p> |
| 6065 | 6091 | {#see_also|@mod#} |
| 6066 | 6092 | {#header_close#} |
| 6093 | |
| 6067 | 6094 | {#header_open|@returnAddress#} |
| 6068 | 6095 | <pre>{#syntax#}@returnAddress(){#endsyntax#}</pre> |
| 6069 | 6096 | <p> |
| ... | ... | @@ -6084,19 +6111,14 @@ test "call foo" { |
| 6084 | 6111 | Ensures that a function will have a stack alignment of at least {#syntax#}alignment{#endsyntax#} bytes. |
| 6085 | 6112 | </p> |
| 6086 | 6113 | {#header_close#} |
| 6114 | |
| 6087 | 6115 | {#header_open|@setCold#} |
| 6088 | 6116 | <pre>{#syntax#}@setCold(is_cold: bool){#endsyntax#}</pre> |
| 6089 | 6117 | <p> |
| 6090 | 6118 | Tells the optimizer that a function is rarely called. |
| 6091 | 6119 | </p> |
| 6092 | 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 | 6122 | {#header_open|@setEvalBranchQuota#} |
| 6101 | 6123 | <pre>{#syntax#}@setEvalBranchQuota(new_quota: usize){#endsyntax#}</pre> |
| 6102 | 6124 | <p> |
| ... | ... | @@ -6131,6 +6153,7 @@ test "foo" { |
| 6131 | 6153 | |
| 6132 | 6154 | {#see_also|comptime#} |
| 6133 | 6155 | {#header_close#} |
| 6156 | |
| 6134 | 6157 | {#header_open|@setFloatMode#} |
| 6135 | 6158 | <pre>{#syntax#}@setFloatMode(mode: @import("builtin").FloatMode){#endsyntax#}</pre> |
| 6136 | 6159 | <p> |
| ... | ... | @@ -6165,6 +6188,7 @@ pub const FloatMode = enum { |
| 6165 | 6188 | </p> |
| 6166 | 6189 | {#see_also|Floating Point Operations#} |
| 6167 | 6190 | {#header_close#} |
| 6191 | |
| 6168 | 6192 | {#header_open|@setGlobalLinkage#} |
| 6169 | 6193 | <pre>{#syntax#}@setGlobalLinkage(global_variable_name, comptime linkage: GlobalLinkage){#endsyntax#}</pre> |
| 6170 | 6194 | <p> |
| ... | ... | @@ -6172,6 +6196,15 @@ pub const FloatMode = enum { |
| 6172 | 6196 | </p> |
| 6173 | 6197 | {#see_also|Compile Variables#} |
| 6174 | 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 | 6208 | {#header_open|@shlExact#} |
| 6176 | 6209 | <pre>{#syntax#}@shlExact(value: T, shift_amt: Log2T) T{#endsyntax#}</pre> |
| 6177 | 6210 | <p> |
| ... | ... | @@ -6184,6 +6217,7 @@ pub const FloatMode = enum { |
| 6184 | 6217 | </p> |
| 6185 | 6218 | {#see_also|@shrExact|@shlWithOverflow#} |
| 6186 | 6219 | {#header_close#} |
| 6220 | |
| 6187 | 6221 | {#header_open|@shlWithOverflow#} |
| 6188 | 6222 | <pre>{#syntax#}@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: *T) bool{#endsyntax#}</pre> |
| 6189 | 6223 | <p> |
| ... | ... | @@ -6197,6 +6231,7 @@ pub const FloatMode = enum { |
| 6197 | 6231 | </p> |
| 6198 | 6232 | {#see_also|@shlExact|@shrExact#} |
| 6199 | 6233 | {#header_close#} |
| 6234 | |
| 6200 | 6235 | {#header_open|@shrExact#} |
| 6201 | 6236 | <pre>{#syntax#}@shrExact(value: T, shift_amt: Log2T) T{#endsyntax#}</pre> |
| 6202 | 6237 | <p> |
| ... | ... | @@ -6238,6 +6273,7 @@ pub const FloatMode = enum { |
| 6238 | 6273 | This is a low-level intrinsic. Most code can use {#syntax#}std.math.sqrt{#endsyntax#} instead. |
| 6239 | 6274 | </p> |
| 6240 | 6275 | {#header_close#} |
| 6276 | |
| 6241 | 6277 | {#header_open|@subWithOverflow#} |
| 6242 | 6278 | <pre>{#syntax#}@subWithOverflow(comptime T: type, a: T, b: T, result: *T) bool{#endsyntax#}</pre> |
| 6243 | 6279 | <p> |
| ... | ... | @@ -6246,12 +6282,14 @@ pub const FloatMode = enum { |
| 6246 | 6282 | If no overflow or underflow occurs, returns {#syntax#}false{#endsyntax#}. |
| 6247 | 6283 | </p> |
| 6248 | 6284 | {#header_close#} |
| 6285 | |
| 6249 | 6286 | {#header_open|@tagName#} |
| 6250 | 6287 | <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre> |
| 6251 | 6288 | <p> |
| 6252 | 6289 | Converts an enum value or union value to a slice of bytes representing the name. |
| 6253 | 6290 | </p> |
| 6254 | 6291 | {#header_close#} |
| 6292 | |
| 6255 | 6293 | {#header_open|@TagType#} |
| 6256 | 6294 | <pre>{#syntax#}@TagType(T: type) type{#endsyntax#}</pre> |
| 6257 | 6295 | <p> |
| ... | ... | @@ -6261,6 +6299,7 @@ pub const FloatMode = enum { |
| 6261 | 6299 | For a union, returns the enum type that is used to store the tag value. |
| 6262 | 6300 | </p> |
| 6263 | 6301 | {#header_close#} |
| 6302 | |
| 6264 | 6303 | {#header_open|@This#} |
| 6265 | 6304 | <pre>{#syntax#}@This() type{#endsyntax#}</pre> |
| 6266 | 6305 | <p> |
| ... | ... | @@ -6296,6 +6335,7 @@ fn List(comptime T: type) type { |
| 6296 | 6335 | <a href="https://github.com/ziglang/zig/issues/1047">#1047</a> for details. |
| 6297 | 6336 | </p> |
| 6298 | 6337 | {#header_close#} |
| 6338 | |
| 6299 | 6339 | {#header_open|@truncate#} |
| 6300 | 6340 | <pre>{#syntax#}@truncate(comptime T: type, integer) T{#endsyntax#}</pre> |
| 6301 | 6341 | <p> |
| ... | ... | @@ -6320,6 +6360,7 @@ const b: u8 = @truncate(u8, a); |
| 6320 | 6360 | </p> |
| 6321 | 6361 | |
| 6322 | 6362 | {#header_close#} |
| 6363 | |
| 6323 | 6364 | {#header_open|@typeId#} |
| 6324 | 6365 | <pre>{#syntax#}@typeId(comptime T: type) @import("builtin").TypeId{#endsyntax#}</pre> |
| 6325 | 6366 | <p> |
| ... | ... | @@ -6354,6 +6395,7 @@ pub const TypeId = enum { |
| 6354 | 6395 | }; |
| 6355 | 6396 | {#code_end#} |
| 6356 | 6397 | {#header_close#} |
| 6398 | |
| 6357 | 6399 | {#header_open|@typeInfo#} |
| 6358 | 6400 | <pre>{#syntax#}@typeInfo(comptime T: type) @import("builtin").TypeInfo{#endsyntax#}</pre> |
| 6359 | 6401 | <p> |
| ... | ... | @@ -6536,6 +6578,7 @@ pub const TypeInfo = union(TypeId) { |
| 6536 | 6578 | }; |
| 6537 | 6579 | {#code_end#} |
| 6538 | 6580 | {#header_close#} |
| 6581 | |
| 6539 | 6582 | {#header_open|@typeName#} |
| 6540 | 6583 | <pre>{#syntax#}@typeName(T: type) []u8{#endsyntax#}</pre> |
| 6541 | 6584 | <p> |
| ... | ... | @@ -6543,6 +6586,7 @@ pub const TypeInfo = union(TypeId) { |
| 6543 | 6586 | </p> |
| 6544 | 6587 | |
| 6545 | 6588 | {#header_close#} |
| 6589 | |
| 6546 | 6590 | {#header_open|@typeOf#} |
| 6547 | 6591 | <pre>{#syntax#}@typeOf(expression) type{#endsyntax#}</pre> |
| 6548 | 6592 | <p> |
| ... | ... | @@ -6552,6 +6596,7 @@ pub const TypeInfo = union(TypeId) { |
| 6552 | 6596 | |
| 6553 | 6597 | {#header_close#} |
| 6554 | 6598 | {#header_close#} |
| 6599 | |
| 6555 | 6600 | {#header_open|Build Mode#} |
| 6556 | 6601 | <p> |
| 6557 | 6602 | Zig has four build modes: |