aboutsummaryrefslogtreecommitdiff
path: root/doc/langref.html.in
diff options
context:
space:
mode:
authorr00ster91 <r00ster91@proton.me>2023-03-03 18:35:03 +0100
committerr00ster91 <r00ster91@proton.me>2023-03-04 12:08:19 +0100
commit65368683ad92b858d0a391cb29d37c0476784b40 (patch)
tree741bea50bb76c77683a4c48d02f8ee63bd35c1e0 /doc/langref.html.in
parentd6bd00e85500fa1a7909695ae5943be438f7521d (diff)
downloadzig-65368683ad92b858d0a391cb29d37c0476784b40.tar.gz
zig-65368683ad92b858d0a391cb29d37c0476784b40.zip
add @trap builtin
This introduces a new builtin function that compiles down to something that results in an illegal instruction exception/interrupt. It can be used to exit a program abnormally. This implements the builtin for all backends.
Diffstat (limited to 'doc/langref.html.in')
-rw-r--r--doc/langref.html.in17
1 files changed, 16 insertions, 1 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in
index e016ef13f8..0290d3acd6 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -7818,12 +7818,14 @@ comptime {
<p>
This function inserts a platform-specific debug trap instruction which causes
debuggers to break there.
+ Unlike for {#syntax#}@trap(){#endsyntax#}, execution may continue after this point if the program is resumed.
</p>
<p>
This function is only valid within function scope.
</p>
-
+ {#see_also|@trap#}
{#header_close#}
+
{#header_open|@mulAdd#}
<pre>{#syntax#}@mulAdd(comptime T: type, a: T, b: T, c: T) T{#endsyntax#}</pre>
<p>
@@ -9393,6 +9395,19 @@ fn List(comptime T: type) type {
</p>
{#header_close#}
+ {#header_open|@trap#}
+ <pre>{#syntax#}@trap() noreturn{#endsyntax#}</pre>
+ <p>
+ This function inserts a platform-specific trap/jam instruction which can be used to exit the program abnormally.
+ This may be implemented by explicitly emitting an invalid instruction which may cause an illegal instruction exception of some sort.
+ Unlike for {#syntax#}@breakpoint(){#endsyntax#}, execution does not continue after this point.
+ </p>
+ <p>
+ This function is only valid within function scope.
+ </p>
+ {#see_also|@breakpoint#}
+ {#header_close#}
+
{#header_open|@truncate#}
<pre>{#syntax#}@truncate(comptime T: type, integer: anytype) T{#endsyntax#}</pre>
<p>