Bug 1365460 - Remove warning exceptions for MSVC and work around them. r?njn
--- a/memory/mozjemalloc/mozjemalloc.cpp
+++ b/memory/mozjemalloc/mozjemalloc.cpp
@@ -150,18 +150,16 @@
/* Some defines from the CRT internal headers that we need here. */
#define _CRT_SPINCOUNT 5000
#include <io.h>
#include <windows.h>
#include <intrin.h>
#include <algorithm>
-#pragma warning( disable: 4267 4996 4146 )
-
#define SIZE_T_MAX SIZE_MAX
#define STDERR_FILENO 2
#ifndef NO_TLS
static unsigned long tlsIndex = 0xffffffff;
#endif
/* use MSVC intrinsics */
@@ -2032,17 +2030,17 @@ malloc_rtree_set(malloc_rtree_t *rtree,
* from upstream jemalloc 3.4.1 to fix Mozilla bug 956501. */
/* Return the offset between a and the nearest aligned address at or below a. */
#define ALIGNMENT_ADDR2OFFSET(a, alignment) \
((size_t)((uintptr_t)(a) & (alignment - 1)))
/* Return the smallest alignment multiple that is >= s. */
#define ALIGNMENT_CEILING(s, alignment) \
- (((s) + (alignment - 1)) & (-(alignment)))
+ (((s) + (alignment - 1)) & (~(alignment - 1)))
static void *
pages_trim(void *addr, size_t alloc_size, size_t leadsize, size_t size)
{
void *ret = (void *)((uintptr_t)addr + leadsize);
MOZ_ASSERT(alloc_size >= leadsize + size);
#ifdef MOZ_MEMORY_WINDOWS
@@ -3598,17 +3596,17 @@ ipalloc(size_t alignment, size_t size)
* 96 | 1100000 | 32
* 144 | 10100000 | 32
* 192 | 11000000 | 64
*
* Depending on runtime settings, it is possible that arena_malloc()
* will further round up to a power of two, but that never causes
* correctness issues.
*/
- ceil_size = (size + (alignment - 1)) & (-alignment);
+ ceil_size = ALIGNMENT_CEILING(size, alignment);
/*
* (ceil_size < size) protects against the combination of maximal
* alignment and size greater than maximal alignment.
*/
if (ceil_size < size) {
/* size_t overflow. */
return (NULL);
}