Mercurial > hg > nginx
comparison src/core/ngx_slab.c @ 6861:e4590dfd97ff
Win32: support 64-bit compilation with MSVC.
There are lots of C4244 warnings (conversion from 'type1' to 'type2',
possible loss of data), so they were disabled.
The same applies to C4267 warnings (conversion from 'size_t' to 'type',
possible loss of data), most notably - conversion from ngx_str_t.len to
ngx_variable_value_t.len (which is unsigned:28). Additionally, there
is at least one case when it is not possible to fix the warning properly
without introducing win32-specific code: recv() on win32 uses "int len",
while POSIX defines "size_t len".
The ssize_t type now properly defined for 64-bit compilation with MSVC.
Caught by warning C4305 (truncation from '__int64' to 'ssize_t'), on
"cutoff = NGX_MAX_SIZE_T_VALUE / 10" in ngx_atosz()).
Several C4334 warnings (result of 32-bit shift implicitly converted to 64 bits)
were fixed by adding explicit conversions.
Several C4214 warnings (nonstandard extension used: bit field types other
than int) in ngx_http_script.h fixed by changing bit field types from
uintptr_t to unsigned.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 24 Dec 2016 18:01:14 +0300 |
parents | 6eed5ed31e22 |
children | 94f30939545a |
comparison
equal
deleted
inserted
replaced
6860:f18c285c2e59 | 6861:e4590dfd97ff |
---|---|
99 /* void */ | 99 /* void */ |
100 } | 100 } |
101 } | 101 } |
102 /**/ | 102 /**/ |
103 | 103 |
104 pool->min_size = 1 << pool->min_shift; | 104 pool->min_size = (size_t) 1 << pool->min_shift; |
105 | 105 |
106 slots = ngx_slab_slots(pool); | 106 slots = ngx_slab_slots(pool); |
107 | 107 |
108 p = (u_char *) slots; | 108 p = (u_char *) slots; |
109 size = pool->end - p; | 109 size = pool->end - p; |
471 switch (type) { | 471 switch (type) { |
472 | 472 |
473 case NGX_SLAB_SMALL: | 473 case NGX_SLAB_SMALL: |
474 | 474 |
475 shift = slab & NGX_SLAB_SHIFT_MASK; | 475 shift = slab & NGX_SLAB_SHIFT_MASK; |
476 size = 1 << shift; | 476 size = (size_t) 1 << shift; |
477 | 477 |
478 if ((uintptr_t) p & (size - 1)) { | 478 if ((uintptr_t) p & (size - 1)) { |
479 goto wrong_chunk; | 479 goto wrong_chunk; |
480 } | 480 } |
481 | 481 |
566 goto chunk_already_free; | 566 goto chunk_already_free; |
567 | 567 |
568 case NGX_SLAB_BIG: | 568 case NGX_SLAB_BIG: |
569 | 569 |
570 shift = slab & NGX_SLAB_SHIFT_MASK; | 570 shift = slab & NGX_SLAB_SHIFT_MASK; |
571 size = 1 << shift; | 571 size = (size_t) 1 << shift; |
572 | 572 |
573 if ((uintptr_t) p & (size - 1)) { | 573 if ((uintptr_t) p & (size - 1)) { |
574 goto wrong_chunk; | 574 goto wrong_chunk; |
575 } | 575 } |
576 | 576 |