1 |
root |
1.15 |
TODO: |
2 |
|
|
08:30:06 <b_jonas> I think it could be worth to add a macro that works like alignof or _Alignof on sane |
3 |
|
|
compilers, and like __alignof on MS compilers that support it, see |
4 |
|
|
http://msdn.microsoft.com/en-us/library/45t0s5f4.aspx |
5 |
|
|
08:30:24 <b_jonas> even if you can't support it on all the old compilers |
6 |
|
|
08:31:17 <b_jonas> I'd also like a macro for alignas, but sadly, that seems impossible in general, because |
7 |
|
|
the MS compiler only has some half-attempt to do something similar but with different and |
8 |
|
|
more broken semantics, see http://msdn.microsoft.com/en-us/library/83ythb65.aspx |
9 |
|
|
08:31:35 <b_jonas> but I wonder if some special case could still be worth to support |
10 |
|
|
08:32:23 <b_jonas> probably not, because it would just account to making a union with a highly aligned type, |
11 |
|
|
which is something I can do on any compiler portably |
12 |
|
|
|
13 |
|
|
TODO: #define ECB_IS_INTEGRAL(x) !((1 ? 1 : (x)) / 2) |
14 |
|
|
#define ECB_IS_INTEGRAL(x) (sizeof ((x) + 1.0f) != sizeof((x) + 1ULL)) |
15 |
|
|
|
16 |
|
|
TODO: https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ |
17 |
|
|
|
18 |
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/ |
19 |
root |
1.12 |
|
20 |
|
|
#ifdef _MSC_VER |
21 |
|
|
|
22 |
|
|
#include <stdlib.h> |
23 |
|
|
#define bswap_32(x) _byteswap_ulong(x) |
24 |
|
|
#define bswap_64(x) _byteswap_uint64(x) |
25 |
|
|
|
26 |
|
|
#elif defined(__APPLE__) |
27 |
|
|
|
28 |
|
|
// Mac OS X / Darwin features |
29 |
|
|
#include <libkern/OSByteOrder.h> |
30 |
|
|
#define bswap_32(x) OSSwapInt32(x) |
31 |
|
|
#define bswap_64(x) OSSwapInt64(x) |
32 |
|
|
|
33 |
|
|
#elif defined(__sun) || defined(sun) |
34 |
|
|
|
35 |
|
|
#include <sys/byteorder.h> |
36 |
|
|
#define bswap_32(x) BSWAP_32(x) |
37 |
|
|
#define bswap_64(x) BSWAP_64(x) |
38 |
|
|
|
39 |
|
|
#elif defined(__FreeBSD__) |
40 |
|
|
|
41 |
|
|
#include <sys/endian.h> |
42 |
|
|
#define bswap_32(x) bswap32(x) |
43 |
|
|
#define bswap_64(x) bswap64(x) |
44 |
|
|
|
45 |
|
|
#elif defined(__OpenBSD__) |
46 |
|
|
|
47 |
|
|
#include <sys/types.h> |
48 |
|
|
#define bswap_32(x) swap32(x) |
49 |
|
|
#define bswap_64(x) swap64(x) |
50 |
|
|
|
51 |
|
|
#elif defined(__NetBSD__) |
52 |
|
|
|
53 |
|
|
#include <sys/types.h> |
54 |
|
|
#include <machine/bswap.h> |
55 |
|
|
#if defined(__BSWAP_RENAME) && !defined(__bswap_32) |
56 |
|
|
#define bswap_32(x) bswap32(x) |
57 |
|
|
#define bswap_64(x) bswap64(x) |
58 |
|
|
#endif |
59 |
|
|
|
60 |
|
|
#else |
61 |
|
|
|
62 |
|
|
#include <byteswap.h> |
63 |
|
|
|
64 |
|
|
#endif |
65 |
|
|
|
66 |
root |
1.23 |
- apply ctz/ld patch for msc by Zsbán Ambrus. |
67 |
root |
1.24 |
- ECB_PTRSIZE erroneously was 8 on most 32bit systems ( |
68 |
|
|
found by Zsbán Ambrus). |
69 |
root |
1.23 |
|
70 |
root |
1.22 |
0x00010005 |
71 |
|
|
- improve ecb_binary16_to_float. |
72 |
|
|
- add ecb_float_to_binary16. |
73 |
|
|
- add ecb_binary16_to_binary32 and ecb_binary32_to_binary16 pair. |
74 |
|
|
|
75 |
root |
1.6 |
0x00010001 |
76 |
|
|
- add ecb_is_pot32/64. |
77 |
|
|
- add intptr_t/uintptr_t. |
78 |
|
|
- add ECB_PTRSIZE. |
79 |
root |
1.7 |
- more macros for C/C++ version checks. |
80 |
|
|
- support C11 atomics for memory fences. |
81 |
|
|
- support gcc-4.7 atomics for memory fences. |
82 |
root |
1.10 |
- support m68k, m88k and sh (patch by Miod Vallat). |
83 |
root |
1.11 |
- add ecb_binary16_to_float. |
84 |
root |
1.6 |
|
85 |
root |
1.9 |
TODO: ecb_restrict_array etc. http://ue.tst.eu/5093eafd713ec5fda776d8065070aa4c.txt |
86 |
sf-exg |
1.20 |
TODO: ffs |
87 |
root |
1.1 |
64 bit variants of everything |
88 |
root |
1.2 |
TODO: examples from X for clz/ctz |
89 |
root |
1.3 |
TODO: arithmetic right shift |
90 |
|
|
TODO: template/generic functions for x32/x64 and so on |
91 |
root |
1.4 |
TODO: #define ecb_integer_multiples_of(n,d) ((char (*)[d])(n) - (char (*)[d])0) |
92 |
root |
1.3 |
TODO: generalised shift |
93 |
root |
1.8 |
TODO: #define ECB_FAST_UNALIGNED_ACCESS |
94 |
root |
1.3 |
unsigned long gensh(unsigned long v, int x) { |
95 |
|
|
int a, b; |
96 |
|
|
a = (v << x) & -(((unsigned int)x) < 32); |
97 |
|
|
x = -x; |
98 |
|
|
b = (v >> x) & -(((unsigned int)x) < 32); |
99 |
|
|
return a|b; |
100 |
|
|
} |
101 |
root |
1.14 |
|
102 |
root |
1.16 |
TODO: export(=dllexport) & hidden |
103 |
|
|
TODO: flatten |
104 |
|
|
TODO: warning(msg) |
105 |
|
|
TODO: error(msg) |
106 |
root |
1.17 |
TODO: leaf (uh), noclone (hmmm) |
107 |
|
|
TODO: nonnull, returns_nonnull |
108 |
|
|
TODO: nothrow |
109 |
|
|
TODO: used |
110 |
|
|
TODO: trap |
111 |
|
|
TODO: http://llvm.org/docs/doxygen/html/Compiler_8h_source.html |
112 |
root |
1.16 |
|
113 |
root |
1.14 |
TODO: read/write unaligned macros |
114 |
|
|
TODO: htonl and friends |
115 |
sf-exg |
1.20 |
TODO: macro to convert from unsigned to signed "the natural way" |
116 |
root |
1.14 |
TODO: ecb_static_assert, with message (just like boost), or somesuch, using array-declaration |
117 |
|
|
TODO: alignof |
118 |
|
|
|
119 |
|
|
|