-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
posix: Fix pthread_barrier_wait() return value #9976
posix: Fix pthread_barrier_wait() return value #9976
Conversation
The return value from this function is supposed to return "PTHREAD_BARRIER_SERIAL_WAIT" from exactly one of the calling threads, otherwise zero or an error code. Fixes zephyrproject-rtos#9953 Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
@@ -11,7 +11,7 @@ | |||
|
|||
int pthread_barrier_wait(pthread_barrier_t *b) | |||
{ | |||
int key = irq_lock(); | |||
int key = irq_lock(), ret, serial = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not unless I'm missing something. ret needs to match the return type of the function, and serial is just a flag that is 0 or 1 depending on whether this is the last thread to arrive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am talking about return of irq_lock
} | ||
} | ||
|
||
#define PTHREAD_BARRIER_SERIAL_THREAD 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, according to doc
The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in <pthread.h> and its value shall be distinct from any other value returned by pthread_barrier_wait().
and
the pthread_barrier_wait() function shall return PTHREAD_BARRIER_SERIAL_THREAD for a single (arbitrary) thread synchronized at the barrier and zero for each of the other threads.
So shouldn't the value be something other than 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh... yeah. This is what I get for pushing a feature without a test, I guess. Will fix. I also see I misspelled the name of the symbol in the commit message (though it looks correct here).
@andyross can you please update this |
This is patched in #14003. Closing as a duplicate fix. |
The return value from this function is supposed to return
"PTHREAD_BARRIER_SERIAL_WAIT" from exactly one of the calling threads,
otherwise zero or an error code.
Fixes #9953
Signed-off-by: Andy Ross andrew.j.ross@intel.com