Commit 1c5c124
committed
coreaudio: make legacy-Apple shim robust to mach header exposure quirks
The pre-10.7 shim added in 24157a0 typedef'd dispatch_semaphore_t from
semaphore_t at file scope, expecting <mach/mach.h> and <mach/semaphore.h>
to expose the underlying typedef transitively. On some older SDK and
compiler combinations that chain doesn't settle by the time we read it,
producing:
coreaudio.c:66: error: syntax error before dispatch_semaphore_t
Two defensive changes:
1) Include <mach/mach_types.h> (canonical home of semaphore_t) and
<mach/sync_policy.h> (SYNC_POLICY_FIFO) explicitly rather than
relying on transitive inclusion from other mach headers.
2) Declare dispatch_semaphore_t as uintptr_t so its file-scope typedef
depends on nothing from the mach headers. semaphore_t is still
used inside function bodies, where the full header chain has been
processed regardless of ordering quirks; the uintptr_t handle is
cast to semaphore_t at each call site.
Modern SDKs take the existing <stdatomic.h> / <dispatch/dispatch.h> path
and are unaffected.1 parent 24157a0 commit 1c5c124
1 file changed
Lines changed: 19 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | | - | |
37 | 40 | | |
| 41 | + | |
38 | 42 | | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
54 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
55 | 65 | | |
56 | 66 | | |
57 | 67 | | |
| |||
60 | 70 | | |
61 | 71 | | |
62 | 72 | | |
63 | | - | |
64 | | - | |
| 73 | + | |
| 74 | + | |
65 | 75 | | |
66 | 76 | | |
67 | 77 | | |
68 | | - | |
| 78 | + | |
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
72 | | - | |
| 82 | + | |
73 | 83 | | |
74 | 84 | | |
75 | 85 | | |
76 | 86 | | |
77 | | - | |
| 87 | + | |
78 | 88 | | |
79 | 89 | | |
80 | 90 | | |
| |||
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
92 | | - | |
| 102 | + | |
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
96 | 106 | | |
97 | | - | |
| 107 | + | |
98 | 108 | | |
99 | 109 | | |
100 | 110 | | |
| |||
0 commit comments