diff --git a/libs/libc/semaphore/sem_getvalue.c b/libs/libc/semaphore/sem_getvalue.c index 194f5fa1ef..14706cea05 100644 --- a/libs/libc/semaphore/sem_getvalue.c +++ b/libs/libc/semaphore/sem_getvalue.c @@ -29,6 +29,7 @@ #include #include +#include /**************************************************************************** * Public Functions @@ -64,7 +65,7 @@ int nxsem_get_value(FAR sem_t *sem, FAR int *sval) { if (sem != NULL && sval != NULL) { - *sval = sem->semcount; + *sval = atomic_read(NXSEM_COUNT(sem)); return OK; }