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) 1996 NeXT Software, Inc.
25 * Byte ordering conversion (for ppc).
29 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
32 * 8 October 1992 ? at NeXT
33 * Converted to NXxxx versions. Condensed history.
35 * 28 August 1992 Bruce Martin @NeXT
50 inp
= (union sconv
*)&inv
;
52 outv
.uc
[0] = inp
->uc
[1];
53 outv
.uc
[1] = inp
->uc
[0];
69 inp
= (union iconv
*)&inv
;
71 outv
.uc
[0] = inp
->uc
[3];
72 outv
.uc
[1] = inp
->uc
[2];
73 outv
.uc
[2] = inp
->uc
[1];
74 outv
.uc
[3] = inp
->uc
[0];
90 inp
= (union lconv
*)&inv
;
92 outv
.uc
[0] = inp
->uc
[3];
93 outv
.uc
[1] = inp
->uc
[2];
94 outv
.uc
[2] = inp
->uc
[1];
95 outv
.uc
[3] = inp
->uc
[0];
103 unsigned long long inv
107 unsigned long long ull
;
111 inp
= (union llconv
*)&inv
;
113 outv
.uc
[0] = inp
->uc
[7];
114 outv
.uc
[1] = inp
->uc
[6];
115 outv
.uc
[2] = inp
->uc
[5];
116 outv
.uc
[3] = inp
->uc
[4];
117 outv
.uc
[4] = inp
->uc
[3];
118 outv
.uc
[5] = inp
->uc
[2];
119 outv
.uc
[6] = inp
->uc
[1];
120 outv
.uc
[7] = inp
->uc
[0];
127 static __inline__ NXSwappedFloat
128 NXConvertHostFloatToSwapped(float x
)
134 return ((union fconv
*)&x
)->sf
;
137 static __inline__
float
138 NXConvertSwappedFloatToHost(NXSwappedFloat x
)
144 return ((union fconv
*)&x
)->number
;
147 static __inline__ NXSwappedDouble
148 NXConvertHostDoubleToSwapped(double x
)
154 return ((union dconv
*)&x
)->sd
;
157 static __inline__
double
158 NXConvertSwappedDoubleToHost(NXSwappedDouble x
)
164 return ((union dconv
*)&x
)->number
;
167 static __inline__ NXSwappedFloat
168 NXSwapFloat(NXSwappedFloat x
)
170 return NXSwapLong(x
);
173 static __inline__ NXSwappedDouble
174 NXSwapDouble(NXSwappedDouble x
)
176 return NXSwapLongLong(x
);
179 #endif /* ! KERNEL */