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

Last change on this file since 2 was 2, checked in by Sam Hocevar, 14 years ago
  • imported original 0.7.0 tarball
File size: 720 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_short(x) (((((unsigned short) (x)))<<8)|((((unsigned short) (x)))>>8))
22#define swap_long(x) \
23   ((( ((unsigned long)(x)) )>>24)|((( ((unsigned long)(x)) )&0x00ff0000)>>8)| \
24   ((( ((unsigned long)(x)) )&0x0000ff00)<<8)|(( ((unsigned long)(x)) )<<24))
25#else
26#define swap_short(x) (x)
27#define swap_long(x) (x)
28
29#endif
30
31#define uchar unsigned char
32
33#endif
34
35
36
37
Note: See TracBrowser for help on using the repository browser.