Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libc / iconv / lib / endian.h
blob2db6c6df9c2bd8a552b1745fd9e4867d3d547b7a
1 /*
2 * Copyright (c) 2003-2004, Artem B. Bityuckiy
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.
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.
25 #ifndef __ICONV_CES_ENDIAN_H__
26 #define __ICONV_CES_ENDIAN_H__
28 #include <sys/param.h>
30 #if (BYTE_ORDER == LITTLE_ENDIAN)
32 # define ICONV_BETOHS(s) \
33 ((((s) << 8) & 0xFF00) | (((s) >> 8) & 0x00FF))
35 # define ICONV_BETOHL(l) \
36 ((((l) << 24) & 0xFF000000) | \
37 (((l) << 8) & 0x00FF0000) | \
38 (((l) >> 8) & 0x0000FF00) | \
39 (((l) >> 24) & 0x000000FF))
41 # define ICONV_LETOHS(s) (s)
42 # define ICONV_LETOHL(l) (l)
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)
49 #elif (BYTE_ORDER == BIG_ENDIAN)
51 # define ICONV_BETOHS(s) (s)
52 # define ICONV_BETOHL(l) (l)
54 # define ICONV_LETOHS(s) \
55 ((((s) << 8) & 0xFF00) | (((s) >> 8) & 0x00FF))
57 # define ICONV_LETOHL(l) \
58 ((((l) << 24) & 0xFF000000) | \
59 (((l) << 8) & 0x00FF0000) | \
60 (((l) >> 8) & 0x0000FF00) | \
61 (((l) >> 24) & 0x000000FF))
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)
68 #else
69 # error "Unknown byte order."
70 #endif
72 #endif /* !__ICONV_CES_ENDIAN_H__ */