]> git.saurik.com Git - apple/libc.git/blob - arm/sys/OSAtomic_resolvers.c
Libc-763.13.tar.gz
[apple/libc.git] / arm / sys / OSAtomic_resolvers.c
1 /*
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*
25 * This holds the C versions of OSAtomic.s resolver functions, used by
26 * everyone except dyld.
27 */
28
29 #include <arm/arch.h>
30 #if defined(_ARM_ARCH_7) && !defined(VARIANT_DYLD)
31
32 #include <stdlib.h>
33 #include <machine/cpu_capabilities.h>
34 #include <mach/machine.h>
35
36 #define makeResolver_up_mp(name) \
37 void name ## $VARIANT$up(void); \
38 void name ## $VARIANT$mp(void); \
39 void* name ## Resolver(void) __asm__( "_" #name ) ; \
40 void* name ## Resolver(void) { \
41 __asm__(".symbol_resolver _" #name); \
42 /* return MP variant functions on kNumCPUs > 1 */ \
43 if ((_get_cpu_capabilities() & kUP) == 0) { \
44 return name ## $VARIANT$mp; \
45 } \
46 return name ## $VARIANT$up; \
47 }
48
49 #define makeResolver_up_mp_wfe(name) \
50 void name ## $VARIANT$up(void); \
51 void name ## $VARIANT$mp(void); \
52 void name ## $VARIANT$wfe(void); \
53 void* name ## Resolver(void) __asm__( "_" #name ) ; \
54 void* name ## Resolver(void) { \
55 __asm__(".symbol_resolver _" #name); \
56 int caps = _get_cpu_capabilities(); \
57 /* return WFE variant if we will get woken up */ \
58 if ((caps & (kHasEvent | kUP)) == kHasEvent) { \
59 return name ## $VARIANT$wfe; \
60 } \
61 /* return MP variant functions on kNumCPUs > 1 */ \
62 else if ((caps & kUP) == 0) { \
63 return name ## $VARIANT$mp; \
64 } \
65 return name ## $VARIANT$up; \
66 }
67
68 #include "OSAtomic_resolvers.h"
69
70 #else // defined _ARM_ARCH_7 && !defined VARIANT_DYLD
71
72 typedef int emptyFilesArentCFiles;
73
74 #endif // defined _ARM_ARCH_7 && !defined VARIANT_DYLD