summaryrefslogtreecommitdiffstats
path: root/rtemsbsd/freebsd/machine/endian.h
blob: 1b8128da4cc83a436d9274917a7d9760031ff884 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * @file
 *
 * @ingroup rtems_bsd_machine
 *
 * @brief TODO.
 */

/*
 * Copyright (c) 2009, 2010 embedded brains GmbH.  All rights reserved.
 *
 *  embedded brains GmbH
 *  Obere Lagerstr. 30
 *  82178 Puchheim
 *  Germany
 *  <rtems@embedded-brains.de>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.com/license/LICENSE.
 */

#ifndef _RTEMS_BSD_MACHINE_ENDIAN_H
#define _RTEMS_BSD_MACHINE_ENDIAN_H

#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_CONFIG_H_
#error "the header file <freebsd/machine/rtems-bsd-config.h> must be included first"
#endif

#include <rtems/endian.h>

#if CPU_BIG_ENDIAN
# define _BYTE_ORDER _BIG_ENDIAN
#elif CPU_LITTLE_ENDIAN
# define _BYTE_ORDER _LITTLE_ENDIAN
#else
# error "undefined endian"
#endif

#define __bswap16(x) CPU_swap_u16(x)
#define __bswap32(x) CPU_swap_u32(x)

#define __htonl(x)  __bswap32(x)
#define __htons(x)  __bswap16(x)
#define __ntohl(x)  __bswap32(x)
#define __ntohs(x)  __bswap16(x)

#endif /* _RTEMS_BSD_MACHINE_ENDIAN_H */