Flutter Engine
The Flutter Engine
unaligned.h
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_PLATFORM_UNALIGNED_H_
6#define RUNTIME_PLATFORM_UNALIGNED_H_
7
8#include "platform/globals.h"
10
11namespace dart {
12
13template <typename T>
14static inline T LoadUnaligned(const T* ptr) {
15 T value;
16 memcpy(reinterpret_cast<void*>(&value), // NOLINT
17 reinterpret_cast<const void*>(ptr), sizeof(value));
18 return value;
19}
20
21template <typename T>
22static inline void StoreUnaligned(T* ptr, T value) {
23 memcpy(reinterpret_cast<void*>(ptr), // NOLINT
24 reinterpret_cast<const void*>(&value), sizeof(value));
25}
26
27} // namespace dart
28
29#endif // RUNTIME_PLATFORM_UNALIGNED_H_
uint8_t value
Definition: dart_vm.cc:33
static T LoadUnaligned(const T *ptr)
Definition: unaligned.h:14
static void StoreUnaligned(T *ptr, T value)
Definition: unaligned.h:22
#define T
Definition: precompiler.cc:65