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

Comparing libecb/ecb.h (file contents):
Revision 1.97 by root, Thu May 31 15:47:25 2012 UTC vs.
Revision 1.98 by root, Thu Jun 7 21:25:13 2012 UTC

465 465
466ecb_inline unsigned char ecb_byteorder_helper (void) ecb_const; 466ecb_inline unsigned char ecb_byteorder_helper (void) ecb_const;
467ecb_inline unsigned char 467ecb_inline unsigned char
468ecb_byteorder_helper (void) 468ecb_byteorder_helper (void)
469{ 469{
470 const uint32_t u = 0x11223344; 470 /* the union code still generates code under pressure in gcc, */
471 return *(unsigned char *)&u; 471 /* but less than using pointers, and always seem to */
472 /* successfully return a constant. */
473 /* the reason why we have this horrible preprocessor mess */
474 /* is to avoid it in all cases, at leats on common architectures */
475#if __i386 || __i386__ || _M_X86 || __amd64 || __amd64__ || _M_X64
476 return 0x44;
477#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
478 return 0x44;
479#elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
480 retrurn 0x11;
481#else
482 union
483 {
484 uint32_t i;
485 uint8_t c;
486 } u = { 0x11223344 };
487 return u.c;
488#endif
472} 489}
473 490
474ecb_inline ecb_bool ecb_big_endian (void) ecb_const; 491ecb_inline ecb_bool ecb_big_endian (void) ecb_const;
475ecb_inline ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; } 492ecb_inline ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; }
476ecb_inline ecb_bool ecb_little_endian (void) ecb_const; 493ecb_inline ecb_bool ecb_little_endian (void) ecb_const;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines