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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc2/] [newlib/] [libc/] [iconv/] [lib/] [endian.h] - Blame information for rev 520

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 2003-2004, Artem B. Bityuckiy
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
 * SUCH DAMAGE.
24
 */
25
#ifndef __ICONV_CES_ENDIAN_H__
26
#define __ICONV_CES_ENDIAN_H__
27
 
28
#include <sys/param.h>
29
 
30
#if (BYTE_ORDER == LITTLE_ENDIAN)
31
 
32
#  define ICONV_BETOHS(s) \
33
     ((((s) << 8) & 0xFF00) | (((s) >> 8) & 0x00FF))
34
 
35
#  define ICONV_BETOHL(l) \
36
     ((((l) << 24) & 0xFF000000) | \
37
      (((l) <<  8) & 0x00FF0000) | \
38
      (((l) >>  8) & 0x0000FF00) | \
39
      (((l) >> 24) & 0x000000FF))
40
 
41
#  define ICONV_LETOHS(s) (s)
42
#  define ICONV_LETOHL(l) (l)
43
 
44
#  define ICONV_HTOLES(s) ICONV_LETOHS (s)
45
#  define ICONV_HTOLEL(l) ICONV_LETOHL (l)
46
#  define ICONV_HTOBES(s) ICONV_BETOHS (s)
47
#  define ICONV_HTOBEL(l) ICONV_BETOHL (l)
48
 
49
#elif (BYTE_ORDER == BIG_ENDIAN)
50
 
51
#  define ICONV_BETOHS(s) (s)
52
#  define ICONV_BETOHL(l) (l)
53
 
54
#  define ICONV_LETOHS(s) \
55
     ((((s) << 8) & 0xFF00) | (((s) >> 8) & 0x00FF))
56
 
57
#  define ICONV_LETOHL(l) \
58
     ((((l) << 24) & 0xFF000000) | \
59
      (((l) <<  8) & 0x00FF0000) | \
60
      (((l) >>  8) & 0x0000FF00) | \
61
      (((l) >> 24) & 0x000000FF))
62
 
63
#  define ICONV_HTOBES(s) ICONV_BETOHS (s)
64
#  define ICONV_HTOBEL(l) ICONV_BETOHL (l)
65
#  define ICONV_HTOLES(s) ICONV_LETOHS (s)
66
#  define ICONV_HTOLEL(l) ICONV_LETOHL (l)
67
 
68
#else
69
#  error "Unknown byte order."
70
#endif
71
 
72
#endif /* !__ICONV_CES_ENDIAN_H__ */
73
 

powered by: WebSVN 2.1.0

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