aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fxcrt/widestring.cpp13
-rw-r--r--third_party/Android.bp6
-rw-r--r--third_party/base/allocator/partition_allocator/address_space_randomization.h6
-rw-r--r--third_party/base/allocator/partition_allocator/spin_lock.cc4
4 files changed, 20 insertions, 9 deletions
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 10a31c3fa..4e51a85d9 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -287,18 +287,13 @@ static_assert(sizeof(WideString) <= sizeof(wchar_t*),
WideString WideString::FormatV(const wchar_t* format, va_list argList) {
va_list argListCopy;
va_copy(argListCopy, argList);
- int maxLen = vswprintf(nullptr, 0, format, argListCopy);
+ auto guess = GuessSizeForVSWPrintf(format, argListCopy);
va_end(argListCopy);
- if (maxLen <= 0) {
- va_copy(argListCopy, argList);
- auto guess = GuessSizeForVSWPrintf(format, argListCopy);
- va_end(argListCopy);
-
- if (!guess.has_value())
- return WideString();
- maxLen = pdfium::base::checked_cast<int>(guess.value());
+ if (!guess.has_value()) {
+ return WideString();
}
+ int maxLen = pdfium::base::checked_cast<int>(guess.value());
while (maxLen < 32 * 1024) {
va_copy(argListCopy, argList);
diff --git a/third_party/Android.bp b/third_party/Android.bp
index 3fcb08d80..1c8e251cf 100644
--- a/third_party/Android.bp
+++ b/third_party/Android.bp
@@ -39,6 +39,12 @@ cc_library_static {
"-DARCH_CPU_ARM64",
],
},
+ riscv64: {
+ cflags: [
+ "-DARCH_CPU_64_BITS",
+ "-DARCH_CPU_RISCV64",
+ ],
+ },
x86: {
cflags: [
"-DARCH_CPU_32_BITS",
diff --git a/third_party/base/allocator/partition_allocator/address_space_randomization.h b/third_party/base/allocator/partition_allocator/address_space_randomization.h
index 5cb2cccc3..7ed7f6ba4 100644
--- a/third_party/base/allocator/partition_allocator/address_space_randomization.h
+++ b/third_party/base/allocator/partition_allocator/address_space_randomization.h
@@ -100,6 +100,12 @@ constexpr uintptr_t AslrMask(uintptr_t bits) {
#endif
+ #elif defined(ARCH_CPU_RISCV64)
+
+ // RISCV64 on Linux has 39-bit user space.
+ constexpr uintptr_t kASLRMask = AslrMask(38);
+ constexpr uintptr_t kASLROffset = AslrAddress(0x1000000000ULL);
+
#elif defined(ARCH_CPU_PPC64)
#if defined(OS_AIX)
diff --git a/third_party/base/allocator/partition_allocator/spin_lock.cc b/third_party/base/allocator/partition_allocator/spin_lock.cc
index 42055836b..99e56b256 100644
--- a/third_party/base/allocator/partition_allocator/spin_lock.cc
+++ b/third_party/base/allocator/partition_allocator/spin_lock.cc
@@ -45,6 +45,10 @@
#define YIELD_PROCESSOR __asm__ __volatile__("pause")
#elif defined(ARCH_CPU_PPC64_FAMILY)
#define YIELD_PROCESSOR __asm__ __volatile__("or 31,31,31")
+#elif defined(ARCH_CPU_RISCV64)
+// Encoding of the pause instruction from the Zihintpause extension. This
+// is a noop on cpus that don't have the Zihintpause extension.
+#define YIELD_PROCESSOR __asm__ __volatile__ (".4byte 0x100000F");
#elif defined(ARCH_CPU_S390_FAMILY)
// just do nothing
#define YIELD_PROCESSOR ((void)0)