diff --git a/media/gmp-clearkey/0.1/moz.build b/media/gmp-clearkey/0.1/moz.build index 4dc7e8767889..a4200a76ac23 100644 --- a/media/gmp-clearkey/0.1/moz.build +++ b/media/gmp-clearkey/0.1/moz.build @@ -7,7 +7,7 @@ with Files("**"): BUG_COMPONENT = ("Core", "Audio/Video: GMP") -SharedLibrary("clearkey") +GeckoSharedLibrary("clearkey", linkage=None) FINAL_TARGET = "dist/bin/gmp-clearkey/0.1" diff --git a/memory/replace/logalloc/replay/moz.build b/memory/replace/logalloc/replay/moz.build index 3e0c8c395aee..ca85f175570f 100644 --- a/memory/replace/logalloc/replay/moz.build +++ b/memory/replace/logalloc/replay/moz.build @@ -44,7 +44,19 @@ if CONFIG["MOZ_DMD"] or CONFIG["MOZ_PHC"]: "/mozglue/misc/StackWalk.h", ] -if not CONFIG["MOZ_REPLACE_MALLOC_STATIC"]: +if CONFIG["MOZ_REPLACE_MALLOC_STATIC"]: + UNIFIED_SOURCES += [ + "/mfbt/double-conversion/double-conversion/bignum-dtoa.cc", + "/mfbt/double-conversion/double-conversion/bignum.cc", + "/mfbt/double-conversion/double-conversion/cached-powers.cc", + "/mfbt/double-conversion/double-conversion/double-to-string.cc", + "/mfbt/double-conversion/double-conversion/fast-dtoa.cc", + "/mfbt/double-conversion/double-conversion/fixed-dtoa.cc", + "/mfbt/double-conversion/double-conversion/string-to-double.cc", + "/mfbt/double-conversion/double-conversion/strtod.cc", + "/mozglue/misc/Printf.cpp", + ] +else: SOURCES += [ "../FdPrintf.cpp", ] diff --git a/mfbt/tests/moz.build b/mfbt/tests/moz.build index 5d08728f8492..9c8ebc838ced 100644 --- a/mfbt/tests/moz.build +++ b/mfbt/tests/moz.build @@ -91,9 +91,6 @@ if not CONFIG["MOZ_ASAN"]: ] ) -# Since we link directly with MFBT object files, define IMPL_MFBT -DEFINES["IMPL_MFBT"] = True - DisableStlWrapping() if CONFIG["CC_TYPE"] == "clang-cl": @@ -103,7 +100,7 @@ if CONFIG["CC_TYPE"] == "clang-cl": ] USE_LIBS += [ - "mfbt", + "mozglue", ] if CONFIG["CC_TYPE"] in ("clang", "gcc"): diff --git a/mozglue/misc/Printf.h b/mozglue/misc/Printf.h index e073a0d61cac..3f4fa2c1bb89 100644 --- a/mozglue/misc/Printf.h +++ b/mozglue/misc/Printf.h @@ -88,6 +88,8 @@ class PrintfTarget { bool MFBT_API appendIntOct(uint64_t); bool MFBT_API appendIntHex(uint64_t); + inline size_t emitted() { return mEmitted; } + protected: MFBT_API PrintfTarget(); virtual ~PrintfTarget() = default; diff --git a/mozglue/misc/Sprintf.h b/mozglue/misc/Sprintf.h index 14dcbe0c1dea..2017aad5dc54 100644 --- a/mozglue/misc/Sprintf.h +++ b/mozglue/misc/Sprintf.h @@ -11,19 +11,60 @@ #include #include +#include #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" +#include "mozilla/Printf.h" #ifdef __cplusplus +# ifndef SPRINTF_H_USES_VSNPRINTF +namespace mozilla { +namespace detail { + +struct MOZ_STACK_CLASS SprintfAppend final : public mozilla::PrintfTarget { + template + explicit SprintfAppend(char (&aBuf)[N]) : mBuf(aBuf), mBufLen(N) {} + + bool append(const char* aStr, size_t aLen) override { + if (aLen == 0) { + return true; + } + // Don't copy more than what's left to use. + size_t copy = std::min(mBufLen, aLen); + if (copy > 0) { + memcpy(mBuf, aStr, copy); + mBuf += copy; + mBufLen -= copy; + } + return true; + } + + private: + char* mBuf; + size_t mBufLen; +}; + +} // namespace detail +} // namespace mozilla +# endif // SPRINTF_H_USES_VSNPRINTF + template MOZ_FORMAT_PRINTF(2, 0) int VsprintfLiteral(char (&buffer)[N], const char* format, va_list args) { MOZ_ASSERT(format != buffer); +# ifdef SPRINTF_H_USES_VSNPRINTF int result = vsnprintf(buffer, N, format, args); buffer[N - 1] = '\0'; return result; +# else + mozilla::detail::SprintfAppend ss(buffer); + ss.vprint(format, args); + size_t len = ss.emitted(); + buffer[std::min(len, N - 1)] = '\0'; + return len; +# endif } template diff --git a/toolkit/mozapps/update/updater/updater-common.build b/toolkit/mozapps/update/updater/updater-common.build index 2f2a210f255b..28cf32982a4f 100644 --- a/toolkit/mozapps/update/updater/updater-common.build +++ b/toolkit/mozapps/update/updater/updater-common.build @@ -85,6 +85,7 @@ if CONFIG["MOZ_TSAN"]: "TsanOptions.cpp", ] +DEFINES["SPRINTF_H_USES_VSNPRINTF"] = True DEFINES["NS_NO_XPCOM"] = True DisableStlWrapping() for var in ("MAR_CHANNEL_ID", "MOZ_APP_VERSION"): diff --git a/xpcom/tests/moz.build b/xpcom/tests/moz.build index e05fe9093d91..4758c655ace1 100644 --- a/xpcom/tests/moz.build +++ b/xpcom/tests/moz.build @@ -24,7 +24,7 @@ test_progs = [ ] SimplePrograms(test_progs) -USE_LIBS += ["mfbt"] +USE_LIBS += ["mozglue"] XPCSHELL_TESTS_MANIFESTS += ["unit/xpcshell.ini"]