source: abuse/tags/pd/macabuse/src/net/unix/endian.hpp @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 11 years ago
  • Imported original public domain release, for future reference.
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.