-
Notifications
You must be signed in to change notification settings - Fork 2
/
nif_stubs.h
57 lines (49 loc) · 1.26 KB
/
nif_stubs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <stdio.h>
#include "erl_nif.h"
#include "map.h"
#include "str.h"
typedef ERL_NIF_TERM term;
struct alloc {
void *p;
struct alloc *next;
};
/* This should be called struct shared_object, but the way erl_nif.h
* is written forces me to use this dumb name (which should not have a
* trailing _t, and should be a typedef). */
struct enif_environment_t {
void *dl_handle;
const char *path;
/* The following items are non-NULL only if this SO is a NIF. */
ErlNifEntry *entry;
void *priv_data;
term exception;
struct atom_ptr_map fns;
struct alloc *allocations;
};
typedef enum {
TERM_THE_NON_VALUE,
TERM_SMALL,
TERM_ATOM,
TERM_NIL,
TERM_IMMEDIATE,
TERM_TUPLE,
TERM_FLOAT,
TERM_BIN,
TERM_EXTREF,
TERM_BOXED,
TERM_CONS,
TERM_THING
} term_type;
/* helpers */
extern void pretty_print_term(FILE *, const term *);
void pretty_print_argument_list(FILE *, const term *);
term tuple_of_list(ErlNifEnv *, term);
extern term nconc(term, term);
extern term nreverse_list(term);
extern bool iolist_to_binary(term, term *);
extern term_type type_of_term(const term);
extern term tagged_atom(atom);
extern atom atom_untagged(term);
extern const term nil;
extern const unsigned max_atom_index;