blob: 673b6ffb5a0d8d7089a2c208ddd0a49affe1d934 [file] [log] [blame]
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_PLATFORM_UNALIGNED_H_
#define RUNTIME_PLATFORM_UNALIGNED_H_
#include "platform/globals.h"
#include "platform/undefined_behavior_sanitizer.h"
namespace dart {
template <typename T>
static inline T LoadUnaligned(const T* ptr) {
T value;
memcpy(reinterpret_cast<void*>(&value), // NOLINT
reinterpret_cast<const void*>(ptr), sizeof(value));
return value;
}
template <typename T>
static inline void StoreUnaligned(T* ptr, T value) {
memcpy(reinterpret_cast<void*>(ptr), // NOLINT
reinterpret_cast<const void*>(&value), sizeof(value));
}
} // namespace dart
#endif // RUNTIME_PLATFORM_UNALIGNED_H_