]>
git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/OSCrossEndian.h
0b1e5aa1868160b4c3a71d17f736de29257803c8
2 * Copyright (c) 2000-2006 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@
24 * This private header exports 3 APIs.
25 * _OSRosettaCheck() - An inline function that returns true if we are
26 * currently running under Rosetta.
27 * IF_ROSETTA() - Which is used to as a regular conditional
28 * expression that is true only if the current
29 * code is executing in the Rosetta
31 * ROSETTA_ONLY(exprs) - Which is used to create a block code that only
32 * executes if we are running in Rosetta.
37 * // Do Cross endian swapping of input data
38 * outdata = OSSwap??(indata);
41 * // Do straight through
47 * // Do Cross endian swapping of input data
48 * outdata = OSSwap??(outdata);
52 #ifndef _LIBKERN_OSCROSSENDIAN_H
53 #define _LIBKERN_OSCROSSENDIAN_H
55 #include <sys/sysctl.h>
62 int isCrossEndian
= 0;
64 size_t size
= sizeof val
;
66 if (sysctlbyname("sysctl.proc_native", &val
, &size
, NULL
, 0) == -1)
69 isCrossEndian
= val
? 0 : 1;
76 static __inline__
int _OSRosettaCheck(void) { return 0; }
80 #define IF_ROSETTA() if (__builtin_expect(_OSRosettaCheck(), 0) )
82 #define ROSETTA_ONLY(exprs) \
89 #endif /* _LIBKERN_OSCROSSENDIAN_H */