Skip to content
Snippets Groups Projects
Commit c3f3da69 authored by Ron Williams's avatar Ron Williams
Browse files

fix tzset cbindgen declarations

parent 4c7d1a56
Branches
No related tags found
1 merge request!386fix tzset cbindgen declarations
Pipeline #12071 failed
...@@ -66,7 +66,7 @@ static mut ASCTIME: [c_char; 26] = [0; 26]; ...@@ -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 // We don't handle timezones, so just initialize the timezone info to GMT
// TODO: timezones // TODO: timezones
#[repr(C)] #[repr(transparent)]
pub struct TzName { pub struct TzName {
tz: [*const c_char; 2], tz: [*const c_char; 2],
} }
...@@ -75,13 +75,13 @@ unsafe impl Sync for TzName {} ...@@ -75,13 +75,13 @@ unsafe impl Sync for TzName {}
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
#[no_mangle] #[no_mangle]
pub static tzname: TzName = TzName { tz: [UTC, UTC] }; pub static mut tzname: TzName = TzName { tz: [UTC, UTC] };
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
#[no_mangle] #[no_mangle]
pub static daylight: c_int = 0; pub static mut daylight: c_int = 0;
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
#[no_mangle] #[no_mangle]
pub static timezone: c_long = 0; pub static mut timezone: c_long = 0;
#[repr(C)] #[repr(C)]
pub struct itimerspec { pub struct itimerspec {
......
...@@ -84,6 +84,7 @@ EXPECT_NAMES=\ ...@@ -84,6 +84,7 @@ EXPECT_NAMES=\
time/mktime \ time/mktime \
time/strftime \ time/strftime \
time/time \ time/time \
time/tzset \
tls \ tls \
unistd/access \ unistd/access \
unistd/brk \ unistd/brk \
......
tzname[0] UTC, tzname[1] UTC, daylight 0, timezone 0
#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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment