Skip to content
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
25 changes: 13 additions & 12 deletions src/bthread/bthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -281,20 +282,20 @@ 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);
// extern int bthread_rwlockattr_init(bthread_rwlockattr_t* attr);

// Destroy attribute object `attr'.
extern int bthread_rwlockattr_destroy(bthread_rwlockattr_t* 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);
// 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);
// extern int bthread_rwlockattr_setkind_np(bthread_rwlockattr_t* attr, int pref);

// -------------------------------------------
// Functions for handling semaphore.
Expand Down Expand Up @@ -343,18 +344,18 @@ 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_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_destroy(bthread_barrier_t* barrier);

extern int bthread_barrier_wait(bthread_barrier_t* barrier);
// extern int bthread_barrier_wait(bthread_barrier_t* barrier);

// ---------------------------------------------------------------------
// Functions for handling thread-specific data.
Expand Down
15 changes: 9 additions & 6 deletions src/bthread/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,18 @@ typedef struct bthread_rwlock_t {
unsigned* lock_word;
} bthread_rwlock_t;

// 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;

typedef struct {
unsigned int count;
} bthread_barrier_t;

typedef struct {
} bthread_barrierattr_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;
Expand Down
Loading