Skip to content

Fix passing timezone structure in Tsettimeofday()/Tgettimeofday() #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ struct timezone
int tz_minuteswest; /* Minutes west of GMT. */
int tz_dsttime; /* Nonzero if DST is ever in effect. */
};
struct __mint_timezone
{
long tz_minuteswest; /* Minutes west of GMT. */
long tz_dsttime; /* Nonzero if DST is ever in effect. */
};

typedef struct timezone *__restrict __timezone_ptr_t;
#else
Expand Down
13 changes: 12 additions & 1 deletion unix/gettimeofday.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ __gettimeofday (struct timeval *tp, struct timezone *tzp)
static int have_Tgettimeofday = 1;

if (have_Tgettimeofday != 0) {
long retval = Tgettimeofday (tp, tzp);
long retval;
/*
* MiNTs timezone structure is different than ours
*/
struct __mint_timezone minttz;

retval = Tgettimeofday(tp, &minttz);
if (retval == -ENOSYS) {
have_Tgettimeofday = 0;
} else if (retval < 0) {
__set_errno (-retval);
return -1;
} else {
if (tzp != NULL)
{
tzp->tz_minuteswest = minttz.tz_minuteswest;
tzp->tz_dsttime = minttz.tz_dsttime;
}
return 0;
}
} /* have_Tgettimeofday != 0 */
Expand Down
14 changes: 13 additions & 1 deletion unix/settimeofday.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ __settimeofday (const struct timeval *tp, const struct timezone *tzp)
static int have_Tsettimeofday = 1;

if (have_Tsettimeofday != 0) {
retval = Tsettimeofday (tp, tzp);
/*
* MiNTs timezone structure is different than ours
*/
struct __mint_timezone minttz;
struct __mint_timezone *minttzp = NULL;

if (tzp != NULL)
{
minttz.tz_minuteswest = tzp->tz_minuteswest;
minttz.tz_dsttime = tzp->tz_dsttime;
minttzp = &minttz;
}
retval = Tsettimeofday(tp, minttzp);
if (retval == -ENOSYS) {
have_Tsettimeofday = 0;
} else if (retval < 0) {
Expand Down