authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-01-02 20:08:37+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-01-02 20:08:37+01:00
log5a6579611f3040015fc788d249de504f54dabfd5
treeb590c771c0a5bf19dbc04d0fe29152ada879e15c
parenta9c75a2b48f202d5c55097877499942ed07cc2e8
parent763d8073774ae0b77014187a75b2167522c44079
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #7506 from kubkon/fix-6923

zig cc: detect framework include paths when native

9 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 */
79typedef 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 */
87OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
88__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
89bool 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 */
97OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
98__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
99void OSSpinLockLock( volatile OSSpinLock *__lock );
100
101
102/*! @abstract Unlocks a spinlock */
103OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
104__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
105void 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
134typedef 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
141OSSPINLOCK_INLINE
142void
143OSSpinLockLock(volatile OSSpinLock *__lock)
144{
145 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
146 return os_unfair_lock_lock(lock);
147}
148
149OSSPINLOCK_INLINE
150bool
151OSSpinLockTry(volatile OSSpinLock *__lock)
152{
153 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
154 return os_unfair_lock_trylock(lock);
155}
156
157OSSPINLOCK_INLINE
158void
159OSSpinLockUnlock(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
184typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
185typedef volatile OSSpinLock *_os_nospin_lock_t
186 OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t);
187
188OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
189OS_NOSPIN_LOCK_AVAILABILITY
190void _os_nospin_lock_lock(_os_nospin_lock_t lock);
191#undef OSSpinLockLock
192#define OSSpinLockLock(lock) _os_nospin_lock_lock(lock)
193
194OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
195OS_NOSPIN_LOCK_AVAILABILITY
196bool _os_nospin_lock_trylock(_os_nospin_lock_t lock);
197#undef OSSpinLockTry
198#define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock)
199
200OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
201OS_NOSPIN_LOCK_AVAILABILITY
202void _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 */
79typedef 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 */
87OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
88__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
89bool 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 */
97OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
98__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
99void OSSpinLockLock( volatile OSSpinLock *__lock );
100
101
102/*! @abstract Unlocks a spinlock */
103OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
104__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
105void 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
134typedef 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
141OSSPINLOCK_INLINE
142void
143OSSpinLockLock(volatile OSSpinLock *__lock)
144{
145 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
146 return os_unfair_lock_lock(lock);
147}
148
149OSSPINLOCK_INLINE
150bool
151OSSpinLockTry(volatile OSSpinLock *__lock)
152{
153 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
154 return os_unfair_lock_trylock(lock);
155}
156
157OSSPINLOCK_INLINE
158void
159OSSpinLockUnlock(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
184typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
185typedef volatile OSSpinLock *_os_nospin_lock_t
186 OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t);
187
188OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
189OS_NOSPIN_LOCK_AVAILABILITY
190void _os_nospin_lock_lock(_os_nospin_lock_t lock);
191#undef OSSpinLockLock
192#define OSSpinLockLock(lock) _os_nospin_lock_lock(lock)
193
194OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
195OS_NOSPIN_LOCK_AVAILABILITY
196bool _os_nospin_lock_trylock(_os_nospin_lock_t lock);
197#undef OSSpinLockTry
198#define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock)
199
200OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
201OS_NOSPIN_LOCK_AVAILABILITY
202void _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 */
79typedef 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 */
87OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
88__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
89bool 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 */
97OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
98__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
99void OSSpinLockLock( volatile OSSpinLock *__lock );
100
101
102/*! @abstract Unlocks a spinlock */
103OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
104__OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_2_0)
105void 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
134typedef 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
141OSSPINLOCK_INLINE
142void
143OSSpinLockLock(volatile OSSpinLock *__lock)
144{
145 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
146 return os_unfair_lock_lock(lock);
147}
148
149OSSPINLOCK_INLINE
150bool
151OSSpinLockTry(volatile OSSpinLock *__lock)
152{
153 os_unfair_lock_t lock = (os_unfair_lock_t)__lock;
154 return os_unfair_lock_trylock(lock);
155}
156
157OSSPINLOCK_INLINE
158void
159OSSpinLockUnlock(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
184typedef int32_t OSSpinLock OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock);
185typedef volatile OSSpinLock *_os_nospin_lock_t
186 OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_t);
187
188OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_lock)
189OS_NOSPIN_LOCK_AVAILABILITY
190void _os_nospin_lock_lock(_os_nospin_lock_t lock);
191#undef OSSpinLockLock
192#define OSSpinLockLock(lock) _os_nospin_lock_lock(lock)
193
194OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_trylock)
195OS_NOSPIN_LOCK_AVAILABILITY
196bool _os_nospin_lock_trylock(_os_nospin_lock_t lock);
197#undef OSSpinLockTry
198#define OSSpinLockTry(lock) _os_nospin_lock_trylock(lock)
199
200OSSPINLOCK_DEPRECATED_REPLACE_WITH(os_unfair_lock_unlock)
201OS_NOSPIN_LOCK_AVAILABILITY
202void _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;
2222pub const NativePaths = struct {
2323 include_dirs: ArrayList([:0]u8),
2424 lib_dirs: ArrayList([:0]u8),
25 framework_dirs: ArrayList([:0]u8),
2526 rpaths: ArrayList([:0]u8),
2627 warnings: ArrayList([:0]u8),
2728
......@@ -29,6 +30,7 @@ pub const NativePaths = struct {
2930 var self: NativePaths = .{
3031 .include_dirs = ArrayList([:0]u8).init(allocator),
3132 .lib_dirs = ArrayList([:0]u8).init(allocator),
33 .framework_dirs = ArrayList([:0]u8).init(allocator),
3234 .rpaths = ArrayList([:0]u8).init(allocator),
3335 .warnings = ArrayList([:0]u8).init(allocator),
3436 };
......@@ -88,6 +90,19 @@ pub const NativePaths = struct {
8890 return self;
8991 }
9092
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
91106 if (!is_windows) {
92107 const triple = try Target.current.linuxTriple(allocator);
93108 const qual = Target.current.cpu.arch.ptrBitWidth();
......@@ -122,6 +137,7 @@ pub const NativePaths = struct {
122137 pub fn deinit(self: *NativePaths) void {
123138 deinitArray(&self.include_dirs);
124139 deinitArray(&self.lib_dirs);
140 deinitArray(&self.framework_dirs);
125141 deinitArray(&self.rpaths);
126142 deinitArray(&self.warnings);
127143 self.* = undefined;
......@@ -158,6 +174,16 @@ pub const NativePaths = struct {
158174 return self.appendArray(&self.warnings, s);
159175 }
160176
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
161187 pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void {
162188 const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args);
163189 errdefer self.warnings.allocator.free(item);
......@@ -237,8 +263,7 @@ pub const NativeTargetInfo = struct {
237263 // `---` `` ``--> Sub-version (Starting from Windows 10 onwards)
238264 // \ `--> Service pack (Always zero in the constants defined)
239265 // `--> OS version (Major & minor)
240 const os_ver: u16 =
241 @intCast(u16, version_info.dwMajorVersion & 0xff) << 8 |
266 const os_ver: u16 = @intCast(u16, version_info.dwMajorVersion & 0xff) << 8 |
242267 @intCast(u16, version_info.dwMinorVersion & 0xff);
243268 const sp_ver: u8 = 0;
244269 const sub_ver: u8 = if (os_ver >= 0x0A00) subver: {
src/Compilation.zig-6
......@@ -2079,12 +2079,6 @@ pub fn addCCArgs(
20792079 try argv.append("-ffunction-sections");
20802080 }
20812081
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
20882082 if (comp.bin_file.options.link_libcpp) {
20892083 const libcxx_include_path = try std.fs.path.join(arena, &[_][]const u8{
20902084 comp.zig_lib_directory.path.?, "libcxx", "include",
src/main.zig+25-1
......@@ -1436,11 +1436,35 @@ fn buildOutputType(
14361436 for (paths.warnings.items) |warning| {
14371437 warn("{}", .{warning});
14381438 }
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
14391452 try clang_argv.ensureCapacity(clang_argv.items.len + paths.include_dirs.items.len * 2);
1453 const isystem_flag = if (has_sysroot) "-iwithsysroot" else "-isystem";
14401454 for (paths.include_dirs.items) |include_dir| {
1441 clang_argv.appendAssumeCapacity("-isystem");
1455 clang_argv.appendAssumeCapacity(isystem_flag);
14421456 clang_argv.appendAssumeCapacity(include_dir);
14431457 }
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
14441468 for (paths.lib_dirs.items) |lib_dir| {
14451469 try lib_dirs.append(lib_dir);
14461470 }