Fixes for running with undefined-behavior sanitizer
[sbcl.git] / src / runtime / unaligned.h
blob1c0128d1091f0ba773a37838d1246b9c0a93e2b1
1 /*
2 * This software is part of the SBCL system. See the README file for
3 * more information.
5 * This software is derived from the CMU CL system, which was
6 * written at Carnegie Mellon University and released into the
7 * public domain. The software is in the public domain and is
8 * provided with absolutely no warranty. See the COPYING and CREDITS
9 * files for more information.
12 #ifndef _SBCL_UNALIGNED_H_
13 #define _SBCL_UNALIGNED_H_
15 // For CPUs that can do unaligned memory operations, the C compiler
16 // is generally smart enough to not actually do a memcpy()
17 static inline uint32_t UNALIGNED_LOAD32(void* p) {
18 uint32_t val;
19 memcpy(&val, p, 4);
20 return val;
22 static inline void UNALIGNED_STORE32(void* p, uint32_t val) {
23 memcpy(p, &val, 4);
25 #ifdef LISP_FEATURE_64_BIT
26 static inline void UNALIGNED_STORE64(void* p, uint64_t val) {
27 memcpy(p, &val, 8);
29 #endif
31 #endif /* _SBCL_UNALIGNED_H_ */