diff options
87 files changed, 613 insertions, 603 deletions
diff --git a/includes/rts/Flags.h b/includes/rts/Flags.h index d3bc001ca1..8020a177b0 100644 --- a/includes/rts/Flags.h +++ b/includes/rts/Flags.h @@ -27,30 +27,30 @@ /* See Note [Synchronization of flags and base APIs] */ typedef struct _GC_FLAGS { FILE *statsFile; - nat giveStats; + uint32_t giveStats; #define NO_GC_STATS 0 #define COLLECT_GC_STATS 1 #define ONELINE_GC_STATS 2 #define SUMMARY_GC_STATS 3 #define VERBOSE_GC_STATS 4 - nat maxStkSize; /* in *words* */ - nat initialStkSize; /* in *words* */ - nat stkChunkSize; /* in *words* */ - nat stkChunkBufferSize; /* in *words* */ - - nat maxHeapSize; /* in *blocks* */ - nat minAllocAreaSize; /* in *blocks* */ - nat largeAllocLim; /* in *blocks* */ - nat nurseryChunkSize; /* in *blocks* */ - nat minOldGenSize; /* in *blocks* */ - nat heapSizeSuggestion; /* in *blocks* */ + uint32_t maxStkSize; /* in *words* */ + uint32_t initialStkSize; /* in *words* */ + uint32_t stkChunkSize; /* in *words* */ + uint32_t stkChunkBufferSize; /* in *words* */ + + uint32_t maxHeapSize; /* in *blocks* */ + uint32_t minAllocAreaSize; /* in *blocks* */ + uint32_t largeAllocLim; /* in *blocks* */ + uint32_t nurseryChunkSize; /* in *blocks* */ + uint32_t minOldGenSize; /* in *blocks* */ + uint32_t heapSizeSuggestion; /* in *blocks* */ rtsBool heapSizeSuggestionAuto; double oldGenFactor; double pcFreeHeap; - nat generations; - nat steps; + uint32_t generations; + uint32_t steps; rtsBool squeezeUpdFrames; rtsBool compact; /* True <=> "compact all the time" */ @@ -97,7 +97,7 @@ typedef struct _DEBUG_FLAGS { /* See Note [Synchronization of flags and base APIs] */ typedef struct _COST_CENTRE_FLAGS { - nat doCostCentres; + uint32_t doCostCentres; # define COST_CENTRES_NONE 0 # define COST_CENTRES_SUMMARY 1 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */ @@ -110,7 +110,7 @@ typedef struct _COST_CENTRE_FLAGS { /* See Note [Synchronization of flags and base APIs] */ typedef struct _PROFILING_FLAGS { - nat doHeapProfile; + uint32_t doHeapProfile; # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */ # define HEAP_BY_CCS 1 # define HEAP_BY_MOD 2 @@ -121,16 +121,16 @@ typedef struct _PROFILING_FLAGS { # define HEAP_BY_CLOSURE_TYPE 8 - Time heapProfileInterval; /* time between samples */ - nat heapProfileIntervalTicks; /* ticks between samples (derived) */ - rtsBool includeTSOs; + Time heapProfileInterval; /* time between samples */ + uint32_t heapProfileIntervalTicks; /* ticks between samples (derived) */ + rtsBool includeTSOs; rtsBool showCCSOnException; - nat maxRetainerSetSize; + uint32_t maxRetainerSetSize; - nat ccsLength; + uint32_t ccsLength; const char* modSelector; const char* descrSelector; @@ -184,27 +184,27 @@ typedef struct _MISC_FLAGS { #ifdef THREADED_RTS /* See Note [Synchronization of flags and base APIs] */ typedef struct _PAR_FLAGS { - nat nNodes; /* number of threads to run simultaneously */ + uint32_t nNodes; /* number of threads to run simultaneously */ rtsBool migrate; /* migrate threads between capabilities */ - nat maxLocalSparks; + uint32_t maxLocalSparks; rtsBool parGcEnabled; /* enable parallel GC */ - nat parGcGen; /* do parallel GC in this generation + uint32_t parGcGen; /* do parallel GC in this generation * and higher only */ - rtsBool parGcLoadBalancingEnabled; + rtsBool parGcLoadBalancingEnabled; /* enable load-balancing in the * parallel GC */ - nat parGcLoadBalancingGen; + uint32_t parGcLoadBalancingGen; /* do load-balancing in this * generation and higher only */ - nat parGcNoSyncWithIdle; + uint32_t parGcNoSyncWithIdle; /* if a Capability has been idle for * this many GCs, do not try to wake * it up when doing a * non-load-balancing parallel GC. * (zero disables) */ - nat parGcThreads; + uint32_t parGcThreads; /* Use this many threads for parallel * GC (default: use all nNodes). */ @@ -249,7 +249,7 @@ extern RTS_FLAGS RtsFlags; /* * The printf formats are here, so we are less likely to make * overly-long filenames (with disastrous results). No more than 128 - * chars, please! + * chars, please! */ #define STATS_FILENAME_MAXLEN 128 diff --git a/includes/rts/IOManager.h b/includes/rts/IOManager.h index 7bf2cdf43c..f9e2cd7958 100644 --- a/includes/rts/IOManager.h +++ b/includes/rts/IOManager.h @@ -26,7 +26,7 @@ void sendIOManagerEvent (HsWord32 event); #else -void setIOManagerControlFd (nat cap_no, int fd); +void setIOManagerControlFd (uint32_t cap_no, int fd); void setTimerManagerControlFd(int fd); void setIOManagerWakeupFd (int fd); diff --git a/includes/rts/OSThreads.h b/includes/rts/OSThreads.h index a3ed47c19b..ee1855b4da 100644 --- a/includes/rts/OSThreads.h +++ b/includes/rts/OSThreads.h @@ -200,7 +200,7 @@ void setThreadLocalVar (ThreadLocalKey *key, void *value); void freeThreadLocalKey (ThreadLocalKey *key); // Processors and affinity -void setThreadAffinity (nat n, nat m); +void setThreadAffinity (uint32_t n, uint32_t m); #endif // !CMINUSMINUS #else @@ -221,7 +221,7 @@ int forkOS_createThread ( HsStablePtr entry ); // // Returns the number of processor cores in the machine // -nat getNumberOfProcessors (void); +uint32_t getNumberOfProcessors (void); // // Support for getting at the kernel thread Id for tracing/profiling. diff --git a/includes/rts/SpinLock.h b/includes/rts/SpinLock.h index b54d678fa5..dccd86705c 100644 --- a/includes/rts/SpinLock.h +++ b/includes/rts/SpinLock.h @@ -42,7 +42,7 @@ typedef StgWord SpinLock; INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p) { StgWord32 r = 0; - nat i; + uint32_t i; do { for (i = 0; i < SPIN_COUNT; i++) { r = cas((StgVolatilePtr)&(p->lock), 1, 0); @@ -75,7 +75,7 @@ INLINE_HEADER void initSpinLock(SpinLock * p) INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p) { StgWord32 r = 0; - nat i; + uint32_t i; do { for (i = 0; i < SPIN_COUNT; i++) { r = cas((StgVolatilePtr)p, 1, 0); diff --git a/includes/rts/Threads.h b/includes/rts/Threads.h index fc8ae6e089..67d01db7d4 100644 --- a/includes/rts/Threads.h +++ b/includes/rts/Threads.h @@ -62,7 +62,7 @@ HsBool rtsSupportsBoundThreads (void); extern unsigned int n_capabilities; // The number of Capabilities that are not disabled -extern nat enabled_capabilities; +extern uint32_t enabled_capabilities; #if !IN_STG_CODE extern Capability MainCapability; @@ -72,6 +72,6 @@ extern Capability MainCapability; // Change the number of capabilities (only supports increasing the // current value at the moment). // -extern void setNumCapabilities (nat new_); +extern void setNumCapabilities (uint32_t new_); #endif /* RTS_THREADS_H */ diff --git a/includes/rts/Types.h b/includes/rts/Types.h index 1791b88772..08baceb1cf 100644 --- a/includes/rts/Types.h +++ b/includes/rts/Types.h @@ -16,7 +16,8 @@ #include <stddef.h> -typedef unsigned int nat; /* at least 32 bits (like int) */ +// Deprecated, use uint32_t instead. +typedef unsigned int nat __attribute__((deprecated)); /* uint32_t */ /* ullong (64|128-bit) type: only include if needed (not ANSI) */ #if defined(__GNUC__) diff --git a/includes/rts/prof/CCS.h b/includes/rts/prof/CCS.h index f3c158d8e2..1ed53c1d7c 100644 --- a/includes/rts/prof/CCS.h +++ b/includes/rts/prof/CCS.h @@ -113,7 +113,7 @@ typedef struct IndexTable_ { CostCentre *cc; CostCentreStack *ccs; struct IndexTable_ *next; - nat back_edge; + uint32_t back_edge; } IndexTable; diff --git a/includes/rts/storage/Block.h b/includes/rts/storage/Block.h index 024f78c6e3..1a31de5512 100644 --- a/includes/rts/storage/Block.h +++ b/includes/rts/storage/Block.h @@ -57,7 +57,7 @@ * own and treat it as an immovable object during GC, expressed as a * fraction of BLOCK_SIZE. */ -#define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10)) +#define LARGE_OBJECT_THRESHOLD ((uint32_t)(BLOCK_SIZE * 8 / 10)) /* * Note [integer overflow] @@ -295,7 +295,7 @@ void freeChain(bdescr *p); void freeGroup_lock(bdescr *p); void freeChain_lock(bdescr *p); -bdescr * splitBlockGroup (bdescr *bd, nat blocks); +bdescr * splitBlockGroup (bdescr *bd, uint32_t blocks); /* Round a value to megablocks --------------------------------------------- */ diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h index 03589f2f16..d7ae5ea122 100644 --- a/includes/rts/storage/ClosureMacros.h +++ b/includes/rts/storage/ClosureMacros.h @@ -256,20 +256,20 @@ INLINE_HEADER rtsBool LOOKS_LIKE_CLOSURE_PTR (void *p) Macros for calculating the size of a closure -------------------------------------------------------------------------- */ -EXTERN_INLINE StgOffset PAP_sizeW ( nat n_args ); -EXTERN_INLINE StgOffset PAP_sizeW ( nat n_args ) +EXTERN_INLINE StgOffset PAP_sizeW ( uint32_t n_args ); +EXTERN_INLINE StgOffset PAP_sizeW ( uint32_t n_args ) { return sizeofW(StgPAP) + n_args; } -EXTERN_INLINE StgOffset AP_sizeW ( nat n_args ); -EXTERN_INLINE StgOffset AP_sizeW ( nat n_args ) +EXTERN_INLINE StgOffset AP_sizeW ( uint32_t n_args ); +EXTERN_INLINE StgOffset AP_sizeW ( uint32_t n_args ) { return sizeofW(StgAP) + n_args; } -EXTERN_INLINE StgOffset AP_STACK_sizeW ( nat size ); -EXTERN_INLINE StgOffset AP_STACK_sizeW ( nat size ) +EXTERN_INLINE StgOffset AP_STACK_sizeW ( uint32_t size ); +EXTERN_INLINE StgOffset AP_STACK_sizeW ( uint32_t size ) { return sizeofW(StgAP_STACK) + size; } -EXTERN_INLINE StgOffset CONSTR_sizeW( nat p, nat np ); -EXTERN_INLINE StgOffset CONSTR_sizeW( nat p, nat np ) +EXTERN_INLINE StgOffset CONSTR_sizeW( uint32_t p, uint32_t np ); +EXTERN_INLINE StgOffset CONSTR_sizeW( uint32_t p, uint32_t np ) { return sizeofW(StgHeader) + p + np; } EXTERN_INLINE StgOffset THUNK_SELECTOR_sizeW ( void ); @@ -333,12 +333,12 @@ EXTERN_INLINE StgWord bco_sizeW ( StgBCO *bco ) { return bco->size; } /* - * TODO: Consider to switch return type from 'nat' to 'StgWord' #8742 + * TODO: Consider to switch return type from 'uint32_t' to 'StgWord' #8742 * * (Also for 'closure_sizeW' below) */ -EXTERN_INLINE nat closure_sizeW_ (StgClosure *p, StgInfoTable *info); -EXTERN_INLINE nat +EXTERN_INLINE uint32_t closure_sizeW_ (StgClosure *p, StgInfoTable *info); +EXTERN_INLINE uint32_t closure_sizeW_ (StgClosure *p, StgInfoTable *info) { switch (info->type) { @@ -399,8 +399,8 @@ closure_sizeW_ (StgClosure *p, StgInfoTable *info) } // The definitive way to find the size, in words, of a heap-allocated closure -EXTERN_INLINE nat closure_sizeW (StgClosure *p); -EXTERN_INLINE nat closure_sizeW (StgClosure *p) +EXTERN_INLINE uint32_t closure_sizeW (StgClosure *p); +EXTERN_INLINE uint32_t closure_sizeW (StgClosure *p) { return closure_sizeW_(p, get_itbl(p)); } @@ -505,13 +505,13 @@ INLINE_HEADER StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, W_ n) #endif #ifdef PROFILING -void LDV_recordDead (StgClosure *c, nat size); +void LDV_recordDead (StgClosure *c, uint32_t size); #endif EXTERN_INLINE void overwritingClosure (StgClosure *p); EXTERN_INLINE void overwritingClosure (StgClosure *p) { - nat size, i; + uint32_t size, i; #if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK // see Note [zeroing slop], also #8402 @@ -537,10 +537,10 @@ EXTERN_INLINE void overwritingClosure (StgClosure *p) // // Note: As this calls LDV_recordDead() you have to call LDV_RECORD() // on the final state of the closure at the call-site -EXTERN_INLINE void overwritingClosureOfs (StgClosure *p, nat offset); -EXTERN_INLINE void overwritingClosureOfs (StgClosure *p, nat offset) +EXTERN_INLINE void overwritingClosureOfs (StgClosure *p, uint32_t offset); +EXTERN_INLINE void overwritingClosureOfs (StgClosure *p, uint32_t offset) { - nat size, i; + uint32_t size, i; #if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK // see Note [zeroing slop], also #8402 diff --git a/includes/rts/storage/GC.h b/includes/rts/storage/GC.h index f7da838739..04548be379 100644 --- a/includes/rts/storage/GC.h +++ b/includes/rts/storage/GC.h @@ -88,7 +88,7 @@ typedef struct nursery_ { // memory allocation is tracked. typedef struct generation_ { - nat no; // generation number + uint32_t no; // generation number bdescr * blocks; // blocks in this gen memcount n_blocks; // number of blocks @@ -109,9 +109,9 @@ typedef struct generation_ { struct generation_ *to; // destination gen for live objects // stats information - nat collections; - nat par_collections; - nat failed_promotions; + uint32_t collections; + uint32_t par_collections; + uint32_t failed_promotions; // ------------------------------------ // Fields below are used during GC only diff --git a/includes/rts/storage/MBlock.h b/includes/rts/storage/MBlock.h index 046990eea9..419a96e225 100644 --- a/includes/rts/storage/MBlock.h +++ b/includes/rts/storage/MBlock.h @@ -17,8 +17,8 @@ extern W_ mblocks_allocated; extern void initMBlocks(void); extern void * getMBlock(void); -extern void * getMBlocks(nat n); -extern void freeMBlocks(void *addr, nat n); +extern void * getMBlocks(uint32_t n); +extern void freeMBlocks(void *addr, uint32_t n); extern void releaseFreeMemory(void); extern void freeAllMBlocks(void); diff --git a/includes/rts/storage/SMPClosureOps.h b/includes/rts/storage/SMPClosureOps.h index a8ebb5d0ed..ee92186f5f 100644 --- a/includes/rts/storage/SMPClosureOps.h +++ b/includes/rts/storage/SMPClosureOps.h @@ -51,7 +51,7 @@ EXTERN_INLINE StgInfoTable *reallyLockClosure(StgClosure *p) { StgWord info; do { - nat i = 0; + uint32_t i = 0; do { info = xchg((P_)(void *)&p->header.info, (W_)&stg_WHITEHOLE_info); if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info; diff --git a/rts/Adjustor.c b/rts/Adjustor.c index ca157661e8..5f047b3db1 100644 --- a/rts/Adjustor.c +++ b/rts/Adjustor.c @@ -137,7 +137,7 @@ createAdjustor (int cconv, { ffi_cif *cif; ffi_type **arg_types; - nat n_args, i; + uint32_t n_args, i; ffi_type *result_type; ffi_closure *cl; int r, abi; @@ -251,7 +251,7 @@ static void * stgAllocStable(size_t size_in_bytes, StgStablePtr *stable) { StgArrBytes* arr; - nat data_size_in_words, total_size_in_words; + uint32_t data_size_in_words, total_size_in_words; /* round up to a whole number of words */ data_size_in_words = ROUNDUP_BYTES_TO_WDS(size_in_bytes); diff --git a/rts/Arena.c b/rts/Arena.c index 813e60ebf6..cd547e5b33 100644 --- a/rts/Arena.c +++ b/rts/Arena.c @@ -63,8 +63,8 @@ void * arenaAlloc( Arena *arena, size_t size ) { void *p; - nat size_w; - nat req_blocks; + uint32_t size_w; + uint32_t req_blocks; bdescr *bd; // round up to nearest alignment chunk. diff --git a/rts/Capability.c b/rts/Capability.c index 2f8e152b5a..1b5f51a92b 100644 --- a/rts/Capability.c +++ b/rts/Capability.c @@ -37,8 +37,8 @@ // builds, and for +RTS -N1 Capability MainCapability; -nat n_capabilities = 0; -nat enabled_capabilities = 0; +uint32_t n_capabilities = 0; +uint32_t enabled_capabilities = 0; // The array of Capabilities. It's important that when we need // to allocate more Capabilities we don't have to move the existing @@ -90,7 +90,7 @@ findSpark (Capability *cap) Capability *robbed; StgClosurePtr spark; rtsBool retry; - nat i = 0; + uint32_t i = 0; if (!emptyRunQueue(cap) || cap->returning_tasks_hd != NULL) { // If there are other threads, don't try to run any new @@ -175,7 +175,7 @@ findSpark (Capability *cap) rtsBool anySparks (void) { - nat i; + uint32_t i; for (i=0; i < n_capabilities; i++) { if (!emptySparkPoolCap(capabilities[i])) { @@ -230,9 +230,9 @@ popReturningTask (Capability *cap) * ------------------------------------------------------------------------- */ static void -initCapability( Capability *cap, nat i ) +initCapability( Capability *cap, uint32_t i ) { - nat g; + uint32_t g; cap->no = i; cap->in_haskell = rtsFalse; @@ -356,10 +356,10 @@ initCapabilities( void ) } void -moreCapabilities (nat from USED_IF_THREADS, nat to USED_IF_THREADS) +moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) { #if defined(THREADED_RTS) - nat i; + uint32_t i; Capability **old_capabilities = capabilities; capabilities = stgMallocBytes(to * sizeof(Capability*), "moreCapabilities"); @@ -399,7 +399,7 @@ moreCapabilities (nat from USED_IF_THREADS, nat to USED_IF_THREADS) void contextSwitchAllCapabilities(void) { - nat i; + uint32_t i; for (i=0; i < n_capabilities; i++) { contextSwitchCapability(capabilities[i]); } @@ -407,7 +407,7 @@ void contextSwitchAllCapabilities(void) void interruptAllCapabilities(void) { - nat i; + uint32_t i; for (i=0; i < n_capabilities; i++) { interruptCapability(capabilities[i]); } @@ -721,7 +721,7 @@ void waitForCapability (Capability **pCap, Task *task) // Try last_free_capability first cap = last_free_capability; if (cap->running_task) { - nat i; + uint32_t i; // otherwise, search for a free capability cap = NULL; for (i = 0; i < n_capabilities; i++) { @@ -960,7 +960,7 @@ shutdownCapability (Capability *cap USED_IF_THREADS, rtsBool safe USED_IF_THREADS) { #if defined(THREADED_RTS) - nat i; + uint32_t i; task->cap = cap; @@ -1057,7 +1057,7 @@ shutdownCapability (Capability *cap USED_IF_THREADS, void shutdownCapabilities(Task *task, rtsBool safe) { - nat i; + uint32_t i; for (i=0; i < n_capabilities; i++) { ASSERT(task->incall->tso == NULL); shutdownCapability(capabilities[i], task, safe); @@ -1084,7 +1084,7 @@ void freeCapabilities (void) { #if defined(THREADED_RTS) - nat i; + uint32_t i; for (i=0; i < n_capabilities; i++) { freeCapability(capabilities[i]); if (capabilities[i] != &MainCapability) @@ -1138,7 +1138,7 @@ markCapability (evac_fn evac, void *user, Capability *cap, void markCapabilities (evac_fn evac, void *user) { - nat n; + uint32_t n; for (n = 0; n < n_capabilities; n++) { markCapability(evac, user, capabilities[n], rtsFalse); } @@ -1149,7 +1149,7 @@ rtsBool checkSparkCountInvariant (void) { SparkCounters sparks = { 0, 0, 0, 0, 0, 0 }; StgWord64 remaining = 0; - nat i; + uint32_t i; for (i = 0; i < n_capabilities; i++) { sparks.created += capabilities[i]->spark_stats.created; @@ -1176,7 +1176,8 @@ rtsBool checkSparkCountInvariant (void) #endif #if !defined(mingw32_HOST_OS) -void setIOManagerControlFd(nat cap_no USED_IF_THREADS, int fd USED_IF_THREADS) { +void +setIOManagerControlFd(uint32_t cap_no USED_IF_THREADS, int fd USED_IF_THREADS) { #if defined(THREADED_RTS) if (cap_no < n_capabilities) { capabilities[cap_no]->io_manager_control_wr_fd = fd; diff --git a/rts/Capability.h b/rts/Capability.h index 85fb53457d..46ae8b9ea3 100644 --- a/rts/Capability.h +++ b/rts/Capability.h @@ -34,7 +34,7 @@ struct Capability_ { StgFunTable f; StgRegTable r; - nat no; // capability number. + uint32_t no; // capability number. // The Task currently holding this Capability. This task has // exclusive access to the contents of this Capability (apart from @@ -47,7 +47,7 @@ struct Capability_ { rtsBool in_haskell; // Has there been any activity on this Capability since the last GC? - nat idle; + uint32_t idle; rtsBool disabled; @@ -105,7 +105,7 @@ struct Capability_ { #if defined(THREADED_RTS) // Worker Tasks waiting in the wings. Singly-linked. Task *spare_workers; - nat n_spare_workers; // count of above + uint32_t n_spare_workers; // count of above // This lock protects: // running_task @@ -141,7 +141,7 @@ struct Capability_ { StgInvariantCheckQueue *free_invariant_check_queues; StgTRecChunk *free_trec_chunks; StgTRecHeader *free_trec_headers; - nat transaction_tokens; + uint32_t transaction_tokens; } // typedef Capability is defined in RtsAPI.h // We never want a Capability to overlap a cache line with anything // else, so round it up to a cache line size: @@ -192,7 +192,7 @@ void initCapabilities (void); // Add and initialise more Capabilities // -void moreCapabilities (nat from, nat to); +void moreCapabilities (uint32_t from, uint32_t to); // Release a capability. This is called by a Task that is exiting // Haskell to make a foreign call, or in various other cases when we @@ -217,8 +217,8 @@ INLINE_HEADER void releaseCapability_ (Capability* cap STG_UNUSED, // extern Capability MainCapability; // declared in includes/rts/Threads.h: -// extern nat n_capabilities; -// extern nat enabled_capabilities; +// extern uint32_t n_capabilities; +// extern uint32_t enabled_capabilities; // Array of all the capabilities // @@ -260,7 +260,8 @@ extern PendingSync * volatile pending_sync; // void waitForCapability (Capability **cap/*in/out*/, Task *task); -EXTERN_INLINE void recordMutableCap (StgClosure *p, Capability *cap, nat gen); +EXTERN_INLINE void recordMutableCap (StgClosure *p, Capability *cap, + uint32_t gen); EXTERN_INLINE void recordClosureMutated (Capability *cap, StgClosure *p); @@ -302,7 +303,7 @@ StgClosure *findSpark (Capability *cap); rtsBool anySparks (void); INLINE_HEADER rtsBool emptySparkPoolCap (Capability *cap); -INLINE_HEADER nat sparkPoolSizeCap (Capability *cap); +INLINE_HEADER uint32_t sparkPoolSizeCap (Capability *cap); INLINE_HEADER void discardSparksCap (Capability *cap); #else // !THREADED_RTS @@ -353,7 +354,7 @@ INLINE_HEADER rtsBool emptyInbox(Capability *cap); * -------------------------------------------------------------------------- */ EXTERN_INLINE void -recordMutableCap (StgClosure *p, Capability *cap, nat gen) +recordMutableCap (StgClosure *p, Capability *cap, uint32_t gen) { bdescr *bd; @@ -385,7 +386,7 @@ INLINE_HEADER rtsBool emptySparkPoolCap (Capability *cap) { return looksEmpty(cap->sparks); } -INLINE_HEADER nat +INLINE_HEADER uint32_t sparkPoolSizeCap (Capability *cap) { return sparkPoolSize(cap->sparks); } diff --git a/rts/CheckUnload.c b/rts/CheckUnload.c index 7dc2c9cc30..bb51638455 100644 --- a/rts/CheckUnload.c +++ b/rts/CheckUnload.c @@ -89,7 +89,7 @@ static void searchHeapBlocks (HashTable *addrs, bdescr *bd) { StgPtr p; StgInfoTable *info; - nat size; + uint32_t size; rtsBool prim; for (; bd != NULL; bd = bd->link) { @@ -275,7 +275,7 @@ static void searchCostCentres (HashTable *addrs, CostCentreStack *ccs) // void checkUnload (StgClosure *static_objects) { - nat g, n; + uint32_t g, n; HashTable *addrs; StgClosure* p; const StgInfoTable *info; diff --git a/rts/Disassembler.c b/rts/Disassembler.c index 2e1790ef8d..f9e42b7767 100644 --- a/rts/Disassembler.c +++ b/rts/Disassembler.c @@ -281,11 +281,11 @@ disInstr ( StgBCO *bco, int pc ) */ void disassemble( StgBCO *bco ) { - nat i, j; - StgWord16* instrs = (StgWord16*)(bco->instrs->payload); - StgMutArrPtrs* ptrs = bco->ptrs; - nat nbcs = (int)(bco->instrs->bytes / sizeof(StgWord16)); - nat pc = 1; + uint32_t i, j; + StgWord16* instrs = (StgWord16*)(bco->instrs->payload); + StgMutArrPtrs* ptrs = bco->ptrs; + uint32_t nbcs = (uint32_t)(bco->instrs->bytes / sizeof(StgWord16)); + uint32_t pc = 1; debugBelch("BCO\n" ); pc = 0; diff --git a/rts/Globals.c b/rts/Globals.c index 2e4b99474f..4b899b15ba 100644 --- a/rts/Globals.c +++ b/rts/Globals.c @@ -45,7 +45,7 @@ static StgStablePtr store[MaxStoreKey]; void initGlobalStore(void) { - nat i; + uint32_t i; for (i=0; i < MaxStoreKey; i++) { store[i] = 0; } @@ -57,7 +57,7 @@ initGlobalStore(void) void exitGlobalStore(void) { - nat i; + uint32_t i; #ifdef THREADED_RTS closeMutex(&globalStoreLock); #endif @@ -257,7 +257,7 @@ hs_hpc_module(char *modName, StgWord64 *tixArr) { HpcModuleInfo *tmpModule; - nat i; + uint32_t i; if (moduleHash == NULL) { moduleHash = allocStrHashTable(); @@ -332,12 +332,12 @@ writeTix(FILE *f) { } fprintf(f," TixModule \"%s\" %u %u [", tmpModule->modName, - (nat)tmpModule->hashNo, - (nat)tmpModule->tickCount); + (uint32_t)tmpModule->hashNo, + (uint32_t)tmpModule->tickCount); debugTrace(DEBUG_hpc,"%s: %u (hash=%u)\n", tmpModule->modName, - (nat)tmpModule->tickCount, - (nat)tmpModule->hashNo); + (uint32_t)tmpModule->tickCount, + (uint32_t)tmpModule->hashNo); inner_comma = 0; for(i = 0;i < tmpModule->tickCount;i++) { diff --git a/rts/Interpreter.c b/rts/Interpreter.c index 7734aacd36..f88e47493c 100644 --- a/rts/Interpreter.c +++ b/rts/Interpreter.c @@ -234,7 +234,7 @@ interpretBCO (Capability* cap) register StgPtr Sp; // local state -- stack pointer register StgPtr SpLim; // local state -- stack lim pointer register StgClosure *tagged_obj = 0, *obj; - nat n, m; + uint32_t n, m; LOAD_THREAD_STATE(); @@ -363,7 +363,7 @@ eval_obj: case AP: /* Copied from stg_AP_entry. */ { - nat i, words; + uint32_t i, words; StgAP *ap; ap = (StgAP*)obj; @@ -643,7 +643,7 @@ do_apply: case PAP: { StgPAP *pap; - nat i, arity; + uint32_t i, arity; pap = (StgPAP *)obj; @@ -722,7 +722,7 @@ do_apply: } case BCO: { - nat arity, i; + uint32_t arity, i; Sp++; arity = ((StgBCO *)obj)->arity; @@ -748,7 +748,7 @@ do_apply: else /* arity > n */ { // build a PAP and return it. StgPAP *pap; - nat i; + uint32_t i; pap = (StgPAP *)allocate(cap, PAP_sizeW(m)); SET_HDR(pap, &stg_PAP_info,cap->r.rCCCS); pap->arity = arity - n; @@ -1558,9 +1558,9 @@ run_BCO: #define ROUND_UP_WDS(p) ((((StgWord)(p)) + sizeof(W_)-1)/sizeof(W_)) ffi_cif *cif = (ffi_cif *)marshall_fn; - nat nargs = cif->nargs; - nat ret_size; - nat i; + uint32_t nargs = cif->nargs; + uint32_t ret_size; + uint32_t i; int j; StgPtr p; W_ ret[2]; // max needed diff --git a/rts/LdvProfile.c b/rts/LdvProfile.c index 4a2ee42424..1dfdc56b34 100644 --- a/rts/LdvProfile.c +++ b/rts/LdvProfile.c @@ -27,10 +27,10 @@ * closure. Returns the size of the closure, including the profiling * header portion, so that the caller can find the next closure. * ----------------------------------------------------------------------- */ -STATIC_INLINE nat +STATIC_INLINE uint32_t processHeapClosureForDead( StgClosure *c ) { - nat size; + uint32_t size; const StgInfoTable *info; info = get_itbl(c); @@ -216,9 +216,9 @@ processChainForDead( bdescr *bd ) * have just been garbage collected. * ----------------------------------------------------------------------- */ void -LdvCensusForDead( nat N ) +LdvCensusForDead( uint32_t N ) { - nat g; + uint32_t g; // ldvTime == 0 means that LDV profiling is currently turned off. if (era == 0) diff --git a/rts/LdvProfile.h b/rts/LdvProfile.h index d58c5fbf57..e515715bc3 100644 --- a/rts/LdvProfile.h +++ b/rts/LdvProfile.h @@ -14,7 +14,7 @@ #include "ProfHeap.h" -RTS_PRIVATE void LdvCensusForDead ( nat ); +RTS_PRIVATE void LdvCensusForDead ( uint32_t ); RTS_PRIVATE void LdvCensusKillAll ( void ); // Creates a 0-filled slop of size 'howManyBackwards' backwards from the diff --git a/rts/LibdwPool.c b/rts/LibdwPool.c index b0de8ac7c3..2363212eaa 100644 --- a/rts/LibdwPool.c +++ b/rts/LibdwPool.c @@ -34,7 +34,7 @@ */ static Pool *pool = NULL; -static nat pool_size = 10; // TODO +static uint32_t pool_size = 10; // TODO void libdwPoolInit(void) { pool = poolInit(pool_size, pool_size, diff --git a/rts/Linker.c b/rts/Linker.c index 87ad9e3e81..981df2553f 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -1521,12 +1521,12 @@ static StgWord roundDownToPage (StgWord size) // // Returns NULL on failure. // -static void * mmapForLinker (size_t bytes, nat flags, int fd, int offset) +static void * mmapForLinker (size_t bytes, uint32_t flags, int fd, int offset) { void *map_addr = NULL; void *result; StgWord size; - static nat fixed = 0; + static uint32_t fixed = 0; IF_DEBUG(linker, debugBelch("mmapForLinker: start\n")); size = roundUpToPage(bytes); @@ -5335,12 +5335,12 @@ end: // TODO: These likely belong in a library somewhere // Signed extend a number to a 32-bit int. -static inline StgInt32 sign_extend32(nat bits, StgWord32 x) { +static inline StgInt32 sign_extend32(uint32_t bits, StgWord32 x) { return ((StgInt32) (x << (32 - bits))) >> (32 - bits); } // Does the given signed integer fit into the given bit width? -static inline StgBool is_int(nat bits, StgInt32 x) { +static inline StgBool is_int(uint32_t bits, StgInt32 x) { return bits > 32 || (-(1 << (bits-1)) <= x && x < (1 << (bits-1))); } @@ -7231,7 +7231,7 @@ static int ocRunInit_MachO ( ObjectCode *oc ) struct load_command *lc = (struct load_command*) (image + sizeof(struct mach_header)); struct segment_command *segLC = NULL; struct section *sections; - nat i; + uint32_t i; for (i = 0; i < header->ncmds; i++) { if (lc->cmd == LC_SEGMENT || lc->cmd == LC_SEGMENT_64) { diff --git a/rts/Messages.c b/rts/Messages.c index 5a67bf3e8c..2177dd11c3 100644 --- a/rts/Messages.c +++ b/rts/Messages.c @@ -80,7 +80,7 @@ loop: else if (i == &stg_MSG_THROWTO_info) { MessageThrowTo *t = (MessageThrowTo *)m; - nat r; + uint32_t r; const StgInfoTable *i; i = lockClosure((StgClosure*)m); @@ -113,7 +113,7 @@ loop: } else if (i == &stg_MSG_BLACKHOLE_info) { - nat r; + uint32_t r; MessageBlackHole *b = (MessageBlackHole*)m; r = messageBlackHole(cap, b); @@ -158,7 +158,7 @@ loop: ------------------------------------------------------------------------- */ -nat messageBlackHole(Capability *cap, MessageBlackHole *msg) +uint32_t messageBlackHole(Capability *cap, MessageBlackHole *msg) { const StgInfoTable *info; StgClosure *p; diff --git a/rts/Messages.h b/rts/Messages.h index 4121364b21..302cb946b3 100644 --- a/rts/Messages.h +++ b/rts/Messages.h @@ -8,7 +8,7 @@ #include "BeginPrivate.h" -nat messageBlackHole(Capability *cap, MessageBlackHole *msg); +uint32_t messageBlackHole(Capability *cap, MessageBlackHole *msg); StgTSO * blackHoleOwner (StgClosure *bh); #ifdef THREADED_RTS diff --git a/rts/Pool.c b/rts/Pool.c index b3e3446647..158391111b 100644 --- a/rts/Pool.c +++ b/rts/Pool.c @@ -22,12 +22,12 @@ typedef struct PoolEntry_ { struct Pool_ { /* the maximum number of allocated resources in the pool */ - nat max_size; + uint32_t max_size; /* the number of allocated resources to keep in the pool when idle */ - nat desired_size; + uint32_t desired_size; /* how many things are currently allocated? (sum of lengths of available and * taken lists) */ - nat current_size; + uint32_t current_size; #ifdef THREADED_RTS /* signaled when a thing is released */ Condition cond; @@ -43,10 +43,10 @@ struct Pool_ { #endif }; -Pool *poolInit(nat max_size, nat desired_size, +Pool *poolInit(uint32_t max_size, uint32_t desired_size, alloc_thing_fn alloc_fn, free_thing_fn free_fn) { Pool *pool = stgMallocBytes(sizeof(Pool), "pool_init"); - pool->max_size = max_size == 0 ? (nat) -1 : max_size; + pool->max_size = max_size == 0 ? (uint32_t) -1 : max_size; pool->desired_size = desired_size; pool->current_size = 0; pool->alloc_fn = alloc_fn; @@ -74,7 +74,7 @@ int poolFree(Pool *pool) { } /* free available entries such that current_size <= size */ -static void free_available(Pool *pool, nat size) { +static void free_available(Pool *pool, uint32_t size) { while (pool->current_size > size && pool->available != NULL) { PoolEntry *ent = pool->available; pool->free_fn(ent->thing); @@ -84,17 +84,17 @@ static void free_available(Pool *pool, nat size) { } } -void poolSetDesiredSize(Pool *pool, nat size) { +void poolSetDesiredSize(Pool *pool, uint32_t size) { ACQUIRE_LOCK(&pool->mutex); pool->desired_size = size; free_available(pool, size); RELEASE_LOCK(&pool->mutex); } -void poolSetMaxSize(Pool *pool, nat size) { +void poolSetMaxSize(Pool *pool, uint32_t size) { ACQUIRE_LOCK(&pool->mutex); if (size == 0) - size = (nat) -1; + size = (uint32_t) -1; pool->max_size = size; if (pool->desired_size > pool->max_size) { pool->desired_size = size; @@ -103,11 +103,11 @@ void poolSetMaxSize(Pool *pool, nat size) { RELEASE_LOCK(&pool->mutex); } -nat poolGetMaxSize(Pool *pool) { +uint32_t poolGetMaxSize(Pool *pool) { return pool->max_size; } -nat poolGetDesiredSize(Pool *pool) { +uint32_t poolGetDesiredSize(Pool *pool) { return pool->desired_size; } diff --git a/rts/Pool.h b/rts/Pool.h index dd00412d27..5190ce8bcc 100644 --- a/rts/Pool.h +++ b/rts/Pool.h @@ -23,7 +23,7 @@ typedef void (*free_thing_fn)(void *); typedef struct Pool_ Pool; /* Create a pool of things. */ -Pool *poolInit(nat max_size, nat desired_size, +Pool *poolInit(uint32_t max_size, uint32_t desired_size, alloc_thing_fn alloc_fn, free_thing_fn free_fn); /* Free a pool. Returns 0 on success or 1 on failure due to things @@ -32,16 +32,16 @@ int poolFree(Pool *pool); /* Set the maximum size of a pool (0 indicates unbounded). desired_size will be * lowered if necessary. */ -void poolSetMaxSize(Pool *pool, nat size); +void poolSetMaxSize(Pool *pool, uint32_t size); /* Get the maximum size of a pool */ -nat poolGetMaxSize(Pool *pool); +uint32_t poolGetMaxSize(Pool *pool); /* Set the desired size of a pool */ -void poolSetDesiredSize(Pool *pool, nat size); +void poolSetDesiredSize(Pool *pool, uint32_t size); /* Get the desired size of a pool */ -nat poolGetDesiredSize(Pool *pool); +uint32_t poolGetDesiredSize(Pool *pool); /* Try to grab an available thing from a pool, returning NULL if no things * are available. diff --git a/rts/Printer.c b/rts/Printer.c index 3b98ab4cd6..b4400da5b9 100644 --- a/rts/Printer.c +++ b/rts/Printer.c @@ -421,9 +421,10 @@ void printGraph( StgClosure *obj ) */ static void -printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, nat size ) +printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, + uint32_t size ) { - nat i; + uint32_t i; for(i = 0; i < size; i++, bitmap >>= 1 ) { debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); @@ -437,10 +438,11 @@ printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, nat size ) } static void -printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, nat size ) +printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, + uint32_t size ) { StgWord bmp; - nat i, j; + uint32_t i, j; i = 0; for (bmp=0; i < size; bmp++) { @@ -756,7 +758,7 @@ findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) void findPtr(P_ p, int follow) { - nat g, n; + uint32_t g, n; bdescr *bd; const int arr_size = 1024; StgPtr arr[arr_size]; @@ -830,7 +832,7 @@ void prettyPrintClosure_ (StgClosure *obj) case CONSTR_STATIC: case CONSTR_NOCAF_STATIC: { - nat i; + uint32_t i; char *descriptor; /* find the con_info for the constructor */ diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c index 819faeb9be..875cc7ed33 100644 --- a/rts/ProfHeap.c +++ b/rts/ProfHeap.c @@ -37,7 +37,7 @@ * store only up to (max_era - 1) as its creation or last use time. * -------------------------------------------------------------------------- */ unsigned int era; -static nat max_era; +static uint32_t max_era; /* ----------------------------------------------------------------------------- * Counters @@ -50,7 +50,7 @@ static nat max_era; typedef struct _counter { void *identity; union { - nat resid; + uint32_t resid; struct { long prim; // total size of 'inherently used' closures long not_used; // total size of 'never used' closures @@ -87,7 +87,7 @@ typedef struct { } Census; static Census *censuses = NULL; -static nat n_censuses = 0; +static uint32_t n_censuses = 0; #ifdef PROFILING static void aggregateCensusInfo( void ); @@ -180,10 +180,10 @@ doingRetainerProfiling( void ) #ifdef PROFILING void -LDV_recordDead( StgClosure *c, nat size ) +LDV_recordDead( StgClosure *c, uint32_t size ) { void *id; - nat t; + uint32_t t; counter *ctr; if (era > 0 && closureSatisfiesConstraints(c)) { @@ -372,7 +372,7 @@ printSample(rtsBool beginSample, StgDouble sampleValue) /* -------------------------------------------------------------------------- * Initialize the heap profilier * ----------------------------------------------------------------------- */ -nat +uint32_t initHeapProfiling(void) { if (! RtsFlags.ProfFlags.doHeapProfile) { @@ -455,7 +455,7 @@ endHeapProfiling(void) #ifdef PROFILING if (doingLDVProfiling()) { - nat t; + uint32_t t; LdvCensusKillAll(); aggregateCensusInfo(); for (t = 1; t < era; t++) { @@ -466,7 +466,7 @@ endHeapProfiling(void) #ifdef PROFILING if (doingLDVProfiling()) { - nat t; + uint32_t t; if (RtsFlags.ProfFlags.bioSelector != NULL) { for (t = 1; t <= era; t++) { freeEra( &censuses[t] ); @@ -505,7 +505,7 @@ buf_append(char *p, const char *q, char *end) } static void -fprint_ccs(FILE *fp, CostCentreStack *ccs, nat max_length) +fprint_ccs(FILE *fp, CostCentreStack *ccs, uint32_t max_length) { char buf[max_length+1], *p, *buf_end; @@ -602,7 +602,7 @@ closureSatisfiesConstraints( StgClosure* p ) } if (RtsFlags.ProfFlags.retainerSelector) { RetainerSet *rs; - nat i; + uint32_t i; // We must check that the retainer set is valid here. One // reason it might not be valid is if this closure is a // a newly deceased weak pointer (i.e. a DEAD_WEAK), since @@ -631,7 +631,7 @@ static void aggregateCensusInfo( void ) { HashTable *acc; - nat t; + uint32_t t; counter *c, *d, *ctrs; Arena *arena; @@ -835,7 +835,7 @@ dumpCensus( Census *census ) } -static void heapProfObject(Census *census, StgClosure *p, nat size, +static void heapProfObject(Census *census, StgClosure *p, uint32_t size, rtsBool prim #ifndef PROFILING STG_UNUSED @@ -843,7 +843,7 @@ static void heapProfObject(Census *census, StgClosure *p, nat size, ) { void *identity; - nat real_size; + uint32_t real_size; counter *ctr; identity = NULL; @@ -920,7 +920,7 @@ heapCensusChain( Census *census, bdescr *bd ) { StgPtr p; StgInfoTable *info; - nat size; + uint32_t size; rtsBool prim; for (; bd != NULL; bd = bd->link) { @@ -1101,7 +1101,7 @@ heapCensusChain( Census *census, bdescr *bd ) void heapCensus (Time t) { - nat g, n; + uint32_t g, n; Census *census; gen_workspace *ws; diff --git a/rts/ProfHeap.h b/rts/ProfHeap.h index 279eef2bf9..56b2529f1b 100644 --- a/rts/ProfHeap.h +++ b/rts/ProfHeap.h @@ -11,10 +11,10 @@ #include "BeginPrivate.h" -void heapCensus (Time t); -nat initHeapProfiling (void); -void endHeapProfiling (void); -rtsBool strMatchesSelector (const char* str, const char* sel); +void heapCensus (Time t); +uint32_t initHeapProfiling (void); +void endHeapProfiling (void); +rtsBool strMatchesSelector (const char* str, const char* sel); #ifdef PROFILING // doingRetainerProfiling: `-hr` or `-hr<cc> -h<x>` diff --git a/rts/Profiling.c b/rts/Profiling.c index 5dca8c0524..f6430ae41a 100644 --- a/rts/Profiling.c +++ b/rts/Profiling.c @@ -114,17 +114,17 @@ static CostCentreStack * actualPush_ ( CostCentreStack *ccs, CostCentre *cc static rtsBool ignoreCCS ( CostCentreStack *ccs ); static void countTickss ( CostCentreStack *ccs ); static void inheritCosts ( CostCentreStack *ccs ); -static nat numDigits ( StgInt i ); +static uint32_t numDigits ( StgInt i ); static void findCCSMaxLens ( CostCentreStack *ccs, - nat indent, - nat *max_label_len, - nat *max_module_len, - nat *max_id_len ); + uint32_t indent, + uint32_t *max_label_len, + uint32_t *max_module_len, + uint32_t *max_id_len ); static void logCCS ( CostCentreStack *ccs, - nat indent, - nat max_label_len, - nat max_module_len, - nat max_id_len ); + uint32_t indent, + uint32_t max_label_len, + uint32_t max_module_len, + uint32_t max_id_len ); static void reportCCS ( CostCentreStack *ccs ); static CostCentreStack * checkLoop ( CostCentreStack *ccs, CostCentre *cc ); @@ -149,7 +149,7 @@ void initProfiling (void) /* for the benefit of allocate()... */ { - nat n; + uint32_t n; for (n=0; n < n_capabilities; n++) { capabilities[n]->r.rCCCS = CCS_SYSTEM; } @@ -393,7 +393,7 @@ void enterFunCCS (StgRegTable *reg, CostCentreStack *ccsfn) // uncommon case 4: ccsapp is deeper than ccsfn if (ccsapp->depth > ccsfn->depth) { - nat i, n; + uint32_t i, n; CostCentreStack *tmp = ccsapp; n = ccsapp->depth - ccsfn->depth; for (i = 0; i < n; i++) { @@ -747,10 +747,10 @@ insertCCInSortedList( CostCentre *new_cc ) *prev = new_cc; } -static nat +static uint32_t strlen_utf8 (char *s) { - nat n = 0; + uint32_t n = 0; unsigned char c; for (; *s != '\0'; s++) { @@ -764,7 +764,7 @@ static void reportPerCCCosts( void ) { CostCentre *cc, *next; - nat max_label_len, max_module_len; + uint32_t max_label_len, max_module_len; aggregateCCCosts(CCS_MAIN); sorted_cc_list = NULL; @@ -822,7 +822,8 @@ reportPerCCCosts( void ) -------------------------------------------------------------------------- */ static void -fprintHeader( nat max_label_len, nat max_module_len, nat max_id_len ) +fprintHeader( uint32_t max_label_len, uint32_t max_module_len, + uint32_t max_id_len ) { fprintf(prof_file, "%-*s %-*s %-*s %11s %12s %12s\n", max_label_len, "", @@ -848,7 +849,7 @@ fprintHeader( nat max_label_len, nat max_module_len, nat max_id_len ) void reportCCSProfiling( void ) { - nat count; + uint32_t count; char temp[128]; /* sigh: magic constant */ stopProfTimer(); @@ -892,9 +893,9 @@ reportCCSProfiling( void ) reportCCS(pruneCCSTree(CCS_MAIN)); } -static nat +static uint32_t numDigits(StgInt i) { - nat result; + uint32_t result; result = 1; @@ -909,8 +910,8 @@ numDigits(StgInt i) { } static void -findCCSMaxLens(CostCentreStack *ccs, nat indent, - nat *max_label_len, nat *max_module_len, nat *max_id_len) { +findCCSMaxLens(CostCentreStack *ccs, uint32_t indent, uint32_t *max_label_len, + uint32_t *max_module_len, uint32_t *max_id_len) { CostCentre *cc; IndexTable *i; @@ -929,8 +930,8 @@ findCCSMaxLens(CostCentreStack *ccs, nat indent, } static void -logCCS(CostCentreStack *ccs, nat indent, - nat max_label_len, nat max_module_len, nat max_id_len) +logCCS(CostCentreStack *ccs, uint32_t indent, + uint32_t max_label_len, uint32_t max_module_len, uint32_t max_id_len) { CostCentre *cc; IndexTable *i; @@ -976,7 +977,7 @@ logCCS(CostCentreStack *ccs, nat indent, static void reportCCS(CostCentreStack *ccs) { - nat max_label_len, max_module_len, max_id_len; + uint32_t max_label_len, max_module_len, max_id_len; max_label_len = 11; // no shorter than "COST CENTRE" header max_module_len = 6; // no shorter than "MODULE" header @@ -1102,8 +1103,8 @@ fprintCCS_stderr (CostCentreStack *ccs, StgClosure *exception, StgTSO *tso) StgPtr frame; StgStack *stack; CostCentreStack *prev_ccs; - nat depth = 0; - const nat MAX_DEPTH = 10; // don't print gigantic chains of stacks + uint32_t depth = 0; + const uint32_t MAX_DEPTH = 10; // don't print gigantic chains of stacks { char *desc; diff --git a/rts/Proftimer.c b/rts/Proftimer.c index d1736f722b..4f4002a0e6 100644 --- a/rts/Proftimer.c +++ b/rts/Proftimer.c @@ -66,7 +66,7 @@ initProfTimer( void ) startHeapProfTimer(); } -nat total_ticks = 0; +uint32_t total_ticks = 0; void handleProfTick(void) @@ -74,7 +74,7 @@ handleProfTick(void) #ifdef PROFILING total_ticks++; if (do_prof_ticks) { - nat n; + uint32_t n; for (n=0; n < n_capabilities; n++) { capabilities[n]->r.rCCCS->time_ticks++; } diff --git a/rts/RaiseAsync.c b/rts/RaiseAsync.c index a0a81cf9ef..f55a4c23de 100644 --- a/rts/RaiseAsync.c +++ b/rts/RaiseAsync.c @@ -228,7 +228,7 @@ throwTo (Capability *cap, // the Capability we hold } -nat +uint32_t throwToMsg (Capability *cap, MessageThrowTo *msg) { StgWord status; @@ -781,7 +781,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception, StgRetInfoTable *info; StgPtr sp, frame; StgClosure *updatee; - nat i; + uint32_t i; StgStack *stack; debugTraceCap(DEBUG_sched, cap, @@ -861,7 +861,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception, case UPDATE_FRAME: { StgAP_STACK * ap; - nat words; + uint32_t words; // First build an AP_STACK consisting of the stack chunk above the // current update frame, with the top word on the stack as the @@ -873,7 +873,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception, ap->size = words; ap->fun = (StgClosure *)sp[0]; sp++; - for(i=0; i < (nat)words; ++i) { + for(i=0; i < words; ++i) { ap->payload[i] = (StgClosure *)*sp++; } @@ -912,7 +912,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception, case UNDERFLOW_FRAME: { StgAP_STACK * ap; - nat words; + uint32_t words; // First build an AP_STACK consisting of the stack chunk above the // current update frame, with the top word on the stack as the @@ -924,7 +924,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception, ap->size = words; ap->fun = (StgClosure *)sp[0]; sp++; - for(i=0; i < (nat)words; ++i) { + for(i=0; i < words; ++i) { ap->payload[i] = (StgClosure *)*sp++; } diff --git a/rts/RaiseAsync.h b/rts/RaiseAsync.h index b5dba46c22..243d3e0598 100644 --- a/rts/RaiseAsync.h +++ b/rts/RaiseAsync.h @@ -44,7 +44,7 @@ MessageThrowTo *throwTo (Capability *cap, // the Capability we hold StgTSO *target, StgClosure *exception); // the exception closure -nat throwToMsg (Capability *cap, +uint32_t throwToMsg (Capability *cap, MessageThrowTo *msg); int maybePerformBlockedException (Capability *cap, StgTSO *tso); diff --git a/rts/RetainerProfile.c b/rts/RetainerProfile.c index 42d5f2947b..04bbd82e04 100644 --- a/rts/RetainerProfile.c +++ b/rts/RetainerProfile.c @@ -46,10 +46,11 @@ * Declarations... * -------------------------------------------------------------------------- */ -static nat retainerGeneration; // generation +static uint32_t retainerGeneration; // generation -static nat numObjectVisited; // total number of objects visited -static nat timesAnyObjectVisited; // number of times any objects are visited +static uint32_t numObjectVisited; // total number of objects visited +static uint32_t timesAnyObjectVisited; // number of times any objects are + // visited /* The rs field in the profile header of any object points to its retainer @@ -79,18 +80,18 @@ static void belongToHeap(StgPtr p); Invariants: cStackSize <= maxCStackSize */ -static nat cStackSize, maxCStackSize; +static uint32_t cStackSize, maxCStackSize; -static nat sumOfNewCost; // sum of the cost of each object, computed +static uint32_t sumOfNewCost; // sum of the cost of each object, computed // when the object is first visited -static nat sumOfNewCostExtra; // for those objects not visited during +static uint32_t sumOfNewCostExtra; // for those objects not visited during // retainer profiling, e.g., MUT_VAR -static nat costArray[N_CLOSURE_TYPES]; +static uint32_t costArray[N_CLOSURE_TYPES]; -nat sumOfCostLinear; // sum of the costs of all object, computed +uint32_t sumOfCostLinear; // sum of the costs of all object, computed // when linearly traversing the heap after // retainer profiling -nat costArrayLinear[N_CLOSURE_TYPES]; +uint32_t costArrayLinear[N_CLOSURE_TYPES]; #endif /* ----------------------------------------------------------------------------- @@ -301,7 +302,7 @@ isOnBoundary( void ) * payload[] begins with ptrs pointers followed by non-pointers. * -------------------------------------------------------------------------- */ static INLINE void -init_ptrs( stackPos *info, nat ptrs, StgPtr payload ) +init_ptrs( stackPos *info, uint32_t ptrs, StgPtr payload ) { info->type = posTypePtrs; info->next.ptrs.pos = 0; @@ -388,7 +389,7 @@ find_srt( stackPos *info ) } else { // Large SRT bitmap - nat i = info->next.large_srt.offset; + uint32_t i = info->next.large_srt.offset; StgWord bitmap; // Follow the pattern from GC.c:scavenge_large_srt_bitmap(). @@ -836,8 +837,8 @@ pop( StgClosure **c, StgClosure **cp, retainer *r ) // which field, and the rest of the bits indicate the // entry number (starting from zero). TRecEntry *entry; - nat entry_no = se->info.next.step >> 2; - nat field_no = se->info.next.step & 3; + uint32_t entry_no = se->info.next.step >> 2; + uint32_t field_no = se->info.next.step & 3; if (entry_no == ((StgTRecChunk *)se->c)->next_entry_idx) { *c = NULL; popOff(); @@ -1162,10 +1163,10 @@ associate( StgClosure *c, RetainerSet *s ) -------------------------------------------------------------------------- */ static void -retain_large_bitmap (StgPtr p, StgLargeBitmap *large_bitmap, nat size, +retain_large_bitmap (StgPtr p, StgLargeBitmap *large_bitmap, uint32_t size, StgClosure *c, retainer c_child_r) { - nat i, b; + uint32_t i, b; StgWord bitmap; b = 0; @@ -1186,7 +1187,7 @@ retain_large_bitmap (StgPtr p, StgLargeBitmap *large_bitmap, nat size, } static INLINE StgPtr -retain_small_bitmap (StgPtr p, nat size, StgWord bitmap, +retain_small_bitmap (StgPtr p, uint32_t size, StgWord bitmap, StgClosure *c, retainer c_child_r) { while (size > 0) { @@ -1207,7 +1208,7 @@ retain_small_bitmap (StgPtr p, nat size, StgWord bitmap, static void retain_large_srt_bitmap (StgLargeSRT *srt, StgClosure *c, retainer c_child_r) { - nat i, b, size; + uint32_t i, b, size; StgWord bitmap; StgClosure **p; @@ -1231,9 +1232,10 @@ retain_large_srt_bitmap (StgLargeSRT *srt, StgClosure *c, retainer c_child_r) } static INLINE void -retainSRT (StgClosure **srt, nat srt_bitmap, StgClosure *c, retainer c_child_r) +retainSRT (StgClosure **srt, uint32_t srt_bitmap, StgClosure *c, + retainer c_child_r) { - nat bitmap; + uint32_t bitmap; StgClosure **p; bitmap = srt_bitmap; @@ -1288,7 +1290,7 @@ retainStack( StgClosure *c, retainer c_child_r, StgPtr p; StgRetInfoTable *info; StgWord bitmap; - nat size; + uint32_t size; #ifdef DEBUG_RETAINER cStackSize++; @@ -1764,7 +1766,7 @@ computeRetainerSet( void ) { StgWeak *weak; RetainerSet *rtl; - nat g, n; + uint32_t g, n; StgPtr ml; bdescr *bd; #ifdef DEBUG_RETAINER @@ -1870,7 +1872,7 @@ void resetStaticObjectForRetainerProfiling( StgClosure *static_objects ) { #ifdef DEBUG_RETAINER - nat count; + uint32_t count; #endif StgClosure *p; @@ -1926,8 +1928,8 @@ void retainerProfile(void) { #ifdef DEBUG_RETAINER - nat i; - nat totalHeapSize; // total raw heap size (computed by linear scanning) + uint32_t i; + uint32_t totalHeapSize; // total raw heap size (computed by linear scanning) #endif #ifdef DEBUG_RETAINER @@ -2065,7 +2067,7 @@ retainerProfile(void) ((HEAP_ALLOCED(r) && ((Bdescr((P_)r)->flags & BF_FREE) == 0)))) && \ ((StgWord)(*(StgPtr)r)!=(StgWord)0xaaaaaaaaaaaaaaaaULL)) -static nat +static uint32_t sanityCheckHeapClosure( StgClosure *c ) { ASSERT(LOOKS_LIKE_GHC_INFO(c->header.info)); @@ -2092,11 +2094,11 @@ sanityCheckHeapClosure( StgClosure *c ) return closure_sizeW(c); } -static nat +static uint32_t heapCheck( bdescr *bd ) { StgPtr p; - static nat costSum, size; + static uint32_t costSum, size; costSum = 0; while (bd != NULL) { @@ -2116,12 +2118,12 @@ heapCheck( bdescr *bd ) return costSum; } -static nat +static uint32_t smallObjectPoolCheck(void) { bdescr *bd; StgPtr p; - static nat costSum, size; + static uint32_t costSum, size; bd = g0s0->blocks; costSum = 0; @@ -2157,10 +2159,10 @@ smallObjectPoolCheck(void) return costSum; } -static nat +static uint32_t chainCheck(bdescr *bd) { - nat costSum, size; + uint32_t costSum, size; costSum = 0; while (bd != NULL) { @@ -2177,10 +2179,10 @@ chainCheck(bdescr *bd) return costSum; } -static nat +static uint32_t checkHeapSanityForRetainerProfiling( void ) { - nat costSum, g, s; + uint32_t costSum, g, s; costSum = 0; debugBelch("START: sumOfCostLinear = %d, costSum = %d\n", sumOfCostLinear, costSum); @@ -2221,7 +2223,7 @@ findPointer(StgPtr p) { StgPtr q, r, e; bdescr *bd; - nat g, s; + uint32_t g, s; for (g = 0; g < RtsFlags.GcFlags.generations; g++) { for (s = 0; s < generations[g].n_steps; s++) { @@ -2257,7 +2259,7 @@ static void belongToHeap(StgPtr p) { bdescr *bd; - nat g, s; + uint32_t g, s; for (g = 0; g < RtsFlags.GcFlags.generations; g++) { for (s = 0; s < generations[g].n_steps; s++) { diff --git a/rts/RetainerSet.c b/rts/RetainerSet.c index 4057e2e638..9c4cbb30f6 100644 --- a/rts/RetainerSet.c +++ b/rts/RetainerSet.c @@ -140,8 +140,8 @@ singleton(retainer r) RetainerSet * addElement(retainer r, RetainerSet *rs) { - nat i; - nat nl; // Number of retainers in *rs Less than r + uint32_t i; + uint32_t nl; // Number of retainers in *rs Less than r RetainerSet *nrs; // New Retainer Set StgWord hk; // Hash Key @@ -249,11 +249,11 @@ printRetainer(FILE *f, retainer cc) #if defined(RETAINER_SCHEME_INFO) // Retainer scheme 1: retainer = info table void -printRetainerSetShort(FILE *f, RetainerSet *rs, nat max_length) +printRetainerSetShort(FILE *f, RetainerSet *rs, uint32_t max_length) { char tmp[max_length + 1]; int size; - nat j; + uint32_t j; ASSERT(rs->id < 0); @@ -285,21 +285,21 @@ printRetainerSetShort(FILE *f, RetainerSet *rs, nat max_length) #elif defined(RETAINER_SCHEME_CC) // Retainer scheme 3: retainer = cost centre void -printRetainerSetShort(FILE *f, RetainerSet *rs, nat max_length) +printRetainerSetShort(FILE *f, RetainerSet *rs, uint32_t max_length) { char tmp[max_length + 1]; int size; - nat j; + uint32_t j; } #elif defined(RETAINER_SCHEME_CCS) // Retainer scheme 2: retainer = cost centre stack void -printRetainerSetShort(FILE *f, RetainerSet *rs, nat max_length) +printRetainerSetShort(FILE *f, RetainerSet *rs, uint32_t max_length) { char tmp[max_length + 1]; - nat size; - nat j; + uint32_t size; + uint32_t j; ASSERT(rs->id < 0); @@ -331,11 +331,11 @@ printRetainerSetShort(FILE *f, RetainerSet *rs, nat max_length) #elif defined(RETAINER_SCHEME_CC) // Retainer scheme 3: retainer = cost centre static void -printRetainerSetShort(FILE *f, retainerSet *rs, nat max_length) +printRetainerSetShort(FILE *f, retainerSet *rs, uint32_t max_length) { char tmp[max_length + 1]; int size; - nat j; + uint32_t j; ASSERT(rs->id < 0); @@ -372,7 +372,7 @@ printRetainerSetShort(FILE *f, retainerSet *rs, nat max_length) // printing one natural number (plus '(' and ')'). char tmp[32]; int size, ts; - nat j; + uint32_t j; ASSERT(rs->id < 0); @@ -415,8 +415,8 @@ printRetainerSetShort(FILE *f, retainerSet *rs, nat max_length) void outputAllRetainerSet(FILE *prof_file) { - nat i, j; - nat numSet; + uint32_t i, j; + uint32_t numSet; RetainerSet *rs, **rsArray, *tmp; // find out the number of retainer sets which have had a non-zero cost at diff --git a/rts/RetainerSet.h b/rts/RetainerSet.h index ea9fabb7d7..c581293e8b 100644 --- a/rts/RetainerSet.h +++ b/rts/RetainerSet.h @@ -63,7 +63,7 @@ typedef CostCentre *retainer; */ typedef struct _RetainerSet { - nat num; // number of elements + uint32_t num; // number of elements StgWord hashKey; // hash key for this retainer set struct _RetainerSet *link; // link to the next retainer set in the bucket int id; // unique id of this retainer set (used when printing) @@ -132,7 +132,7 @@ extern RetainerSet rs_MANY; INLINE_HEADER rtsBool isMember(retainer r, RetainerSet *rs) { - int i, left, right; // must be int, not nat (because -1 can appear) + int i, left, right; // must be int, not uint32_t (because -1 can appear) retainer ri; if (rs == &rs_MANY) { return rtsTrue; } @@ -162,12 +162,12 @@ RetainerSet *addElement(retainer, RetainerSet *); #ifdef SECOND_APPROACH // Prints a single retainer set. -void printRetainerSetShort(FILE *, RetainerSet *, nat); +void printRetainerSetShort(FILE *, RetainerSet *, uint32_t); #endif // Print the statistics on all the retainer sets. // store the sum of all costs and the number of all retainer sets. -void outputRetainerSet(FILE *, nat *, nat *); +void outputRetainerSet(FILE *, uint32_t *, uint32_t *); #ifdef SECOND_APPROACH // Print all retainer sets at the exit of the program. diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 084fc210be..b0ce8bee1b 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -91,7 +91,7 @@ static int openStatsFile ( char *filename, const char *FILENAME_FMT, FILE **file_ret); static StgWord64 decodeSize ( - const char *flag, nat offset, StgWord64 min, StgWord64 max); + const char *flag, uint32_t offset, StgWord64 min, StgWord64 max); static void bad_option (const char *s); @@ -491,9 +491,9 @@ static void errorRtsOptsDisabled(const char *s) void setupRtsFlags (int *argc, char *argv[], RtsConfig rts_config) { - nat mode; - nat total_arg; - nat arg, rts_argc0; + uint32_t mode; + uint32_t total_arg; + uint32_t arg, rts_argc0; rtsConfig = rts_config; @@ -869,7 +869,7 @@ error = rtsTrue; #if defined(PROFILING) RtsFlags.ParFlags.nNodes = 1; #else - RtsFlags.ParFlags.nNodes = (nat)nNodes; + RtsFlags.ParFlags.nNodes = (uint32_t)nNodes; #endif ) break; } else { @@ -900,15 +900,16 @@ error = rtsTrue; if (rts_argv[arg][2] == '\0') { RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsTrue; } else { - RtsFlags.GcFlags.heapSizeSuggestion = - (nat)(decodeSize(rts_argv[arg], 2, BLOCK_SIZE, HS_WORD_MAX) / BLOCK_SIZE); + RtsFlags.GcFlags.heapSizeSuggestion = (uint32_t) + (decodeSize(rts_argv[arg], 2, BLOCK_SIZE, HS_WORD_MAX) + / BLOCK_SIZE); } break; case 'O': OPTION_UNSAFE; RtsFlags.GcFlags.minOldGenSize = - (nat)(decodeSize(rts_argv[arg], 2, BLOCK_SIZE, + (uint32_t)(decodeSize(rts_argv[arg], 2, BLOCK_SIZE, HS_WORD_MAX) / BLOCK_SIZE); break; @@ -1089,7 +1090,7 @@ error = rtsTrue; errorRtsOptsDisabled("Using large values for -N is not allowed by default. %s"); stg_exit(EXIT_FAILURE); } - RtsFlags.ParFlags.nNodes = (nat)nNodes; + RtsFlags.ParFlags.nNodes = (uint32_t)nNodes; } ) break; @@ -1483,7 +1484,7 @@ static void initStatsFile (FILE *f) -------------------------------------------------------------------------- */ static StgWord64 -decodeSize(const char *flag, nat offset, StgWord64 min, StgWord64 max) +decodeSize(const char *flag, uint32_t offset, StgWord64 min, StgWord64 max) { char c; const char *s; diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index 6d774f4735..0aa3b28b2e 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -293,7 +293,7 @@ hs_add_root(void (*init_root)(void) STG_UNUSED) static void hs_exit_(rtsBool wait_foreign) { - nat g, i; + uint32_t g, i; if (hs_init_count <= 0) { errorBelch("warning: too many hs_exit()s"); diff --git a/rts/Schedule.c b/rts/Schedule.c index 3eb9624231..8bbc9cf3e2 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -123,9 +123,9 @@ static void scheduleYield (Capability **pcap, Task *task); static rtsBool requestSync (Capability **pcap, Task *task, PendingSync *sync_type, SyncType *prev_sync_type); static void acquireAllCapabilities(Capability *cap, Task *task); -static void releaseAllCapabilities(nat n, Capability *cap, Task *task); -static void stopAllCapabilities(Capability **pCap, Task *task); -static void startWorkerTasks (nat from USED_IF_THREADS, nat to USED_IF_THREADS); +static void releaseAllCapabilities(uint32_t n, Capability *cap, Task *task); +static void startWorkerTasks (uint32_t from USED_IF_THREADS, + uint32_t to USED_IF_THREADS); #endif static void scheduleStartSignalHandlers (Capability *cap); static void scheduleCheckBlockedThreads (Capability *cap); @@ -138,7 +138,7 @@ static void scheduleActivateSpark(Capability *cap); static void schedulePostRunThread(Capability *cap, StgTSO *t); static rtsBool scheduleHandleHeapOverflow( Capability *cap, StgTSO *t ); static rtsBool scheduleHandleYield( Capability *cap, StgTSO *t, - nat prev_what_next ); + uint32_t prev_what_next ); static void scheduleHandleThreadBlocked( StgTSO *t ); static rtsBool scheduleHandleThreadFinished( Capability *cap, Task *task, StgTSO *t ); @@ -172,7 +172,7 @@ schedule (Capability *initialCapability, Task *task) StgTSO *t; Capability *cap; StgThreadReturnCode ret; - nat prev_what_next; + uint32_t prev_what_next; rtsBool ready_to_gc; #if defined(THREADED_RTS) rtsBool first = rtsTrue; @@ -423,7 +423,7 @@ run_thread: case ACTIVITY_DONE_GC: { // ACTIVITY_DONE_GC means we turned off the timer signal to // conserve power (see #1623). Re-enable it here. - nat prev; + uint32_t prev; prev = xchg((P_)&recent_activity, ACTIVITY_YES); if (prev == ACTIVITY_DONE_GC) { #ifndef PROFILING @@ -699,7 +699,7 @@ schedulePushWork(Capability *cap USED_IF_THREADS, #if defined(THREADED_RTS) Capability *free_caps[n_capabilities], *cap0; - nat i, n_wanted_caps, n_free_caps; + uint32_t i, n_wanted_caps, n_free_caps; StgTSO *t; // migration can be turned off with +RTS -qm @@ -1194,7 +1194,7 @@ scheduleHandleHeapOverflow( Capability *cap, StgTSO *t ) * -------------------------------------------------------------------------- */ static rtsBool -scheduleHandleYield( Capability *cap, StgTSO *t, nat prev_what_next ) +scheduleHandleYield( Capability *cap, StgTSO *t, uint32_t prev_what_next ) { /* put the thread back on the run queue. Then, if we're ready to * GC, check whether this is the last task to stop. If so, wake @@ -1459,7 +1459,7 @@ static rtsBool requestSync ( static void acquireAllCapabilities(Capability *cap, Task *task) { Capability *tmpcap; - nat i; + uint32_t i; ASSERT(pending_sync != NULL); for (i=0; i < n_capabilities; i++) { @@ -1491,9 +1491,9 @@ static void acquireAllCapabilities(Capability *cap, Task *task) * -------------------------------------------------------------------------- */ #ifdef THREADED_RTS -static void releaseAllCapabilities(nat n, Capability *cap, Task *task) +static void releaseAllCapabilities(uint32_t n, Capability *cap, Task *task) { - nat i; + uint32_t i; for (i = 0; i < n; i++) { if (cap->no != i) { @@ -1515,13 +1515,13 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, { Capability *cap = *pcap; rtsBool heap_census; - nat collect_gen; + uint32_t collect_gen; rtsBool major_gc; #ifdef THREADED_RTS - nat gc_type; - nat i; - nat need_idle; - nat n_idle_caps = 0, n_failed_trygrab_idles = 0; + uint32_t gc_type; + uint32_t i; + uint32_t need_idle; + uint32_t n_idle_caps = 0, n_failed_trygrab_idles = 0; StgTSO *tso; rtsBool *idle_cap; #endif @@ -1593,7 +1593,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, // When using +RTS -qn, we need some capabilities to be idle during // GC. The best bet is to choose some inactive ones, so we look for // those first: - nat n_idle = need_idle; + uint32_t n_idle = need_idle; for (i=0; i < n_capabilities; i++) { if (capabilities[i]->disabled) { idle_cap[i] = rtsTrue; @@ -1912,9 +1912,9 @@ forkProcess(HsStablePtr *entry pid_t pid; StgTSO* t,*next; Capability *cap; - nat g; + uint32_t g; Task *task = NULL; - nat i; + uint32_t i; debugTrace(DEBUG_sched, "forking!"); @@ -2097,7 +2097,7 @@ forkProcess(HsStablePtr *entry * ------------------------------------------------------------------------- */ void -setNumCapabilities (nat new_n_capabilities USED_IF_THREADS) +setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) { #if !defined(THREADED_RTS) if (new_n_capabilities != 1) { @@ -2112,9 +2112,9 @@ setNumCapabilities (nat new_n_capabilities USED_IF_THREADS) #else Task *task; Capability *cap; - nat n; + uint32_t n; Capability *old_capabilities = NULL; - nat old_n_capabilities = n_capabilities; + uint32_t old_n_capabilities = n_capabilities; if (new_n_capabilities == enabled_capabilities) return; @@ -2226,7 +2226,7 @@ deleteAllThreads ( Capability *cap ) // NOTE: only safe to call if we own all capabilities. StgTSO* t, *next; - nat g; + uint32_t g; debugTrace(DEBUG_sched,"deleting all threads"); for (g = 0; g < RtsFlags.GcFlags.generations; g++) { @@ -2530,10 +2530,10 @@ void scheduleWorker (Capability *cap, Task *task) * -------------------------------------------------------------------------- */ static void -startWorkerTasks (nat from USED_IF_THREADS, nat to USED_IF_THREADS) +startWorkerTasks (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) { #if defined(THREADED_RTS) - nat i; + uint32_t i; Capability *cap; for (i = from; i < to; i++) { @@ -2624,7 +2624,7 @@ exitScheduler (rtsBool wait_foreign USED_IF_THREADS) void freeScheduler( void ) { - nat still_running; + uint32_t still_running; ACQUIRE_LOCK(&sched_mutex); still_running = freeTaskManager(); diff --git a/rts/Sparks.c b/rts/Sparks.c index ec075805bf..e0b2e66a7d 100644 --- a/rts/Sparks.c +++ b/rts/Sparks.c @@ -89,7 +89,7 @@ pruneSparkQueue (Capability *cap) { SparkPool *pool; StgClosurePtr spark, tmp, *elements; - nat n, pruned_sparks; // stats only + uint32_t n, pruned_sparks; // stats only StgWord botInd,oldBotInd,currInd; // indices in array (always < size) const StgInfoTable *info; @@ -293,10 +293,10 @@ traverseSparkQueue (evac_fn evac, void *user, Capability *cap) * * Could be called after GC, before Cap. release, from scheduler. * -------------------------------------------------------------------------- */ -void balanceSparkPoolsCaps(nat n_caps, Capability caps[]) +void balanceSparkPoolsCaps(uint32_t n_caps, Capability caps[]) GNUC3_ATTRIBUTE(__noreturn__); -void balanceSparkPoolsCaps(nat n_caps STG_UNUSED, +void balanceSparkPoolsCaps(uint32_t n_caps STG_UNUSED, Capability caps[] STG_UNUSED) { barf("not implemented"); } diff --git a/rts/Stable.c b/rts/Stable.c index 695c11d039..2c9480a559 100644 --- a/rts/Stable.c +++ b/rts/Stable.c @@ -113,7 +113,7 @@ static unsigned int SPT_size = 0; #endif static spEntry *old_SPTs[MAX_N_OLD_SPTS]; -static nat n_old_SPTs = 0; +static uint32_t n_old_SPTs = 0; #ifdef THREADED_RTS Mutex stable_mutex; @@ -153,7 +153,7 @@ stableUnlock(void) * -------------------------------------------------------------------------- */ STATIC_INLINE void -initSnEntryFreeList(snEntry *table, nat n, snEntry *free) +initSnEntryFreeList(snEntry *table, uint32_t n, snEntry *free) { snEntry *p; for (p = table + n - 1; p >= table; p--) { @@ -166,7 +166,7 @@ initSnEntryFreeList(snEntry *table, nat n, snEntry *free) } STATIC_INLINE void -initSpEntryFreeList(spEntry *table, nat n, spEntry *free) +initSpEntryFreeList(spEntry *table, uint32_t n, spEntry *free) { spEntry *p; for (p = table + n - 1; p >= table; p--) { @@ -208,7 +208,7 @@ initStableTables(void) static void enlargeStableNameTable(void) { - nat old_SNT_size = SNT_size; + uint32_t old_SNT_size = SNT_size; // 2nd and subsequent times SNT_size *= 2; @@ -223,7 +223,7 @@ enlargeStableNameTable(void) static void enlargeStablePtrTable(void) { - nat old_SPT_size = SPT_size; + uint32_t old_SPT_size = SPT_size; spEntry *new_stable_ptr_table; // 2nd and subsequent times @@ -273,7 +273,7 @@ enlargeStablePtrTable(void) static void freeOldSPTs(void) { - nat i; + uint32_t i; for (i = 0; i < n_old_SPTs; i++) { stgFree(old_SPTs[i]); diff --git a/rts/Stats.c b/rts/Stats.c index 25074ea1d0..64a371a9d6 100644 --- a/rts/Stats.c +++ b/rts/Stats.c @@ -163,7 +163,7 @@ initStats0(void) void initStats1 (void) { - nat i; + uint32_t i; if (RtsFlags.GcFlags.giveStats >= VERBOSE_GC_STATS) { statsPrintf(" Alloc Copied Live GC GC TOT TOT Page Flts\n"); @@ -232,12 +232,12 @@ stat_startGCSync (gc_thread *gct) Called at the beginning of each GC -------------------------------------------------------------------------- */ -static nat rub_bell = 0; +static uint32_t rub_bell = 0; void stat_startGC (Capability *cap, gc_thread *gct) { - nat bell = RtsFlags.GcFlags.ringBell; + uint32_t bell = RtsFlags.GcFlags.ringBell; if (bell) { if (bell > 1) { @@ -272,8 +272,8 @@ stat_startGC (Capability *cap, gc_thread *gct) void stat_endGC (Capability *cap, gc_thread *gct, - W_ live, W_ copied, W_ slop, nat gen, - nat par_n_threads, W_ par_max_copied, W_ par_tot_copied) + W_ live, W_ copied, W_ slop, uint32_t gen, + uint32_t par_n_threads, W_ par_max_copied, W_ par_tot_copied) { W_ tot_alloc; W_ alloc; @@ -420,9 +420,9 @@ stat_startRP(void) #ifdef PROFILING void stat_endRP( - nat retainerGeneration, + uint32_t retainerGeneration, #ifdef DEBUG_RETAINER - nat maxCStackSize, + uint32_t maxCStackSize, int maxStackSize, #endif double averageNumVisit) @@ -540,7 +540,7 @@ stat_exit (void) char temp[BIG_STRING_LEN]; Time tot_cpu; Time tot_elapsed; - nat i, g, total_collections = 0; + uint32_t i, g, total_collections = 0; getProcessTimes( &tot_cpu, &tot_elapsed ); tot_elapsed -= start_init_elapsed; @@ -643,7 +643,7 @@ stat_exit (void) statsPrintf("\n"); { - nat i; + uint32_t i; SparkCounters sparks = { 0, 0, 0, 0, 0, 0}; for (i = 0; i < n_capabilities; i++) { sparks.created += capabilities[i]->spark_stats.created; @@ -713,7 +713,7 @@ stat_exit (void) #if defined(THREADED_RTS) && defined(PROF_SPIN) { - nat g; + uint32_t g; statsPrintf("gc_alloc_block_sync: %"FMT_Word64"\n", gc_alloc_block_sync.spin); statsPrintf("whitehole_spin: %"FMT_Word64"\n", whitehole_spin); @@ -785,7 +785,7 @@ stat_exit (void) void statDescribeGens(void) { - nat g, mut, lge, i; + uint32_t g, mut, lge, i; W_ gen_slop; W_ tot_live, tot_slop; W_ gen_live, gen_blocks; @@ -859,8 +859,8 @@ extern rtsBool getGCStatsEnabled( void ) extern void getGCStats( GCStats *s ) { - nat total_collections = 0; - nat g; + uint32_t total_collections = 0; + uint32_t g; Time gc_cpu = 0; Time gc_elapsed = 0; Time current_elapsed = 0; @@ -904,7 +904,7 @@ extern void getGCStats( GCStats *s ) // extern void getTaskStats( TaskStats **s ) {} #if 0 extern void getSparkStats( SparkCounters *s ) { - nat i; + uint32_t i; s->created = 0; s->dud = 0; s->overflowed = 0; diff --git a/rts/Stats.h b/rts/Stats.h index 5897a3b0f5..1d95170f2c 100644 --- a/rts/Stats.h +++ b/rts/Stats.h @@ -29,15 +29,15 @@ void stat_endInit(void); void stat_startGCSync(struct gc_thread_ *_gct); void stat_startGC(Capability *cap, struct gc_thread_ *_gct); -void stat_endGC (Capability *cap, struct gc_thread_ *_gct, - W_ live, W_ copied, W_ slop, nat gen, - nat n_gc_threads, W_ par_max_copied, W_ par_tot_copied); +void stat_endGC (Capability *cap, struct gc_thread_ *_gct, W_ live, + W_ copied, W_ slop, uint32_t gen, uint32_t n_gc_threads, + W_ par_max_copied, W_ par_tot_copied); #ifdef PROFILING void stat_startRP(void); -void stat_endRP(nat, +void stat_endRP(uint32_t, #ifdef DEBUG_RETAINER - nat, int, + uint32_t, int, #endif double); #endif /* PROFILING */ diff --git a/rts/Task.c b/rts/Task.c index c30bcf17d5..45ef77ba0b 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -27,10 +27,11 @@ // Locks required: all_tasks_mutex. Task *all_tasks = NULL; -nat taskCount; // current number of bound tasks + total number of worker tasks. -nat workerCount; -nat currentWorkerCount; -nat peakWorkerCount; +// current number of bound tasks + total number of worker tasks. +uint32_t taskCount; +uint32_t workerCount; +uint32_t currentWorkerCount; +uint32_t peakWorkerCount; static int tasksInitialized = 0; @@ -80,11 +81,11 @@ initTaskManager (void) } } -nat +uint32_t freeTaskManager (void) { Task *task, *next; - nat tasksRunning = 0; + uint32_t tasksRunning = 0; ACQUIRE_LOCK(&all_tasks_mutex); diff --git a/rts/Task.h b/rts/Task.h index 209df49ddb..5fea2badda 100644 --- a/rts/Task.h +++ b/rts/Task.h @@ -140,7 +140,7 @@ typedef struct Task_ { // The current top-of-stack InCall struct InCall_ *incall; - nat n_spare_incalls; + uint32_t n_spare_incalls; struct InCall_ *spare_incalls; rtsBool worker; // == rtsTrue if this is a worker Task @@ -192,7 +192,7 @@ extern Mutex all_tasks_mutex; // Requires: sched_mutex. // void initTaskManager (void); -nat freeTaskManager (void); +uint32_t freeTaskManager (void); // Create a new Task for a bound thread. This Task must be released // by calling boundTaskExiting. The Task is cached in @@ -247,9 +247,9 @@ void interruptWorkerTask (Task *task); #endif /* THREADED_RTS */ // For stats -extern nat taskCount; -extern nat workerCount; -extern nat peakWorkerCount; +extern uint32_t taskCount; +extern uint32_t workerCount; +extern uint32_t peakWorkerCount; // ----------------------------------------------------------------------------- // INLINE functions... private from here on down: diff --git a/rts/ThreadPaused.c b/rts/ThreadPaused.c index 1f1d0afe58..f58a51ed8f 100644 --- a/rts/ThreadPaused.c +++ b/rts/ThreadPaused.c @@ -30,12 +30,12 @@ struct stack_gap { StgWord gap_size; struct stack_gap *next_gap; }; static struct stack_gap * -updateAdjacentFrames (Capability *cap, StgTSO *tso, - StgUpdateFrame *upd, nat count, struct stack_gap *next) +updateAdjacentFrames (Capability *cap, StgTSO *tso, StgUpdateFrame *upd, + uint32_t count, struct stack_gap *next) { StgClosure *updatee; struct stack_gap *gap; - nat i; + uint32_t i; // The first one (highest address) is the frame we take the // "master" updatee from; all the others will be made indirections @@ -80,7 +80,7 @@ static void stackSqueeze(Capability *cap, StgTSO *tso, StgPtr bottom) { StgPtr frame; - nat adjacent_update_frames; + uint32_t adjacent_update_frames; struct stack_gap *gap; // Stage 1: @@ -158,7 +158,7 @@ stackSqueeze(Capability *cap, StgTSO *tso, StgPtr bottom) { StgWord8 *sp; StgWord8 *gap_start, *next_gap_start, *gap_end; - nat chunk_size; + uint32_t chunk_size; next_gap_start = (StgWord8*)gap + sizeof(StgUpdateFrame); sp = next_gap_start; @@ -197,9 +197,9 @@ threadPaused(Capability *cap, StgTSO *tso) const StgInfoTable *cur_bh_info USED_IF_THREADS; StgClosure *bh; StgPtr stack_end; - nat words_to_squeeze = 0; - nat weight = 0; - nat weight_pending = 0; + uint32_t words_to_squeeze = 0; + uint32_t weight = 0; + uint32_t weight_pending = 0; rtsBool prev_was_update_frame = rtsFalse; StgWord heuristic_says_squeeze; @@ -352,7 +352,7 @@ threadPaused(Capability *cap, StgTSO *tso) // normal stack frames; do nothing except advance the pointer default: { - nat frame_size = stack_frame_sizeW(frame); + uint32_t frame_size = stack_frame_sizeW(frame); weight_pending += frame_size; frame = (StgClosure *)((StgPtr)frame + frame_size); prev_was_update_frame = rtsFalse; diff --git a/rts/Threads.c b/rts/Threads.c index bf30ab8eac..7317249e11 100644 --- a/rts/Threads.c +++ b/rts/Threads.c @@ -59,7 +59,7 @@ createThread(Capability *cap, W_ size) { StgTSO *tso; StgStack *stack; - nat stack_size; + uint32_t stack_size; /* sched_mutex is *not* required */ @@ -701,7 +701,7 @@ threadStackUnderflow (Capability *cap, StgTSO *tso) { StgStack *new_stack, *old_stack; StgUnderflowFrame *frame; - nat retvals; + uint32_t retvals; debugTraceCap(DEBUG_sched, cap, "stack underflow"); @@ -831,7 +831,7 @@ void printAllThreads(void) { StgTSO *t, *next; - nat i, g; + uint32_t i, g; Capability *cap; debugBelch("all threads:\n"); @@ -859,7 +859,7 @@ printAllThreads(void) void printThreadQueue(StgTSO *t) { - nat i = 0; + uint32_t i = 0; for (; t != END_TSO_QUEUE; t = t->_link) { printThreadStatus(t); i++; diff --git a/rts/Trace.c b/rts/Trace.c index d0fa1e57a0..cf47e160bb 100644 --- a/rts/Trace.c +++ b/rts/Trace.c @@ -147,7 +147,7 @@ void resetTracing (void) } } -void tracingAddCapapilities (nat from, nat to) +void tracingAddCapapilities (uint32_t from, uint32_t to) { if (eventlog_enabled) { moreCapEventBufs(from,to); @@ -338,7 +338,7 @@ void traceHeapEvent_ (Capability *cap, } void traceEventHeapInfo_ (CapsetID heap_capset, - nat gens, + uint32_t gens, W_ maxHeapSize, W_ allocAreaSize, W_ mblockSize, @@ -358,11 +358,11 @@ void traceEventHeapInfo_ (CapsetID heap_capset, void traceEventGcStats_ (Capability *cap, CapsetID heap_capset, - nat gen, + uint32_t gen, W_ copied, W_ slop, W_ fragmentation, - nat par_n_threads, + uint32_t par_n_threads, W_ par_max_copied, W_ par_tot_copied) { diff --git a/rts/Trace.h b/rts/Trace.h index e0d6f20c45..cad65b0644 100644 --- a/rts/Trace.h +++ b/rts/Trace.h @@ -28,7 +28,7 @@ void initTracing (void); void endTracing (void); void freeTracing (void); void resetTracing (void); -void tracingAddCapapilities (nat from, nat to); +void tracingAddCapapilities (uint32_t from, uint32_t to); #endif /* TRACING */ @@ -136,7 +136,7 @@ void traceHeapEvent_ (Capability *cap, W_ info1); void traceEventHeapInfo_ (CapsetID heap_capset, - nat gens, + uint32_t gens, W_ maxHeapSize, W_ allocAreaSize, W_ mblockSize, @@ -144,11 +144,11 @@ void traceEventHeapInfo_ (CapsetID heap_capset, void traceEventGcStats_ (Capability *cap, CapsetID heap_capset, - nat gen, + uint32_t gen, W_ copied, W_ slop, W_ fragmentation, - nat par_n_threads, + uint32_t par_n_threads, W_ par_max_copied, W_ par_tot_copied); @@ -519,7 +519,7 @@ INLINE_HEADER void traceEventStopThread(Capability *cap STG_UNUSED, INLINE_HEADER void traceEventMigrateThread(Capability *cap STG_UNUSED, StgTSO *tso STG_UNUSED, - nat new_cap STG_UNUSED) + uint32_t new_cap STG_UNUSED) { traceSchedEvent(cap, EVENT_MIGRATE_THREAD, tso, new_cap); dtraceMigrateThread((EventCapNo)cap->no, (EventThreadID)tso->id, @@ -552,7 +552,7 @@ INLINE_HEADER void traceCapDisable(Capability *cap STG_UNUSED) INLINE_HEADER void traceEventThreadWakeup(Capability *cap STG_UNUSED, StgTSO *tso STG_UNUSED, - nat other_cap STG_UNUSED) + uint32_t other_cap STG_UNUSED) { traceSchedEvent(cap, EVENT_THREAD_WAKEUP, tso, other_cap); dtraceThreadWakeup((EventCapNo)cap->no, (EventThreadID)tso->id, @@ -633,11 +633,11 @@ INLINE_HEADER void traceEventGcGlobalSync(Capability *cap STG_UNUSED) INLINE_HEADER void traceEventGcStats(Capability *cap STG_UNUSED, CapsetID heap_capset STG_UNUSED, - nat gen STG_UNUSED, + uint32_t gen STG_UNUSED, W_ copied STG_UNUSED, W_ slop STG_UNUSED, W_ fragmentation STG_UNUSED, - nat par_n_threads STG_UNUSED, + uint32_t par_n_threads STG_UNUSED, W_ par_max_copied STG_UNUSED, W_ par_tot_copied STG_UNUSED) { @@ -652,7 +652,7 @@ INLINE_HEADER void traceEventGcStats(Capability *cap STG_UNUSED, } INLINE_HEADER void traceEventHeapInfo(CapsetID heap_capset STG_UNUSED, - nat gens STG_UNUSED, + uint32_t gens STG_UNUSED, W_ maxHeapSize STG_UNUSED, W_ allocAreaSize STG_UNUSED, W_ mblockSize STG_UNUSED, @@ -706,14 +706,14 @@ INLINE_HEADER void traceCapsetDelete(CapsetID capset STG_UNUSED) } INLINE_HEADER void traceCapsetAssignCap(CapsetID capset STG_UNUSED, - nat capno STG_UNUSED) + uint32_t capno STG_UNUSED) { traceCapsetEvent(EVENT_CAPSET_ASSIGN_CAP, capset, capno); dtraceCapsetAssignCap(capset, capno); } INLINE_HEADER void traceCapsetRemoveCap(CapsetID capset STG_UNUSED, - nat capno STG_UNUSED) + uint32_t capno STG_UNUSED) { traceCapsetEvent(EVENT_CAPSET_REMOVE_CAP, capset, capno); dtraceCapsetRemoveCap(capset, capno); @@ -781,7 +781,7 @@ INLINE_HEADER void traceEventSparkRun(Capability *cap STG_UNUSED) } INLINE_HEADER void traceEventSparkSteal(Capability *cap STG_UNUSED, - nat victim_cap STG_UNUSED) + uint32_t victim_cap STG_UNUSED) { traceSparkEvent2(cap, EVENT_SPARK_STEAL, victim_cap); dtraceSparkSteal((EventCapNo)cap->no, (EventCapNo)victim_cap); diff --git a/rts/WSDeque.c b/rts/WSDeque.c index 19f2866c08..45a0b10984 100644 --- a/rts/WSDeque.c +++ b/rts/WSDeque.c @@ -69,7 +69,7 @@ roundUp2(StgWord val) } WSDeque * -newWSDeque (nat size) +newWSDeque (uint32_t size) { StgWord realsize; WSDeque *q; diff --git a/rts/WSDeque.h b/rts/WSDeque.h index 4993d5ac61..5a23746562 100644 --- a/rts/WSDeque.h +++ b/rts/WSDeque.h @@ -67,7 +67,7 @@ typedef struct WSDeque_ { * -------------------------------------------------------------------------- */ // Allocation, deallocation -WSDeque * newWSDeque (nat size); +WSDeque * newWSDeque (uint32_t size); void freeWSDeque (WSDeque *q); // Take an element from the "write" end of the pool. Can be called diff --git a/rts/Weak.c b/rts/Weak.c index 92f1bdbd02..27854c91be 100644 --- a/rts/Weak.c +++ b/rts/Weak.c @@ -82,7 +82,7 @@ scheduleFinalizers(Capability *cap, StgWeak *list) StgTSO *t; StgMutArrPtrs *arr; StgWord size; - nat n, i; + uint32_t n, i; Task *task; task = myTask(); diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index db103a7f3c..9e2ed33d22 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -112,7 +112,7 @@ char *EventDesc[] = { typedef struct _EventType { EventTypeNum etNum; // Event Type number. - nat size; // size of the payload in bytes + uint32_t size; // size of the payload in bytes char *desc; // Description } EventType; @@ -130,7 +130,7 @@ static void postBlockMarker(EventsBuf *eb); static void closeBlockMarker(EventsBuf *ebuf); static StgBool hasRoomForEvent(EventsBuf *eb, EventTypeNum eNum); -static StgBool hasRoomForVariableEvent(EventsBuf *eb, nat payload_bytes); +static StgBool hasRoomForVariableEvent(EventsBuf *eb, uint32_t payload_bytes); static void ensureRoomForEvent(EventsBuf *eb, EventTypeNum tag); static int ensureRoomForVariableEvent(EventsBuf *eb, StgWord16 size); @@ -158,7 +158,7 @@ static inline void postWord64(EventsBuf *eb, StgWord64 i) postWord32(eb, (StgWord32)i); } -static inline void postBuf(EventsBuf *eb, StgWord8 *buf, nat size) +static inline void postBuf(EventsBuf *eb, StgWord8 *buf, uint32_t size) { memcpy(eb->pos, buf, size); eb->pos += size; @@ -214,7 +214,7 @@ void initEventLogging(void) { StgWord8 t, c; - nat n_caps; + uint32_t n_caps; char *prog; prog = stgMallocBytes(strlen(prog_name) + 1, "initEventLogging"); @@ -465,7 +465,7 @@ initEventLogging(void) void endEventLogging(void) { - nat c; + uint32_t c; // Flush all events remaining in the buffers. for (c = 0; c < n_capabilities; ++c) { @@ -486,9 +486,9 @@ endEventLogging(void) } void -moreCapEventBufs (nat from, nat to) +moreCapEventBufs (uint32_t from, uint32_t to) { - nat c; + uint32_t c; if (from > 0) { capEventBuf = stgReallocBytes(capEventBuf, to * sizeof(EventsBuf), @@ -867,7 +867,7 @@ void postHeapEvent (Capability *cap, } void postEventHeapInfo (EventCapsetID heap_capset, - nat gens, + uint32_t gens, W_ maxHeapSize, W_ allocAreaSize, W_ mblockSize, @@ -892,11 +892,11 @@ void postEventHeapInfo (EventCapsetID heap_capset, void postEventGcStats (Capability *cap, EventCapsetID heap_capset, - nat gen, + uint32_t gen, W_ copied, W_ slop, W_ fragmentation, - nat par_n_threads, + uint32_t par_n_threads, W_ par_max_copied, W_ par_tot_copied) { @@ -993,7 +993,7 @@ postEventAtTimestamp (Capability *cap, EventTimestamp ts, EventTypeNum tag) void postLogMsg(EventsBuf *eb, EventTypeNum type, char *msg, va_list ap) { char buf[BUF]; - nat size; + uint32_t size; size = vsnprintf(buf,BUF,msg,ap); if (size > BUF) { @@ -1141,7 +1141,7 @@ void resetEventsBuf(EventsBuf* eb) StgBool hasRoomForEvent(EventsBuf *eb, EventTypeNum eNum) { - nat size; + uint32_t size; size = sizeof(EventTypeNum) + sizeof(EventTimestamp) + eventTypes[eNum].size; @@ -1152,9 +1152,9 @@ StgBool hasRoomForEvent(EventsBuf *eb, EventTypeNum eNum) } } -StgBool hasRoomForVariableEvent(EventsBuf *eb, nat payload_bytes) +StgBool hasRoomForVariableEvent(EventsBuf *eb, uint32_t payload_bytes) { - nat size; + uint32_t size; size = sizeof(EventTypeNum) + sizeof(EventTimestamp) + sizeof(EventPayloadSize) + payload_bytes; @@ -1189,7 +1189,7 @@ int ensureRoomForVariableEvent(EventsBuf *eb, StgWord16 size) void postEventType(EventsBuf *eb, EventType *et) { StgWord8 d; - nat desclen; + uint32_t desclen; postInt32(eb, EVENT_ET_BEGIN); postEventTypeNum(eb, et->etNum); diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h index abe7880fe4..ed783bc361 100644 --- a/rts/eventlog/EventLog.h +++ b/rts/eventlog/EventLog.h @@ -26,7 +26,7 @@ void endEventLogging(void); void freeEventLogging(void); void abortEventLogging(void); // #4512 - after fork child needs to abort void flushEventLog(void); // event log inherited from parent -void moreCapEventBufs (nat from, nat to); +void moreCapEventBufs (uint32_t from, uint32_t to); /* * Post a scheduler event to the capability's event buffer (an event @@ -107,7 +107,7 @@ void postHeapEvent (Capability *cap, W_ info1); void postEventHeapInfo (EventCapsetID heap_capset, - nat gens, + uint32_t gens, W_ maxHeapSize, W_ allocAreaSize, W_ mblockSize, @@ -115,11 +115,11 @@ void postEventHeapInfo (EventCapsetID heap_capset, void postEventGcStats (Capability *cap, EventCapsetID heap_capset, - nat gen, + uint32_t gen, W_ copied, W_ slop, W_ fragmentation, - nat par_n_threads, + uint32_t par_n_threads, W_ par_max_copied, W_ par_tot_copied); diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c index ab0d15e129..130d3f1ca9 100644 --- a/rts/posix/GetTime.c +++ b/rts/posix/GetTime.c @@ -140,7 +140,7 @@ Time getProcessElapsedTime(void) void getProcessTimes(Time *user, Time *elapsed) { - static nat ClockFreq = 0; + static uint32_t ClockFreq = 0; if (ClockFreq == 0) { #if defined(HAVE_SYSCONF) diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c index 20d27bec4f..a06f544874 100644 --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -260,7 +260,7 @@ gen_map_mblocks (W_ size) } void * -osGetMBlocks(nat n) +osGetMBlocks(uint32_t n) { caddr_t ret; W_ size = MBLOCK_SIZE * (W_)n; @@ -294,7 +294,7 @@ osGetMBlocks(nat n) return ret; } -void osFreeMBlocks(char *addr, nat n) +void osFreeMBlocks(char *addr, uint32_t n) { munmap(addr, n * MBLOCK_SIZE); } diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index 1562ee49d7..ad138d314d 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -227,10 +227,10 @@ forkOS_createThread ( HsStablePtr entry ) return result; } -nat +uint32_t getNumberOfProcessors (void) { - static nat nproc = 0; + static uint32_t nproc = 0; if (nproc == 0) { #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) @@ -238,13 +238,13 @@ getNumberOfProcessors (void) #elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_CONF) nproc = sysconf(_SC_NPROCESSORS_CONF); #elif defined(darwin_HOST_OS) - size_t size = sizeof(nat); + size_t size = sizeof(uint32_t); if(sysctlbyname("hw.logicalcpu",&nproc,&size,NULL,0) != 0) { if(sysctlbyname("hw.ncpu",&nproc,&size,NULL,0) != 0) nproc = 1; } #elif defined(freebsd_HOST_OS) - size_t size = sizeof(nat); + size_t size = sizeof(uint32_t); if(sysctlbyname("hw.ncpu",&nproc,&size,NULL,0) != 0) nproc = 1; #else @@ -260,11 +260,11 @@ getNumberOfProcessors (void) // number of physical CPUs, in which case, the thread will be allowed // to run on CPU n, n+m, n+2m etc. void -setThreadAffinity (nat n, nat m) +setThreadAffinity (uint32_t n, uint32_t m) { - nat nproc; + uint32_t nproc; cpu_set_t cs; - nat i; + uint32_t i; nproc = getNumberOfProcessors(); CPU_ZERO(&cs); @@ -277,7 +277,7 @@ setThreadAffinity (nat n, nat m) #elif defined(darwin_HOST_OS) && defined(THREAD_AFFINITY_POLICY) // Schedules the current thread in the affinity set identified by tag n. void -setThreadAffinity (nat n, nat m GNUC3_ATTRIBUTE(__unused__)) +setThreadAffinity (uint32_t n, uint32_t m GNUC3_ATTRIBUTE(__unused__)) { thread_affinity_policy_data_t policy; @@ -290,11 +290,11 @@ setThreadAffinity (nat n, nat m GNUC3_ATTRIBUTE(__unused__)) #elif defined(HAVE_SYS_CPUSET_H) /* FreeBSD 7.1+ */ void -setThreadAffinity(nat n, nat m) +setThreadAffinity(uint32_t n, uint32_t m) { - nat nproc; + uint32_t nproc; cpuset_t cs; - nat i; + uint32_t i; nproc = getNumberOfProcessors(); CPU_ZERO(&cs); @@ -308,8 +308,8 @@ setThreadAffinity(nat n, nat m) #else void -setThreadAffinity (nat n GNUC3_ATTRIBUTE(__unused__), - nat m GNUC3_ATTRIBUTE(__unused__)) +setThreadAffinity (uint32_t n GNUC3_ATTRIBUTE(__unused__), + uint32_t m GNUC3_ATTRIBUTE(__unused__)) { } #endif @@ -328,7 +328,7 @@ forkOS_createThread ( HsStablePtr entry STG_UNUSED ) return -1; } -nat getNumberOfProcessors (void) +uint32_t getNumberOfProcessors (void) { return 1; } diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c index 7fb854b894..496ec7b2df 100644 --- a/rts/posix/Signals.c +++ b/rts/posix/Signals.c @@ -65,7 +65,7 @@ HsInt nocldstop = 0; StgInt *signal_handlers = NULL; /* Dynamically grown array of signal handlers */ static StgInt nHandlers = 0; /* Size of handlers array */ -static nat n_haskell_handlers = 0; +static uint32_t n_haskell_handlers = 0; static sigset_t userSignals; static sigset_t savedSignals; @@ -185,7 +185,7 @@ void ioManagerDie (void) { StgWord8 byte = (StgWord8)IO_MANAGER_DIE; - nat i; + uint32_t i; int fd; int r; diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c index a07dedb137..ff1a6460a4 100644 --- a/rts/sm/BlockAlloc.c +++ b/rts/sm/BlockAlloc.c @@ -7,7 +7,7 @@ * This is the architecture independent part of the block allocator. * It requires only the following support from the operating system: * - * void *getMBlock(nat n); + * void *getMBlock(uint32_t n); * * returns the address of an n*MBLOCK_SIZE region of memory, aligned on * an MBLOCK_SIZE boundary. There are no other restrictions on the @@ -140,7 +140,7 @@ static void initMBlock(void *mblock); Be very careful with integer overflow here. If you have an expression like (n_blocks * BLOCK_SIZE), and n_blocks is an int or - a nat, then it will very likely overflow on a 64-bit platform. + a uint32_t, then it will very likely overflow on a 64-bit platform. Always cast to StgWord (or W_ for short) first: ((W_)n_blocks * BLOCK_SIZE). --------------------------------------------------------------------------- */ @@ -170,7 +170,7 @@ W_ hw_alloc_blocks; // high-water allocated blocks void initBlockAllocator(void) { - nat i; + uint32_t i; for (i=0; i < NUM_FREE_LISTS; i++) { free_list[i] = NULL; } @@ -209,7 +209,7 @@ initGroup(bdescr *head) #endif // log base 2 (floor), needs to support up to (2^NUM_FREE_LISTS)-1 -STATIC_INLINE nat +STATIC_INLINE uint32_t log_2(W_ n) { ASSERT(n > 0 && n < (1<<NUM_FREE_LISTS)); @@ -229,12 +229,12 @@ log_2(W_ n) } // log base 2 (ceiling), needs to support up to (2^NUM_FREE_LISTS)-1 -STATIC_INLINE nat +STATIC_INLINE uint32_t log_2_ceil(W_ n) { ASSERT(n > 0 && n < (1<<NUM_FREE_LISTS)); #if defined(__GNUC__) - nat r = log_2(n); + uint32_t r = log_2(n); return (n & (n-1)) ? r+1 : r; #else W_ i, x; @@ -250,7 +250,7 @@ log_2_ceil(W_ n) STATIC_INLINE void free_list_insert (bdescr *bd) { - nat ln; + uint32_t ln; ASSERT(bd->blocks < BLOCKS_PER_MBLOCK); ln = log_2(bd->blocks); @@ -284,7 +284,7 @@ setup_tail (bdescr *bd) // Take a free block group bd, and split off a group of size n from // it. Adjust the free list as necessary, and return the new group. static bdescr * -split_free_block (bdescr *bd, W_ n, nat ln) +split_free_block (bdescr *bd, W_ n, uint32_t ln) { bdescr *fg; // free group @@ -732,7 +732,7 @@ countAllocdBlocks(bdescr *bd) return n; } -void returnMemoryToOS(nat n /* megablocks */) +void returnMemoryToOS(uint32_t n /* megablocks */) { static bdescr *bd; StgWord size; diff --git a/rts/sm/BlockAlloc.h b/rts/sm/BlockAlloc.h index aebb71a913..2ba7c02c08 100644 --- a/rts/sm/BlockAlloc.h +++ b/rts/sm/BlockAlloc.h @@ -17,7 +17,7 @@ bdescr *allocLargeChunk (W_ min, W_ max); extern W_ countBlocks (bdescr *bd); extern W_ countAllocdBlocks (bdescr *bd); -extern void returnMemoryToOS(nat n); +extern void returnMemoryToOS(uint32_t n); #ifdef DEBUG void checkFreeListSanity(void); diff --git a/rts/sm/Compact.h b/rts/sm/Compact.h index db7a9694d2..7ff6e12d14 100644 --- a/rts/sm/Compact.h +++ b/rts/sm/Compact.h @@ -19,7 +19,7 @@ INLINE_HEADER void mark(StgPtr p, bdescr *bd) { - nat offset_within_block = p - bd->start; // in words + uint32_t offset_within_block = p - bd->start; // in words StgPtr bitmap_word = (StgPtr)bd->u.bitmap + (offset_within_block / (sizeof(W_)*BITS_PER_BYTE)); StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1)); @@ -29,7 +29,7 @@ mark(StgPtr p, bdescr *bd) INLINE_HEADER void unmark(StgPtr p, bdescr *bd) { - nat offset_within_block = p - bd->start; // in words + uint32_t offset_within_block = p - bd->start; // in words StgPtr bitmap_word = (StgPtr)bd->u.bitmap + (offset_within_block / (sizeof(W_)*BITS_PER_BYTE)); StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1)); @@ -39,7 +39,7 @@ unmark(StgPtr p, bdescr *bd) INLINE_HEADER StgWord is_marked(StgPtr p, bdescr *bd) { - nat offset_within_block = p - bd->start; // in words + uint32_t offset_within_block = p - bd->start; // in words StgPtr bitmap_word = (StgPtr)bd->u.bitmap + (offset_within_block / (sizeof(W_)*BITS_PER_BYTE)); StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1)); diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c index a9f112702f..e53461de63 100644 --- a/rts/sm/Evac.c +++ b/rts/sm/Evac.c @@ -52,7 +52,7 @@ STATIC_INLINE void evacuate_large(StgPtr p); -------------------------------------------------------------------------- */ STATIC_INLINE StgPtr -alloc_for_copy (nat size, nat gen_no) +alloc_for_copy (uint32_t size, uint32_t gen_no) { StgPtr to; gen_workspace *ws; @@ -91,10 +91,10 @@ alloc_for_copy (nat size, nat gen_no) STATIC_INLINE GNUC_ATTR_HOT void copy_tag(StgClosure **p, const StgInfoTable *info, - StgClosure *src, nat size, nat gen_no, StgWord tag) + StgClosure *src, uint32_t size, uint32_t gen_no, StgWord tag) { StgPtr to, from; - nat i; + uint32_t i; to = alloc_for_copy(size,gen_no); @@ -146,10 +146,10 @@ copy_tag(StgClosure **p, const StgInfoTable *info, #if defined(PARALLEL_GC) && !defined(PROFILING) STATIC_INLINE void copy_tag_nolock(StgClosure **p, const StgInfoTable *info, - StgClosure *src, nat size, nat gen_no, StgWord tag) + StgClosure *src, uint32_t size, uint32_t gen_no, StgWord tag) { StgPtr to, from; - nat i; + uint32_t i; to = alloc_for_copy(size,gen_no); @@ -182,11 +182,11 @@ copy_tag_nolock(StgClosure **p, const StgInfoTable *info, * used to optimise evacuation of TSOs. */ static rtsBool -copyPart(StgClosure **p, StgClosure *src, nat size_to_reserve, - nat size_to_copy, nat gen_no) +copyPart(StgClosure **p, StgClosure *src, uint32_t size_to_reserve, + uint32_t size_to_copy, uint32_t gen_no) { StgPtr to, from; - nat i; + uint32_t i; StgWord info; #if defined(PARALLEL_GC) @@ -235,7 +235,7 @@ spin: /* Copy wrappers that don't tag the closure after copying */ STATIC_INLINE GNUC_ATTR_HOT void copy(StgClosure **p, const StgInfoTable *info, - StgClosure *src, nat size, nat gen_no) + StgClosure *src, uint32_t size, uint32_t gen_no) { copy_tag(p,info,src,size,gen_no,0); } @@ -256,7 +256,7 @@ evacuate_large(StgPtr p) { bdescr *bd; generation *gen, *new_gen; - nat gen_no, new_gen_no; + uint32_t gen_no, new_gen_no; gen_workspace *ws; bd = Bdescr(p); @@ -401,7 +401,7 @@ REGPARM1 GNUC_ATTR_HOT void evacuate(StgClosure **p) { bdescr *bd = NULL; - nat gen_no; + uint32_t gen_no; StgClosure *q; const StgInfoTable *info; StgWord tag; @@ -809,7 +809,7 @@ static void eval_thunk_selector (StgClosure **q, StgSelector * p, rtsBool evac) // NB. for legacy reasons, p & q are swapped around :( { - nat field; + uint32_t field; StgInfoTable *info; StgWord info_ptr; StgClosure *selectee; diff --git a/rts/sm/GC.c b/rts/sm/GC.c index d3f3ab0166..996ce8cbce 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -95,7 +95,7 @@ * flag) is when we're collecting all generations. We only attempt to * deal with static objects and GC CAFs when doing a major GC. */ -nat N; +uint32_t N; rtsBool major_gc; /* Data used for allocation area sizing. @@ -104,7 +104,7 @@ static W_ g0_pcnt_kept = 30; // percentage of g0 live at last minor GC /* Mut-list stats */ #ifdef DEBUG -nat mutlist_MUTVARS, +uint32_t mutlist_MUTVARS, mutlist_MUTARRS, mutlist_MVARS, mutlist_TVAR, @@ -126,15 +126,15 @@ StgWord8 the_gc_thread[sizeof(gc_thread) + 64 * sizeof(gen_workspace)]; // Number of threads running in *this* GC. Affects how many // step->todos[] lists we have to look in to find work. -nat n_gc_threads; +uint32_t n_gc_threads; // For stats: static long copied; // *words* copied & scavenged during this GC rtsBool work_stealing; -nat static_flag = STATIC_FLAG_B; -nat prev_static_flag = STATIC_FLAG_A; +uint32_t static_flag = STATIC_FLAG_B; +uint32_t prev_static_flag = STATIC_FLAG_A; DECLARE_GCT @@ -152,8 +152,8 @@ static void start_gc_threads (void); static void scavenge_until_all_done (void); static StgWord inc_running (void); static StgWord dec_running (void); -static void wakeup_gc_threads (nat me); -static void shutdown_gc_threads (nat me); +static void wakeup_gc_threads (uint32_t me); +static void shutdown_gc_threads (uint32_t me); static void collect_gct_blocks (void); static void collect_pinned_object_blocks (void); @@ -178,9 +178,9 @@ StgPtr mark_sp; // pointer to the next unallocated mark stack entry -------------------------------------------------------------------------- */ void -GarbageCollect (nat collect_gen, +GarbageCollect (uint32_t collect_gen, rtsBool do_heap_census, - nat gc_type USED_IF_THREADS, + uint32_t gc_type USED_IF_THREADS, Capability *cap) { bdescr *bd; @@ -189,7 +189,7 @@ GarbageCollect (nat collect_gen, #if defined(THREADED_RTS) gc_thread *saved_gct; #endif - nat g, n; + uint32_t g, n; // necessary if we stole a callee-saves register for gct: #if defined(THREADED_RTS) @@ -459,7 +459,7 @@ GarbageCollect (nat collect_gen, par_max_copied = 0; par_tot_copied = 0; { - nat i; + uint32_t i; for (i=0; i < n_gc_threads; i++) { if (n_gc_threads > 1) { debugTrace(DEBUG_gc,"thread %d:", i); @@ -621,7 +621,7 @@ GarbageCollect (nat collect_gen, // add in the partial blocks in the gen_workspaces { - nat i; + uint32_t i; for (i = 0; i < n_capabilities; i++) { live_words += gcThreadLiveWords(i, gen->no); live_blocks += gcThreadLiveBlocks(i, gen->no); @@ -766,9 +766,9 @@ GarbageCollect (nat collect_gen, #define GC_THREAD_WAITING_TO_CONTINUE 3 static void -new_gc_thread (nat n, gc_thread *t) +new_gc_thread (uint32_t n, gc_thread *t) { - nat g; + uint32_t g; gen_workspace *ws; t->cap = capabilities[n]; @@ -829,10 +829,10 @@ new_gc_thread (nat n, gc_thread *t) void -initGcThreads (nat from USED_IF_THREADS, nat to USED_IF_THREADS) +initGcThreads (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) { #if defined(THREADED_RTS) - nat i; + uint32_t i; if (from > 0) { gc_threads = stgReallocBytes (gc_threads, to * sizeof(gc_thread*), @@ -861,10 +861,10 @@ initGcThreads (nat from USED_IF_THREADS, nat to USED_IF_THREADS) void freeGcThreads (void) { - nat g; + uint32_t g; if (gc_threads != NULL) { #if defined(THREADED_RTS) - nat i; + uint32_t i; for (i = 0; i < n_capabilities; i++) { for (g = 0; g < RtsFlags.GcFlags.generations; g++) { @@ -933,7 +933,7 @@ any_work (void) #if defined(THREADED_RTS) if (work_stealing) { - nat n; + uint32_t n; // look for work to steal for (n = 0; n < n_gc_threads; n++) { if (n == gct->thread_index) continue; @@ -956,7 +956,7 @@ any_work (void) static void scavenge_until_all_done (void) { - DEBUG_ONLY( nat r ); + DEBUG_ONLY( uint32_t r ); loop: @@ -1063,9 +1063,9 @@ gcWorkerThread (Capability *cap) void waitForGcThreads (Capability *cap USED_IF_THREADS) { - const nat n_threads = n_capabilities; - const nat me = cap->no; - nat i, j; + const uint32_t n_threads = n_capabilities; + const uint32_t me = cap->no; + uint32_t i, j; rtsBool retry = rtsTrue; stat_startGCSync(gc_threads[cap->no]); @@ -1104,10 +1104,10 @@ start_gc_threads (void) } static void -wakeup_gc_threads (nat me USED_IF_THREADS) +wakeup_gc_threads (uint32_t me USED_IF_THREADS) { #if defined(THREADED_RTS) - nat i; + uint32_t i; if (n_gc_threads == 1) return; @@ -1128,10 +1128,10 @@ wakeup_gc_threads (nat me USED_IF_THREADS) // standby state, otherwise they may still be executing inside // any_work(), and may even remain awake until the next GC starts. static void -shutdown_gc_threads (nat me USED_IF_THREADS) +shutdown_gc_threads (uint32_t me USED_IF_THREADS) { #if defined(THREADED_RTS) - nat i; + uint32_t i; if (n_gc_threads == 1) return; @@ -1149,9 +1149,9 @@ shutdown_gc_threads (nat me USED_IF_THREADS) void releaseGCThreads (Capability *cap USED_IF_THREADS) { - const nat n_threads = n_capabilities; - const nat me = cap->no; - nat i; + const uint32_t n_threads = n_capabilities; + const uint32_t me = cap->no; + uint32_t i; for (i=0; i < n_threads; i++) { if (i == me || gc_threads[i]->idle) continue; if (gc_threads[i]->wakeup != GC_THREAD_WAITING_TO_CONTINUE) @@ -1171,7 +1171,7 @@ releaseGCThreads (Capability *cap USED_IF_THREADS) static void prepare_collected_gen (generation *gen) { - nat i, g, n; + uint32_t i, g, n; gen_workspace *ws; bdescr *bd, *next; @@ -1293,7 +1293,7 @@ prepare_collected_gen (generation *gen) ------------------------------------------------------------------------- */ static void -stash_mut_list (Capability *cap, nat gen_no) +stash_mut_list (Capability *cap, uint32_t gen_no) { cap->saved_mut_lists[gen_no] = cap->mut_lists[gen_no]; cap->mut_lists[gen_no] = allocBlock_sync(); @@ -1306,7 +1306,7 @@ stash_mut_list (Capability *cap, nat gen_no) static void prepare_uncollected_gen (generation *gen) { - nat i; + uint32_t i; ASSERT(gen->no > 0); @@ -1330,7 +1330,7 @@ prepare_uncollected_gen (generation *gen) static void collect_gct_blocks (void) { - nat g; + uint32_t g; gen_workspace *ws; bdescr *bd, *prev; @@ -1380,7 +1380,7 @@ collect_gct_blocks (void) static void collect_pinned_object_blocks (void) { - nat n; + uint32_t n; bdescr *bd, *prev; for (n = 0; n < n_capabilities; n++) { @@ -1456,7 +1456,7 @@ mark_root(void *user USED_IF_THREADS, StgClosure **root) static void resize_generations (void) { - nat g; + uint32_t g; if (major_gc && RtsFlags.GcFlags.generations > 1) { W_ live, size, min_alloc, words; @@ -1683,7 +1683,7 @@ static void gcCAFs(void) StgIndStatic *p, *prev; const StgInfoTable *info; - nat i; + uint32_t i; i = 0; p = debug_caf_list; diff --git a/rts/sm/GC.h b/rts/sm/GC.h index 2953d9eb0c..c32064a4dd 100644 --- a/rts/sm/GC.h +++ b/rts/sm/GC.h @@ -20,14 +20,14 @@ void GarbageCollect (rtsBool force_major_gc, rtsBool do_heap_census, - nat gc_type, Capability *cap); + uint32_t gc_type, Capability *cap); typedef void (*evac_fn)(void *user, StgClosure **root); StgClosure * isAlive ( StgClosure *p ); void markCAFs ( evac_fn evac, void *user ); -extern nat N; +extern uint32_t N; extern rtsBool major_gc; extern bdescr *mark_stack_bd; @@ -37,7 +37,7 @@ extern StgPtr mark_sp; extern rtsBool work_stealing; #ifdef DEBUG -extern nat mutlist_MUTVARS, mutlist_MUTARRS, mutlist_MVARS, mutlist_OTHERS, +extern uint32_t mutlist_MUTVARS, mutlist_MUTARRS, mutlist_MVARS, mutlist_OTHERS, mutlist_TVAR, mutlist_TVAR_WATCH_QUEUE, mutlist_TREC_CHUNK, @@ -51,7 +51,7 @@ extern StgWord64 whitehole_spin; #endif void gcWorkerThread (Capability *cap); -void initGcThreads (nat from, nat to); +void initGcThreads (uint32_t from, uint32_t to); void freeGcThreads (void); #if defined(THREADED_RTS) diff --git a/rts/sm/GCThread.h b/rts/sm/GCThread.h index 1fee7a68e9..b728315554 100644 --- a/rts/sm/GCThread.h +++ b/rts/sm/GCThread.h @@ -87,7 +87,7 @@ typedef struct gen_workspace_ { WSDeque * todo_q; bdescr * todo_overflow; - nat n_todo_overflow; + uint32_t n_todo_overflow; // where large objects to be scavenged go bdescr * todo_large_objects; @@ -126,7 +126,7 @@ typedef struct gc_thread_ { SpinLock mut_spin; volatile StgWord wakeup; // NB not StgWord8; only StgWord is guaranteed atomic #endif - nat thread_index; // a zero based index identifying the thread + uint32_t thread_index; // a zero based index identifying the thread rtsBool idle; // sitting out of this GC cycle bdescr * free_blocks; // a buffer of free blocks for this thread @@ -155,7 +155,7 @@ typedef struct gc_thread_ { // -------------------- // evacuate flags - nat evac_gen_no; // Youngest generation that objects + uint32_t evac_gen_no; // Youngest generation that objects // should be evacuated to in // evacuate(). (Logically an // argument to evacuate, but it's @@ -200,7 +200,7 @@ typedef struct gc_thread_ { } gc_thread; -extern nat n_gc_threads; +extern uint32_t n_gc_threads; extern gc_thread **gc_threads; diff --git a/rts/sm/GCUtils.c b/rts/sm/GCUtils.c index 9ecb674bb3..5edf9dedbc 100644 --- a/rts/sm/GCUtils.c +++ b/rts/sm/GCUtils.c @@ -41,7 +41,7 @@ allocBlock_sync(void) } static bdescr * -allocGroup_sync(nat n) +allocGroup_sync(uint32_t n) { bdescr *bd; ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); @@ -51,11 +51,11 @@ allocGroup_sync(nat n) } -static nat -allocBlocks_sync(nat n, bdescr **hd) +static uint32_t +allocBlocks_sync(uint32_t n, bdescr **hd) { bdescr *bd; - nat i; + uint32_t i; ACQUIRE_SPIN_LOCK(&gc_alloc_block_sync); bd = allocLargeChunk(1,n); // NB. allocLargeChunk, rather than allocGroup(n), to allocate in a @@ -112,9 +112,9 @@ grab_local_todo_block (gen_workspace *ws) #if defined(THREADED_RTS) bdescr * -steal_todo_block (nat g) +steal_todo_block (uint32_t g) { - nat n; + uint32_t n; bdescr *bd; // look for work to steal @@ -191,7 +191,7 @@ push_scanned_block (bdescr *bd, gen_workspace *ws) */ StgPtr -todo_block_full (nat size, gen_workspace *ws) +todo_block_full (uint32_t size, gen_workspace *ws) { rtsBool urgent_to_push, can_extend; StgPtr p; @@ -296,7 +296,7 @@ todo_block_full (nat size, gen_workspace *ws) } StgPtr -alloc_todo_block (gen_workspace *ws, nat size) +alloc_todo_block (gen_workspace *ws, uint32_t size) { bdescr *bd/*, *hd, *tl */; diff --git a/rts/sm/GCUtils.h b/rts/sm/GCUtils.h index e77c98aa22..0f87eee3f1 100644 --- a/rts/sm/GCUtils.h +++ b/rts/sm/GCUtils.h @@ -22,12 +22,12 @@ bdescr *allocBlock_sync(void); void freeChain_sync(bdescr *bd); void push_scanned_block (bdescr *bd, gen_workspace *ws); -StgPtr todo_block_full (nat size, gen_workspace *ws); -StgPtr alloc_todo_block (gen_workspace *ws, nat size); +StgPtr todo_block_full (uint32_t size, gen_workspace *ws); +StgPtr alloc_todo_block (gen_workspace *ws, uint32_t size); bdescr *grab_local_todo_block (gen_workspace *ws); #if defined(THREADED_RTS) -bdescr *steal_todo_block (nat s); +bdescr *steal_todo_block (uint32_t s); #endif // Returns true if a block is partially full. This predicate is used to try @@ -48,7 +48,7 @@ void printMutableList (bdescr *bd); // mutable lists attached to the current gc_thread structure, which // are the same as the mutable lists on the Capability. INLINE_HEADER void -recordMutableGen_GC (StgClosure *p, nat gen_no) +recordMutableGen_GC (StgClosure *p, uint32_t gen_no) { bdescr *bd; diff --git a/rts/sm/HeapAlloc.h b/rts/sm/HeapAlloc.h index 99a62f9023..a867a484ae 100644 --- a/rts/sm/HeapAlloc.h +++ b/rts/sm/HeapAlloc.h @@ -168,7 +168,7 @@ INLINE_HEADER StgBool HEAP_ALLOCED(void *p) { StgWord mblock; - nat entry_no; + uint32_t entry_no; MbcCacheLine entry, value; mblock = (StgWord)p >> MBLOCK_SHIFT; @@ -196,7 +196,7 @@ INLINE_HEADER StgBool HEAP_ALLOCED_GC(void *p) { StgWord mblock; - nat entry_no; + uint32_t entry_no; MbcCacheLine entry, value; StgBool b; diff --git a/rts/sm/MBlock.c b/rts/sm/MBlock.c index 2131ae6e13..11b12d1c16 100644 --- a/rts/sm/MBlock.c +++ b/rts/sm/MBlock.c @@ -50,10 +50,10 @@ W_ mpc_misses = 0; be used in an interation fashion. Pass NULL if @state is not interesting,or pass a pointer to NULL if you don't have a state. - void *getCommittedMBlocks(nat n) + void *getCommittedMBlocks(uint32_t n) return @n new mblocks, ready to be used (reserved and committed) - void *decommitMBlocks(char *addr, nat n) + void *decommitMBlocks(char *addr, uint32_t n) release memory for @n mblocks, starting at the given address void releaseFreeMemory() @@ -152,7 +152,7 @@ void * getNextMBlock(void **state STG_UNUSED, void *mblock) return getAllocatedMBlock(casted_state, (W_)mblock + MBLOCK_SIZE); } -static void *getReusableMBlocks(nat n) +static void *getReusableMBlocks(uint32_t n) { struct free_list *iter; W_ size = MBLOCK_SIZE * (W_)n; @@ -190,7 +190,7 @@ static void *getReusableMBlocks(nat n) return NULL; } -static void *getFreshMBlocks(nat n) +static void *getFreshMBlocks(uint32_t n) { W_ size = MBLOCK_SIZE * (W_)n; void *addr = (void*)mblock_high_watermark; @@ -207,7 +207,7 @@ static void *getFreshMBlocks(nat n) return addr; } -static void *getCommittedMBlocks(nat n) +static void *getCommittedMBlocks(uint32_t n) { void *p; @@ -220,7 +220,7 @@ static void *getCommittedMBlocks(nat n) return p; } -static void decommitMBlocks(char *addr, nat n) +static void decommitMBlocks(char *addr, uint32_t n) { struct free_list *iter, *prev; W_ size = MBLOCK_SIZE * (W_)n; @@ -354,14 +354,14 @@ setHeapAlloced(void *p, StgWord8 i) MBlockMap **mblock_maps = NULL; -nat mblock_map_count = 0; +uint32_t mblock_map_count = 0; MbcCacheLine mblock_cache[MBC_ENTRIES]; static MBlockMap * findMBlockMap(void *p) { - nat i; + uint32_t i; StgWord32 hi = (StgWord32) (((StgWord)p) >> 32); for( i = 0; i < mblock_map_count; i++ ) { @@ -377,7 +377,7 @@ StgBool HEAP_ALLOCED_miss(StgWord mblock, void *p) { MBlockMap *map; MBlockMapLine value; - nat entry_no; + uint32_t entry_no; entry_no = mblock & (MBC_ENTRIES-1); @@ -416,7 +416,7 @@ setHeapAlloced(void *p, StgWord8 i) { StgWord mblock; - nat entry_no; + uint32_t entry_no; mblock = (StgWord)p >> MBLOCK_SHIFT; entry_no = mblock & (MBC_ENTRIES-1); @@ -441,14 +441,14 @@ markHeapUnalloced(void *p) #if SIZEOF_VOID_P == 4 STATIC_INLINE -void * mapEntryToMBlock(nat i) +void * mapEntryToMBlock(uint32_t i) { return (void *)((StgWord)i << MBLOCK_SHIFT); } void * getFirstMBlock(void **state STG_UNUSED) { - nat i; + uint32_t i; for (i = 0; i < MBLOCK_MAP_SIZE; i++) { if (mblock_map[i]) return mapEntryToMBlock(i); @@ -458,7 +458,7 @@ void * getFirstMBlock(void **state STG_UNUSED) void * getNextMBlock(void **state STG_UNUSED, void *mblock) { - nat i; + uint32_t i; for (i = MBLOCK_MAP_ENTRY(mblock) + 1; i < MBLOCK_MAP_SIZE; i++) { if (mblock_map[i]) return mapEntryToMBlock(i); @@ -471,8 +471,8 @@ void * getNextMBlock(void **state STG_UNUSED, void *mblock) void * getNextMBlock(void **state STG_UNUSED, void *p) { MBlockMap *map; - nat off, j; - nat line_no; + uint32_t off, j; + uint32_t line_no; MBlockMapLine line; for (j = 0; j < mblock_map_count; j++) { @@ -508,7 +508,7 @@ void * getNextMBlock(void **state STG_UNUSED, void *p) void * getFirstMBlock(void **state STG_UNUSED) { MBlockMap *map = mblock_maps[0]; - nat line_no, off; + uint32_t line_no, off; MbcCacheLine line; for (line_no = 0; line_no < MBLOCK_MAP_ENTRIES; line_no++) { @@ -528,11 +528,11 @@ void * getFirstMBlock(void **state STG_UNUSED) #endif // SIZEOF_VOID_P == 8 -static void *getCommittedMBlocks(nat n) +static void *getCommittedMBlocks(uint32_t n) { // The OS layer returns committed memory directly void *ret = osGetMBlocks(n); - nat i; + uint32_t i; // fill in the table for (i = 0; i < n; i++) { @@ -542,10 +542,10 @@ static void *getCommittedMBlocks(nat n) return ret; } -static void decommitMBlocks(void *p, nat n) +static void decommitMBlocks(void *p, uint32_t n) { osFreeMBlocks(p, n); - nat i; + uint32_t i; for (i = 0; i < n; i++) { markHeapUnalloced( (StgWord8*)p + i * MBLOCK_SIZE ); @@ -573,7 +573,7 @@ getMBlock(void) // address. void * -getMBlocks(nat n) +getMBlocks(uint32_t n) { void *ret; @@ -588,7 +588,7 @@ getMBlocks(nat n) } void -freeMBlocks(void *addr, nat n) +freeMBlocks(void *addr, uint32_t n) { debugTrace(DEBUG_gc, "freeing %d megablock(s) at %p",n,addr); @@ -622,7 +622,7 @@ freeAllMBlocks(void) osFreeAllMBlocks(); #if SIZEOF_VOID_P == 8 - nat n; + uint32_t n; for (n = 0; n < mblock_map_count; n++) { stgFree(mblock_maps[n]); } diff --git a/rts/sm/MarkWeak.c b/rts/sm/MarkWeak.c index d9f17337d1..c6ab5b161c 100644 --- a/rts/sm/MarkWeak.c +++ b/rts/sm/MarkWeak.c @@ -89,7 +89,7 @@ static void tidyThreadList (generation *gen); void initWeakForGC(void) { - nat g; + uint32_t g; for (g = 0; g <= N; g++) { generation *gen = &generations[g]; @@ -118,7 +118,7 @@ traverseWeakPtrList(void) * become garbage, we wake them up and administer an exception. */ { - nat g; + uint32_t g; for (g = 0; g <= N; g++) { tidyThreadList(&generations[g]); @@ -156,7 +156,7 @@ traverseWeakPtrList(void) case WeakPtrs: { - nat g; + uint32_t g; // resurrecting threads might have made more weak pointers // alive, so traverse those lists again: @@ -365,7 +365,7 @@ static void checkWeakPtrSanity(StgWeak *hd, StgWeak *tl) void collectFreshWeakPtrs() { - nat i; + uint32_t i; generation *gen = &generations[0]; // move recently allocated weak_ptr_list to the old list as well for (i = 0; i < n_capabilities; i++) { @@ -390,7 +390,7 @@ void collectFreshWeakPtrs() void markWeakPtrList ( void ) { - nat g; + uint32_t g; for (g = 0; g <= N; g++) { generation *gen = &generations[g]; diff --git a/rts/sm/OSMem.h b/rts/sm/OSMem.h index 533f6f7fe6..defa0d408c 100644 --- a/rts/sm/OSMem.h +++ b/rts/sm/OSMem.h @@ -12,8 +12,8 @@ #include "BeginPrivate.h" void osMemInit(void); -void *osGetMBlocks(nat n); -void osFreeMBlocks(char *addr, nat n); +void *osGetMBlocks(uint32_t n); +void osFreeMBlocks(char *addr, uint32_t n); void osReleaseFreeMemory(void); void osFreeAllMBlocks(void); W_ getPageSize (void); diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c index 1f4c4923c4..d1ed7db977 100644 --- a/rts/sm/Sanity.c +++ b/rts/sm/Sanity.c @@ -33,19 +33,19 @@ Forward decls. -------------------------------------------------------------------------- */ -static void checkSmallBitmap ( StgPtr payload, StgWord bitmap, nat ); -static void checkLargeBitmap ( StgPtr payload, StgLargeBitmap*, nat ); -static void checkClosureShallow ( StgClosure * ); -static void checkSTACK (StgStack *stack); +static void checkSmallBitmap ( StgPtr payload, StgWord bitmap, uint32_t ); +static void checkLargeBitmap ( StgPtr payload, StgLargeBitmap*, uint32_t ); +static void checkClosureShallow ( StgClosure * ); +static void checkSTACK (StgStack *stack); /* ----------------------------------------------------------------------------- Check stack sanity -------------------------------------------------------------------------- */ static void -checkSmallBitmap( StgPtr payload, StgWord bitmap, nat size ) +checkSmallBitmap( StgPtr payload, StgWord bitmap, uint32_t size ) { - nat i; + uint32_t i; for(i = 0; i < size; i++, bitmap >>= 1 ) { if ((bitmap & 1) == 0) { @@ -55,10 +55,10 @@ checkSmallBitmap( StgPtr payload, StgWord bitmap, nat size ) } static void -checkLargeBitmap( StgPtr payload, StgLargeBitmap* large_bitmap, nat size ) +checkLargeBitmap( StgPtr payload, StgLargeBitmap* large_bitmap, uint32_t size ) { StgWord bmp; - nat i, j; + uint32_t i, j; i = 0; for (bmp=0; i < size; bmp++) { @@ -98,7 +98,7 @@ checkClosureShallow( StgClosure* p ) StgOffset checkStackFrame( StgPtr c ) { - nat size; + uint32_t size; const StgRetInfoTable* info; info = get_ret_itbl((StgClosure *)c); @@ -123,7 +123,7 @@ checkStackFrame( StgPtr c ) case RET_BCO: { StgBCO *bco; - nat size; + uint32_t size; bco = (StgBCO *)*(c+1); size = BCO_BITMAP_SIZE(bco); checkLargeBitmap((StgPtr)c + 2, BCO_BITMAP(bco), size); @@ -257,7 +257,7 @@ checkClosure( StgClosure* p ) case THUNK_0_2: case THUNK_2_0: { - nat i; + uint32_t i; for (i = 0; i < info->layout.payload.ptrs; i++) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(((StgThunk *)p)->payload[i])); } @@ -287,7 +287,7 @@ checkClosure( StgClosure* p ) case THUNK_STATIC: case FUN_STATIC: { - nat i; + uint32_t i; for (i = 0; i < info->layout.payload.ptrs; i++) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(p->payload[i])); } @@ -395,7 +395,7 @@ checkClosure( StgClosure* p ) case MUT_ARR_PTRS_FROZEN0: { StgMutArrPtrs* a = (StgMutArrPtrs *)p; - nat i; + uint32_t i; for (i = 0; i < a->ptrs; i++) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(a->payload[i])); } @@ -412,7 +412,7 @@ checkClosure( StgClosure* p ) case TREC_CHUNK: { - nat i; + uint32_t i; StgTRecChunk *tc = (StgTRecChunk *)p; ASSERT(LOOKS_LIKE_CLOSURE_PTR(tc->prev_chunk)); for (i = 0; i < tc -> next_entry_idx; i ++) { @@ -446,7 +446,7 @@ void checkHeapChain (bdescr *bd) if(!(bd->flags & BF_SWEPT)) { p = bd->start; while (p < bd->free) { - nat size = checkClosure((StgClosure *)p); + uint32_t size = checkClosure((StgClosure *)p); /* This is the smallest size of closure that can live in the heap */ ASSERT( size >= MIN_PAYLOAD_SIZE + sizeofW(StgHeader) ); p += size; @@ -463,7 +463,7 @@ void checkHeapChunk(StgPtr start, StgPtr end) { StgPtr p; - nat size; + uint32_t size; for (p=start; p<end; p+=size) { ASSERT(LOOKS_LIKE_INFO_PTR(*p)); @@ -542,7 +542,7 @@ void checkGlobalTSOList (rtsBool checkTSOs) { StgTSO *tso; - nat g; + uint32_t g; for (g = 0; g < RtsFlags.GcFlags.generations; g++) { for (tso=generations[g].threads; tso != END_TSO_QUEUE; @@ -585,7 +585,7 @@ checkGlobalTSOList (rtsBool checkTSOs) -------------------------------------------------------------------------- */ static void -checkMutableList( bdescr *mut_bd, nat gen ) +checkMutableList( bdescr *mut_bd, uint32_t gen ) { bdescr *bd; StgPtr q; @@ -610,9 +610,9 @@ checkMutableList( bdescr *mut_bd, nat gen ) } static void -checkLocalMutableLists (nat cap_no) +checkLocalMutableLists (uint32_t cap_no) { - nat g; + uint32_t g; for (g = 1; g < RtsFlags.GcFlags.generations; g++) { checkMutableList(capabilities[cap_no]->mut_lists[g], g); } @@ -621,7 +621,7 @@ checkLocalMutableLists (nat cap_no) static void checkMutableLists (void) { - nat i; + uint32_t i; for (i = 0; i < n_capabilities; i++) { checkLocalMutableLists(i); } @@ -675,7 +675,7 @@ void checkNurserySanity (nursery *nursery) { bdescr *bd, *prev; - nat blocks = 0; + uint32_t blocks = 0; prev = NULL; for (bd = nursery->blocks; bd != NULL; bd = bd->link) { @@ -691,7 +691,7 @@ checkNurserySanity (nursery *nursery) static void checkGeneration (generation *gen, rtsBool after_major_gc USED_IF_THREADS) { - nat n; + uint32_t n; gen_workspace *ws; ASSERT(countBlocks(gen->blocks) == gen->n_blocks); @@ -719,7 +719,7 @@ static void checkGeneration (generation *gen, /* Full heap sanity check. */ static void checkFullHeap (rtsBool after_major_gc) { - nat g, n; + uint32_t g, n; for (g = 0; g < RtsFlags.GcFlags.generations; g++) { checkGeneration(&generations[g], after_major_gc); @@ -753,7 +753,7 @@ void checkSanity (rtsBool after_gc, rtsBool major_gc) static void findMemoryLeak (void) { - nat g, i; + uint32_t g, i; for (g = 0; g < RtsFlags.GcFlags.generations; g++) { for (i = 0; i < n_capabilities; i++) { markBlocks(capabilities[i]->mut_lists[g]); @@ -839,7 +839,7 @@ genBlocks (generation *gen) void memInventory (rtsBool show) { - nat g, i; + uint32_t g, i; W_ gen_blocks[RtsFlags.GcFlags.generations]; W_ nursery_blocks, retainer_blocks, arena_blocks, exec_blocks, gc_free_blocks = 0; diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c index 7f64ea6b33..2fbb8f06cc 100644 --- a/rts/sm/Scav.c +++ b/rts/sm/Scav.c @@ -276,11 +276,11 @@ scavenge_AP (StgAP *ap) static void scavenge_large_srt_bitmap( StgLargeSRT *large_srt ) { - nat i, j, size; + uint32_t i, j, size; StgWord bitmap; StgClosure **p; - size = (nat)large_srt->l.size; + size = (uint32_t)large_srt->l.size; p = (StgClosure **)large_srt->srt; for (i = 0; i < size / BITS_IN(W_); i++) { @@ -316,9 +316,9 @@ scavenge_large_srt_bitmap( StgLargeSRT *large_srt ) * never dereference it. */ STATIC_INLINE GNUC_ATTR_HOT void -scavenge_srt (StgClosure **srt, nat srt_bitmap) +scavenge_srt (StgClosure **srt, uint32_t srt_bitmap) { - nat bitmap; + uint32_t bitmap; StgClosure **p; bitmap = srt_bitmap; @@ -359,7 +359,7 @@ STATIC_INLINE GNUC_ATTR_HOT void scavenge_thunk_srt(const StgInfoTable *info) { StgThunkInfoTable *thunk_info; - nat bitmap; + uint32_t bitmap; if (!major_gc) return; @@ -376,7 +376,7 @@ STATIC_INLINE GNUC_ATTR_HOT void scavenge_fun_srt(const StgInfoTable *info) { StgFunInfoTable *fun_info; - nat bitmap; + uint32_t bitmap; if (!major_gc) return; @@ -1559,7 +1559,7 @@ static void scavenge_mutable_list(bdescr *bd, generation *gen) { StgPtr p, q; - nat gen_no; + uint32_t gen_no; gen_no = gen->no; gct->evac_gen_no = gen_no; @@ -1650,7 +1650,7 @@ scavenge_mutable_list(bdescr *bd, generation *gen) void scavenge_capability_mut_lists (Capability *cap) { - nat g; + uint32_t g; /* Mutable lists from each generation > N * we want to *scavenge* these roots, not evacuate them: they're not @@ -1765,7 +1765,7 @@ scavenge_static(void) static void scavenge_large_bitmap( StgPtr p, StgLargeBitmap *large_bitmap, StgWord size ) { - nat i, j, b; + uint32_t i, j, b; StgWord bitmap; b = 0; diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index 3e421a6e9b..b50594193c 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -55,7 +55,7 @@ generation *g0 = NULL; /* generation 0, for convenience */ generation *oldest_gen = NULL; /* oldest generation, for convenience */ nursery *nurseries = NULL; /* array of nurseries, size == n_capabilities */ -nat n_nurseries; +uint32_t n_nurseries; volatile StgWord next_nursery = 0; #ifdef THREADED_RTS @@ -66,8 +66,8 @@ volatile StgWord next_nursery = 0; Mutex sm_mutex; #endif -static void allocNurseries (nat from, nat to); -static void assignNurseriesToCapabilities (nat from, nat to); +static void allocNurseries (uint32_t from, uint32_t to); +static void assignNurseriesToCapabilities (uint32_t from, uint32_t to); static void initGeneration (generation *gen, int g) @@ -104,7 +104,7 @@ initGeneration (generation *gen, int g) void initStorage (void) { - nat g; + uint32_t g; if (generations != NULL) { // multi-init protection @@ -211,9 +211,9 @@ initStorage (void) BLOCK_SIZE_W * sizeof(W_)); } -void storageAddCapabilities (nat from, nat to) +void storageAddCapabilities (uint32_t from, uint32_t to) { - nat n, g, i, new_n_nurseries; + uint32_t n, g, i, new_n_nurseries; if (RtsFlags.GcFlags.nurseryChunkSize == 0) { new_n_nurseries = to; @@ -577,7 +577,7 @@ allocNursery (bdescr *tail, W_ blocks) } STATIC_INLINE void -assignNurseryToCapability (Capability *cap, nat n) +assignNurseryToCapability (Capability *cap, uint32_t n) { ASSERT(n < n_nurseries); cap->r.rNursery = &nurseries[n]; @@ -591,9 +591,9 @@ assignNurseryToCapability (Capability *cap, nat n) * here, everything must be stopped to call this function. */ static void -assignNurseriesToCapabilities (nat from, nat to) +assignNurseriesToCapabilities (uint32_t from, uint32_t to) { - nat i; + uint32_t i; for (i = from; i < to; i++) { assignNurseryToCapability(capabilities[i], next_nursery++); @@ -601,9 +601,9 @@ assignNurseriesToCapabilities (nat from, nat to) } static void -allocNurseries (nat from, nat to) +allocNurseries (uint32_t from, uint32_t to) { - nat i; + uint32_t i; memcount n_blocks; if (RtsFlags.GcFlags.nurseryChunkSize) { @@ -626,7 +626,7 @@ resetNurseries (void) #ifdef DEBUG bdescr *bd; - nat n; + uint32_t n; for (n = 0; n < n_nurseries; n++) { for (bd = nurseries[n].blocks; bd; bd = bd->link) { ASSERT(bd->gen_no == 0); @@ -640,7 +640,7 @@ resetNurseries (void) W_ countNurseryBlocks (void) { - nat i; + uint32_t i; W_ blocks = 0; for (i = 0; i < n_nurseries; i++) { @@ -695,7 +695,7 @@ resizeNursery (nursery *nursery, W_ blocks) static void resizeNurseriesEach (W_ blocks) { - nat i; + uint32_t i; for (i = 0; i < n_nurseries; i++) { resizeNursery(&nurseries[i], blocks); @@ -705,7 +705,7 @@ resizeNurseriesEach (W_ blocks) void resizeNurseriesFixed (void) { - nat blocks; + uint32_t blocks; if (RtsFlags.GcFlags.nurseryChunkSize) { blocks = RtsFlags.GcFlags.nurseryChunkSize; @@ -1149,7 +1149,7 @@ calcTotalAllocated (void) void updateNurseriesStats (void) { - nat i; + uint32_t i; bdescr *bd; for (i = 0; i < n_capabilities; i++) { @@ -1184,7 +1184,7 @@ W_ genLiveBlocks (generation *gen) return gen->n_blocks + gen->n_large_blocks; } -W_ gcThreadLiveWords (nat i, nat g) +W_ gcThreadLiveWords (uint32_t i, uint32_t g) { W_ a, b, c; @@ -1196,7 +1196,7 @@ W_ gcThreadLiveWords (nat i, nat g) return a + b + c; } -W_ gcThreadLiveBlocks (nat i, nat g) +W_ gcThreadLiveBlocks (uint32_t i, uint32_t g) { W_ blocks; @@ -1221,7 +1221,7 @@ extern W_ calcNeeded (rtsBool force_major, memcount *blocks_needed) { W_ needed = 0, blocks; - nat g, N; + uint32_t g, N; generation *gen; if (force_major) { diff --git a/rts/sm/Storage.h b/rts/sm/Storage.h index 6c6daab44d..2bd1a35176 100644 --- a/rts/sm/Storage.h +++ b/rts/sm/Storage.h @@ -23,7 +23,7 @@ void freeStorage(rtsBool free_heap); // Adding more Capabilities later: this function allocates nurseries // and initialises other storage-related things. -void storageAddCapabilities (nat from, nat to); +void storageAddCapabilities (uint32_t from, uint32_t to); /* ----------------------------------------------------------------------------- Should we GC? @@ -66,7 +66,7 @@ void dirty_TVAR(Capability *cap, StgTVar *p); -------------------------------------------------------------------------- */ extern nursery *nurseries; -extern nat n_nurseries; +extern uint32_t n_nurseries; void resetNurseries (void); void clearNursery (Capability *cap); @@ -104,8 +104,8 @@ StgWord countLargeAllocated (void); StgWord countOccupied (bdescr *bd); StgWord calcNeeded (rtsBool force_major, StgWord *blocks_needed); -StgWord gcThreadLiveWords (nat i, nat g); -StgWord gcThreadLiveBlocks (nat i, nat g); +StgWord gcThreadLiveWords (uint32_t i, uint32_t g); +StgWord gcThreadLiveBlocks (uint32_t i, uint32_t g); StgWord genLiveWords (generation *gen); StgWord genLiveBlocks (generation *gen); @@ -153,7 +153,7 @@ void move_STACK (StgStack *src, StgStack *dest); // The previous and current values of the static flag. These flip // between STATIC_FLAG_A and STATIC_FLAG_B at each major GC. -extern nat prev_static_flag, static_flag; +extern uint32_t prev_static_flag, static_flag; // In the chain of static objects built up during GC, all the link // fields are tagged with the current static_flag value. How to mark diff --git a/rts/sm/Sweep.c b/rts/sm/Sweep.c index c927f300d7..2cf8399a3b 100644 --- a/rts/sm/Sweep.c +++ b/rts/sm/Sweep.c @@ -22,7 +22,7 @@ void sweep(generation *gen) { bdescr *bd, *prev, *next; - nat i; + uint32_t i; W_ freed, resid, fragd, blocks, live; ASSERT(countBlocks(gen->old_blocks) == gen->n_old_blocks); diff --git a/rts/win32/AwaitEvent.c b/rts/win32/AwaitEvent.c index feae4c86ed..51581025e1 100644 --- a/rts/win32/AwaitEvent.c +++ b/rts/win32/AwaitEvent.c @@ -22,7 +22,7 @@ // Used to avoid calling abandonRequestWait() if we don't need to. // Protected by sched_mutex. -static nat workerWaitingForRequests = 0; +static uint32_t workerWaitingForRequests = 0; void awaitEvent(rtsBool wait) diff --git a/rts/win32/OSMem.c b/rts/win32/OSMem.c index 0009a4ec9d..65791b69d1 100644 --- a/rts/win32/OSMem.c +++ b/rts/win32/OSMem.c @@ -48,7 +48,7 @@ osMemInit(void) static alloc_rec* -allocNew(nat n) { +allocNew(uint32_t n) { alloc_rec* rec; rec = (alloc_rec*)stgMallocBytes(sizeof(alloc_rec),"getMBlocks: allocNew"); rec->size = ((W_)n+1)*MBLOCK_SIZE; @@ -117,7 +117,7 @@ insertFree(char* alloc_base, W_ alloc_size) { static void* -findFreeBlocks(nat n) { +findFreeBlocks(uint32_t n) { void* ret=0; block_rec* it; block_rec temp; @@ -186,7 +186,7 @@ commitBlocks(char* base, W_ size) { } void * -osGetMBlocks(nat n) { +osGetMBlocks(uint32_t n) { void* ret; ret = findFreeBlocks(n); if(ret==0) { @@ -246,7 +246,7 @@ static void decommitBlocks(char *addr, W_ nBytes) } } -void osFreeMBlocks(char *addr, nat n) +void osFreeMBlocks(char *addr, uint32_t n) { W_ nBytes = (W_)n * MBLOCK_SIZE; diff --git a/rts/win32/OSThreads.c b/rts/win32/OSThreads.c index 0c256127e5..7a51ec5191 100644 --- a/rts/win32/OSThreads.c +++ b/rts/win32/OSThreads.c @@ -242,10 +242,10 @@ forkOS_createThread ( HsStablePtr entry ) (unsigned*)&pId) == 0); } -nat +uint32_t getNumberOfProcessors (void) { - static nat nproc = 0; + static uint32_t nproc = 0; if (nproc == 0) { SYSTEM_INFO si; @@ -257,11 +257,11 @@ getNumberOfProcessors (void) } void -setThreadAffinity (nat n, nat m) // cap N of M +setThreadAffinity (uint32_t n, uint32_t m) // cap N of M { HANDLE hThread; DWORD_PTR mask, r; // 64-bit win is required to handle more than 32 procs - nat nproc, i; + uint32_t nproc, i; hThread = GetCurrentThread(); @@ -308,7 +308,7 @@ forkOS_createThread ( HsStablePtr entry STG_UNUSED ) return -1; } -nat getNumberOfProcessors (void) +uint32_t getNumberOfProcessors (void) { return 1; } diff --git a/rts/win32/ThrIOManager.c b/rts/win32/ThrIOManager.c index 3f50e53817..0fb5912024 100644 --- a/rts/win32/ThrIOManager.c +++ b/rts/win32/ThrIOManager.c @@ -26,7 +26,7 @@ static HANDLE io_manager_event = INVALID_HANDLE_VALUE; #define EVENT_BUFSIZ 256 Mutex event_buf_mutex; StgWord32 event_buf[EVENT_BUFSIZ]; -nat next_event; +uint32_t next_event; #endif diff --git a/testsuite/tests/rts/testblockalloc.c b/testsuite/tests/rts/testblockalloc.c index bde81d31e5..577245f45e 100644 --- a/testsuite/tests/rts/testblockalloc.c +++ b/testsuite/tests/rts/testblockalloc.c @@ -2,7 +2,7 @@ #include <stdio.h> -extern bdescr *allocGroup_lock_lock(nat n); +extern bdescr *allocGroup_lock_lock(uint32_t n); extern void freeGroup_lock(bdescr *p); const int ARRSIZE = 256; diff --git a/testsuite/tests/rts/testheapalloced.c b/testsuite/tests/rts/testheapalloced.c index e827ae2208..a28079572a 100644 --- a/testsuite/tests/rts/testheapalloced.c +++ b/testsuite/tests/rts/testheapalloced.c @@ -12,7 +12,7 @@ extern void *getNextMBlock(void *mblock); #include <stdio.h> #include <string.h> -extern bdescr *allocGroup_lock_lock(nat n); +extern bdescr *allocGroup_lock_lock(uint32_t n); extern void freeGroup_lock(bdescr *p); const int ARRSIZE = 2000; diff --git a/testsuite/tests/rts/testmblockalloc.c b/testsuite/tests/rts/testmblockalloc.c index cbfd050342..f464be9e3d 100644 --- a/testsuite/tests/rts/testmblockalloc.c +++ b/testsuite/tests/rts/testmblockalloc.c @@ -16,7 +16,7 @@ int main (int argc, char *argv[]) int i, j, b; void *a[ARRSIZE]; - nat sizes[ARRSIZE]; + uint32_t sizes[ARRSIZE]; srand(SEED); diff --git a/testsuite/tests/rts/testwsdeque.c b/testsuite/tests/rts/testwsdeque.c index e6f644c5de..3f17f321cd 100644 --- a/testsuite/tests/rts/testwsdeque.c +++ b/testsuite/tests/rts/testwsdeque.c @@ -31,7 +31,7 @@ StgWord last_v[THREADS][BUF]; #define CASTOP(addr,old,new) ((old) == cas(((StgPtr)addr),(old),(new))) void * -myStealWSDeque_ (WSDeque *q, nat n) +myStealWSDeque_ (WSDeque *q, uint32_t n) { void * stolen; StgWord b,t; @@ -75,7 +75,7 @@ myStealWSDeque_ (WSDeque *q, nat n) } void * -myStealWSDeque (WSDeque *q, nat n) +myStealWSDeque (WSDeque *q, uint32_t n) { void *stolen; @@ -88,8 +88,8 @@ myStealWSDeque (WSDeque *q, nat n) void dump(void) { - nat n; - nat i; + uint32_t n; + uint32_t i; for (n = 0; n < THREADS; n++) { debugBelch("\nthread %d:\n", n); for (i = bufs[n]; i >= stg_max(bufs[n]-20,0); i--) { @@ -102,7 +102,7 @@ void dump(void) // ----------------------------------------------------------------------------- -void work(void *p, nat n) +void work(void *p, uint32_t n) { StgWord val; @@ -120,7 +120,7 @@ void OSThreadProcAttr thief(void *info) { void *p; StgWord n; - nat count = 0; + uint32_t count = 0; n = (StgWord)info; @@ -138,7 +138,7 @@ void OSThreadProcAttr thief(void *info) int main(int argc, char*argv[]) { int n; - nat count = 0; + uint32_t count = 0; void *p; q = newWSDeque(1024); |