peachsim 0.1.1692 → 0.1.1700

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/cli/bridge-flow-runner.ts +61 -39
  2. package/cli/commands/agent-wrapper.ts +21 -10
  3. package/cli/commands/control.ts +27 -7
  4. package/cli/commands/coverage.ts +1 -1
  5. package/cli/commands/detect.ts +17 -4
  6. package/cli/commands/maestro-compare.ts +25 -99
  7. package/cli/help-core.ts +3 -4
  8. package/cli/maestro-compare.ts +172 -4
  9. package/cli/outbound-endpoints.ts +2 -10
  10. package/detox/index.ts +15 -0
  11. package/detox/launch-permissions.ts +169 -0
  12. package/dist-lib/agent-daemon-client.cjs +2 -2
  13. package/dist-lib/agent-events.cjs +2 -2
  14. package/dist-lib/attached-projects.cjs +2 -2
  15. package/dist-lib/auth/shared-session.cjs +2 -2
  16. package/dist-lib/backend-origin.cjs +2 -2
  17. package/dist-lib/beta.cjs +2 -2
  18. package/dist-lib/beta.mjs +1 -1
  19. package/dist-lib/bridge-constants.cjs +2 -2
  20. package/dist-lib/bridge-contract-input.cjs +2 -2
  21. package/dist-lib/bridge-contract-input.mjs +1 -1
  22. package/dist-lib/bridge-contract.cjs +2 -2
  23. package/dist-lib/bridge-contract.mjs +1 -1
  24. package/dist-lib/bundle-channel.cjs +18273 -15925
  25. package/dist-lib/capture-contract.cjs +2 -2
  26. package/dist-lib/capture-contract.mjs +1 -1
  27. package/dist-lib/cloud-contract.cjs +2 -2
  28. package/dist-lib/cloud-contract.mjs +1 -1
  29. package/dist-lib/cloud-test-args.cjs +2 -2
  30. package/dist-lib/cloud-test-args.mjs +1 -1
  31. package/dist-lib/cloud.cjs +2 -2
  32. package/dist-lib/cloud.mjs +1 -1
  33. package/dist-lib/config.cjs +2 -2
  34. package/dist-lib/config.mjs +1 -1
  35. package/dist-lib/detox/index.cjs +104 -3
  36. package/dist-lib/dev-bundle-resolution.cjs +208 -44
  37. package/dist-lib/expo-swift-bundle.cjs +2349 -1778
  38. package/dist-lib/expo-swift-metadata.cjs +2 -2
  39. package/dist-lib/expo-swift-metadata.mjs +1 -1
  40. package/dist-lib/home-paths.cjs +2 -2
  41. package/dist-lib/host/bridge-host.cjs +7885 -3334
  42. package/dist-lib/host/fetch-proxy-handler.cjs +331 -39
  43. package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
  44. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  45. package/dist-lib/host/replacement-module-handler.cjs +2 -2
  46. package/dist-lib/host/websocket-proxy.cjs +2 -2
  47. package/dist-lib/index.cjs +297 -77
  48. package/dist-lib/jump-to-source-babel.cjs +2 -2
  49. package/dist-lib/jump-to-source-native.cjs +2 -2
  50. package/dist-lib/kotlin-host.cjs +2 -2
  51. package/dist-lib/menu.cjs +2 -2
  52. package/dist-lib/menu.mjs +1 -1
  53. package/dist-lib/metro-fingerprint-registry.cjs +2 -2
  54. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  55. package/dist-lib/metro-production-bundle.cjs +2 -2
  56. package/dist-lib/metro-production-bundle.mjs +1 -1
  57. package/dist-lib/metro.cjs +294 -74
  58. package/dist-lib/native-app-identity-project.cjs +48 -37
  59. package/dist-lib/native-app-identity-project.mjs +47 -36
  60. package/dist-lib/native-app-identity.cjs +2 -2
  61. package/dist-lib/native-app-identity.mjs +1 -1
  62. package/dist-lib/native-firebase-metadata.cjs +2 -2
  63. package/dist-lib/native-firebase-metadata.mjs +1 -1
  64. package/dist-lib/plist.cjs +2 -2
  65. package/dist-lib/plist.mjs +1 -1
  66. package/dist-lib/profiles.cjs +2 -2
  67. package/dist-lib/public-brand.cjs +2 -2
  68. package/dist-lib/public-origins-lib-esm.json +24 -23
  69. package/dist-lib/public-origins-lib.json +199 -79
  70. package/dist-lib/react-native-host-modules.cjs +2 -2
  71. package/dist-lib/react-native-host-modules.mjs +1 -1
  72. package/dist-lib/reap-browser.cjs +2 -2
  73. package/dist-lib/scripts/dev-server-scanner.cjs +206 -31
  74. package/dist-lib/sdk.cjs +2 -2
  75. package/dist-lib/sdk.mjs +1 -1
  76. package/dist-lib/skills.cjs +19600 -15992
  77. package/dist-lib/swift-compile.cjs +640 -402
  78. package/dist-lib/swift-compile.mjs +595 -357
  79. package/dist-lib/swift-package.cjs +24 -20
  80. package/dist-lib/swift-package.mjs +23 -19
  81. package/dist-lib/swift-submit.cjs +2 -2
  82. package/dist-lib/swift-submit.mjs +1 -1
  83. package/dist-lib/swift-toolchain.cjs +31 -4
  84. package/dist-lib/swift.cjs +2 -2
  85. package/dist-lib/vite-swift.cjs +1559 -1208
  86. package/dist-lib/vite.cjs +251 -42
  87. package/dist-lib/worklet-executable.cjs +2 -2
  88. package/dist-lib/worklet-executable.mjs +1 -1
  89. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +1 -1
  90. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
  91. package/dist-types/packages/peach-engine/src/engine/scroll-pan-contacts.d.ts +3 -1
  92. package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +7 -0
  93. package/dist-types/packages/peach-engine/src/engine/types.d.ts +2 -1
  94. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
  95. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  96. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +1 -0
  97. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +17 -0
  98. package/dist-types/packages/peach-engine/src/render-worker/worker-input-runtime.d.ts +2 -1
  99. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +3 -0
  100. package/dist-types/packages/peach-globals/src/cameraBridgeContract.d.ts +1 -0
  101. package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +1 -0
  102. package/dist-types/packages/peach-globals/src/shellHostBridgeContract.d.ts +3 -0
  103. package/dist-types/packages/peach-kit/src/materials/types.d.ts +1 -0
  104. package/package.json +1 -1
  105. package/runtime-companion.json +1 -1
  106. package/scripts/dev-server-scanner.ts +4 -0
  107. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Alpha.h +2282 -0
  108. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/BasicImageTypes.h +55 -0
  109. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Conversion.h +10551 -6
  110. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Convolution.h +4236 -3
  111. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Geometry.h +827 -8
  112. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Histogram.h +1369 -0
  113. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Morphology.h +1243 -0
  114. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/Transform.h +1747 -0
  115. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage.h +291 -2
  116. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_CVUtilities.h +1283 -0
  117. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Types.h +811 -91
  118. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Headers/vImage_Utilities.h +1342 -25
  119. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns.h +2738 -0
  120. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_constants.h +1685 -0
  121. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_graph.h +913 -0
  122. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/BNNS/bnns_structures.h +1917 -0
  123. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/LinearAlgebra.h +23 -0
  124. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/arithmetic.h +209 -0
  125. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/base.h +104 -0
  126. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/linear_systems.h +77 -0
  127. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/matrix.h +554 -0
  128. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/norms.h +58 -0
  129. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/object.h +186 -0
  130. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/splat.h +86 -0
  131. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/LinearAlgebra/vector.h +364 -0
  132. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Integration.h +195 -0
  133. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Quadrature/Quadrature.h +44 -0
  134. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/BLAS.h +2330 -0
  135. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/BLAS/Types.h +123 -0
  136. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Solve.h +8339 -0
  137. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementation.h +520 -0
  138. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/SolveImplementationTyped.h +1893 -0
  139. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/Sparse/Sparse.h +10 -0
  140. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/blas_new.h +1098 -0
  141. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas.h +859 -0
  142. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/cblas_new.h +1134 -0
  143. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h +10555 -0
  144. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/fortran_blas.h +695 -0
  145. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack.h +38526 -0
  146. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_types.h +60 -0
  147. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/lapack_version.h +20 -0
  148. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/thread_api.h +50 -0
  149. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBasicOps.h +1218 -0
  150. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vBigNum.h +1458 -0
  151. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP.h +10377 -0
  152. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vDSP_translate.h +167 -0
  153. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vForce.h +1243 -0
  154. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLib.h +114 -0
  155. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vecLibTypes.h +146 -0
  156. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vectorOps.h +1106 -0
  157. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/vfp.h +294 -0
  158. package/sdk/ios/System/Library/Frameworks/Accelerate.framework/Headers/Accelerate.h +25 -1
  159. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFArray.h +673 -0
  160. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFAvailability.h +232 -0
  161. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h +827 -0
  162. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCalendar.h +121 -0
  163. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCharacterSet.h +387 -0
  164. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFData.h +79 -0
  165. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDate.h +122 -0
  166. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDictionary.h +674 -0
  167. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFError.h +182 -0
  168. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFLocale.h +213 -0
  169. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNotificationCenter.h +82 -0
  170. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFNumber.h +129 -0
  171. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFSet.h +491 -0
  172. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h +883 -2
  173. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFTimeZone.h +98 -0
  174. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +11 -229
  175. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -6
  176. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +2 -1
  177. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h +1 -0
  178. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecBase.h +906 -3
  179. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecCertificate.h +613 -0
  180. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecItem.h +1284 -29
  181. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecPolicy.h +441 -0
  182. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecTrust.h +845 -0
  183. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/Security.h +4 -0
  184. package/sdk/ios/usr/include/AvailabilityMacros.h +3985 -0
  185. package/sdk/ios/usr/include/copyfile.h +143 -0
  186. package/sdk/ios/usr/include/malloc/_malloc.h +143 -0
  187. package/sdk/ios/usr/include/malloc/_malloc_type.h +153 -0
  188. package/sdk/ios/usr/include/malloc/_platform.h +80 -0
  189. package/sdk/ios/usr/include/malloc/_ptrcheck.h +43 -0
  190. package/sdk/ios/usr/include/malloc/malloc.h +768 -0
  191. package/sdk/ios/usr/include/os/availability.h +168 -6
  192. package/sdk/ios/usr/include/os/base.h +351 -0
  193. package/sdk/ios/usr/include/os/clock.h +18 -0
  194. package/sdk/ios/usr/include/os/lock.h +232 -10
  195. package/sdk/ios/usr/include/os/log.h +521 -38
  196. package/sdk/ios/usr/include/os/object.h +320 -3
  197. package/sdk/ios/usr/include/os/trace.h +492 -0
  198. package/sdk/ios/usr/include/os/trace_base.h +167 -0
  199. package/sdk/ios/usr/include/os/workgroup.h +37 -0
  200. package/sdk/ios/usr/include/os/workgroup_base.h +91 -0
  201. package/sdk/ios/usr/include/os/workgroup_interval.h +156 -0
  202. package/sdk/ios/usr/include/os/workgroup_object.h +359 -0
  203. package/sdk/ios/usr/include/os/workgroup_parallel.h +76 -0
  204. package/sdk/ios/usr/include/sys/cdefs.h +38 -0
  205. package/sdk/ios/wasm/include/unistd.h +3 -0
  206. package/skills/contrast/SKILL.md +3 -0
  207. package/src/codex-client.ts +11 -6
  208. package/src/dev-bundle-resolution.ts +124 -48
  209. package/src/expo-native-workspace.ts +176 -0
  210. package/src/expo-swift-host.ts +161 -26
  211. package/src/expo-swift-ready.ts +14 -28
  212. package/src/expoSwiftContract.ts +4 -1
  213. package/src/generated/swift-c-predefines.json +68 -12
  214. package/src/host/bridge-host.ts +5 -0
  215. package/src/installed-package-versions.ts +14 -1
  216. package/src/metro-project-root.ts +44 -33
  217. package/src/native-app-identity-project.ts +1 -0
  218. package/src/nitro-adapter.lock.json +916 -10
  219. package/src/nitro-adapter.ts +33 -24
  220. package/src/nitro-bundle.ts +108 -22
  221. package/src/nitro-compile.ts +32 -5
  222. package/src/nitro-source.ts +13 -3
  223. package/src/nitroAdapterContract.ts +100 -20
  224. package/src/node-http-fetch.ts +116 -0
  225. package/src/packageVersionsContract.ts +46 -0
  226. package/src/serverDiscoveryContract.ts +1 -0
  227. package/src/settingsContract.ts +0 -30
  228. package/src/swift-binary-modules.ts +20 -5
  229. package/src/swift-compile.ts +168 -48
  230. package/src/swift-coverage/xcode-assets.ts +4 -3
  231. package/src/swift-host.ts +14 -3
  232. package/src/swift-objc-compile.ts +32 -5
  233. package/src/swift-objc-metadata.ts +2 -2
  234. package/src/swift-objc-platform.ts +2 -2
  235. package/src/swift-objc-standin.ts +43 -13
  236. package/src/swift-package.ts +33 -26
  237. package/src/swift-source-pods.ts +126 -41
  238. package/src/swift-standin-digest.ts +77 -0
  239. package/src/swift-standin-emit.ts +40 -4
  240. package/src/swift-standins.ts +68 -19
  241. package/src/swift-toolchain.ts +38 -0
  242. package/src/swiftContract.ts +8 -0
  243. package/src/vite-plugin.ts +0 -10
  244. package/src/xcode-project.ts +62 -42
  245. package/src/settings-flags.ts +0 -107
@@ -1,7 +1,97 @@
1
- #pragma once
1
+ /*
2
+ * Copyright (c) 2016 Apple Inc. All rights reserved.
3
+ *
4
+ * @APPLE_APACHE_LICENSE_HEADER_START@
5
+ *
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
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
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.
17
+ *
18
+ * @APPLE_APACHE_LICENSE_HEADER_END@
19
+ */
20
+
21
+ #ifndef __OS_LOCK__
22
+ #define __OS_LOCK__
23
+
24
+ #include <Availability.h>
25
+ #include <sys/cdefs.h>
26
+ #include <stddef.h>
2
27
  #include <stdint.h>
3
28
  #include <stdbool.h>
4
- typedef struct os_unfair_lock_s { uint32_t _os_unfair_lock_opaque; } os_unfair_lock, *os_unfair_lock_t;
29
+ #include <os/base.h>
30
+
31
+ OS_ASSUME_NONNULL_BEGIN
32
+
33
+ /*! @header
34
+ * Low-level lock API.
35
+ */
36
+
37
+ #define OS_LOCK_API_VERSION 20160309
38
+
39
+ __BEGIN_DECLS
40
+
41
+ #define OS_UNFAIR_LOCK_AVAILABILITY \
42
+ __API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
43
+
44
+ /*!
45
+ * @typedef os_unfair_lock
46
+ *
47
+ * @abstract
48
+ * Low-level lock that allows waiters to block efficiently on contention.
49
+ *
50
+ * os_unfair_lock is an appropriate lock for cases where simple and lightweight
51
+ * mutual exclusion is needed.
52
+ * It can be intrusively stored inline in a datastructure without needing a
53
+ * separate allocation, reducing memory consumption and cost of indirection.
54
+ * For situations where something more sophisticated like condition waits or
55
+ * FIFO ordering is needed, use appropriate higher level APIs such as those from
56
+ * the pthread or dispatch subsystems.
57
+ *
58
+ * The values stored in the lock should be considered opaque and implementation
59
+ * defined, they contain thread ownership information that the system may use
60
+ * to attempt to resolve priority inversions. However, it is guaranteed that an
61
+ * unlocked lock with no other contending threads will have the value
62
+ * OS_UNFAIR_LOCK_INIT, and so bytewise copying the value to a new location is
63
+ * equivalent to initializing a new lock in the new location.
64
+ *
65
+ * This lock must be unlocked from the same thread that locked it, attempts to
66
+ * unlock from a different thread will cause an assertion aborting the process.
67
+ *
68
+ * This lock must not be accessed from multiple processes or threads via shared
69
+ * or multiply-mapped memory, because the lock implementation relies on the
70
+ * address of the lock value and identity of the owning process.
71
+ *
72
+ * Must be initialized with OS_UNFAIR_LOCK_INIT.
73
+ *
74
+ * @discussion
75
+ * The name 'unfair' indicates that there is no attempt at enforcing acquisition
76
+ * fairness, e.g. an unlocker can potentially immediately reacquire the lock
77
+ * before a woken up waiter gets an opportunity to attempt to acquire the lock.
78
+ * This is often advantageous for performance reasons, but also makes starvation
79
+ * of waiters a possibility.
80
+ *
81
+ * This lock is suitable as a drop-in replacement for the deprecated OSSpinLock,
82
+ * providing much better behavior under contention.
83
+ *
84
+ * In Swift, note that use of the `&` operator on an unfair lock can copy or move
85
+ * the lock memory, leading to misbehavior. Use an OSAllocatedUnfairLock to safely wrap
86
+ * access to the lock memory instead. If you use os_unfair_lock APIs directly,
87
+ * always make sure to store and use the lock in memory with a stable address.
88
+ */
89
+ OS_UNFAIR_LOCK_AVAILABILITY
90
+ typedef struct os_unfair_lock_s {
91
+ uint32_t _os_unfair_lock_opaque;
92
+ } os_unfair_lock, *os_unfair_lock_t;
93
+
94
+ #ifndef OS_UNFAIR_LOCK_INIT
5
95
  #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
6
96
  #define OS_UNFAIR_LOCK_INIT ((os_unfair_lock){0})
7
97
  #elif defined(__cplusplus) && __cplusplus >= 201103L
@@ -11,14 +101,146 @@ typedef struct os_unfair_lock_s { uint32_t _os_unfair_lock_opaque; } os_unfair_l
11
101
  #else
12
102
  #define OS_UNFAIR_LOCK_INIT {0}
13
103
  #endif
14
- #ifdef __cplusplus
15
- extern "C" {
16
- #endif
104
+ #endif // OS_UNFAIR_LOCK_INIT
105
+
106
+ /*!
107
+ * @function os_unfair_lock_lock
108
+ *
109
+ * @abstract
110
+ * Locks an os_unfair_lock.
111
+ *
112
+ * @param lock
113
+ * Pointer to an os_unfair_lock.
114
+ */
115
+ OS_UNFAIR_LOCK_AVAILABILITY
116
+ OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
117
+ OS_SWIFT_UNAVAILABLE_FROM_ASYNC("Use OSAllocatedUnfairLock.performWhileLocked() for async-safe scoped locking")
17
118
  void os_unfair_lock_lock(os_unfair_lock_t lock);
119
+
120
+ /*!
121
+ * @function os_unfair_lock_trylock
122
+ *
123
+ * @abstract
124
+ * Locks an os_unfair_lock if it is not already locked.
125
+ *
126
+ * @discussion
127
+ * It is invalid to surround this function with a retry loop, if this function
128
+ * returns false, the program must be able to proceed without having acquired
129
+ * the lock, or it must call os_unfair_lock_lock() directly (a retry loop around
130
+ * os_unfair_lock_trylock() amounts to an inefficient implementation of
131
+ * os_unfair_lock_lock() that hides the lock waiter from the system and prevents
132
+ * resolution of priority inversions).
133
+ *
134
+ * @param lock
135
+ * Pointer to an os_unfair_lock.
136
+ *
137
+ * @result
138
+ * Returns true if the lock was succesfully locked and false if the lock was
139
+ * already locked.
140
+ */
141
+ OS_UNFAIR_LOCK_AVAILABILITY
142
+ OS_EXPORT OS_NOTHROW OS_WARN_RESULT OS_NONNULL_ALL
143
+ OS_SWIFT_UNAVAILABLE_FROM_ASYNC("Use OSAllocatedUnfairLock.tryPerformWhileLocked() for async-safe scoped locking")
18
144
  bool os_unfair_lock_trylock(os_unfair_lock_t lock);
145
+
146
+ /*!
147
+ * @function os_unfair_lock_unlock
148
+ *
149
+ * @abstract
150
+ * Unlocks an os_unfair_lock.
151
+ *
152
+ * @param lock
153
+ * Pointer to an os_unfair_lock.
154
+ */
155
+ OS_UNFAIR_LOCK_AVAILABILITY
156
+ OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
157
+ OS_SWIFT_UNAVAILABLE_FROM_ASYNC("Use OSAllocatedUnfairLock.performWhileLocked() for async-safe scoped locking")
19
158
  void os_unfair_lock_unlock(os_unfair_lock_t lock);
20
- void os_unfair_lock_assert_owner(os_unfair_lock_t lock);
21
- void os_unfair_lock_assert_not_owner(os_unfair_lock_t lock);
22
- #ifdef __cplusplus
23
- }
24
- #endif
159
+
160
+ /*!
161
+ * @function os_unfair_lock_assert_owner
162
+ *
163
+ * @abstract
164
+ * Asserts that the calling thread is the current owner of the specified
165
+ * unfair lock.
166
+ *
167
+ * @discussion
168
+ * If the lock is currently owned by the calling thread, this function returns.
169
+ *
170
+ * If the lock is unlocked or owned by a different thread, this function
171
+ * asserts and terminates the process.
172
+ *
173
+ * @param lock
174
+ * Pointer to an os_unfair_lock.
175
+ */
176
+ OS_UNFAIR_LOCK_AVAILABILITY
177
+ OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
178
+ void os_unfair_lock_assert_owner(const os_unfair_lock *lock);
179
+
180
+ /*!
181
+ * @function os_unfair_lock_assert_not_owner
182
+ *
183
+ * @abstract
184
+ * Asserts that the calling thread is not the current owner of the specified
185
+ * unfair lock.
186
+ *
187
+ * @discussion
188
+ * If the lock is unlocked or owned by a different thread, this function
189
+ * returns.
190
+ *
191
+ * If the lock is currently owned by the current thread, this function asserts
192
+ * and terminates the process.
193
+ *
194
+ * @param lock
195
+ * Pointer to an os_unfair_lock.
196
+ */
197
+ OS_UNFAIR_LOCK_AVAILABILITY
198
+ OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
199
+ void os_unfair_lock_assert_not_owner(const os_unfair_lock *lock);
200
+
201
+ /*!
202
+ * @typedef os_unfair_lock_flags_t
203
+ *
204
+ * @const OS_UNFAIR_LOCK_FLAG_ADAPTIVE_SPIN
205
+ * This flag allows the caller of os_unfair_lock_lock_with_flags API to spin
206
+ * temporarily before blocking, particularly useful when the holder of the
207
+ * lock is on core. This should only be used for locks where the protected
208
+ * critical section is always extremely short.
209
+ */
210
+ OS_REFINED_FOR_SWIFT
211
+ OS_OPTIONS(os_unfair_lock_flags, uint32_t,
212
+ OS_UNFAIR_LOCK_FLAG_NONE
213
+ __API_AVAILABLE(macos(15.0), ios(18.0),
214
+ tvos(18.0), watchos(11.0), visionos(2.0))
215
+ OS_SWIFT_UNAVAILABLE("Use OSAllocatedUnfairLock APIs that do not require flags.")
216
+ = 0x00000000,
217
+ OS_UNFAIR_LOCK_FLAG_ADAPTIVE_SPIN
218
+ __API_AVAILABLE(macos(15.0), ios(18.0),
219
+ tvos(18.0), watchos(11.0), visionos(2.0))
220
+ OS_SWIFT_UNAVAILABLE("Use OSAllocatedUnfairLockFlags.AdaptiveSpin")
221
+ = 0x00040000,
222
+ );
223
+
224
+ /*!
225
+ * @function os_unfair_lock_lock_with_flags
226
+ *
227
+ * @abstract
228
+ * Locks an os_unfair_lock.
229
+ *
230
+ * @param lock
231
+ * Pointer to an os_unfair_lock.
232
+ *
233
+ * @param flags
234
+ * Flags to alter the behavior of the lock. See os_unfair_lock_flags_t.
235
+ */
236
+ __API_AVAILABLE(macos(15.0), ios(18.0), tvos(18.0), watchos(11.0), visionos(2.0))
237
+ OS_EXPORT OS_NOTHROW OS_NONNULL_ALL
238
+ OS_SWIFT_UNAVAILABLE_FROM_ASYNC("Use OSAllocatedUnfairLock for async-safe scoped locking")
239
+ void os_unfair_lock_lock_with_flags(os_unfair_lock_t lock,
240
+ os_unfair_lock_flags_t flags);
241
+
242
+ __END_DECLS
243
+
244
+ OS_ASSUME_NONNULL_END
245
+
246
+ #endif // __OS_LOCK__