2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1992 NeXT Computer, Inc.
25 * Byte ordering conversion (for i386).
29 * 8 October 1992 ? at NeXT
30 * Converted to NXxxx versions. Condensed history.
32 * 18 May 1992 ? at NeXT
42 register unsigned short value
= inv
;
44 __asm__
volatile( "xchgb %h1, %b1" : "=q" (value
) : "0" (value
));
55 register unsigned int outv
= inv
;
57 __asm__
volatile( "bswap %0" : "=r" (outv
) : "0" (outv
));
82 unsigned long long inv
86 unsigned long long ull
;
90 inp
= (union llconv
*)&inv
;
92 outv
.ul
[0] = NXSwapLong(inp
->ul
[1]);
93 outv
.ul
[1] = NXSwapLong(inp
->ul
[0]);
98 static __inline__ NXSwappedFloat
99 NXConvertHostFloatToSwapped(float x
)
105 return ((union fconv
*)&x
)->sf
;
108 static __inline__
float
109 NXConvertSwappedFloatToHost(NXSwappedFloat x
)
115 return ((union fconv
*)&x
)->number
;
118 static __inline__ NXSwappedDouble
119 NXConvertHostDoubleToSwapped(double x
)
125 return ((union dconv
*)&x
)->sd
;
128 static __inline__
double
129 NXConvertSwappedDoubleToHost(NXSwappedDouble x
)
135 return ((union dconv
*)&x
)->number
;
138 static __inline__ NXSwappedFloat
139 NXSwapFloat(NXSwappedFloat x
)
141 return NXSwapLong(x
);
144 static __inline__ NXSwappedDouble
145 NXSwapDouble(NXSwappedDouble x
)
147 return NXSwapLongLong(x
);