diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-09-19 21:40:37 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-09-19 21:40:37 -0700 |
commit | 87f252aaa53f8ce5305d84c95a8751592f647dc2 (patch) | |
tree | 9c39b2286aa34d504172bbe4c99a3d2631aeeaa8 /nasmlib.h | |
parent | eb49a4e1d402d5a1ce95e495787b900aa5303a47 (diff) | |
download | nasm-87f252aaa53f8ce5305d84c95a8751592f647dc2.tar.gz |
Make nasm_malloc() et al available from inside ndisasm
Clean up nasmlib to remove functions irrelevant for ndisasm; make
nasm_malloc() etc usable inside ndisasm.
Diffstat (limited to 'nasmlib.h')
-rw-r--r-- | nasmlib.h | 58 |
1 files changed, 42 insertions, 16 deletions
@@ -23,13 +23,54 @@ /* #define LOGALLOC */ /* + * ------------------------- + * Error reporting functions + * ------------------------- + */ + +/* + * An error reporting function should look like this. + */ +typedef void (*efunc) (int severity, const char *fmt, ...); + +/* + * These are the error severity codes which get passed as the first + * argument to an efunc. + */ + +#define ERR_DEBUG 0x00000008 /* put out debugging message */ +#define ERR_WARNING 0x00000000 /* warn only: no further action */ +#define ERR_NONFATAL 0x00000001 /* terminate assembly after phase */ +#define ERR_FATAL 0x00000002 /* instantly fatal: exit with error */ +#define ERR_PANIC 0x00000003 /* internal error: panic instantly + * and dump core for reference */ +#define ERR_MASK 0x0000000F /* mask off the above codes */ +#define ERR_NOFILE 0x00000010 /* don't give source file name/line */ +#define ERR_USAGE 0x00000020 /* print a usage message */ +#define ERR_PASS1 0x00000040 /* only print this error on pass one */ + +/* + * These codes define specific types of suppressible warning. + */ + +#define ERR_WARN_MASK 0x0000FF00 /* the mask for this feature */ +#define ERR_WARN_SHR 8 /* how far to shift right */ + +#define ERR_WARN_MNP 0x00000100 /* macro-num-parameters warning */ +#define ERR_WARN_MSR 0x00000200 /* macro self-reference */ +#define ERR_WARN_OL 0x00000300 /* orphan label (no colon, and + * alone on line) */ +#define ERR_WARN_NOV 0x00000400 /* numeric overflow */ +#define ERR_WARN_GNUELF 0x00000500 /* using GNU ELF extensions */ +#define ERR_WARN_MAX 5 /* the highest numbered one */ + +/* * Wrappers around malloc, realloc and free. nasm_malloc will * fatal-error and die rather than return NULL; nasm_realloc will * do likewise, and will also guarantee to work right on being * passed a NULL pointer; nasm_free will do nothing if it is passed * a NULL pointer. */ -#ifdef NASM_NASM_H /* need efunc defined for this */ void nasm_set_malloc_error(efunc); #ifndef LOGALLOC void *nasm_malloc(size_t); @@ -49,7 +90,6 @@ char *nasm_strndup_log(char *, int, char *, size_t); #define nasm_strdup(x) nasm_strdup_log(__FILE__,__LINE__,x) #define nasm_strndup(x,y) nasm_strndup_log(__FILE__,__LINE__,x,y) #endif -#endif /* * ANSI doesn't guarantee the presence of `stricmp' or @@ -234,20 +274,6 @@ void saa_fread(struct SAA *s, int32_t posn, void *p, int32_t len); /* fixup * void saa_fwrite(struct SAA *s, int32_t posn, void *p, int32_t len); /* fixup */ void saa_fpwrite(struct SAA *, FILE *); -#ifdef NASM_NASM_H -/* - * Library routines to manipulate expression data types. - */ -int is_reloc(expr *); -int is_simple(expr *); -int is_really_simple(expr *); -int is_unknown(expr *); -int is_just_unknown(expr *); -int64_t reloc_value(expr *); -int32_t reloc_seg(expr *); -int32_t reloc_wrt(expr *); -#endif - /* * Binary search routine. Returns index into `array' of an entry * matching `string', or <0 if no match. `array' is taken to |