*** empty log message ***
[mmondor.git] / tests / bktr_httpd / endian.h
CommitLineData
811ad35c
MM
1/* $Id: endian.h,v 1.1 2008/02/05 17:01:11 mmondor Exp $ */
2
3/*
4 * Copyright (C) 2004, Matthew Mondor
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Matthew Mondor.
18 * 4. The name of Matthew Mondor may not be used to endorse or promote
19 * products derived from this software without specific prior written
20 * permission.
21 * 5. Redistribution of source code may not be released under the terms of
22 * any GNU Public License derivate.
23 *
24 * THIS SOFTWARE IS PROVIDED BY MATTHEW MONDOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL MATTHEW MONDOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36
37#ifndef _MM_ENDIAN_H_
38#define _MM_ENDIAN_H_
39
40
41#include <stdint.h>
42
43
44#if BYTE_ORDER == LITTLE_ENDIAN
45
46/* Little endian is not network order, we need conversions */
47#define BYTEORDER_NETWORK16 byteorder_bswap16
48#define BYTEORDER_HOST16 byteorder_bswap16
49#define BYTEORDER_NETWORK32 byteorder_bswap32
50#define BYTEORDER_HOST32 byteorder_bswap32
51#define BYTEORDER_NETWORK64 byteorder_bswap64
52#define BYTEORDER_HOST64 byteorder_bswap64
53
54extern uint16_t byteorder_bswap16(uint16_t);
55extern uint32_t byteorder_bswap32(uint32_t);
56extern uint64_t byteorder_bswap64(uint64_t);
57
58#elif BYTE_ORDER == BIG_ENDIAN
59
60/* Big endian is network order, no need to do anything */
61#define BYTEORDER_NETWORK16(w) (w)
62#define BYTEORDER_HOST16(w) (w)
63#define BYTEORDER_NETWORK32(w) (w)
64#define BYTEORDER_HOST32(w) (w)
65#define BYTEORDER_NETWORK64(w) (w)
66#define BYTEORDER_HOST64(w) (w)
67
68#else
69error "Undefined byte order";
70#endif
71
72
73#endif