]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/machine/OSByteOrder.h
b85d69b9ac5abff5ba5fca2702158b68053bbd21
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) 1999 Apple Computer, Inc. All rights reserved.
33 #ifndef _OS_OSBYTEORDERMACHINE_H
34 #define _OS_OSBYTEORDERMACHINE_H
36 #include <libkern/OSTypes.h>
38 /* Functions for byte reversed loads. */
51 inp
= (union sconv
*)((UInt8
*)base
+ offset
);
52 outv
.uc
[0] = inp
->uc
[1];
53 outv
.uc
[1] = inp
->uc
[0];
68 inp
= (union lconv
*)((UInt8
*)base
+ offset
);
69 outv
.uc
[0] = inp
->uc
[3];
70 outv
.uc
[1] = inp
->uc
[2];
71 outv
.uc
[2] = inp
->uc
[1];
72 outv
.uc
[3] = inp
->uc
[0];
87 inp
= (union llconv
*)((UInt8
*)base
+ offset
);
88 outv
.uc
[0] = inp
->uc
[7];
89 outv
.uc
[1] = inp
->uc
[6];
90 outv
.uc
[2] = inp
->uc
[5];
91 outv
.uc
[3] = inp
->uc
[4];
92 outv
.uc
[4] = inp
->uc
[3];
93 outv
.uc
[5] = inp
->uc
[2];
94 outv
.uc
[6] = inp
->uc
[1];
95 outv
.uc
[7] = inp
->uc
[0];
102 volatile void * base
,
106 return (UInt
)OSReadSwapInt32(base
, offset
);
109 /* Functions for byte reversed stores. */
114 volatile void * base
,
123 inp
= (union sconv
*)((UInt8
*)base
+ offset
);
124 outp
= (union sconv
*)&data
;
125 outp
->uc
[0] = inp
->uc
[1];
126 outp
->uc
[1] = inp
->uc
[0];
132 volatile void * base
,
141 inp
= (union lconv
*)((UInt8
*)base
+ offset
);
142 outp
= (union lconv
*)&data
;
143 outp
->uc
[0] = inp
->uc
[3];
144 outp
->uc
[1] = inp
->uc
[2];
145 outp
->uc
[2] = inp
->uc
[1];
146 outp
->uc
[3] = inp
->uc
[0];
152 volatile void * base
,
161 inp
= (union llconv
*)((UInt8
*)base
+ offset
);
162 outp
= (union llconv
*)&data
;
163 outp
->uc
[0] = inp
->uc
[7];
164 outp
->uc
[1] = inp
->uc
[6];
165 outp
->uc
[2] = inp
->uc
[5];
166 outp
->uc
[3] = inp
->uc
[4];
167 outp
->uc
[4] = inp
->uc
[3];
168 outp
->uc
[5] = inp
->uc
[2];
169 outp
->uc
[6] = inp
->uc
[1];
170 outp
->uc
[7] = inp
->uc
[0];
176 volatile void * base
,
181 OSWriteSwapInt32(base
, offset
, (UInt32
)data
);
184 /* Generic byte swapping functions. */
193 return OSReadSwapInt16(&temp
, 0);
203 return OSReadSwapInt32(&temp
, 0);
213 return OSReadSwapInt64(&temp
, 0);
223 return OSReadSwapInt(&temp
, 0);
226 #endif /* ! _OS_OSBYTEORDERMACHINE_H */