summaryrefslogtreecommitdiff
path: root/static/freebsd/man3/stdckdint.3 3.html
diff options
context:
space:
mode:
Diffstat (limited to 'static/freebsd/man3/stdckdint.3 3.html')
-rw-r--r--static/freebsd/man3/stdckdint.3 3.html106
1 files changed, 106 insertions, 0 deletions
diff --git a/static/freebsd/man3/stdckdint.3 3.html b/static/freebsd/man3/stdckdint.3 3.html
new file mode 100644
index 00000000..5434f16e
--- /dev/null
+++ b/static/freebsd/man3/stdckdint.3 3.html
@@ -0,0 +1,106 @@
+<table class="head">
+ <tr>
+ <td class="head-ltitle">STDCKDINT(3)</td>
+ <td class="head-vol">Library Functions Manual</td>
+ <td class="head-rtitle">STDCKDINT(3)</td>
+ </tr>
+</table>
+<div class="manual-text">
+<section class="Sh">
+<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
+<p class="Pp"><code class="Nm">stdckdint</code> &#x2014;
+ <span class="Nd">checked integer arithmetic</span></p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
+<p class="Pp"><code class="In">#include
+ &lt;<a class="In">stdckdint.h</a>&gt;</code></p>
+<p class="Pp"><var class="Ft">bool</var>
+ <br/>
+ <code class="Fn">ckd_add</code>(<var class="Fa" style="white-space: nowrap;">type1
+ *result</var>, <var class="Fa" style="white-space: nowrap;">type2 a</var>,
+ <var class="Fa" style="white-space: nowrap;">type3 b</var>);</p>
+<p class="Pp"><var class="Ft">bool</var>
+ <br/>
+ <code class="Fn">ckd_sub</code>(<var class="Fa" style="white-space: nowrap;">type1
+ *result</var>, <var class="Fa" style="white-space: nowrap;">type2 a</var>,
+ <var class="Fa" style="white-space: nowrap;">type3 b</var>);</p>
+<p class="Pp"><var class="Ft">bool</var>
+ <br/>
+ <code class="Fn">ckd_mul</code>(<var class="Fa" style="white-space: nowrap;">type1
+ *result</var>, <var class="Fa" style="white-space: nowrap;">type2 a</var>,
+ <var class="Fa" style="white-space: nowrap;">type3 b</var>);</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
+<p class="Pp">The function-like macros <code class="Nm">ckd_add</code>,
+ <code class="Nm">ckd_sub</code>, and <code class="Nm">ckd_mul</code> perform
+ checked integer addition, subtraction, and multiplication, respectively. If
+ the result of adding, subtracting, or multiplying <var class="Fa">a</var>
+ and <var class="Fa">b</var> as if their respective types had infinite range
+ fits in <var class="Ft">type1</var>, it is stored in the location pointed to
+ by <var class="Fa">result</var> and the macro evaluates to
+ <code class="Dv">false</code>. Otherwise, the macro evaluates to
+ <code class="Dv">true</code> and the contents of the location pointed to by
+ <var class="Fa">result</var> is the result of the operation wrapped to the
+ range of <var class="Ft">type1</var>.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
+ VALUES</a></h1>
+<p class="Pp">The <code class="Nm">ckd_add</code>,
+ <code class="Nm">ckd_sub</code>, and <code class="Nm">ckd_mul</code> macros
+ evaluate to <code class="Dv">true</code> if the requested operation
+ overflowed the result type and <code class="Dv">false</code> otherwise.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
+<div class="Bd Bd-indent Li">
+<pre>#include &lt;assert.h&gt;
+#include &lt;limits.h&gt;
+#include &lt;stdckdint.h&gt;
+
+int main(void)
+{
+ int result;
+
+ assert(!ckd_add(&amp;result, INT_MAX, 0));
+ assert(result == INT_MAX);
+ assert(ckd_add(&amp;result, INT_MAX, 1));
+ assert(result == INT_MIN);
+
+ assert(!ckd_sub(&amp;result, INT_MIN, 0));
+ assert(result == INT_MIN);
+ assert(ckd_sub(&amp;result, INT_MIN, 1));
+ assert(result == INT_MAX);
+
+ assert(!ckd_mul(&amp;result, INT_MAX / 2, 2));
+ assert(result == INT_MAX - 1);
+ assert(ckd_mul(&amp;result, INT_MAX / 2 + 1, 2));
+ assert(result == INT_MIN);
+
+ return 0;
+}</pre>
+</div>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
+<p class="Pp">The <code class="Nm">ckd_add</code>,
+ <code class="Nm">ckd_sub</code>, and <code class="Nm">ckd_mul</code> macros
+ were first introduced in <span class="Ux">FreeBSD 14.0</span>.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
+<p class="Pp">The <code class="Nm">ckd_add</code>,
+ <code class="Nm">ckd_sub</code>, and <code class="Nm">ckd_mul</code> macros
+ and this manual page were written by <span class="An">Dag-Erling
+ Sm&#x00F8;rgrav</span>
+ &lt;<a class="Mt" href="mailto:des@FreeBSD.org">des@FreeBSD.org</a>&gt;.</p>
+</section>
+</div>
+<table class="foot">
+ <tr>
+ <td class="foot-date">September 5, 2023</td>
+ <td class="foot-os">FreeBSD 15.0</td>
+ </tr>
+</table>