4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
30 #pragma ident "%Z%%M% %I% %E% SMI"
36 #include <sys/types.h>
39 ((uint32_t)((((uint32_t)(x) & 0x000000ff) << 24) | \
40 (((uint32_t)(x) & 0x0000ff00) << 8) | \
41 (((uint32_t)(x) & 0x00ff0000) >> 8) | \
42 (((uint32_t)(x) & 0xff000000) >> 24)))
45 ((uint16_t)((((uint16_t)(x) & 0x00ff) << 8) | \
46 (((uint16_t)(x) & 0xff00) >> 8)))
51 #if defined(_BIG_ENDIAN)
52 #define CPU_TO_LE32(x) swap32(x)
53 #define CPU_TO_LE16(x) swap16(x)
54 #define CPU_TO_BE32(x) (x)
55 #define CPU_TO_BE16(x) (x)
57 #define CPU_TO_LE32(x) (x)
58 #define CPU_TO_LE16(x) (x)
59 #define CPU_TO_BE32(x) swap32(x)
60 #define CPU_TO_BE16(x) swap16(x)
63 #define LE32_TO_CPU(x) CPU_TO_LE32(x)
64 #define LE16_TO_CPU(x) CPU_TO_LE16(x)
65 #define BE32_TO_CPU(x) CPU_TO_BE32(x)
66 #define BE16_TO_CPU(x) CPU_TO_BE16(x)
72 #endif /* _BYTEORDER_H */