errno: Rename get_errno_ptr to __errno

Inrease the compatiblity with the third party library(e.g. newlib)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2020-05-03 20:02:48 +08:00 committed by patacongo
parent 5c748cea2a
commit a2f6dc9b7c
10 changed files with 27 additions and 36 deletions

View file

@ -10299,13 +10299,13 @@ OS resources. These hidden structures include:
<p>
<ul><pre>
#include &lt;errno.h&gt;
#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>

View file

@ -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
*****************************************************************************/

View file

@ -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);

View file

@ -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 *"

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -33,7 +33,7 @@
#
############################################################################
CSRCS += errno_getptr.c
CSRCS += errno_errno.c
ifeq ($(CONFIG_LIB_SYSCALL),y)
CSRCS += errno_get.c errno_set.c

View file

@ -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 <gnutt@nuttx.org>
@ -43,19 +43,12 @@
#include <nuttx/arch.h>
#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;

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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()).

View file

@ -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 *"

Can't render this file because it has a wrong number of fields in line 2.