From 421216a10ad76ab1887e54584849b9fcabe79c96 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 18 Sep 2015 01:39:17 +0200 Subject: [PATCH] 32bit fixes --- tools/cmpmrg_text.c | 2 +- tools/masm_tools.h | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/cmpmrg_text.c b/tools/cmpmrg_text.c index 38acd6d..561c9b2 100644 --- a/tools/cmpmrg_text.c +++ b/tools/cmpmrg_text.c @@ -474,7 +474,7 @@ static int check_equiv(uint8_t *d_obj, uint8_t *d_exe, int maxlen) break; if ((jo == len && je != len) || (jo != len && je == len)) { - printf("invalid equiv_op #%ld\n", op - equiv_ops); + printf("invalid equiv_op #%td\n", op - equiv_ops); return -1; } if (jo == len) diff --git a/tools/masm_tools.h b/tools/masm_tools.h index 717001f..cee4d62 100644 --- a/tools/masm_tools.h +++ b/tools/masm_tools.h @@ -1,7 +1,3 @@ -#if __SIZEOF_LONG__ != 8 -#error fix ret/strtoul to do 64bit -#endif - static unsigned long parse_number(const char *number) { int len = strlen(number); @@ -27,9 +23,16 @@ static unsigned long parse_number(const char *number) } if (bad) aerr("number parsing failed (%s)\n", number); - if (neg) +#if __SIZEOF_LONG__ > 4 + // if this happens, callers must be fixed too + if (ret > 0xfffffffful) + aerr("number too large? (%s)\n", number); +#endif + if (neg) { + if (ret > 0x7fffffff) + aerr("too large negative? (%s)\n", number); ret = -ret; + } return ret; } - -- 2.39.5