2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1992 NeXT Computer, Inc.
28 * Byte ordering conversion (for i386).
32 * 8 October 1992 ? at NeXT
33 * Converted to NXxxx versions. Condensed history.
35 * 18 May 1992 ? at NeXT
45 register unsigned short value
= inv
;
47 __asm__
volatile( "xchgb %h1, %b1" : "=q" (value
) : "0" (value
));
58 register unsigned int outv
= inv
;
60 __asm__
volatile( "bswap %0" : "=r" (outv
) : "0" (outv
));
85 unsigned long long inv
89 unsigned long long ull
;
93 inp
= (union llconv
*)&inv
;
95 outv
.ul
[0] = NXSwapLong(inp
->ul
[1]);
96 outv
.ul
[1] = NXSwapLong(inp
->ul
[0]);
101 static __inline__ NXSwappedFloat
102 NXConvertHostFloatToSwapped(float x
)
108 return ((union fconv
*)&x
)->sf
;
111 static __inline__
float
112 NXConvertSwappedFloatToHost(NXSwappedFloat x
)
118 return ((union fconv
*)&x
)->number
;
121 static __inline__ NXSwappedDouble
122 NXConvertHostDoubleToSwapped(double x
)
128 return ((union dconv
*)&x
)->sd
;
131 static __inline__
double
132 NXConvertSwappedDoubleToHost(NXSwappedDouble x
)
138 return ((union dconv
*)&x
)->number
;
141 static __inline__ NXSwappedFloat
142 NXSwapFloat(NXSwappedFloat x
)
144 return NXSwapLong(x
);
147 static __inline__ NXSwappedDouble
148 NXSwapDouble(NXSwappedDouble x
)
150 return NXSwapLongLong(x
);