1 |
root |
1.12 |
|
2 |
|
|
#ifdef _MSC_VER |
3 |
|
|
|
4 |
|
|
#include <stdlib.h> |
5 |
|
|
#define bswap_32(x) _byteswap_ulong(x) |
6 |
|
|
#define bswap_64(x) _byteswap_uint64(x) |
7 |
|
|
|
8 |
|
|
#elif defined(__APPLE__) |
9 |
|
|
|
10 |
|
|
// Mac OS X / Darwin features |
11 |
|
|
#include <libkern/OSByteOrder.h> |
12 |
|
|
#define bswap_32(x) OSSwapInt32(x) |
13 |
|
|
#define bswap_64(x) OSSwapInt64(x) |
14 |
|
|
|
15 |
|
|
#elif defined(__sun) || defined(sun) |
16 |
|
|
|
17 |
|
|
#include <sys/byteorder.h> |
18 |
|
|
#define bswap_32(x) BSWAP_32(x) |
19 |
|
|
#define bswap_64(x) BSWAP_64(x) |
20 |
|
|
|
21 |
|
|
#elif defined(__FreeBSD__) |
22 |
|
|
|
23 |
|
|
#include <sys/endian.h> |
24 |
|
|
#define bswap_32(x) bswap32(x) |
25 |
|
|
#define bswap_64(x) bswap64(x) |
26 |
|
|
|
27 |
|
|
#elif defined(__OpenBSD__) |
28 |
|
|
|
29 |
|
|
#include <sys/types.h> |
30 |
|
|
#define bswap_32(x) swap32(x) |
31 |
|
|
#define bswap_64(x) swap64(x) |
32 |
|
|
|
33 |
|
|
#elif defined(__NetBSD__) |
34 |
|
|
|
35 |
|
|
#include <sys/types.h> |
36 |
|
|
#include <machine/bswap.h> |
37 |
|
|
#if defined(__BSWAP_RENAME) && !defined(__bswap_32) |
38 |
|
|
#define bswap_32(x) bswap32(x) |
39 |
|
|
#define bswap_64(x) bswap64(x) |
40 |
|
|
#endif |
41 |
|
|
|
42 |
|
|
#else |
43 |
|
|
|
44 |
|
|
#include <byteswap.h> |
45 |
|
|
|
46 |
|
|
#endif |
47 |
|
|
|
48 |
root |
1.6 |
0x00010001 |
49 |
|
|
- add ecb_is_pot32/64. |
50 |
|
|
- add intptr_t/uintptr_t. |
51 |
|
|
- add ECB_PTRSIZE. |
52 |
root |
1.7 |
- more macros for C/C++ version checks. |
53 |
|
|
- support C11 atomics for memory fences. |
54 |
|
|
- support gcc-4.7 atomics for memory fences. |
55 |
root |
1.10 |
- support m68k, m88k and sh (patch by Miod Vallat). |
56 |
root |
1.11 |
- add ecb_binary16_to_float. |
57 |
root |
1.6 |
|
58 |
root |
1.9 |
TODO: ecb_restrict_array etc. http://ue.tst.eu/5093eafd713ec5fda776d8065070aa4c.txt |
59 |
root |
1.1 |
TODO: ffs/clz |
60 |
|
|
64 bit variants of everything |
61 |
root |
1.2 |
TODO: examples from X for clz/ctz |
62 |
root |
1.3 |
TODO: arithmetic right shift |
63 |
|
|
TODO: template/generic functions for x32/x64 and so on |
64 |
root |
1.4 |
TODO: #define ecb_integer_multiples_of(n,d) ((char (*)[d])(n) - (char (*)[d])0) |
65 |
root |
1.3 |
TODO: generalised shift |
66 |
root |
1.8 |
TODO: #define ECB_FAST_UNALIGNED_ACCESS |
67 |
root |
1.3 |
unsigned long gensh(unsigned long v, int x) { |
68 |
|
|
int a, b; |
69 |
|
|
a = (v << x) & -(((unsigned int)x) < 32); |
70 |
|
|
x = -x; |
71 |
|
|
b = (v >> x) & -(((unsigned int)x) < 32); |
72 |
|
|
return a|b; |
73 |
|
|
} |