Page MenuHomeFreeBSD

Add sem_clockwait_np()
ClosedPublic

Authored by vangyzen on Feb 17 2017, 9:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 11 2024, 3:03 PM
Unknown Object (File)
Mar 11 2024, 3:03 PM
Unknown Object (File)
Mar 11 2024, 5:35 AM
Unknown Object (File)
Mar 11 2024, 5:35 AM
Unknown Object (File)
Mar 11 2024, 5:29 AM
Unknown Object (File)
Mar 11 2024, 5:29 AM
Unknown Object (File)
Mar 11 2024, 5:29 AM
Unknown Object (File)
Mar 7 2024, 10:09 PM
Subscribers

Details

Summary

This function allows the caller to specify the reference clock
and choose between absolute and relative mode. In relative mode,
the remaining time can be returned.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

vangyzen retitled this revision from to Add sem_timedwait5_np().
vangyzen updated this object.
vangyzen edited the test plan for this revision. (Show Details)

I have only compile-tested this. I still need to write unit tests.

https://github.com/vangyzen/freebsd/tree/sem_timedwait5

ed added inline comments.
include/semaphore.h
62 ↗(On Diff #25333)

Hmmm... I'm not a fan of this. This means that if you include <semaphore.h> once without exposing this function, there is no way to get it later on.

Saying: "just make sure to include stuff in the right order" won't work in practice. What if you make use of some kind of library that suddenly decides to start using semaphores in its header files from one version to the other? That will break the build in unforeseen ways.

The only sensible thing is to use __clockid_t.

63 ↗(On Diff #25333)

What about calling this sem_clock_timedwait()?

63 ↗(On Diff #25333)

Correction: sem_clock_timedwait_np().

include/semaphore.h
62 ↗(On Diff #25333)

I completely agree. I pulled most of this from a commercial appliance and failed to revisit this part before uploading...even though I remembered it when I updated the man page! Thanks for catching it.

63 ↗(On Diff #25333)

I've been looking for a better name, too. I like your suggestion.

How about sem_clockwait_np()? It's shorter, but it still describes the behavior well enough. It's also consistent with other functions like sem_timedwait and sem_trywait.

Use __clockid_t to avoid the need for <time.h>

include/semaphore.h
63 ↗(On Diff #25333)

Sounds good to me!

  • rename sem_timedwait5_np to sem_clockwait_np
  • start adding unit tests for sem_timedwait() and sem_timedwait5_np()
ed added a reviewer: ed.

Looks good to me, except that I don't know everything about umtx internals to judge whether those changes are all right. ;-)

lib/libc/gen/sem_timedwait.3
151 ↗(On Diff #25417)

.Fx instead of FreeBSD, right?

This revision is now accepted and ready to land.Feb 20 2017, 3:31 PM
vangyzen retitled this revision from Add sem_timedwait5_np() to Add sem_clockwait_np().Feb 22 2017, 3:15 PM
vangyzen edited edge metadata.
This revision was automatically updated to reflect the committed changes.