File tree Expand file tree Collapse file tree 4 files changed +16
-8
lines changed
examples/tests/alarms/alarm_in_overflow Expand file tree Collapse file tree 4 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ static bool fired = false;
27
27
// from gettimeasticks
28
28
static uint32_t get_time_ms (void ) {
29
29
struct timeval tv ;
30
- libtock_alarm_gettimeasticks (& tv , NULL );
30
+ libtock_alarm_gettimeasticks (& tv );
31
31
return (tv .tv_sec * 1000 ) + (tv .tv_usec / 1000 );
32
32
}
33
33
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ uint32_t otPlatAlarmMilliGetNow(void) {
124
124
// reset the alarm.
125
125
126
126
struct timeval tv ;
127
- libtock_alarm_gettimeasticks (& tv , NULL );
127
+ libtock_alarm_gettimeasticks (& tv );
128
128
129
129
uint32_t nowSeconds = tv .tv_sec ;
130
130
uint32_t nowMicro = tv .tv_usec ;
Original file line number Diff line number Diff line change @@ -421,7 +421,7 @@ void libtock_alarm_ms_cancel(libtock_alarm_t* alarm) {
421
421
libtock_alarm_cancel (& alarm -> alarm );
422
422
}
423
423
424
- int libtock_alarm_gettimeasticks (struct timeval * tv , __attribute__ (( unused )) void * tzvp ) {
424
+ int libtock_alarm_gettimeasticks (struct timeval * tv ) {
425
425
uint32_t frequency , now , seconds , remainder ;
426
426
const uint32_t microsecond_scaler = 1000000 ;
427
427
Original file line number Diff line number Diff line change @@ -99,15 +99,23 @@ void libtock_alarm_cancel(libtock_alarm_ticks_t* alarm);
99
99
// Use this to implement _gettimeofday yourself as libtock-c doesn't provide
100
100
// an implementation.
101
101
//
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:
104
109
//
105
110
// ```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);
108
116
// }
109
117
// ```
110
- int libtock_alarm_gettimeasticks (struct timeval * tv , void * tzvp );
118
+ int libtock_alarm_gettimeasticks (struct timeval * tv ) __attribute__(( nonnull ) );
111
119
112
120
/** \brief Create a new alarm to fire in `ms` milliseconds.
113
121
*
You can’t perform that action at this time.
0 commit comments