]>
git.saurik.com Git - apple/libplatform.git/blob - internal/os/internal.h
2 * Copyright (c) 2013 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
21 #ifndef __OS_INTERNAL_H__
22 #define __OS_INTERNAL_H__
24 #define __OS_ALLOC_INDIRECT__
26 #include <TargetConditionals.h>
27 #include <machine/cpu_capabilities.h>
29 #include "os/base_private.h"
30 #include "os/semaphore_private.h"
39 #include <mach/thread_switch.h>
41 #define likely(x) os_likely(x)
42 #define unlikely(x) os_unlikely(x)
44 #define __OS_CRASH__(rc, msg) ({ \
45 _os_set_crash_log_cause_and_message(rc, msg); \
46 os_prevent_tail_call_optimization(); \
50 #define __LIBPLATFORM_CLIENT_CRASH__(rc, msg) \
51 __OS_CRASH__(rc, "BUG IN CLIENT OF LIBPLATFORM: " msg)
52 #define __LIBPLATFORM_INTERNAL_CRASH__(rc, msg) \
53 __OS_CRASH__(rc, "BUG IN LIBPLATFORM: " msg)
55 #define __OS_EXPOSE_INTERNALS__ 1
56 #include "os/internal/internal_shared.h"
59 #define OS_NOEXPORT extern __attribute__((__visibility__("hidden")))
61 #define OS_VARIANT(f, v) OS_CONCAT(f, OS_CONCAT($VARIANT$, v))
63 #define _OS_ATOMIC_ALIAS_PRIVATE_EXTERN(n)
64 #define OS_ATOMIC_EXPORT OS_EXPORT
65 #define _OS_ATOMIC_ALIAS_GLOBL(n) \
66 ".globl _" OS_STRINGIFY(n) "\n\t"
68 #define _OS_ATOMIC_ALIAS_THUMB(n) \
69 ".thumb_func _" OS_STRINGIFY(n) "\n\t"
71 #define _OS_ATOMIC_ALIAS_THUMB(n)
73 #define _OS_ATOMIC_ALIAS_SET(n, o) \
74 ".set _" OS_STRINGIFY(n) ", _" OS_STRINGIFY(o)
76 #define OS_ATOMIC_ALIAS(n, o) __asm__( \
77 _OS_ATOMIC_ALIAS_PRIVATE_EXTERN(n) \
78 _OS_ATOMIC_ALIAS_GLOBL(n) \
79 _OS_ATOMIC_ALIAS_THUMB(n) \
80 _OS_ATOMIC_ALIAS_SET(n, o))
82 #define OS_ATOMIC_EXPORT_ALIAS(n, o) __asm__( \
83 _OS_ATOMIC_ALIAS_GLOBL(n) \
84 _OS_ATOMIC_ALIAS_THUMB(n) \
85 _OS_ATOMIC_ALIAS_SET(n, o))
87 #define _OS_VARIANT_RESOLVER(s, v, ...) \
88 __attribute__((visibility(OS_STRINGIFY(v)))) extern void* s(void); \
90 __asm__(".symbol_resolver _" OS_STRINGIFY(s)); \
94 #endif // __OS_INTERNAL_H__