1 /* Macros to swap the order of bytes in integer values.
2 Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _ASM_BITS_BYTESWAP_H
20 #define _ASM_BITS_BYTESWAP_H 1
22 #define __bswap_non_constant_16(x) \
24 ({ register unsigned short int __v; \
25 __asm__ ("rorw $8, %w0" \
31 /* To swap the bytes in a word the i486 processors and up provide the
32 `bswap' opcode. On i386 we have to use three instructions. */
33 #if !defined __i486__ && !defined __pentium__ && !defined __pentiumpro__ \
34 && !defined __pentium4__
35 # define __bswap_non_constant_32(x) \
37 ({ register unsigned int __v; \
38 __asm__ ("rorw $8, %w0;" \
46 # define __bswap_non_constant_32(x) \
48 ({ register unsigned int __v; \
49 __asm__ ("bswap %0" : "=r" (__v) : "0" (x)); \
55 #include <bits/byteswap-common.h>