Completes the Implementation of the TLS-based errno

- Remove per-thread errno from the TCB structure (pterrno)
- Remove get_errno() and set_errno() as functions.  The macros are still available as stubs and will be needed in the future if we need to access the errno from a different address environment (KERNEL mode).
- Add errno value to the tls_info_s structure definitions
- Move sched/errno to libs/libc/errno.  Replace old TCB access to the errno with TLS access to the errno.
This commit is contained in:
Gregory Nutt
2020-05-07 14:15:09 -06:00
committed by Abdelatif Guettouche
parent a6da3c2cb6
commit 3dca5eba15
51 changed files with 475 additions and 1143 deletions
+3 -8
View File
@@ -157,20 +157,17 @@ int nxmq_wait_receive(mqd_t mqdes, FAR struct mqueue_msg_s **rcvmsg)
if ((mqdes->oflags & O_NONBLOCK) == 0)
{
int saved_errno;
/* Yes.. Block and try again */
rtcb = this_task();
rtcb->msgwaitq = msgq;
msgq->nwaitnotempty++;
/* "Borrow" the per-task errno to communication wake-up error
/* Initialize the 'errcode" used to communication wake-up error
* conditions.
*/
saved_errno = rtcb->pterrno;
rtcb->pterrno = OK;
rtcb->errcode = OK;
/* Make sure this is not the idle task, descheduling that
* isn't going to end well.
@@ -185,9 +182,7 @@ int nxmq_wait_receive(mqd_t mqdes, FAR struct mqueue_msg_s **rcvmsg)
* errno value (should be either EINTR or ETIMEDOUT).
*/
ret = rtcb->pterrno;
rtcb->pterrno = saved_errno;
ret = rtcb->errcode;
if (ret != OK)
{
return -ret;
+3 -8
View File
@@ -260,8 +260,6 @@ int nxmq_wait_send(mqd_t mqdes)
while (msgq->nmsgs >= msgq->maxmsgs)
{
int saved_errno;
/* Block until the message queue is no longer full.
* When we are unblocked, we will try again
*/
@@ -270,12 +268,11 @@ int nxmq_wait_send(mqd_t mqdes)
rtcb->msgwaitq = msgq;
msgq->nwaitnotfull++;
/* "Borrow" the per-task errno to communication wake-up error
/* Initialize the errcode used to communication wake-up error
* conditions.
*/
saved_errno = rtcb->pterrno;
rtcb->pterrno = OK;
rtcb->errcode = OK;
/* Make sure this is not the idle task, descheduling that
* isn't going to end well.
@@ -290,9 +287,7 @@ int nxmq_wait_send(mqd_t mqdes)
* per-task errno value (should be EINTR or ETIMEOUT).
*/
ret = rtcb->pterrno;
rtcb->pterrno = saved_errno;
ret = rtcb->errcode;
if (ret != OK)
{
return -ret;
+2 -2
View File
@@ -97,9 +97,9 @@ void nxmq_wait_irq(FAR struct tcb_s *wtcb, int errcode)
msgq->nwaitnotfull--;
}
/* Mark the errno value for the thread. */
/* Mark the error value for the thread. */
wtcb->pterrno = errcode;
wtcb->errcode = errcode;
/* Restart the task. */