libc and libnx: When the libraries are built into two libraries, a user space library and a OS space library (as in the PROTECTED and KERNEL build). Then the user space library must not use the OS internal interfaces; similarly, the OS must avoid using the userspace interfaces so that it does not muck the errno value or create spurious cancellation points.
This commit is contained in:
parent
6642e20e05
commit
5e4f4ee788
3 changed files with 53 additions and 4 deletions
|
|
@ -68,9 +68,9 @@
|
|||
* (libuc.a and libunx.a). The that case, the correct interface must be
|
||||
* used for the build context.
|
||||
*
|
||||
* The interfaces sem_twait() and sem_timedwait() are cancellation points.
|
||||
* The interfaces sem_wait() and sem_timedwait() are cancellation points.
|
||||
*
|
||||
* REVISIT: The fact that sem_twait() and sem_timedwait() are cancellation
|
||||
* REVISIT: The fact that sem_wait() and sem_timedwait() are cancellation
|
||||
* points is an issue and may cause violations: It use of these internally
|
||||
* will cause the calling function to become a cancellation points!
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -45,6 +45,51 @@
|
|||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* Most internal nxsig_* interfaces are not available in the user space in
|
||||
* PROTECTED and KERNEL builds. In that context, the application signal
|
||||
* interfaces must be used. The differences between the two sets of
|
||||
* interfaces are: (1) the nxsig_* 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.
|
||||
*
|
||||
* The interfaces sigtimedwait(), sigwait(), sigwaitinfo(), sleep(),
|
||||
* nanosleep(), and usleep() are cancellation points.
|
||||
*
|
||||
* REVISIT: The fact that these interfaces are cancellation points is an
|
||||
* issue and may cause violations: It use of these internally will cause
|
||||
* the calling function to become a cancellation points!
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
# define _SIG_PROCMASK(h,s,o) nxsig_procmask(h,s,o)
|
||||
# define _SIG_QUEUE(p,s,v) nxsig_queue(p,s,v)
|
||||
# define _SIG_KILL(p,s) nxsig_kill(p,s);
|
||||
# define _SIG_WAITINFO(s,i) nxsig_timedwait(s,i,NULL)
|
||||
# define _SIG_NANOSLEEP(r,a) nxsig_nanosleep(r,a)
|
||||
# define _SIG_SLEEP(s) nxsig_sleep(s)
|
||||
# define _SIG_USLEEP(u) nxsig_usleep(u)
|
||||
# define _SIG_ERRNO(r) (-(r))
|
||||
# define _SIG_ERRVAL(r) (r)
|
||||
#else
|
||||
# define _SIG_PROCMASK(h,s,o) sigprocmask(h,s,o)
|
||||
# define _SIG_QUEUE(p,s,v) sigqueue(p,s,v)
|
||||
# define _SIG_KILL(p,s) kill(p,s);
|
||||
# define _SIG_WAITINFO(s,i) sigwaitinfo(s,i)
|
||||
# define _SIG_NANOSLEEP(r,a) nanosleep(r,a)
|
||||
# define _SIG_SLEEP(s) sleep(s)
|
||||
# define _SIG_USLEEP(u) usleep(u)
|
||||
# define _SIG_ERRNO(r) errno
|
||||
# define _SIG_ERRVAL(r) (-errno)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
|
@ -129,7 +174,7 @@ int nxsig_procmask(int how, FAR const sigset_t *set, FAR sigset_t *oset);
|
|||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
int nxsig_queue (int pid, int signo, union sigval value);
|
||||
int nxsig_queue(int pid, int signo, union sigval value);
|
||||
#else
|
||||
int nxsig_queue(int pid, int signo, void *sival_ptr);
|
||||
#endif
|
||||
|
|
@ -236,6 +281,8 @@ int nxsig_kill(pid_t pid, int signo);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
||||
FAR const struct timespec *timeout);
|
||||
int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
||||
FAR const struct timespec *timeout);
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/signal.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/nx/nx.h>
|
||||
#include <nuttx/nx/nxmu.h>
|
||||
|
|
@ -190,7 +191,8 @@ NXHANDLE nx_connectinstance(FAR const char *svrmqname)
|
|||
gerr("ERROR: nx_message failed: %d\n", errno);
|
||||
goto errout_with_wmq;
|
||||
}
|
||||
usleep(300000);
|
||||
|
||||
_SIG_USLEEP(300000);
|
||||
}
|
||||
while (conn->state != NX_CLISTATE_CONNECTED);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue