mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:34:07 +08:00
libc/pthread: Avoid compiler optimizations for once_control->done
Prevent compiler reordering that may read stale value of once_control->done. Use volatile to ensure visibility across threads and prevent incorrect once initialization. Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
This commit is contained in:
+1
-1
@@ -402,7 +402,7 @@ typedef struct pthread_barrier_s pthread_barrier_t;
|
||||
|
||||
struct pthread_once_s
|
||||
{
|
||||
bool done;
|
||||
volatile bool done;
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user