mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-24 15:40:31 +08:00
POSIX: Add sem_getvalue() abstraction
This commit is contained in:
@@ -85,6 +85,16 @@ int px4_sem_post(px4_sem_t *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int px4_sem_getvalue(px4_sem_t *s)
|
||||
{
|
||||
int val;
|
||||
pthread_mutex_lock(&(s->lock));
|
||||
val = s->value;
|
||||
pthread_mutex_unlock(&(s->lock));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
int px4_sem_destroy(px4_sem_t *s)
|
||||
{
|
||||
pthread_mutex_lock(&(s->lock));
|
||||
|
||||
@@ -64,6 +64,7 @@ typedef struct
|
||||
__EXPORT int px4_sem_init(px4_sem_t *s, int pshared, unsigned value);
|
||||
__EXPORT int px4_sem_wait(px4_sem_t *s);
|
||||
__EXPORT int px4_sem_post(px4_sem_t *s);
|
||||
__EXPORT int px4_sem_getvalue(px4_sem_t *s);
|
||||
__EXPORT int px4_sem_destroy(px4_sem_t *s);
|
||||
|
||||
__END_DECLS
|
||||
@@ -75,6 +76,7 @@ typedef px4_sem_t sem_t
|
||||
#define px4_sem_init _GLOBAL sem_init
|
||||
#define px4_sem_wait _GLOBAL sem_wait
|
||||
#define px4_sem_post _GLOBAL px4_sem_post
|
||||
#define px4_sem_getvalue _GLOBAL px4_sem_getvalue
|
||||
#define px4_sem_destroy _GLOBAL sem_destroy
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user