source: abuse/trunk/src/net/include/endian.hpp @ 17

Last change on this file since 17 was 17, checked in by Sam Hocevar, 18 years ago
  • absolute shitloads of 64 bit fixes.
File size: 665 bytes
Line 
1#ifndef __INDIANS__HPP_
2#define __INDIANS__HPP_
3
4#error hi
5
6
7#ifdef __linux__
8#include <asm/byteorder.h>
9#endif
10
11#ifdef __sgi
12#include <sys/endian.h>
13#endif
14
15
16
17// these macros swap the "endians" of a word to intel form... this should be done for anything sent
18// across the net as the other computer might have a different endianess
19
20#ifdef BIGUNS
21#define swap_uint16(x) (((((uint16_t) (x)))<<8)|((((uint16_t) (x)))>>8))
22#define swap_uint32(x) \
23   ((( ((uint32_t)(x)) )>>24)|((( ((uint32_t)(x)) )&0x00ff0000)>>8)| \
24   ((( ((uint32_t)(x)) )&0x0000ff00)<<8)|(( ((uint32_t)(x)) )<<24))
25#else
26#define swap_uint16(x) (x)
27#define swap_uint32(x) (x)
28
29#endif
30
31#endif
32
33
34
35
Note: See TracBrowser for help on using the repository browser.