include/nutt: Fix definitions used to access OS functions within the libraries. In the FLAT build, we must always set the errno and/or create cancellation points because the same library functions are used within the OS as are used by applications. This could cause issues for the OS but corrects some problems at the user interface.

Noted by Federico Braghiroli in Bitbucket issue 121.
This commit is contained in:
Gregory Nutt 2018-09-26 06:57:49 -06:00
parent 71eac2d530
commit 3b1cc69d68
6 changed files with 37 additions and 20 deletions

View File

@ -73,16 +73,21 @@
* (libuc.a and libunx.a). The that case, the correct interface must be * (libuc.a and libunx.a). The that case, the correct interface must be
* used for the build context. * used for the build context.
* *
* The interfaces open(), close(), creat(), read(), pread(), write(), * REVISIT: In the flat build, the same functions must be used both by
* pwrite(), poll(), select(), fcntl(), and aio_suspend() are all * the OS and by applications. We have to use the normal user functions
* cancellation points. * in this case or we will fail to set the errno or fail to create the
* cancellation point.
*
* The interfaces close(), creat(), read(), pread(), write(), pwrite(),
* poll(), select(), fcntl(), and aio_suspend() are all cancellation
* points.
* *
* REVISIT: These cancellation points are an issue and may cause * REVISIT: These cancellation points are an issue and may cause
* violations: It use of these internally will cause the calling function * violations: It use of these internally will cause the calling function
* to become a cancellation points! * to become a cancellation points!
*/ */
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
# ifdef CONFIG_CPP_HAVE_VARARGS # ifdef CONFIG_CPP_HAVE_VARARGS
# define _NX_OPEN(p,f,...) nx_open(p,f,##__VA_ARGS__) # define _NX_OPEN(p,f,...) nx_open(p,f,##__VA_ARGS__)
# else # else

View File

@ -68,15 +68,13 @@
* (libuc.a and libunx.a). The that case, the correct interface must be * (libuc.a and libunx.a). The that case, the correct interface must be
* used for the build context. * used for the build context.
* *
* The interfaces sigtimedwait(), sigwait(), sigwaitinfo(), sleep(), * REVISIT: In the flat build, the same functions must be used both by
* nanosleep(), and usleep() are cancellation points. * 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
* REVISIT: The fact that these interfaces are cancellation points is an * cancellation point.
* 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__) #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
# define _MQ_SEND(d,m,l,p) nxmq_send(d,m,l,p) # define _MQ_SEND(d,m,l,p) nxmq_send(d,m,l,p)
# define _MQ_TIMEDSEND(d,m,l,p,t) nxmq_timedsend(d,m,l,p,t) # define _MQ_TIMEDSEND(d,m,l,p,t) nxmq_timedsend(d,m,l,p,t)
# define _MQ_RECEIVE(d,m,l,p) nxmq_receive(d,m,l,p) # define _MQ_RECEIVE(d,m,l,p) nxmq_receive(d,m,l,p)

View File

@ -65,6 +65,11 @@
* (libuc.a and libunx.a). The that case, the correct interface must be * (libuc.a and libunx.a). The that case, the correct interface must be
* used for the build context. * 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.
*
* The interfaces accept(), read(), recv(), recvfrom(), write(), send(), * The interfaces accept(), read(), recv(), recvfrom(), write(), send(),
* sendto() are all cancellation points. * sendto() are all cancellation points.
* *
@ -73,7 +78,7 @@
* to become a cancellation points! * to become a cancellation points!
*/ */
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
# define _NX_SEND(s,b,l,f) nx_send(s,b,l,f) # define _NX_SEND(s,b,l,f) nx_send(s,b,l,f)
# define _NX_RECV(s,b,l,f) nx_recv(s,b,l,f) # define _NX_RECV(s,b,l,f) nx_recv(s,b,l,f)
# define _NX_RECVFROM(s,b,l,f,a,n) nx_recvfrom(s,b,l,f,a,n) # define _NX_RECVFROM(s,b,l,f,a,n) nx_recvfrom(s,b,l,f,a,n)

View File

@ -188,9 +188,14 @@
* used both by the OS (libkc.a and libknx.a) or by the applications * 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 * (libuc.a and libunx.a). The that case, the correct interface must be
* used for the build context. * 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__) #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
# define _SCHED_GETPARAM(t,p) nxsched_getparam(t,p) # define _SCHED_GETPARAM(t,p) nxsched_getparam(t,p)
# define _SCHED_SETPARAM(t,p) nxsched_setparam(t,p) # define _SCHED_SETPARAM(t,p) nxsched_setparam(t,p)
# define _SCHED_GETSCHEDULER(t) nxsched_getscheduler(t) # define _SCHED_GETSCHEDULER(t) nxsched_getscheduler(t)

View File

@ -68,14 +68,13 @@
* (libuc.a and libunx.a). The that case, the correct interface must be * (libuc.a and libunx.a). The that case, the correct interface must be
* used for the build context. * used for the build context.
* *
* The interfaces sem_wait() and sem_timedwait() are cancellation points. * 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
* REVISIT: The fact that sem_wait() and sem_timedwait() are cancellation * in this case or we will fail to set the errno or fail to create the
* points is an issue and may cause violations: It use of these internally * cancellation point.
* will cause the calling function to become a cancellation points!
*/ */
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
# define _SEM_INIT(s,p,c) nxsem_init(s,p,c) # define _SEM_INIT(s,p,c) nxsem_init(s,p,c)
# define _SEM_DESTROY(s) nxsem_destroy(s) # define _SEM_DESTROY(s) nxsem_destroy(s)
# define _SEM_WAIT(s) nxsem_wait(s) # define _SEM_WAIT(s) nxsem_wait(s)

View File

@ -61,6 +61,11 @@
* (libuc.a and libunx.a). The that case, the correct interface must be * (libuc.a and libunx.a). The that case, the correct interface must be
* used for the build context. * 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.
*
* The interfaces sigtimedwait(), sigwait(), sigwaitinfo(), sleep(), * The interfaces sigtimedwait(), sigwait(), sigwaitinfo(), sleep(),
* nanosleep(), and usleep() are cancellation points. * nanosleep(), and usleep() are cancellation points.
* *
@ -69,7 +74,7 @@
* the calling function to become a cancellation points! * the calling function to become a cancellation points!
*/ */
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
# define _SIG_PROCMASK(h,s,o) nxsig_procmask(h,s,o) # define _SIG_PROCMASK(h,s,o) nxsig_procmask(h,s,o)
# define _SIG_SIGACTION(s,a,o) nxsig_action(s,a,o,false) # define _SIG_SIGACTION(s,a,o) nxsig_action(s,a,o,false)
# define _SIG_QUEUE(p,s,v) nxsig_queue(p,s,v) # define _SIG_QUEUE(p,s,v) nxsig_queue(p,s,v)