Fix some build problems after recent separation of internal OS from application interfaces. The build problem only occurs in the PROTECTED and KERNEL builds where separate libraries are built for the applications and for use within the OS. In these cases, the correct interfaces must be used. This commit fixes a few of these, so I can get through build testing, but there are many more that need fixin'.
This commit is contained in:
parent
be1cb58f67
commit
a857cc04e4
@ -954,8 +954,6 @@ Where <subdir> is one of the following:
|
||||
|
||||
knxwm:
|
||||
-----
|
||||
[WARNING: This is a work in progress].
|
||||
|
||||
This is identical to the nxwm configuration below except that NuttX
|
||||
is built as a kernel-mode, monolithic module and the user applications
|
||||
are built separately. Is is recommended to use a special make command;
|
||||
@ -1470,14 +1468,16 @@ Where <subdir> is one of the following:
|
||||
|
||||
1. Install the nxwm configuration
|
||||
|
||||
$ cd ~/nuttx-code/nuttx/tools
|
||||
$ ./configure.sh stm3240g-eval/nxwm
|
||||
$ cd ~/nuttx-code/nuttx
|
||||
$ tools/configure.sh stm3240g-eval/nxwm
|
||||
|
||||
Use the -l option with the configure.sh script if you are using a
|
||||
Linux host; use the -c option if you are using Cygwin under Windows.
|
||||
Use the -h option to see other selections.
|
||||
|
||||
2. Make the build context (only)
|
||||
|
||||
$ cd ..
|
||||
$ make context
|
||||
...
|
||||
|
||||
3. Install the nxwm unit test
|
||||
|
||||
@ -1491,13 +1491,11 @@ Where <subdir> is one of the following:
|
||||
|
||||
$ cd ~/nuttx-code/NxWidgets/libnxwidgets
|
||||
$ make TOPDIR=~/nuttx-code/nuttx
|
||||
...
|
||||
|
||||
5. Build the NxWM library
|
||||
|
||||
$ cd ~/nuttx-code/NxWidgets/nxwm
|
||||
$ make TOPDIR=~/nuttx-code/nuttx
|
||||
...
|
||||
|
||||
6. Built NuttX with the installed unit test as the application
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <mqueue.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
@ -87,7 +88,7 @@
|
||||
|
||||
/* Handy macros */
|
||||
|
||||
#define nxmu_semgive(sem) nxsem_post(sem) /* To match nxmu_semtake() */
|
||||
#define nxmu_semgive(sem) _SEM_POST(sem) /* To match nxmu_semtake() */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
|
@ -57,6 +57,39 @@
|
||||
#define SEM_PRIO_INHERIT 1
|
||||
#define SEM_PRIO_PROTECT 2
|
||||
|
||||
/* 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
|
||||
* (libuc.a and libunx.a). The that case, the correct interface must be
|
||||
* used for the build context.
|
||||
*
|
||||
* REVISIT: The fact that sem_wait() is a cancellation point is an issue
|
||||
* and may cause violations: It makes functions into cancellation points!
|
||||
*/
|
||||
|
||||
#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_POST(s) nxsem_post(s)
|
||||
# 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_POST(s) sem_post(s)
|
||||
# define _SEM_ERRNO(r) errno
|
||||
# define _SEM_ERRVAL(r) (-errno)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/nx/nxfonts.h>
|
||||
|
||||
#include "nxcontext.h"
|
||||
@ -109,15 +110,15 @@ static void nxf_list_lock(void)
|
||||
|
||||
/* Get exclusive access to the font cache */
|
||||
|
||||
while ((ret = sem_wait(&g_cachesem)) < 0)
|
||||
while ((ret = _SEM_WAIT(&g_cachesem)) < 0)
|
||||
{
|
||||
int errorcode = errno;
|
||||
int errorcode = _SEM_ERRNO(ret);
|
||||
DEBUGASSERT(errorcode == EINTR || errorcode == ECANCELED);
|
||||
UNUSED(errorcode);
|
||||
}
|
||||
}
|
||||
|
||||
#define nxf_list_unlock() (nxsem_post(&g_cachesem))
|
||||
#define nxf_list_unlock() (_SEM_POST(&g_cachesem))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxf_removecache
|
||||
@ -166,15 +167,15 @@ static void nxf_cache_lock(FAR struct nxfonts_fcache_s *priv)
|
||||
|
||||
/* Get exclusive access to the font cache */
|
||||
|
||||
while ((ret = sem_wait(&priv->fsem)) < 0)
|
||||
while ((ret = _SEM_WAIT(&priv->fsem)) < 0)
|
||||
{
|
||||
int errorcode = errno;
|
||||
int errorcode = _SEM_ERRNO(ret);
|
||||
DEBUGASSERT(errorcode == EINTR || errorcode == ECANCELED);
|
||||
UNUSED(errorcode);
|
||||
}
|
||||
}
|
||||
|
||||
#define nxf_cache_unlock(p) (nxsem_post(&priv->fsem))
|
||||
#define nxf_cache_unlock(p) (_SEM_POST(&priv->fsem))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxf_removeglyph
|
||||
@ -845,7 +846,7 @@ void nxf_cache_disconnect(FCACHE fhandle)
|
||||
|
||||
/* Destroy the serializing semaphore... while we are holding it? */
|
||||
|
||||
nxsem_destroy(&priv->fsem);
|
||||
_SEM_DESTROY(&priv->fsem);
|
||||
|
||||
/* Finally, free the font cache stucture itself */
|
||||
|
||||
|
@ -115,7 +115,7 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
|
||||
|
||||
if (ret != OK)
|
||||
{
|
||||
gerr("ERROR: nxsem_init failed: %d\n", errno);
|
||||
gerr("ERROR: sem_init failed: %d\n", errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
|
||||
|
||||
/* Destroy the semaphore and return. */
|
||||
|
||||
nxsem_destroy(&sem_done);
|
||||
sem_destroy(&sem_done);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -43,10 +43,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <semaphore.h>
|
||||
#include <mqueue.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
||||
@ -65,7 +67,7 @@
|
||||
* NOTE: that client ID 0 is reserved for the server(s) themselves
|
||||
*/
|
||||
|
||||
static sem_t g_nxlibsem = { 1 };
|
||||
static sem_t g_nxlibsem = SEM_INITIALIZER(1);
|
||||
static uint32_t g_nxcid = 1;
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -106,10 +106,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 = _SEM_INIT(&sem_done, 0, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
gerr("ERROR: nxsem_init failed: %d\n", errno);
|
||||
gerr("ERROR: _SEM_INIT failed: %d\n", _SEM_ERRNO(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -127,12 +127,12 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = sem_wait(&sem_done);
|
||||
ret = _SEM_WAIT(&sem_done);
|
||||
}
|
||||
|
||||
/* Destroy the semaphore and return. */
|
||||
|
||||
nxsem_destroy(&sem_done);
|
||||
_SEM_DESTROY(&sem_done);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -52,28 +52,23 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* Internal nxsem_* interfaces are not available in the user space in
|
||||
* PROTECTED and FLAT builds. In that context, the application semaphore
|
||||
* 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.
|
||||
*
|
||||
* See additional definitions in include/nuttx/semaphore.h
|
||||
*
|
||||
* REVISIT: The fact that sem_wait() is a cancellation point is an issue
|
||||
* and does cause a violation: It makes all of the memory management
|
||||
* interfaces into cancellation points!
|
||||
* interfaces into cancellation points when used from user space in the
|
||||
* PROTECTED and KERNEL builds.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
# define SEM_INIT(s,p,c) nxsem_init(s,p,c)
|
||||
# define SEM_WAIT(s) nxsem_wait(s)
|
||||
# define SEM_TRYWAIT(s) nxsem_trywait(s)
|
||||
# define SEM_POST(s) nxsem_post(s)
|
||||
# define SEM_ERROR(r)
|
||||
# define _SEM_GETERROR(r)
|
||||
#else
|
||||
# define SEM_INIT(s,p,c) sem_init(s,p,c)
|
||||
# define SEM_WAIT(s) sem_wait(s)
|
||||
# define SEM_TRYWAIT(s) sem_trywait(s)
|
||||
# define SEM_POST(s) sem_post(s)
|
||||
# define SEM_ERROR(r) (r) = -errno
|
||||
# define _SEM_GETERROR(r) (r) = -errno
|
||||
#endif
|
||||
|
||||
/* Define the following to enable semaphore state monitoring */
|
||||
@ -114,7 +109,7 @@ void mm_seminitialize(FAR struct mm_heap_s *heap)
|
||||
* private data sets).
|
||||
*/
|
||||
|
||||
(void)SEM_INIT(&heap->mm_semaphore, 0, 1);
|
||||
(void)nxsem_init(&heap->mm_semaphore, 0, 1);
|
||||
|
||||
heap->mm_holder = -1;
|
||||
heap->mm_counts_held = 0;
|
||||
@ -149,10 +144,10 @@ int mm_trysemaphore(FAR struct mm_heap_s *heap)
|
||||
{
|
||||
/* Try to take the semaphore (perhaps waiting) */
|
||||
|
||||
ret = SEM_TRYWAIT(&heap->mm_semaphore);
|
||||
ret = _SEM_TRYWAIT(&heap->mm_semaphore);
|
||||
if (ret < 0)
|
||||
{
|
||||
SEM_ERROR(ret);
|
||||
_SEM_GETERROR(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -194,7 +189,7 @@ void mm_takesemaphore(FAR struct mm_heap_s *heap)
|
||||
mseminfo("PID=%d taking\n", my_pid);
|
||||
do
|
||||
{
|
||||
ret = SEM_WAIT(&heap->mm_semaphore);
|
||||
ret = _SEM_WAIT(&heap->mm_semaphore);
|
||||
|
||||
/* The only case that an error should occur here is if the wait
|
||||
* was awakened by a signal.
|
||||
@ -261,6 +256,6 @@ void mm_givesemaphore(FAR struct mm_heap_s *heap)
|
||||
|
||||
heap->mm_holder = -1;
|
||||
heap->mm_counts_held = 0;
|
||||
DEBUGVERIFY(SEM_POST(&heap->mm_semaphore));
|
||||
DEBUGVERIFY(_SEM_POST(&heap->mm_semaphore));
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user