plebble
endian_rw.h
Go to the documentation of this file.
1 #ifndef USGOV_e5acce2140cfdf81b2fc07daee27f8bb0244681c5993c3ec13ed393478783d50
2 #define USGOV_e5acce2140cfdf81b2fc07daee27f8bb0244681c5993c3ec13ed393478783d50
3 
4 // Copyright (c) 2014 The Bitcoin Core developers
5 // Distributed under the MIT software license, see the accompanying
6 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 // Original file bitcoin-core:crypto/common.h
8 
9 
10 #include <stdint.h>
11 #include <endian.h>
12 
13 namespace us { namespace gov {
14 namespace crypto {
15 
16 uint16_t static inline ReadLE16(const unsigned char* ptr) { return le16toh(*((uint16_t*)ptr));}
17 uint32_t static inline ReadLE32(const unsigned char* ptr) { return le32toh(*((uint32_t*)ptr));}
18 uint64_t static inline ReadLE64(const unsigned char* ptr) { return le64toh(*((uint64_t*)ptr));}
19 void static inline WriteLE16(unsigned char* ptr, uint16_t x) { *((uint16_t*)ptr) = htole16(x); }
20 void static inline WriteLE32(unsigned char* ptr, uint32_t x) { *((uint32_t*)ptr) = htole32(x); }
21 void static inline WriteLE64(unsigned char* ptr, uint64_t x) { *((uint64_t*)ptr) = htole64(x); }
22 uint32_t static inline ReadBE32(const unsigned char* ptr) { return be32toh(*((uint32_t*)ptr)); }
23 uint64_t static inline ReadBE64(const unsigned char* ptr) { return be64toh(*((uint64_t*)ptr)); }
24 void static inline WriteBE32(unsigned char* ptr, uint32_t x) { *((uint32_t*)ptr) = htobe32(x); }
25 void static inline WriteBE64(unsigned char* ptr, uint64_t x) { *((uint64_t*)ptr) = htobe64(x); }
26 
27 }
28 }}
29 
30 #endif
us::gov::crypto::WriteBE32
static void WriteBE32(unsigned char *ptr, uint32_t x)
Definition: endian_rw.h:24
us::gov::crypto::WriteLE16
static void WriteLE16(unsigned char *ptr, uint16_t x)
Definition: endian_rw.h:19
us
Definition: daemon.h:22
us::gov::crypto::WriteLE64
static void WriteLE64(unsigned char *ptr, uint64_t x)
Definition: endian_rw.h:21
us::gov::crypto::WriteBE64
static void WriteBE64(unsigned char *ptr, uint64_t x)
Definition: endian_rw.h:25
us::gov::crypto::ReadLE64
static uint64_t ReadLE64(const unsigned char *ptr)
Definition: endian_rw.h:18
us::gov::crypto::ReadBE64
static uint64_t ReadBE64(const unsigned char *ptr)
Definition: endian_rw.h:23
us::gov::crypto::ReadLE32
static uint32_t ReadLE32(const unsigned char *ptr)
Definition: endian_rw.h:17
us::gov::crypto::WriteLE32
static void WriteLE32(unsigned char *ptr, uint32_t x)
Definition: endian_rw.h:20
us::gov::crypto::ReadLE16
static uint16_t ReadLE16(const unsigned char *ptr)
Definition: endian_rw.h:16
us::gov::crypto::ReadBE32
static uint32_t ReadBE32(const unsigned char *ptr)
Definition: endian_rw.h:22