This is an automated email from the ASF dual-hosted git repository. gnutt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit a2f6dc9b7ca3312eeecda2639122b0c158d7778c Author: Xiang Xiao <xiaoxi...@xiaomi.com> AuthorDate: Sun May 3 20:02:48 2020 +0800 errno: Rename get_errno_ptr to __errno Inrease the compatiblity with the third party library(e.g. newlib) Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com> --- Documentation/NuttxUserGuide.html | 8 +++---- .../lpc17xx_40xx/pnev5180b/src/lpc17_40_symtab.c | 9 +++++--- include/errno.h | 4 ++-- libs/libc/libc.csv | 2 +- sched/errno/Make.defs | 2 +- sched/errno/{errno_getptr.c => errno_errno.c} | 25 ++++++++-------------- sched/errno/errno_get.c | 4 +--- sched/errno/errno_set.c | 6 ++---- sched/task/task_exit.c | 2 +- syscall/syscall.csv | 1 - 10 files changed, 27 insertions(+), 36 deletions(-) diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html index 27604c4..701398f 100644 --- a/Documentation/NuttxUserGuide.html +++ b/Documentation/NuttxUserGuide.html @@ -10299,13 +10299,13 @@ OS resources. These hidden structures include: <p> <ul><pre> #include <errno.h> -#define errno *get_errno_ptr() -int *get_errno_ptr(void); +#define errno *__errno() +int *__errno(void); </pre></ul> <p> <b>Description</b>: - <code>get_errno_ptr()</code> returns a pointer to the thread-specific <code>errno</code> value. - Note that the symbol <code>errno</code> is defined to be <code>get_errno_ptr()</code> so that the usual + <code>__errno()</code> returns a pointer to the thread-specific <code>errno</code> value. + Note that the symbol <code>errno</code> is defined to be <code>__errno()</code> so that the usual access by referencing the symbol <code>errno</code> will work as expected. </p> <p> diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_symtab.c b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_symtab.c index af5ddc9..db3a341 100644 --- a/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_symtab.c +++ b/boards/arm/lpc17xx_40xx/pnev5180b/src/lpc17_40_symtab.c @@ -48,7 +48,6 @@ extern void *exit; extern void *fflush; extern void *fopen; extern void *fprintf; -extern void *get_errno_ptr; extern void *getpid; extern void *kill; extern void *memset; @@ -80,7 +79,6 @@ const struct symtab_s lpc17_40_exports[] = {"fflush", &fflush}, {"fopen", &fopen}, {"fprintf", &fprintf}, - {"get_errno_ptr", &get_errno_ptr}, {"getpid", &getpid}, {"kill", &kill}, {"memset", &memset}, @@ -107,4 +105,9 @@ const struct symtab_s lpc17_40_exports[] = {"usleep", &usleep}, }; -const int lpc17_40_nexports = sizeof(lpc17_40_exports) / sizeof(struct symtab_s); +const int lpc17_40_nexports = + sizeof(lpc17_40_exports) / sizeof(struct symtab_s); + +/***************************************************************************** + * Public Functions + *****************************************************************************/ diff --git a/include/errno.h b/include/errno.h index 8bd8bcf..76a1bc4 100644 --- a/include/errno.h +++ b/include/errno.h @@ -91,7 +91,7 @@ #ifdef __DIRECT_ERRNO_ACCESS -# define errno *get_errno_ptr() +# define errno *__errno() # define set_errno(e) do { errno = (int)(e); } while (0) # define get_errno() errno @@ -406,7 +406,7 @@ extern "C" * either as macros or via syscalls. */ -FAR int *get_errno_ptr(void); +FAR int *__errno(void); #ifndef __DIRECT_ERRNO_ACCESS void set_errno(int errcode); diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv index a979851..2eafa1e 100644 --- a/libs/libc/libc.csv +++ b/libs/libc/libc.csv @@ -1,3 +1,4 @@ +"__errno","errno.h","defined(CONFIG_BUILD_FLAT)","FAR int *" "abort","stdlib.h","","void" "abs","stdlib.h","","int","int" "aio_error","aio.h","defined(CONFIG_FS_AIO)","int","FAR struct aiocb *" @@ -47,7 +48,6 @@ "fsetpos","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR fpos_t *" "ftell","stdio.h","CONFIG_NFILE_STREAMS > 0","long","FAR FILE *" "fwrite","stdio.h","CONFIG_NFILE_STREAMS > 0","size_t","FAR const void *","size_t","size_t","FAR FILE *" -"get_errno_ptr","errno.h","defined(CONFIG_BUILD_FLAT)","FAR int *" "getcwd","unistd.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char","FAR char *","size_t" "gethostname","unistd.h","","int","FAR char*","size_t" "getopt","unistd.h","","int","int","FAR char *const[]","FAR const char *" diff --git a/sched/errno/Make.defs b/sched/errno/Make.defs index d233b11..6c51ee2 100644 --- a/sched/errno/Make.defs +++ b/sched/errno/Make.defs @@ -33,7 +33,7 @@ # ############################################################################ -CSRCS += errno_getptr.c +CSRCS += errno_errno.c ifeq ($(CONFIG_LIB_SYSCALL),y) CSRCS += errno_get.c errno_set.c diff --git a/sched/errno/errno_getptr.c b/sched/errno/errno_errno.c similarity index 86% rename from sched/errno/errno_getptr.c rename to sched/errno/errno_errno.c index 537fdb9..a262b5b 100644 --- a/sched/errno/errno_getptr.c +++ b/sched/errno/errno_errno.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/errno/errno_getptr.c + * sched/errno/errno_errno.c * * Copyright (C) 2007, 2008, 2011, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gn...@nuttx.org> @@ -44,18 +44,11 @@ #include "sched/sched.h" /**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#undef get_errno_ptr -#undef errno - -/**************************************************************************** * Private Data ****************************************************************************/ /* This is a 'dummy' errno value to use in context where there is no valid - * errno location to use. For example, when running from an interrupt handler + * errno location to use. For example, when running from an interrupt handler * or early in initialization when task structures have not yet been * initialized. */ @@ -67,7 +60,7 @@ static int g_irqerrno; ****************************************************************************/ /**************************************************************************** - * Name: get_errno_ptr + * Name: __errno * * Description: * Return a pointer to the thread specific errno. @@ -82,7 +75,7 @@ static int g_irqerrno; * ****************************************************************************/ -FAR int *get_errno_ptr(void) +FAR int *__errno(void) { /* Check if this function was called from an interrupt handler. In that * case, we have to do things a little differently to prevent the interrupt @@ -113,12 +106,12 @@ FAR int *get_errno_ptr(void) } /* We were called either from (1) an interrupt handler or (2) from normally - * code but in an unhealthy state. In either event, do not permit access to + * code but in an unhealthy state. In either event, do not permit access to * the errno in the TCB of the task at the head of the ready-to-run list. - * Instead, use a separate errno just for interrupt handlers. Of course, this - * would have to change if we ever wanted to support nested interrupts or if - * we really cared about the stability of the errno during those "unhealthy - * states." + * Instead, use a separate errno just for interrupt handlers. Of course, + * this would have to change if we ever wanted to support nested interrupts + * or if we really cared about the stability of the errno during those + * "unhealthy states." */ return &g_irqerrno; diff --git a/sched/errno/errno_get.c b/sched/errno/errno_get.c index be5c30b..2d91497 100644 --- a/sched/errno/errno_get.c +++ b/sched/errno/errno_get.c @@ -45,9 +45,7 @@ * Pre-processor Definitions ****************************************************************************/ -#undef get_errno_ptr #undef get_errno -#undef errno /**************************************************************************** * Public Functions @@ -74,5 +72,5 @@ int get_errno(void) { - return *get_errno_ptr(); + return *__errno(); } diff --git a/sched/errno/errno_set.c b/sched/errno/errno_set.c index 7a6f1eb..2eada24 100644 --- a/sched/errno/errno_set.c +++ b/sched/errno/errno_set.c @@ -45,9 +45,7 @@ * Pre-processor Definitions ****************************************************************************/ -#undef get_errno_ptr #undef set_errno -#undef errno /**************************************************************************** * Public Functions @@ -62,7 +60,7 @@ * thread-specific errno value. * * Input Parameters: - * errcode - The thread specific errno will be set to this error code value. + * errcode - The thread specific errno will be set to this value. * * Returned Value: * None @@ -73,5 +71,5 @@ void set_errno(int errcode) { - *get_errno_ptr() = errcode; + *__errno() = errcode; } diff --git a/sched/task/task_exit.c b/sched/task/task_exit.c index 78af294..8311dd9 100644 --- a/sched/task/task_exit.c +++ b/sched/task/task_exit.c @@ -129,7 +129,7 @@ int nxtask_exit(void) /* We are now in a bad state -- the head of the ready to run task list * does not correspond to the thread that is running. Disabling pre- * emption on this TCB and marking the new ready-to-run task as not - * running (see, for example, get_errno_ptr()). + * running. * * We disable pre-emption here by directly incrementing the lockcount * (vs. calling sched_lock()). diff --git a/syscall/syscall.csv b/syscall/syscall.csv index b539e72..a7e4a1c 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -30,7 +30,6 @@ "fsync","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int" "ftruncate","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int","off_t" "get_errno","errno.h","!defined(__DIRECT_ERRNO_ACCESS)","int" -"get_errno_ptr","errno.h","defined(__DIRECT_ERRNO_ACCESS)","FAR int*" "getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char*","FAR const char*" "getgid","unistd.h","defined(CONFIG_SCHED_USER_IDENTITY)","gid_t" "getitimer","sys/time.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","int","int","FAR struct itimerval *"