Skip to content

Commit

Permalink
Merge pull request #473 from tock/no-timezone
Browse files Browse the repository at this point in the history
alarm: remove references to timezone
  • Loading branch information
bradjc authored Nov 4, 2024
2 parents 13fe2da + 7673dfd commit 7f2ced0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/tests/alarms/alarm_in_overflow/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static bool fired = false;
// from gettimeasticks
static uint32_t get_time_ms(void) {
struct timeval tv;
libtock_alarm_gettimeasticks(&tv, NULL);
libtock_alarm_gettimeasticks(&tv);
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}

Expand Down
2 changes: 1 addition & 1 deletion libopenthread/platform/alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ uint32_t otPlatAlarmMilliGetNow(void) {
// reset the alarm.

struct timeval tv;
libtock_alarm_gettimeasticks(&tv, NULL);
libtock_alarm_gettimeasticks(&tv);

uint32_t nowSeconds = tv.tv_sec;
uint32_t nowMicro = tv.tv_usec;
Expand Down
2 changes: 1 addition & 1 deletion libtock/services/alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void libtock_alarm_ms_cancel(libtock_alarm_t* alarm) {
libtock_alarm_cancel(&alarm->alarm);
}

int libtock_alarm_gettimeasticks(struct timeval* tv, __attribute__ ((unused)) void* tzvp) {
int libtock_alarm_gettimeasticks(struct timeval* tv) {
uint32_t frequency, now, seconds, remainder;
const uint32_t microsecond_scaler = 1000000;

Expand Down
18 changes: 13 additions & 5 deletions libtock/services/alarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,23 @@ void libtock_alarm_cancel(libtock_alarm_ticks_t* alarm);
// Use this to implement _gettimeofday yourself as libtock-c doesn't provide
// an implementation.
//
// See https://github.com/tock/libtock-c/pull/355#issuecomment-1841351091 for
// more details
// Note, from `man gettimeofday`:
// The use of the timezone structure is obsolete;
// the tz argument should normally be specified as NULL.
//
// libtock-c makes no pretense of supporting timezone. As such, it expects
// that `tv` is not NULL and does not accept a `tz` parameter. A minimal
// implementation then might look like the following:
//
// ```c
// int _gettimeofday(struct timeval *tv, void *tzvp) {
// return libtock_alarm_gettimeasticks(tv, tzvp);
// int _gettimeofday(struct timeval *tv, __attribute__ ((unused)) void *tz) {
// if (tv == NULL) {
// return EINVAL;
// }
// return libtock_alarm_gettimeasticks(tv);
// }
// ```
int libtock_alarm_gettimeasticks(struct timeval* tv, void* tzvp);
int libtock_alarm_gettimeasticks(struct timeval* tv) __attribute__((nonnull));

/** \brief Create a new alarm to fire in `ms` milliseconds.
*
Expand Down

0 comments on commit 7f2ced0

Please sign in to comment.