Skip to content

posix: Implement pthread_equal function #60416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/services/portability/posix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ multiple processes.
pthread_condattr_init(),yes
pthread_create(),yes
pthread_detach(),yes
pthread_equal(),
pthread_equal(),yes
pthread_exit(),yes
pthread_getspecific(),yes
pthread_join(),yes
Expand Down
5 changes: 1 addition & 4 deletions include/zephyr/posix/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,7 @@ pthread_t pthread_self(void);
*
* See IEEE 1003.1
*/
static inline int pthread_equal(pthread_t pt1, pthread_t pt2)
{
return (pt1 == pt2);
}
int pthread_equal(pthread_t pt1, pthread_t pt2);

/**
* @brief Destroy the read-write lock attributes object.
Expand Down
5 changes: 5 additions & 0 deletions lib/posix/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,9 @@ static int posix_thread_pool_init(void)
return 0;
}

int pthread_equal(pthread_t pt1, pthread_t pt2)
{
return (pt1 == pt2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no brackets needed here, but I'm not going to stop this from going in now. If there is another review that requires another spin, please fix this too.

}

SYS_INIT(posix_thread_pool_init, PRE_KERNEL_1, 0);
6 changes: 6 additions & 0 deletions tests/posix/common/src/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,3 +771,9 @@ ZTEST(posix_apis, test_barrier)
ret = pthread_barrierattr_destroy(&attr);
zassert_equal(ret, 0, "pthread_barrierattr_destroy failed");
}

ZTEST(posix_apis, test_pthread_equal)
{
zassert_true(pthread_equal(pthread_self(), pthread_self()));
zassert_false(pthread_equal(pthread_self(), (pthread_t)4242));
}