Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-06-15 01:56:09 +0300
committerAnna Henningsen <anna@addaleax.net>2020-06-19 18:34:20 +0300
commit2899588f28f4d02a61a19ecc8454ddaf14c7b6b3 (patch)
treeed629baa1209ad1d4ec6ee844c694a0c8d73c7a0 /src/util.h
parent563062eddf3ee9582730b6ef61c439b6cfb2d849 (diff)
src: simplify alignment-handling code
Use a common function to handle alignment computations in multiple places. PR-URL: https://github.com/nodejs/node/pull/33884 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 8cec9a8aab9..2a4d6e27d59 100644
--- a/src/util.h
+++ b/src/util.h
@@ -729,6 +729,13 @@ constexpr T RoundUp(T a, T b) {
return a % b != 0 ? a + b - (a % b) : a;
}
+// Align ptr to an `alignment`-bytes boundary.
+template <typename T, typename U>
+constexpr T* AlignUp(T* ptr, U alignment) {
+ return reinterpret_cast<T*>(
+ RoundUp(reinterpret_cast<uintptr_t>(ptr), alignment));
+}
+
class SlicedArguments : public MaybeStackBuffer<v8::Local<v8::Value>> {
public:
inline explicit SlicedArguments(