Commit 41737f12 authored by Simon Marlow's avatar Simon Marlow

Deprecate lnat, and use StgWord instead

lnat was originally "long unsigned int" but we were using it when we
wanted a 64-bit type on a 64-bit machine.  This broke on Windows x64,
where long == int == 32 bits.  Using types of unspecified size is bad,
but what we really wanted was a type with N bits on an N-bit machine.
StgWord is exactly that.

lnat was mentioned in some APIs that clients might be using
(e.g. StackOverflowHook()), so we leave it defined but with a comment
to say that it's deprecated.
parent a8179622
...@@ -40,7 +40,7 @@ defaultsHook (void) ...@@ -40,7 +40,7 @@ defaultsHook (void)
} }
void void
StackOverflowHook (lnat stack_size) /* in bytes */ StackOverflowHook (StgWord stack_size) /* in bytes */
{ {
fprintf(stderr, "GHC stack-space overflow: current limit is %zu bytes.\nUse the `-K<size>' option to increase it.\n", (size_t)stack_size); fprintf(stderr, "GHC stack-space overflow: current limit is %zu bytes.\nUse the `-K<size>' option to increase it.\n", (size_t)stack_size);
} }
......
...@@ -225,7 +225,7 @@ main(int argc, char *argv[]) ...@@ -225,7 +225,7 @@ main(int argc, char *argv[])
printf("#define BLOCK_SIZE %u\n", BLOCK_SIZE); printf("#define BLOCK_SIZE %u\n", BLOCK_SIZE);
printf("#define MBLOCK_SIZE %u\n", MBLOCK_SIZE); printf("#define MBLOCK_SIZE %u\n", MBLOCK_SIZE);
printf("#define BLOCKS_PER_MBLOCK %" FMT_SizeT "\n", (lnat)BLOCKS_PER_MBLOCK); printf("#define BLOCKS_PER_MBLOCK %" FMT_SizeT "\n", (W_)BLOCKS_PER_MBLOCK);
// could be derived, but better to save doing the calculation twice // could be derived, but better to save doing the calculation twice
printf("\n\n"); printf("\n\n");
......
...@@ -18,9 +18,9 @@ extern char *ghc_rts_opts; ...@@ -18,9 +18,9 @@ extern char *ghc_rts_opts;
extern void OnExitHook (void); extern void OnExitHook (void);
extern int NoRunnableThreadsHook (void); extern int NoRunnableThreadsHook (void);
extern void StackOverflowHook (lnat stack_size); extern void StackOverflowHook (W_ stack_size);
extern void OutOfHeapHook (lnat request_size, lnat heap_size); extern void OutOfHeapHook (W_ request_size, W_ heap_size);
extern void MallocFailHook (lnat request_size /* in bytes */, char *msg); extern void MallocFailHook (W_ request_size /* in bytes */, char *msg);
extern void defaultsHook (void); extern void defaultsHook (void);
#endif /* RTS_HOOKS_H */ #endif /* RTS_HOOKS_H */
...@@ -34,7 +34,7 @@ typedef struct SpinLock_ ...@@ -34,7 +34,7 @@ typedef struct SpinLock_
typedef StgWord SpinLock; typedef StgWord SpinLock;
#endif #endif
typedef lnat SpinLockCount; typedef StgWord SpinLockCount;
#if defined(PROF_SPIN) #if defined(PROF_SPIN)
......
...@@ -16,8 +16,10 @@ ...@@ -16,8 +16,10 @@
#include <stddef.h> #include <stddef.h>
typedef unsigned int nat; /* at least 32 bits (like int) */ typedef unsigned int nat; /* at least 32 bits (like int) */
typedef size_t lnat; /* at least 32 bits */
// Deprecated; just use StgWord instead
typedef StgWord lnat;
/* ullong (64|128-bit) type: only include if needed (not ANSI) */ /* ullong (64|128-bit) type: only include if needed (not ANSI) */
#if defined(__GNUC__) #if defined(__GNUC__)
......
...@@ -429,20 +429,20 @@ EXTERN_INLINE StgWord stack_frame_sizeW( StgClosure *frame ) ...@@ -429,20 +429,20 @@ EXTERN_INLINE StgWord stack_frame_sizeW( StgClosure *frame )
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
// The number of card bytes needed // The number of card bytes needed
INLINE_HEADER lnat mutArrPtrsCards (lnat elems) INLINE_HEADER W_ mutArrPtrsCards (W_ elems)
{ {
return (lnat)((elems + (1 << MUT_ARR_PTRS_CARD_BITS) - 1) return (W_)((elems + (1 << MUT_ARR_PTRS_CARD_BITS) - 1)
>> MUT_ARR_PTRS_CARD_BITS); >> MUT_ARR_PTRS_CARD_BITS);
} }
// The number of words in the card table // The number of words in the card table
INLINE_HEADER lnat mutArrPtrsCardTableSize (lnat elems) INLINE_HEADER W_ mutArrPtrsCardTableSize (W_ elems)
{ {
return ROUNDUP_BYTES_TO_WDS(mutArrPtrsCards(elems)); return ROUNDUP_BYTES_TO_WDS(mutArrPtrsCards(elems));
} }
// The address of the card for a particular card number // The address of the card for a particular card number
INLINE_HEADER StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, lnat n) INLINE_HEADER StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, W_ n)
{ {
return ((StgWord8 *)&(a->payload[a->ptrs]) + n); return ((StgWord8 *)&(a->payload[a->ptrs]) + n);
} }
......
...@@ -149,8 +149,8 @@ extern generation * oldest_gen; ...@@ -149,8 +149,8 @@ extern generation * oldest_gen;
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
StgPtr allocate ( Capability *cap, lnat n ); StgPtr allocate ( Capability *cap, W_ n );
StgPtr allocatePinned ( Capability *cap, lnat n ); StgPtr allocatePinned ( Capability *cap, W_ n );
/* memory allocator for executable memory */ /* memory allocator for executable memory */
void * allocateExec(unsigned int len, void **exec_addr); void * allocateExec(unsigned int len, void **exec_addr);
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#ifndef RTS_STORAGE_MBLOCK_H #ifndef RTS_STORAGE_MBLOCK_H
#define RTS_STORAGE_MBLOCK_H #define RTS_STORAGE_MBLOCK_H
extern lnat peak_mblocks_allocated; extern W_ peak_mblocks_allocated;
extern lnat mblocks_allocated; extern W_ mblocks_allocated;
extern void initMBlocks(void); extern void initMBlocks(void);
extern void * getMBlock(void); extern void * getMBlock(void);
...@@ -156,7 +156,7 @@ typedef struct { ...@@ -156,7 +156,7 @@ typedef struct {
MBlockMapLine lines[MBLOCK_MAP_ENTRIES]; MBlockMapLine lines[MBLOCK_MAP_ENTRIES];
} MBlockMap; } MBlockMap;
extern lnat mpc_misses; extern W_ mpc_misses;
StgBool HEAP_ALLOCED_miss(StgWord mblock, void *p); StgBool HEAP_ALLOCED_miss(StgWord mblock, void *p);
......
...@@ -80,7 +80,7 @@ arenaAlloc( Arena *arena, size_t size ) ...@@ -80,7 +80,7 @@ arenaAlloc( Arena *arena, size_t size )
return p; return p;
} else { } else {
// allocate a fresh block... // allocate a fresh block...
req_blocks = (lnat)BLOCK_ROUND_UP(size) / BLOCK_SIZE; req_blocks = (W_)BLOCK_ROUND_UP(size) / BLOCK_SIZE;
bd = allocGroup_lock(req_blocks); bd = allocGroup_lock(req_blocks);
arena_blocks += req_blocks; arena_blocks += req_blocks;
......
...@@ -123,7 +123,7 @@ struct Capability_ { ...@@ -123,7 +123,7 @@ struct Capability_ {
SparkCounters spark_stats; SparkCounters spark_stats;
#endif #endif
// Total words allocated by this cap since rts start // Total words allocated by this cap since rts start
lnat total_allocated; W_ total_allocated;
// Per-capability STM-related data // Per-capability STM-related data
StgTVarWatchQueue *free_tvar_watch_queues; StgTVarWatchQueue *free_tvar_watch_queues;
......
...@@ -80,7 +80,7 @@ disInstr ( StgBCO *bco, int pc ) ...@@ -80,7 +80,7 @@ disInstr ( StgBCO *bco, int pc )
pc += 1; break; pc += 1; break;
case bci_STKCHECK: { case bci_STKCHECK: {
StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1; StgWord stk_words_reqd = BCO_GET_LARGE_ARG + 1;
debugBelch("STKCHECK %" FMT_SizeT "\n", (lnat)stk_words_reqd ); debugBelch("STKCHECK %" FMT_SizeT "\n", (W_)stk_words_reqd );
break; break;
} }
case bci_PUSH_L: case bci_PUSH_L:
......
...@@ -296,7 +296,7 @@ numLabel( GtkWidget *lbl, nat n ) ...@@ -296,7 +296,7 @@ numLabel( GtkWidget *lbl, nat n )
} }
void void
updateFrontPanelAfterGC( nat N, lnat live ) updateFrontPanelAfterGC( nat N, W_ live )
{ {
char buf[1000]; char buf[1000];
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
void initFrontPanel( void ); void initFrontPanel( void );
void stopFrontPanel( void ); void stopFrontPanel( void );
void updateFrontPanelBeforeGC( nat N ); void updateFrontPanelBeforeGC( nat N );
void updateFrontPanelAfterGC( nat N, lnat live ); void updateFrontPanelAfterGC( nat N, W_ live );
void updateFrontPanel( void ); void updateFrontPanel( void );
......
...@@ -1900,7 +1900,7 @@ mmap_again: ...@@ -1900,7 +1900,7 @@ mmap_again:
MAP_PRIVATE|TRY_MAP_32BIT|fixed|flags, fd, 0); MAP_PRIVATE|TRY_MAP_32BIT|fixed|flags, fd, 0);
if (result == MAP_FAILED) { if (result == MAP_FAILED) {
sysErrorBelch("mmap %" FMT_SizeT " bytes at %p",(lnat)size,map_addr); sysErrorBelch("mmap %" FMT_SizeT " bytes at %p",(W_)size,map_addr);
errorBelch("Try specifying an address with +RTS -xm<addr> -RTS"); errorBelch("Try specifying an address with +RTS -xm<addr> -RTS");
stg_exit(EXIT_FAILURE); stg_exit(EXIT_FAILURE);
} }
...@@ -1943,7 +1943,7 @@ mmap_again: ...@@ -1943,7 +1943,7 @@ mmap_again:
} }
#endif #endif
IF_DEBUG(linker, debugBelch("mmapForLinker: mapped %" FMT_SizeT " bytes starting at %p\n", (lnat)size, result)); IF_DEBUG(linker, debugBelch("mmapForLinker: mapped %" FMT_SizeT " bytes starting at %p\n", (W_)size, result));
IF_DEBUG(linker, debugBelch("mmapForLinker: done\n")); IF_DEBUG(linker, debugBelch("mmapForLinker: done\n"));
return result; return result;
} }
...@@ -4937,7 +4937,7 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC, ...@@ -4937,7 +4937,7 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC,
default: default:
errorBelch("%s: unhandled ELF relocation(Rel) type %" FMT_SizeT "\n", errorBelch("%s: unhandled ELF relocation(Rel) type %" FMT_SizeT "\n",
oc->fileName, (lnat)ELF_R_TYPE(info)); oc->fileName, (W_)ELF_R_TYPE(info));
return 0; return 0;
} }
...@@ -5252,7 +5252,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC, ...@@ -5252,7 +5252,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
default: default:
errorBelch("%s: unhandled ELF relocation(RelA) type %" FMT_SizeT "\n", errorBelch("%s: unhandled ELF relocation(RelA) type %" FMT_SizeT "\n",
oc->fileName, (lnat)ELF_R_TYPE(info)); oc->fileName, (W_)ELF_R_TYPE(info));
return 0; return 0;
} }
......
...@@ -74,7 +74,7 @@ loop: ...@@ -74,7 +74,7 @@ loop:
{ {
StgTSO *tso = ((MessageWakeup *)m)->tso; StgTSO *tso = ((MessageWakeup *)m)->tso;
debugTraceCap(DEBUG_sched, cap, "message: try wakeup thread %ld", debugTraceCap(DEBUG_sched, cap, "message: try wakeup thread %ld",
(lnat)tso->id); (W_)tso->id);
tryWakeupThread(cap, tso); tryWakeupThread(cap, tso);
} }
else if (i == &stg_MSG_THROWTO_info) else if (i == &stg_MSG_THROWTO_info)
...@@ -90,7 +90,7 @@ loop: ...@@ -90,7 +90,7 @@ loop:
} }
debugTraceCap(DEBUG_sched, cap, "message: throwTo %ld -> %ld", debugTraceCap(DEBUG_sched, cap, "message: throwTo %ld -> %ld",
(lnat)t->source->id, (lnat)t->target->id); (W_)t->source->id, (W_)t->target->id);
ASSERT(t->source->why_blocked == BlockedOnMsgThrowTo); ASSERT(t->source->why_blocked == BlockedOnMsgThrowTo);
ASSERT(t->source->block_info.closure == (StgClosure *)m); ASSERT(t->source->block_info.closure == (StgClosure *)m);
...@@ -167,7 +167,7 @@ nat messageBlackHole(Capability *cap, MessageBlackHole *msg) ...@@ -167,7 +167,7 @@ nat messageBlackHole(Capability *cap, MessageBlackHole *msg)
StgTSO *owner; StgTSO *owner;
debugTraceCap(DEBUG_sched, cap, "message: thread %d blocking on blackhole %p", debugTraceCap(DEBUG_sched, cap, "message: thread %d blocking on blackhole %p",
(lnat)msg->tso->id, msg->bh); (W_)msg->tso->id, msg->bh);
info = bh->header.info; info = bh->header.info;
...@@ -256,7 +256,7 @@ loop: ...@@ -256,7 +256,7 @@ loop:
recordClosureMutated(cap,bh); // bh was mutated recordClosureMutated(cap,bh); // bh was mutated
debugTraceCap(DEBUG_sched, cap, "thread %d blocked on thread %d", debugTraceCap(DEBUG_sched, cap, "thread %d blocked on thread %d",
(lnat)msg->tso->id, (lnat)owner->id); (W_)msg->tso->id, (W_)owner->id);
return 1; // blocked return 1; // blocked
} }
...@@ -289,7 +289,7 @@ loop: ...@@ -289,7 +289,7 @@ loop:
} }
debugTraceCap(DEBUG_sched, cap, "thread %d blocked on thread %d", debugTraceCap(DEBUG_sched, cap, "thread %d blocked on thread %d",
(lnat)msg->tso->id, (lnat)owner->id); (W_)msg->tso->id, (W_)owner->id);
// See above, #3838 // See above, #3838
if (owner->why_blocked == NotBlocked && owner->id != msg->tso->id) { if (owner->why_blocked == NotBlocked && owner->id != msg->tso->id) {
......
...@@ -300,21 +300,21 @@ printClosure( StgClosure *obj ) ...@@ -300,21 +300,21 @@ printClosure( StgClosure *obj )
StgWord i; StgWord i;
debugBelch("ARR_WORDS(\""); debugBelch("ARR_WORDS(\"");
for (i=0; i<arr_words_words((StgArrWords *)obj); i++) for (i=0; i<arr_words_words((StgArrWords *)obj); i++)
debugBelch("%" FMT_SizeT, (lnat)((StgArrWords *)obj)->payload[i]); debugBelch("%" FMT_SizeT, (W_)((StgArrWords *)obj)->payload[i]);
debugBelch("\")\n"); debugBelch("\")\n");
break; break;
} }
case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_CLEAN:
debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_SizeT ")\n", (lnat)((StgMutArrPtrs *)obj)->ptrs); debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_SizeT ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs);
break; break;
case MUT_ARR_PTRS_DIRTY: case MUT_ARR_PTRS_DIRTY:
debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_SizeT ")\n", (lnat)((StgMutArrPtrs *)obj)->ptrs); debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_SizeT ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs);
break; break;
case MUT_ARR_PTRS_FROZEN: case MUT_ARR_PTRS_FROZEN:
debugBelch("MUT_ARR_PTRS_FROZEN(size=%" FMT_SizeT ")\n", (lnat)((StgMutArrPtrs *)obj)->ptrs); debugBelch("MUT_ARR_PTRS_FROZEN(size=%" FMT_SizeT ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs);
break; break;
case MVAR_CLEAN: case MVAR_CLEAN:
...@@ -431,7 +431,7 @@ printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, nat size ) ...@@ -431,7 +431,7 @@ printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, nat size )
printPtr((P_)payload[i]); printPtr((P_)payload[i]);
debugBelch("\n"); debugBelch("\n");
} else { } else {
debugBelch("Word# %" FMT_SizeT "\n", (lnat)payload[i]); debugBelch("Word# %" FMT_SizeT "\n", (W_)payload[i]);
} }
} }
} }
...@@ -447,12 +447,12 @@ printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, ...@@ -447,12 +447,12 @@ printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap,
StgWord bitmap = large_bitmap->bitmap[bmp]; StgWord bitmap = large_bitmap->bitmap[bmp];
j = 0; j = 0;
for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) {
debugBelch(" stk[%" FMT_SizeT "] (%p) = ", (lnat)(spBottom-(payload+i)), payload+i); debugBelch(" stk[%" FMT_SizeT "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i);
if ((bitmap & 1) == 0) { if ((bitmap & 1) == 0) {
printPtr((P_)payload[i]); printPtr((P_)payload[i]);
debugBelch("\n"); debugBelch("\n");
} else { } else {
debugBelch("Word# %" FMT_SizeT "\n", (lnat)payload[i]); debugBelch("Word# %" FMT_SizeT "\n", (W_)payload[i]);
} }
} }
} }
......
...@@ -821,7 +821,7 @@ dumpCensus( Census *census ) ...@@ -821,7 +821,7 @@ dumpCensus( Census *census )
} }
#endif #endif
fprintf(hp_file, "\t%" FMT_SizeT "\n", (lnat)count * sizeof(W_)); fprintf(hp_file, "\t%" FMT_SizeT "\n", (W_)count * sizeof(W_));
} }
printSample(rtsFalse, census->time); printSample(rtsFalse, census->time);
......
...@@ -42,7 +42,7 @@ unsigned int CCS_ID = 1; ...@@ -42,7 +42,7 @@ unsigned int CCS_ID = 1;
/* figures for the profiling report. /* figures for the profiling report.
*/ */
static StgWord64 total_alloc; static StgWord64 total_alloc;
static lnat total_prof_ticks; static W_ total_prof_ticks;
/* Globals for opening the profiling log file(s) /* Globals for opening the profiling log file(s)
*/ */
......
...@@ -271,11 +271,11 @@ isEmptyRetainerStack( void ) ...@@ -271,11 +271,11 @@ isEmptyRetainerStack( void )
* Returns size of stack * Returns size of stack
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#ifdef DEBUG #ifdef DEBUG
lnat W_
retainerStackBlocks( void ) retainerStackBlocks( void )
{ {
bdescr* bd; bdescr* bd;
lnat res = 0; W_ res = 0;
for (bd = firstStack; bd != NULL; bd = bd->link) for (bd = firstStack; bd != NULL; bd = bd->link)
res += bd->blocks; res += bd->blocks;
......
...@@ -43,7 +43,7 @@ retainerSetOf( StgClosure *c ) ...@@ -43,7 +43,7 @@ retainerSetOf( StgClosure *c )
// Used by Storage.c:memInventory() // Used by Storage.c:memInventory()
#ifdef DEBUG #ifdef DEBUG
extern lnat retainerStackBlocks ( void ); extern W_ retainerStackBlocks ( void );
#endif #endif
#include "EndPrivate.h" #include "EndPrivate.h"
......
...@@ -1542,7 +1542,7 @@ decodeSize(const char *flag, nat offset, StgWord64 min, StgWord64 max) ...@@ -1542,7 +1542,7 @@ decodeSize(const char *flag, nat offset, StgWord64 min, StgWord64 max)
if (m < 0 || val < min || val > max) { if (m < 0 || val < min || val > max) {
// printf doesn't like 64-bit format specs on Windows // printf doesn't like 64-bit format specs on Windows
// apparently, so fall back to unsigned long. // apparently, so fall back to unsigned long.
errorBelch("error in RTS option %s: size outside allowed range (%" FMT_SizeT " - %" FMT_SizeT ")", flag, (lnat)min, (lnat)max); errorBelch("error in RTS option %s: size outside allowed range (%" FMT_SizeT " - %" FMT_SizeT ")", flag, (W_)min, (W_)max);
stg_exit(EXIT_FAILURE); stg_exit(EXIT_FAILURE);
} }
......
...@@ -130,7 +130,7 @@ heapOverflow(void) ...@@ -130,7 +130,7 @@ heapOverflow(void)
{ {
/* don't fflush(stdout); WORKAROUND bug in Linux glibc */ /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
OutOfHeapHook(0/*unknown request size*/, OutOfHeapHook(0/*unknown request size*/,
(lnat)RtsFlags.GcFlags.maxHeapSize * BLOCK_SIZE); (W_)RtsFlags.GcFlags.maxHeapSize * BLOCK_SIZE);
heap_overflow = rtsTrue; heap_overflow = rtsTrue;
} }
......
...@@ -1107,9 +1107,9 @@ scheduleHandleHeapOverflow( Capability *cap, StgTSO *t ) ...@@ -1107,9 +1107,9 @@ scheduleHandleHeapOverflow( Capability *cap, StgTSO *t )
if (cap->r.rHpAlloc > BLOCK_SIZE) { if (cap->r.rHpAlloc > BLOCK_SIZE) {
// if so, get one and push it on the front of the nursery. // if so, get one and push it on the front of the nursery.
bdescr *bd; bdescr *bd;
lnat blocks; W_ blocks;
blocks = (lnat)BLOCK_ROUND_UP(cap->r.rHpAlloc) / BLOCK_SIZE; blocks = (W_)BLOCK_ROUND_UP(cap->r.rHpAlloc) / BLOCK_SIZE;
if (blocks > BLOCKS_PER_MBLOCK) { if (blocks > BLOCKS_PER_MBLOCK) {
barf("allocation of %ld bytes too large (GHC should have complained at compile-time)", (long)cap->r.rHpAlloc); barf("allocation of %ld bytes too large (GHC should have complained at compile-time)", (long)cap->r.rHpAlloc);
......
...@@ -57,14 +57,14 @@ static Time HCe_start_time, HCe_tot_time = 0; // heap census prof elap time ...@@ -57,14 +57,14 @@ static Time HCe_start_time, HCe_tot_time = 0; // heap census prof elap time
#endif #endif
// current = current as of last GC // current = current as of last GC
static lnat current_residency = 0; // in words; for stats only static W_ current_residency = 0; // in words; for stats only
static lnat max_residency = 0; static W_ max_residency = 0;
static lnat cumulative_residency = 0; static W_ cumulative_residency = 0;
static lnat residency_samples = 0; // for stats only static W_ residency_samples = 0; // for stats only
static lnat current_slop = 0; static W_ current_slop = 0;
static lnat max_slop = 0; static W_ max_slop = 0;
static lnat GC_end_faults = 0; static W_ GC_end_faults = 0;
static Time *GC_coll_cpu = NULL; static Time *GC_coll_cpu = NULL;
static Time *GC_coll_elapsed = NULL; static Time *GC_coll_elapsed = NULL;
...@@ -340,8 +340,8 @@ stat_gcWorkerThreadDone (gc_thread *gct STG_UNUSED) ...@@ -340,8 +340,8 @@ stat_gcWorkerThreadDone (gc_thread *gct STG_UNUSED)
void void
stat_endGC (Capability *cap, gc_thread *gct, stat_endGC (Capability *cap, gc_thread *gct,
lnat alloc, lnat live, lnat copied, lnat slop, nat gen, W_ alloc, W_ live, W_ copied, W_ slop, nat gen,
nat par_n_threads, lnat par_max_copied, lnat par_tot_copied) nat par_n_threads, W_ par_max_copied, W_ par_tot_copied)
{ {
if (RtsFlags.GcFlags.giveStats != NO_GC_STATS || if (RtsFlags.GcFlags.giveStats != NO_GC_STATS ||
RtsFlags.ProfFlags.doHeapProfile) RtsFlags.ProfFlags.doHeapProfile)
...@@ -419,8 +419,8 @@ stat_endGC (Capability *cap, gc_thread *gct, ...@@ -419,8 +419,8 @@ stat_endGC (Capability *cap, gc_thread *gct,
* to calculate the total * to calculate the total
*/ */
{ {
lnat tot_alloc = 0; W_ tot_alloc = 0;
lnat n; W_ n;
for (n = 0; n < n_capabilities; n++) { for (n = 0; n < n_capabilities; n++) {
tot_alloc += capabilities[n].total_allocated; tot_alloc += capabilities[n].total_allocated;
traceEventHeapAllocated(&capabilities[n], traceEventHeapAllocated(&capabilities[n],
...@@ -627,7 +627,7 @@ stat_exit(int alloc) ...@@ -627,7 +627,7 @@ stat_exit(int alloc)
if (tot_elapsed == 0.0) tot_elapsed = 1; if (tot_elapsed == 0.0) tot_elapsed = 1;
if (RtsFlags.GcFlags.giveStats >= VERBOSE_GC_STATS) { if (RtsFlags.GcFlags.giveStats >= VERBOSE_GC_STATS) {
statsPrintf("%9" FMT_SizeT " %9.9s %9.9s", (lnat)alloc*sizeof(W_), "", ""); statsPrintf("%9" FMT_SizeT " %9.9s %9.9s", (W_)alloc*sizeof(W_), "", "");
statsPrintf(" %5.2f %5.2f\n\n", 0.0, 0.0); statsPrintf(" %5.2f %5.2f\n\n", 0.0, 0.0);
} }
...@@ -675,7 +675,7 @@ stat_exit(int alloc) ...@@ -675,7 +675,7 @@ stat_exit(int alloc)
statsPrintf("%16" FMT_SizeT " MB total memory in use (%" FMT_SizeT " MB lost due to fragmentation)\n\n", statsPrintf("%16" FMT_SizeT " MB total memory in use (%" FMT_SizeT " MB lost due to fragmentation)\n\n",
peak_mblocks_allocated * MBLOCK_SIZE_W / (1024 * 1024 / sizeof(W_)), peak_mblocks_allocated * MBLOCK_SIZE_W / (1024 * 1024 / sizeof(W_)),
(lnat)(peak_mblocks_allocated * BLOCKS_PER_MBLOCK * BLOCK_SIZE_W - hw_alloc_blocks * BLOCK_SIZE_W) / (1024 * 1024 / sizeof(W_))); (W_)(peak_mblocks_allocated * BLOCKS_PER_MBLOCK * BLOCK_SIZE_W - hw_alloc_blocks * BLOCK_SIZE_W) / (1024 * 1024 / sizeof(W_)));
/* Print garbage collections in each gen */ /* Print garbage collections in each gen */
statsPrintf(" Tot time (elapsed) Avg pause Max pause\n"); statsPrintf(" Tot time (elapsed) Avg pause Max pause\n");
...@@ -856,9 +856,9 @@ void ...@@ -856,9 +856,9 @@ void
statDescribeGens(void) statDescribeGens(void)
{ {
nat g, mut, lge, i; nat g, mut, lge, i;
lnat gen_slop; W_ gen_slop;
lnat tot_live, tot_slop; W_ tot_live, tot_slop;
lnat gen_live, gen_blocks; W_ gen_live, gen_blocks;
bdescr *bd; bdescr *bd;
generation *gen; generation *gen;
...@@ -896,7 +896,7 @@ statDescribeGens(void) ...@@ -896,7 +896,7 @@ statDescribeGens(void)
gen_blocks += gcThreadLiveBlocks(i,g); gen_blocks += gcThreadLiveBlocks(i,g);
} }
debugBelch("%5d %7" FMT_SizeT " %9d", g, (lnat)gen->max_blocks, mut); debugBelch("%5d %7" FMT_SizeT " %9d", g, (W_)gen->max_blocks, mut);
gen_slop = gen_blocks * BLOCK_SIZE_W - gen_live; gen_slop = gen_blocks * BLOCK_SIZE_W - gen_live;
......
...@@ -29,8 +29,8 @@ void stat_endInit(void); ...@@ -29,8 +29,8 @@ void stat_endInit(void);
void stat_startGC(Capability *cap, struct gc_thread_ *gct); void stat_startGC(Capability *cap, struct gc_thread_ *gct);
void stat_endGC (Capability *cap, struct gc_thread_ *gct, void stat_endGC (Capability *cap, struct gc_thread_ *gct,
lnat alloc, lnat live, lnat copied, lnat slop, nat gen, W_ alloc, W_ live, W_ copied, W_ slop, nat gen,
nat n_gc_threads, lnat par_max_copied, lnat par_tot_copied); nat n_gc_threads, W_ par_max_copied, W_ par_tot_copied);
void stat_gcWorkerThreadStart (struct gc_thread_ *gct); void stat_gcWorkerThreadStart (struct gc_thread_ *gct);
void stat_gcWorkerThreadDone (struct gc_thread_ *gct); void stat_gcWorkerThreadDone (struct gc_thread_ *gct);
......
...@@ -247,7 +247,7 @@ tryWakeupThread (Capability *cap, StgTSO *tso) ...@@ -247,7 +247,7 @@ tryWakeupThread (Capability *cap, StgTSO *tso)
msg->tso = tso; msg->tso = tso;
sendMessage(cap, tso->cap, (Message*)msg); sendMessage(cap, tso->cap, (Message*)msg);
debugTraceCap(DEBUG_sched, cap, "message: try wakeup thread %ld on cap %d", debugTraceCap(DEBUG_sched, cap, "message: try wakeup thread %ld on cap %d",
(lnat)tso->id, tso->cap->no); (W_)tso->id, tso->cap->no);
return; return;
} }
#endif #endif
...@@ -272,7 +272,7 @@ tryWakeupThread (Capability *cap, StgTSO *tso) ...@@ -272,7 +272,7 @@ tryWakeupThread (Capability *cap, StgTSO *tso)
unlockClosure(tso->block_info.closure, i); unlockClosure(tso->block_info.closure, i);
if (i != &stg_MSG_NULL_info) { if (i != &stg_MSG_NULL_info) {
debugTraceCap(DEBUG_sched, cap, "thread %ld still blocked on throwto (%p)", debugTraceCap(DEBUG_sched, cap, "thread %ld still blocked on throwto (%p)",
(lnat)tso->id, tso->block_info.throwto->header.info); (W_)tso->id, tso->block_info.throwto->header.info);
return; return;
} }
...@@ -375,7 +375,7 @@ checkBlockingQueues (Capability *cap, StgTSO *tso) ...@@ -375,7 +375,7 @@ checkBlockingQueues (Capability *cap, StgTSO *tso)