1 /* i/n/u.h
2 **
3 ** This file is in the public domain.
4 */
5   /**  Constants.
6   **/
7     /* u3_none - u3_noun which is not a noun.
8     */
9 #     define u3_none  (u3_noun)0xffffffff
10 
11     /* u3_nul: 0, hoon ~.
12     */
13 #     define u3_nul   0
14 
15     /* u3_blip: 0, hoon %$.
16     */
17 #     define u3_blip  0
18 
19 
20   /**  Typedefs.
21   **/
22     /* u3_post: pointer offset into u3_Loom; _p suffix; declare as u3p().
23     */
24       typedef c3_w      u3_post;
25 #     define u3p(type)  u3_post
26 
27     /* u3_noun: tagged noun pointer.
28     **
29     **  If bit 31 is 0, a u3_noun is a direct 31-bit atom ("cat").
30     **  If bit 31 is 1 and bit 30 0, an indirect atom ("pug").
31     **  If bit 31 is 1 and bit 30 1, an indirect cell ("pom").
32     **
33     ** Bits 0-29 are a word offset against u3_Loom (u3_post).
34     */
35       typedef c3_w u3_noun;
36 
37     /* u3_weak: u3_noun which may be u3_none (not a noun).
38     */
39       typedef u3_noun u3_weak;
40 
41     /* u3_atom: u3_noun which must be an atom.
42     */
43       typedef u3_noun u3_atom;
44 
45     /* u3_term: u3_noun which must be a term (@tas).
46     */
47       typedef u3_noun u3_term;
48 
49     /* u3_cell, u3_trel, u3_qual, u3_quin: cell, triple, quadruple, quintuple.
50     */
51       typedef u3_noun u3_cell;
52       typedef u3_noun u3_trel;
53       typedef u3_noun u3_qual;
54       typedef u3_noun u3_quin;
55 
56     /* u3_funk, u3_funq: unary and binary noun functions.
57     */
58       typedef u3_noun (*u3_funk)(u3_noun);
59       typedef u3_noun (*u3_funq)(u3_noun, u3_noun);
60 
61 
62   /**  Macros.
63   **/
64     /* u3_assure(): loobean assert, bailing with %fail.
65     */
66 #     define u3_assure(x)  if ( !_(x) ) { u3m_bail(c3__fail); }
67 
68     /* u3_assert(): loobean assert, bailing with %exit.
69     */
70 #     define u3_assent(x)  if ( !_(x) ) { u3m_bail(c3__exit); }
71 
72 
73   /**  Aliases.
74   **/
75     /* u3h(), u3t(), u3at(): noun fragments.
76     */
77 #     define u3h(som)          u3x_h(som)
78 #     define u3t(som)          u3x_t(som)
79 #     define u3at(axe, som)    u3x_at(axe, som)
80 
81     /* u3nc(), u3nt(), u3nq(): tuple composition.
82     */
83 #     define u3nc(a, b)        u3i_cell(a, b)
84 #     define u3nt(a, b, c)     u3i_trel(a, b, c)
85 #     define u3nq(a, b, c, d)  u3i_qual(a, b, c, d)
86 
87     /* u3du(), u3ud(): noun/cell test.
88     */
89 #     define u3du(som)         (u3r_du(som))
90 #     define u3ud(som)         (u3r_ud(som))
91 
92     /* u3k(), u3z(): reference counts.
93     */
94 #     define u3k(som)          u3a_gain(som)
95 #     define u3z(som)          u3a_lose(som)
96 
97     /* u3do(), u3dc(), u3dt(), u3dq(): arvo calls.
98     */
99 #     define  u3do(txt_c, arg)         u3v_do(txt_c, arg)
100 #     define  u3dc(txt_c, a, b)        u3v_do(txt_c, u3nc(a, b))
101 #     define  u3dt(txt_c, a, b, c)     u3v_do(txt_c, u3nt(a, b, c))
102 #     define  u3dq(txt_c, a, b, c, d)  u3v_do(txt_c, u3nt(a, b, c, d))
103 
104     /* u3to(), u3of(): offset/pointer conversion.
105     */
106 #     define  u3to(type, x) ((type *) u3a_into(x))
107 #     define  u3tn(type, x) (x == 0) ? (void *)0 :  ((type *) u3a_into(x))
108 #     define  u3of(type, x) (u3a_outa((type *)x))
109 
110