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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// First-party C++ shim for `mlx::core` APIs that the vendored mlx-c layer
// does not expose. Compiled by build.rs against libmlx and hand-declared
// (NOT bindgen-generated) in src/lib.rs, so this stays out of the mlx-c
// bindgen drift gate.
//
// Policy: prefer mlx-c bindings for everything. Add a shim here ONLY for a
// genuine mlx-c coverage gap, and track it for upstreaming to
// ml-explore/mlx-c so this file shrinks over time.
//
// Current gaps bridged:
// - mlx::core::clear_streams() (mlx/stream.h) — no mlx-c equivalent.
//
// Upstream tracking:
// - mlx-c: request a `mlx_clear_streams()` binding for the above so this
// shim can be retired (pure binding gap; the C++ symbol exists).
// - mlx (ml-explore/mlx): there is NO per-stream teardown anywhere in
// mlx C++ — verified by exhaustive grep, the only stream destroy
// primitive is the bulk thread-wide `clear_streams()`. Real per-value
// RAII for the safe `Stream` wrapper is therefore impossible at the
// source level, not just unavailable via mlx-c. If scoped stream
// lifetimes ever matter, the only path is an upstream feature request
// for a `free_stream(Stream)` / per-stream destructor in mlx itself.
extern "C" // extern "C"