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

Comparing libeio/ecb.h (file contents):
Revision 1.15 by root, Wed Jul 25 16:12:28 2012 UTC vs.
Revision 1.17 by root, Fri Dec 28 07:33:41 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 0x00010002 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,
152 #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST) 161 #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST)
153 162
154 /* The __has_feature syntax from clang is so misdesigned that we cannot use it 163 /* The __has_feature syntax from clang is so misdesigned that we cannot use it
155 * without risking compile time errors with other compilers. We *could* 164 * without risking compile time errors with other compilers. We *could*
156 * define our own ecb_clang_has_feature, but I just can't be bothered to work 165 * define our own ecb_clang_has_feature, but I just can't be bothered to work
157 * around * this shit time and again. 166 * around this shit time and again.
158 * #elif defined __clang && __has_feature (cxx_atomic) 167 * #elif defined __clang && __has_feature (cxx_atomic)
159 * // see comment below (stdatomic.h) about the C11 memory model. 168 * // see comment below (stdatomic.h) about the C11 memory model.
160 * #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST) 169 * #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST)
161 */ 170 */
162 171
482ecb_inline unsigned char ecb_byteorder_helper (void) ecb_const; 491ecb_inline unsigned char ecb_byteorder_helper (void) ecb_const;
483ecb_inline unsigned char 492ecb_inline unsigned char
484ecb_byteorder_helper (void) 493ecb_byteorder_helper (void)
485{ 494{
486 /* the union code still generates code under pressure in gcc, */ 495 /* the union code still generates code under pressure in gcc, */
487 /* but less than using pointers, and always seem to */ 496 /* but less than using pointers, and always seems to */
488 /* successfully return a constant. */ 497 /* successfully return a constant. */
489 /* the reason why we have this horrible preprocessor mess */ 498 /* the reason why we have this horrible preprocessor mess */
490 /* 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 */
491 /* and yes, gcc defines __BYTE_ORDER__, g++ does not */ 500 /* or when using a recent enough gcc version (>= 4.6) */
492#if __i386 || __i386__ || _M_X86 || __amd64 || __amd64__ || _M_X64 501#if __i386 || __i386__ || _M_X86 || __amd64 || __amd64__ || _M_X64
493 return 0x44; 502 return 0x44;
494#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 503#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
495 return 0x44; 504 return 0x44;
496#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 505#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
497 retrurn 0x11; 506 return 0x11;
498#else 507#else
499 union 508 union
500 { 509 {
501 uint32_t i; 510 uint32_t i;
502 uint8_t c; 511 uint8_t c;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines