64-bit fixes.
Don't assume that sizeof(int) == sizeof(StgInt).
This assumption creeped in in many places since 6.2.
#if SIZEOF_INT == 4
#define CInt bits32
#if SIZEOF_INT == 4
#define CInt bits32
#define CInt bits64
#else
#error Unknown int size
#define CInt bits64
#else
#error Unknown int size
#if SIZEOF_LONG == 4
#define CLong bits32
#if SIZEOF_LONG == 4
#define CLong bits32
#define CLong bits64
#else
#error Unknown long size
#define CLong bits64
#else
#error Unknown long size
#define HALF_W_(x) %lobits32(x)
#endif
#define HALF_W_(x) %lobits32(x)
#endif
+#if SIZEOF_INT == 4 && SIZEOF_W == 8
+#define W_TO_INT(x) %lobits32(x)
+#elif SIZEOF_INT == SIZEOF_W
+#define W_TO_INT(x) (x)
+#endif
+
/* -----------------------------------------------------------------------------
Heap/stack access, and adjusting the heap/stack pointers.
-------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
Heap/stack access, and adjusting the heap/stack pointers.
-------------------------------------------------------------------------- */
TICK_ALLOC_HEAP_NOCTR(alloc);
#define MAYBE_GC(liveness,reentry) \
TICK_ALLOC_HEAP_NOCTR(alloc);
#define MAYBE_GC(liveness,reentry) \
- if (CInt[alloc_blocks] >= CInt[alloc_blocks_lim]) { \
+ if (W_[alloc_blocks] >= W_[alloc_blocks_lim]) { \
R9 = liveness; \
R10 = reentry; \
jump stg_gc_gen_hp; \
R9 = liveness; \
R10 = reentry; \
jump stg_gc_gen_hp; \
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: TSO.h,v 1.37 2004/11/08 12:26:57 simonmar Exp $
+ * $Id: TSO.h,v 1.38 2004/11/10 02:13:12 wolfgang Exp $
*
* (c) The GHC Team, 1998-1999
*
*
* (c) The GHC Team, 1998-1999
*
typedef union {
StgClosure *closure;
struct StgTSO_ *tso;
typedef union {
StgClosure *closure;
struct StgTSO_ *tso;
+ StgInt fd; // StgInt instead of int, so that it's the same size as the ptrs
#if defined(mingw32_TARGET_OS)
StgAsyncIOResult* async_result;
#endif
#if defined(mingw32_TARGET_OS)
StgAsyncIOResult* async_result;
#endif
inf = %GET_STD_INFO(p); \
np = TO_W_(%INFO_PTRS(inf)); \
nw = TO_W_(%INFO_NPTRS(inf)); \
inf = %GET_STD_INFO(p); \
np = TO_W_(%INFO_PTRS(inf)); \
nw = TO_W_(%INFO_NPTRS(inf)); \
- if (%INFO_TYPE(inf) != THUNK_SELECTOR::I16) { \
+ if (%INFO_TYPE(inf) != HALF_W_(THUNK_SELECTOR)) { \
i = 0; \
for: \
if (i < np + nw) { \
i = 0; \
for: \
if (i < np + nw) { \
/* ASSERT( p1 != p2 && !closure_IND(p1) ); \
*/ LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC(p1); \
bd = Bdescr(p1); \
/* ASSERT( p1 != p2 && !closure_IND(p1) ); \
*/ LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC(p1); \
bd = Bdescr(p1); \
- if (bdescr_gen_no(bd) == 0) { \
+ if (bdescr_gen_no(bd) == 0 :: CInt) { \
StgInd_indirectee(p1) = p2; \
SET_INFO(p1, ind_info); \
LDV_RECORD_CREATE(p1); \
StgInd_indirectee(p1) = p2; \
SET_INFO(p1, ind_info); \
LDV_RECORD_CREATE(p1); \
if (info != stg_BLACKHOLE_BQ_info) { \
DEBUG_FILL_SLOP(p1); \
W_ __mut_once_list; \
if (info != stg_BLACKHOLE_BQ_info) { \
DEBUG_FILL_SLOP(p1); \
W_ __mut_once_list; \
- __mut_once_list = generation(bdescr_gen_no(bd)) + \
+ __mut_once_list = generation(TO_W_(bdescr_gen_no(bd))) + \
OFFSET_generation_mut_once_list; \
StgMutClosure_mut_link(p1) = W_[__mut_once_list]; \
W_[__mut_once_list] = p1; \
OFFSET_generation_mut_once_list; \
StgMutClosure_mut_link(p1) = W_[__mut_once_list]; \
W_[__mut_once_list] = p1; \
CLOSE_NURSERY(); \
CurrentNursery = bdescr_link(CurrentNursery); \
OPEN_NURSERY(); \
CLOSE_NURSERY(); \
CurrentNursery = bdescr_link(CurrentNursery); \
OPEN_NURSERY(); \
- if (CInt[context_switch] != 0) { \
+ if (CInt[context_switch] != 0 :: CInt) { \
R1 = ThreadYielding; \
goto sched; \
} else { \
R1 = ThreadYielding; \
goto sched; \
} else { \
/* gettimeofday() takes around 1us on our 500MHz PIII. Since we're
* only calling it 50 times/s, it shouldn't have any great impact.
*/
/* gettimeofday() takes around 1us on our 500MHz PIII. Since we're
* only calling it 50 times/s, it shouldn't have any great impact.
*/
getourtimeofday(void)
{
struct timeval tv;
gettimeofday(&tv, (struct timezone *) NULL);
getourtimeofday(void)
{
struct timeval tv;
gettimeofday(&tv, (struct timezone *) NULL);
- return (tv.tv_sec * TICK_FREQUENCY +
- tv.tv_usec * TICK_FREQUENCY / 1000000);
+ // cast to nat because nat may be 64 bit when int is only 32 bit
+ return ((nat)tv.tv_sec * TICK_FREQUENCY +
+ (nat)tv.tv_usec * TICK_FREQUENCY / 1000000);
extern int startTicker( nat ms, TickProc handle_tick);
extern int stopTicker ( void );
extern int startTicker( nat ms, TickProc handle_tick);
extern int stopTicker ( void );
-extern unsigned int getourtimeofday ( void );
+extern nat getourtimeofday ( void );
#if 0
/* unused */
extern void block_vtalrm_signal ( void );
#if 0
/* unused */
extern void block_vtalrm_signal ( void );
#define GMP_TAKE2_RET1(name,mp_fun) \
name \
{ \
#define GMP_TAKE2_RET1(name,mp_fun) \
name \
{ \
+ CInt s1, s2; \
+ W_ d1, d2; \
\
/* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR & R4_PTR, name); \
\
\
/* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR & R4_PTR, name); \
\
- MP_INT__mp_alloc(mp_tmp1) = StgArrWords_words(d1); \
+ MP_INT__mp_alloc(mp_tmp1) = W_TO_INT(StgArrWords_words(d1)); \
MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
- MP_INT__mp_alloc(mp_tmp2) = StgArrWords_words(d2); \
+ MP_INT__mp_alloc(mp_tmp2) = W_TO_INT(StgArrWords_words(d2)); \
MP_INT__mp_size(mp_tmp2) = (s2); \
MP_INT__mp_d(mp_tmp2) = BYTE_ARR_CTS(d2); \
\
MP_INT__mp_size(mp_tmp2) = (s2); \
MP_INT__mp_d(mp_tmp2) = BYTE_ARR_CTS(d2); \
\
/* Perform the operation */ \
foreign "C" mp_fun(result1,mp_tmp1,mp_tmp2); \
\
/* Perform the operation */ \
foreign "C" mp_fun(result1,mp_tmp1,mp_tmp2); \
\
- RET_NP(MP_INT__mp_size(result1), \
+ RET_NP(TO_W_(MP_INT__mp_size(result1)), \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords); \
}
#define GMP_TAKE1_RET1(name,mp_fun) \
name \
{ \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords); \
}
#define GMP_TAKE1_RET1(name,mp_fun) \
name \
{ \
\
/* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR, name); \
\
d1 = R2; \
\
/* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR, name); \
\
d1 = R2; \
- MP_INT__mp_alloc(mp_tmp1) = StgArrWords_words(d1); \
+ MP_INT__mp_alloc(mp_tmp1) = W_TO_INT(StgArrWords_words(d1)); \
MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
\
MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
\
/* Perform the operation */ \
foreign "C" mp_fun(result1,mp_tmp1); \
\
/* Perform the operation */ \
foreign "C" mp_fun(result1,mp_tmp1); \
\
- RET_NP(MP_INT__mp_size(result1), \
+ RET_NP(TO_W_(MP_INT__mp_size(result1)), \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords); \
}
#define GMP_TAKE2_RET2(name,mp_fun) \
name \
{ \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords); \
}
#define GMP_TAKE2_RET2(name,mp_fun) \
name \
{ \
+ CInt s1, s2; \
+ W_ d1, d2; \
\
/* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR & R4_PTR, name); \
\
\
/* call doYouWantToGC() */ \
MAYBE_GC(R2_PTR & R4_PTR, name); \
\
- MP_INT__mp_alloc(mp_tmp1) = StgArrWords_words(d1); \
+ MP_INT__mp_alloc(mp_tmp1) = W_TO_INT(StgArrWords_words(d1)); \
MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
MP_INT__mp_size(mp_tmp1) = (s1); \
MP_INT__mp_d(mp_tmp1) = BYTE_ARR_CTS(d1); \
- MP_INT__mp_alloc(mp_tmp2) = StgArrWords_words(d2); \
+ MP_INT__mp_alloc(mp_tmp2) = W_TO_INT(StgArrWords_words(d2)); \
MP_INT__mp_size(mp_tmp2) = (s2); \
MP_INT__mp_d(mp_tmp2) = BYTE_ARR_CTS(d2); \
\
MP_INT__mp_size(mp_tmp2) = (s2); \
MP_INT__mp_d(mp_tmp2) = BYTE_ARR_CTS(d2); \
\
/* Perform the operation */ \
foreign "C" mp_fun(result1,result2,mp_tmp1,mp_tmp2); \
\
/* Perform the operation */ \
foreign "C" mp_fun(result1,result2,mp_tmp1,mp_tmp2); \
\
- RET_NPNP(MP_INT__mp_size(result1), \
+ RET_NPNP(TO_W_(MP_INT__mp_size(result1)), \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords, \
MP_INT__mp_d(result1) - SIZEOF_StgArrWords, \
- MP_INT__mp_size(result2), \
+ TO_W_(MP_INT__mp_size(result2)), \
MP_INT__mp_d(result2) - SIZEOF_StgArrWords); \
}
MP_INT__mp_d(result2) - SIZEOF_StgArrWords); \
}
cmp = foreign "C" mpn_cmp(up "ptr", vp "ptr", size);
cmp = foreign "C" mpn_cmp(up "ptr", vp "ptr", size);
+ if (cmp == 0 :: CInt) {
R1 = 0;
jump %ENTRY_CODE(Sp(0));
}
R1 = 0;
jump %ENTRY_CODE(Sp(0));
}
- if (%lt(cmp,0) == %lt(usize,0)) {
+ if (%lt(cmp,0 :: CInt) == %lt(usize,0)) {
R1 = 1;
} else {
R1 = (-1);
R1 = 1;
} else {
R1 = (-1);
foreign "C" __decodeFloat(mp_tmp1,exponent,arg);
/* returns: (Int# (expn), Int#, ByteArray#) */
foreign "C" __decodeFloat(mp_tmp1,exponent,arg);
/* returns: (Int# (expn), Int#, ByteArray#) */
- RET_NNP(W_[exponent], MP_INT__mp_size(mp_tmp1), p);
+ RET_NNP(W_[exponent], TO_W_(MP_INT__mp_size(mp_tmp1)), p);
}
#define DOUBLE_MANTISSA_SIZE SIZEOF_DOUBLE
}
#define DOUBLE_MANTISSA_SIZE SIZEOF_DOUBLE
foreign "C" __decodeDouble(mp_tmp1,exponent,arg);
/* returns: (Int# (expn), Int#, ByteArray#) */
foreign "C" __decodeDouble(mp_tmp1,exponent,arg);
/* returns: (Int# (expn), Int#, ByteArray#) */
- RET_NNP(W_[exponent], MP_INT__mp_size(mp_tmp1), p);
+ RET_NNP(W_[exponent], TO_W_(MP_INT__mp_size(mp_tmp1)), p);
}
/* -----------------------------------------------------------------------------
}
/* -----------------------------------------------------------------------------
foreign "C" scheduleThread(R1 "ptr");
// switch at the earliest opportunity
foreign "C" scheduleThread(R1 "ptr");
// switch at the earliest opportunity
- CInt[context_switch] = 1;
+ CInt[context_switch] = 1 :: CInt;
// This function is *only* used to wrap zero-arity BCOs in an
// updatable wrapper (see ByteCodeLink.lhs). An AP thunk is always
// saturated and always points directly to a FUN or BCO.
// This function is *only* used to wrap zero-arity BCOs in an
// updatable wrapper (see ByteCodeLink.lhs). An AP thunk is always
// saturated and always points directly to a FUN or BCO.
- ASSERT(%INFO_TYPE(%GET_STD_INFO(R1)) == BCO::I16 &&
- StgBCO_arity(R1) == 0::I16);
+ ASSERT(%INFO_TYPE(%GET_STD_INFO(R1)) == HALF_W_(BCO) &&
+ StgBCO_arity(R1) == HALF_W_(0));
HP_CHK_GEN_TICKY(SIZEOF_StgAP, R1_PTR, mkApUpd0zh_fast);
TICK_ALLOC_UP_THK(0, 0);
HP_CHK_GEN_TICKY(SIZEOF_StgAP, R1_PTR, mkApUpd0zh_fast);
TICK_ALLOC_UP_THK(0, 0);
ap = Hp - SIZEOF_StgAP + WDS(1);
SET_HDR(ap, stg_AP_info, W_[CCCS]);
ap = Hp - SIZEOF_StgAP + WDS(1);
SET_HDR(ap, stg_AP_info, W_[CCCS]);
- StgAP_n_args(ap) = 0::I16;
+ StgAP_n_args(ap) = HALF_W_(0);
StgAP_fun(ap) = R1;
RET_P(ap);
StgAP_fun(ap) = R1;
RET_P(ap);
time = foreign "C" getourtimeofday();
time = foreign "C" getourtimeofday();
- target = (R1 / (TICK_MILLISECS*1000)) + TO_W_(time);
+ target = (R1 / (TICK_MILLISECS*1000)) + time;
StgTSO_block_info(CurrentTSO) = target;
/* Insert the new thread in the sleeping queue. */
StgTSO_block_info(CurrentTSO) = target;
/* Insert the new thread in the sleeping queue. */
* When era reaches max_era, the profiling stops because a closure can
* store only up to (max_era - 1) as its creation or last use time.
* -------------------------------------------------------------------------- */
* When era reaches max_era, the profiling stops because a closure can
* store only up to (max_era - 1) as its creation or last use time.
* -------------------------------------------------------------------------- */
static nat max_era;
/* -----------------------------------------------------------------------------
static nat max_era;
/* -----------------------------------------------------------------------------