Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: mojo/public/cpp/bindings/lib/bindings_internal.cc

Issue 2202023005: Mojo C++ bindings: inline pointer encoding/decoding/validating functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@85_inline_data_view
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/bindings/lib/bindings_internal.h ('k') | mojo/public/cpp/bindings/lib/validation_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/bindings_internal.cc
diff --git a/mojo/public/cpp/bindings/lib/bindings_internal.cc b/mojo/public/cpp/bindings/lib/bindings_internal.cc
deleted file mode 100644
index a3bdb1fe98d5e7a8a5160868213e82d89f292040..0000000000000000000000000000000000000000
--- a/mojo/public/cpp/bindings/lib/bindings_internal.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
-
-namespace mojo {
-namespace internal {
-
-namespace {
-
-const size_t kAlignment = 8;
-
-template <typename T>
-T AlignImpl(T t) {
- return t + (kAlignment - (t % kAlignment)) % kAlignment;
-}
-
-} // namespace
-
-size_t Align(size_t size) {
- return AlignImpl(size);
-}
-
-char* AlignPointer(char* ptr) {
- return reinterpret_cast<char*>(AlignImpl(reinterpret_cast<uintptr_t>(ptr)));
-}
-
-bool IsAligned(const void* ptr) {
- return !(reinterpret_cast<uintptr_t>(ptr) % kAlignment);
-}
-
-void EncodePointer(const void* ptr, uint64_t* offset) {
- if (!ptr) {
- *offset = 0;
- return;
- }
-
- const char* p_obj = reinterpret_cast<const char*>(ptr);
- const char* p_slot = reinterpret_cast<const char*>(offset);
- DCHECK(p_obj > p_slot);
-
- *offset = static_cast<uint64_t>(p_obj - p_slot);
-}
-
-} // namespace internal
-} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/bindings_internal.h ('k') | mojo/public/cpp/bindings/lib/validation_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698