From 7033c497a093739c59103cf050b9748a101229bd Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Mon, 11 Dec 2023 14:29:04 +0100 Subject: [PATCH] time: posix: use strftime from the `libc` crate. Signed-off-by: Lukas Wagner --- proxmox-time/src/posix.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/proxmox-time/src/posix.rs b/proxmox-time/src/posix.rs index 6157f8bc..c463ab3a 100644 --- a/proxmox-time/src/posix.rs +++ b/proxmox-time/src/posix.rs @@ -108,25 +108,13 @@ pub fn epoch_f64() -> f64 { } } -// rust libc bindings do not include strftime -#[link(name = "c")] -extern "C" { - #[link_name = "strftime"] - fn libc_strftime( - s: *mut libc::c_char, - max: libc::size_t, - format: *const libc::c_char, - time: *const libc::tm, - ) -> libc::size_t; -} - /// Safe bindings to libc strftime pub fn strftime(format: &str, t: &libc::tm) -> Result { let format = CString::new(format).map_err(|err| format_err!("{}", err))?; let mut buf = vec![0u8; 8192]; let res = unsafe { - libc_strftime( + libc::strftime( buf.as_mut_ptr() as *mut libc::c_char, buf.len() as libc::size_t, format.as_ptr(),