pstore2
uint64.hpp
Go to the documentation of this file.
1 //===- include/pstore/os/uint64.hpp -----------------------*- mode: C++ -*-===//
2 //* _ _ __ _ _ *
3 //* _ _(_)_ __ | |_ / /_ | || | *
4 //* | | | | | '_ \| __| '_ \| || |_ *
5 //* | |_| | | | | | |_| (_) |__ _| *
6 //* \__,_|_|_| |_|\__|\___/ |_| *
7 //* *
8 //===----------------------------------------------------------------------===//
9 //
10 // Part of the pstore project, under the Apache License v2.0 with LLVM Exceptions.
11 // See https://github.com/SNSystems/pstore/blob/master/LICENSE.txt for license
12 // information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //===----------------------------------------------------------------------===//
18 
19 #ifndef PSTORE_OS_UINT64_HPP
20 #define PSTORE_OS_UINT64_HPP
21 
22 #include <cstdint>
23 
24 #ifdef _WIN32
25 # define NOMINMAX
26 # define WIN32_LEAN_AND_MEAN
27 # include <Windows.h>
28 #endif
29 
30 #include "pstore/support/portab.hpp"
31 
32 namespace pstore {
33 
34 #ifdef _WIN32
35  PSTORE_STATIC_ASSERT (sizeof (DWORD) == sizeof (std::uint32_t));
36  PSTORE_STATIC_ASSERT (std::is_unsigned<DWORD>::value);
37 #endif
38 
39  constexpr auto uint64_high4 (std::uint64_t const v) noexcept -> std::uint32_t {
40  return static_cast<std::uint32_t> (v >> 32U);
41  }
42  constexpr auto uint64_low4 (std::uint64_t const v) noexcept -> std::uint32_t {
43  return static_cast<std::uint32_t> (v & ((std::uint64_t{1} << 32U) - 1U));
44  }
45 
46 } // end namespace pstore
47 
48 #endif // PSTORE_OS_UINT64_HPP
Definition: nonpod2.cpp:40