| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license. | |
| 4 * | |
| 5 * Some functions commonly found in sys/endian.h, a header file not available | |
| 6 * on Windows platforms. | |
| 7 */ | |
| 8 | |
| 9 #ifndef _SCRYPT_SYSENDIAN_H | |
| 10 #define _SCRYPT_SYSENDIAN_H | |
| 11 | |
| 12 static __inline void be32enc(void *buf, uint32_t u) | |
| 13 { | |
| 14 uint8_t *p = (uint8_t *)buf; | |
| 15 p[0] = (uint8_t)((u >> 24) & 0xff); | |
| 16 p[1] = (uint8_t)((u >> 16) & 0xff); | |
| 17 p[2] = (uint8_t)((u >> 8) & 0xff); | |
| 18 p[3] = (uint8_t)(u & 0xff); | |
| 19 } | |
| 20 | |
| 21 static __inline void le32enc(void *buf, uint32_t u) | |
| 22 { | |
| 23 uint8_t *p = (uint8_t *)buf; | |
| 24 p[0] = (uint8_t)(u & 0xff); | |
| 25 p[1] = (uint8_t)((u >> 8) & 0xff); | |
| 26 p[2] = (uint8_t)((u >> 16) & 0xff); | |
| 27 p[3] = (uint8_t)((u >> 24) & 0xff); | |
| 28 } | |
| 29 | |
| 30 static __inline uint32_t be32dec(const void *buf) | |
| 31 { | |
| 32 const uint8_t *p = (const uint8_t *)buf; | |
| 33 return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); | |
| 34 } | |
| 35 | |
| 36 static __inline uint32_t le32dec(const void *buf) | |
| 37 { | |
| 38 const uint8_t *p = (const uint8_t *)buf; | |
| 39 return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); | |
| 40 } | |
| 41 | |
| 42 #endif // _SCRYPT_SYSENDIAN_H | |
| OLD | NEW |