Slides for 2xxx.
[libguestfs-talks.git] / 2020-frama-c / 2100-range-struct.html
diff --git a/2020-frama-c/2100-range-struct.html b/2020-frama-c/2100-range-struct.html
new file mode 100644 (file)
index 0000000..ced14e4
--- /dev/null
@@ -0,0 +1,31 @@
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+<link rel="stylesheet" href="style.css" type="text/css"/>
+<script src="code.js" type="text/javascript"></script>
+
+<h1>Range type</h1>
+
+<pre class="code">
+<span class="comment">/*
+ * Operations on 64 bit address ranges.
+ * Notes:
+ * - Ranges must not wrap around 0, but can include UINT64_MAX.
+ */</span>
+struct Range {
+    <span class="comment">/*
+     * Do not access members directly, use the functions!
+     * A non-empty range has @lob <= @upb.
+     * An empty range has @lob == @upb + 1.
+     */</span>
+    uint64_t lob;        <span class="comment">/* inclusive lower bound */</span>
+    uint64_t upb;        <span class="comment">/* inclusive upper bound */</span>
+};
+typedef struct Range Range;
+</pre>
+
+<pre>
+┌─────┬─────────┬──────── ── ── ──
+│     │         │
+└─────┴─────────┴──────── ── ── ──
+       ↑       ↑
+       lob   upb
+</pre>