]>
git.saurik.com Git - apple/libc.git/blob - arm/sys/OSAtomic_resolvers.c
28ad04fae96a6eb6776b3ff5138aefb230cfc43c
2 * Copyright (c) 2010 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 * This holds the C versions of OSAtomic.s resolver functions, used by
26 * everyone except dyld.
30 #if defined(_ARM_ARCH_7)
33 #include <machine/cpu_capabilities.h>
34 #include <mach/machine.h>
36 #if defined(VARIANT_DYLD)
38 #define _STRDEF(x) __STRING(x)
40 #define makeResolver_up_mp(name) \
41 void* name ## $VARIANT$up(void); \
42 void* name ## $VARIANT$mp(void); \
43 void* name ## Resolver(void) __asm__( "_" #name ); \
44 void* name ## Resolver(void) { \
45 __asm__ __volatile__ ( \
46 "ldr ip, L" #name "$commpage ;" \
48 "tst ip, $(" _STRDEF(kUP) ") ;" \
50 "b _" __STRING(name) "$VARIANT$mp ;" \
51 "1: b _" __STRING(name) "$VARIANT$up ;" \
52 "L" #name "$commpage: .long " _STRDEF(_COMM_PAGE_CPU_CAPABILITIES) " ;" \
56 #define makeResolver_up_mp_wfe(name) makeResolver_up_mp(name)
60 #define makeResolver_up_mp(name) \
61 void name ## $VARIANT$up(void); \
62 void name ## $VARIANT$mp(void); \
63 void* name ## Resolver(void) __asm__( "_" #name ) ; \
64 void* name ## Resolver(void) { \
65 __asm__(".symbol_resolver _" #name); \
66 /* return MP variant functions on kNumCPUs > 1 */ \
67 if ((*(uint32_t*)(uintptr_t)_COMM_PAGE_CPU_CAPABILITIES & kUP) == 0) { \
68 return name ## $VARIANT$mp; \
70 return name ## $VARIANT$up; \
73 #define makeResolver_up_mp_wfe(name) \
74 void name ## $VARIANT$up(void); \
75 void name ## $VARIANT$mp(void); \
76 void name ## $VARIANT$wfe(void); \
77 void* name ## Resolver(void) __asm__( "_" #name ) ; \
78 void* name ## Resolver(void) { \
79 __asm__(".symbol_resolver _" #name); \
80 uint32_t caps = *(uint32_t*)(uintptr_t)_COMM_PAGE_CPU_CAPABILITIES; \
81 /* return WFE variant if we will get woken up */ \
82 if ((caps & (kHasEvent | kUP)) == kHasEvent) { \
83 return name ## $VARIANT$wfe; \
85 /* return MP variant functions on kNumCPUs > 1 */ \
86 else if ((caps & kUP) == 0) { \
87 return name ## $VARIANT$mp; \
89 return name ## $VARIANT$up; \
92 #endif // defined VARIANT_DYLD
94 #include "OSAtomic_resolvers.h"
96 #else // defined _ARM_ARCH_7
98 typedef int emptyFilesArentCFiles
;
100 #endif // defined _ARM_ARCH_7 && !defined VARIANT_DYLD