From ac37ac75e0717f4635be52999648f2494ec20146 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 1 Feb 2008 21:23:19 +0000 Subject: [PATCH] errno now defined to be *get_errno_ptr() git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@607 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 2 ++ Documentation/NuttX.html | 3 +- arch/arm/src/common/up_sigdeliver.c | 36 ++++++++++----------- arch/z16/src/common/up_sigdeliver.c | 4 +-- arch/z80/src/common/up_sigdeliver.c | 4 +-- examples/nettest/nettest.h | 4 --- examples/nsh/nsh.h | 2 -- examples/pashello/pashello.h | 2 -- examples/udp/udp-internal.h | 8 ++--- include/errno.h | 10 ++++-- include/nuttx/sched.h | 2 +- netutils/dhcpd/dhcpd.c | 5 ++- netutils/uiplib/uip-server.c | 2 -- netutils/webserver/httpd.c | 4 +-- sched/get_errno_ptr.c | 5 +-- sched/mq_timedreceive.c | 2 +- sched/mq_timedsend.c | 2 +- sched/mq_waitirq.c | 48 ++++++++++++++-------------- sched/os_internal.h | 4 +-- sched/sem_waitirq.c | 48 ++++++++++++++-------------- sched/sig_deliver.c | 49 +++++++++++++++-------------- 21 files changed, 120 insertions(+), 126 deletions(-) diff --git a/ChangeLog b/ChangeLog index 665074ff14..191b5cf215 100644 --- a/ChangeLog +++ b/ChangeLog @@ -314,4 +314,6 @@ * Added a test case to verify the Pascal P-Code interpreter * Added /dev/zero + * 'errno' is now defined to be *get_errno_ptr() with no name conflicts + diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index b12036faa4..60e1857cda 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: January 31, 2008

+

Last Updated: February 1, 2008

@@ -964,6 +964,7 @@ Other memory: * Added a test case to verify the Pascal P-Code interpreter * Added /dev/zero + * 'errno' is now defined to be *get_errno_ptr() with no name conflicts diff --git a/arch/arm/src/common/up_sigdeliver.c b/arch/arm/src/common/up_sigdeliver.c index 6738551444..31d798b935 100644 --- a/arch/arm/src/common/up_sigdeliver.c +++ b/arch/arm/src/common/up_sigdeliver.c @@ -1,7 +1,7 @@ -/************************************************************ +/**************************************************************************** * common/up_sigdeliver.c * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Included Files - ************************************************************/ + ****************************************************************************/ #include #include @@ -47,23 +47,23 @@ #include "up_internal.h" #include "up_arch.h" -/************************************************************ +/**************************************************************************** * Definitions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Data - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Public Funtions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Name: up_sigdeliver * * Description: @@ -72,7 +72,7 @@ * with and forced to branch to this location with interrupts * disabled. * - ************************************************************/ + ****************************************************************************/ void up_sigdeliver(void) { @@ -86,7 +86,7 @@ void up_sigdeliver(void) * the correct errno value (probably EINTR). */ - int saved_errno = rtcb->errno; + int saved_errno = rtcb->pterrno; up_ledon(LED_SIGNAL); @@ -125,7 +125,7 @@ void up_sigdeliver(void) */ dbg("Resuming\n"); - rtcb->errno = saved_errno; + rtcb->pterrno = saved_errno; /* Then restore the correct state for this thread of * execution. diff --git a/arch/z16/src/common/up_sigdeliver.c b/arch/z16/src/common/up_sigdeliver.c index afc554e858..e6aa6325da 100644 --- a/arch/z16/src/common/up_sigdeliver.c +++ b/arch/z16/src/common/up_sigdeliver.c @@ -91,7 +91,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->errno; + int saved_errno = rtcb->pterrno; up_ledon(LED_SIGNAL); @@ -131,7 +131,7 @@ void up_sigdeliver(void) */ dbg("Resuming\n"); - rtcb->errno = saved_errno; + rtcb->pterrno = saved_errno; /* Then restore the correct state for this thread of * execution. diff --git a/arch/z80/src/common/up_sigdeliver.c b/arch/z80/src/common/up_sigdeliver.c index e9ade99640..5f2aab7679 100644 --- a/arch/z80/src/common/up_sigdeliver.c +++ b/arch/z80/src/common/up_sigdeliver.c @@ -90,7 +90,7 @@ void up_sigdeliver(void) * EINTR). */ - int saved_errno = rtcb->errno; + int saved_errno = rtcb->pterrno; up_ledon(LED_SIGNAL); @@ -129,7 +129,7 @@ void up_sigdeliver(void) */ dbg("Resuming\n"); - rtcb->errno = saved_errno; + rtcb->pterrno = saved_errno; /* Then restore the correct state for this thread of * execution. diff --git a/examples/nettest/nettest.h b/examples/nettest/nettest.h index 4805c8f9ad..db84ac495b 100644 --- a/examples/nettest/nettest.h +++ b/examples/nettest/nettest.h @@ -65,10 +65,6 @@ #else - /* Get errno using a pointer */ - -# define errno *get_errno_ptr() - /* Used lib_rawprintf() so that there is not confusion from buffered IO */ # define message(...) lib_rawprintf(__VA_ARGS__) diff --git a/examples/nsh/nsh.h b/examples/nsh/nsh.h index 659a59d174..015c0aa886 100644 --- a/examples/nsh/nsh.h +++ b/examples/nsh/nsh.h @@ -52,8 +52,6 @@ #define NSH_MAX_ARGUMENTS 6 -#define errno (*get_errno_ptr()) - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/examples/pashello/pashello.h b/examples/pashello/pashello.h index 1b544f182f..ad206261e2 100644 --- a/examples/pashello/pashello.h +++ b/examples/pashello/pashello.h @@ -44,8 +44,6 @@ * Definitions ****************************************************************************/ -#define errno *get_errno_ptr() - /**************************************************************************** * Public Function Prototypes ****************************************************************************/ diff --git a/examples/udp/udp-internal.h b/examples/udp/udp-internal.h index ef5a030b70..94fe1e4825 100644 --- a/examples/udp/udp-internal.h +++ b/examples/udp/udp-internal.h @@ -1,7 +1,7 @@ /**************************************************************************** * examples/udp/udp-internal.h * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -63,10 +63,6 @@ #else - /* Get errno using a pointer */ - -# define errno *get_errno_ptr() - /* If debug is enabled, use the synchronous lib_lowprintf so that the * program output does not get disassociated in the debug output. */ diff --git a/include/errno.h b/include/errno.h index 1291a2cffc..1dea0f4091 100644 --- a/include/errno.h +++ b/include/errno.h @@ -1,7 +1,7 @@ /************************************************************************ - * errno.h + * include/errno.h * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -44,6 +44,10 @@ * Definitions ************************************************************************/ +/* Convenience/compatibility definition */ + +#define errno *get_errno_ptr() + /* Definitions of error numbers and the string that would be * returned by strerror(). */ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index c3cc5d8090..87cdc8127e 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -238,7 +238,7 @@ struct _TCB /* Library related fields *****************************************************/ - int errno; /* Current per-thread errno */ + int pterrno; /* Current per-thread errno */ /* File system support ********************************************************/ diff --git a/netutils/dhcpd/dhcpd.c b/netutils/dhcpd/dhcpd.c index 118b991f11..6c41b84a82 100644 --- a/netutils/dhcpd/dhcpd.c +++ b/netutils/dhcpd/dhcpd.c @@ -1,7 +1,7 @@ /**************************************************************************** * netutils/dhcpd/dhcpd.c * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -55,7 +55,6 @@ typedef unsigned char boolean; # include # include # include -# define errno *get_errno_ptr() #endif #include diff --git a/netutils/uiplib/uip-server.c b/netutils/uiplib/uip-server.c index 8baccf33de..38b5e6ae82 100644 --- a/netutils/uiplib/uip-server.c +++ b/netutils/uiplib/uip-server.c @@ -53,8 +53,6 @@ * Public Functions ****************************************************************************/ -#define errno *get_errno_ptr() - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/netutils/webserver/httpd.c b/netutils/webserver/httpd.c index 9e37e46aad..e3e1559713 100644 --- a/netutils/webserver/httpd.c +++ b/netutils/webserver/httpd.c @@ -2,7 +2,7 @@ * netutils/webserver/httpd.c * httpd Web server * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * This is a leverage of similar logic from uIP: @@ -76,8 +76,6 @@ #define ISO_slash 0x2f #define ISO_colon 0x3a -#define errno *get_errno_ptr() - #undef CONFIG_NETUTILS_HTTPD_DUMPBUFFER #undef CONFIG_NETUTILS_HTTPD_DUMPPSTATE diff --git a/sched/get_errno_ptr.c b/sched/get_errno_ptr.c index 36598caae9..ebf2e105c3 100644 --- a/sched/get_errno_ptr.c +++ b/sched/get_errno_ptr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * get_errno_ptr.c + * sched/get_errno_ptr.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -44,6 +44,7 @@ #include "os_internal.h" #undef get_errno_ptr +#undef errno /**************************************************************************** * Private Data @@ -93,7 +94,7 @@ FAR int *get_errno_ptr(void) * thread-private errno in the TCB of the running task. */ - return &rtcb->errno; + return &rtcb->pterrno; } } diff --git a/sched/mq_timedreceive.c b/sched/mq_timedreceive.c index 6f0d93d2b6..ca4b4aa854 100644 --- a/sched/mq_timedreceive.c +++ b/sched/mq_timedreceive.c @@ -112,7 +112,7 @@ static void mq_rcvtimeout(int argc, uint32 pid) { /* Mark the errno value for the thread. */ - wtcb->errno = ETIMEDOUT; + wtcb->pterrno = ETIMEDOUT; /* Restart the the task. */ diff --git a/sched/mq_timedsend.c b/sched/mq_timedsend.c index 76e3fda5d2..012bd2ab01 100644 --- a/sched/mq_timedsend.c +++ b/sched/mq_timedsend.c @@ -113,7 +113,7 @@ static void mq_sndtimeout(int argc, uint32 pid) { /* Mark the errno value for the thread. */ - wtcb->errno = ETIMEDOUT; + wtcb->pterrno = ETIMEDOUT; /* Restart the the task. */ diff --git a/sched/mq_waitirq.c b/sched/mq_waitirq.c index be23e5b903..75ecbb08f3 100644 --- a/sched/mq_waitirq.c +++ b/sched/mq_waitirq.c @@ -1,7 +1,7 @@ -/************************************************************ - * mq_waitirq.c +/**************************************************************************** + * sched/mq_waitirq.c * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Included Files - ************************************************************/ + ****************************************************************************/ #include #include @@ -43,35 +43,35 @@ #include #include "sem_internal.h" -/************************************************************ +/**************************************************************************** * Compilation Switches - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Definitions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Type Declarations - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Global Variables - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Variables - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Public Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Function: sem_waitirq * * Description: @@ -89,7 +89,7 @@ * * Assumptions: * - ************************************************************/ + ****************************************************************************/ void mq_waitirq(FAR _TCB *wtcb) { @@ -111,7 +111,7 @@ void mq_waitirq(FAR _TCB *wtcb) { /* Mark the errno value for the thread. */ - wtcb->errno = EINTR; + wtcb->pterrno = EINTR; /* Restart the the task. */ diff --git a/sched/os_internal.h b/sched/os_internal.h index e3dffb2074..665d05e743 100644 --- a/sched/os_internal.h +++ b/sched/os_internal.h @@ -105,10 +105,10 @@ enum os_crash_codes_e /* A more efficient ways to access the errno */ #define SET_ERRNO(e) \ - { _TCB *rtcb = _TCB*)g_readytorun.head; rtcb->errno = (e); } + { _TCB *rtcb = _TCB*)g_readytorun.head; rtcb->pterrno = (e); } #define _SET_TCB_ERRNO(t,e) \ - { (t)->errno = (e); } + { (t)->pterrno = (e); } /**************************************************************************** * Public Type Definitions diff --git a/sched/sem_waitirq.c b/sched/sem_waitirq.c index b7cbdce21a..3aded997d3 100644 --- a/sched/sem_waitirq.c +++ b/sched/sem_waitirq.c @@ -1,7 +1,7 @@ -/************************************************************ - * sem_waitirq.c +/**************************************************************************** + * sched/sem_waitirq.c * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Included Files - ************************************************************/ + ****************************************************************************/ #include #include @@ -43,35 +43,35 @@ #include #include "sem_internal.h" -/************************************************************ +/**************************************************************************** * Compilation Switches - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Definitions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Type Declarations - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Global Variables - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Variables - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Public Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Function: sem_waitirq * * Description: @@ -90,7 +90,7 @@ * * Assumptions: * - ************************************************************/ + ****************************************************************************/ void sem_waitirq(FAR _TCB *wtcb) { @@ -115,7 +115,7 @@ void sem_waitirq(FAR _TCB *wtcb) /* Mark the errno value for the thread. */ - wtcb->errno = EINTR; + wtcb->pterrno = EINTR; /* Restart the the task. */ diff --git a/sched/sig_deliver.c b/sched/sig_deliver.c index 0a900c73d5..2244ca2fe0 100644 --- a/sched/sig_deliver.c +++ b/sched/sig_deliver.c @@ -1,7 +1,7 @@ -/************************************************************ - * sig_deliver.c +/**************************************************************************** + * sched/sig_deliver.c * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,11 +31,13 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Included Files - ************************************************************/ + ****************************************************************************/ + +#include #include #include @@ -43,35 +45,36 @@ #include #include #include + #include "os_internal.h" #include "sem_internal.h" #include "sig_internal.h" -/************************************************************ +/**************************************************************************** * Definitions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Type Declarations - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Global Variables - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Variables - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Public Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Function: sig_deliver * * Description: @@ -79,7 +82,7 @@ * the signal receiving task. It processes all queued * signals then returns. * - ************************************************************/ + ****************************************************************************/ void sig_deliver(FAR _TCB *stcb) { @@ -99,7 +102,7 @@ void sig_deliver(FAR _TCB *stcb) * was reawakened by a signal must be retained. */ - saved_errno = stcb->errno; + saved_errno = stcb->pterrno; for (sigq = (FAR sigq_t*)stcb->sigpendactionq.head; (sigq); sigq = next) { next = sigq->flink; @@ -158,7 +161,7 @@ void sig_deliver(FAR _TCB *stcb) sig_releasependingsigaction(sigq); } - stcb->errno = saved_errno; + stcb->pterrno = saved_errno; sched_unlock(); }