1
/* From the mplayer project (www.mplayerhq.hu) */
1
/*****************************************************************************
2
* Copyright (C) 2002 Shie Erlich <erlich@users.sourceforge.net> *
3
* Copyright (C) 2002 Rafi Yanai <yanai@users.sourceforge.net> *
4
* From the mplayer project (www.mplayerhq.hu) *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This package is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this package; if not, write to the Free Software *
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19
*****************************************************************************/
24
/* this file doesn't exist
6
25
#ifdef HAVE_CONFIG_H
10
30
#ifdef HAVE_BYTESWAP_H
11
31
#include <byteswap.h>
24
44
inline static unsigned int ByteSwap32(unsigned int x)
30
__asm("xchgb %b0,%h0\n"
50
__asm("xchgb %b0,%h0\n"
38
58
#define bswap_32(x) ByteSwap32(x)
40
inline static unsigned long long int ByteSwap64(unsigned long long int x)
60
inline static unsigned long long int ByteSwap64(unsigned long long int x)
42
register union { __extension__ unsigned long long int __ll;
43
unsigned int __l[2]; } __x;
45
"=r"(__x.__l[0]),"=r"(__x.__l[1]):
46
"0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
62
register union { __extension__ unsigned long long int __ll;
66
"=r"(__x.__l[0]), "=r"(__x.__l[1]):
67
"0"(bswap_32((unsigned long)x)), "1"(bswap_32((unsigned long)(x >> 32))));
49
70
#define bswap_64(x) ByteSwap64(x)
53
74
#define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8)
56
77
/* code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc. */
57
78
#define bswap_32(x) \
58
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
59
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
79
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
80
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
61
82
#define bswap_64(x) \
63
({ union { __extension__ unsigned long long int __ll; \
64
unsigned int __l[2]; } __w, __r; \
66
__r.__l[0] = bswap_32 (__w.__l[1]); \
67
__r.__l[1] = bswap_32 (__w.__l[0]); \
69
#endif /* !ARCH_X86 */
84
({ union { __extension__ unsigned long long int __ll; \
85
unsigned int __l[2]; } __w, __r; \
87
__r.__l[0] = bswap_32 (__w.__l[1]); \
88
__r.__l[1] = bswap_32 (__w.__l[0]); \
90
#endif /* !ARCH_X86 */
71
#endif /* !HAVE_BYTESWAP_H */
92
#endif /* !HAVE_BYTESWAP_H */
74
95
be2me ... BigEndian to MachineEndian