Fabcoin Core
0.16.2
P2P Digital Currency
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
cpp-ethereum
libethash
endian.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <stdint.h>
4
#include "
compiler.h
"
5
6
#if defined(__MINGW32__) || defined(_WIN32)
7
# define LITTLE_ENDIAN 1234
8
# define BYTE_ORDER LITTLE_ENDIAN
9
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
10
# include <sys/endian.h>
11
#elif defined(__OpenBSD__) || defined(__SVR4)
12
# include <sys/types.h>
13
#elif defined(__APPLE__)
14
# include <machine/endian.h>
15
#elif defined( BSD ) && (BSD >= 199103)
16
# include <machine/endian.h>
17
#elif defined( __QNXNTO__ ) && defined( __LITTLEENDIAN__ )
18
# define LITTLE_ENDIAN 1234
19
# define BYTE_ORDER LITTLE_ENDIAN
20
#elif defined( __QNXNTO__ ) && defined( __BIGENDIAN__ )
21
# define BIG_ENDIAN 1234
22
# define BYTE_ORDER BIG_ENDIAN
23
#else
24
# include <
endian.h
>
25
#endif
26
27
#if defined(_WIN32)
28
#include <stdlib.h>
29
#define ethash_swap_u32(input_) _byteswap_ulong(input_)
30
#define ethash_swap_u64(input_) _byteswap_uint64(input_)
31
#elif defined(__APPLE__)
32
#include <libkern/OSByteOrder.h>
33
#define ethash_swap_u32(input_) OSSwapInt32(input_)
34
#define ethash_swap_u64(input_) OSSwapInt64(input_)
35
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
36
#define ethash_swap_u32(input_) bswap32(input_)
37
#define ethash_swap_u64(input_) bswap64(input_)
38
#else // posix
39
#include <
byteswap.h
>
40
#define ethash_swap_u32(input_) __bswap_32(input_)
41
#define ethash_swap_u64(input_) __bswap_64(input_)
42
#endif
43
44
45
#if LITTLE_ENDIAN == BYTE_ORDER
46
47
#define fix_endian32(dst_ ,src_) dst_ = src_
48
#define fix_endian32_same(val_)
49
#define fix_endian64(dst_, src_) dst_ = src_
50
#define fix_endian64_same(val_)
51
#define fix_endian_arr32(arr_, size_)
52
#define fix_endian_arr64(arr_, size_)
53
54
#elif BIG_ENDIAN == BYTE_ORDER
55
56
#define fix_endian32(dst_, src_) dst_ = ethash_swap_u32(src_)
57
#define fix_endian32_same(val_) val_ = ethash_swap_u32(val_)
58
#define fix_endian64(dst_, src_) dst_ = ethash_swap_u64(src_
59
#define fix_endian64_same(val_) val_ = ethash_swap_u64(val_)
60
#define fix_endian_arr32(arr_, size_) \
61
do { \
62
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
63
arr_[i_] = ethash_swap_u32(arr_[i_]); \
64
} \
65
while (0)
66
#define fix_endian_arr64(arr_, size_) \
67
do { \
68
for (unsigned i_ = 0; i_ < (size_), ++i_) { \
69
arr_[i_] = ethash_swap_u64(arr_[i_]); \
70
} \
71
while (0) \
72
73
#else
74
# error "endian not supported"
75
#endif // BYTE_ORDER
endian.h
compiler.h
byteswap.h
Generated on Mon Oct 22 2018 15:15:26 for Fabcoin Core by
1.8.11