25#define LELY_UTIL_ERRNUM_INLINE extern inline
36#define ERRSTR_SIZE 256
41#if _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
42static const char *gai_strerror_r(
int ecode,
char *strerrbuf,
size_t buflen);
227#ifdef ENOTRECOVERABLE
242#if defined(EOPNOTSUPP) && EOPNOTSUPP != ENOTSUP
260#ifdef EPROTONOSUPPORT
288#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
304 return errc > 0 ? errc : 0;
331 case ERROR_BEGINNING_OF_MEDIA:
return ERRNUM_IO;
345 case ERROR_CANT_RESOLVE_FILENAME:
return ERRNUM_LOOP;
353 case ERROR_DEVICE_DOOR_OPEN:
return ERRNUM_IO;
356 case ERROR_DEVICE_REQUIRES_CLEANING:
return ERRNUM_IO;
362 case ERROR_DISK_CORRUPT:
return ERRNUM_IO;
365 case ERROR_DS_GENERIC_ERROR:
return ERRNUM_IO;
370#ifdef ERROR_ELEVATION_REQUIRED
374 case ERROR_EOM_OVERFLOW:
return ERRNUM_IO;
381 case ERROR_FILEMARK_DETECTED:
return ERRNUM_IO;
385#ifdef ERROR_FLOAT_MULTIPLE_FAULTS
386 case ERROR_FLOAT_MULTIPLE_FAULTS:
return ERRNUM_DOM;
388 case ERROR_GEN_FAILURE:
return ERRNUM_IO;
392#ifdef ERROR_ILLEGAL_CHARACTER
398 case ERROR_INVALID_AT_INTERRUPT_TIME:
return ERRNUM_INTR;
400 case ERROR_INVALID_BLOCK_LENGTH:
return ERRNUM_IO;
427 case ERROR_META_EXPANSION_TOO_LONG:
return ERRNUM_INVAL;
439 case ERROR_NONPAGED_SYSTEM_RESOURCES:
return ERRNUM_AGAIN;
443 case ERROR_NOT_ENOUGH_QUOTA:
return ERRNUM_IO;
450 case ERROR_NO_DATA_DETECTED:
return ERRNUM_IO;
455 case ERROR_NO_SIGNAL_SENT:
return ERRNUM_IO;
456 case ERROR_NO_SYSTEM_RESOURCES:
return ERRNUM_FBIG;
459 case ERROR_OPEN_FAILED:
return ERRNUM_IO;
481 case ERROR_SERVICE_REQUEST_TIMEOUT:
return ERRNUM_BUSY;
482 case ERROR_SETMARK_DETECTED:
return ERRNUM_IO;
483 case ERROR_SHARING_BUFFER_EXCEEDED:
return ERRNUM_NOLCK;
487 case ERROR_SIGNAL_REFUSED:
return ERRNUM_IO;
488#ifdef ERROR_SYMLINK_NOT_SUPPORTED
496 case ERROR_UNEXP_NET_ERR:
return ERRNUM_IO;
499 case ERROR_WRITE_FAULT:
return ERRNUM_IO;
548#if _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
738#ifdef ENOTRECOVERABLE
771#ifdef EPROTONOSUPPORT
831#ifdef ERROR_FLOAT_MULTIPLE_FAULTS
832 case ERRNUM_DOM:
return ERROR_FLOAT_MULTIPLE_FAULTS;
837 case ERRNUM_FBIG:
return ERROR_NO_SYSTEM_RESOURCES;
841#ifdef ERROR_ILLEGAL_CHARACTER
851 case ERRNUM_LOOP:
return ERROR_CANT_RESOLVE_FILENAME;
913#if _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
935 return GetLastError();
960 strerror_s(strerrbuf, buflen,
errnum);
963#elif _POSIX_C_SOURCE >= 200112L
966 return strerror_r(
errnum, strerrbuf, buflen);
968 int errc = strerror_r(
errnum, strerrbuf, buflen);
977 if (buflen && !memccpy(strerrbuf, strerror(
errnum),
'\0',
980 strerrbuf[buflen - 1] =
'\0';
992 static char errstr[ERRSTR_SIZE];
998 buflen =
sizeof(errstr);
1002 if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM
1003 | FORMAT_MESSAGE_IGNORE_INSERTS,
1004 NULL, errc, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
1005 strerrbuf, buflen, NULL))
1009 size_t n = strlen(strerrbuf);
1011 strerrbuf[n - 2] =
'\0';
1014#if _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
1016 case -
ABS(EAI_AGAIN):
1017 return gai_strerror_r(EAI_AGAIN, strerrbuf, buflen);
1018 case -
ABS(EAI_BADFLAGS):
1019 return gai_strerror_r(EAI_BADFLAGS, strerrbuf, buflen);
1020 case -
ABS(EAI_FAIL):
return gai_strerror_r(EAI_FAIL, strerrbuf, buflen);
1021 case -
ABS(EAI_FAMILY):
1022 return gai_strerror_r(EAI_FAMILY, strerrbuf, buflen);
1023 case -
ABS(EAI_MEMORY):
1024 return gai_strerror_r(EAI_MEMORY, strerrbuf, buflen);
1025 case -
ABS(EAI_NONAME):
1026 return gai_strerror_r(EAI_NONAME, strerrbuf, buflen);
1027 case -
ABS(EAI_OVERFLOW):
1028 return gai_strerror_r(EAI_OVERFLOW, strerrbuf, buflen);
1029 case -
ABS(EAI_SERVICE):
1030 return gai_strerror_r(EAI_SERVICE, strerrbuf, buflen);
1031 case -
ABS(EAI_SOCKTYPE):
1032 return gai_strerror_r(EAI_SOCKTYPE, strerrbuf, buflen);
1039#if _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
1041gai_strerror_r(
int ecode,
char *strerrbuf,
size_t buflen)
1045 if (buflen && !memccpy(strerrbuf, gai_strerror(ecode),
'\0',
1048 strerrbuf[buflen - 1] =
'\0';
1051 return gai_strerror(ecode);
errnum_t errno2num(int errnum)
Transforms a standard C error number to a platform-independent error number.
errnum_t errc2num(int errc)
Transforms a native error code to a platform-independent error number.
int errnum2c(errnum_t errnum)
Transforms a platform-independent error number to a native error code.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errc2no(int errc)
Transforms a native error code to a standard C error number.
const char * errc2str_r(int errc, char *strerrbuf, size_t buflen)
Returns a string describing a native error code.
int errnum2no(errnum_t errnum)
Transforms a platform-independent error number to a standard C error number.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
const char * errno2str_r(int errnum, char *strerrbuf, size_t buflen)
Returns a string describing a standard C error number.
This header file is part of the utilities library; it contains the native and platform-independent er...
errnum
The platform-independent error numbers.
@ ERRNUM_NOSPC
No space left on device.
@ ERRNUM_AI_MEMORY
There was a memory allocation failure.
@ ERRNUM_NOSYS
Function not supported.
@ ERRNUM_WOULDBLOCK
Operation would block.
@ ERRNUM_OWNERDEAD
Previous owner died.
@ ERRNUM_PROTO
Protocol error.
@ ERRNUM_BADMSG
Bad message.
@ ERRNUM_AFNOSUPPORT
Address family not supported.
@ ERRNUM_NOTCONN
The socket is not connected.
@ ERRNUM_NXIO
No such device or address.
@ ERRNUM_IDRM
Identifier removed.
@ ERRNUM_AI_BADFLAGS
The flags had an invalid value.
@ ERRNUM_RANGE
Result too large.
@ ERRNUM_MSGSIZE
Message too large.
@ ERRNUM_INTR
Interrupted function.
@ ERRNUM_SPIPE
Invalid seek.
@ ERRNUM_ALREADY
Connection already in progress.
@ ERRNUM_NOPROTOOPT
Protocol not available.
@ ERRNUM_BUSY
Device or resource busy.
@ ERRNUM_ISCONN
Socket is connected.
@ ERRNUM_NETDOWN
Network is down.
@ ERRNUM_SRCH
No such process.
@ ERRNUM_MLINK
Too many links.
@ ERRNUM_TIMEDOUT
Connection timed out.
@ ERRNUM_NOENT
No such file or directory.
@ ERRNUM_NFILE
Too many files open in system.
@ ERRNUM_AI_SOCKTYPE
The intended socket type was not recognized.
@ ERRNUM_BADF
Bad file descriptor.
@ ERRNUM_OPNOTSUPP
Operation not supported on socket.
@ ERRNUM_NOTTY
Inappropriate I/O control operation.
@ ERRNUM_PERM
Operation not permitted.
@ ERRNUM_PROTONOSUPPORT
Protocol not supported.
@ ERRNUM_NOMEM
Not enough space.
@ ERRNUM_TIME
Stream ioctl() timeout.
@ ERRNUM_FBIG
File too large.
@ ERRNUM_2BIG
Argument list too long.
@ ERRNUM_NOEXEC
Executable file format error.
@ ERRNUM_NOTSUP
Not supported.
@ ERRNUM_CHILD
No child process.
@ ERRNUM_NOTSOCK
Not a socket.
@ ERRNUM_NOTDIR
Not a directory or a symbolic link to a directory.
@ ERRNUM_MFILE
File descriptor value too large.
@ ERRNUM_ACCES
Permission denied.
@ ERRNUM_ADDRNOTAVAIL
Address not available.
@ ERRNUM_INVAL
Invalid argument.
@ ERRNUM_AI_AGAIN
The name could not be resolved at this time.
@ ERRNUM_CONNABORTED
Connection aborted.
@ ERRNUM_NOTEMPTY
Directory not empty.
@ ERRNUM_AI_FAIL
A non-recoverable error occurred.
@ ERRNUM_PROTOTYPE
Protocol wrong type for socket.
@ ERRNUM_ADDRINUSE
Address in use.
@ ERRNUM_NOMSG
No message of the desired type.
@ ERRNUM_AGAIN
Resource unavailable, try again.
@ ERRNUM_ROFS
Read-only file system.
@ ERRNUM_NOBUFS
No buffer space available.
@ ERRNUM_CONNREFUSED
Connection refused.
@ ERRNUM_DOM
Mathematics argument out of domain of function.
@ ERRNUM_NETRESET
Connection aborted by network.
@ ERRNUM_HOSTUNREACH
Host is unreachable.
@ ERRNUM_DEADLK
Resource deadlock would occur.
@ ERRNUM_EXIST
File exists.
@ ERRNUM_NODATA
No message is available on the STREAM head read queue.
@ ERRNUM_ISDIR
Is a directory.
@ ERRNUM_OVERFLOW
Value too large to be stored in data type.
@ ERRNUM_AI_OVERFLOW
An argument buffer overflowed.
@ ERRNUM_PIPE
Broken pipe.
@ ERRNUM_TXTBSY
Text file busy.
@ ERRNUM_AI_FAMILY
The address family was not recognized or the address length was invalid for the specified family.
@ ERRNUM_NOSR
No STREAM resources.
@ ERRNUM_NOSTR
Not a STREAM.
@ ERRNUM_ILSEQ
Illegal byte sequence.
@ ERRNUM_CONNRESET
Connection reset.
@ ERRNUM_INPROGRESS
Operation in progress.
@ ERRNUM_AI_SERVICE
The service passed was not recognized for the specified socket type.
@ ERRNUM_NODEV
No such device.
@ ERRNUM_FAULT
Bad address.
@ ERRNUM_LOOP
Too many levels of symbolic links.
@ ERRNUM_NETUNREACH
Network unreachable.
@ ERRNUM_AI_NONAME
The name does not resolve for the supplied parameters.
@ ERRNUM_XDEV
Cross-device link.
@ ERRNUM_DESTADDRREQ
Destination address required.
@ ERRNUM_NAMETOOLONG
Filename too long.
@ ERRNUM_CANCELED
Operation canceled.
@ ERRNUM_NOTRECOVERABLE
State not recoverable.
@ ERRNUM_NOLCK
No locks available.
enum errnum errnum_t
The platform-independent error number type.
#define _Thread_local
An object whose identifier is declared with the storage-class specifier _Thread_local has thread stor...
This is the public header file of the utilities library.
#define ABS(a)
Returns the absolute value of a.
This is the internal header file of the utilities library.
This header file is part of the C11 and POSIX compatibility library; it includes <string....