2 * Copyright (c) 2000-2004 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) 1996 NeXT Software, Inc.
25 * Byte ordering conversion (for ppc).
39 inp
= (union sconv
*)&inv
;
41 outv
.uc
[0] = inp
->uc
[1];
42 outv
.uc
[1] = inp
->uc
[0];
58 inp
= (union iconv
*)&inv
;
60 outv
.uc
[0] = inp
->uc
[3];
61 outv
.uc
[1] = inp
->uc
[2];
62 outv
.uc
[2] = inp
->uc
[1];
63 outv
.uc
[3] = inp
->uc
[0];
71 unsigned long long inv
75 unsigned long long ull
;
79 inp
= (union llconv
*)&inv
;
81 outv
.uc
[0] = inp
->uc
[7];
82 outv
.uc
[1] = inp
->uc
[6];
83 outv
.uc
[2] = inp
->uc
[5];
84 outv
.uc
[3] = inp
->uc
[4];
85 outv
.uc
[4] = inp
->uc
[3];
86 outv
.uc
[5] = inp
->uc
[2];
87 outv
.uc
[6] = inp
->uc
[1];
88 outv
.uc
[7] = inp
->uc
[0];
106 inp
= (union llconv
*)&inv
;
108 outv
.uc
[0] = inp
->uc
[7];
109 outv
.uc
[1] = inp
->uc
[6];
110 outv
.uc
[2] = inp
->uc
[5];
111 outv
.uc
[3] = inp
->uc
[4];
112 outv
.uc
[4] = inp
->uc
[3];
113 outv
.uc
[5] = inp
->uc
[2];
114 outv
.uc
[6] = inp
->uc
[1];
115 outv
.uc
[7] = inp
->uc
[0];
133 inp
= (union lconv
*)&inv
;
135 outv
.uc
[0] = inp
->uc
[3];
136 outv
.uc
[1] = inp
->uc
[2];
137 outv
.uc
[2] = inp
->uc
[1];
138 outv
.uc
[3] = inp
->uc
[0];
143 #endif /* __LP64__ */
147 static __inline__ NXSwappedFloat
148 NXConvertHostFloatToSwapped(float x
)
154 return ((union fconv
*)&x
)->sf
;
157 static __inline__
float
158 NXConvertSwappedFloatToHost(NXSwappedFloat x
)
164 return ((union fconv
*)&x
)->number
;
167 static __inline__ NXSwappedDouble
168 NXConvertHostDoubleToSwapped(double x
)
174 return ((union dconv
*)&x
)->sd
;
177 static __inline__
double
178 NXConvertSwappedDoubleToHost(NXSwappedDouble x
)
184 return ((union dconv
*)&x
)->number
;
187 static __inline__ NXSwappedFloat
188 NXSwapFloat(NXSwappedFloat x
)
190 return NXSwapLong(x
);
193 static __inline__ NXSwappedDouble
194 NXSwapDouble(NXSwappedDouble x
)
196 return NXSwapLongLong(x
);
199 #endif /* ! KERNEL */