include/nuttx/semaphore.h: Fix broken macros

This commit is contained in:
Gregory Nutt
2016-11-03 12:49:44 -06:00
parent 1da3a5fa61
commit 4c8ec0d2ca
6 changed files with 17 additions and 26 deletions
-8
View File
@@ -160,11 +160,7 @@ int sem_reset(FAR sem_t *sem, int16_t count);
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_PRIORITY_INHERITANCE
int sem_getprotocol(FAR sem_t *sem, FAR int *protocol); int sem_getprotocol(FAR sem_t *sem, FAR int *protocol);
#else
# define sem_getprotocol(s,p) do { *(p) == SEM_PRIO_NONE); } while (0)
#endif
/**************************************************************************** /****************************************************************************
* Function: sem_setprotocol * Function: sem_setprotocol
@@ -202,11 +198,7 @@ int sem_getprotocol(FAR sem_t *sem, FAR int *protocol);
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_PRIORITY_INHERITANCE
int sem_setprotocol(FAR sem_t *sem, int protocol); int sem_setprotocol(FAR sem_t *sem, int protocol);
#else
# define sem_setprotocol(s,p) ((p) == SEM_PRIO_NONE ? 0 : -ENOSYS);
#endif
#undef EXTERN #undef EXTERN
#ifdef __cplusplus #ifdef __cplusplus
+1 -5
View File
@@ -35,11 +35,7 @@
# Add the semaphore C files to the build # Add the semaphore C files to the build
CSRCS += sem_init.c sem_getvalue.c CSRCS += sem_init.c sem_getprotocol.c sem_getvalue.c
ifeq ($(CONFIG_PRIORITY_INHERITANCE),y)
CSRCS += sem_getprotocol.c
endif
# Add the semaphore directory to the build # Add the semaphore directory to the build
+9 -6
View File
@@ -43,8 +43,6 @@
#include <nuttx/semaphore.h> #include <nuttx/semaphore.h>
#ifdef CONFIG_PRIORITY_INHERITANCE
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -71,14 +69,19 @@ int sem_getprotocol(FAR sem_t *sem, FAR int *protocol)
{ {
DEBUGASSERT(sem != NULL && protocol != NULL); DEBUGASSERT(sem != NULL && protocol != NULL);
#ifdef CONFIG_PRIORITY_INHERITANCE
if ((sem->flags & PRIOINHERIT_FLAGS_DISABLE) != 0) if ((sem->flags & PRIOINHERIT_FLAGS_DISABLE) != 0)
{ {
return SEM_PRIO_NONE; *protocol = SEM_PRIO_NONE;
} }
else else
{ {
return SEM_PRIO_INHERIT; *protocol = SEM_PRIO_INHERIT;
} }
}
#endif /* CONFIG_PRIORITY_INHERITANCE */ #else
*protocol = SEM_PRIO_NONE;
#endif
return OK;
}
+2 -2
View File
@@ -37,10 +37,10 @@
CSRCS += sem_destroy.c sem_wait.c sem_trywait.c sem_tickwait.c CSRCS += sem_destroy.c sem_wait.c sem_trywait.c sem_tickwait.c
CSRCS += sem_timedwait.c sem_timeout.c sem_post.c sem_recover.c CSRCS += sem_timedwait.c sem_timeout.c sem_post.c sem_recover.c
CSRCS += sem_reset.c sem_waitirq.c CSRCS += sem_reset.c sem_setprotocol.c sem_waitirq.c
ifeq ($(CONFIG_PRIORITY_INHERITANCE),y) ifeq ($(CONFIG_PRIORITY_INHERITANCE),y)
CSRCS += sem_initialize.c sem_holder.c sem_setprotocol.c CSRCS += sem_initialize.c sem_holder.c
endif endif
ifeq ($(CONFIG_SPINLOCK),y) ifeq ($(CONFIG_SPINLOCK),y)
+4 -4
View File
@@ -46,8 +46,6 @@
#include "semaphore/semaphore.h" #include "semaphore/semaphore.h"
#ifdef CONFIG_PRIORITY_INHERITANCE
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -97,6 +95,7 @@ int sem_setprotocol(FAR sem_t *sem, int protocol)
switch (protocol) switch (protocol)
{ {
case SEM_PRIO_NONE: case SEM_PRIO_NONE:
#ifdef CONFIG_PRIORITY_INHERITANCE
/* Disable priority inheritance */ /* Disable priority inheritance */
sem->flags |= PRIOINHERIT_FLAGS_DISABLE; sem->flags |= PRIOINHERIT_FLAGS_DISABLE;
@@ -104,13 +103,16 @@ int sem_setprotocol(FAR sem_t *sem, int protocol)
/* Remove any current holders */ /* Remove any current holders */
sem_destroyholder(sem); sem_destroyholder(sem);
#endif
return OK; return OK;
case SEM_PRIO_INHERIT: case SEM_PRIO_INHERIT:
#ifdef CONFIG_PRIORITY_INHERITANCE
/* Enable priority inheritance (dangerous) */ /* Enable priority inheritance (dangerous) */
sem->flags &= ~PRIOINHERIT_FLAGS_DISABLE; sem->flags &= ~PRIOINHERIT_FLAGS_DISABLE;
return OK; return OK;
#endif
case SEM_PRIO_PROTECT: case SEM_PRIO_PROTECT:
/* Not yet supported */ /* Not yet supported */
@@ -126,5 +128,3 @@ int sem_setprotocol(FAR sem_t *sem, int protocol)
set_errno(errcode); set_errno(errcode);
return ERROR; return ERROR;
} }
#endif /* CONFIG_PRIORITY_INHERITANCE */
+1 -1
View File
@@ -118,7 +118,7 @@
"sem_destroy","semaphore.h","","int","FAR sem_t*" "sem_destroy","semaphore.h","","int","FAR sem_t*"
"sem_open","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","FAR sem_t*","FAR const char*","int","..." "sem_open","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","FAR sem_t*","FAR const char*","int","..."
"sem_post","semaphore.h","","int","FAR sem_t*" "sem_post","semaphore.h","","int","FAR sem_t*"
"sem_setprotocol","nuttx/semaphore.h","defined(CONFIG_PRIORITY_INHERITANCE)","int","FAR sem_t*","int" "sem_setprotocol","nuttx/semaphore.h","","int","FAR sem_t*","int"
"sem_timedwait","semaphore.h","","int","FAR sem_t*","FAR const struct timespec *" "sem_timedwait","semaphore.h","","int","FAR sem_t*","FAR const struct timespec *"
"sem_trywait","semaphore.h","","int","FAR sem_t*" "sem_trywait","semaphore.h","","int","FAR sem_t*"
"sem_unlink","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","int","FAR const char*" "sem_unlink","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","int","FAR const char*"
1 _exit unistd.h void int
118 sem_destroy semaphore.h int FAR sem_t*
119 sem_open semaphore.h defined(CONFIG_FS_NAMED_SEMAPHORES) FAR sem_t* FAR const char*
120 sem_post semaphore.h int FAR sem_t*
121 sem_setprotocol nuttx/semaphore.h defined(CONFIG_PRIORITY_INHERITANCE) int FAR sem_t*
122 sem_timedwait semaphore.h int FAR sem_t*
123 sem_trywait semaphore.h int FAR sem_t*
124 sem_unlink semaphore.h defined(CONFIG_FS_NAMED_SEMAPHORES) int FAR const char*