Commit db9de7eb authored by Erik de Castro Lopo's avatar Erik de Castro Lopo

rts: Replace `nat` with `uint32_t`

The `nat` type was an alias for `unsigned int` with a comment saying
it was at least 32 bits. We keep the typedef in case client code is
using it but mark it as deprecated.

Test Plan: Validated on Linux, OS X and Windows

Reviewers: simonmar, austin, thomie, hvr, bgamari, hsyl20

Differential Revision: https://phabricator.haskell.org/D2166
parent ad4392c1
...@@ -27,30 +27,30 @@ ...@@ -27,30 +27,30 @@
/* See Note [Synchronization of flags and base APIs] */ /* See Note [Synchronization of flags and base APIs] */
typedef struct _GC_FLAGS { typedef struct _GC_FLAGS {
FILE *statsFile; FILE *statsFile;
nat giveStats; uint32_t giveStats;
#define NO_GC_STATS 0 #define NO_GC_STATS 0
#define COLLECT_GC_STATS 1 #define COLLECT_GC_STATS 1
#define ONELINE_GC_STATS 2 #define ONELINE_GC_STATS 2
#define SUMMARY_GC_STATS 3 #define SUMMARY_GC_STATS 3
#define VERBOSE_GC_STATS 4 #define VERBOSE_GC_STATS 4
nat maxStkSize; /* in *words* */ uint32_t maxStkSize; /* in *words* */
nat initialStkSize; /* in *words* */ uint32_t initialStkSize; /* in *words* */
nat stkChunkSize; /* in *words* */ uint32_t stkChunkSize; /* in *words* */
nat stkChunkBufferSize; /* in *words* */ uint32_t stkChunkBufferSize; /* in *words* */
nat maxHeapSize; /* in *blocks* */ uint32_t maxHeapSize; /* in *blocks* */
nat minAllocAreaSize; /* in *blocks* */ uint32_t minAllocAreaSize; /* in *blocks* */
nat largeAllocLim; /* in *blocks* */ uint32_t largeAllocLim; /* in *blocks* */
nat nurseryChunkSize; /* in *blocks* */ uint32_t nurseryChunkSize; /* in *blocks* */
nat minOldGenSize; /* in *blocks* */ uint32_t minOldGenSize; /* in *blocks* */
nat heapSizeSuggestion; /* in *blocks* */ uint32_t heapSizeSuggestion; /* in *blocks* */
rtsBool heapSizeSuggestionAuto; rtsBool heapSizeSuggestionAuto;
double oldGenFactor; double oldGenFactor;
double pcFreeHeap; double pcFreeHeap;
nat generations; uint32_t generations;
nat steps; uint32_t steps;
rtsBool squeezeUpdFrames; rtsBool squeezeUpdFrames;
rtsBool compact; /* True <=> "compact all the time" */ rtsBool compact; /* True <=> "compact all the time" */
...@@ -97,7 +97,7 @@ typedef struct _DEBUG_FLAGS { ...@@ -97,7 +97,7 @@ typedef struct _DEBUG_FLAGS {
/* See Note [Synchronization of flags and base APIs] */ /* See Note [Synchronization of flags and base APIs] */
typedef struct _COST_CENTRE_FLAGS { typedef struct _COST_CENTRE_FLAGS {
nat doCostCentres; uint32_t doCostCentres;
# define COST_CENTRES_NONE 0 # define COST_CENTRES_NONE 0
# define COST_CENTRES_SUMMARY 1 # define COST_CENTRES_SUMMARY 1
# define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */ # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
...@@ -110,7 +110,7 @@ typedef struct _COST_CENTRE_FLAGS { ...@@ -110,7 +110,7 @@ typedef struct _COST_CENTRE_FLAGS {
/* See Note [Synchronization of flags and base APIs] */ /* See Note [Synchronization of flags and base APIs] */
typedef struct _PROFILING_FLAGS { typedef struct _PROFILING_FLAGS {
nat doHeapProfile; uint32_t doHeapProfile;
# define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */ # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
# define HEAP_BY_CCS 1 # define HEAP_BY_CCS 1
# define HEAP_BY_MOD 2 # define HEAP_BY_MOD 2
...@@ -121,16 +121,16 @@ typedef struct _PROFILING_FLAGS { ...@@ -121,16 +121,16 @@ typedef struct _PROFILING_FLAGS {
# define HEAP_BY_CLOSURE_TYPE 8 # define HEAP_BY_CLOSURE_TYPE 8
Time heapProfileInterval; /* time between samples */ Time heapProfileInterval; /* time between samples */
nat heapProfileIntervalTicks; /* ticks between samples (derived) */ uint32_t heapProfileIntervalTicks; /* ticks between samples (derived) */
rtsBool includeTSOs; rtsBool includeTSOs;
rtsBool showCCSOnException; rtsBool showCCSOnException;
nat maxRetainerSetSize; uint32_t maxRetainerSetSize;
nat ccsLength; uint32_t ccsLength;
const char* modSelector; const char* modSelector;
const char* descrSelector; const char* descrSelector;
...@@ -184,27 +184,27 @@ typedef struct _MISC_FLAGS { ...@@ -184,27 +184,27 @@ typedef struct _MISC_FLAGS {
#ifdef THREADED_RTS #ifdef THREADED_RTS
/* See Note [Synchronization of flags and base APIs] */ /* See Note [Synchronization of flags and base APIs] */
typedef struct _PAR_FLAGS { 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 */ rtsBool migrate; /* migrate threads between capabilities */
nat maxLocalSparks; uint32_t maxLocalSparks;
rtsBool parGcEnabled; /* enable parallel GC */ 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 */ * and higher only */
rtsBool parGcLoadBalancingEnabled; rtsBool parGcLoadBalancingEnabled;
/* enable load-balancing in the /* enable load-balancing in the
* parallel GC */ * parallel GC */
nat parGcLoadBalancingGen; uint32_t parGcLoadBalancingGen;
/* do load-balancing in this /* do load-balancing in this
* generation and higher only */ * generation and higher only */
nat parGcNoSyncWithIdle; uint32_t parGcNoSyncWithIdle;
/* if a Capability has been idle for /* if a Capability has been idle for
* this many GCs, do not try to wake * this many GCs, do not try to wake
* it up when doing a * it up when doing a
* non-load-balancing parallel GC. * non-load-balancing parallel GC.
* (zero disables) */ * (zero disables) */
nat parGcThreads; uint32_t parGcThreads;
/* Use this many threads for parallel /* Use this many threads for parallel
* GC (default: use all nNodes). */ * GC (default: use all nNodes). */
...@@ -249,7 +249,7 @@ extern RTS_FLAGS RtsFlags; ...@@ -249,7 +249,7 @@ extern RTS_FLAGS RtsFlags;
/* /*
* The printf formats are here, so we are less likely to make * The printf formats are here, so we are less likely to make
* overly-long filenames (with disastrous results). No more than 128 * overly-long filenames (with disastrous results). No more than 128
* chars, please! * chars, please!
*/ */
#define STATS_FILENAME_MAXLEN 128 #define STATS_FILENAME_MAXLEN 128
......
...@@ -26,7 +26,7 @@ void sendIOManagerEvent (HsWord32 event); ...@@ -26,7 +26,7 @@ void sendIOManagerEvent (HsWord32 event);
#else #else
void setIOManagerControlFd (nat cap_no, int fd); void setIOManagerControlFd (uint32_t cap_no, int fd);
void setTimerManagerControlFd(int fd); void setTimerManagerControlFd(int fd);
void setIOManagerWakeupFd (int fd); void setIOManagerWakeupFd (int fd);
......
...@@ -200,7 +200,7 @@ void setThreadLocalVar (ThreadLocalKey *key, void *value); ...@@ -200,7 +200,7 @@ void setThreadLocalVar (ThreadLocalKey *key, void *value);
void freeThreadLocalKey (ThreadLocalKey *key); void freeThreadLocalKey (ThreadLocalKey *key);
// Processors and affinity // Processors and affinity
void setThreadAffinity (nat n, nat m); void setThreadAffinity (uint32_t n, uint32_t m);
#endif // !CMINUSMINUS #endif // !CMINUSMINUS
#else #else
...@@ -221,7 +221,7 @@ int forkOS_createThread ( HsStablePtr entry ); ...@@ -221,7 +221,7 @@ int forkOS_createThread ( HsStablePtr entry );
// //
// Returns the number of processor cores in the machine // 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. // Support for getting at the kernel thread Id for tracing/profiling.
......
...@@ -42,7 +42,7 @@ typedef StgWord SpinLock; ...@@ -42,7 +42,7 @@ typedef StgWord SpinLock;
INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p) INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p)
{ {
StgWord32 r = 0; StgWord32 r = 0;
nat i; uint32_t i;
do { do {
for (i = 0; i < SPIN_COUNT; i++) { for (i = 0; i < SPIN_COUNT; i++) {
r = cas((StgVolatilePtr)&(p->lock), 1, 0); r = cas((StgVolatilePtr)&(p->lock), 1, 0);
...@@ -75,7 +75,7 @@ INLINE_HEADER void initSpinLock(SpinLock * p) ...@@ -75,7 +75,7 @@ INLINE_HEADER void initSpinLock(SpinLock * p)
INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p) INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p)
{ {
StgWord32 r = 0; StgWord32 r = 0;
nat i; uint32_t i;
do { do {
for (i = 0; i < SPIN_COUNT; i++) { for (i = 0; i < SPIN_COUNT; i++) {
r = cas((StgVolatilePtr)p, 1, 0); r = cas((StgVolatilePtr)p, 1, 0);
......
...@@ -62,7 +62,7 @@ HsBool rtsSupportsBoundThreads (void); ...@@ -62,7 +62,7 @@ HsBool rtsSupportsBoundThreads (void);
extern unsigned int n_capabilities; extern unsigned int n_capabilities;
// The number of Capabilities that are not disabled // The number of Capabilities that are not disabled
extern nat enabled_capabilities; extern uint32_t enabled_capabilities;
#if !IN_STG_CODE #if !IN_STG_CODE
extern Capability MainCapability; extern Capability MainCapability;
...@@ -72,6 +72,6 @@ extern Capability MainCapability; ...@@ -72,6 +72,6 @@ extern Capability MainCapability;
// Change the number of capabilities (only supports increasing the // Change the number of capabilities (only supports increasing the
// current value at the moment). // current value at the moment).
// //
extern void setNumCapabilities (nat new_); extern void setNumCapabilities (uint32_t new_);
#endif /* RTS_THREADS_H */ #endif /* RTS_THREADS_H */
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
#include <stddef.h> #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) */ /* ullong (64|128-bit) type: only include if needed (not ANSI) */
#if defined(__GNUC__) #if defined(__GNUC__)
......
...@@ -113,7 +113,7 @@ typedef struct IndexTable_ { ...@@ -113,7 +113,7 @@ typedef struct IndexTable_ {
CostCentre *cc; CostCentre *cc;
CostCentreStack *ccs; CostCentreStack *ccs;
struct IndexTable_ *next; struct IndexTable_ *next;
nat back_edge; uint32_t back_edge;
} IndexTable; } IndexTable;
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
* own and treat it as an immovable object during GC, expressed as a * own and treat it as an immovable object during GC, expressed as a
* fraction of BLOCK_SIZE. * 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] * Note [integer overflow]
...@@ -295,7 +295,7 @@ void freeChain(bdescr *p); ...@@ -295,7 +295,7 @@ void freeChain(bdescr *p);
void freeGroup_lock(bdescr *p); void freeGroup_lock(bdescr *p);
void freeChain_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 --------------------------------------------- */ /* Round a value to megablocks --------------------------------------------- */
......
...@@ -256,20 +256,20 @@ INLINE_HEADER rtsBool LOOKS_LIKE_CLOSURE_PTR (void *p) ...@@ -256,20 +256,20 @@ INLINE_HEADER rtsBool LOOKS_LIKE_CLOSURE_PTR (void *p)
Macros for calculating the size of a closure Macros for calculating the size of a closure
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
EXTERN_INLINE StgOffset PAP_sizeW ( nat n_args ); EXTERN_INLINE StgOffset PAP_sizeW ( uint32_t n_args );
EXTERN_INLINE StgOffset PAP_sizeW ( nat n_args ) EXTERN_INLINE StgOffset PAP_sizeW ( uint32_t n_args )
{ return sizeofW(StgPAP) + n_args; } { return sizeofW(StgPAP) + n_args; }
EXTERN_INLINE StgOffset AP_sizeW ( nat n_args ); EXTERN_INLINE StgOffset AP_sizeW ( uint32_t n_args );
EXTERN_INLINE StgOffset AP_sizeW ( nat n_args ) EXTERN_INLINE StgOffset AP_sizeW ( uint32_t n_args )
{ return sizeofW(StgAP) + n_args; } { return sizeofW(StgAP) + n_args; }
EXTERN_INLINE StgOffset AP_STACK_sizeW ( nat size ); EXTERN_INLINE StgOffset AP_STACK_sizeW ( uint32_t size );
EXTERN_INLINE StgOffset AP_STACK_sizeW ( nat size ) EXTERN_INLINE StgOffset AP_STACK_sizeW ( uint32_t size )
{ return sizeofW(StgAP_STACK) + size; } { return sizeofW(StgAP_STACK) + size; }
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( nat p, nat np ) EXTERN_INLINE StgOffset CONSTR_sizeW( uint32_t p, uint32_t np )
{ return sizeofW(StgHeader) + p + np; } { return sizeofW(StgHeader) + p + np; }
EXTERN_INLINE StgOffset THUNK_SELECTOR_sizeW ( void ); EXTERN_INLINE StgOffset THUNK_SELECTOR_sizeW ( void );
...@@ -333,12 +333,12 @@ EXTERN_INLINE StgWord bco_sizeW ( StgBCO *bco ) ...@@ -333,12 +333,12 @@ EXTERN_INLINE StgWord bco_sizeW ( StgBCO *bco )
{ return bco->size; } { 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) * (Also for 'closure_sizeW' below)
*/ */
EXTERN_INLINE nat closure_sizeW_ (StgClosure *p, StgInfoTable *info); EXTERN_INLINE uint32_t closure_sizeW_ (StgClosure *p, StgInfoTable *info);
EXTERN_INLINE nat EXTERN_INLINE uint32_t
closure_sizeW_ (StgClosure *p, StgInfoTable *info) closure_sizeW_ (StgClosure *p, StgInfoTable *info)
{ {
switch (info->type) { switch (info->type) {
...@@ -399,8 +399,8 @@ closure_sizeW_ (StgClosure *p, StgInfoTable *info) ...@@ -399,8 +399,8 @@ closure_sizeW_ (StgClosure *p, StgInfoTable *info)
} }
// The definitive way to find the size, in words, of a heap-allocated closure // The definitive way to find the size, in words, of a heap-allocated closure
EXTERN_INLINE nat closure_sizeW (StgClosure *p); EXTERN_INLINE uint32_t closure_sizeW (StgClosure *p);
EXTERN_INLINE nat closure_sizeW (StgClosure *p) EXTERN_INLINE uint32_t closure_sizeW (StgClosure *p)
{ {
return closure_sizeW_(p, get_itbl(p)); return closure_sizeW_(p, get_itbl(p));
} }
...@@ -505,13 +505,13 @@ INLINE_HEADER StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, W_ n) ...@@ -505,13 +505,13 @@ INLINE_HEADER StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, W_ n)
#endif #endif
#ifdef PROFILING #ifdef PROFILING
void LDV_recordDead (StgClosure *c, nat size); void LDV_recordDead (StgClosure *c, uint32_t size);
#endif #endif
EXTERN_INLINE void overwritingClosure (StgClosure *p); EXTERN_INLINE void overwritingClosure (StgClosure *p);
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 #if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
// see Note [zeroing slop], also #8402 // see Note [zeroing slop], also #8402
...@@ -537,10 +537,10 @@ EXTERN_INLINE void overwritingClosure (StgClosure *p) ...@@ -537,10 +537,10 @@ EXTERN_INLINE void overwritingClosure (StgClosure *p)
// //
// Note: As this calls LDV_recordDead() you have to call LDV_RECORD() // Note: As this calls LDV_recordDead() you have to call LDV_RECORD()
// on the final state of the closure at the call-site // 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, uint32_t offset);
EXTERN_INLINE void overwritingClosureOfs (StgClosure *p, nat 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 #if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
// see Note [zeroing slop], also #8402 // see Note [zeroing slop], also #8402
......
...@@ -88,7 +88,7 @@ typedef struct nursery_ { ...@@ -88,7 +88,7 @@ typedef struct nursery_ {
// memory allocation is tracked. // memory allocation is tracked.
typedef struct generation_ { typedef struct generation_ {
nat no; // generation number uint32_t no; // generation number
bdescr * blocks; // blocks in this gen bdescr * blocks; // blocks in this gen
memcount n_blocks; // number of blocks memcount n_blocks; // number of blocks
...@@ -109,9 +109,9 @@ typedef struct generation_ { ...@@ -109,9 +109,9 @@ typedef struct generation_ {
struct generation_ *to; // destination gen for live objects struct generation_ *to; // destination gen for live objects
// stats information // stats information
nat collections; uint32_t collections;
nat par_collections; uint32_t par_collections;
nat failed_promotions; uint32_t failed_promotions;
// ------------------------------------ // ------------------------------------
// Fields below are used during GC only // Fields below are used during GC only
......
...@@ -17,8 +17,8 @@ extern W_ mblocks_allocated; ...@@ -17,8 +17,8 @@ extern W_ mblocks_allocated;
extern void initMBlocks(void); extern void initMBlocks(void);
extern void * getMBlock(void); extern void * getMBlock(void);
extern void * getMBlocks(nat n); extern void * getMBlocks(uint32_t n);
extern void freeMBlocks(void *addr, nat n); extern void freeMBlocks(void *addr, uint32_t n);
extern void releaseFreeMemory(void); extern void releaseFreeMemory(void);
extern void freeAllMBlocks(void); extern void freeAllMBlocks(void);
......
...@@ -51,7 +51,7 @@ EXTERN_INLINE StgInfoTable *reallyLockClosure(StgClosure *p) ...@@ -51,7 +51,7 @@ EXTERN_INLINE StgInfoTable *reallyLockClosure(StgClosure *p)
{ {
StgWord info; StgWord info;
do { do {
nat i = 0; uint32_t i = 0;
do { do {
info = xchg((P_)(void *)&p->header.info, (W_)&stg_WHITEHOLE_info); info = xchg((P_)(void *)&p->header.info, (W_)&stg_WHITEHOLE_info);
if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info; if (info != (W_)&stg_WHITEHOLE_info) return (StgInfoTable *)info;
......
...@@ -137,7 +137,7 @@ createAdjustor (int cconv, ...@@ -137,7 +137,7 @@ createAdjustor (int cconv,
{ {
ffi_cif *cif; ffi_cif *cif;
ffi_type **arg_types; ffi_type **arg_types;
nat n_args, i; uint32_t n_args, i;
ffi_type *result_type; ffi_type *result_type;
ffi_closure *cl; ffi_closure *cl;
int r, abi; int r, abi;
...@@ -251,7 +251,7 @@ static void * ...@@ -251,7 +251,7 @@ static void *
stgAllocStable(size_t size_in_bytes, StgStablePtr *stable) stgAllocStable(size_t size_in_bytes, StgStablePtr *stable)
{ {
StgArrBytes* arr; 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 */ /* round up to a whole number of words */
data_size_in_words = ROUNDUP_BYTES_TO_WDS(size_in_bytes); data_size_in_words = ROUNDUP_BYTES_TO_WDS(size_in_bytes);
......
...@@ -63,8 +63,8 @@ void * ...@@ -63,8 +63,8 @@ void *
arenaAlloc( Arena *arena, size_t size ) arenaAlloc( Arena *arena, size_t size )
{ {
void *p; void *p;
nat size_w; uint32_t size_w;
nat req_blocks; uint32_t req_blocks;
bdescr *bd; bdescr *bd;
// round up to nearest alignment chunk. // round up to nearest alignment chunk.
......
...@@ -37,8 +37,8 @@ ...@@ -37,8 +37,8 @@
// builds, and for +RTS -N1 // builds, and for +RTS -N1
Capability MainCapability; Capability MainCapability;
nat n_capabilities = 0; uint32_t n_capabilities = 0;
nat enabled_capabilities = 0; uint32_t enabled_capabilities = 0;
// The array of Capabilities. It's important that when we need // The array of Capabilities. It's important that when we need
// to allocate more Capabilities we don't have to move the existing // to allocate more Capabilities we don't have to move the existing
...@@ -90,7 +90,7 @@ findSpark (Capability *cap) ...@@ -90,7 +90,7 @@ findSpark (Capability *cap)
Capability *robbed; Capability *robbed;
StgClosurePtr spark; StgClosurePtr spark;
rtsBool retry; rtsBool retry;
nat i = 0; uint32_t i = 0;
if (!emptyRunQueue(cap) || cap->returning_tasks_hd != NULL) { if (!emptyRunQueue(cap) || cap->returning_tasks_hd != NULL) {
// If there are other threads, don't try to run any new // If there are other threads, don't try to run any new
...@@ -175,7 +175,7 @@ findSpark (Capability *cap) ...@@ -175,7 +175,7 @@ findSpark (Capability *cap)
rtsBool rtsBool
anySparks (void) anySparks (void)
{ {
nat i; uint32_t i;
for (i=0; i < n_capabilities; i++) { for (i=0; i < n_capabilities; i++) {
if (!emptySparkPoolCap(capabilities[i])) { if (!emptySparkPoolCap(capabilities[i])) {
...@@ -230,9 +230,9 @@ popReturningTask (Capability *cap) ...@@ -230,9 +230,9 @@ popReturningTask (Capability *cap)
* ------------------------------------------------------------------------- */ * ------------------------------------------------------------------------- */
static void static void
initCapability( Capability *cap, nat i ) initCapability( Capability *cap, uint32_t i )
{ {
nat g; uint32_t g;
cap->no = i; cap->no = i;
cap->in_haskell = rtsFalse; cap->in_haskell = rtsFalse;
...@@ -356,10 +356,10 @@ initCapabilities( void ) ...@@ -356,10 +356,10 @@ initCapabilities( void )
} }
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) #if defined(THREADED_RTS)
nat i; uint32_t i;
Capability **old_capabilities = capabilities; Capability **old_capabilities = capabilities;
capabilities = stgMallocBytes(to * sizeof(Capability*), "moreCapabilities"); capabilities = stgMallocBytes(to * sizeof(Capability*), "moreCapabilities");
...@@ -399,7 +399,7 @@ moreCapabilities (nat from USED_IF_THREADS, nat to USED_IF_THREADS) ...@@ -399,7 +399,7 @@ moreCapabilities (nat from USED_IF_THREADS, nat to USED_IF_THREADS)
void contextSwitchAllCapabilities(void) void contextSwitchAllCapabilities(void)
{ {
nat i; uint32_t i;
for (i=0; i < n_capabilities; i++) { for (i=0; i < n_capabilities; i++) {
contextSwitchCapability(capabilities[i]); contextSwitchCapability(capabilities[i]);
} }
...@@ -407,7 +407,7 @@ void contextSwitchAllCapabilities(void) ...@@ -407,7 +407,7 @@ void contextSwitchAllCapabilities(void)
void interruptAllCapabilities(void) void interruptAllCapabilities(void)
{ {
nat i; uint32_t i;
for (i=0; i < n_capabilities; i++) { for (i=0; i < n_capabilities; i++) {
interruptCapability(capabilities[i]); interruptCapability(capabilities[i]);
} }
...@@ -721,7 +721,7 @@ void waitForCapability (Capability **pCap, Task *task) ...@@ -721,7 +721,7 @@ void waitForCapability (Capability **pCap, Task *task)
// Try last_free_capability first // Try last_free_capability first
cap = last_free_capability; cap = last_free_capability;
if (cap->running_task) { if (cap->running_task) {
nat i; uint32_t i;
// otherwise, search for a free capability // otherwise, search for a free capability
cap = NULL; cap = NULL;
for (i = 0; i < n_capabilities; i++) { for (i = 0; i < n_capabilities; i++) {
...@@ -960,7 +960,7 @@ shutdownCapability (Capability *cap USED_IF_THREADS, ...@@ -960,7 +960,7 @@ shutdownCapability (Capability *cap USED_IF_THREADS,
rtsBool safe USED_IF_THREADS) rtsBool safe USED_IF_THREADS)
{ {
#if defined(THREADED_RTS) #if defined(THREADED_RTS)
nat i; uint32_t i;
task->cap = cap; task->cap = cap;
...@@ -1057,7 +1057,7 @@ shutdownCapability (Capability *cap USED_IF_THREADS, ...@@ -1057,7 +1057,7 @@ shutdownCapability (Capability *cap USED_IF_THREADS,
void void
shutdownCapabilities(Task *task, rtsBool safe) shutdownCapabilities(Task *task, rtsBool safe)
{ {
nat i; uint32_t i;
for (i=0; i < n_capabilities; i++) { for (i=0; i < n_capabilities; i++) {
ASSERT(task->incall->tso == NULL); ASSERT(task->incall->tso == NULL);
shutdownCapability(capabilities[i], task, safe); shutdownCapability(capabilities[i], task, safe);
...@@ -1084,7 +1084,7 @@ void ...@@ -1084,7 +1084,7 @@ void
freeCapabilities (void) freeCapabilities (void)
{ {
#if defined(THREADED_RTS) #if defined(THREADED_RTS)
nat i; uint32_t i;
for (i=0; i < n_capabilities; i++) { for (i=0; i < n_capabilities; i++) {
freeCapability(capabilities[i]); freeCapability(capabilities[i]);
if (capabilities[i] != &MainCapability) if (capabilities[i] != &MainCapability)
...@@ -1138,7 +1138,7 @@ markCapability (evac_fn evac, void *user, Capability *cap, ...@@ -1138,7 +1138,7 @@ markCapability (evac_fn evac, void *user, Capability *cap,
void void
markCapabilities (evac_fn evac, void *user) markCapabilities (evac_fn evac, void *user)
{ {
nat n; uint32_t n;
for (n = 0; n < n_capabilities; n++) { for (n = 0; n < n_capabilities; n++) {
markCapability(evac, user, capabilities[n], rtsFalse); markCapability(evac, user, capabilities[n], rtsFalse);