OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libnetworking/] [machine/] [endian.h] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  endian.h,v 1.3 2002/07/30 23:31:00 joel Exp
3
 */
4
 
5
#ifndef _MACHINE_ENDIAN_H_
6
#define _MACHINE_ENDIAN_H_
7
 
8
#include <rtems.h>
9
 
10
/*
11
 * BSD-style endian declaration
12
 */
13
#define BIG_ENDIAN      4321
14
#define LITTLE_ENDIAN   1234
15
 
16
#if CPU_BIG_ENDIAN
17
# define BYTE_ORDER BIG_ENDIAN
18
#elif CPU_LITTLE_ENDIAN
19
# define BYTE_ORDER LITTLE_ENDIAN
20
#else
21
# error "Can't decide which end is which!"
22
#endif
23
 
24
#if ( CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES == FALSE )
25
 
26
#if ( CPU_BIG_ENDIAN == TRUE )
27
 
28
/*
29
 *  Very simply on big endian CPUs
30
 */
31
 
32
#define       ntohl(_x)        (_x)
33
#define       ntohs(_x)        (_x)
34
#define       htonl(_x)        (_x)
35
#define       htons(_x)        (_x)
36
 
37
#define NTOHS(x)
38
#define HTONS(x)
39
#define NTOHL(x)
40
#define HTONL(x)
41
 
42
#elif ( CPU_LITTLE_ENDIAN == TRUE )
43
 
44
/*
45
 *  A little more complicated on little endian CPUs
46
 */
47
 
48
#define       ntohl(_x)        ((long)  CPU_swap_u32((unsigned32)_x))
49
#define       ntohs(_x)        ((short) CPU_swap_u16((unsigned16)_x))
50
#define       htonl(_x)        ((long)  CPU_swap_u32((unsigned32)_x))
51
#define       htons(_x)        ((short) CPU_swap_u16((unsigned16)_x))
52
 
53
#define NTOHS(x) (x) = ntohs(x)
54
#define HTONS(x) (x) = htons(x)
55
#define NTOHL(x) (x) = ntohl(x)
56
#define HTONL(x) (x) = htonl(x)
57
 
58
#else
59
#error "Unknown endian-ness for this cpu"
60
#endif
61
 
62
#endif  /* CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES */
63
 
64
#endif /* _MACHINE_ENDIAN_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.