Skip to content

Conversation

@cfriedt
Copy link
Member

@cfriedt cfriedt commented Nov 16, 2022

3 commits:

  • lib: posix: pthread: rename pthread_key_lock to pthread_once_lock
  • lib: posix: pthread_key: use spinlock instead of semaphore
  • posix: key: abstract pthread_key_t as uint32_t

Please see each commit message for details.

@cfriedt cfriedt added the area: POSIX POSIX API Library label Nov 16, 2022
@cfriedt cfriedt self-assigned this Nov 16, 2022
@cfriedt cfriedt force-pushed the use-uint32-for-pthread-key branch from 57034dd to 8b6b10c Compare November 16, 2022 21:13
@cfriedt
Copy link
Member Author

cfriedt commented Nov 16, 2022

Compliance failure is a false positive (pthread functions return non-negative errno values, not introducing any new types).

@cfriedt cfriedt changed the title Use uint32 for pthread key posix: abstract pthread_mutex_t as uint32_t Nov 17, 2022
@cfriedt cfriedt changed the title posix: abstract pthread_mutex_t as uint32_t posix: abstract pthread_key_t as uint32_t Nov 17, 2022
jeremybettis
jeremybettis previously approved these changes Nov 18, 2022
Chris Friedt added 2 commits November 19, 2022 17:34
Since this lock is only used in `pthread_once()` it makes sense
to name it accordingly.

Signed-off-by: Chris Friedt <[email protected]>
None of the operations that `pthread_key_sem` protected were
blocking, so simply make it a spinlock.

Also made the lock static.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt
Copy link
Member Author

cfriedt commented Nov 19, 2022

  • rebased

Consistent with the change of `pthread_t`, `pthread_mutex_t`,
and `pthread_cond_t` to `uint32_t`, we can now also abstract
`pthread_key_t` as `uint32_t` and separate the implementation
detail, hidden from POSIX API consumers.

This change introduces `CONFIG_MAX_PTHREAD_KEY_COUNT`.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt force-pushed the use-uint32-for-pthread-key branch from 9093e8e to 4f1f47d Compare November 21, 2022 17:15
@cfriedt
Copy link
Member Author

cfriedt commented Nov 21, 2022

  • fixed spelling mistake in comment (implemenataiton -> implementation)
  • added function pointer argument name which was previously never there (void (*destructor)(void *) -> void (*destructor)(void *value))

@cfriedt
Copy link
Member Author

cfriedt commented Nov 22, 2022

@jeremybettis - are you OK to re-ACK?

@cfriedt
Copy link
Member Author

cfriedt commented Nov 22, 2022

@enjiamai @KangJianX @keith-packard @stephanosio - would gratefully accept an approval if anyone is feeling generous 😁

@stephanosio stephanosio merged commit f1ececc into zephyrproject-rtos:main Nov 23, 2022
@cfriedt cfriedt deleted the use-uint32-for-pthread-key branch November 23, 2022 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: POSIX POSIX API Library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants