bug 1237869 - Tweak NSPR to build with Mozilla's build system. r?glandium
Fixes three issues that occur when building using Mozilla's build system instead of NSPR's build system:
1) The top-level configure defines WIN32_LEAN_AND_MEAN which makes a Windows header not get included for ntinrval.c.
2) Visibility issue with __mmap2 on Android in unix.c.
3) Visibility issue with __asan_{poison,unpoison}_memory in plarena.h.
--- a/nsprpub/lib/ds/plarena.h
+++ b/nsprpub/lib/ds/plarena.h
@@ -91,21 +91,21 @@ struct PLArenaPool {
#elif defined(__SANITIZE_ADDRESS__)
#define PL_SANITIZE_ADDRESS 1
#endif
#if defined(PL_SANITIZE_ADDRESS)
/* These definitions are usually provided through the
* sanitizer/asan_interface.h header installed by ASan.
- * See https://code.google.com/p/address-sanitizer/wiki/ManualPoisoning
+ * See https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
*/
-void __asan_poison_memory_region(void const volatile *addr, size_t size);
-void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
+PR_IMPORT(void) __asan_poison_memory_region(void const volatile *addr, size_t size);
+PR_IMPORT(void) __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#define PL_MAKE_MEM_NOACCESS(addr, size) \
__asan_poison_memory_region((addr), (size))
#define PL_MAKE_MEM_UNDEFINED(addr, size) \
__asan_unpoison_memory_region((addr), (size))
#define PL_MAKE_MEM_DEFINED(addr, size) \
--- a/nsprpub/pr/src/md/unix/unix.c
+++ b/nsprpub/pr/src/md/unix/unix.c
@@ -2710,17 +2710,17 @@ static void* _MD_Unix_mmap64(
{
PR_SetError(PR_FILE_TOO_BIG_ERROR, 0);
return NULL;
} /* _MD_Unix_mmap64 */
#endif /* defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5) */
/* Android <= 19 doesn't have mmap64. */
#if defined(ANDROID) && __ANDROID_API__ <= 19
-extern void *__mmap2(void *, size_t, int, int, int, size_t);
+PR_IMPORT(void) *__mmap2(void *, size_t, int, int, int, size_t);
#define ANDROID_PAGE_SIZE 4096
static void *
mmap64(void *addr, size_t len, int prot, int flags, int fd, loff_t offset)
{
if (offset & (ANDROID_PAGE_SIZE - 1)) {
errno = EINVAL;
--- a/nsprpub/pr/src/md/windows/ntinrval.c
+++ b/nsprpub/pr/src/md/windows/ntinrval.c
@@ -3,16 +3,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* NT interval timers
*
*/
+/* Mozilla's build system defines this globally. */
+#ifdef WIN32_LEAN_AND_MEAN
+#undef WIN32_LEAN_AND_MEAN
+#endif
#include "primpl.h"
#ifdef WINCE
typedef DWORD (*IntervalFuncType)(void);
static IntervalFuncType intervalFunc;
#endif
void