File: endian.h

package info (click to toggle)
arcload 0.5-7
  • links: PTS
  • area: main
  • in suites: lenny, squeeze, wheezy
  • size: 504 kB
  • ctags: 1,651
  • sloc: ansic: 7,471; sh: 1,162; makefile: 127; asm: 30
file content (24 lines) | stat: -rw-r--r-- 458 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * ARCload (c) 2005 Stanislaw Skowronek
 */

#ifndef ENDIAN_H
#define ENDIAN_H

#include <endian.h>

void swap32(unsigned int *x)
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
	*x = (((*x >> 16) & 0x0000FFFF) | ((*x << 16) & 0xFFFF0000));
	*x = (((*x >> 8) & 0x00FF00FF) | ((*x << 8) & 0xFF00FF00));
#endif
}
void swap16(unsigned short *x)
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
	*x = (((*x >> 8) & 0x00FF) | ((*x << 8) & 0xFF00));
#endif
}

#endif /* ENDIAN_H */