29#define relptr(type) union { type *relptr_type; Size relptr_off; }
38#define relptr_declare(type, relptrtype) \
39 typedef relptr(type) relptrtype
42#define relptr_access(base, rp) \
43 (AssertVariableIsOfTypeMacro(base, char *), \
44 (typeof((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \
45 (base) + (rp).relptr_off - 1))
47#define relptr_access(base, rp) \
48 (AssertVariableIsOfTypeMacro(base, char *), \
49 (void *) ((rp).relptr_off == 0 ? NULL : (base) + (rp).relptr_off - 1))
52#define relptr_is_null(rp) \
53 ((rp).relptr_off == 0)
55#define relptr_offset(rp) \
67 return val - base + 1;
72#define relptr_store(base, rp, val) \
73 (AssertVariableIsOfTypeMacro(base, char *), \
74 AssertVariableIsOfTypeMacro(val, typeof((rp).relptr_type)), \
75 (rp).relptr_off = relptr_store_eval((base), (char *) (val)))
77#define relptr_store(base, rp, val) \
78 (AssertVariableIsOfTypeMacro(base, char *), \
79 (rp).relptr_off = relptr_store_eval((base), (char *) (val)))
82#define relptr_copy(rp1, rp2) \
83 ((rp1).relptr_off = (rp2).relptr_off)
Assert(PointerIsAligned(start, uint64))
static Size relptr_store_eval(char *base, char *val)