ReactOS 0.4.16-dev-822-gbcedb53
errno.cpp File Reference
#include <corecrt_internal.h>
#include <corecrt_internal_ptd_propagation.h>
#include <errno.h>
Include dependency graph for errno.cpp:

Go to the source code of this file.

Classes

struct  anonymous_namespace{errno.cpp}::errentry
 

Namespaces

namespace  anonymous_namespace{errno.cpp}
 

Macros

#define _ALLOW_OLD_VALIDATE_MACROS
 
#define ERRTABLECOUNT   (sizeof(errtable) / sizeof(errtable[0]))
 
#define MIN_EXEC_ERROR   ERROR_INVALID_STARTING_CODESEG
 
#define MAX_EXEC_ERROR   ERROR_INFLOOP_IN_RELOC_CHAIN
 
#define MIN_EACCES_RANGE   ERROR_WRITE_PROTECT
 
#define MAX_EACCES_RANGE   ERROR_SHARING_BUFFER_EXCEEDED
 

Functions

void __cdecl __acrt_errno_map_os_error (unsigned long const oserrno)
 
void __cdecl __acrt_errno_map_os_error_ptd (unsigned long const oserrno, __crt_cached_ptd_host &ptd)
 
int __cdecl __acrt_errno_from_os_error (unsigned long const oserrno)
 
errno_t _set_errno (int const value)
 
errno_t _get_errno (int *const result)
 
errno_t _set_doserrno (unsigned long const value)
 
errno_t _get_doserrno (unsigned long *const result)
 
int *__cdecl _errno ()
 
unsigned long *__cdecl __doserrno ()
 

Variables

static errentry const errtable []
 
static int errno_no_memory {ENOMEM}
 
static unsigned long doserrno_no_memory {ERROR_NOT_ENOUGH_MEMORY}
 

Macro Definition Documentation

◆ _ALLOW_OLD_VALIDATE_MACROS

#define _ALLOW_OLD_VALIDATE_MACROS

Definition at line 8 of file errno.cpp.

◆ ERRTABLECOUNT

#define ERRTABLECOUNT   (sizeof(errtable) / sizeof(errtable[0]))

Definition at line 76 of file errno.cpp.

◆ MAX_EACCES_RANGE

#define MAX_EACCES_RANGE   ERROR_SHARING_BUFFER_EXCEEDED

Definition at line 86 of file errno.cpp.

◆ MAX_EXEC_ERROR

#define MAX_EXEC_ERROR   ERROR_INFLOOP_IN_RELOC_CHAIN

Definition at line 81 of file errno.cpp.

◆ MIN_EACCES_RANGE

#define MIN_EACCES_RANGE   ERROR_WRITE_PROTECT

Definition at line 85 of file errno.cpp.

◆ MIN_EXEC_ERROR

#define MIN_EXEC_ERROR   ERROR_INVALID_STARTING_CODESEG

Definition at line 80 of file errno.cpp.

Function Documentation

◆ __acrt_errno_from_os_error()

int __cdecl __acrt_errno_from_os_error ( unsigned long const  oserrno)

Definition at line 103 of file errno.cpp.

104{
105 // Check the table for the OS error code
106 for (unsigned i{0}; i < ERRTABLECOUNT; ++i)
107 {
108 if (oserrno == errtable[i].oscode)
109 return errtable[i].errnocode;
110 }
111
112 // The error code wasn't in the table. We check for a range of
113 // EACCES errors or exec failure errors (ENOEXEC). Otherwise
114 // EINVAL is returned.
115 if (oserrno >= MIN_EACCES_RANGE && oserrno <= MAX_EACCES_RANGE)
116 {
117 return EACCES;
118 }
119 else if (oserrno >= MIN_EXEC_ERROR && oserrno <= MAX_EXEC_ERROR)
120 {
121 return ENOEXEC;
122 }
123 else
124 {
125 return EINVAL;
126 }
127}
#define EINVAL
Definition: acclib.h:90
#define EACCES
Definition: acclib.h:85
#define ENOEXEC
Definition: errno.h:14
#define ERRTABLECOUNT
Definition: errno.cpp:76
#define MAX_EXEC_ERROR
Definition: errno.cpp:81
#define MIN_EACCES_RANGE
Definition: errno.cpp:85
static errentry const errtable[]
Definition: errno.cpp:27
#define MIN_EXEC_ERROR
Definition: errno.cpp:80
#define MAX_EACCES_RANGE
Definition: errno.cpp:86
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by __acrt_errno_map_os_error(), __acrt_errno_map_os_error_ptd(), and _getdiskfree().

◆ __acrt_errno_map_os_error()

◆ __acrt_errno_map_os_error_ptd()

void __cdecl __acrt_errno_map_os_error_ptd ( unsigned long const  oserrno,
__crt_cached_ptd_host &  ptd 
)

Definition at line 97 of file errno.cpp.

98{
99 ptd.get_doserrno().set(oserrno);
100 ptd.get_errno().set(__acrt_errno_from_os_error(oserrno));
101}
_In_ size_t const _In_ int _In_ bool const _In_ unsigned const _In_ __acrt_rounding_mode const _Inout_ __crt_cached_ptd_host & ptd
Definition: cvt.cpp:355

Referenced by _close_nolock_internal(), _dup2_nolock_internal(), _write_nolock(), common_lseek_do_seek_nolock(), and duplicate_osfhnd().

◆ __doserrno()

unsigned long *__cdecl __doserrno ( void  )

Definition at line 191 of file errno.cpp.

192{
194 if (!ptd)
195 {
196 return &doserrno_no_memory;
197 }
198
199 return &ptd->_tdoserrno;
200}
__acrt_ptd *__cdecl __acrt_getptd_noexit(void)
static unsigned long doserrno_no_memory
Definition: errno.cpp:178

Referenced by _cwait(), and msvcrt_init_fp().

◆ _errno()

◆ _get_doserrno()

errno_t _get_doserrno ( unsigned long *const  result)

Definition at line 164 of file errno.cpp.

165{
167
168 // Unlike most of our globals, this one is guaranteed to give some answer:
169 *result = _doserrno;
170 return 0;
171}
GLuint64EXT * result
Definition: glext.h:11304
#define _VALIDATE_RETURN_NOERRNO(expr, retexpr)

◆ _get_errno()

errno_t _get_errno ( int *const  result)

Definition at line 142 of file errno.cpp.

143{
145
146 // Unlike most of our globals, this one is guaranteed to give some answer
147 *result = errno;
148 return 0;
149}

◆ _set_doserrno()

errno_t _set_doserrno ( unsigned long const  value)

Definition at line 154 of file errno.cpp.

155{
157 if (!ptd)
158 return ENOMEM;
159
161 return 0;
162}
#define ENOMEM
Definition: acclib.h:84
Definition: pdh_main.c:94

◆ _set_errno()

errno_t _set_errno ( int const  value)

Definition at line 132 of file errno.cpp.

133{
135 if (!ptd)
136 return ENOMEM;
137
138 errno = value;
139 return 0;
140}

Variable Documentation

◆ doserrno_no_memory

unsigned long doserrno_no_memory {ERROR_NOT_ENOUGH_MEMORY}
static

Definition at line 178 of file errno.cpp.

Referenced by __doserrno().

◆ errno_no_memory

int errno_no_memory {ENOMEM}
static

Definition at line 177 of file errno.cpp.

Referenced by _errno().

◆ errtable

errentry const errtable[]
static

Definition at line 26 of file errno.cpp.

Referenced by __acrt_errno_from_os_error().