2 ** DynASM encoding engine prototypes.
3 ** Copyright (C) 2005-2011 Mike Pall. All rights reserved.
4 ** Released under the MIT license. See dynasm.lua for full copyright notice.
13 #define DASM_IDENT "DynASM 1.3.0"
14 #define DASM_VERSION 10300 /* 1.3.0 */
17 #define Dst_DECL dasm_State **Dst
21 #define Dst_REF (*Dst)
25 #define DASM_FDEF extern
29 #define DASM_M_GROW(ctx, t, p, sz, need) \
31 size_t _sz = (sz), _need = (need); \
33 if (_sz < 16) _sz = 16; \
34 while (_sz < _need) _sz += _sz; \
35 (p) = (t *)realloc((p), _sz); \
36 if ((p) == NULL) exit(1); \
43 #define DASM_M_FREE(ctx, p, sz) free(p)
46 /* Internal DynASM encoder state. */
47 typedef struct dasm_State dasm_State
;
50 /* Initialize and free DynASM state. */
51 DASM_FDEF
void dasm_init(Dst_DECL
, int maxsection
);
52 DASM_FDEF
void dasm_free(Dst_DECL
);
54 /* Setup global array. Must be called before dasm_setup(). */
55 DASM_FDEF
void dasm_setupglobal(Dst_DECL
, void **gl
, unsigned int maxgl
);
57 /* Grow PC label array. Can be called after dasm_setup(), too. */
58 DASM_FDEF
void dasm_growpc(Dst_DECL
, unsigned int maxpc
);
61 DASM_FDEF
void dasm_setup(Dst_DECL
, const void *actionlist
);
63 /* Feed encoder with actions. Calls are generated by pre-processor. */
64 DASM_FDEF
void dasm_put(Dst_DECL
, int start
, ...);
66 /* Link sections and return the resulting size. */
67 DASM_FDEF
int dasm_link(Dst_DECL
, size_t *szp
);
69 /* Encode sections into buffer. */
70 DASM_FDEF
int dasm_encode(Dst_DECL
, void *buffer
);
72 /* Get PC label offset. */
73 DASM_FDEF
int dasm_getpclabel(Dst_DECL
, unsigned int pc
);
76 /* Optional sanity checker to call between isolated encoding steps. */
77 DASM_FDEF
int dasm_checkstep(Dst_DECL
, int secmatch
);
79 #define dasm_checkstep(a, b) 0
83 #endif /* _DASM_PROTO_H */