verify time header includes
This commit is contained in:
@@ -1,4 +1,16 @@
|
||||
sys_includes = ["sys/types.h", "stdint.h", "stddef.h", "features.h"]
|
||||
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/time.h.html
|
||||
#
|
||||
# Spec quotations relating to includes:
|
||||
# - "The <time.h> header shall define the clock_t, size_t, time_t, types as described in <sys/types.h>."
|
||||
# - "The <time.h> header shall define the clockid_t and timer_t types as described in <sys/types.h>."
|
||||
# - "The <time.h> header shall define the locale_t type as described in <locale.h>."
|
||||
# - "The <time.h> header shall define the pid_t type as described in <sys/types.h>."
|
||||
# - "The tag sigevent shall be declared as naming an incomplete structure type, the contents of which are described in the <signal.h> header."
|
||||
# - "NULL As described in <stddef.h>."
|
||||
# - "Inclusion of the <time.h> header may make visible all symbols from the <signal.h> header."
|
||||
#
|
||||
# features.h included for deprecated annotations
|
||||
sys_includes = ["sys/types.h", "stddef.h", "features.h"]
|
||||
include_guard = "_RELIBC_TIME_H"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
@@ -6,6 +18,8 @@ no_includes = true
|
||||
cpp_compat = true
|
||||
after_includes = """
|
||||
#include <bits/timespec.h> // for timespec
|
||||
#include <bits/locale-t.h> // for locale_t from locale.h
|
||||
|
||||
struct sigevent;
|
||||
"""
|
||||
|
||||
|
||||
@@ -10,9 +10,12 @@ pub mod sys;
|
||||
|
||||
pub use self::sys::*;
|
||||
|
||||
/// cbindgen:ignore
|
||||
pub(crate) const UTC: *const c_char = c"UTC".as_ptr().cast();
|
||||
|
||||
/// cbindgen:ignore
|
||||
pub(crate) const DAY_NAMES: [&str; 7] = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||
/// cbindgen:ignore
|
||||
pub(crate) const MON_NAMES: [&str; 12] = [
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
];
|
||||
|
||||
@@ -39,10 +39,15 @@ mod strftime;
|
||||
mod strptime;
|
||||
pub use strptime::strptime;
|
||||
|
||||
/// cbindgen:ignore
|
||||
const YEARS_PER_ERA: time_t = 400;
|
||||
/// cbindgen:ignore
|
||||
const DAYS_PER_ERA: time_t = 146097;
|
||||
/// cbindgen:ignore
|
||||
const SECS_PER_DAY: time_t = 24 * 60 * 60;
|
||||
/// cbindgen:ignore
|
||||
pub(crate) const NANOSECONDS: c_long = 1_000_000_000;
|
||||
/// cbindgen:ignore
|
||||
const UTC_STR: &core::ffi::CStr = c"UTC";
|
||||
|
||||
/// timer_t internal data, ABI unstable
|
||||
@@ -73,6 +78,7 @@ impl timer_internal_t {
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/time.h.html>.
|
||||
#[allow(non_camel_case_types)]
|
||||
#[repr(C)]
|
||||
pub struct tm {
|
||||
pub tm_sec: c_int, // 0 - 60
|
||||
@@ -90,9 +96,11 @@ pub struct tm {
|
||||
|
||||
unsafe impl Sync for tm {}
|
||||
|
||||
/// cbindgen:ignore
|
||||
// The C Standard says that localtime and gmtime return the same pointer.
|
||||
static GMTIME_LOCALTIME_RETURN_TM: RawCell<tm> = RawCell::new(blank_tm());
|
||||
|
||||
/// cbindgen:ignore
|
||||
// The C Standard says that ctime and asctime return the same pointer.
|
||||
static mut ASCTIME: [c_char; 26] = [0; 26];
|
||||
|
||||
@@ -101,9 +109,11 @@ pub struct TzName([*mut c_char; 2]);
|
||||
|
||||
unsafe impl Sync for TzName {}
|
||||
|
||||
/// cbindgen:ignore
|
||||
// Name storage for the `tm_zone` field.
|
||||
static TIMEZONE_NAMES: Mutex<OnceCell<BTreeSet<CString>>> = Mutex::new(OnceCell::new());
|
||||
|
||||
/// cbindgen:ignore
|
||||
// relibc functions should hold `TIMEZONE_LOCK` when accessing `daylight`,
|
||||
// `timezone`, and `tzname`. However, it cannot guard those variables against
|
||||
// user access (see `tzset()` specs for details).
|
||||
@@ -132,6 +142,7 @@ pub static mut tzname: TzName = TzName([ptr::null_mut(); 2]);
|
||||
pub static mut getdate_err: c_int = 0;
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/time.h.html>.
|
||||
#[allow(non_camel_case_types)]
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct itimerspec {
|
||||
|
||||
@@ -11,8 +11,10 @@ use core::{
|
||||
str,
|
||||
};
|
||||
|
||||
/// cbindgen:ignore
|
||||
/// For convenience, we define some helper constants for the C-locale.
|
||||
const SHORT_DAYS: [&str; 7] = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||
/// cbindgen:ignore
|
||||
const LONG_DAYS: [&str; 7] = [
|
||||
"Sunday",
|
||||
"Monday",
|
||||
@@ -22,9 +24,11 @@ const LONG_DAYS: [&str; 7] = [
|
||||
"Friday",
|
||||
"Saturday",
|
||||
];
|
||||
/// cbindgen:ignore
|
||||
const SHORT_MONTHS: [&str; 12] = [
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
];
|
||||
/// cbindgen:ignore
|
||||
const LONG_MONTHS: [&str; 12] = [
|
||||
"January",
|
||||
"February",
|
||||
|
||||
Reference in New Issue
Block a user