1
/* -*- buffer-read-only: t -*- vi: set ro: */
2
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3
/* byteswap.h - Byte swapping
4
Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc.
5
Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
7
This program is free software: you can redistribute it and/or modify
8
it under the terms of the GNU Lesser General Public License as published by
9
the Free Software Foundation; either version 2.1 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
#ifndef _GL_BYTESWAP_H
21
#define _GL_BYTESWAP_H
23
/* Given an unsigned 16-bit argument X, return the value corresponding to
24
X with reversed byte order. */
25
#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
26
(((x) & 0xFF00) >> 8))
28
/* Given an unsigned 32-bit argument X, return the value corresponding to
29
X with reversed byte order. */
30
#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
31
(((x) & 0x0000FF00) << 8) | \
32
(((x) & 0x00FF0000) >> 8) | \
33
(((x) & 0xFF000000) >> 24))
35
/* Given an unsigned 64-bit argument X, return the value corresponding to
36
X with reversed byte order. */
37
#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
38
(((x) & 0x000000000000FF00ULL) << 40) | \
39
(((x) & 0x0000000000FF0000ULL) << 24) | \
40
(((x) & 0x00000000FF000000ULL) << 8) | \
41
(((x) & 0x000000FF00000000ULL) >> 8) | \
42
(((x) & 0x0000FF0000000000ULL) >> 24) | \
43
(((x) & 0x00FF000000000000ULL) >> 40) | \
44
(((x) & 0xFF00000000000000ULL) >> 56))
46
#endif /* _GL_BYTESWAP_H */