Skip to content

Commit 2eb9754

Browse files
authored
Couple of improvements (#168)
* Make libc_type!() check even outside test builds * Add stubs for a couple of wide character functions Rustc needs these. Likely through its dependency LLVM.
1 parent a2f804a commit 2eb9754

5 files changed

Lines changed: 44 additions & 20 deletions

File tree

c-gull/src/use_libc.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,14 @@ macro_rules! libc {
5959
#[cfg(all(feature = "take-charge", feature = "thread"))]
6060
macro_rules! libc_type {
6161
($name:ident, $libc:ident) => {
62-
#[cfg(test)]
63-
static_assertions::const_assert_eq!(
64-
core::mem::size_of::<$name>(),
65-
core::mem::size_of::<libc::$libc>()
66-
);
67-
#[cfg(test)]
68-
static_assertions::const_assert_eq!(
69-
core::mem::align_of::<$name>(),
70-
core::mem::align_of::<libc::$libc>()
71-
);
62+
const _: () = {
63+
if core::mem::size_of::<$name>() != core::mem::size_of::<libc::$libc>() {
64+
panic!();
65+
}
66+
if core::mem::align_of::<$name>() != core::mem::align_of::<libc::$libc>() {
67+
panic!();
68+
}
69+
};
7270
};
7371
}
7472

c-scape/src/todo.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ unsafe extern "C" fn strftime() {
293293
todo!("strftime")
294294
}
295295
#[no_mangle]
296+
unsafe extern "C" fn wcsftime() {
297+
todo!("wcsftime")
298+
}
299+
#[no_mangle]
296300
unsafe extern "C" fn __isoc99_scanf() {
297301
todo!("__isoc99_scanf")
298302
}
@@ -1169,3 +1173,11 @@ unsafe extern "C" fn backtrace() {
11691173
unsafe extern "C" fn backtrace_symbols() {
11701174
todo!("backtrace_symbols")
11711175
}
1176+
#[no_mangle]
1177+
unsafe extern "C" fn getwc() {
1178+
todo!("getwc")
1179+
}
1180+
#[no_mangle]
1181+
unsafe extern "C" fn putwc() {
1182+
todo!("putwc")
1183+
}

c-scape/src/todo/locale.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ unsafe extern "C" fn strtoll_l() {
4040
unsafe extern "C" fn strtoull_l() {
4141
todo!("strtoull_l")
4242
}
43+
#[no_mangle]
44+
unsafe extern "C" fn wcsxfrm() {
45+
todo!("wcsxfrm")
46+
}
47+
#[no_mangle]
48+
unsafe extern "C" fn wcscoll() {
49+
todo!("wcscoll")
50+
}

c-scape/src/todo/wchar.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,11 @@ unsafe extern "C" fn iswupper() {
280280
unsafe extern "C" fn iswxdigit() {
281281
todo!("iswxdigit")
282282
}
283+
#[no_mangle]
284+
unsafe extern "C" fn towupper() {
285+
todo!("towupper")
286+
}
287+
#[no_mangle]
288+
unsafe extern "C" fn towlower() {
289+
todo!("towlower")
290+
}

c-scape/src/use_libc.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,14 @@ macro_rules! libc {
5959
#[cfg(all(feature = "take-charge", feature = "thread"))]
6060
macro_rules! libc_type {
6161
($name:ident, $libc:ident) => {
62-
#[cfg(test)]
63-
static_assertions::const_assert_eq!(
64-
core::mem::size_of::<$name>(),
65-
core::mem::size_of::<libc::$libc>()
66-
);
67-
#[cfg(test)]
68-
static_assertions::const_assert_eq!(
69-
core::mem::align_of::<$name>(),
70-
core::mem::align_of::<libc::$libc>()
71-
);
62+
const _: () = {
63+
if core::mem::size_of::<$name>() != core::mem::size_of::<libc::$libc>() {
64+
panic!();
65+
}
66+
if core::mem::align_of::<$name>() != core::mem::align_of::<libc::$libc>() {
67+
panic!();
68+
}
69+
};
7270
};
7371
}
7472

0 commit comments

Comments
 (0)