From 732be68f65d76574d4227da5f3c24509fe104425 Mon Sep 17 00:00:00 2001 From: wangchenguang Date: Sat, 29 Aug 2026 17:35:52 +0800 Subject: [PATCH 1/2] fix(bthread): drop unimplemented barrier and rwlockattr APIs These declarations had no definitions, so calling them failed at link time. Keep bthread_rwlockattr_t for bthread_rwlock_init(). --- src/bthread/bthread.h | 32 +------------------------------- src/bthread/types.h | 9 ++------- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/bthread/bthread.h b/src/bthread/bthread.h index 008beffadc..76979c308c 100644 --- a/src/bthread/bthread.h +++ b/src/bthread/bthread.h @@ -249,6 +249,7 @@ extern int bthread_cond_timedwait( // Initialize read-write lock `rwlock' using attributes `attr', or use // the default values if later is nullptr. +// NOTE: attr is not used in the current implementation. extern int bthread_rwlock_init(bthread_rwlock_t* __restrict rwlock, const bthread_rwlockattr_t* __restrict attr); @@ -278,24 +279,6 @@ extern int bthread_rwlock_timedwrlock(bthread_rwlock_t* __restrict rwlock, // Unlock `rwlock'. extern int bthread_rwlock_unlock(bthread_rwlock_t* rwlock); -// --------------------------------------------------- -// Functions for handling read-write lock attributes. -// --------------------------------------------------- - -// Initialize attribute object `attr' with default values. -extern int bthread_rwlockattr_init(bthread_rwlockattr_t* attr); - -// Destroy attribute object `attr'. -extern int bthread_rwlockattr_destroy(bthread_rwlockattr_t* attr); - -// Return current setting of reader/writer preference. -extern int bthread_rwlockattr_getkind_np(const bthread_rwlockattr_t* attr, - int* pref); - -// Set reader/write preference. -extern int bthread_rwlockattr_setkind_np(bthread_rwlockattr_t* attr, - int pref); - // ------------------------------------------- // Functions for handling semaphore. // ------------------------------------------- @@ -343,19 +326,6 @@ extern int bthread_sem_post(bthread_sem_t* sem); // Return 0 on success, errno otherwise. extern int bthread_sem_post_n(bthread_sem_t* sem, size_t n); - -// ---------------------------------------------------------------------- -// Functions for handling barrier which is a new feature in 1003.1j-2000. -// ---------------------------------------------------------------------- - -extern int bthread_barrier_init(bthread_barrier_t* __restrict barrier, - const bthread_barrierattr_t* __restrict attr, - unsigned count); - -extern int bthread_barrier_destroy(bthread_barrier_t* barrier); - -extern int bthread_barrier_wait(bthread_barrier_t* barrier); - // --------------------------------------------------------------------- // Functions for handling thread-specific data. // Notice that they can be used in pthread: get pthread-specific data in diff --git a/src/bthread/types.h b/src/bthread/types.h index 1fb7a5d0cb..58b1ce3463 100644 --- a/src/bthread/types.h +++ b/src/bthread/types.h @@ -247,16 +247,11 @@ typedef struct bthread_rwlock_t { unsigned* lock_word; } bthread_rwlock_t; +// Kept for ABI compatibility with bthread_rwlock_init(). There is no +// bthread_rwlockattr_* API; pass nullptr to use the default. typedef struct { } bthread_rwlockattr_t; -typedef struct { - unsigned int count; -} bthread_barrier_t; - -typedef struct { -} bthread_barrierattr_t; - #if defined(__cplusplus) class bthread_once_t; namespace bthread { From f17fe5f5d9c1ada962c62672389266f94e7ba6f5 Mon Sep 17 00:00:00 2001 From: wangchenguang Date: Mon, 31 Aug 2026 22:16:26 +0800 Subject: [PATCH 2/2] fix(bthread): keep unimplemented APIs as commented TODOs Leave barrier and rwlockattr declarations in comments so they can be restored later, instead of deleting them. --- src/bthread/bthread.h | 31 +++++++++++++++++++++++++++++++ src/bthread/types.h | 12 ++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/bthread/bthread.h b/src/bthread/bthread.h index 76979c308c..e0d95892c7 100644 --- a/src/bthread/bthread.h +++ b/src/bthread/bthread.h @@ -279,6 +279,24 @@ extern int bthread_rwlock_timedwrlock(bthread_rwlock_t* __restrict rwlock, // Unlock `rwlock'. extern int bthread_rwlock_unlock(bthread_rwlock_t* rwlock); +// --------------------------------------------------- +// Functions for handling read-write lock attributes. +// --------------------------------------------------- +// TODO: Implement these APIs. bthread_rwlock_init() currently ignores attr. + +// Initialize attribute object `attr' with default values. +// extern int bthread_rwlockattr_init(bthread_rwlockattr_t* attr); + +// Destroy attribute object `attr'. +// extern int bthread_rwlockattr_destroy(bthread_rwlockattr_t* attr); + +// Return current setting of reader/writer preference. +// extern int bthread_rwlockattr_getkind_np(const bthread_rwlockattr_t* attr, +// int* pref); + +// Set reader/write preference. +// extern int bthread_rwlockattr_setkind_np(bthread_rwlockattr_t* attr, int pref); + // ------------------------------------------- // Functions for handling semaphore. // ------------------------------------------- @@ -326,6 +344,19 @@ extern int bthread_sem_post(bthread_sem_t* sem); // Return 0 on success, errno otherwise. extern int bthread_sem_post_n(bthread_sem_t* sem, size_t n); +// ---------------------------------------------------------------------- +// Functions for handling barrier which is a new feature in 1003.1j-2000. +// ---------------------------------------------------------------------- +// TODO: Implement bthread barrier. + +// extern int bthread_barrier_init(bthread_barrier_t* __restrict barrier, +// const bthread_barrierattr_t* __restrict attr, +// unsigned count); + +// extern int bthread_barrier_destroy(bthread_barrier_t* barrier); + +// extern int bthread_barrier_wait(bthread_barrier_t* barrier); + // --------------------------------------------------------------------- // Functions for handling thread-specific data. // Notice that they can be used in pthread: get pthread-specific data in diff --git a/src/bthread/types.h b/src/bthread/types.h index 58b1ce3463..14411e5e06 100644 --- a/src/bthread/types.h +++ b/src/bthread/types.h @@ -247,11 +247,19 @@ typedef struct bthread_rwlock_t { unsigned* lock_word; } bthread_rwlock_t; -// Kept for ABI compatibility with bthread_rwlock_init(). There is no -// bthread_rwlockattr_* API; pass nullptr to use the default. +// Kept for ABI compatibility with bthread_rwlock_init(). Pass nullptr +// for the default. See TODO on bthread_rwlockattr_* in bthread.h. typedef struct { } bthread_rwlockattr_t; +// TODO: Implement bthread barrier. +// typedef struct { +// unsigned int count; +// } bthread_barrier_t; +// +// typedef struct { +// } bthread_barrierattr_t; + #if defined(__cplusplus) class bthread_once_t; namespace bthread {