dasm_proto.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. ** DynASM encoding engine prototypes.
  3. ** Copyright (C) 2005-2010 Mike Pall. All rights reserved.
  4. ** Released under the MIT/X license. See dynasm.lua for full copyright notice.
  5. */
  6. #ifndef _DASM_PROTO_H
  7. #define _DASM_PROTO_H
  8. #include <stddef.h>
  9. #include <stdarg.h>
  10. #define DASM_IDENT "DynASM 1.2.1"
  11. #define DASM_VERSION 10201 /* 1.2.1 */
  12. #ifndef Dst_DECL
  13. #define Dst_DECL dasm_State *Dst
  14. #endif
  15. #ifndef Dst_GET
  16. #define Dst_GET (Dst)
  17. #endif
  18. #ifndef DASM_FDEF
  19. #define DASM_FDEF extern
  20. #endif
  21. /* Internal DynASM encoder state. */
  22. typedef struct dasm_State dasm_State;
  23. /* Action list type. */
  24. typedef const unsigned char *dasm_ActList;
  25. /* Initialize and free DynASM state. */
  26. DASM_FDEF void dasm_init(Dst_DECL, int maxsection);
  27. DASM_FDEF void dasm_free(Dst_DECL);
  28. /* Setup global array. Must be called before dasm_setup(). */
  29. DASM_FDEF void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl);
  30. /* Grow PC label array. Can be called after dasm_setup(), too. */
  31. DASM_FDEF void dasm_growpc(Dst_DECL, unsigned int maxpc);
  32. /* Setup encoder. */
  33. DASM_FDEF void dasm_setup(Dst_DECL, dasm_ActList actionlist);
  34. /* Feed encoder with actions. Calls are generated by pre-processor. */
  35. DASM_FDEF void dasm_put(Dst_DECL, int start, ...);
  36. /* Link sections and return the resulting size. */
  37. DASM_FDEF int dasm_link(Dst_DECL, size_t *szp);
  38. /* Encode sections into buffer. */
  39. DASM_FDEF int dasm_encode(Dst_DECL, void *buffer);
  40. /* Get PC label offset. */
  41. DASM_FDEF int dasm_getpclabel(Dst_DECL, unsigned int pc);
  42. #ifdef DASM_CHECKS
  43. /* Optional sanity checker to call between isolated encoding steps. */
  44. DASM_FDEF int dasm_checkstep(Dst_DECL, int secmatch);
  45. #else
  46. #define dasm_checkstep(a, b) 0
  47. #endif
  48. #endif /* _DASM_PROTO_H */