OSAtomic_resolvers.c   [plain text]


/*
 * Copyright (c) 2010 Apple Inc. All rights reserved.
 *
 * @APPLE_LICENSE_HEADER_START@
 * 
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this
 * file.
 * 
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 * 
 * @APPLE_LICENSE_HEADER_END@
 */

/*
 * This holds the C versions of OSAtomic.s resolver functions, used by
 * everyone except dyld.
 */

#include <arm/arch.h>
#if defined(_ARM_ARCH_7) && !defined(VARIANT_DYLD)

#include <stdlib.h>
#include <machine/cpu_capabilities.h>
#include <mach/machine.h>

#define makeResolver_up_mp(name) \
	void name ## $VARIANT$up(void); \
	void name ## $VARIANT$mp(void); \
	void* name ## Resolver(void) __asm__( "_" #name ) ; \
	void* name ## Resolver(void) { \
		__asm__(".symbol_resolver _" #name); \
		/* return MP variant functions on kNumCPUs > 1 */ \
		if ((_get_cpu_capabilities() & kUP) == 0) { \
			return name ## $VARIANT$mp; \
		} \
		return name ## $VARIANT$up; \
	}

#define makeResolver_up_mp_wfe(name) \
	void name ## $VARIANT$up(void); \
	void name ## $VARIANT$mp(void); \
	void name ## $VARIANT$wfe(void); \
	void* name ## Resolver(void) __asm__( "_" #name ) ; \
	void* name ## Resolver(void) { \
		__asm__(".symbol_resolver _" #name); \
		int caps = _get_cpu_capabilities(); \
		/* return WFE variant if we will get woken up */ \
		if ((caps & (kHasEvent | kUP)) == kHasEvent) { \
			return name ## $VARIANT$wfe; \
		} \
		/* return MP variant functions on kNumCPUs > 1 */ \
		else if ((caps & kUP) == 0) { \
			return name ## $VARIANT$mp; \
		} \
		return name ## $VARIANT$up; \
	}
	
#include "OSAtomic_resolvers.h"

#else // defined _ARM_ARCH_7 && !defined VARIANT_DYLD

typedef int emptyFilesArentCFiles;

#endif // defined _ARM_ARCH_7 && !defined VARIANT_DYLD