Commit e262d6d
committed
xnnpack: work around Zephyr clamp macro collision
Zephyr's <zephyr/sys/util.h> unconditionally defines a function-like
macro named "clamp" in the global namespace (in C mode) since its
Sept 2025 rename of Z_CLAMP -> clamp. XNNPACK uses "clamp" as an
identifier for a file-local static helper in
src/operators/fully-connected-nc.c:
static float clamp(const float value, const float minimum,
const float maximum) { ... }
The Zephyr macro expands over this function definition and breaks
the XNNPACK build.
Add a small prelude header (zephyr/include/xnnpack_zephyr_prelude.h)
that force-includes util.h and immediately #undef's clamp. The
util.h include guard then prevents any later transitive include
(via pthread.h etc.) from re-defining the macro.
The prelude is wired via -include on the xnnpack-base INTERFACE
target, propagating to all XNNPACK component targets.
Only clamp is undef'd; min/max have C++ guards upstream and do not
collide with XNNPACK's current C code.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>1 parent 0b50b01 commit e262d6d
2 files changed
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
191 | 200 | | |
192 | 201 | | |
193 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
0 commit comments