2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1996 NeXT Software, Inc.
31 * Byte ordering conversion (for ppc).
45 inp
= (union sconv
*)&inv
;
47 outv
.uc
[0] = inp
->uc
[1];
48 outv
.uc
[1] = inp
->uc
[0];
64 inp
= (union iconv
*)&inv
;
66 outv
.uc
[0] = inp
->uc
[3];
67 outv
.uc
[1] = inp
->uc
[2];
68 outv
.uc
[2] = inp
->uc
[1];
69 outv
.uc
[3] = inp
->uc
[0];
77 unsigned long long inv
81 unsigned long long ull
;
85 inp
= (union llconv
*)&inv
;
87 outv
.uc
[0] = inp
->uc
[7];
88 outv
.uc
[1] = inp
->uc
[6];
89 outv
.uc
[2] = inp
->uc
[5];
90 outv
.uc
[3] = inp
->uc
[4];
91 outv
.uc
[4] = inp
->uc
[3];
92 outv
.uc
[5] = inp
->uc
[2];
93 outv
.uc
[6] = inp
->uc
[1];
94 outv
.uc
[7] = inp
->uc
[0];
112 inp
= (union llconv
*)&inv
;
114 outv
.uc
[0] = inp
->uc
[7];
115 outv
.uc
[1] = inp
->uc
[6];
116 outv
.uc
[2] = inp
->uc
[5];
117 outv
.uc
[3] = inp
->uc
[4];
118 outv
.uc
[4] = inp
->uc
[3];
119 outv
.uc
[5] = inp
->uc
[2];
120 outv
.uc
[6] = inp
->uc
[1];
121 outv
.uc
[7] = inp
->uc
[0];
139 inp
= (union lconv
*)&inv
;
141 outv
.uc
[0] = inp
->uc
[3];
142 outv
.uc
[1] = inp
->uc
[2];
143 outv
.uc
[2] = inp
->uc
[1];
144 outv
.uc
[3] = inp
->uc
[0];
149 #endif /* __LP64__ */
153 static __inline__ NXSwappedFloat
154 NXConvertHostFloatToSwapped(float x
)
160 return ((union fconv
*)&x
)->sf
;
163 static __inline__
float
164 NXConvertSwappedFloatToHost(NXSwappedFloat x
)
170 return ((union fconv
*)&x
)->number
;
173 static __inline__ NXSwappedDouble
174 NXConvertHostDoubleToSwapped(double x
)
180 return ((union dconv
*)&x
)->sd
;
183 static __inline__
double
184 NXConvertSwappedDoubleToHost(NXSwappedDouble x
)
190 return ((union dconv
*)&x
)->number
;
193 static __inline__ NXSwappedFloat
194 NXSwapFloat(NXSwappedFloat x
)
196 return NXSwapLong(x
);
199 static __inline__ NXSwappedDouble
200 NXSwapDouble(NXSwappedDouble x
)
202 return NXSwapLongLong(x
);
205 #endif /* ! KERNEL */