1 /* ----------------------------------------------------------------------- *
3 * Copyright 2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
8 * Boston MA 02110-1301, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
16 * Write unaligned littleendian data
24 #if defined(__i386__) || defined(__x86_64__)
26 /* Littleendian architecture, unaligned accesses permitted */
28 static inline uint16_t rdle16(const uint16_t *p)
33 static inline uint32_t rdle32(const uint32_t *p)
38 static inline void wrle16(uint16_t v, uint16_t *p)
43 static inline void wrle32(uint32_t v, uint32_t *p)
50 static inline uint16_t rdle16(const uint16_t *p)
52 const uint8_t *_p = (const uint8_t *)p;
53 return _p[0] + (_p[1] << 8);
56 static inline uint32_t rdle32(const uint32_t *p)
58 const uint8_t *_p = (const uint8_t *)p;
59 return _p[0] + (_p[1] << 8) + (_p[2] << 16) + (_p[3] << 24);
62 static inline void wrle16(uint16_t v, uint16_t *p)
64 uint8_t *_p = (uint8_t *)p;
70 static inline void wrle32(uint32_t v, uint32_t *p)
72 uint8_t *_p = (uint8_t *)p;