ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libecb/ecb.h
(Generate patch)

Comparing libecb/ecb.h (file contents):
Revision 1.109 by root, Fri Jun 29 14:05:50 2012 UTC vs.
Revision 1.115 by root, Wed Dec 19 23:51:24 2012 UTC

29 29
30#ifndef ECB_H 30#ifndef ECB_H
31#define ECB_H 31#define ECB_H
32 32
33/* 16 bits major, 16 bits minor */ 33/* 16 bits major, 16 bits minor */
34#define ECB_VERSION 0x00010001 34#define ECB_VERSION 0x00010003
35 35
36#ifdef _WIN32 36#ifdef _WIN32
37 typedef signed char int8_t; 37 typedef signed char int8_t;
38 typedef unsigned char uint8_t; 38 typedef unsigned char uint8_t;
39 typedef signed short int16_t; 39 typedef signed short int16_t;
60 #include <inttypes.h> 60 #include <inttypes.h>
61 #if UINTMAX_MAX > 0xffffffffU 61 #if UINTMAX_MAX > 0xffffffffU
62 #define ECB_PTRSIZE 8 62 #define ECB_PTRSIZE 8
63 #else 63 #else
64 #define ECB_PTRSIZE 4 64 #define ECB_PTRSIZE 4
65 #endif
66#endif
67
68/* work around x32 idiocy by defining proper macros */
69#if __x86_64 || _M_AMD64
70 #if __ILP32
71 #define ECB_AMD64_X32 1
72 #else
73 #define ECB_AMD64 1
65 #endif 74 #endif
66#endif 75#endif
67 76
68/* many compilers define _GNUC_ to some versions but then only implement 77/* many compilers define _GNUC_ to some versions but then only implement
69 * what their idiot authors think are the "more important" extensions, 78 * what their idiot authors think are the "more important" extensions,
148 157
149#ifndef ECB_MEMORY_FENCE 158#ifndef ECB_MEMORY_FENCE
150 #if ECB_GCC_VERSION(4,7) 159 #if ECB_GCC_VERSION(4,7)
151 /* see comment below (stdatomic.h) about the C11 memory model. */ 160 /* see comment below (stdatomic.h) about the C11 memory model. */
152 #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST) 161 #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST)
162
163 /* The __has_feature syntax from clang is so misdesigned that we cannot use it
164 * without risking compile time errors with other compilers. We *could*
165 * define our own ecb_clang_has_feature, but I just can't be bothered to work
166 * around this shit time and again.
153 /*#elif defined __clang && __has_feature (cxx_atomic)*/ 167 * #elif defined __clang && __has_feature (cxx_atomic)
154 /* see comment below (stdatomic.h) about the C11 memory model. */ 168 * // see comment below (stdatomic.h) about the C11 memory model.
155 /*#define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST)*/ 169 * #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST)
170 */
171
156 #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__ 172 #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__
157 #define ECB_MEMORY_FENCE __sync_synchronize () 173 #define ECB_MEMORY_FENCE __sync_synchronize ()
158 #elif _MSC_VER >= 1400 /* VC++ 2005 */ 174 #elif _MSC_VER >= 1400 /* VC++ 2005 */
159 #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier) 175 #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier)
160 #define ECB_MEMORY_FENCE _ReadWriteBarrier () 176 #define ECB_MEMORY_FENCE _ReadWriteBarrier ()
475ecb_inline unsigned char ecb_byteorder_helper (void) ecb_const; 491ecb_inline unsigned char ecb_byteorder_helper (void) ecb_const;
476ecb_inline unsigned char 492ecb_inline unsigned char
477ecb_byteorder_helper (void) 493ecb_byteorder_helper (void)
478{ 494{
479 /* the union code still generates code under pressure in gcc, */ 495 /* the union code still generates code under pressure in gcc, */
480 /* but less than using pointers, and always seem to */ 496 /* but less than using pointers, and always seems to */
481 /* successfully return a constant. */ 497 /* successfully return a constant. */
482 /* the reason why we have this horrible preprocessor mess */ 498 /* the reason why we have this horrible preprocessor mess */
483 /* is to avoid it in all cases, at least on common architectures */ 499 /* is to avoid it in all cases, at least on common architectures */
484 /* and yes, gcc defines __BYTE_ORDER__, g++ does not */ 500 /* or when using a recent enough gcc version (>= 4.6) */
485#if __i386 || __i386__ || _M_X86 || __amd64 || __amd64__ || _M_X64 501#if __i386 || __i386__ || _M_X86 || __amd64 || __amd64__ || _M_X64
486 return 0x44; 502 return 0x44;
487#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 503#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
488 return 0x44; 504 return 0x44;
489#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 505#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
490 retrurn 0x11; 506 return 0x11;
491#else 507#else
492 union 508 union
493 { 509 {
494 uint32_t i; 510 uint32_t i;
495 uint8_t c; 511 uint8_t c;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines