diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-05-02 06:37:14 +1000 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-05-05 08:29:27 +1000 |
commit | db9de7eb3e91820024f673bfdb6fb8064cfed20d (patch) | |
tree | 5e1c3ef0b6dee7f40fedbc118ba36cfe6ffdd1ee /rts/Pool.c | |
parent | ad4392c142696d5092533480a82ed65322e9d413 (diff) | |
download | haskell-db9de7eb3e91820024f673bfdb6fb8064cfed20d.tar.gz |
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
Diffstat (limited to 'rts/Pool.c')
-rw-r--r-- | rts/Pool.c | 22 |
1 files changed, 11 insertions, 11 deletions
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; } |