Skip to content

Commit a8491b4

Browse files
committed
hack: make it compile on asahi fedora
1 parent 73384f5 commit a8491b4

File tree

7 files changed

+27
-27
lines changed

7 files changed

+27
-27
lines changed

src/celt/celt.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ pub mod arch_h {
44
pub type opus_val16 = f32;
55
pub type opus_val32 = f32;
66
pub unsafe fn celt_fatal(str: *const i8, file: *const i8, line: i32) -> ! {
7-
let str = std::ffi::CStr::from_ptr(str);
8-
let file = std::ffi::CStr::from_ptr(file);
7+
let str = std::ffi::CStr::from_ptr(str as *const std::ffi::c_char);
8+
let file = std::ffi::CStr::from_ptr(file as *const std::ffi::c_char);
99
panic!(
1010
"Fatal (internal) error in {}, line {}: {}",
1111
file.to_str().unwrap(),
@@ -234,23 +234,23 @@ pub unsafe fn init_caps(m: *const OpusCustomMode, cap: *mut i32, LM: i32, C: i32
234234
i += 1;
235235
}
236236
}
237-
pub unsafe fn opus_strerror(error: i32) -> *const i8 {
238-
static mut error_strings: [*const i8; 8] = [
239-
b"success\0" as *const u8 as *const i8,
240-
b"invalid argument\0" as *const u8 as *const i8,
241-
b"buffer too small\0" as *const u8 as *const i8,
242-
b"internal error\0" as *const u8 as *const i8,
243-
b"corrupted stream\0" as *const u8 as *const i8,
244-
b"request not implemented\0" as *const u8 as *const i8,
245-
b"invalid state\0" as *const u8 as *const i8,
246-
b"memory allocation failed\0" as *const u8 as *const i8,
237+
pub unsafe fn opus_strerror(error: i32) -> *const std::ffi::c_char {
238+
static mut error_strings: [*const std::ffi::c_char; 8] = [
239+
b"success\0" as *const u8 as *const std::ffi::c_char,
240+
b"invalid argument\0" as *const u8 as *const std::ffi::c_char,
241+
b"buffer too small\0" as *const u8 as *const std::ffi::c_char,
242+
b"internal error\0" as *const u8 as *const std::ffi::c_char,
243+
b"corrupted stream\0" as *const u8 as *const std::ffi::c_char,
244+
b"request not implemented\0" as *const u8 as *const std::ffi::c_char,
245+
b"invalid state\0" as *const u8 as *const std::ffi::c_char,
246+
b"memory allocation failed\0" as *const u8 as *const std::ffi::c_char,
247247
];
248248
if error > 0 as i32 || error < -(7 as i32) {
249-
return b"unknown error\0" as *const u8 as *const i8;
249+
return b"unknown error\0" as *const u8 as *const std::ffi::c_char;
250250
} else {
251251
return error_strings[-error as usize];
252252
};
253253
}
254-
pub unsafe fn opus_get_version_string() -> *const i8 {
255-
return b"unsafe-libopus (rust port) 1.3.1\0" as *const u8 as *const i8;
254+
pub unsafe fn opus_get_version_string() -> *const std::ffi::c_char {
255+
return b"unsafe-libopus (rust port) 1.3.1\0" as *const u8 as *const std::ffi::c_char;
256256
}

src/externs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,28 @@ pub unsafe fn memset(dest: *mut core::ffi::c_void, ch: i32, count: u64) -> *mut
9999
dest
100100
}
101101

102-
pub unsafe fn strcmp(lhs: *const i8, rhs: *const i8) -> i32 {
102+
pub unsafe fn strcmp(lhs: *const std::ffi::c_char, rhs: *const std::ffi::c_char) -> i32 {
103103
let lhs = slice::from_raw_parts(lhs.cast::<u8>(), strlen(lhs) as usize);
104104
let rhs = slice::from_raw_parts(rhs.cast::<u8>(), strlen(rhs) as usize);
105105
lhs.cmp(rhs) as i32
106106
}
107107

108-
pub unsafe fn strdup(src: *const i8) -> *mut i8 {
108+
pub unsafe fn strdup(src: *const std::ffi::c_char) -> *mut std::ffi::c_char {
109109
let len = strlen(src);
110110
let dest = malloc(len + 1);
111111
memcpy(dest, src.cast(), len + 1);
112112
dest.cast()
113113
}
114114

115-
pub unsafe fn strlen(str: *const i8) -> u64 {
115+
pub unsafe fn strlen(str: *const std::ffi::c_char) -> u64 {
116116
let mut end = str;
117117
while *end != 0 {
118118
end = end.add(1);
119119
}
120120
end.offset_from(str) as u64
121121
}
122122

123-
pub unsafe fn strncmp(lhs: *const i8, rhs: *const i8, mut count: u64) -> i32 {
123+
pub unsafe fn strncmp(lhs: *const std::ffi::c_char, rhs: *const std::ffi::c_char, mut count: u64) -> i32 {
124124
let mut lhs = lhs.cast::<u8>();
125125
let mut rhs = rhs.cast::<u8>();
126126
while count > 0 && *lhs != 0 && *lhs == *rhs {

tests/opus_api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub mod test_opus_common_h {
1313
eprintln!("Please report this failure and include");
1414
eprintln!(
1515
"'make check fails {} at line {} for {}'",
16-
std::ffi::CStr::from_ptr(file).to_str().unwrap(),
16+
std::ffi::CStr::from_ptr(file as *const std::ffi::c_char).to_str().unwrap(),
1717
line,
1818
std::ffi::CStr::from_ptr(opus_get_version_string())
1919
.to_str()
@@ -4296,7 +4296,7 @@ pub unsafe fn test_malloc_fail() -> i32 {
42964296

42974297
unsafe fn main_0() -> i32 {
42984298
let mut total: i32 = 0;
4299-
let mut oversion: *const i8 = std::ptr::null::<i8>();
4299+
let mut oversion: *const std::ffi::c_char = std::ptr::null::<_>();
43004300
oversion = opus_get_version_string();
43014301
if oversion.is_null() {
43024302
_test_failed(
@@ -4306,7 +4306,7 @@ unsafe fn main_0() -> i32 {
43064306
}
43074307
eprintln!(
43084308
"Testing the {} API deterministically",
4309-
std::ffi::CStr::from_ptr(oversion).to_str().unwrap()
4309+
std::ffi::CStr::from_ptr(oversion as *const std::ffi::c_char).to_str().unwrap()
43104310
);
43114311
if (opus_strerror(-(32768 as i32))).is_null() {
43124312
_test_failed(

tests/opus_decode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub mod test_opus_common_h {
7878
eprintln!(
7979
"'make check SEED={} fails {} at line {} for {}'",
8080
iseed,
81-
std::ffi::CStr::from_ptr(file).to_str().unwrap(),
81+
std::ffi::CStr::from_ptr(file as *const std::ffi::c_char).to_str().unwrap(),
8282
line,
8383
std::ffi::CStr::from_ptr(opus_get_version_string())
8484
.to_str()

tests/opus_encode/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub mod test_opus_common_h {
7878
eprintln!(
7979
"'make check SEED={} fails {} at line {} for {}'",
8080
iseed,
81-
std::ffi::CStr::from_ptr(file).to_str().unwrap(),
81+
std::ffi::CStr::from_ptr(file as *const std::ffi::c_char).to_str().unwrap(),
8282
line,
8383
std::ffi::CStr::from_ptr(opus_get_version_string())
8484
.to_str()

tests/opus_padding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub mod test_opus_common_h {
1515
eprintln!(
1616
"'make check SEED={} fails {} at line {} for {}'",
1717
iseed,
18-
std::ffi::CStr::from_ptr(file).to_str().unwrap(),
18+
std::ffi::CStr::from_ptr(file as *const std::ffi::c_char).to_str().unwrap(),
1919
line,
2020
std::ffi::CStr::from_ptr(opus_get_version_string())
2121
.to_str()
@@ -67,7 +67,7 @@ pub unsafe fn test_overflow() -> i32 {
6767
1 as i32
6868
}
6969
unsafe fn main_0() -> i32 {
70-
let mut oversion: *const i8 = std::ptr::null::<i8>();
70+
let mut oversion: *const std::ffi::c_char = std::ptr::null::<_>();
7171
let mut _tests: i32 = 0 as i32;
7272
iseed = 0 as i32 as u32;
7373
oversion = opus_get_version_string();

tests/opus_projection/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub mod test_opus_common_h {
3232
eprintln!(
3333
"'make check SEED={} fails {} at line {} for {}'",
3434
iseed,
35-
std::ffi::CStr::from_ptr(file).to_str().unwrap(),
35+
std::ffi::CStr::from_ptr(file as *const std::ffi::c_char).to_str().unwrap(),
3636
line,
3737
std::ffi::CStr::from_ptr(opus_get_version_string())
3838
.to_str()

0 commit comments

Comments
 (0)