Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 522588d

Browse files
authored
fix: feature flag exporting uv_compat symbols (#1313)
we already have some in deno, and right now we would have to remove our existing implementations (which work for napi), which would regress
1 parent c25f78f commit 522588d

2 files changed

Lines changed: 28 additions & 27 deletions

File tree

core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ include_js_files_for_snapshotting = []
2424
unsafe_runtime_options = []
2525
unsafe_use_unprotected_platform = []
2626
snapshot_flags_eager_parse = []
27+
uv_compat_export = []
2728

2829
[dependencies]
2930
anyhow.workspace = true

core/uv_compat.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ pub unsafe fn uv_loop_get_inner_ptr(
821821

822822
/// ### Safety
823823
/// `loop_` must be a valid, non-null pointer to an uninitialized `uv_loop_t`.
824-
#[unsafe(no_mangle)]
824+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
825825
pub unsafe extern "C" fn uv_loop_init(loop_: *mut uv_loop_t) -> c_int {
826826
let inner = Box::new(UvLoopInner::new());
827827
// SAFETY: Caller guarantees loop_ is a valid, writable pointer.
@@ -835,7 +835,7 @@ pub unsafe extern "C" fn uv_loop_init(loop_: *mut uv_loop_t) -> c_int {
835835

836836
/// ### Safety
837837
/// `loop_` must be a valid pointer to a `uv_loop_t` initialized by `uv_loop_init`.
838-
#[unsafe(no_mangle)]
838+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
839839
pub unsafe extern "C" fn uv_loop_close(loop_: *mut uv_loop_t) -> c_int {
840840
// SAFETY: Caller guarantees loop_ was initialized by uv_loop_init.
841841
unsafe {
@@ -850,7 +850,7 @@ pub unsafe extern "C" fn uv_loop_close(loop_: *mut uv_loop_t) -> c_int {
850850

851851
/// ### Safety
852852
/// `loop_` must be a valid pointer to a `uv_loop_t` initialized by `uv_loop_init`.
853-
#[unsafe(no_mangle)]
853+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
854854
pub unsafe extern "C" fn uv_now(loop_: *mut uv_loop_t) -> u64 {
855855
// SAFETY: Caller guarantees loop_ was initialized by uv_loop_init.
856856
let inner = unsafe { get_inner(loop_) };
@@ -859,12 +859,12 @@ pub unsafe extern "C" fn uv_now(loop_: *mut uv_loop_t) -> u64 {
859859

860860
/// ### Safety
861861
/// `_loop_` must be a valid pointer to a `uv_loop_t` initialized by `uv_loop_init`.
862-
#[unsafe(no_mangle)]
862+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
863863
pub unsafe extern "C" fn uv_update_time(_loop_: *mut uv_loop_t) {}
864864

865865
/// ### Safety
866866
/// `loop_` must be initialized by `uv_loop_init`. `handle` must be a valid, writable pointer.
867-
#[unsafe(no_mangle)]
867+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
868868
pub unsafe extern "C" fn uv_timer_init(
869869
loop_: *mut uv_loop_t,
870870
handle: *mut uv_timer_t,
@@ -886,7 +886,7 @@ pub unsafe extern "C" fn uv_timer_init(
886886

887887
/// ### Safety
888888
/// `handle` must be a valid pointer to a `uv_timer_t` initialized by `uv_timer_init`.
889-
#[unsafe(no_mangle)]
889+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
890890
pub unsafe extern "C" fn uv_timer_start(
891891
handle: *mut uv_timer_t,
892892
cb: uv_timer_cb,
@@ -924,7 +924,7 @@ pub unsafe extern "C" fn uv_timer_start(
924924

925925
/// ### Safety
926926
/// `handle` must be a valid pointer to a `uv_timer_t` initialized by `uv_timer_init`.
927-
#[unsafe(no_mangle)]
927+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
928928
pub unsafe extern "C" fn uv_timer_stop(handle: *mut uv_timer_t) -> c_int {
929929
// SAFETY: Caller guarantees handle was initialized by uv_timer_init.
930930
unsafe {
@@ -941,7 +941,7 @@ pub unsafe extern "C" fn uv_timer_stop(handle: *mut uv_timer_t) -> c_int {
941941

942942
/// ### Safety
943943
/// `handle` must be a valid pointer to a `uv_timer_t` initialized by `uv_timer_init`.
944-
#[unsafe(no_mangle)]
944+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
945945
pub unsafe extern "C" fn uv_timer_again(handle: *mut uv_timer_t) -> c_int {
946946
// SAFETY: Caller guarantees handle was initialized by uv_timer_init.
947947
unsafe {
@@ -973,15 +973,15 @@ pub unsafe extern "C" fn uv_timer_again(handle: *mut uv_timer_t) -> c_int {
973973

974974
/// ### Safety
975975
/// `handle` must be a valid pointer to a `uv_timer_t` initialized by `uv_timer_init`.
976-
#[unsafe(no_mangle)]
976+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
977977
pub unsafe extern "C" fn uv_timer_get_repeat(handle: *const uv_timer_t) -> u64 {
978978
// SAFETY: Caller guarantees handle is valid and initialized.
979979
unsafe { (*handle).repeat }
980980
}
981981

982982
/// ### Safety
983983
/// `handle` must be a valid pointer to a `uv_timer_t` initialized by `uv_timer_init`.
984-
#[unsafe(no_mangle)]
984+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
985985
pub unsafe extern "C" fn uv_timer_set_repeat(
986986
handle: *mut uv_timer_t,
987987
repeat: u64,
@@ -994,7 +994,7 @@ pub unsafe extern "C" fn uv_timer_set_repeat(
994994

995995
/// ### Safety
996996
/// `loop_` must be initialized by `uv_loop_init`. `handle` must be a valid, writable pointer.
997-
#[unsafe(no_mangle)]
997+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
998998
pub unsafe extern "C" fn uv_idle_init(
999999
loop_: *mut uv_loop_t,
10001000
handle: *mut uv_idle_t,
@@ -1012,7 +1012,7 @@ pub unsafe extern "C" fn uv_idle_init(
10121012

10131013
/// ### Safety
10141014
/// `handle` must be a valid pointer to a `uv_idle_t` initialized by `uv_idle_init`.
1015-
#[unsafe(no_mangle)]
1015+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
10161016
pub unsafe extern "C" fn uv_idle_start(
10171017
handle: *mut uv_idle_t,
10181018
cb: uv_idle_cb,
@@ -1035,7 +1035,7 @@ pub unsafe extern "C" fn uv_idle_start(
10351035

10361036
/// ### Safety
10371037
/// `handle` must be a valid pointer to a `uv_idle_t` initialized by `uv_idle_init`.
1038-
#[unsafe(no_mangle)]
1038+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
10391039
pub unsafe extern "C" fn uv_idle_stop(handle: *mut uv_idle_t) -> c_int {
10401040
// SAFETY: Caller guarantees handle was initialized by uv_idle_init.
10411041
unsafe {
@@ -1052,7 +1052,7 @@ pub unsafe extern "C" fn uv_idle_stop(handle: *mut uv_idle_t) -> c_int {
10521052

10531053
/// ### Safety
10541054
/// `loop_` must be initialized by `uv_loop_init`. `handle` must be a valid, writable pointer.
1055-
#[unsafe(no_mangle)]
1055+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
10561056
pub unsafe extern "C" fn uv_prepare_init(
10571057
loop_: *mut uv_loop_t,
10581058
handle: *mut uv_prepare_t,
@@ -1070,7 +1070,7 @@ pub unsafe extern "C" fn uv_prepare_init(
10701070

10711071
/// ### Safety
10721072
/// `handle` must be a valid pointer to a `uv_prepare_t` initialized by `uv_prepare_init`.
1073-
#[unsafe(no_mangle)]
1073+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
10741074
pub unsafe extern "C" fn uv_prepare_start(
10751075
handle: *mut uv_prepare_t,
10761076
cb: uv_prepare_cb,
@@ -1093,7 +1093,7 @@ pub unsafe extern "C" fn uv_prepare_start(
10931093

10941094
/// ### Safety
10951095
/// `handle` must be a valid pointer to a `uv_prepare_t` initialized by `uv_prepare_init`.
1096-
#[unsafe(no_mangle)]
1096+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
10971097
pub unsafe extern "C" fn uv_prepare_stop(handle: *mut uv_prepare_t) -> c_int {
10981098
// SAFETY: Caller guarantees handle was initialized by uv_prepare_init.
10991099
unsafe {
@@ -1110,7 +1110,7 @@ pub unsafe extern "C" fn uv_prepare_stop(handle: *mut uv_prepare_t) -> c_int {
11101110

11111111
/// ### Safety
11121112
/// `loop_` must be initialized by `uv_loop_init`. `handle` must be a valid, writable pointer.
1113-
#[unsafe(no_mangle)]
1113+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
11141114
pub unsafe extern "C" fn uv_check_init(
11151115
loop_: *mut uv_loop_t,
11161116
handle: *mut uv_check_t,
@@ -1128,7 +1128,7 @@ pub unsafe extern "C" fn uv_check_init(
11281128

11291129
/// ### Safety
11301130
/// `handle` must be a valid pointer to a `uv_check_t` initialized by `uv_check_init`.
1131-
#[unsafe(no_mangle)]
1131+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
11321132
pub unsafe extern "C" fn uv_check_start(
11331133
handle: *mut uv_check_t,
11341134
cb: uv_check_cb,
@@ -1151,7 +1151,7 @@ pub unsafe extern "C" fn uv_check_start(
11511151

11521152
/// ### Safety
11531153
/// `handle` must be a valid pointer to a `uv_check_t` initialized by `uv_check_init`.
1154-
#[unsafe(no_mangle)]
1154+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
11551155
pub unsafe extern "C" fn uv_check_stop(handle: *mut uv_check_t) -> c_int {
11561156
// SAFETY: Caller guarantees handle was initialized by uv_check_init.
11571157
unsafe {
@@ -1169,7 +1169,7 @@ pub unsafe extern "C" fn uv_check_stop(handle: *mut uv_check_t) -> c_int {
11691169
/// ### Safety
11701170
/// `handle` must be a valid pointer to any uv handle type (timer, idle, tcp, etc.) initialized
11711171
/// by the corresponding `uv_*_init` function. Must not be called twice on the same handle.
1172-
#[unsafe(no_mangle)]
1172+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
11731173
pub unsafe extern "C" fn uv_close(
11741174
handle: *mut uv_handle_t,
11751175
close_cb: Option<uv_close_cb>,
@@ -1210,7 +1210,7 @@ pub unsafe extern "C" fn uv_close(
12101210

12111211
/// ### Safety
12121212
/// `handle` must be a valid pointer to an initialized uv handle.
1213-
#[unsafe(no_mangle)]
1213+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
12141214
pub unsafe extern "C" fn uv_ref(handle: *mut uv_handle_t) {
12151215
// SAFETY: Caller guarantees handle is valid and initialized.
12161216
unsafe {
@@ -1220,7 +1220,7 @@ pub unsafe extern "C" fn uv_ref(handle: *mut uv_handle_t) {
12201220

12211221
/// ### Safety
12221222
/// `handle` must be a valid pointer to an initialized uv handle.
1223-
#[unsafe(no_mangle)]
1223+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
12241224
pub unsafe extern "C" fn uv_unref(handle: *mut uv_handle_t) {
12251225
// SAFETY: Caller guarantees handle is valid and initialized.
12261226
unsafe {
@@ -1230,7 +1230,7 @@ pub unsafe extern "C" fn uv_unref(handle: *mut uv_handle_t) {
12301230

12311231
/// ### Safety
12321232
/// `handle` must be a valid pointer to an initialized uv handle.
1233-
#[unsafe(no_mangle)]
1233+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
12341234
pub unsafe extern "C" fn uv_is_active(handle: *const uv_handle_t) -> c_int {
12351235
// SAFETY: Caller guarantees handle is valid and initialized.
12361236
unsafe {
@@ -1244,7 +1244,7 @@ pub unsafe extern "C" fn uv_is_active(handle: *const uv_handle_t) -> c_int {
12441244

12451245
/// ### Safety
12461246
/// `handle` must be a valid pointer to an initialized uv handle.
1247-
#[unsafe(no_mangle)]
1247+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
12481248
pub unsafe extern "C" fn uv_is_closing(handle: *const uv_handle_t) -> c_int {
12491249
// SAFETY: Caller guarantees handle is valid and initialized.
12501250
unsafe {
@@ -1515,7 +1515,7 @@ pub unsafe fn uv_tcp_getsockname(
15151515

15161516
/// ### Safety
15171517
/// `_tcp` must be a valid pointer to a `uv_tcp_t` initialized by `uv_tcp_init`.
1518-
#[unsafe(no_mangle)]
1518+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
15191519
pub unsafe extern "C" fn uv_tcp_keepalive(
15201520
_tcp: *mut uv_tcp_t,
15211521
_enable: c_int,
@@ -1529,7 +1529,7 @@ pub unsafe extern "C" fn uv_tcp_keepalive(
15291529

15301530
/// ### Safety
15311531
/// `_tcp` must be a valid pointer to a `uv_tcp_t` initialized by `uv_tcp_init`.
1532-
#[unsafe(no_mangle)]
1532+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
15331533
pub unsafe extern "C" fn uv_tcp_simultaneous_accepts(
15341534
_tcp: *mut uv_tcp_t,
15351535
_enable: c_int,
@@ -1539,7 +1539,7 @@ pub unsafe extern "C" fn uv_tcp_simultaneous_accepts(
15391539

15401540
/// ### Safety
15411541
/// `ip` must be a valid, null-terminated C string. `addr` must be a valid, writable pointer.
1542-
#[unsafe(no_mangle)]
1542+
#[cfg_attr(feature = "uv_compat_export", unsafe(no_mangle))]
15431543
pub unsafe extern "C" fn uv_ip4_addr(
15441544
ip: *const c_char,
15451545
port: c_int,

0 commit comments

Comments
 (0)