Commit 4eef306
authored
Cleanup pseudostack allocation paths (#72)
Consolidates the pseudostack machinery down to a single header and
brings the custom `THREADSAFE` mode in line with upstream Opus. No
functional change to decode/encode output.
## Consolidation
- Deletes the standalone `patches/stack_alloc.h` and the `unused
stack_alloc.patch`. `Silk/src` sources previously resolved this drifted
copy via -I patches; they now use the single patched
`celt/stack_alloc.h` like the celt sources already did.
- Drops the `#else` catch-all in the mode selector for an explicit
`#elif defined(NONTHREADSAFE_PSEUDOSTACK)` / `#elif
defined(THREADSAFE_PSEUDOSTACK)` chain.
## Matching upstream in the `THREADSAFE` branch
- Gates the `PUSH` overflow check behind `ENABLE_HARDENING`, the way
upstream already gates `NONTHREADSAFE`. Off by default, so it drops a
compare-and-branch from every allocation.
- Aligns with `ALIGNOF(type)` instead of `sizeof(type)` and cast via
`(type*)(void*)`, making `PUSH`/`ALIGN`/`ALIGNOF` byte-for-byte
identical to upstream's `NONTHREADSAFE` branch.
- Guards our fallback `celt_fatal` in `custom_support.h` behind
`!ENABLE_ASSERTIONS && !ENABLE_HARDENING`, since `arch.h` defines it
itself under those flags (avoids a redefinition collision under
hardening and a missing symbol without it).
## Bug fixes
- Aborts via `CELT_FATAL` when the per-thread pseudostack allocation
returns `NULL`, instead of writing through a near-`NULL` pointer (the
overflow guard degrades to a bare size check at a `NULL` base, and with
the guard now off by default there is no check at all).
- Routes `THREADSAFE` allocation through `opus_alloc_scratch()` in
`custom_support.h` rather than a second `Kconfig` mapping. The old copy
omitted `MALLOC_CAP_8BIT`, so the internal-RAM fallback could land in
IRAM and fault on the first byte/halfword store into the pseudostack.
- Size the `THREADSAFE` valgrind pseudostack to `GLOBAL_STACK_SIZE*2` to
match its redzone-doubling `PUSH`; it was allocating 1x and overrunning
past half usage. `_opus_alloc_and_register_pseudostack()` now takes the
size from `ALLOC_STACK` so the buffer and the `PUSH` advance stay in
step.1 parent d9be825 commit 4eef306
7 files changed
Lines changed: 70 additions & 456 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
106 | 112 | | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| 116 | + | |
110 | 117 | | |
111 | 118 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
65 | 86 | | |
66 | 87 | | |
67 | 88 | | |
| |||
70 | 91 | | |
71 | 92 | | |
72 | 93 | | |
73 | | - | |
| 94 | + | |
74 | 95 | | |
75 | | - | |
| 96 | + | |
76 | 97 | | |
77 | 98 | | |
78 | 99 | | |
79 | | - | |
80 | 100 | | |
81 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
82 | 107 | | |
83 | 108 | | |
84 | 109 | | |
85 | 110 | | |
86 | 111 | | |
87 | 112 | | |
88 | | - | |
| 113 | + | |
89 | 114 | | |
90 | 115 | | |
91 | 116 | | |
| |||
This file was deleted.
0 commit comments