From 8a4ba96e27a585473f07f3bb02f29068f17dcb33 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Wed, 14 May 2025 14:48:51 +0800 Subject: [PATCH] import from UXP: No Issue - Fixes for building with LLVM 19 included with FreeBSD 13.5. Fix a conflict with libc++ 19 and the old Mozilla (re)alloc macros. LLVM 18+ does not allow std::char_traits so avoid it. https://bugzilla.mozilla.org/show_bug.cgi?id=1849070 Partial NSS upgrade to replace ByteString with a class. https://bugzilla.mozilla.org/show_bug.cgi?id=1851092 (e8b3077d) --- gfx/graphite2/src/MozGrMalloc.h | 20 +++++++++++--- js/src/builtin/intl/Locale.cpp | 9 ++++--- .../mozpkix/include/pkix-test/pkixtestutil.h | 26 ++++++++++++++++++- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/gfx/graphite2/src/MozGrMalloc.h b/gfx/graphite2/src/MozGrMalloc.h index acaae1236..eb5466112 100644 --- a/gfx/graphite2/src/MozGrMalloc.h +++ b/gfx/graphite2/src/MozGrMalloc.h @@ -12,8 +12,22 @@ #include "mozilla/mozalloc.h" -#define malloc moz_xmalloc -#define calloc moz_xcalloc -#define realloc moz_xrealloc +// extern "C" is needed for the Solaris build, while the inline +// functions are needed for the MinGW build. + +extern "C" inline void* malloc(size_t size) +{ + return moz_xmalloc(size); +} + +extern "C" inline void* calloc(size_t nmemb, size_t size) +{ + return moz_xcalloc(nmemb, size); +} + +extern "C" inline void* realloc(void *ptr, size_t size) +{ + return moz_xrealloc(ptr, size); +} #endif // MOZ_GR_MALLOC_H diff --git a/js/src/builtin/intl/Locale.cpp b/js/src/builtin/intl/Locale.cpp index 980ab37f6..b34ee953c 100644 --- a/js/src/builtin/intl/Locale.cpp +++ b/js/src/builtin/intl/Locale.cpp @@ -746,8 +746,9 @@ static inline auto FindUnicodeExtensionType(JSLinearString* unicodeExtension, UnicodeKey key) { JS::AutoCheckCannotGC nogc; return unicodeExtension->hasLatin1Chars() - ? FindUnicodeExtensionType(unicodeExtension->latin1Chars(nogc), - unicodeExtension->length(), key) + ? FindUnicodeExtensionType( + reinterpret_cast(unicodeExtension->latin1Chars(nogc)), + unicodeExtension->length(), key) : FindUnicodeExtensionType(unicodeExtension->twoByteChars(nogc), unicodeExtension->length(), key); } @@ -858,7 +859,9 @@ static BaseNamePartsResult BaseNameParts(const CharT* baseName, size_t length) { static inline auto BaseNameParts(JSLinearString* baseName) { JS::AutoCheckCannotGC nogc; return baseName->hasLatin1Chars() - ? BaseNameParts(baseName->latin1Chars(nogc), baseName->length()) + ? BaseNameParts( + reinterpret_cast(baseName->latin1Chars(nogc)), + baseName->length()) : BaseNameParts(baseName->twoByteChars(nogc), baseName->length()); } diff --git a/security/nss/lib/mozpkix/include/pkix-test/pkixtestutil.h b/security/nss/lib/mozpkix/include/pkix-test/pkixtestutil.h index 405842768..7c9bfa0d6 100644 --- a/security/nss/lib/mozpkix/include/pkix-test/pkixtestutil.h +++ b/security/nss/lib/mozpkix/include/pkix-test/pkixtestutil.h @@ -35,7 +35,31 @@ namespace mozilla { namespace pkix { namespace test { -typedef std::basic_string ByteString; +class ByteString : public std::string { + public: + ByteString() {} + ByteString(size_t count, uint8_t value) : std::string(count, char(value)) {} + explicit ByteString(const uint8_t* data) + : std::string(reinterpret_cast(data)) {} + ByteString(const uint8_t* data, size_t length) + : std::string(reinterpret_cast(data), length) {} + ByteString operator+(const ByteString& rhs) const { + ByteString result = *this; + result.std::string::append(rhs); + return result; + } + const uint8_t* data() const { + return reinterpret_cast(std::string::data()); + } + void assign(const uint8_t* data, size_t length) { + std::string::assign(reinterpret_cast(data), length); + } + void append(const ByteString& other) { std::string::append(other); } + void append(const uint8_t* data, size_t length) { + std::string::append(reinterpret_cast(data), length); + } + void push_back(uint8_t c) { std::string::push_back(char(c)); } +}; inline bool ENCODING_FAILED(const ByteString& bs) { return bs.empty(); }