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
+4 -4
View File
@@ -10299,13 +10299,13 @@ OS resources. These hidden structures include:
<p> <p>
<ul><pre> <ul><pre>
#include &lt;errno.h&gt; #include &lt;errno.h&gt;
#define errno *get_errno_ptr() #define errno *__errno()
int *get_errno_ptr(void); int *__errno(void);
</pre></ul> </pre></ul>
<p> <p>
<b>Description</b>: <b>Description</b>:
<code>get_errno_ptr()</code> returns a pointer to the thread-specific <code>errno</code> value. <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>get_errno_ptr()</code> so that the usual 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. access by referencing the symbol <code>errno</code> will work as expected.
</p> </p>
<p> <p>
@@ -48,7 +48,6 @@ extern void *exit;
extern void *fflush; extern void *fflush;
extern void *fopen; extern void *fopen;
extern void *fprintf; extern void *fprintf;
extern void *get_errno_ptr;
extern void *getpid; extern void *getpid;
extern void *kill; extern void *kill;
extern void *memset; extern void *memset;
@@ -80,7 +79,6 @@ const struct symtab_s lpc17_40_exports[] =
{"fflush", &fflush}, {"fflush", &fflush},
{"fopen", &fopen}, {"fopen", &fopen},
{"fprintf", &fprintf}, {"fprintf", &fprintf},
{"get_errno_ptr", &get_errno_ptr},
{"getpid", &getpid}, {"getpid", &getpid},
{"kill", &kill}, {"kill", &kill},
{"memset", &memset}, {"memset", &memset},
@@ -107,4 +105,9 @@ const struct symtab_s lpc17_40_exports[] =
{"usleep", &usleep}, {"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
*****************************************************************************/
+2 -2
View File
@@ -91,7 +91,7 @@
#ifdef __DIRECT_ERRNO_ACCESS #ifdef __DIRECT_ERRNO_ACCESS
# define errno *get_errno_ptr() # define errno *__errno()
# define set_errno(e) do { errno = (int)(e); } while (0) # define set_errno(e) do { errno = (int)(e); } while (0)
# define get_errno() errno # define get_errno() errno
@@ -406,7 +406,7 @@ extern "C"
* either as macros or via syscalls. * either as macros or via syscalls.
*/ */
FAR int *get_errno_ptr(void); FAR int *__errno(void);
#ifndef __DIRECT_ERRNO_ACCESS #ifndef __DIRECT_ERRNO_ACCESS
void set_errno(int errcode); void set_errno(int errcode);
+1 -1
View File
@@ -1,3 +1,4 @@
"__errno","errno.h","defined(CONFIG_BUILD_FLAT)","FAR int *"
"abort","stdlib.h","","void" "abort","stdlib.h","","void"
"abs","stdlib.h","","int","int" "abs","stdlib.h","","int","int"
"aio_error","aio.h","defined(CONFIG_FS_AIO)","int","FAR struct aiocb *" "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 *" "fsetpos","stdio.h","CONFIG_NFILE_STREAMS > 0","int","FAR FILE *","FAR fpos_t *"
"ftell","stdio.h","CONFIG_NFILE_STREAMS > 0","long","FAR FILE *" "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 *" "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" "getcwd","unistd.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char","FAR char *","size_t"
"gethostname","unistd.h","","int","FAR char*","size_t" "gethostname","unistd.h","","int","FAR char*","size_t"
"getopt","unistd.h","","int","int","FAR char *const[]","FAR const char *" "getopt","unistd.h","","int","int","FAR char *const[]","FAR const char *"
1 abort __errno stdlib.h errno.h defined(CONFIG_BUILD_FLAT) void FAR int *
1 __errno errno.h defined(CONFIG_BUILD_FLAT) FAR int *
2 abort abort stdlib.h stdlib.h void void
3 abs abs stdlib.h stdlib.h int int
4 aio_error aio_error aio.h aio.h defined(CONFIG_FS_AIO) defined(CONFIG_FS_AIO) int int
48 fsetpos fsetpos stdio.h stdio.h CONFIG_NFILE_STREAMS > 0 CONFIG_NFILE_STREAMS > 0 int int
49 ftell ftell stdio.h stdio.h CONFIG_NFILE_STREAMS > 0 CONFIG_NFILE_STREAMS > 0 long long
50 fwrite fwrite stdio.h stdio.h CONFIG_NFILE_STREAMS > 0 CONFIG_NFILE_STREAMS > 0 size_t size_t
get_errno_ptr errno.h defined(CONFIG_BUILD_FLAT) FAR int *
51 getcwd getcwd unistd.h unistd.h !defined(CONFIG_DISABLE_ENVIRON) !defined(CONFIG_DISABLE_ENVIRON) FAR char FAR char
52 gethostname gethostname unistd.h unistd.h int int
53 getopt getopt unistd.h unistd.h int int
+1 -1
View File
@@ -33,7 +33,7 @@
# #
############################################################################ ############################################################################
CSRCS += errno_getptr.c CSRCS += errno_errno.c
ifeq ($(CONFIG_LIB_SYSCALL),y) ifeq ($(CONFIG_LIB_SYSCALL),y)
CSRCS += errno_get.c errno_set.c CSRCS += errno_get.c errno_set.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. * Copyright (C) 2007, 2008, 2011, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
@@ -43,19 +43,12 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#undef get_errno_ptr
#undef errno
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
/* This is a 'dummy' errno value to use in context where there is no valid /* 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 * or early in initialization when task structures have not yet been
* initialized. * initialized.
*/ */
@@ -67,7 +60,7 @@ static int g_irqerrno;
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: get_errno_ptr * Name: __errno
* *
* Description: * Description:
* Return a pointer to the thread specific errno. * 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 /* 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 * 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 /* 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. * 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 * Instead, use a separate errno just for interrupt handlers. Of course,
* would have to change if we ever wanted to support nested interrupts or if * this would have to change if we ever wanted to support nested interrupts
* we really cared about the stability of the errno during those "unhealthy * or if we really cared about the stability of the errno during those
* states." * "unhealthy states."
*/ */
return &g_irqerrno; return &g_irqerrno;
+1 -3
View File
@@ -45,9 +45,7 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#undef get_errno_ptr
#undef get_errno #undef get_errno
#undef errno
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -74,5 +72,5 @@
int get_errno(void) int get_errno(void)
{ {
return *get_errno_ptr(); return *__errno();
} }
+2 -4
View File
@@ -45,9 +45,7 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#undef get_errno_ptr
#undef set_errno #undef set_errno
#undef errno
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -62,7 +60,7 @@
* thread-specific errno value. * thread-specific errno value.
* *
* Input Parameters: * 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: * Returned Value:
* None * None
@@ -73,5 +71,5 @@
void set_errno(int errcode) void set_errno(int errcode)
{ {
*get_errno_ptr() = errcode; *__errno() = errcode;
} }
+1 -1
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 /* 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- * 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 * 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 * We disable pre-emption here by directly incrementing the lockcount
* (vs. calling sched_lock()). * (vs. calling sched_lock()).
-1
View File
@@ -30,7 +30,6 @@
"fsync","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int" "fsync","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int"
"ftruncate","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int","off_t" "ftruncate","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","int","off_t"
"get_errno","errno.h","!defined(__DIRECT_ERRNO_ACCESS)","int" "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*" "getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char*","FAR const char*"
"getgid","unistd.h","defined(CONFIG_SCHED_USER_IDENTITY)","gid_t" "getgid","unistd.h","defined(CONFIG_SCHED_USER_IDENTITY)","gid_t"
"getitimer","sys/time.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","int","int","FAR struct itimerval *" "getitimer","sys/time.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","int","int","FAR struct itimerval *"
1 _exit unistd.h void int
30 fsync unistd.h !defined(CONFIG_DISABLE_MOUNTPOINT) int int
31 ftruncate unistd.h !defined(CONFIG_DISABLE_MOUNTPOINT) int int
32 get_errno errno.h !defined(__DIRECT_ERRNO_ACCESS) int
get_errno_ptr errno.h defined(__DIRECT_ERRNO_ACCESS) FAR int*
33 getenv stdlib.h !defined(CONFIG_DISABLE_ENVIRON) FAR char* FAR const char*
34 getgid unistd.h defined(CONFIG_SCHED_USER_IDENTITY) gid_t
35 getitimer sys/time.h !defined(CONFIG_DISABLE_POSIX_TIMERS) int int