aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR. Blaine Whittle <[email protected]>2013-02-19 16:59:48 +0100
committerSverker Eriksson <[email protected]>2013-02-21 18:44:06 +0100
commit944fca78d202712848e317ec666647e8db78bcb4 (patch)
tree2acd1f8688bfd644557b18358f59faceb52b416b
parentd78e430de1f22ed122d58ad49984ff88a8171b8f (diff)
downloadotp-944fca78d202712848e317ec666647e8db78bcb4.tar.gz
otp-944fca78d202712848e317ec666647e8db78bcb4.tar.bz2
otp-944fca78d202712848e317ec666647e8db78bcb4.zip
erts: Correct term type for printf %T
-rw-r--r--erts/emulator/beam/erl_printf_term.c9
-rw-r--r--erts/emulator/beam/erl_printf_term.h4
-rw-r--r--erts/include/internal/erl_printf_format.h11
-rw-r--r--erts/lib_src/common/erl_printf_format.c10
4 files changed, 23 insertions, 11 deletions
diff --git a/erts/emulator/beam/erl_printf_term.c b/erts/emulator/beam/erl_printf_term.c
index 2ec59febcb..ce544503bd 100644
--- a/erts/emulator/beam/erl_printf_term.c
+++ b/erts/emulator/beam/erl_printf_term.c
@@ -498,10 +498,13 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
}
int
-erts_printf_term(fmtfn_t fn, void* arg, unsigned long term, long precision,
- unsigned long* term_base)
+erts_printf_term(fmtfn_t fn, void* arg, ErlPfEterm term, long precision,
+ ErlPfEterm* term_base)
{
- int res = print_term(fn, arg, (Eterm)term, &precision, (Eterm*)term_base);
+ int res;
+ ASSERT(sizeof(ErlPfEterm) == sizeof(Eterm));
+
+ res = print_term(fn, arg, (Eterm)term, &precision, (Eterm*)term_base);
if (res < 0)
return res;
if (precision <= 0)
diff --git a/erts/emulator/beam/erl_printf_term.h b/erts/emulator/beam/erl_printf_term.h
index a48a3de34c..d9bf79a5ce 100644
--- a/erts/emulator/beam/erl_printf_term.h
+++ b/erts/emulator/beam/erl_printf_term.h
@@ -21,6 +21,6 @@
#define ERL_PRINTF_TERM_H__
#include "erl_printf_format.h"
-int erts_printf_term(fmtfn_t fn, void* arg, unsigned long term, long precision,
- unsigned long* term_base);
+int erts_printf_term(fmtfn_t fn, void* arg, ErlPfEterm term, long precision,
+ ErlPfEterm* term_base);
#endif
diff --git a/erts/include/internal/erl_printf_format.h b/erts/include/internal/erl_printf_format.h
index 6fe4af8fbb..0f35c41044 100644
--- a/erts/include/internal/erl_printf_format.h
+++ b/erts/include/internal/erl_printf_format.h
@@ -56,7 +56,16 @@ extern int erts_printf_uword(fmtfn_t, void*, char, int, int, ErlPfUWord);
extern int erts_printf_sword(fmtfn_t, void*, char, int, int, ErlPfSWord);
extern int erts_printf_double(fmtfn_t, void *, char, int, int, double);
-extern int (*erts_printf_eterm_func)(fmtfn_t, void*, unsigned long, long, unsigned long*);
+#ifdef HALFWORD_HEAP_EMULATOR
+# if SIZEOF_INT != 4
+# error Unsupported integer size for HALFWORD_HEAP_EMULATOR
+# endif
+typedef unsigned int ErlPfEterm;
+#else
+typedef ErlPfUWord ErlPfEterm;
+#endif
+
+extern int (*erts_printf_eterm_func)(fmtfn_t, void*, ErlPfEterm, long, ErlPfEterm*);
#endif /* ERL_PRINTF_FORMAT_H__ */
diff --git a/erts/lib_src/common/erl_printf_format.c b/erts/lib_src/common/erl_printf_format.c
index 7148b5149b..d40ad43a62 100644
--- a/erts/lib_src/common/erl_printf_format.c
+++ b/erts/lib_src/common/erl_printf_format.c
@@ -165,7 +165,7 @@ static char heX[] = "0123456789ABCDEF";
#define SIGN(X) ((X) > 0 ? 1 : ((X) < 0 ? -1 : 0))
#define USIGN(X) ((X) == 0 ? 0 : 1)
-int (*erts_printf_eterm_func)(fmtfn_t, void*, unsigned long, long, unsigned long*) = NULL;
+int (*erts_printf_eterm_func)(fmtfn_t, void*, ErlPfEterm, long, ErlPfEterm*) = NULL;
static int
noop_fn(void *vfp, char* buf, size_t len)
@@ -822,8 +822,8 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
case FMTC_T: /* Eterm */
case FMTC_R: { /* Eterm, Eterm* base (base ignored if !HALFWORD_HEAP) */
long prec;
- unsigned long eterm;
- unsigned long* eterm_base;
+ ErlPfEterm eterm;
+ ErlPfEterm* eterm_base;
if (!erts_printf_eterm_func)
return -EINVAL;
@@ -833,9 +833,9 @@ int erts_printf_format(fmtfn_t fn, void* arg, char* fmt, va_list ap)
prec = LONG_MAX;
else
prec = (long) precision;
- eterm = va_arg(ap, unsigned long);
+ eterm = va_arg(ap, ErlPfEterm);
eterm_base = ((fmt & FMTC_MASK) == FMTC_R) ?
- va_arg(ap, unsigned long*) : NULL;
+ va_arg(ap, ErlPfEterm*) : NULL;
if (width > 0 && !(fmt & FMTF_adj)) {
res = (*erts_printf_eterm_func)(noop_fn, NULL, eterm, prec, eterm_base);
if (res < 0)