1 |
root |
1.34 |
0x00010009 |
2 |
root |
1.35 |
- added ecb_i2a family of functions. |
3 |
root |
1.34 |
- added ECB_64BIT_NATIVE. |
4 |
|
|
|
5 |
root |
1.15 |
TODO: |
6 |
|
|
08:30:06 <b_jonas> I think it could be worth to add a macro that works like alignof or _Alignof on sane |
7 |
|
|
compilers, and like __alignof on MS compilers that support it, see |
8 |
|
|
http://msdn.microsoft.com/en-us/library/45t0s5f4.aspx |
9 |
|
|
08:30:24 <b_jonas> even if you can't support it on all the old compilers |
10 |
|
|
08:31:17 <b_jonas> I'd also like a macro for alignas, but sadly, that seems impossible in general, because |
11 |
|
|
the MS compiler only has some half-attempt to do something similar but with different and |
12 |
|
|
more broken semantics, see http://msdn.microsoft.com/en-us/library/83ythb65.aspx |
13 |
|
|
08:31:35 <b_jonas> but I wonder if some special case could still be worth to support |
14 |
|
|
08:32:23 <b_jonas> probably not, because it would just account to making a union with a highly aligned type, |
15 |
|
|
which is something I can do on any compiler portably |
16 |
|
|
|
17 |
|
|
TODO: #define ECB_IS_INTEGRAL(x) !((1 ? 1 : (x)) / 2) |
18 |
|
|
#define ECB_IS_INTEGRAL(x) (sizeof ((x) + 1.0f) != sizeof((x) + 1ULL)) |
19 |
|
|
|
20 |
root |
1.28 |
TODO: ecb_minpot, either using bit tricks or ecb_ldXX |
21 |
|
|
|
22 |
|
|
TODO: __builtin_popcountll exists... |
23 |
|
|
|
24 |
root |
1.26 |
TODO: __builtin_powi |
25 |
|
|
|
26 |
root |
1.15 |
TODO: https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ |
27 |
|
|
|
28 |
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/ |
29 |
root |
1.12 |
|
30 |
|
|
#ifdef _MSC_VER |
31 |
|
|
|
32 |
|
|
#include <stdlib.h> |
33 |
|
|
#define bswap_32(x) _byteswap_ulong(x) |
34 |
|
|
#define bswap_64(x) _byteswap_uint64(x) |
35 |
|
|
|
36 |
|
|
#elif defined(__APPLE__) |
37 |
|
|
|
38 |
|
|
// Mac OS X / Darwin features |
39 |
|
|
#include <libkern/OSByteOrder.h> |
40 |
|
|
#define bswap_32(x) OSSwapInt32(x) |
41 |
|
|
#define bswap_64(x) OSSwapInt64(x) |
42 |
|
|
|
43 |
|
|
#elif defined(__sun) || defined(sun) |
44 |
|
|
|
45 |
|
|
#include <sys/byteorder.h> |
46 |
|
|
#define bswap_32(x) BSWAP_32(x) |
47 |
|
|
#define bswap_64(x) BSWAP_64(x) |
48 |
|
|
|
49 |
|
|
#elif defined(__FreeBSD__) |
50 |
|
|
|
51 |
|
|
#include <sys/endian.h> |
52 |
|
|
#define bswap_32(x) bswap32(x) |
53 |
|
|
#define bswap_64(x) bswap64(x) |
54 |
|
|
|
55 |
|
|
#elif defined(__OpenBSD__) |
56 |
|
|
|
57 |
|
|
#include <sys/types.h> |
58 |
|
|
#define bswap_32(x) swap32(x) |
59 |
|
|
#define bswap_64(x) swap64(x) |
60 |
|
|
|
61 |
|
|
#elif defined(__NetBSD__) |
62 |
|
|
|
63 |
|
|
#include <sys/types.h> |
64 |
|
|
#include <machine/bswap.h> |
65 |
|
|
#if defined(__BSWAP_RENAME) && !defined(__bswap_32) |
66 |
|
|
#define bswap_32(x) bswap32(x) |
67 |
|
|
#define bswap_64(x) bswap64(x) |
68 |
|
|
#endif |
69 |
|
|
|
70 |
|
|
#else |
71 |
|
|
|
72 |
|
|
#include <byteswap.h> |
73 |
|
|
|
74 |
|
|
#endif |
75 |
|
|
|
76 |
root |
1.32 |
TODO: generic poprcount etc., also fast_t for them? |
77 |
root |
1.33 |
|
78 |
root |
1.36 |
- allow any rotate count in rcb_rot*, at the expense |
79 |
|
|
of bad optimisation results on some platforms or with |
80 |
|
|
some word sizes. |
81 |
root |
1.33 |
- try to use inttypes.h on mingw. |
82 |
|
|
|
83 |
root |
1.30 |
0x00010008 |
84 |
|
|
- aligned/unaligned load/store, bswap, host order |
85 |
|
|
conversion. |
86 |
root |
1.32 |
- generic C++ ecb_rot[lr], ecb_popcount, ecb_ctz, |
87 |
|
|
ecb_is_pot32 and ecb_bitrev functions. |
88 |
root |
1.30 |
|
89 |
root |
1.29 |
0x00010007 |
90 |
|
|
- new ECB_OPTIMIZE_SIZE symbol. |
91 |
|
|
|
92 |
root |
1.28 |
0x00010006 |
93 |
root |
1.29 |
- new ECB_MEMORY_FENCE_RELAXED memory fence. |
94 |
root |
1.28 |
- use acquire/eelease memory barriers on sun workshop pro, not read/write. |
95 |
|
|
- rely on c++ compiler barriers to do the right thing in gcc/clang. |
96 |
root |
1.27 |
- change release memory fence to memory barrier on ia32/ia64. |
97 |
root |
1.23 |
- apply ctz/ld patch for msc by Zsbán Ambrus. |
98 |
root |
1.24 |
- ECB_PTRSIZE erroneously was 8 on most 32bit systems ( |
99 |
|
|
found by Zsbán Ambrus). |
100 |
root |
1.25 |
- improved compiletime detection of endianness, also, allow |
101 |
|
|
runtime detection to indicate other-than-big/little endianness. |
102 |
root |
1.26 |
- no memory barrier neded on arm < 6. |
103 |
root |
1.23 |
|
104 |
root |
1.22 |
0x00010005 |
105 |
|
|
- improve ecb_binary16_to_float. |
106 |
|
|
- add ecb_float_to_binary16. |
107 |
|
|
- add ecb_binary16_to_binary32 and ecb_binary32_to_binary16 pair. |
108 |
|
|
|
109 |
root |
1.6 |
0x00010001 |
110 |
|
|
- add ecb_is_pot32/64. |
111 |
|
|
- add intptr_t/uintptr_t. |
112 |
|
|
- add ECB_PTRSIZE. |
113 |
root |
1.7 |
- more macros for C/C++ version checks. |
114 |
|
|
- support C11 atomics for memory fences. |
115 |
|
|
- support gcc-4.7 atomics for memory fences. |
116 |
root |
1.10 |
- support m68k, m88k and sh (patch by Miod Vallat). |
117 |
root |
1.11 |
- add ecb_binary16_to_float. |
118 |
root |
1.6 |
|
119 |
root |
1.9 |
TODO: ecb_restrict_array etc. http://ue.tst.eu/5093eafd713ec5fda776d8065070aa4c.txt |
120 |
sf-exg |
1.20 |
TODO: ffs |
121 |
root |
1.1 |
64 bit variants of everything |
122 |
root |
1.2 |
TODO: examples from X for clz/ctz |
123 |
root |
1.3 |
TODO: arithmetic right shift |
124 |
|
|
TODO: template/generic functions for x32/x64 and so on |
125 |
root |
1.4 |
TODO: #define ecb_integer_multiples_of(n,d) ((char (*)[d])(n) - (char (*)[d])0) |
126 |
root |
1.3 |
TODO: generalised shift |
127 |
root |
1.8 |
TODO: #define ECB_FAST_UNALIGNED_ACCESS |
128 |
root |
1.3 |
unsigned long gensh(unsigned long v, int x) { |
129 |
|
|
int a, b; |
130 |
|
|
a = (v << x) & -(((unsigned int)x) < 32); |
131 |
|
|
x = -x; |
132 |
|
|
b = (v >> x) & -(((unsigned int)x) < 32); |
133 |
|
|
return a|b; |
134 |
|
|
} |
135 |
root |
1.14 |
|
136 |
root |
1.16 |
TODO: export(=dllexport) & hidden |
137 |
|
|
TODO: flatten |
138 |
|
|
TODO: warning(msg) |
139 |
|
|
TODO: error(msg) |
140 |
root |
1.17 |
TODO: leaf (uh), noclone (hmmm) |
141 |
|
|
TODO: nonnull, returns_nonnull |
142 |
|
|
TODO: nothrow |
143 |
|
|
TODO: used |
144 |
|
|
TODO: trap |
145 |
|
|
TODO: http://llvm.org/docs/doxygen/html/Compiler_8h_source.html |
146 |
root |
1.16 |
|
147 |
root |
1.14 |
TODO: read/write unaligned macros |
148 |
|
|
TODO: htonl and friends |
149 |
sf-exg |
1.20 |
TODO: macro to convert from unsigned to signed "the natural way" |
150 |
root |
1.14 |
TODO: ecb_static_assert, with message (just like boost), or somesuch, using array-declaration |
151 |
|
|
TODO: alignof |
152 |
|
|
|
153 |
|
|
|