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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// @trace REQ-ENG-001
//! C library hooks for uWebSockets HTTP layer, BoringSSL TLS, and DNS.
//!
//! Compiled C libraries (all via cc::Build in respective build.rs):
//! - `libusockets.a` (bun_uws_sys): socket I/O, HTTP, WebSocket
//! - `libusockets_tls.a` (bun_uws_sys): TLS via BoringSSL
//! - `libbrotli.a` (bun_brotli_sys): Brotli compression
//! - `libzstd.a` (bun_zstd): Zstandard compression
//! - `liblshpack.a` (bun_lsquic_sys): HPACK header compression
//! - `libmimalloc.a` (bun_mimalloc_sys): memory allocator
//! - `libhighway.a` + `libhighway_strings.a` (bun_highway): SIMD string ops
//!
//! Loop symbols (`us_loop_run_bun_tick`, `us_wakeup_loop`, `uws_get_loop`)
//! are provided by `bao_uloop`.
// ──────────────────────────────────────────────────────────────
// lshpack — HPACK header compression for HTTP/2
// Provided by compiled C library: bun_lsquic_sys (vendor/lshpack, merged)
// ──────────────────────────────────────────────────────────────
// ──────────────────────────────────────────────────────────────
// SSL — provided by libusockets.a + libusockets_tls.a when compiled with TLS
// ──────────────────────────────────────────────────────────────
// us_get_default_ca_store / us_get_shared_default_ca_store — provided by
// compiled C++ code (root_certs.cpp in libusockets_tls.a).
// ──────────────────────────────────────────────────────────────
// uWebSockets — HTTP/WebSocket server C API
// Original: uNetworking/uWebSockets C++ wrapper (libuwsockets.a)
//
// SPEC (CLAUDE.md L13/L26) 禁止手写 C++ 已实现的符号的 Rust 翻译。
// `bun_uws_sys` 编译产出 libuwsockets.a,导出真实 uws_create_app /
// uws_app_any / uws_app_listen / uws_req_* / uws_res_* / us_socket_get_fd /
// us_socket_sendfile_needs_more 等符号。这里不再保留 stub —— 让 C++ 二进制
// 符号在链接器解析中胜出。
// ──────────────────────────────────────────────────────────────
// ──────────────────────────────────────────────────────────────
// C-library → Rust hooks (all owned elsewhere; do NOT define here)
// ──────────────────────────────────────────────────────────────
//
// Dual-def iron rule (STUB-INVENTORY): every hook below has exactly one
// `#[no_mangle]` definition in its owning crate:
//
// - Bun__JSC_onBeforeWait — bun_uws_sys/src/c_hooks.rs
// - Bun__panic — bun_uws_sys/src/c_hooks.rs
// - sys_epoll_pwait2 — bun_uws_sys/src/c_hooks.rs
// - Bun__lock__size — bun_threading::Mutex (real size of ReleaseImpl)
// - Bun__isEpollPwait2SupportedOnLinuxKernel — bun_analytics (kernel version check)
// - __bun_crash_handler_out_of_memory — bun_crash_handler
//
// TLS C→Rust hooks (root_certs.cpp / openssl.c us_ctx_cache_ex_idx) moved to
// their named owner `bao_uloop` (chained into every link scope that pulls the
// uSockets TLS archives). Do NOT reintroduce copies here — dual-def with
// bao_uloop / bun_runtime::product_native_symbols breaks consumer links:
// - Bun__Node__UseSystemCA — system CA flag (root_certs.cpp)
// - BUN__warn__extra_ca_load_failed — warning callback (root_certs.cpp)
// - bun_ssl_ctx_cache_on_free — BoringSSL EX_free callback (openssl.c)
// ──────────────────────────────────────────────────────────────
// BoringSSL extensions — now provided by compiled C++ library (bun_boringssl_sys)
// ──────────────────────────────────────────────────────────────
/// Force the linker to include all c_lib_stubs symbols.
/// Called from bao_native_stubs::force_link().