| author | |
| committer | |
| log | 5a6579611f3040015fc788d249de504f54dabfd5 |
| tree | b590c771c0a5bf19dbc04d0fe29152ada879e15c |
| parent | a9c75a2b48f202d5c55097877499942ed07cc2e8 |
| parent | 763d8073774ae0b77014187a75b2167522c44079 |
| signature |
zig cc: detect framework include paths when native9 files changed, 570 insertions(+), 268 deletions(-)
lib/libc/include/aarch64-macos-gnu/libkern/OSAtomic.h created+47| ... | @@ -0,0 +1,47 @@ | ||
| 1 | /* | ||
| 2 | * Copyright (c) 2004-2016 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 | #ifndef _OSATOMIC_H_ | ||
| 25 | #define _OSATOMIC_H_ | ||
| 26 | |||
| 27 | /*! @header | ||
| 28 | * These are deprecated legacy interfaces for atomic and synchronization | ||
| 29 | * operations. | ||
| 30 | * | ||
| 31 | * Define OSATOMIC_USE_INLINED=1 to get inline implementations of the | ||
| 32 | * OSAtomic interfaces in terms of the <stdatomic.h> primitives. | ||
| 33 | * | ||
| 34 | * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of the | ||
| 35 | * OSSpinLock interfaces in terms of the <os/lock.h> primitives. | ||
| 36 | * | ||
| 37 | * These are intended as a transition convenience, direct use of those | ||
| 38 | * primitives should be preferred. | ||
| 39 | */ | ||
| 40 | |||
| 41 | #include <sys/cdefs.h> | ||
| 42 | |||
| 43 | #include "OSAtomicDeprecated.h" | ||
| 44 | #include "OSSpinLockDeprecated.h" | ||
| 45 | #include "OSAtomicQueue.h" | ||
| 46 | |||
| 47 | #endif /* _OSATOMIC_H_ */ | ||
| \ No newline at end of file | |||
lib/libc/include/aarch64-macos-gnu/libkern/OSSpinLockDeprecated.h created+212| ... | @@ -0,0 +1,212 @@ | ||
| 1 | /* | ||
| 2 | * Copyright (c) 2004-2016 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 | #ifndef _OSSPINLOCK_DEPRECATED_H_ | ||
| 25 | #define _OSSPINLOCK_DEPRECATED_H_ | ||
| 26 | |||
| 27 | /*! @header | ||
| 28 | * These are deprecated legacy interfaces for userspace spinlocks. | ||
| 29 | * | ||
| 30 | * These interfaces should no longer be used, particularily in situations where | ||
| 31 | * threads of differing priorities may contend on the same spinlock. | ||
| 32 | * | ||
| 33 | * The interfaces in <os/lock.h> should be used instead in cases where a very | ||
| 34 | * low-level lock primitive is required. In general however, using higher level | ||
| 35 | * synchronization primitives such as those provided by the pthread or dispatch | ||
| 36 | * subsystems should be preferred. | ||
| 37 | * | ||
| 38 | * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of these | ||
| 39 | * interfaces in terms of the <os/lock.h> primitives. This is intended as a | ||
| 40 | * transition convenience, direct use of those primitives is preferred. | ||
| 41 | */ | ||
| 42 | |||
| 43 | #ifndef OSSPINLOCK_DEPRECATED | ||
| 44 | #define OSSPINLOCK_DEPRECATED 1 | ||
| 45 | #define OSSPINLOCK_DEPRECATED_MSG(_r) "Use " #_r "() from <os/lock.h> instead" | ||
| 46 | #define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) \ | ||
| 47 | 	__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 48 | 	__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 49 | 	__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 50 | 	__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSSPINLOCK_DEPRECATED_MSG(_r)) | ||
| 51 | #else | ||
| 52 | #undef OSSPINLOCK_DEPRECATED | ||
| 53 | #define OSSPINLOCK_DEPRECATED 0 | ||
| 54 | #define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if !(defined(OSSPINLOCK_USE_INLINED) && OSSPINLOCK_USE_INLINED) | ||
| 58 | |||
| 59 | #include <sys/cdefs.h> | ||
| 60 | #include <stddef.h> | ||
| 61 | #include <stdint.h> | ||
| 62 | #include <stdbool.h> | ||
| 63 | #include <Availability.h> | ||
| 64 | |||
| 65 | __BEGIN_DECLS | ||
| 66 | |||
| 67 | /*! @abstract The default value for an <code>OSSpinLock</code>. | ||
| 68 | @discussion | ||
| 69 | 	The convention is that unlocked is zero, locked is nonzero. | ||
| 70 | */ | ||
| 71 | #define	OS_SPINLOCK_INIT 0 | ||
| 72 | |||
| 73 | |||
| 74 | /*! @abstract Data type for a spinlock. | ||
| 75 | @discussion | ||
| 76 | 	You should always initialize a spinlock to {@link OS_SPINLOCK_INIT} before | ||
| 77 | 	using it. | ||
| 78 | */ | ||
| 79 | typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock); | ||
| 80 | |||
| 81 | |||
| 82 | /*! @abstract Locks a spinlock if it would not block | ||
| 83 | @result | ||
| 84 | 	Returns <code>false</code> if the lock was already held by another thread, | ||
| 85 | 	<code>true</code> if it took the lock successfully. | ||
| 86 | */ | ||
| 87 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock) | ||
| 88 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 89 | bool OSSpinLockTry( volatile OSSpinLock *__lock ); | ||
| 90 | |||
| 91 | |||
| 92 | /*! @abstract Locks a spinlock | ||
| 93 | @discussion | ||
| 94 | 	Although the lock operation spins, it employs various strategies to back | ||
| 95 | 	off if the lock is held. | ||
| 96 | */ | ||
| 97 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock) | ||
| 98 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 99 | void OSSpinLockLock( volatile OSSpinLock *__lock ); | ||
| 100 | |||
| 101 | |||
| 102 | /*! @abstract Unlocks a spinlock */ | ||
| 103 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock) | ||
| 104 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 105 | void OSSpinLockUnlock( volatile OSSpinLock *__lock ); | ||
| 106 | |||
| 107 | __END_DECLS | ||
| 108 | |||
| 109 | #else /* OSSPINLOCK_USE_INLINED */ | ||
| 110 | |||
| 111 | /* | ||
| 112 | * Inline implementations of the legacy OSSpinLock interfaces in terms of the | ||
| 113 | * of the <os/lock.h> primitives. Direct use of those primitives is preferred. | ||
| 114 | * | ||
| 115 | * NOTE: the locked value of os_unfair_lock is implementation defined and | ||
| 116 | * subject to change, code that relies on the specific locked value used by the | ||
| 117 | * legacy OSSpinLock interface WILL break when using these inline | ||
| 118 | * implementations in terms of os_unfair_lock. | ||
| 119 | */ | ||
| 120 | |||
| 121 | #if !OSSPINLOCK_USE_INLINED_TRANSPARENT | ||
| 122 | |||
| 123 | #include <os/lock.h> | ||
| 124 | |||
| 125 | __BEGIN_DECLS | ||
| 126 | |||
| 127 | #if __has_attribute(always_inline) | ||
| 128 | #define OSSPINLOCK_INLINE static __inline | ||
| 129 | #else | ||
| 130 | #define OSSPINLOCK_INLINE static __inline __attribute__((__always_inline__)) | ||
| 131 | #endif | ||
| 132 | |||
| 133 | #define OS_SPINLOCK_INIT 0 | ||
| 134 | typedef int32_t OSSpinLock; | ||
| 135 | |||
| 136 | #if __has_extension(c_static_assert) | ||
| 137 | _Static_assert(sizeof(OSSpinLock) == sizeof(os_unfair_lock), | ||
| 138 | 		"Incompatible os_unfair_lock type"); | ||
| 139 | #endif | ||
| 140 | |||
| 141 | OSSPINLOCK_INLINE | ||
| 142 | void | ||
| 143 | OSSpinLockLock(volatile OSSpinLock *__lock) | ||
| 144 | { | ||
| 145 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 146 | 	return os_unfair_lock_lock(lock); | ||
| 147 | } | ||
| 148 | |||
| 149 | OSSPINLOCK_INLINE | ||
| 150 | bool | ||
| 151 | OSSpinLockTry(volatile OSSpinLock *__lock) | ||
| 152 | { | ||
| 153 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 154 | 	return os_unfair_lock_trylock(lock); | ||
| 155 | } | ||
| 156 | |||
| 157 | OSSPINLOCK_INLINE | ||
| 158 | void | ||
| 159 | OSSpinLockUnlock(volatile OSSpinLock *__lock) | ||
| 160 | { | ||
| 161 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 162 | 	return os_unfair_lock_unlock(lock); | ||
| 163 | } | ||
| 164 | |||
| 165 | #undef OSSPINLOCK_INLINE | ||
| 166 | |||
| 167 | __END_DECLS | ||
| 168 | |||
| 169 | #else /* OSSPINLOCK_USE_INLINED_TRANSPARENT */ | ||
| 170 | |||
| 171 | #include <sys/cdefs.h> | ||
| 172 | #include <stddef.h> | ||
| 173 | #include <stdint.h> | ||
| 174 | #include <stdbool.h> | ||
| 175 | #include <Availability.h> | ||
| 176 | |||
| 177 | #define OS_NOSPIN_LOCK_AVAILABILITY \ | ||
| 178 | 		__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) \ | ||
| 179 | 		__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0) | ||
| 180 | |||
| 181 | __BEGIN_DECLS | ||
| 182 | |||
| 183 | #define OS_SPINLOCK_INIT 0 | ||
| 184 | typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock); | ||
| 185 | typedef volatile OSSpinLock *_os_nospin_lock_t | ||
| 186 | 		OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t); | ||
| 187 | |||
| 188 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock) | ||
| 189 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 190 | void _os_nospin_lock_lock(_os_nospin_lock_t lock); | ||
| 191 | #undef OSSpinLockLock | ||
| 192 | #define OSSpinLockLock(lock) _os_nospin_lock_lock(lock) | ||
| 193 | |||
| 194 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock) | ||
| 195 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 196 | bool _os_nospin_lock_trylock(_os_nospin_lock_t lock); | ||
| 197 | #undef OSSpinLockTry | ||
| 198 | #define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock) | ||
| 199 | |||
| 200 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock) | ||
| 201 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 202 | void _os_nospin_lock_unlock(_os_nospin_lock_t lock); | ||
| 203 | #undef OSSpinLockUnlock | ||
| 204 | #define OSSpinLockUnlock(lock) _os_nospin_lock_unlock(lock) | ||
| 205 | |||
| 206 | __END_DECLS | ||
| 207 | |||
| 208 | #endif /* OSSPINLOCK_USE_INLINED_TRANSPARENT */ | ||
| 209 | |||
| 210 | #endif /* OSSPINLOCK_USE_INLINED */ | ||
| 211 | |||
| 212 | #endif /* _OSSPINLOCK_DEPRECATED_H_ */ | ||
| \ No newline at end of file | |||
lib/libc/include/any-macos-any/libkern/OSAtomic.h deleted-47| ... | @@ -1,47 +0,0 @@ | ||
| 1 | /* | ||
| 2 | * Copyright (c) 2004-2016 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 | #ifndef _OSATOMIC_H_ | ||
| 25 | #define _OSATOMIC_H_ | ||
| 26 | |||
| 27 | /*! @header | ||
| 28 | * These are deprecated legacy interfaces for atomic and synchronization | ||
| 29 | * operations. | ||
| 30 | * | ||
| 31 | * Define OSATOMIC_USE_INLINED=1 to get inline implementations of the | ||
| 32 | * OSAtomic interfaces in terms of the <stdatomic.h> primitives. | ||
| 33 | * | ||
| 34 | * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of the | ||
| 35 | * OSSpinLock interfaces in terms of the <os/lock.h> primitives. | ||
| 36 | * | ||
| 37 | * These are intended as a transition convenience, direct use of those | ||
| 38 | * primitives should be preferred. | ||
| 39 | */ | ||
| 40 | |||
| 41 | #include <sys/cdefs.h> | ||
| 42 | |||
| 43 | #include "OSAtomicDeprecated.h" | ||
| 44 | #include "OSSpinLockDeprecated.h" | ||
| 45 | #include "OSAtomicQueue.h" | ||
| 46 | |||
| 47 | #endif /* _OSATOMIC_H_ */ | ||
| \ No newline at end of file | |||
lib/libc/include/any-macos-any/libkern/OSSpinLockDeprecated.h deleted-212| ... | @@ -1,212 +0,0 @@ | ||
| 1 | /* | ||
| 2 | * Copyright (c) 2004-2016 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 | #ifndef _OSSPINLOCK_DEPRECATED_H_ | ||
| 25 | #define _OSSPINLOCK_DEPRECATED_H_ | ||
| 26 | |||
| 27 | /*! @header | ||
| 28 | * These are deprecated legacy interfaces for userspace spinlocks. | ||
| 29 | * | ||
| 30 | * These interfaces should no longer be used, particularily in situations where | ||
| 31 | * threads of differing priorities may contend on the same spinlock. | ||
| 32 | * | ||
| 33 | * The interfaces in <os/lock.h> should be used instead in cases where a very | ||
| 34 | * low-level lock primitive is required. In general however, using higher level | ||
| 35 | * synchronization primitives such as those provided by the pthread or dispatch | ||
| 36 | * subsystems should be preferred. | ||
| 37 | * | ||
| 38 | * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of these | ||
| 39 | * interfaces in terms of the <os/lock.h> primitives. This is intended as a | ||
| 40 | * transition convenience, direct use of those primitives is preferred. | ||
| 41 | */ | ||
| 42 | |||
| 43 | #ifndef OSSPINLOCK_DEPRECATED | ||
| 44 | #define OSSPINLOCK_DEPRECATED 1 | ||
| 45 | #define OSSPINLOCK_DEPRECATED_MSG(_r) "Use " #_r "() from <os/lock.h> instead" | ||
| 46 | #define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) \ | ||
| 47 | 	__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 48 | 	__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 49 | 	__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 50 | 	__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSSPINLOCK_DEPRECATED_MSG(_r)) | ||
| 51 | #else | ||
| 52 | #undef OSSPINLOCK_DEPRECATED | ||
| 53 | #define OSSPINLOCK_DEPRECATED 0 | ||
| 54 | #define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if !(defined(OSSPINLOCK_USE_INLINED) && OSSPINLOCK_USE_INLINED) | ||
| 58 | |||
| 59 | #include <sys/cdefs.h> | ||
| 60 | #include <stddef.h> | ||
| 61 | #include <stdint.h> | ||
| 62 | #include <stdbool.h> | ||
| 63 | #include <Availability.h> | ||
| 64 | |||
| 65 | __BEGIN_DECLS | ||
| 66 | |||
| 67 | /*! @abstract The default value for an <code>OSSpinLock</code>. | ||
| 68 | @discussion | ||
| 69 | 	The convention is that unlocked is zero, locked is nonzero. | ||
| 70 | */ | ||
| 71 | #define	OS_SPINLOCK_INIT 0 | ||
| 72 | |||
| 73 | |||
| 74 | /*! @abstract Data type for a spinlock. | ||
| 75 | @discussion | ||
| 76 | 	You should always initialize a spinlock to {@link OS_SPINLOCK_INIT} before | ||
| 77 | 	using it. | ||
| 78 | */ | ||
| 79 | typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock); | ||
| 80 | |||
| 81 | |||
| 82 | /*! @abstract Locks a spinlock if it would not block | ||
| 83 | @result | ||
| 84 | 	Returns <code>false</code> if the lock was already held by another thread, | ||
| 85 | 	<code>true</code> if it took the lock successfully. | ||
| 86 | */ | ||
| 87 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock) | ||
| 88 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 89 | bool OSSpinLockTry( volatile OSSpinLock *__lock ); | ||
| 90 | |||
| 91 | |||
| 92 | /*! @abstract Locks a spinlock | ||
| 93 | @discussion | ||
| 94 | 	Although the lock operation spins, it employs various strategies to back | ||
| 95 | 	off if the lock is held. | ||
| 96 | */ | ||
| 97 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock) | ||
| 98 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 99 | void OSSpinLockLock( volatile OSSpinLock *__lock ); | ||
| 100 | |||
| 101 | |||
| 102 | /*! @abstract Unlocks a spinlock */ | ||
| 103 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock) | ||
| 104 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 105 | void OSSpinLockUnlock( volatile OSSpinLock *__lock ); | ||
| 106 | |||
| 107 | __END_DECLS | ||
| 108 | |||
| 109 | #else /* OSSPINLOCK_USE_INLINED */ | ||
| 110 | |||
| 111 | /* | ||
| 112 | * Inline implementations of the legacy OSSpinLock interfaces in terms of the | ||
| 113 | * of the <os/lock.h> primitives. Direct use of those primitives is preferred. | ||
| 114 | * | ||
| 115 | * NOTE: the locked value of os_unfair_lock is implementation defined and | ||
| 116 | * subject to change, code that relies on the specific locked value used by the | ||
| 117 | * legacy OSSpinLock interface WILL break when using these inline | ||
| 118 | * implementations in terms of os_unfair_lock. | ||
| 119 | */ | ||
| 120 | |||
| 121 | #if !OSSPINLOCK_USE_INLINED_TRANSPARENT | ||
| 122 | |||
| 123 | #include <os/lock.h> | ||
| 124 | |||
| 125 | __BEGIN_DECLS | ||
| 126 | |||
| 127 | #if __has_attribute(always_inline) | ||
| 128 | #define OSSPINLOCK_INLINE static __inline | ||
| 129 | #else | ||
| 130 | #define OSSPINLOCK_INLINE static __inline __attribute__((__always_inline__)) | ||
| 131 | #endif | ||
| 132 | |||
| 133 | #define OS_SPINLOCK_INIT 0 | ||
| 134 | typedef int32_t OSSpinLock; | ||
| 135 | |||
| 136 | #if __has_extension(c_static_assert) | ||
| 137 | _Static_assert(sizeof(OSSpinLock) == sizeof(os_unfair_lock), | ||
| 138 | 		"Incompatible os_unfair_lock type"); | ||
| 139 | #endif | ||
| 140 | |||
| 141 | OSSPINLOCK_INLINE | ||
| 142 | void | ||
| 143 | OSSpinLockLock(volatile OSSpinLock *__lock) | ||
| 144 | { | ||
| 145 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 146 | 	return os_unfair_lock_lock(lock); | ||
| 147 | } | ||
| 148 | |||
| 149 | OSSPINLOCK_INLINE | ||
| 150 | bool | ||
| 151 | OSSpinLockTry(volatile OSSpinLock *__lock) | ||
| 152 | { | ||
| 153 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 154 | 	return os_unfair_lock_trylock(lock); | ||
| 155 | } | ||
| 156 | |||
| 157 | OSSPINLOCK_INLINE | ||
| 158 | void | ||
| 159 | OSSpinLockUnlock(volatile OSSpinLock *__lock) | ||
| 160 | { | ||
| 161 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 162 | 	return os_unfair_lock_unlock(lock); | ||
| 163 | } | ||
| 164 | |||
| 165 | #undef OSSPINLOCK_INLINE | ||
| 166 | |||
| 167 | __END_DECLS | ||
| 168 | |||
| 169 | #else /* OSSPINLOCK_USE_INLINED_TRANSPARENT */ | ||
| 170 | |||
| 171 | #include <sys/cdefs.h> | ||
| 172 | #include <stddef.h> | ||
| 173 | #include <stdint.h> | ||
| 174 | #include <stdbool.h> | ||
| 175 | #include <Availability.h> | ||
| 176 | |||
| 177 | #define OS_NOSPIN_LOCK_AVAILABILITY \ | ||
| 178 | 		__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) \ | ||
| 179 | 		__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0) | ||
| 180 | |||
| 181 | __BEGIN_DECLS | ||
| 182 | |||
| 183 | #define OS_SPINLOCK_INIT 0 | ||
| 184 | typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock); | ||
| 185 | typedef volatile OSSpinLock *_os_nospin_lock_t | ||
| 186 | 		OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t); | ||
| 187 | |||
| 188 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock) | ||
| 189 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 190 | void _os_nospin_lock_lock(_os_nospin_lock_t lock); | ||
| 191 | #undef OSSpinLockLock | ||
| 192 | #define OSSpinLockLock(lock) _os_nospin_lock_lock(lock) | ||
| 193 | |||
| 194 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock) | ||
| 195 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 196 | bool _os_nospin_lock_trylock(_os_nospin_lock_t lock); | ||
| 197 | #undef OSSpinLockTry | ||
| 198 | #define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock) | ||
| 199 | |||
| 200 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock) | ||
| 201 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 202 | void _os_nospin_lock_unlock(_os_nospin_lock_t lock); | ||
| 203 | #undef OSSpinLockUnlock | ||
| 204 | #define OSSpinLockUnlock(lock) _os_nospin_lock_unlock(lock) | ||
| 205 | |||
| 206 | __END_DECLS | ||
| 207 | |||
| 208 | #endif /* OSSPINLOCK_USE_INLINED_TRANSPARENT */ | ||
| 209 | |||
| 210 | #endif /* OSSPINLOCK_USE_INLINED */ | ||
| 211 | |||
| 212 | #endif /* _OSSPINLOCK_DEPRECATED_H_ */ | ||
| \ No newline at end of file | |||
lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h created+47| ... | @@ -0,0 +1,47 @@ | ||
| 1 | /* | ||
| 2 | * Copyright (c) 2004-2016 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 | #ifndef _OSATOMIC_H_ | ||
| 25 | #define _OSATOMIC_H_ | ||
| 26 | |||
| 27 | /*! @header | ||
| 28 | * These are deprecated legacy interfaces for atomic and synchronization | ||
| 29 | * operations. | ||
| 30 | * | ||
| 31 | * Define OSATOMIC_USE_INLINED=1 to get inline implementations of the | ||
| 32 | * OSAtomic interfaces in terms of the <stdatomic.h> primitives. | ||
| 33 | * | ||
| 34 | * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of the | ||
| 35 | * OSSpinLock interfaces in terms of the <os/lock.h> primitives. | ||
| 36 | * | ||
| 37 | * These are intended as a transition convenience, direct use of those | ||
| 38 | * primitives should be preferred. | ||
| 39 | */ | ||
| 40 | |||
| 41 | #include <sys/cdefs.h> | ||
| 42 | |||
| 43 | #include "OSAtomicDeprecated.h" | ||
| 44 | #include "OSSpinLockDeprecated.h" | ||
| 45 | #include "OSAtomicQueue.h" | ||
| 46 | |||
| 47 | #endif /* _OSATOMIC_H_ */ | ||
| \ No newline at end of file | |||
lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h created+212| ... | @@ -0,0 +1,212 @@ | ||
| 1 | /* | ||
| 2 | * Copyright (c) 2004-2016 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 | #ifndef _OSSPINLOCK_DEPRECATED_H_ | ||
| 25 | #define _OSSPINLOCK_DEPRECATED_H_ | ||
| 26 | |||
| 27 | /*! @header | ||
| 28 | * These are deprecated legacy interfaces for userspace spinlocks. | ||
| 29 | * | ||
| 30 | * These interfaces should no longer be used, particularily in situations where | ||
| 31 | * threads of differing priorities may contend on the same spinlock. | ||
| 32 | * | ||
| 33 | * The interfaces in <os/lock.h> should be used instead in cases where a very | ||
| 34 | * low-level lock primitive is required. In general however, using higher level | ||
| 35 | * synchronization primitives such as those provided by the pthread or dispatch | ||
| 36 | * subsystems should be preferred. | ||
| 37 | * | ||
| 38 | * Define OSSPINLOCK_USE_INLINED=1 to get inline implementations of these | ||
| 39 | * interfaces in terms of the <os/lock.h> primitives. This is intended as a | ||
| 40 | * transition convenience, direct use of those primitives is preferred. | ||
| 41 | */ | ||
| 42 | |||
| 43 | #ifndef OSSPINLOCK_DEPRECATED | ||
| 44 | #define OSSPINLOCK_DEPRECATED 1 | ||
| 45 | #define OSSPINLOCK_DEPRECATED_MSG(_r) "Use " #_r "() from <os/lock.h> instead" | ||
| 46 | #define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) \ | ||
| 47 | 	__OS_AVAILABILITY_MSG(macosx, deprecated=10.12, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 48 | 	__OS_AVAILABILITY_MSG(ios, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 49 | 	__OS_AVAILABILITY_MSG(tvos, deprecated=10.0, OSSPINLOCK_DEPRECATED_MSG(_r)) \ | ||
| 50 | 	__OS_AVAILABILITY_MSG(watchos, deprecated=3.0, OSSPINLOCK_DEPRECATED_MSG(_r)) | ||
| 51 | #else | ||
| 52 | #undef OSSPINLOCK_DEPRECATED | ||
| 53 | #define OSSPINLOCK_DEPRECATED 0 | ||
| 54 | #define OSSPINLOCK_DEPRECATED_REPLACE_WITH(_r) | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #if !(defined(OSSPINLOCK_USE_INLINED) && OSSPINLOCK_USE_INLINED) | ||
| 58 | |||
| 59 | #include <sys/cdefs.h> | ||
| 60 | #include <stddef.h> | ||
| 61 | #include <stdint.h> | ||
| 62 | #include <stdbool.h> | ||
| 63 | #include <Availability.h> | ||
| 64 | |||
| 65 | __BEGIN_DECLS | ||
| 66 | |||
| 67 | /*! @abstract The default value for an <code>OSSpinLock</code>. | ||
| 68 | @discussion | ||
| 69 | 	The convention is that unlocked is zero, locked is nonzero. | ||
| 70 | */ | ||
| 71 | #define	OS_SPINLOCK_INIT 0 | ||
| 72 | |||
| 73 | |||
| 74 | /*! @abstract Data type for a spinlock. | ||
| 75 | @discussion | ||
| 76 | 	You should always initialize a spinlock to {@link OS_SPINLOCK_INIT} before | ||
| 77 | 	using it. | ||
| 78 | */ | ||
| 79 | typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock); | ||
| 80 | |||
| 81 | |||
| 82 | /*! @abstract Locks a spinlock if it would not block | ||
| 83 | @result | ||
| 84 | 	Returns <code>false</code> if the lock was already held by another thread, | ||
| 85 | 	<code>true</code> if it took the lock successfully. | ||
| 86 | */ | ||
| 87 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock) | ||
| 88 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 89 | bool OSSpinLockTry( volatile OSSpinLock *__lock ); | ||
| 90 | |||
| 91 | |||
| 92 | /*! @abstract Locks a spinlock | ||
| 93 | @discussion | ||
| 94 | 	Although the lock operation spins, it employs various strategies to back | ||
| 95 | 	off if the lock is held. | ||
| 96 | */ | ||
| 97 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock) | ||
| 98 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 99 | void OSSpinLockLock( volatile OSSpinLock *__lock ); | ||
| 100 | |||
| 101 | |||
| 102 | /*! @abstract Unlocks a spinlock */ | ||
| 103 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock) | ||
| 104 | __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0) | ||
| 105 | void OSSpinLockUnlock( volatile OSSpinLock *__lock ); | ||
| 106 | |||
| 107 | __END_DECLS | ||
| 108 | |||
| 109 | #else /* OSSPINLOCK_USE_INLINED */ | ||
| 110 | |||
| 111 | /* | ||
| 112 | * Inline implementations of the legacy OSSpinLock interfaces in terms of the | ||
| 113 | * of the <os/lock.h> primitives. Direct use of those primitives is preferred. | ||
| 114 | * | ||
| 115 | * NOTE: the locked value of os_unfair_lock is implementation defined and | ||
| 116 | * subject to change, code that relies on the specific locked value used by the | ||
| 117 | * legacy OSSpinLock interface WILL break when using these inline | ||
| 118 | * implementations in terms of os_unfair_lock. | ||
| 119 | */ | ||
| 120 | |||
| 121 | #if !OSSPINLOCK_USE_INLINED_TRANSPARENT | ||
| 122 | |||
| 123 | #include <os/lock.h> | ||
| 124 | |||
| 125 | __BEGIN_DECLS | ||
| 126 | |||
| 127 | #if __has_attribute(always_inline) | ||
| 128 | #define OSSPINLOCK_INLINE static __inline | ||
| 129 | #else | ||
| 130 | #define OSSPINLOCK_INLINE static __inline __attribute__((__always_inline__)) | ||
| 131 | #endif | ||
| 132 | |||
| 133 | #define OS_SPINLOCK_INIT 0 | ||
| 134 | typedef int32_t OSSpinLock; | ||
| 135 | |||
| 136 | #if __has_extension(c_static_assert) | ||
| 137 | _Static_assert(sizeof(OSSpinLock) == sizeof(os_unfair_lock), | ||
| 138 | 		"Incompatible os_unfair_lock type"); | ||
| 139 | #endif | ||
| 140 | |||
| 141 | OSSPINLOCK_INLINE | ||
| 142 | void | ||
| 143 | OSSpinLockLock(volatile OSSpinLock *__lock) | ||
| 144 | { | ||
| 145 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 146 | 	return os_unfair_lock_lock(lock); | ||
| 147 | } | ||
| 148 | |||
| 149 | OSSPINLOCK_INLINE | ||
| 150 | bool | ||
| 151 | OSSpinLockTry(volatile OSSpinLock *__lock) | ||
| 152 | { | ||
| 153 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 154 | 	return os_unfair_lock_trylock(lock); | ||
| 155 | } | ||
| 156 | |||
| 157 | OSSPINLOCK_INLINE | ||
| 158 | void | ||
| 159 | OSSpinLockUnlock(volatile OSSpinLock *__lock) | ||
| 160 | { | ||
| 161 | 	os_unfair_lock_t lock = (os_unfair_lock_t)__lock; | ||
| 162 | 	return os_unfair_lock_unlock(lock); | ||
| 163 | } | ||
| 164 | |||
| 165 | #undef OSSPINLOCK_INLINE | ||
| 166 | |||
| 167 | __END_DECLS | ||
| 168 | |||
| 169 | #else /* OSSPINLOCK_USE_INLINED_TRANSPARENT */ | ||
| 170 | |||
| 171 | #include <sys/cdefs.h> | ||
| 172 | #include <stddef.h> | ||
| 173 | #include <stdint.h> | ||
| 174 | #include <stdbool.h> | ||
| 175 | #include <Availability.h> | ||
| 176 | |||
| 177 | #define OS_NOSPIN_LOCK_AVAILABILITY \ | ||
| 178 | 		__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) \ | ||
| 179 | 		__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0) | ||
| 180 | |||
| 181 | __BEGIN_DECLS | ||
| 182 | |||
| 183 | #define OS_SPINLOCK_INIT 0 | ||
| 184 | typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock); | ||
| 185 | typedef volatile OSSpinLock *_os_nospin_lock_t | ||
| 186 | 		OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t); | ||
| 187 | |||
| 188 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock) | ||
| 189 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 190 | void _os_nospin_lock_lock(_os_nospin_lock_t lock); | ||
| 191 | #undef OSSpinLockLock | ||
| 192 | #define OSSpinLockLock(lock) _os_nospin_lock_lock(lock) | ||
| 193 | |||
| 194 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock) | ||
| 195 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 196 | bool _os_nospin_lock_trylock(_os_nospin_lock_t lock); | ||
| 197 | #undef OSSpinLockTry | ||
| 198 | #define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock) | ||
| 199 | |||
| 200 | OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock) | ||
| 201 | OS_NOSPIN_LOCK_AVAILABILITY | ||
| 202 | void _os_nospin_lock_unlock(_os_nospin_lock_t lock); | ||
| 203 | #undef OSSpinLockUnlock | ||
| 204 | #define OSSpinLockUnlock(lock) _os_nospin_lock_unlock(lock) | ||
| 205 | |||
| 206 | __END_DECLS | ||
| 207 | |||
| 208 | #endif /* OSSPINLOCK_USE_INLINED_TRANSPARENT */ | ||
| 209 | |||
| 210 | #endif /* OSSPINLOCK_USE_INLINED */ | ||
| 211 | |||
| 212 | #endif /* _OSSPINLOCK_DEPRECATED_H_ */ | ||
| \ No newline at end of file | |||
lib/std/zig/system.zig+27-2| ... | @@ -22,6 +22,7 @@ pub const getSDKPath = macos.getSDKPath; | ... | @@ -22,6 +22,7 @@ pub const getSDKPath = macos.getSDKPath; |
| 22 | pub const NativePaths = struct { | 22 | pub const NativePaths = struct { |
| 23 | include_dirs: ArrayList([:0]u8), | 23 | include_dirs: ArrayList([:0]u8), |
| 24 | lib_dirs: ArrayList([:0]u8), | 24 | lib_dirs: ArrayList([:0]u8), |
| 25 | framework_dirs: ArrayList([:0]u8), | ||
| 25 | rpaths: ArrayList([:0]u8), | 26 | rpaths: ArrayList([:0]u8), |
| 26 | warnings: ArrayList([:0]u8), | 27 | warnings: ArrayList([:0]u8), |
| 27 | 28 | ||
| ... | @@ -29,6 +30,7 @@ pub const NativePaths = struct { | ... | @@ -29,6 +30,7 @@ pub const NativePaths = struct { |
| 29 | var self: NativePaths = .{ | 30 | var self: NativePaths = .{ |
| 30 | .include_dirs = ArrayList([:0]u8).init(allocator), | 31 | .include_dirs = ArrayList([:0]u8).init(allocator), |
| 31 | .lib_dirs = ArrayList([:0]u8).init(allocator), | 32 | .lib_dirs = ArrayList([:0]u8).init(allocator), |
| 33 | .framework_dirs = ArrayList([:0]u8).init(allocator), | ||
| 32 | .rpaths = ArrayList([:0]u8).init(allocator), | 34 | .rpaths = ArrayList([:0]u8).init(allocator), |
| 33 | .warnings = ArrayList([:0]u8).init(allocator), | 35 | .warnings = ArrayList([:0]u8).init(allocator), |
| 34 | }; | 36 | }; |
| ... | @@ -88,6 +90,19 @@ pub const NativePaths = struct { | ... | @@ -88,6 +90,19 @@ pub const NativePaths = struct { |
| 88 | return self; | 90 | return self; |
| 89 | } | 91 | } |
| 90 | 92 | ||
| 93 | if (comptime Target.current.isDarwin()) { | ||
| 94 | try self.addIncludeDir("/usr/include"); | ||
| 95 | try self.addIncludeDir("/usr/local/include"); | ||
| 96 | |||
| 97 | try self.addLibDir("/usr/lib"); | ||
| 98 | try self.addLibDir("/usr/local/lib"); | ||
| 99 | |||
| 100 | try self.addFrameworkDir("/Library/Frameworks"); | ||
| 101 | try self.addFrameworkDir("/System/Library/Frameworks"); | ||
| 102 | |||
| 103 | return self; | ||
| 104 | } | ||
| 105 | |||
| 91 | if (!is_windows) { | 106 | if (!is_windows) { |
| 92 | const triple = try Target.current.linuxTriple(allocator); | 107 | const triple = try Target.current.linuxTriple(allocator); |
| 93 | const qual = Target.current.cpu.arch.ptrBitWidth(); | 108 | const qual = Target.current.cpu.arch.ptrBitWidth(); |
| ... | @@ -122,6 +137,7 @@ pub const NativePaths = struct { | ... | @@ -122,6 +137,7 @@ pub const NativePaths = struct { |
| 122 | pub fn deinit(self: *NativePaths) void { | 137 | pub fn deinit(self: *NativePaths) void { |
| 123 | deinitArray(&self.include_dirs); | 138 | deinitArray(&self.include_dirs); |
| 124 | deinitArray(&self.lib_dirs); | 139 | deinitArray(&self.lib_dirs); |
| 140 | deinitArray(&self.framework_dirs); | ||
| 125 | deinitArray(&self.rpaths); | 141 | deinitArray(&self.rpaths); |
| 126 | deinitArray(&self.warnings); | 142 | deinitArray(&self.warnings); |
| 127 | self.* = undefined; | 143 | self.* = undefined; |
| ... | @@ -158,6 +174,16 @@ pub const NativePaths = struct { | ... | @@ -158,6 +174,16 @@ pub const NativePaths = struct { |
| 158 | return self.appendArray(&self.warnings, s); | 174 | return self.appendArray(&self.warnings, s); |
| 159 | } | 175 | } |
| 160 | 176 | ||
| 177 | pub fn addFrameworkDir(self: *NativePaths, s: []const u8) !void { | ||
| 178 | return self.appendArray(&self.framework_dirs, s); | ||
| 179 | } | ||
| 180 | |||
| 181 | pub fn addFrameworkDirFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void { | ||
| 182 | const item = try std.fmt.allocPrint0(self.framework_dirs.allocator, fmt, args); | ||
| 183 | errdefer self.framework_dirs.allocator.free(item); | ||
| 184 | try self.framework_dirs.append(item); | ||
| 185 | } | ||
| 186 | |||
| 161 | pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void { | 187 | pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void { |
| 162 | const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args); | 188 | const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args); |
| 163 | errdefer self.warnings.allocator.free(item); | 189 | errdefer self.warnings.allocator.free(item); |
| ... | @@ -237,8 +263,7 @@ pub const NativeTargetInfo = struct { | ... | @@ -237,8 +263,7 @@ pub const NativeTargetInfo = struct { |
| 237 | // `---` `` ``--> Sub-version (Starting from Windows 10 onwards) | 263 | // `---` `` ``--> Sub-version (Starting from Windows 10 onwards) |
| 238 | // \ `--> Service pack (Always zero in the constants defined) | 264 | // \ `--> Service pack (Always zero in the constants defined) |
| 239 | // `--> OS version (Major & minor) | 265 | // `--> OS version (Major & minor) |
| 240 | const os_ver: u16 = | 266 | const os_ver: u16 = @intCast(u16, version_info.dwMajorVersion & 0xff) << 8 | |
| 241 | @intCast(u16, version_info.dwMajorVersion & 0xff) << 8 | | ||
| 242 | @intCast(u16, version_info.dwMinorVersion & 0xff); | 267 | @intCast(u16, version_info.dwMinorVersion & 0xff); |
| 243 | const sp_ver: u8 = 0; | 268 | const sp_ver: u8 = 0; |
| 244 | const sub_ver: u8 = if (os_ver >= 0x0A00) subver: { | 269 | const sub_ver: u8 = if (os_ver >= 0x0A00) subver: { |
src/Compilation.zig-6| ... | @@ -2079,12 +2079,6 @@ pub fn addCCArgs( | ... | @@ -2079,12 +2079,6 @@ pub fn addCCArgs( |
| 2079 | try argv.append("-ffunction-sections"); | 2079 | try argv.append("-ffunction-sections"); |
| 2080 | } | 2080 | } |
| 2081 | 2081 | ||
| 2082 | try argv.ensureCapacity(argv.items.len + comp.bin_file.options.framework_dirs.len * 2); | ||
| 2083 | for (comp.bin_file.options.framework_dirs) |framework_dir| { | ||
| 2084 | argv.appendAssumeCapacity("-iframework"); | ||
| 2085 | argv.appendAssumeCapacity(framework_dir); | ||
| 2086 | } | ||
| 2087 | |||
| 2088 | if (comp.bin_file.options.link_libcpp) { | 2082 | if (comp.bin_file.options.link_libcpp) { |
| 2089 | const libcxx_include_path = try std.fs.path.join(arena, &[_][]const u8{ | 2083 | const libcxx_include_path = try std.fs.path.join(arena, &[_][]const u8{ |
| 2090 | comp.zig_lib_directory.path.?, "libcxx", "include", | 2084 | comp.zig_lib_directory.path.?, "libcxx", "include", |
src/main.zig+25-1| ... | @@ -1436,11 +1436,35 @@ fn buildOutputType( | ... | @@ -1436,11 +1436,35 @@ fn buildOutputType( |
| 1436 | for (paths.warnings.items) |warning| { | 1436 | for (paths.warnings.items) |warning| { |
| 1437 | warn("{}", .{warning}); | 1437 | warn("{}", .{warning}); |
| 1438 | } | 1438 | } |
| 1439 | |||
| 1440 | const has_sysroot = if (comptime std.Target.current.isDarwin()) outer: { | ||
| 1441 | const at_least_big_sur = target_info.target.os.getVersionRange().semver.min.major >= 11; | ||
| 1442 | if (at_least_big_sur) { | ||
| 1443 | const sdk_path = try std.zig.system.getSDKPath(arena); | ||
| 1444 | try clang_argv.ensureCapacity(clang_argv.items.len + 2); | ||
| 1445 | clang_argv.appendAssumeCapacity("-isysroot"); | ||
| 1446 | clang_argv.appendAssumeCapacity(sdk_path); | ||
| 1447 | break :outer true; | ||
| 1448 | } | ||
| 1449 | break :outer false; | ||
| 1450 | } else false; | ||
| 1451 | |||
| 1439 | try clang_argv.ensureCapacity(clang_argv.items.len + paths.include_dirs.items.len * 2); | 1452 | try clang_argv.ensureCapacity(clang_argv.items.len + paths.include_dirs.items.len * 2); |
| 1453 | const isystem_flag = if (has_sysroot) "-iwithsysroot" else "-isystem"; | ||
| 1440 | for (paths.include_dirs.items) |include_dir| { | 1454 | for (paths.include_dirs.items) |include_dir| { |
| 1441 | clang_argv.appendAssumeCapacity("-isystem"); | 1455 | clang_argv.appendAssumeCapacity(isystem_flag); |
| 1442 | clang_argv.appendAssumeCapacity(include_dir); | 1456 | clang_argv.appendAssumeCapacity(include_dir); |
| 1443 | } | 1457 | } |
| 1458 | |||
| 1459 | try clang_argv.ensureCapacity(clang_argv.items.len + paths.framework_dirs.items.len * 2); | ||
| 1460 | try framework_dirs.ensureCapacity(framework_dirs.items.len + paths.framework_dirs.items.len); | ||
| 1461 | const iframework_flag = if (has_sysroot) "-iframeworkwithsysroot" else "-iframework"; | ||
| 1462 | for (paths.framework_dirs.items) |framework_dir| { | ||
| 1463 | clang_argv.appendAssumeCapacity(iframework_flag); | ||
| 1464 | clang_argv.appendAssumeCapacity(framework_dir); | ||
| 1465 | framework_dirs.appendAssumeCapacity(framework_dir); | ||
| 1466 | } | ||
| 1467 | |||
| 1444 | for (paths.lib_dirs.items) |lib_dir| { | 1468 | for (paths.lib_dirs.items) |lib_dir| { |
| 1445 | try lib_dirs.append(lib_dir); | 1469 | try lib_dirs.append(lib_dir); |
| 1446 | } | 1470 | } |