diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-06-26 19:58:43 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-06-26 19:58:43 +0300 |
commit | b53b7b0413d4898b9bd73cd30e8d433b8893a66d (patch) | |
tree | 984fba281456d62f0803ab9b726a448ad7fba6d9 /src/nxt_mp.c | |
parent | 9399a04121c054433ba3247523487d94ba9db2ba (diff) | |
download | unit-b53b7b0413d4898b9bd73cd30e8d433b8893a66d.tar.gz unit-b53b7b0413d4898b9bd73cd30e8d433b8893a66d.tar.bz2 |
Build on Solaris 11 fixed.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_mp.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/nxt_mp.c b/src/nxt_mp.c index 5a7308cd..f1ddd86b 100644 --- a/src/nxt_mp.c +++ b/src/nxt_mp.c @@ -113,7 +113,7 @@ struct nxt_mp_s { nxt_queue_t free_pages; nxt_queue_t nget_pages; nxt_queue_t get_pages; - nxt_queue_t chunk_pages[0]; + nxt_queue_t chunk_pages[]; }; @@ -151,6 +151,41 @@ static const char *nxt_mp_chunk_free(nxt_mp_t *mp, nxt_mp_block_t *cluster, u_char *p); +#if (NXT_HAVE_BUILTIN_CLZ) + +#define nxt_lg2(value) \ + (31 - __builtin_clz(value)) + +#else + +static const int nxt_lg2_tab64[64] = { + 63, 0, 58, 1, 59, 47, 53, 2, + 60, 39, 48, 27, 54, 33, 42, 3, + 61, 51, 37, 40, 49, 18, 28, 20, + 55, 30, 34, 11, 43, 14, 22, 4, + 62, 57, 46, 52, 38, 26, 32, 41, + 50, 36, 17, 19, 29, 10, 13, 21, + 56, 45, 25, 31, 35, 16, 9, 12, + 44, 24, 15, 8, 23, 7, 6, 5 +}; + +static const uint64_t nxt_lg2_magic = 0x07EDD5E59A4E28C2ULL; + +static int +nxt_lg2(uint64_t v) +{ + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v |= v >> 32; + return nxt_lg2_tab64[ ((v - (v >> 1)) * nxt_lg2_magic) >> 58 ]; +} + +#endif + + nxt_mp_t * nxt_mp_create(size_t cluster_size, size_t page_alignment, size_t page_size, size_t min_chunk_size) |