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