Skip to content

Commit 5bf612d

Browse files
committed
use c-unwind for functions that we cannot guarantee won't panic
1 parent c6d28e2 commit 5bf612d

File tree

1 file changed

+49
-41
lines changed

1 file changed

+49
-41
lines changed

libz-rs-sys/src/lib.rs

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub type z_off_t = c_long;
9696
/// }
9797
/// ```
9898
#[export_name = prefix!(crc32)]
99-
pub unsafe extern "C" fn crc32(crc: c_ulong, buf: *const Bytef, len: uInt) -> c_ulong {
99+
pub unsafe extern "C-unwind" fn crc32(crc: c_ulong, buf: *const Bytef, len: uInt) -> c_ulong {
100100
match unsafe { slice_from_raw_parts(buf, len as usize) } {
101101
Some(buf) => zlib_rs::crc32(crc as u32, buf) as c_ulong,
102102
None => 0,
@@ -131,7 +131,7 @@ pub unsafe extern "C" fn crc32(crc: c_ulong, buf: *const Bytef, len: uInt) -> c_
131131
/// }
132132
/// ```
133133
#[export_name = prefix!(crc32_combine)]
134-
pub extern "C" fn crc32_combine(crc1: c_ulong, crc2: c_ulong, len2: z_off_t) -> c_ulong {
134+
pub extern "C-unwind" fn crc32_combine(crc1: c_ulong, crc2: c_ulong, len2: z_off_t) -> c_ulong {
135135
zlib_rs::crc32_combine(crc1 as u32, crc2 as u32, len2 as u64) as c_ulong
136136
}
137137

@@ -161,7 +161,7 @@ pub extern "C" fn crc32_combine(crc1: c_ulong, crc2: c_ulong, len2: z_off_t) ->
161161
/// }
162162
/// ```
163163
#[export_name = prefix!(adler32)]
164-
pub unsafe extern "C" fn adler32(adler: c_ulong, buf: *const Bytef, len: uInt) -> c_ulong {
164+
pub unsafe extern "C-unwind" fn adler32(adler: c_ulong, buf: *const Bytef, len: uInt) -> c_ulong {
165165
match unsafe { slice_from_raw_parts(buf, len as usize) } {
166166
Some(buf) => zlib_rs::adler32(adler as u32, buf) as c_ulong,
167167
None => 1,
@@ -196,7 +196,11 @@ pub unsafe extern "C" fn adler32(adler: c_ulong, buf: *const Bytef, len: uInt) -
196196
/// }
197197
/// ```
198198
#[export_name = prefix!(adler32_combine)]
199-
pub extern "C" fn adler32_combine(adler1: c_ulong, adler2: c_ulong, len2: z_off_t) -> c_ulong {
199+
pub extern "C-unwind" fn adler32_combine(
200+
adler1: c_ulong,
201+
adler2: c_ulong,
202+
len2: z_off_t,
203+
) -> c_ulong {
200204
match u64::try_from(len2) {
201205
Ok(len2) => zlib_rs::adler32_combine(adler1 as u32, adler2 as u32, len2) as c_ulong,
202206
Err(_) => {
@@ -262,7 +266,7 @@ pub extern "C" fn adler32_combine(adler1: c_ulong, adler2: c_ulong, len2: z_off_
262266
/// assert_eq!(dest, b"Ferris");
263267
/// ```
264268
#[export_name = prefix!(uncompress)]
265-
pub unsafe extern "C" fn uncompress(
269+
pub unsafe extern "C-unwind" fn uncompress(
266270
dest: *mut u8,
267271
destLen: *mut c_ulong,
268272
source: *const u8,
@@ -311,7 +315,7 @@ pub unsafe extern "C" fn uncompress(
311315
/// - `strm` is `NULL`
312316
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
313317
#[export_name = prefix!(inflate)]
314-
pub unsafe extern "C" fn inflate(strm: *mut z_stream, flush: i32) -> i32 {
318+
pub unsafe extern "C-unwind" fn inflate(strm: *mut z_stream, flush: i32) -> i32 {
315319
if let Some(stream) = InflateStream::from_stream_mut(strm) {
316320
let flush = InflateFlush::try_from(flush).unwrap_or_default();
317321
zlib_rs::inflate::inflate(stream, flush) as _
@@ -335,7 +339,7 @@ pub unsafe extern "C" fn inflate(strm: *mut z_stream, flush: i32) -> i32 {
335339
/// - `strm` is `NULL`
336340
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
337341
#[export_name = prefix!(inflateEnd)]
338-
pub unsafe extern "C" fn inflateEnd(strm: *mut z_stream) -> i32 {
342+
pub unsafe extern "C-unwind" fn inflateEnd(strm: *mut z_stream) -> i32 {
339343
match InflateStream::from_stream_mut(strm) {
340344
Some(stream) => {
341345
zlib_rs::inflate::end(stream);
@@ -369,7 +373,7 @@ pub unsafe extern "C" fn inflateEnd(strm: *mut z_stream) -> i32 {
369373
/// - `zfree`
370374
/// - `opaque`
371375
#[export_name = prefix!(inflateBackInit_)]
372-
pub unsafe extern "C" fn inflateBackInit_(
376+
pub unsafe extern "C-unwind" fn inflateBackInit_(
373377
_strm: z_streamp,
374378
_windowBits: c_int,
375379
_window: *mut c_uchar,
@@ -389,7 +393,7 @@ pub unsafe extern "C" fn inflateBackInit_(
389393
/// - `strm` is `NULL`
390394
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateBackInit_`]
391395
#[export_name = prefix!(inflateBack)]
392-
pub unsafe extern "C" fn inflateBack(
396+
pub unsafe extern "C-unwind" fn inflateBack(
393397
_strm: z_streamp,
394398
_in: in_func,
395399
_in_desc: *mut c_void,
@@ -416,7 +420,7 @@ pub unsafe extern "C" fn inflateBack(
416420
/// - `strm` is `NULL`
417421
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateBackInit_`]
418422
#[export_name = prefix!(inflateBackEnd)]
419-
pub unsafe extern "C" fn inflateBackEnd(_strm: z_streamp) -> c_int {
423+
pub unsafe extern "C-unwind" fn inflateBackEnd(_strm: z_streamp) -> c_int {
420424
todo!("inflateBack is not implemented yet")
421425
}
422426

@@ -445,7 +449,7 @@ pub unsafe extern "C" fn inflateBackEnd(_strm: z_streamp) -> c_int {
445449
/// - `source` is `NULL`
446450
/// - `source` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
447451
#[export_name = prefix!(inflateCopy)]
448-
pub unsafe extern "C" fn inflateCopy(dest: *mut z_stream, source: *const z_stream) -> i32 {
452+
pub unsafe extern "C-unwind" fn inflateCopy(dest: *mut z_stream, source: *const z_stream) -> i32 {
449453
let Some(dest) = (unsafe { dest.cast::<MaybeUninit<InflateStream>>().as_mut() }) else {
450454
return ReturnCode::StreamError as _;
451455
};
@@ -480,7 +484,7 @@ pub unsafe extern "C" fn inflateCopy(dest: *mut z_stream, source: *const z_strea
480484
/// - `strm` is `NULL`
481485
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
482486
#[export_name = prefix!(inflateMark)]
483-
pub unsafe extern "C" fn inflateMark(strm: *const z_stream) -> c_long {
487+
pub unsafe extern "C-unwind" fn inflateMark(strm: *const z_stream) -> c_long {
484488
if let Some(stream) = InflateStream::from_stream_ref(strm) {
485489
zlib_rs::inflate::mark(stream)
486490
} else {
@@ -514,7 +518,7 @@ pub unsafe extern "C" fn inflateMark(strm: *const z_stream) -> c_long {
514518
/// - `strm` is `NULL`
515519
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
516520
#[export_name = prefix!(inflateSync)]
517-
pub unsafe extern "C" fn inflateSync(strm: *mut z_stream) -> i32 {
521+
pub unsafe extern "C-unwind" fn inflateSync(strm: *mut z_stream) -> i32 {
518522
if let Some(stream) = InflateStream::from_stream_mut(strm) {
519523
zlib_rs::inflate::sync(stream) as _
520524
} else {
@@ -531,7 +535,7 @@ pub unsafe extern "C" fn inflateSync(strm: *mut z_stream) -> i32 {
531535
/// - `strm` is `NULL`
532536
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
533537
#[export_name = prefix!(inflateSyncPoint)]
534-
pub unsafe extern "C" fn inflateSyncPoint(strm: *mut z_stream) -> i32 {
538+
pub unsafe extern "C-unwind" fn inflateSyncPoint(strm: *mut z_stream) -> i32 {
535539
if let Some(stream) = InflateStream::from_stream_mut(strm) {
536540
zlib_rs::inflate::sync_point(stream) as i32
537541
} else {
@@ -565,7 +569,7 @@ pub unsafe extern "C" fn inflateSyncPoint(strm: *mut z_stream) -> i32 {
565569
/// - `zfree`
566570
/// - `opaque`
567571
#[export_name = prefix!(inflateInit_)]
568-
pub unsafe extern "C" fn inflateInit_(
572+
pub unsafe extern "C-unwind" fn inflateInit_(
569573
strm: z_streamp,
570574
version: *const c_char,
571575
stream_size: c_int,
@@ -598,7 +602,7 @@ pub unsafe extern "C" fn inflateInit_(
598602
/// - `zfree`
599603
/// - `opaque`
600604
#[export_name = prefix!(inflateInit2_)]
601-
pub unsafe extern "C" fn inflateInit2_(
605+
pub unsafe extern "C-unwind" fn inflateInit2_(
602606
strm: z_streamp,
603607
windowBits: c_int,
604608
version: *const c_char,
@@ -624,7 +628,7 @@ pub unsafe extern "C" fn inflateInit2_(
624628
/// - `zalloc`
625629
/// - `zfree`
626630
/// - `opaque`
627-
unsafe extern "C" fn inflateInit2(strm: z_streamp, windowBits: c_int) -> c_int {
631+
unsafe extern "C-unwind" fn inflateInit2(strm: z_streamp, windowBits: c_int) -> c_int {
628632
let Some(strm) = (unsafe { strm.as_mut() }) else {
629633
return ReturnCode::StreamError as _;
630634
};
@@ -659,7 +663,7 @@ unsafe extern "C" fn inflateInit2(strm: z_streamp, windowBits: c_int) -> c_int {
659663
/// - `strm` is `NULL`
660664
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
661665
#[export_name = prefix!(inflatePrime)]
662-
pub unsafe extern "C" fn inflatePrime(strm: *mut z_stream, bits: i32, value: i32) -> i32 {
666+
pub unsafe extern "C-unwind" fn inflatePrime(strm: *mut z_stream, bits: i32, value: i32) -> i32 {
663667
if let Some(stream) = InflateStream::from_stream_mut(strm) {
664668
zlib_rs::inflate::prime(stream, bits, value) as _
665669
} else {
@@ -685,7 +689,7 @@ pub unsafe extern "C" fn inflatePrime(strm: *mut z_stream, bits: i32, value: i32
685689
/// - `strm` is `NULL`
686690
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
687691
#[export_name = prefix!(inflateReset)]
688-
pub unsafe extern "C" fn inflateReset(strm: *mut z_stream) -> i32 {
692+
pub unsafe extern "C-unwind" fn inflateReset(strm: *mut z_stream) -> i32 {
689693
if let Some(stream) = InflateStream::from_stream_mut(strm) {
690694
zlib_rs::inflate::reset(stream) as _
691695
} else {
@@ -712,7 +716,7 @@ pub unsafe extern "C" fn inflateReset(strm: *mut z_stream) -> i32 {
712716
/// - `strm` is `NULL`
713717
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
714718
#[export_name = prefix!(inflateReset2)]
715-
pub unsafe extern "C" fn inflateReset2(strm: *mut z_stream, windowBits: c_int) -> i32 {
719+
pub unsafe extern "C-unwind" fn inflateReset2(strm: *mut z_stream, windowBits: c_int) -> i32 {
716720
if let Some(stream) = InflateStream::from_stream_mut(strm) {
717721
let config = InflateConfig {
718722
window_bits: windowBits,
@@ -751,7 +755,7 @@ pub unsafe extern "C" fn inflateReset2(strm: *mut z_stream, windowBits: c_int) -
751755
/// - `dictionary` is `NULL`
752756
/// - `dictionary` and `dictLength` satisfy the requirements of [`core::slice::from_raw_parts_mut::<u8>`]
753757
#[export_name = prefix!(inflateSetDictionary)]
754-
pub unsafe extern "C" fn inflateSetDictionary(
758+
pub unsafe extern "C-unwind" fn inflateSetDictionary(
755759
strm: *mut z_stream,
756760
dictionary: *const u8,
757761
dictLength: c_uint,
@@ -809,7 +813,7 @@ pub unsafe extern "C" fn inflateSetDictionary(
809813
/// - if `head.name` is not NULL, it must be writable for at least `head.name_max` bytes
810814
/// - if `head.comment` is not NULL, it must be writable for at least `head.comm_max` bytes
811815
#[export_name = prefix!(inflateGetHeader)]
812-
pub unsafe extern "C" fn inflateGetHeader(strm: z_streamp, head: gz_headerp) -> c_int {
816+
pub unsafe extern "C-unwind" fn inflateGetHeader(strm: z_streamp, head: gz_headerp) -> c_int {
813817
let Some(stream) = (unsafe { InflateStream::from_stream_mut(strm) }) else {
814818
return ReturnCode::StreamError as _;
815819
};
@@ -829,7 +833,7 @@ pub unsafe extern "C" fn inflateGetHeader(strm: z_streamp, head: gz_headerp) ->
829833
/// - `strm` is `NULL`
830834
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
831835
#[export_name = prefix!(inflateUndermine)]
832-
pub unsafe extern "C" fn inflateUndermine(strm: *mut z_stream, subvert: i32) -> c_int {
836+
pub unsafe extern "C-unwind" fn inflateUndermine(strm: *mut z_stream, subvert: i32) -> c_int {
833837
if let Some(stream) = InflateStream::from_stream_mut(strm) {
834838
zlib_rs::inflate::undermine(stream, subvert) as i32
835839
} else {
@@ -844,7 +848,7 @@ pub unsafe extern "C" fn inflateUndermine(strm: *mut z_stream, subvert: i32) ->
844848
/// - `strm` is `NULL`
845849
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`inflateInit_`] or similar
846850
#[export_name = prefix!(inflateResetKeep)]
847-
pub unsafe extern "C" fn inflateResetKeep(strm: *mut z_stream) -> c_int {
851+
pub unsafe extern "C-unwind" fn inflateResetKeep(strm: *mut z_stream) -> c_int {
848852
if let Some(stream) = InflateStream::from_stream_mut(strm) {
849853
zlib_rs::inflate::reset_keep(stream) as _
850854
} else {
@@ -863,7 +867,7 @@ pub unsafe extern "C" fn inflateResetKeep(strm: *mut z_stream) -> c_int {
863867
/// - `buf` is `NULL`
864868
/// - `buf` and `len` satisfy the requirements of [`core::slice::from_raw_parts`]
865869
#[export_name = prefix!(inflateCodesUsed)]
866-
pub unsafe extern "C" fn inflateCodesUsed(_strm: *mut z_stream) -> c_ulong {
870+
pub unsafe extern "C-unwind" fn inflateCodesUsed(_strm: *mut z_stream) -> c_ulong {
867871
todo!()
868872
}
869873

@@ -884,7 +888,7 @@ pub unsafe extern "C" fn inflateCodesUsed(_strm: *mut z_stream) -> c_ulong {
884888
/// - `strm` is `NULL`
885889
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`deflateInit_`] or similar
886890
#[export_name = prefix!(deflate)]
887-
pub unsafe extern "C" fn deflate(strm: *mut z_stream, flush: i32) -> c_int {
891+
pub unsafe extern "C-unwind" fn deflate(strm: *mut z_stream, flush: i32) -> c_int {
888892
if let Some(stream) = DeflateStream::from_stream_mut(strm) {
889893
match DeflateFlush::try_from(flush) {
890894
Ok(flush) => zlib_rs::deflate::deflate(stream, flush) as _,
@@ -918,7 +922,7 @@ pub unsafe extern "C" fn deflate(strm: *mut z_stream, flush: i32) -> c_int {
918922
/// - `head` is `NULL`
919923
/// - `head` satisfies the requirements of `&mut *head`
920924
#[export_name = prefix!(deflateSetHeader)]
921-
pub unsafe extern "C" fn deflateSetHeader(strm: *mut z_stream, head: gz_headerp) -> c_int {
925+
pub unsafe extern "C-unwind" fn deflateSetHeader(strm: *mut z_stream, head: gz_headerp) -> c_int {
922926
let Some(stream) = (unsafe { DeflateStream::from_stream_mut(strm) }) else {
923927
return ReturnCode::StreamError as _;
924928
};
@@ -944,7 +948,7 @@ pub unsafe extern "C" fn deflateSetHeader(strm: *mut z_stream, head: gz_headerp)
944948
/// - `strm` is `NULL`
945949
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`deflateInit_`] or similar
946950
#[export_name = prefix!(deflateBound)]
947-
pub unsafe extern "C" fn deflateBound(strm: *mut z_stream, sourceLen: c_ulong) -> c_ulong {
951+
pub unsafe extern "C-unwind" fn deflateBound(strm: *mut z_stream, sourceLen: c_ulong) -> c_ulong {
948952
zlib_rs::deflate::bound(DeflateStream::from_stream_mut(strm), sourceLen as usize) as c_ulong
949953
}
950954

@@ -1001,7 +1005,7 @@ pub unsafe extern "C" fn deflateBound(strm: *mut z_stream, sourceLen: c_ulong) -
10011005
/// assert_eq!(dest, [120, 156, 115, 75, 45, 42, 202, 44, 6, 0, 8, 6, 2, 108]);
10021006
/// ```
10031007
#[export_name = prefix!(compress)]
1004-
pub unsafe extern "C" fn compress(
1008+
pub unsafe extern "C-unwind" fn compress(
10051009
dest: *mut Bytef,
10061010
destLen: *mut c_ulong,
10071011
source: *const Bytef,
@@ -1044,7 +1048,7 @@ pub unsafe extern "C" fn compress(
10441048
/// - `source` is `NULL`
10451049
/// - `source` and `sourceLen` satisfy the requirements of [`core::slice::from_raw_parts`]
10461050
#[export_name = prefix!(compress2)]
1047-
pub unsafe extern "C" fn compress2(
1051+
pub unsafe extern "C-unwind" fn compress2(
10481052
dest: *mut Bytef,
10491053
destLen: *mut c_ulong,
10501054
source: *const Bytef,
@@ -1077,7 +1081,7 @@ pub unsafe extern "C" fn compress2(
10771081
///
10781082
/// Can be used before a [`compress`] or [`compress2`] call to allocate the destination buffer.
10791083
#[export_name = prefix!(compressBound)]
1080-
pub extern "C" fn compressBound(sourceLen: c_ulong) -> c_ulong {
1084+
pub extern "C-unwind" fn compressBound(sourceLen: c_ulong) -> c_ulong {
10811085
zlib_rs::deflate::compress_bound(sourceLen as usize) as c_ulong
10821086
}
10831087

@@ -1099,7 +1103,7 @@ pub extern "C" fn compressBound(sourceLen: c_ulong) -> c_ulong {
10991103
/// - `strm` is `NULL`
11001104
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`deflateInit_`] or similar
11011105
#[export_name = prefix!(deflateEnd)]
1102-
pub unsafe extern "C" fn deflateEnd(strm: *mut z_stream) -> i32 {
1106+
pub unsafe extern "C-unwind" fn deflateEnd(strm: *mut z_stream) -> i32 {
11031107
match DeflateStream::from_stream_mut(strm) {
11041108
Some(stream) => match zlib_rs::deflate::end(stream) {
11051109
Ok(_) => ReturnCode::Ok as _,
@@ -1127,7 +1131,7 @@ pub unsafe extern "C" fn deflateEnd(strm: *mut z_stream) -> i32 {
11271131
/// - `strm` is `NULL`
11281132
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`deflateInit_`] or similar
11291133
#[export_name = prefix!(deflateReset)]
1130-
pub unsafe extern "C" fn deflateReset(strm: *mut z_stream) -> i32 {
1134+
pub unsafe extern "C-unwind" fn deflateReset(strm: *mut z_stream) -> i32 {
11311135
match DeflateStream::from_stream_mut(strm) {
11321136
Some(stream) => zlib_rs::deflate::reset(stream) as _,
11331137
None => ReturnCode::StreamError as _,
@@ -1158,7 +1162,11 @@ pub unsafe extern "C" fn deflateReset(strm: *mut z_stream) -> i32 {
11581162
/// - `strm` is `NULL`
11591163
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`deflateInit_`] or similar
11601164
#[export_name = prefix!(deflateParams)]
1161-
pub unsafe extern "C" fn deflateParams(strm: z_streamp, level: c_int, strategy: c_int) -> c_int {
1165+
pub unsafe extern "C-unwind" fn deflateParams(
1166+
strm: z_streamp,
1167+
level: c_int,
1168+
strategy: c_int,
1169+
) -> c_int {
11621170
let Ok(strategy) = Strategy::try_from(strategy) else {
11631171
return ReturnCode::StreamError as _;
11641172
};
@@ -1189,7 +1197,7 @@ pub unsafe extern "C" fn deflateParams(strm: z_streamp, level: c_int, strategy:
11891197
/// - `dictionary` is `NULL`
11901198
/// - `dictionary` and `dictLength` satisfy the requirements of [`core::slice::from_raw_parts_mut::<u8>`]
11911199
#[export_name = prefix!(deflateSetDictionary)]
1192-
pub unsafe extern "C" fn deflateSetDictionary(
1200+
pub unsafe extern "C-unwind" fn deflateSetDictionary(
11931201
strm: z_streamp,
11941202
dictionary: *const Bytef,
11951203
dictLength: uInt,
@@ -1225,7 +1233,7 @@ pub unsafe extern "C" fn deflateSetDictionary(
12251233
/// - `strm` is `NULL`
12261234
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`deflateInit_`] or similar
12271235
#[export_name = prefix!(deflatePrime)]
1228-
pub unsafe extern "C" fn deflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int {
1236+
pub unsafe extern "C-unwind" fn deflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int {
12291237
match DeflateStream::from_stream_mut(strm) {
12301238
Some(stream) => zlib_rs::deflate::prime(stream, bits, value) as _,
12311239
None => ReturnCode::StreamError as _,
@@ -1257,7 +1265,7 @@ pub unsafe extern "C" fn deflatePrime(strm: z_streamp, bits: c_int, value: c_int
12571265
/// - `bits` is `NULL`
12581266
/// - `bits` satisfies the requirements of [`core::ptr::write::<c_int>`]
12591267
#[export_name = prefix!(deflatePending)]
1260-
pub unsafe extern "C" fn deflatePending(
1268+
pub unsafe extern "C-unwind" fn deflatePending(
12611269
strm: z_streamp,
12621270
pending: *mut c_uint,
12631271
bits: *mut c_int,
@@ -1304,7 +1312,7 @@ pub unsafe extern "C" fn deflatePending(
13041312
/// - `source` is `NULL`
13051313
/// - `source` satisfies the requirements of `&mut *strm` and was initialized with [`deflateInit_`] or similar
13061314
#[export_name = prefix!(deflateCopy)]
1307-
pub unsafe extern "C" fn deflateCopy(dest: z_streamp, source: z_streamp) -> c_int {
1315+
pub unsafe extern "C-unwind" fn deflateCopy(dest: z_streamp, source: z_streamp) -> c_int {
13081316
let Some(dest) = (unsafe { dest.cast::<MaybeUninit<DeflateStream>>().as_mut() }) else {
13091317
return ReturnCode::StreamError as _;
13101318
};
@@ -1384,7 +1392,7 @@ pub unsafe extern "C" fn deflateCopy(dest: z_streamp, source: z_streamp) -> c_in
13841392
/// let strm = unsafe { strm.assume_init_mut() };
13851393
/// ```
13861394
#[export_name = prefix!(deflateInit_)]
1387-
pub unsafe extern "C" fn deflateInit_(
1395+
pub unsafe extern "C-unwind" fn deflateInit_(
13881396
strm: z_streamp,
13891397
level: c_int,
13901398
version: *const c_char,
@@ -1474,7 +1482,7 @@ pub unsafe extern "C" fn deflateInit_(
14741482
/// let strm = unsafe { strm.assume_init_mut() };
14751483
/// ```
14761484
#[export_name = prefix!(deflateInit2_)]
1477-
pub unsafe extern "C" fn deflateInit2_(
1485+
pub unsafe extern "C-unwind" fn deflateInit2_(
14781486
strm: z_streamp,
14791487
level: c_int,
14801488
method: c_int,
@@ -1531,7 +1539,7 @@ pub unsafe extern "C" fn deflateInit2_(
15311539
/// - `strm` is `NULL`
15321540
/// - `strm` satisfies the requirements of `&mut *strm` and was initialized with [`deflateInit_`] or similar
15331541
#[export_name = prefix!(deflateTune)]
1534-
pub unsafe extern "C" fn deflateTune(
1542+
pub unsafe extern "C-unwind" fn deflateTune(
15351543
strm: z_streamp,
15361544
good_length: c_int,
15371545
max_lazy: c_int,

0 commit comments

Comments
 (0)