aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_term.h
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-02-17 14:35:14 +0100
committerBjörn-Egil Dahlberg <[email protected]>2015-03-12 19:15:26 +0100
commit7a12c43da25e3dcad54212f538ebae3dc13f5c2e (patch)
tree4777d51b623f014b250bb7efa6825826d88464a8 /erts/emulator/beam/erl_term.h
parent831ac12e04004c2e93aafc9f52264a57757fa2eb (diff)
downloadotp-7a12c43da25e3dcad54212f538ebae3dc13f5c2e.tar.gz
otp-7a12c43da25e3dcad54212f538ebae3dc13f5c2e.tar.bz2
otp-7a12c43da25e3dcad54212f538ebae3dc13f5c2e.zip
erts: Refactor erl_hashmap header includes
Diffstat (limited to 'erts/emulator/beam/erl_term.h')
-rw-r--r--erts/emulator/beam/erl_term.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_term.h b/erts/emulator/beam/erl_term.h
index 72946d9ddf..7605a41cd8 100644
--- a/erts/emulator/beam/erl_term.h
+++ b/erts/emulator/beam/erl_term.h
@@ -21,7 +21,6 @@
#define __ERL_TERM_H
#include "sys.h" /* defines HALFWORD_HEAP */
-#include "erl_hashmap.h"
typedef UWord Wterm; /* Full word terms */
@@ -996,6 +995,29 @@ _ET_DECLARE_CHECKED(Uint32*,external_ref_data,Wterm)
_ET_DECLARE_CHECKED(struct erl_node_*,external_ref_node,Eterm)
#define external_ref_node(x) _ET_APPLY(external_ref_node,(x))
+/* maps */
+
+#define MAP_HEADER_TAG_SZ (2)
+#define MAP_HEADER_ARITY_SZ (8)
+#define MAP_HEADER_VAL_SZ (16)
+
+#define MAP_HEADER_TAG_FLAT (0x0)
+#define MAP_HEADER_TAG_HAMT_NODE_BITMAP (0x1)
+#define MAP_HEADER_TAG_HAMT_HEAD_ARRAY (0x2)
+#define MAP_HEADER_TAG_HAMT_HEAD_BITMAP (0x3)
+
+#define MAP_HEADER_TYPE(Hdr) (((Hdr) >> (_HEADER_ARITY_OFFS)) & (0x3))
+#define MAP_HEADER_ARITY(Hdr) (((Hdr) >> (_HEADER_ARITY_OFFS + MAP_HEADER_TAG_SZ)) & (0xff))
+#define MAP_HEADER_VAL(Hdr) (((Hdr) >> (_HEADER_ARITY_OFFS + MAP_HEADER_TAG_SZ + MAP_HEADER_ARITY_SZ)) & (0xffff))
+
+#define make_hashmap(x) make_boxed((Eterm*)(x))
+#define make_hashmap_rel make_boxed_rel
+#define is_hashmap(x) (is_boxed((x)) && is_hashmap_header(*boxed_val((x))))
+#define is_hashmap_rel(RTERM,BASE) is_hashmap(rterm2wterm(RTERM,BASE))
+#define is_hashmap_header(x) (((x) & (_TAG_HEADER_MASK)) == _TAG_HEADER_HASHMAP)
+#define hashmap_val(x) _unchecked_boxed_val((x))
+#define hashmap_val_rel(RTERM, BASE) hashmap_val(rterm2wterm(RTERM, BASE))
+
/* number tests */
#define is_integer(x) (is_small(x) || is_big(x))