Skip to content

Commit 7f2ced0

Browse files
authored
Merge pull request #473 from tock/no-timezone
alarm: remove references to timezone
2 parents 13fe2da + 7673dfd commit 7f2ced0

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

examples/tests/alarms/alarm_in_overflow/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static bool fired = false;
2727
// from gettimeasticks
2828
static uint32_t get_time_ms(void) {
2929
struct timeval tv;
30-
libtock_alarm_gettimeasticks(&tv, NULL);
30+
libtock_alarm_gettimeasticks(&tv);
3131
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
3232
}
3333

libopenthread/platform/alarm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ uint32_t otPlatAlarmMilliGetNow(void) {
124124
// reset the alarm.
125125

126126
struct timeval tv;
127-
libtock_alarm_gettimeasticks(&tv, NULL);
127+
libtock_alarm_gettimeasticks(&tv);
128128

129129
uint32_t nowSeconds = tv.tv_sec;
130130
uint32_t nowMicro = tv.tv_usec;

libtock/services/alarm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void libtock_alarm_ms_cancel(libtock_alarm_t* alarm) {
421421
libtock_alarm_cancel(&alarm->alarm);
422422
}
423423

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

libtock/services/alarm.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,23 @@ void libtock_alarm_cancel(libtock_alarm_ticks_t* alarm);
9999
// Use this to implement _gettimeofday yourself as libtock-c doesn't provide
100100
// an implementation.
101101
//
102-
// See https://github.com/tock/libtock-c/pull/355#issuecomment-1841351091 for
103-
// more details
102+
// Note, from `man gettimeofday`:
103+
// The use of the timezone structure is obsolete;
104+
// the tz argument should normally be specified as NULL.
105+
//
106+
// libtock-c makes no pretense of supporting timezone. As such, it expects
107+
// that `tv` is not NULL and does not accept a `tz` parameter. A minimal
108+
// implementation then might look like the following:
104109
//
105110
// ```c
106-
// int _gettimeofday(struct timeval *tv, void *tzvp) {
107-
// return libtock_alarm_gettimeasticks(tv, tzvp);
111+
// int _gettimeofday(struct timeval *tv, __attribute__ ((unused)) void *tz) {
112+
// if (tv == NULL) {
113+
// return EINVAL;
114+
// }
115+
// return libtock_alarm_gettimeasticks(tv);
108116
// }
109117
// ```
110-
int libtock_alarm_gettimeasticks(struct timeval* tv, void* tzvp);
118+
int libtock_alarm_gettimeasticks(struct timeval* tv) __attribute__((nonnull));
111119

112120
/** \brief Create a new alarm to fire in `ms` milliseconds.
113121
*

0 commit comments

Comments
 (0)