Skip to content

Commit 8d2e68e

Browse files
committed
posix: always require clockid_t argument to timespec_to_timeoutms()
Always require the clockid_t argument to timespec_to_timeoutms() and remove the unused variant that accepts no clockid_t parameter. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
1 parent 345479e commit 8d2e68e

File tree

8 files changed

+11
-17
lines changed

8 files changed

+11
-17
lines changed

lib/posix/options/cond.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int cond_wait(pthread_cond_t *cond, pthread_mutex_t *mu, const struct tim
105105
}
106106

107107
if (abstime != NULL) {
108-
timeout = K_MSEC(timespec_to_clock_timeoutms(cv->attr.clock, abstime));
108+
timeout = K_MSEC(timespec_to_timeoutms(cv->attr.clock, abstime));
109109
}
110110

111111
LOG_DBG("Waiting on cond %p with timeout %llx", cv, timeout.ticks);

lib/posix/options/mqueue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
264264
}
265265

266266
return send_message(mqd, msg_ptr, msg_len,
267-
K_MSEC(timespec_to_clock_timeoutms(CLOCK_REALTIME, abstime)));
267+
K_MSEC(timespec_to_timeoutms(CLOCK_REALTIME, abstime)));
268268
}
269269

270270
/**
@@ -300,7 +300,7 @@ int mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
300300
}
301301

302302
return receive_message(mqd, msg_ptr, msg_len,
303-
K_MSEC(timespec_to_clock_timeoutms(CLOCK_REALTIME, abstime)));
303+
K_MSEC(timespec_to_timeoutms(CLOCK_REALTIME, abstime)));
304304
}
305305

306306
/**

lib/posix/options/mutex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int pthread_mutex_timedlock(pthread_mutex_t *m,
216216
return EINVAL;
217217
}
218218

219-
return acquire_mutex(m, K_MSEC(timespec_to_clock_timeoutms(CLOCK_REALTIME, abstime)));
219+
return acquire_mutex(m, K_MSEC(timespec_to_timeoutms(CLOCK_REALTIME, abstime)));
220220
}
221221

222222
/**

lib/posix/options/posix_clock.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ static inline bool timespec_is_valid(const struct timespec *ts)
2222
return (ts->tv_nsec >= 0) && (ts->tv_nsec < NSEC_PER_SEC);
2323
}
2424

25-
uint32_t timespec_to_clock_timeoutms(clockid_t clock_id, const struct timespec *abstime);
26-
uint32_t timespec_to_timeoutms(const struct timespec *abstime);
25+
uint32_t timespec_to_timeoutms(clockid_t clock_id, const struct timespec *abstime);
2726

2827
__syscall int __posix_clock_get_base(clockid_t clock_id, struct timespec *ts);
2928

lib/posix/options/pthread.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,8 @@ int pthread_timedjoin_np(pthread_t pthread, void **status, const struct timespec
11541154
return EINVAL;
11551155
}
11561156

1157-
return pthread_timedjoin_internal(
1158-
pthread, status, K_MSEC(timespec_to_clock_timeoutms(CLOCK_REALTIME, abstime)));
1157+
return pthread_timedjoin_internal(pthread, status,
1158+
K_MSEC(timespec_to_timeoutms(CLOCK_REALTIME, abstime)));
11591159
}
11601160

11611161
/**

lib/posix/options/rwlock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock,
211211
return EINVAL;
212212
}
213213

214-
if (read_lock_acquire(rwl, timespec_to_clock_timeoutms(CLOCK_REALTIME, abstime)) != 0U) {
214+
if (read_lock_acquire(rwl, timespec_to_timeoutms(CLOCK_REALTIME, abstime)) != 0U) {
215215
ret = ETIMEDOUT;
216216
}
217217

@@ -282,7 +282,7 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock,
282282
return EINVAL;
283283
}
284284

285-
if (write_lock_acquire(rwl, timespec_to_clock_timeoutms(CLOCK_REALTIME, abstime)) != 0U) {
285+
if (write_lock_acquire(rwl, timespec_to_timeoutms(CLOCK_REALTIME, abstime)) != 0U) {
286286
ret = ETIMEDOUT;
287287
}
288288

lib/posix/options/semaphore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int sem_timedwait(sem_t *semaphore, struct timespec *abstime)
166166
return -1;
167167
}
168168

169-
if (k_sem_take(semaphore, K_MSEC(timespec_to_clock_timeoutms(CLOCK_REALTIME, abstime)))) {
169+
if (k_sem_take(semaphore, K_MSEC(timespec_to_timeoutms(CLOCK_REALTIME, abstime)))) {
170170
errno = ETIMEDOUT;
171171
return -1;
172172
}

lib/posix/options/timespec_to_timeout.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <ksched.h>
1111
#include <zephyr/posix/time.h>
1212

13-
uint32_t timespec_to_clock_timeoutms(clockid_t clock_id, const struct timespec *abstime)
13+
uint32_t timespec_to_timeoutms(clockid_t clock_id, const struct timespec *abstime)
1414
{
1515
int64_t milli_secs, secs, nsecs;
1616
struct timespec curtime;
@@ -27,8 +27,3 @@ uint32_t timespec_to_clock_timeoutms(clockid_t clock_id, const struct timespec *
2727

2828
return milli_secs;
2929
}
30-
31-
uint32_t timespec_to_timeoutms(const struct timespec *abstime)
32-
{
33-
return timespec_to_clock_timeoutms(CLOCK_MONOTONIC, abstime);
34-
}

0 commit comments

Comments
 (0)