aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/beam_load.c7
-rw-r--r--erts/emulator/beam/big.c2
-rw-r--r--erts/emulator/beam/dist.c2
-rw-r--r--erts/emulator/beam/erl_alloc.c46
-rw-r--r--erts/emulator/beam/erl_alloc.h8
-rw-r--r--erts/emulator/beam/erl_alloc_util.h2
-rw-r--r--erts/emulator/beam/erl_bif_guard.c4
-rw-r--r--erts/emulator/beam/erl_driver.h12
-rw-r--r--erts/emulator/beam/erl_nif.c4
-rw-r--r--erts/emulator/beam/erl_nmgc.c2
-rw-r--r--erts/emulator/beam/global.h9
-rw-r--r--erts/emulator/beam/io.c20
-rw-r--r--erts/emulator/beam/sys.h13
13 files changed, 71 insertions, 60 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index d8434c098e..e6fbdc0d45 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -1434,7 +1434,7 @@ static int
read_literal_table(LoaderState* stp)
{
int i;
- BeamInstr uncompressed_sz;
+ uLongf uncompressed_sz;
byte* uncompressed = 0;
GetInt(stp, 4, uncompressed_sz);
@@ -1444,7 +1444,7 @@ read_literal_table(LoaderState* stp)
LoadError0(stp, "failed to uncompress literal table (constant pool)");
}
stp->file_p = uncompressed;
- stp->file_left = uncompressed_sz;
+ stp->file_left = (unsigned) uncompressed_sz;
GetInt(stp, 4, stp->num_literals);
stp->literals = (Literal *) erts_alloc(ERTS_ALC_T_LOADER_TMP,
stp->num_literals * sizeof(Literal));
@@ -3500,7 +3500,6 @@ gen_jump_tab(LoaderState* stp, GenOpArg S, GenOpArg Fail, GenOpArg Size, GenOpAr
}
size = max - min + 1;
-
/*
* Allocate structure and fill in the fixed fields.
*/
@@ -3532,7 +3531,7 @@ gen_jump_tab(LoaderState* stp, GenOpArg S, GenOpArg Fail, GenOpArg Size, GenOpAr
op->a[i] = Fail;
}
for (i = 0; i < Size.val; i += 2) {
- int index;
+ Sint index;
index = fixed_args+Rest[i].val-min;
ASSERT(fixed_args <= index && index < arity);
op->a[index] = Rest[i+1];
diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c
index 1c38ac3211..976f05c990 100644
--- a/erts/emulator/beam/big.c
+++ b/erts/emulator/beam/big.c
@@ -1325,7 +1325,7 @@ static dsize_t I_lshift(ErtsDigit* x, dsize_t xl, Sint y,
return 1;
}
else {
- long ay = (y < 0) ? -y : y;
+ SWord ay = (y < 0) ? -y : y;
int bw = ay / D_EXP;
int sw = ay % D_EXP;
dsize_t rl;
diff --git a/erts/emulator/beam/dist.c b/erts/emulator/beam/dist.c
index 44c5ba1e26..cfcdb72636 100644
--- a/erts/emulator/beam/dist.c
+++ b/erts/emulator/beam/dist.c
@@ -536,7 +536,7 @@ alloc_dist_obuf(Uint size)
Binary *bin = erts_bin_drv_alloc(obuf_size);
bin->flags = BIN_FLAG_DRV;
erts_refc_init(&bin->refc, 1);
- bin->orig_size = (long) obuf_size;
+ bin->orig_size = (SWord) obuf_size;
obuf = (ErtsDistOutputBuf *) &bin->orig_bytes[0];
#ifdef DEBUG
obuf->dbg_pattern = ERTS_DIST_OUTPUT_BUF_DBG_PATTERN;
diff --git a/erts/emulator/beam/erl_alloc.c b/erts/emulator/beam/erl_alloc.c
index 140a84d5fc..1379f8645a 100644
--- a/erts/emulator/beam/erl_alloc.c
+++ b/erts/emulator/beam/erl_alloc.c
@@ -3117,10 +3117,10 @@ void *safe_realloc(void *ptr, Uint sz)
\* */
#define ERTS_ALC_TEST_ABORT erl_exit(ERTS_ABORT_EXIT, "%s:%d: Internal error\n")
-unsigned long erts_alc_test(unsigned long op,
- unsigned long a1,
- unsigned long a2,
- unsigned long a3)
+UWord erts_alc_test(UWord op,
+ UWord a1,
+ UWord a2,
+ UWord a3)
{
switch (op >> 8) {
case 0x0: return erts_alcu_test(op, a1, a2);
@@ -3134,24 +3134,24 @@ unsigned long erts_alc_test(unsigned long op,
case 0xf00:
#ifdef USE_THREADS
if (((Allctr_t *) a1)->thread_safe)
- return (unsigned long) erts_alcu_alloc_ts(ERTS_ALC_T_UNDEF,
+ return (UWord) erts_alcu_alloc_ts(ERTS_ALC_T_UNDEF,
(void *) a1,
(Uint) a2);
else
#endif
- return (unsigned long) erts_alcu_alloc(ERTS_ALC_T_UNDEF,
+ return (UWord) erts_alcu_alloc(ERTS_ALC_T_UNDEF,
(void *) a1,
(Uint) a2);
case 0xf01:
#ifdef USE_THREADS
if (((Allctr_t *) a1)->thread_safe)
- return (unsigned long) erts_alcu_realloc_ts(ERTS_ALC_T_UNDEF,
+ return (UWord) erts_alcu_realloc_ts(ERTS_ALC_T_UNDEF,
(void *) a1,
(void *) a2,
(Uint) a3);
else
#endif
- return (unsigned long) erts_alcu_realloc(ERTS_ALC_T_UNDEF,
+ return (UWord) erts_alcu_realloc(ERTS_ALC_T_UNDEF,
(void *) a1,
(void *) a2,
(Uint) a3);
@@ -3181,7 +3181,7 @@ unsigned long erts_alc_test(unsigned long op,
if (argv[i][0] == '-' && argv[i][1] == 't')
handle_au_arg(&init, &argv[i][2], argv, &i);
else
- return (unsigned long) NULL;
+ return (UWord) NULL;
i++;
}
}
@@ -3222,25 +3222,25 @@ unsigned long erts_alc_test(unsigned long op,
break;
}
- return (unsigned long) allctr;
+ return (UWord) allctr;
}
case 0xf04:
erts_alcu_stop((Allctr_t *) a1);
erts_free(ERTS_ALC_T_UNDEF, (void *) a1);
break;
#ifdef USE_THREADS
- case 0xf05: return (unsigned long) 1;
- case 0xf06: return (unsigned long) ((Allctr_t *) a1)->thread_safe;
+ case 0xf05: return (UWord) 1;
+ case 0xf06: return (UWord) ((Allctr_t *) a1)->thread_safe;
#ifdef ETHR_NO_FORKSAFETY
- case 0xf07: return (unsigned long) 0;
+ case 0xf07: return (UWord) 0;
#else
- case 0xf07: return (unsigned long) ((Allctr_t *) a1)->thread_safe;
+ case 0xf07: return (UWord) ((Allctr_t *) a1)->thread_safe;
#endif
case 0xf08: {
ethr_mutex *mtx = erts_alloc(ERTS_ALC_T_UNDEF, sizeof(ethr_mutex));
if (ethr_mutex_init(mtx) != 0)
ERTS_ALC_TEST_ABORT;
- return (unsigned long) mtx;
+ return (UWord) mtx;
}
case 0xf09: {
ethr_mutex *mtx = (ethr_mutex *) a1;
@@ -3259,7 +3259,7 @@ unsigned long erts_alc_test(unsigned long op,
ethr_cond *cnd = erts_alloc(ERTS_ALC_T_UNDEF, sizeof(ethr_cond));
if (ethr_cond_init(cnd) != 0)
ERTS_ALC_TEST_ABORT;
- return (unsigned long) cnd;
+ return (UWord) cnd;
}
case 0xf0d: {
ethr_cond *cnd = (ethr_cond *) a1;
@@ -3285,7 +3285,7 @@ unsigned long erts_alc_test(unsigned long op,
(void *) a2,
NULL) != 0)
ERTS_ALC_TEST_ABORT;
- return (unsigned long) tid;
+ return (UWord) tid;
}
case 0xf11: {
ethr_tid *tid = (ethr_tid *) a1;
@@ -3302,13 +3302,13 @@ unsigned long erts_alc_test(unsigned long op,
default:
break;
}
- return (unsigned long) 0;
+ return (UWord) 0;
default:
break;
}
ASSERT(0);
- return ~((unsigned long) 0);
+ return ~((UWord) 0);
}
#ifdef DEBUG
@@ -3544,7 +3544,7 @@ check_memory_fence(void *ptr, Uint *size, ErtsAlcType_t n, int func)
erl_exit(ERTS_ABORT_EXIT,
"ERROR: Fence at beginning of memory block (p=0x%u) "
"clobbered.\n",
- (unsigned long) ptr);
+ (UWord) ptr);
}
memcpy((void *) &post_pattern, (void *) (((char *)ptr)+sz), sizeof(UWord));
@@ -3561,12 +3561,12 @@ check_memory_fence(void *ptr, Uint *size, ErtsAlcType_t n, int func)
erl_exit(ERTS_ABORT_EXIT,
"ERROR: Fence at end of memory block (p=0x%u, sz=%u) "
"clobbered.\n",
- (unsigned long) ptr, (unsigned long) sz);
+ (UWord) ptr, (UWord) sz);
if (found_type != GET_TYPE_OF_PATTERN(post_pattern))
erl_exit(ERTS_ABORT_EXIT,
"ERROR: Fence around memory block (p=0x%u, sz=%u) "
"clobbered.\n",
- (unsigned long) ptr, (unsigned long) sz);
+ (UWord) ptr, (UWord) sz);
ftype = type_no_str(found_type);
if (!ftype) {
@@ -3589,7 +3589,7 @@ check_memory_fence(void *ptr, Uint *size, ErtsAlcType_t n, int func)
erl_exit(ERTS_ABORT_EXIT,
"ERROR: Memory block (p=0x%u, sz=%u) allocated as type \"%s\","
" but %s as type \"%s\".\n",
- (unsigned long) ptr, (unsigned long) sz, ftype, op_str, otype);
+ (UWord) ptr, (UWord) sz, ftype, op_str, otype);
}
#ifdef HARD_DEBUG
diff --git a/erts/emulator/beam/erl_alloc.h b/erts/emulator/beam/erl_alloc.h
index f4133cdb1a..991061c48e 100644
--- a/erts/emulator/beam/erl_alloc.h
+++ b/erts/emulator/beam/erl_alloc.h
@@ -80,10 +80,10 @@ void erts_alloc_late_init(void);
#if defined(GET_ERTS_ALC_TEST) || defined(ERTS_ALC_INTERNAL__)
/* Only for testing */
-unsigned long erts_alc_test(unsigned long,
- unsigned long,
- unsigned long,
- unsigned long);
+UWord erts_alc_test(UWord,
+ UWord,
+ UWord,
+ UWord);
#endif
#define ERTS_ALC_O_ALLOC 0
diff --git a/erts/emulator/beam/erl_alloc_util.h b/erts/emulator/beam/erl_alloc_util.h
index df560a0de2..fc1eddb116 100644
--- a/erts/emulator/beam/erl_alloc_util.h
+++ b/erts/emulator/beam/erl_alloc_util.h
@@ -227,7 +227,7 @@ erts_aint32_t erts_alcu_fix_alloc_shrink(Allctr_t *, erts_aint32_t);
extern int erts_have_sbmbc_alloc;
-typedef union {char c[8]; long l; double d;} Unit_t;
+typedef union {char c[ERTS_ALLOC_ALIGN_BYTES]; long l; double d;} Unit_t;
typedef struct Carrier_t_ Carrier_t;
struct Carrier_t_ {
diff --git a/erts/emulator/beam/erl_bif_guard.c b/erts/emulator/beam/erl_bif_guard.c
index 01e6977a2c..dff59de69b 100644
--- a/erts/emulator/beam/erl_bif_guard.c
+++ b/erts/emulator/beam/erl_bif_guard.c
@@ -52,7 +52,7 @@ BIF_RETTYPE abs_1(BIF_ALIST_1)
/* integer arguments */
if (is_small(BIF_ARG_1)) {
i0 = signed_val(BIF_ARG_1);
- i = labs(i0);
+ i = ERTS_SMALL_ABS(i0);
if (i0 == MIN_SMALL) {
hp = HAlloc(BIF_P, BIG_UINT_HEAP_SIZE);
BIF_RET(uint_to_big(i, hp));
@@ -467,7 +467,7 @@ Eterm erts_gc_abs_1(Process* p, Eterm* reg, Uint live)
/* integer arguments */
if (is_small(arg)) {
i0 = signed_val(arg);
- i = labs(i0);
+ i = ERTS_SMALL_ABS(i0);
if (i0 == MIN_SMALL) {
if (ERTS_NEED_GC(p, BIG_UINT_HEAP_SIZE)) {
erts_garbage_collect(p, BIG_UINT_HEAP_SIZE, reg, live+1);
diff --git a/erts/emulator/beam/erl_driver.h b/erts/emulator/beam/erl_driver.h
index 547f5b44dc..25483380ed 100644
--- a/erts/emulator/beam/erl_driver.h
+++ b/erts/emulator/beam/erl_driver.h
@@ -160,10 +160,15 @@ typedef struct {
/*
* Integer types
*/
-
+#if defined(__WIN32__) && (SIZEOF_VOID_P == 8)
+typedef unsigned __int64 ErlDrvTermData;
+typedef unsigned __int64 ErlDrvUInt;
+typedef signed __int64 ErlDrvSInt;
+#else
typedef unsigned long ErlDrvTermData;
typedef unsigned long ErlDrvUInt;
typedef signed long ErlDrvSInt;
+#endif
#if defined(__WIN32__)
typedef unsigned __int64 ErlDrvUInt64;
@@ -184,10 +189,7 @@ typedef long long ErlDrvSInt64;
*/
typedef struct erl_drv_binary {
- long orig_size; /* total length of binary */
-#if SIZEOF_LONG < SIZEOF_VOID_P
- long _pad;
-#endif
+ ErlDrvSInt orig_size; /* total length of binary */
char orig_bytes[1]; /* the data (char instead of byte!) */
} ErlDrvBinary;
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index bf73c076e0..143f631f58 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -531,7 +531,7 @@ int enif_alloc_binary(size_t size, ErlNifBinary* bin)
}
refbin->flags = BIN_FLAG_DRV; /* BUGBUG: Flag? */
erts_refc_init(&refbin->refc, 1);
- refbin->orig_size = (long) size;
+ refbin->orig_size = (SWord) size;
bin->size = size;
bin->data = (unsigned char*) refbin->orig_bytes;
@@ -801,7 +801,7 @@ int enif_get_ulong(ErlNifEnv* env, Eterm term, unsigned long* ip)
unsigned int tmp;
ret = enif_get_uint(env,term,&tmp);
if (ret) {
- *ip = (long) tmp;
+ *ip = (unsigned long) tmp;
}
return ret;
#else
diff --git a/erts/emulator/beam/erl_nmgc.c b/erts/emulator/beam/erl_nmgc.c
index d7bfb2ab12..2a8c819360 100644
--- a/erts/emulator/beam/erl_nmgc.c
+++ b/erts/emulator/beam/erl_nmgc.c
@@ -1391,7 +1391,7 @@ Eterm *erts_inc_alloc(int need)
if (ma_gc_flags & GC_MAJOR) {
if (need > 254) {
blackmap[(Eterm*)this - global_old_heap] = 255;
- *(int*)((long)(&blackmap[(Eterm*)this - global_old_heap]+4) & ~3) =
+ *(int*)((UWord)(&blackmap[(Eterm*)this - global_old_heap]+4) & ~3) =
need;
} else
blackmap[(Eterm*)this - global_old_heap] = need;
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index e9b5e7e0e5..f98232246b 100644
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -172,7 +172,7 @@ struct port {
DistEntry *dist_entry; /* Dist entry used in DISTRIBUTION */
char *name; /* String used in the open */
erts_driver_t* drv_ptr;
- long drv_data;
+ UWord drv_data;
ErtsProcList *suspended; /* List of suspended processes. */
LineBuf *linebuf; /* Buffer to hold data not ready for
process to get (line oriented I/O)*/
@@ -398,10 +398,7 @@ extern Eterm erts_ddll_monitor_driver(Process *p,
typedef struct binary {
ERTS_INTERNAL_BINARY_FIELDS
- long orig_size;
-#if SIZEOF_LONG < SIZEOF_VOID_P
- long _pad;
-#endif
+ SWord orig_size;
char orig_bytes[1]; /* to be continued */
} Binary;
@@ -410,7 +407,7 @@ typedef struct binary {
typedef struct {
ERTS_INTERNAL_BINARY_FIELDS
- long orig_size;
+ SWord orig_size;
void (*destructor)(Binary *);
char magic_bin_data[1];
} ErtsMagicBinary;
diff --git a/erts/emulator/beam/io.c b/erts/emulator/beam/io.c
index 132dc78515..c2cc03509e 100644
--- a/erts/emulator/beam/io.c
+++ b/erts/emulator/beam/io.c
@@ -445,7 +445,7 @@ setup_port(Port* prt, Eterm pid, erts_driver_t *driver,
prt->control_flags = 0;
prt->connected = pid;
- prt->drv_data = (long) drv_data;
+ prt->drv_data = (SWord) drv_data;
prt->bytes_in = 0;
prt->bytes_out = 0;
prt->dist_entry = NULL;
@@ -648,7 +648,7 @@ erts_open_driver(erts_driver_t* driver, /* Pointer to driver. */
if (IS_TRACED_FL(port, F_TRACE_SCHED_PORTS)) {
trace_sched_ports_where(port, am_out, am_start);
}
- if (error_number_ptr && ((long) drv_data) == (long) -2)
+ if (error_number_ptr && ((SWord) drv_data) == (SWord) -2)
*error_number_ptr = errno;
#ifdef ERTS_SMP
if (port->xports)
@@ -657,10 +657,10 @@ erts_open_driver(erts_driver_t* driver, /* Pointer to driver. */
#endif
}
- if (((long)drv_data) == -1 ||
- ((long)drv_data) == -2 ||
- ((long)drv_data) == -3) {
- int res = (int) ((long) drv_data);
+ if (((SWord)drv_data) == -1 ||
+ ((SWord)drv_data) == -2 ||
+ ((SWord)drv_data) == -3) {
+ int res = (int) ((SWord) drv_data);
if (res == -3 && error_number_ptr) {
*error_number_ptr = BADARG;
@@ -689,7 +689,7 @@ erts_open_driver(erts_driver_t* driver, /* Pointer to driver. */
erts_port_release(port);
return res;
}
- port->drv_data = (long) drv_data;
+ port->drv_data = (SWord) drv_data;
return port_ix;
}
@@ -3083,7 +3083,7 @@ driver_deliver_term(ErlDrvPort port,
Binary* bp = erts_bin_nrml_alloc(size);
ASSERT(bufp);
bp->flags = 0;
- bp->orig_size = (long) size;
+ bp->orig_size = (SWord) size;
erts_refc_init(&bp->refc, 1);
sys_memcpy((void *) bp->orig_bytes, (void *) bufp, size);
pbp = (ProcBin *) hp;
@@ -3449,7 +3449,7 @@ driver_alloc_binary(int size)
return NULL; /* The driver write must take action */
bin->flags = BIN_FLAG_DRV;
erts_refc_init(&bin->refc, 1);
- bin->orig_size = (long) size;
+ bin->orig_size = (SWord) size;
return Binary2ErlDrvBinary(bin);
}
@@ -4076,7 +4076,7 @@ drv_cancel_timer(Port *prt)
erts_port_task_abort(prt->id, &prt->timeout_task);
}
-int driver_set_timer(ErlDrvPort ix, UWord t)
+int driver_set_timer(ErlDrvPort ix, unsigned long t)
{
Port* prt = erts_drvport2port(ix);
diff --git a/erts/emulator/beam/sys.h b/erts/emulator/beam/sys.h
index 0a42e45783..d8cd22a177 100644
--- a/erts/emulator/beam/sys.h
+++ b/erts/emulator/beam/sys.h
@@ -989,6 +989,19 @@ void erl_bin_write(unsigned char *, int, int);
#endif
+#ifdef __WIN32__
+#ifdef ARCH_64
+#define ERTS_ALLOC_ALIGN_BYTES 16
+#define ERTS_SMALL_ABS(Small) _abs64(Small)
+#else
+#define ERTS_ALLOC_ALIGN_BYTES 8
+#define ERTS_SMALL_ABS(Small) labs(Small)
+#endif
+#else
+#define ERTS_ALLOC_ALIGN_BYTES 8
+#define ERTS_SMALL_ABS(Small) labs(Small)
+#endif
+
#ifdef __WIN32__