summaryrefslogtreecommitdiffstats
path: root/config/external/rlbox
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--config/external/rlbox/moz.build27
-rw-r--r--config/external/rlbox/rlbox_config.h40
-rw-r--r--config/external/rlbox/rlbox_thread_locals.cpp17
-rw-r--r--config/external/rlbox_lucet_sandbox/moz.build14
-rw-r--r--config/external/rlbox_lucet_sandbox/rlbox_lucet_thread_locals.cpp20
5 files changed, 118 insertions, 0 deletions
diff --git a/config/external/rlbox/moz.build b/config/external/rlbox/moz.build
new file mode 100644
index 0000000000..d222f530a9
--- /dev/null
+++ b/config/external/rlbox/moz.build
@@ -0,0 +1,27 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# 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/.
+
+EXPORTS.mozilla.rlbox += [
+ "/third_party/rlbox/include/rlbox.hpp",
+ "/third_party/rlbox/include/rlbox_conversion.hpp",
+ "/third_party/rlbox/include/rlbox_helpers.hpp",
+ "/third_party/rlbox/include/rlbox_noop_sandbox.hpp",
+ "/third_party/rlbox/include/rlbox_policy_types.hpp",
+ "/third_party/rlbox/include/rlbox_range.hpp",
+ "/third_party/rlbox/include/rlbox_sandbox.hpp",
+ "/third_party/rlbox/include/rlbox_stdlib.hpp",
+ "/third_party/rlbox/include/rlbox_stdlib_polyfill.hpp",
+ "/third_party/rlbox/include/rlbox_struct_support.hpp",
+ "/third_party/rlbox/include/rlbox_type_traits.hpp",
+ "/third_party/rlbox/include/rlbox_types.hpp",
+ "/third_party/rlbox/include/rlbox_unwrap.hpp",
+ "/third_party/rlbox/include/rlbox_wrapper_traits.hpp",
+ "rlbox_config.h",
+]
+
+SOURCES += ["rlbox_thread_locals.cpp"]
+
+FINAL_LIBRARY = "xul"
diff --git a/config/external/rlbox/rlbox_config.h b/config/external/rlbox/rlbox_config.h
new file mode 100644
index 0000000000..a7926a9a22
--- /dev/null
+++ b/config/external/rlbox/rlbox_config.h
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+#ifndef RLBOX_CONFIG
+#define RLBOX_CONFIG
+
+#ifdef XP_MACOSX
+
+// RLBox uses c++17's shared_locks by default, even for the noop_sandbox
+// However c++17 shared_lock is not supported on macOS 10.9 to 10.11
+// Thus we use Firefox's shared lock implementation
+// This can be removed if macOS 10.9 to 10.11 support is dropped
+# include "mozilla/RWLock.h"
+namespace rlbox {
+struct rlbox_shared_lock {
+ mozilla::detail::StaticRWLock rwlock;
+};
+} // namespace rlbox
+# define RLBOX_USE_CUSTOM_SHARED_LOCK
+# define RLBOX_SHARED_LOCK(name) rlbox::rlbox_shared_lock name
+# define RLBOX_ACQUIRE_SHARED_GUARD(name, ...) \
+ mozilla::detail::StaticAutoReadLock name((__VA_ARGS__).rwlock)
+# define RLBOX_ACQUIRE_UNIQUE_GUARD(name, ...) \
+ mozilla::detail::StaticAutoWriteLock name((__VA_ARGS__).rwlock)
+
+#endif
+
+// All uses are on the main thread right now, disable rlbox thread checks for
+// performance
+#define RLBOX_SINGLE_THREADED_INVOCATIONS
+
+// The MingW compiler does not correctly handle static thread_local inline
+// members. This toggles a workaround that allows the host application (firefox)
+// to provide TLS storage via functions. This can be removed if the MingW bug is
+// fixed.
+#define RLBOX_EMBEDDER_PROVIDES_TLS_STATIC_VARIABLES
+
+#endif
diff --git a/config/external/rlbox/rlbox_thread_locals.cpp b/config/external/rlbox/rlbox_thread_locals.cpp
new file mode 100644
index 0000000000..157177c0e0
--- /dev/null
+++ b/config/external/rlbox/rlbox_thread_locals.cpp
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+// Load general firefox configuration of RLBox
+#include "mozilla/rlbox/rlbox_config.h"
+
+#define RLBOX_USE_STATIC_CALLS() rlbox_noop_sandbox_lookup_symbol
+#include "mozilla/rlbox/rlbox_noop_sandbox.hpp"
+
+#include "mozilla/rlbox/rlbox.hpp"
+
+// The MingW compiler does not correctly handle static thread_local inline
+// members. We instead TLS storage via functions. This can be removed if the
+// MingW bug is fixed.
+RLBOX_NOOP_SANDBOX_STATIC_VARIABLES();
diff --git a/config/external/rlbox_lucet_sandbox/moz.build b/config/external/rlbox_lucet_sandbox/moz.build
new file mode 100644
index 0000000000..4282524636
--- /dev/null
+++ b/config/external/rlbox_lucet_sandbox/moz.build
@@ -0,0 +1,14 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# 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/.
+
+EXPORTS.mozilla.rlbox += [
+ "/third_party/rust/rlbox_lucet_sandbox/include/lucet_sandbox.h",
+ "/third_party/rust/rlbox_lucet_sandbox/include/rlbox_lucet_sandbox.hpp",
+]
+
+SOURCES += ["rlbox_lucet_thread_locals.cpp"]
+
+FINAL_LIBRARY = "xul"
diff --git a/config/external/rlbox_lucet_sandbox/rlbox_lucet_thread_locals.cpp b/config/external/rlbox_lucet_sandbox/rlbox_lucet_thread_locals.cpp
new file mode 100644
index 0000000000..0217074f6b
--- /dev/null
+++ b/config/external/rlbox_lucet_sandbox/rlbox_lucet_thread_locals.cpp
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+#ifdef MOZ_USING_WASM_SANDBOXING
+
+// Load general firefox configuration of RLBox
+# include "mozilla/rlbox/rlbox_config.h"
+
+# include "mozilla/rlbox/rlbox_lucet_sandbox.hpp"
+
+# include "mozilla/rlbox/rlbox.hpp"
+
+// The MingW compiler does not correctly handle static thread_local inline
+// members. We instead TLS storage via functions. This can be removed if the
+// MingW bug is fixed.
+RLBOX_LUCET_SANDBOX_STATIC_VARIABLES();
+
+#endif