diff options
author | Igor Sysoev <igor@sysoev.ru> | 2007-01-11 21:58:40 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2007-01-11 21:58:40 +0300 |
commit | 7431938b90a79d44e7ee97860862c7d354d89fd7 (patch) | |
tree | 92c949cf6a2b58d85df38d21df33850df7caeda0 /src/core/ngx_slab.c | |
parent | 7fe33a9f589b579700a07727c75b75bc9e294884 (diff) |
fix slab allocator on 64-bit platfroms
Diffstat (limited to 'src/core/ngx_slab.c')
-rw-r--r-- | src/core/ngx_slab.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core/ngx_slab.c b/src/core/ngx_slab.c index b09d2e44b..c38d0f3ab 100644 --- a/src/core/ngx_slab.c +++ b/src/core/ngx_slab.c @@ -128,7 +128,7 @@ ngx_slab_init(ngx_slab_pool_t *pool) pool->pages->prev = (uintptr_t) &pool->free; pool->start = (u_char *) - ngx_align((uintptr_t) p + pages * sizeof(ngx_slab_page_t), + ngx_align_ptr((uintptr_t) p + pages * sizeof(ngx_slab_page_t), ngx_pagesize); m = pages - (pool->end - pool->start) / ngx_pagesize; @@ -295,7 +295,7 @@ ngx_slab_alloc_locked(ngx_slab_pool_t *pool, size_t size) n = ngx_pagesize_shift - (page->slab & NGX_SLAB_SHIFT_MASK); n = 1 << n; - n = (1 << n) - 1; + n = ((uintptr_t) 1 << n) - 1; mask = n << NGX_SLAB_MAP_SHIFT; do { @@ -450,7 +450,7 @@ ngx_slab_free_locked(ngx_slab_pool_t *pool, void *p) } n = ((uintptr_t) p & (ngx_pagesize - 1)) >> shift; - m = 1 << (n & (sizeof(uintptr_t) * 8 - 1)); + m = (uintptr_t) 1 << (n & (sizeof(uintptr_t) * 8 - 1)); n /= (sizeof(uintptr_t) * 8); bitmap = (uintptr_t *) ((uintptr_t) p & ~(ngx_pagesize - 1)); @@ -476,7 +476,7 @@ ngx_slab_free_locked(ngx_slab_pool_t *pool, void *p) n = 1; } - if (bitmap[0] & ~((1 << n) - 1)) { + if (bitmap[0] & ~(((uintptr_t) 1 << n) - 1)) { goto done; } @@ -497,7 +497,8 @@ ngx_slab_free_locked(ngx_slab_pool_t *pool, void *p) case NGX_SLAB_EXACT: - m = 1 << (((uintptr_t) p & (ngx_pagesize - 1)) >> ngx_slab_exact_shift); + m = (uintptr_t) 1 << + (((uintptr_t) p & (ngx_pagesize - 1)) >> ngx_slab_exact_shift); size = ngx_slab_exact_size; if ((uintptr_t) p & (size - 1)) { @@ -539,8 +540,8 @@ ngx_slab_free_locked(ngx_slab_pool_t *pool, void *p) goto wrong_chunk; } - m = 1 << ((((uintptr_t) p & (ngx_pagesize - 1)) >> shift) - + NGX_SLAB_MAP_SHIFT); + m = (uintptr_t) 1 << ((((uintptr_t) p & (ngx_pagesize - 1)) >> shift) + + NGX_SLAB_MAP_SHIFT); if (slab & m) { |