diff --git a/memory/mozalloc/mozalloc.cpp b/memory/mozalloc/mozalloc.cpp index 7f752899bbb..f4c3f96decc 100644 --- a/memory/mozalloc/mozalloc.cpp +++ b/memory/mozalloc/mozalloc.cpp @@ -48,6 +48,10 @@ #include // for size_t #include // for malloc, free +#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec)) +# define MOZALLOC_EXPORT __declspec(dllexport) +#endif + // Make sure that "malloc" et al. resolve to their libc variants. #define MOZALLOC_DONT_DEFINE_MACRO_WRAPPERS #include "mozilla/mozalloc.h" diff --git a/memory/mozalloc/mozalloc.h b/memory/mozalloc/mozalloc.h index ea50220fc6e..cd42eb89cd7 100644 --- a/memory/mozalloc/mozalloc.h +++ b/memory/mozalloc/mozalloc.h @@ -54,8 +54,11 @@ * I.e., we don't #include or on purpose. */ -#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec)) -# define MOZALLOC_EXPORT __declspec(dllexport) +#if defined(MOZALLOC_EXPORT) +// do nothing: it's been defined to __declspec(dllexport) by +// mozalloc*.cpp on platforms where that's required +#elif defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec)) +# define MOZALLOC_EXPORT __declspec(dllimport) #elif defined(HAVE_VISIBILITY_ATTRIBUTE) /* Make sure symbols are still exported even if we're wrapped in a * |visibility push(hidden)| blanket. */ diff --git a/memory/mozalloc/mozalloc_oom.cpp b/memory/mozalloc/mozalloc_oom.cpp index 84924a80a5a..8d4878abb20 100644 --- a/memory/mozalloc/mozalloc_oom.cpp +++ b/memory/mozalloc/mozalloc_oom.cpp @@ -46,6 +46,10 @@ # include // for _exit #endif +#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec)) +# define MOZALLOC_EXPORT __declspec(dllexport) +#endif + #include "mozilla/mozalloc_oom.h" static int gDummyCounter; diff --git a/memory/mozalloc/mozalloc_oom.h b/memory/mozalloc/mozalloc_oom.h index 86b4fc95537..311169c0521 100644 --- a/memory/mozalloc/mozalloc_oom.h +++ b/memory/mozalloc/mozalloc_oom.h @@ -41,9 +41,11 @@ #ifndef mozilla_mozalloc_oom_h #define mozilla_mozalloc_oom_h - -#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec)) -# define MOZALLOC_EXPORT __declspec(dllexport) +#if defined(MOZALLOC_EXPORT) +// do nothing: it's been defined to __declspec(dllexport) by +// mozalloc*.cpp on platforms where that's required +#elif defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec)) +# define MOZALLOC_EXPORT __declspec(dllimport) #elif defined(HAVE_VISIBILITY_ATTRIBUTE) /* Make sure symbols are still exported even if we're wrapped in a * |visibility push(hidden)| blanket. */ diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h index bede7272ede..e0227cb0b50 100644 --- a/xpcom/base/nscore.h +++ b/xpcom/base/nscore.h @@ -50,7 +50,10 @@ # if defined(__cplusplus) # include NEW_H /* to give mozalloc std::bad_alloc */ # endif -# include /* to give mozalloc malloc/free decls */ +/* include these to avoid the macro wrappers causing these headers to + * declare system functions with moz_ prefixes */ +# include +# include # include "mozilla/mozalloc.h" # include "mozilla/mozalloc_macro_wrappers.h" #endif