@@ -18,9 +18,7 @@ static void zephyr_timer_wrapper(struct k_timer *ztimer);
18
18
19
19
struct timer_obj {
20
20
struct k_timer ztimer ;
21
- void (* sigev_notify_function )(union sigval val );
22
- union sigval val ;
23
- int sigev_notify ;
21
+ struct sigevent sev ;
24
22
struct k_sem sem_cond ;
25
23
pthread_t thread ;
26
24
struct timespec interval ; /* Reload value */
@@ -41,7 +39,7 @@ static void zephyr_timer_wrapper(struct k_timer *ztimer)
41
39
timer -> status = NOT_ACTIVE ;
42
40
}
43
41
44
- (timer -> sigev_notify_function )(timer -> val );
42
+ (timer -> sev . sigev_notify_function )(timer -> sev . sigev_value );
45
43
}
46
44
47
45
static void * zephyr_thread_wrapper (void * arg )
@@ -55,7 +53,7 @@ static void *zephyr_thread_wrapper(void *arg)
55
53
56
54
k_sem_take (& timer -> sem_cond , K_FOREVER );
57
55
58
- (timer -> sigev_notify_function )(timer -> val );
56
+ (timer -> sev . sigev_notify_function )(timer -> sev . sigev_value );
59
57
}
60
58
61
59
return NULL ;
@@ -82,10 +80,8 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
82
80
struct timer_obj * timer ;
83
81
const k_timeout_t alloc_timeout = K_MSEC (CONFIG_TIMER_CREATE_WAIT );
84
82
85
- if (clockid != CLOCK_MONOTONIC || evp == NULL ||
86
- (evp -> sigev_notify != SIGEV_NONE &&
87
- evp -> sigev_notify != SIGEV_SIGNAL &&
88
- evp -> sigev_notify != SIGEV_THREAD )) {
83
+ if (evp == NULL || (evp -> sigev_notify != SIGEV_NONE && evp -> sigev_notify != SIGEV_SIGNAL &&
84
+ evp -> sigev_notify != SIGEV_THREAD )) {
89
85
errno = EINVAL ;
90
86
return -1 ;
91
87
}
@@ -97,8 +93,8 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
97
93
return -1 ;
98
94
}
99
95
100
- timer -> sigev_notify_function = evp -> sigev_notify_function ;
101
- timer -> val = evp -> sigev_value ;
96
+ timer -> sev . sigev_notify_function = evp -> sigev_notify_function ;
97
+ timer -> sev . sigev_value = evp -> sigev_value ;
102
98
timer -> interval .tv_sec = 0 ;
103
99
timer -> interval .tv_nsec = 0 ;
104
100
timer -> reload = 0U ;
@@ -109,7 +105,7 @@ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
109
105
} else if (evp -> sigev_notify == SIGEV_THREAD ) {
110
106
int ret ;
111
107
112
- timer -> sigev_notify = SIGEV_THREAD ;
108
+ timer -> sev . sigev_notify = SIGEV_THREAD ;
113
109
k_sem_init (& timer -> sem_cond , 0 , 1 );
114
110
ret = pthread_create (& timer -> thread , evp -> sigev_notify_attributes ,
115
111
zephyr_thread_wrapper , timer );
@@ -266,8 +262,9 @@ int timer_delete(timer_t timerid)
266
262
k_timer_stop (& timer -> ztimer );
267
263
}
268
264
269
- if (timer -> sigev_notify == SIGEV_THREAD )
265
+ if (timer -> sev . sigev_notify == SIGEV_THREAD ) {
270
266
pthread_cancel (timer -> thread );
267
+ }
271
268
272
269
k_mem_slab_free (& posix_timer_slab , (void * )timer );
273
270
0 commit comments