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) 1996 NeXT Software, Inc.
28 * Byte ordering conversion (for ppc).
32 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
35 * 8 October 1992 ? at NeXT
36 * Converted to NXxxx versions. Condensed history.
38 * 28 August 1992 Bruce Martin @NeXT
53 inp
= (union sconv
*)&inv
;
55 outv
.uc
[0] = inp
->uc
[1];
56 outv
.uc
[1] = inp
->uc
[0];
72 inp
= (union iconv
*)&inv
;
74 outv
.uc
[0] = inp
->uc
[3];
75 outv
.uc
[1] = inp
->uc
[2];
76 outv
.uc
[2] = inp
->uc
[1];
77 outv
.uc
[3] = inp
->uc
[0];
93 inp
= (union lconv
*)&inv
;
95 outv
.uc
[0] = inp
->uc
[3];
96 outv
.uc
[1] = inp
->uc
[2];
97 outv
.uc
[2] = inp
->uc
[1];
98 outv
.uc
[3] = inp
->uc
[0];
106 unsigned long long inv
110 unsigned long long ull
;
114 inp
= (union llconv
*)&inv
;
116 outv
.uc
[0] = inp
->uc
[7];
117 outv
.uc
[1] = inp
->uc
[6];
118 outv
.uc
[2] = inp
->uc
[5];
119 outv
.uc
[3] = inp
->uc
[4];
120 outv
.uc
[4] = inp
->uc
[3];
121 outv
.uc
[5] = inp
->uc
[2];
122 outv
.uc
[6] = inp
->uc
[1];
123 outv
.uc
[7] = inp
->uc
[0];
130 static __inline__ NXSwappedFloat
131 NXConvertHostFloatToSwapped(float x
)
137 return ((union fconv
*)&x
)->sf
;
140 static __inline__
float
141 NXConvertSwappedFloatToHost(NXSwappedFloat x
)
147 return ((union fconv
*)&x
)->number
;
150 static __inline__ NXSwappedDouble
151 NXConvertHostDoubleToSwapped(double x
)
157 return ((union dconv
*)&x
)->sd
;
160 static __inline__
double
161 NXConvertSwappedDoubleToHost(NXSwappedDouble x
)
167 return ((union dconv
*)&x
)->number
;
170 static __inline__ NXSwappedFloat
171 NXSwapFloat(NXSwappedFloat x
)
173 return NXSwapLong(x
);
176 static __inline__ NXSwappedDouble
177 NXSwapDouble(NXSwappedDouble x
)
179 return NXSwapLongLong(x
);
182 #endif /* ! KERNEL */