fix tzset cbindgen declarations

This commit is contained in:
Ron Williams
2023-05-06 02:55:36 -07:00
parent 4c7d1a567b
commit c3f3da6958
5 changed files with 22 additions and 4 deletions
+4 -4
View File
@@ -66,7 +66,7 @@ static mut ASCTIME: [c_char; 26] = [0; 26];
// We don't handle timezones, so just initialize the timezone info to GMT
// TODO: timezones
#[repr(C)]
#[repr(transparent)]
pub struct TzName {
tz: [*const c_char; 2],
}
@@ -75,13 +75,13 @@ unsafe impl Sync for TzName {}
#[allow(non_upper_case_globals)]
#[no_mangle]
pub static tzname: TzName = TzName { tz: [UTC, UTC] };
pub static mut tzname: TzName = TzName { tz: [UTC, UTC] };
#[allow(non_upper_case_globals)]
#[no_mangle]
pub static daylight: c_int = 0;
pub static mut daylight: c_int = 0;
#[allow(non_upper_case_globals)]
#[no_mangle]
pub static timezone: c_long = 0;
pub static mut timezone: c_long = 0;
#[repr(C)]
pub struct itimerspec {
+1
View File
@@ -84,6 +84,7 @@ EXPECT_NAMES=\
time/mktime \
time/strftime \
time/time \
time/tzset \
tls \
unistd/access \
unistd/brk \
@@ -0,0 +1 @@
tzname[0] UTC, tzname[1] UTC, daylight 0, timezone 0
+16
View File
@@ -0,0 +1,16 @@
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern int daylight;
extern long timezone;
extern const char *tzname[2];
void tzset(void);
int main(void) {
tzset();
printf("tzname[0] %s, tzname[1] %s, daylight %d, timezone %ld\n",
tzname[0], tzname[1], daylight, timezone);
return 0;
}