aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2011-03-28 15:06:30 +0200
committerMike Pall <mike>2011-03-28 15:06:30 +0200
commit492efb7e7e9dc6951677559a99a4cc8af4c74d3f (patch)
tree7ebcbda43c4f374a3c099d9b1a597f964da41fb8
parent32aef8aee46276b654eae14692b6a20c394e41c5 (diff)
downloadluajit-492efb7e7e9dc6951677559a99a4cc8af4c74d3f.tar.gz
luajit-492efb7e7e9dc6951677559a99a4cc8af4c74d3f.tar.bz2
luajit-492efb7e7e9dc6951677559a99a4cc8af4c74d3f.zip
Clean up DynASM glue macros. Thanks to Josh Haberman.
-rw-r--r--dynasm/dasm_proto.h23
-rw-r--r--src/buildvm.c14
2 files changed, 20 insertions, 17 deletions
diff --git a/dynasm/dasm_proto.h b/dynasm/dasm_proto.h
index 7d3f77f6..7fac22ab 100644
--- a/dynasm/dasm_proto.h
+++ b/dynasm/dasm_proto.h
@@ -14,17 +14,34 @@
14#define DASM_VERSION 10202 /* 1.2.2 */ 14#define DASM_VERSION 10202 /* 1.2.2 */
15 15
16#ifndef Dst_DECL 16#ifndef Dst_DECL
17#define Dst_DECL dasm_State *Dst 17#define Dst_DECL dasm_State **Dst
18#endif 18#endif
19 19
20#ifndef Dst_GET 20#ifndef Dst_REF
21#define Dst_GET (Dst) 21#define Dst_REF (*Dst)
22#endif 22#endif
23 23
24#ifndef DASM_FDEF 24#ifndef DASM_FDEF
25#define DASM_FDEF extern 25#define DASM_FDEF extern
26#endif 26#endif
27 27
28#ifndef DASM_M_GROW
29#define DASM_M_GROW(ctx, t, p, sz, need) \
30 do { \
31 size_t _sz = (sz), _need = (need); \
32 if (_sz < _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); \
37 (sz) = _sz; \
38 } \
39 } while(0)
40#endif
41
42#ifndef DASM_M_FREE
43#define DASM_M_FREE(ctx, p, sz) free(p)
44#endif
28 45
29/* Internal DynASM encoder state. */ 46/* Internal DynASM encoder state. */
30typedef struct dasm_State dasm_State; 47typedef struct dasm_State dasm_State;
diff --git a/src/buildvm.c b/src/buildvm.c
index d69fc1d6..152c95f0 100644
--- a/src/buildvm.c
+++ b/src/buildvm.c
@@ -42,20 +42,6 @@
42#include "../dynasm/dasm_proto.h" 42#include "../dynasm/dasm_proto.h"
43 43
44/* Glue macros for DynASM. */ 44/* Glue macros for DynASM. */
45#define DASM_M_GROW(ctx, t, p, sz, need) \
46 do { \
47 size_t _sz = (sz), _need = (need); \
48 if (_sz < _need) { \
49 if (_sz < 16) _sz = 16; \
50 while (_sz < _need) _sz += _sz; \
51 (p) = (t *)realloc((p), _sz); \
52 if ((p) == NULL) exit(1); \
53 (sz) = _sz; \
54 } \
55 } while(0)
56
57#define DASM_M_FREE(ctx, p, sz) free(p)
58
59static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type); 45static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type);
60 46
61#define DASM_EXTERN(ctx, addr, idx, type) \ 47#define DASM_EXTERN(ctx, addr, idx, type) \