Skip to content

Commit

Permalink
removed a number of pointer to unsigned long casts as unsigned long i…
Browse files Browse the repository at this point in the history
…s a 32 bit value on Win64.
  • Loading branch information
R. Blaine Whittle committed Feb 6, 2013
1 parent 28dce0b commit 1d21ce8
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 80 deletions.
4 changes: 2 additions & 2 deletions erts/emulator/beam/beam_catches.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void beam_catches_delmod(unsigned head, BeamInstr *code, unsigned code_bytes,
erl_exit(1,
"beam_catches_delmod: item %#x has cp %#lx which is not "
"in module's range [%#lx,%#lx[\r\n",
i, (long)p->beam_catches[i].cp,
(long)code, (long)((char*)code + code_bytes));
i, (Uint)p->beam_catches[i].cp,
(Uint)code, (Uint)((char*)code + code_bytes));
}
p->beam_catches[i].cp = 0;
cdr = p->beam_catches[i].cdr;
Expand Down
6 changes: 3 additions & 3 deletions erts/emulator/beam/erl_db_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3416,7 +3416,7 @@ static DMCRet dmc_one_term(DMCContext *context,
default:
erl_exit(1, "db_match_compile: "
"Bad object on heap: 0x%08lx\n",
(unsigned long) c);
(Uint) c);
}
return retOk;
}
Expand Down Expand Up @@ -4861,7 +4861,7 @@ static Eterm my_copy_struct(Eterm t, Eterm **hp, ErlOffHeap* off_heap)
ret = copy_struct(b,sz,hp,off_heap);
} else {
erl_exit(1, "Trying to constant-copy non constant expression "
"0x%08x in (d)ets:match compilation.", (unsigned long) t);
"0x%08x in (d)ets:match compilation.", (Uint) t);
}
} else {
sz = size_object(t);
Expand Down Expand Up @@ -5407,7 +5407,7 @@ void db_match_dis(Binary *bp)
first = 0;
else
erts_printf(", ");
erts_printf("0x%08x", (unsigned long) tmp);
erts_printf("0x%08x", (Uint) tmp);
}
erts_printf("}\n");
erts_printf("num_bindings: %d\n", prog->num_bindings);
Expand Down
2 changes: 1 addition & 1 deletion erts/emulator/beam/erl_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ erts_next_heap_size(Uint size, Uint offset)
low = mid + 1;
}
}
erl_exit(1, "no next heap size found: %lu, offset %lu\n", (unsigned long)size, (unsigned long)offset);
erl_exit(1, "no next heap size found: %lu, offset %lu\n", (Uint)size, (Uint)offset);
}
return 0;
}
Expand Down
58 changes: 29 additions & 29 deletions erts/emulator/beam/erl_printf_term.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ do { \
(CNT) += res__; \
} while (0)

#define PRINT_ULONG(CNT, FN, ARG, C, P, W, I) \
#define PRINT_UINT(CNT, FN, ARG, C, P, W, I) \
do { \
int res__ = erts_printf_ulong((FN), (ARG), (C), (P), (W), (I)); \
int res__ = erts_printf_uint((FN), (ARG), (C), (P), (W), (I)); \
if (res__ < 0) \
return res__; \
(CNT) += res__; \
} while (0)

#define PRINT_SLONG(CNT, FN, ARG, C, P, W, I) \
#define PRINT_SINT(CNT, FN, ARG, C, P, W, I) \
do { \
int res__ = erts_printf_slong((FN), (ARG), (C), (P), (W), (I)); \
int res__ = erts_printf_sint((FN), (ARG), (C), (P), (W), (I)); \
if (res__ < 0) \
return res__; \
(CNT) += res__; \
Expand Down Expand Up @@ -153,7 +153,7 @@ static int print_atom_name(fmtfn_t fn, void* arg, Eterm atom, long *dcount)

if ((i < 0) || (i >= atom_table_size()) || (atom_tab(i) == NULL)) {
PRINT_STRING(res, fn, arg, "<bad atom index: ");
PRINT_SLONG(res, fn, arg, 'd', 0, 1, (signed long) i);
PRINT_SINT(res, fn, arg, 'd', 0, 1, (ErlPfSint) i);
PRINT_CHAR(res, fn, arg, '>');
return res;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ static int print_atom_name(fmtfn_t fn, void* arg, Eterm atom, long *dcount)
default:
if (IS_CNTRL(c)) {
PRINT_CHAR(res, fn, arg, '\\');
PRINT_ULONG(res, fn, arg, 'o', 1, 3, (unsigned long) c);
PRINT_UINT(res, fn, arg, 'o', 1, 3, (ErlPfUint) c);
}
else
PRINT_CHAR(res, fn, arg, (char) c);
Expand Down Expand Up @@ -334,7 +334,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
break;
}
case SMALL_DEF:
PRINT_SLONG(res, fn, arg, 'd', 0, 1, (signed long) signed_val(obj));
PRINT_SINT(res, fn, arg, 'd', 0, 1, (ErlPfSint) signed_val(obj));
break;
case BIG_DEF: {
int print_res;
Expand All @@ -360,36 +360,36 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
case REF_DEF:
case EXTERNAL_REF_DEF:
PRINT_STRING(res, fn, arg, "#Ref<");
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
(unsigned long) ref_channel_no(wobj));
PRINT_UINT(res, fn, arg, 'u', 0, 1,
(ErlPfUint) ref_channel_no(wobj));
ref_num = ref_numbers(wobj);
for (i = ref_no_of_numbers(wobj)-1; i >= 0; i--) {
PRINT_CHAR(res, fn, arg, '.');
PRINT_ULONG(res, fn, arg, 'u', 0, 1, (unsigned long) ref_num[i]);
PRINT_UINT(res, fn, arg, 'u', 0, 1, (ErlPfUint) ref_num[i]);
}
PRINT_CHAR(res, fn, arg, '>');
break;
case PID_DEF:
case EXTERNAL_PID_DEF:
PRINT_CHAR(res, fn, arg, '<');
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
(unsigned long) pid_channel_no(wobj));
PRINT_UINT(res, fn, arg, 'u', 0, 1,
(ErlPfUint) pid_channel_no(wobj));
PRINT_CHAR(res, fn, arg, '.');
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
(unsigned long) pid_number(wobj));
PRINT_UINT(res, fn, arg, 'u', 0, 1,
(ErlPfUint) pid_number(wobj));
PRINT_CHAR(res, fn, arg, '.');
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
(unsigned long) pid_serial(wobj));
PRINT_UINT(res, fn, arg, 'u', 0, 1,
(ErlPfUint) pid_serial(wobj));
PRINT_CHAR(res, fn, arg, '>');
break;
case PORT_DEF:
case EXTERNAL_PORT_DEF:
PRINT_STRING(res, fn, arg, "#Port<");
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
(unsigned long) port_channel_no(wobj));
PRINT_UINT(res, fn, arg, 'u', 0, 1,
(ErlPfUint) port_channel_no(wobj));
PRINT_CHAR(res, fn, arg, '.');
PRINT_ULONG(res, fn, arg, 'u', 0, 1,
(unsigned long) port_number(wobj));
PRINT_UINT(res, fn, arg, 'u', 0, 1,
(ErlPfUint) port_number(wobj));
PRINT_CHAR(res, fn, arg, '>');
break;
case LIST_DEF:
Expand Down Expand Up @@ -446,7 +446,7 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
PRINT_STRING(res, fn, arg, "<<1 byte>>");
else {
PRINT_STRING(res, fn, arg, "<<");
PRINT_ULONG(res, fn, arg, 'u', 0, 1, (unsigned long) pb->size);
PRINT_UINT(res, fn, arg, 'u', 0, 1, (ErlPfUint) pb->size);
PRINT_STRING(res, fn, arg, " bytes>>");
}
}
Expand All @@ -462,8 +462,8 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
PRINT_CHAR(res, fn, arg, '.');
PRINT_BUF(res, fn, arg, name->name, name->len);
PRINT_CHAR(res, fn, arg, '.');
PRINT_SLONG(res, fn, arg, 'd', 0, 1,
(signed long) ep->code[2]);
PRINT_SINT(res, fn, arg, 'd', 0, 1,
(ErlPfSint) ep->code[2]);
PRINT_CHAR(res, fn, arg, '>');
}
break;
Expand All @@ -475,11 +475,11 @@ print_term(fmtfn_t fn, void* arg, Eterm obj, long *dcount,
PRINT_STRING(res, fn, arg, "#Fun<");
PRINT_BUF(res, fn, arg, ap->name, ap->len);
PRINT_CHAR(res, fn, arg, '.');
PRINT_SLONG(res, fn, arg, 'd', 0, 1,
(signed long) funp->fe->old_index);
PRINT_SINT(res, fn, arg, 'd', 0, 1,
(ErlPfSint) funp->fe->old_index);
PRINT_CHAR(res, fn, arg, '.');
PRINT_SLONG(res, fn, arg, 'd', 0, 1,
(signed long) funp->fe->old_uniq);
PRINT_SINT(res, fn, arg, 'd', 0, 1,
(ErlPfSint) funp->fe->old_uniq);
PRINT_CHAR(res, fn, arg, '>');
}
break;
Expand All @@ -498,8 +498,8 @@ 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);
if (res < 0)
Expand Down
4 changes: 2 additions & 2 deletions erts/emulator/beam/erl_printf_term.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
51 changes: 48 additions & 3 deletions erts/include/internal/erl_printf_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,47 @@
#include <vxWorks.h>
#endif

#include "erl_int_sizes_config.h"
#if !((SIZEOF_VOID_P >= 4) && (SIZEOF_VOID_P == SIZEOF_SIZE_T) \
&& ((SIZEOF_VOID_P == SIZEOF_INT) || (SIZEOF_VOID_P == SIZEOF_LONG) || \
(SIZEOF_VOID_P == SIZEOF_LONG_LONG)))
#error Cannot handle this combination of int/long/void*/size_t sizes
#endif

#if SIZEOF_VOID_P != SIZEOF_SIZE_T
#error sizeof(void*) != sizeof(size_t)
#endif

#if HALFWORD_HEAP

#if SIZEOF_INT == 4
typedef unsigned int ErlPfEterm;
typedef unsigned int ErlPfUint;
typedef int ErlPfSint;
#else
#error Found no appropriate type to use for 'Eterm', 'Uint' and 'Sint'
#endif

#else /* !HALFWORD_HEAP */

#if SIZEOF_VOID_P == SIZEOF_LONG
typedef unsigned long ErlPfEterm;
typedef unsigned long ErlPfUint;
typedef long ErlPfSint;
#elif SIZEOF_VOID_P == SIZEOF_INT
typedef unsigned int ErlPfEterm;
typedef unsigned int ErlPfUint;
typedef int ErlPfSint;
#elif SIZEOF_VOID_P == SIZEOF_LONG_LONG
typedef unsigned long long ErlPfEterm;
typedef unsigned long long ErlPfUint;
typedef long long ErlPfSint;
#else
#error Found no appropriate type to use for 'Eterm', 'Uint' and 'Sint'
#endif

#endif /* HALFWORD_HEAP */

#include <sys/types.h>
#include <stdarg.h>
#include <stdlib.h>
Expand All @@ -36,11 +77,15 @@ extern int erts_printf_char(fmtfn_t, void*, char);
extern int erts_printf_string(fmtfn_t, void*, char *);
extern int erts_printf_buf(fmtfn_t, void*, char *, size_t);
extern int erts_printf_pointer(fmtfn_t, void*, void *);
extern int erts_printf_ulong(fmtfn_t, void*, char, int, int, unsigned long);
extern int erts_printf_slong(fmtfn_t, void*, char, int, int, signed long);
extern int erts_printf_uint(fmtfn_t, void*, char, int, int, ErlPfUint);
extern int erts_printf_sint(fmtfn_t, void*, char, int, int, ErlPfSint);
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*);
extern int (*erts_printf_eterm_func)(fmtfn_t, void*, ErlPfEterm, long, ErlPfEterm*);

#ifdef __cplusplus
}
#endif

#endif

3 changes: 2 additions & 1 deletion erts/lib_src/common/erl_misc_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ struct erts_cpu_info_t_ {
static __forceinline int
get_proc_affinity(erts_cpu_info_t *cpuinfo, cpu_set_t *cpuset)
{
DWORD pamask, samask;
DWORD_PTR pamask;
DWORD_PTR samask;
if (GetProcessAffinityMask(GetCurrentProcess(), &pamask, &samask)) {
*cpuset = (cpu_set_t) pamask;
return 0;
Expand Down
Loading

0 comments on commit 1d21ce8

Please sign in to comment.