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

Unified Diff: util/numeric/int128.h

Issue 583283003: Add uint128_struct and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 3 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
Index: util/numeric/int128.h
diff --git a/util/numeric/int128.h b/util/numeric/int128.h
new file mode 100644
index 0000000000000000000000000000000000000000..7335e77514e2affd7e62ad9272726cda14ac1fc9
--- /dev/null
+++ b/util/numeric/int128.h
@@ -0,0 +1,50 @@
+// Copyright 2014 The Crashpad Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef CRASHPAD_UTIL_NUMERIC_INT128_H_
+#define CRASHPAD_UTIL_NUMERIC_INT128_H_
+
+#include <stdint.h>
+
+#include "build/build_config.h"
+
+namespace crashpad {
+
+//! \brief Stores a 128-bit quantity.
+//!
+//! This structure is organized so that 128-bit quantities are laid out in
+//! memory according to the system’s natural byte order. If a system offers a
+//! native 128-bit type, it should be possible to bit_cast<> between that type
+//! and this one.
+//!
+//! This structure is designed to have the same layout, although not the same
+//! field names, as the Windows SDK’s `M128A` type from `<winnt.h>`. It is
+//! provided here instead of in `compat` because it is useful outside of the
+//! scope of data structures defined by the Windows SDK.
+struct uint128_struct {
+#if defined(ARCH_CPU_LITTLE_ENDIAN) || DOXYGEN
+ //! \brief The low 64 bits of the 128-bit quantity.
+ uint64_t lo;
+
+ //! \brief The high 64 bits of the 128-bit quantity.
+ uint64_t hi;
+#else
+ uint64_t hi;
+ uint64_t lo;
+#endif
+};
+
+} // namespace crashpad
+
+#endif // CRASHPAD_UTIL_NUMERIC_INT128_H_
« no previous file with comments | « DEPS ('k') | util/numeric/int128_test.cc » ('j') | util/numeric/int128_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698