semaphore/_SEM_XX: Remove the _SEM redirection macros as unnecessary
This commit is contained in:
parent
5f36a43609
commit
e39ef8563e
@ -21,9 +21,7 @@ Libraries in NuttX are very special creatures. They have these properties:
|
||||
For example, ``sem_wait()`` is both a cancellation point and modifies the
|
||||
errno value. So within the FLAT build and without kernel version for
|
||||
the PROTECTED and KERNEL builds, the special internal OS interface
|
||||
``nxsem_wait()`` must be used. Within libraries, the macro ``_SEM_WAIT()``
|
||||
(as defined in ``include/nuttx/semaphore.h``) is used instead. The
|
||||
definition of this macro accounts for the different usage environments.
|
||||
``nxsem_wait()`` must be used.
|
||||
|
||||
NOTE: The libraries under ``libs/`` build differently from other NuttX
|
||||
components: There are no build-related files in the ``libs/`` directory; it
|
||||
|
@ -57,51 +57,6 @@
|
||||
{(c), (f), SEM_WAITLIST_INITIALIZER}
|
||||
#endif /* CONFIG_PRIORITY_INHERITANCE */
|
||||
|
||||
/* Most internal nxsem_* interfaces are not available in the user space in
|
||||
* PROTECTED and KERNEL builds. In that context, the application semaphore
|
||||
* interfaces must be used. The differences between the two sets of
|
||||
* interfaces are: (1) the nxsem_* interfaces do not cause cancellation
|
||||
* points and (2) they do not modify the errno variable.
|
||||
*
|
||||
* This is only important when compiling libraries (libc or libnx) that are
|
||||
* used both by the OS (libkc.a and libknx.a) or by the applications
|
||||
* (libc.a and libnx.a). In that case, the correct interface must be
|
||||
* used for the build context.
|
||||
*
|
||||
* REVISIT: In the flat build, the same functions must be used both by
|
||||
* the OS and by applications. We have to use the normal user functions
|
||||
* in this case or we will fail to set the errno or fail to create the
|
||||
* cancellation point.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
|
||||
# define _SEM_INIT(s,p,c) nxsem_init(s,p,c)
|
||||
# define _SEM_DESTROY(s) nxsem_destroy(s)
|
||||
# define _SEM_WAIT(s) nxsem_wait(s)
|
||||
# define _SEM_TRYWAIT(s) nxsem_trywait(s)
|
||||
# define _SEM_TIMEDWAIT(s,t) nxsem_timedwait(s,t)
|
||||
# define _SEM_CLOCKWAIT(s,c,t) nxsem_clockwait(s,c,t)
|
||||
# define _SEM_POST(s) nxsem_post(s)
|
||||
# define _SEM_GETVALUE(s,v) nxsem_get_value(s,v)
|
||||
# define _SEM_GETPROTOCOL(s,p) nxsem_get_protocol(s,p)
|
||||
# define _SEM_SETPROTOCOL(s,p) nxsem_set_protocol(s,p)
|
||||
# define _SEM_ERRNO(r) (-(r))
|
||||
# define _SEM_ERRVAL(r) (r)
|
||||
#else
|
||||
# define _SEM_INIT(s,p,c) sem_init(s,p,c)
|
||||
# define _SEM_DESTROY(s) sem_destroy(s)
|
||||
# define _SEM_WAIT(s) sem_wait(s)
|
||||
# define _SEM_TRYWAIT(s) sem_trywait(s)
|
||||
# define _SEM_TIMEDWAIT(s,t) sem_timedwait(s,t)
|
||||
# define _SEM_CLOCKWAIT(s,c,t) sem_clockwait(s,c,t)
|
||||
# define _SEM_GETVALUE(s,v) sem_getvalue(s,v)
|
||||
# define _SEM_POST(s) sem_post(s)
|
||||
# define _SEM_GETPROTOCOL(s,p) sem_getprotocol(s,p)
|
||||
# define _SEM_SETPROTOCOL(s,p) sem_setprotocol(s,p)
|
||||
# define _SEM_ERRNO(r) errno
|
||||
# define _SEM_ERRVAL(r) (-errno)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
@ -112,10 +112,10 @@ static int work_qcancel(FAR struct usr_wqueue_s *wqueue,
|
||||
/* Remove the work at the head of the queue */
|
||||
|
||||
dq_remfirst(&wqueue->q);
|
||||
_SEM_GETVALUE(&wqueue->wake, &semcount);
|
||||
nxsem_get_value(&wqueue->wake, &semcount);
|
||||
if (semcount < 1)
|
||||
{
|
||||
_SEM_POST(&wqueue->wake);
|
||||
nxsem_post(&wqueue->wake);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue,
|
||||
/* Add the watchdog to the head == tail of the queue. */
|
||||
|
||||
dq_addfirst(&work->u.s.dq, &wqueue->q);
|
||||
_SEM_POST(&wqueue->wake);
|
||||
nxsem_post(&wqueue->wake);
|
||||
}
|
||||
|
||||
/* There are other active watchdogs in the timer queue */
|
||||
@ -127,10 +127,10 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue,
|
||||
/* Insert the watchdog at the head of the list */
|
||||
|
||||
dq_addfirst(&work->u.s.dq, &wqueue->q);
|
||||
_SEM_GETVALUE(&wqueue->wake, &semcount);
|
||||
nxsem_get_value(&wqueue->wake, &semcount);
|
||||
if (semcount < 1)
|
||||
{
|
||||
_SEM_POST(&wqueue->wake);
|
||||
nxsem_post(&wqueue->wake);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -191,7 +191,7 @@ static void work_process(FAR struct usr_wqueue_s *wqueue)
|
||||
{
|
||||
/* Wait indefinitely until work_queue has new items */
|
||||
|
||||
_SEM_WAIT(&wqueue->wake);
|
||||
nxsem_wait(&wqueue->wake);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -208,7 +208,7 @@ static void work_process(FAR struct usr_wqueue_s *wqueue)
|
||||
clock_ticks2time(next, &delay);
|
||||
clock_timespec_add(&now, &delay, &rqtp);
|
||||
|
||||
_SEM_TIMEDWAIT(&wqueue->wake, &rqtp);
|
||||
nxsem_timedwait(&wqueue->wake, &rqtp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,10 +95,10 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
|
||||
|
||||
outmsg.sem_done = &sem_done;
|
||||
|
||||
ret = _SEM_INIT(&sem_done, 0, 0);
|
||||
ret = nxsem_init(&sem_done, 0, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
gerr("ERROR: _SEM_INIT failed: %d\n", _SEM_ERRNO(ret));
|
||||
gerr("ERROR: nxsem_init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -112,12 +112,12 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = _SEM_WAIT(&sem_done);
|
||||
ret = nxsem_wait(&sem_done);
|
||||
}
|
||||
|
||||
/* Destroy the semaphore and return. */
|
||||
|
||||
_SEM_DESTROY(&sem_done);
|
||||
nxsem_destroy(&sem_done);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -90,10 +90,10 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
|
||||
outmsg.sem_done = &sem_done;
|
||||
|
||||
ret = _SEM_INIT(&sem_done, 0, 0);
|
||||
ret = nxsem_init(&sem_done, 0, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
gerr("ERROR: _SEM_INIT failed: %d\n", _SEM_ERRNO(ret));
|
||||
gerr("ERROR: nxsem_init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -108,12 +108,12 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = _SEM_WAIT(&sem_done);
|
||||
ret = nxsem_wait(&sem_done);
|
||||
}
|
||||
|
||||
/* Destroy the semaphore and return. */
|
||||
|
||||
_SEM_DESTROY(&sem_done);
|
||||
nxsem_destroy(&sem_done);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user