25 #define LELY_UTIL_ERRNUM_INLINE extern inline
36 #define ERRSTR_SIZE 256
228 #ifdef ENOTRECOVERABLE
243 #if defined(EOPNOTSUPP) && EOPNOTSUPP != ENOTSUP
261 #ifdef EPROTONOSUPPORT
289 #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
305 return errc > 0 ? errc : 0;
332 case ERROR_BEGINNING_OF_MEDIA:
return ERRNUM_IO;
347 case ERROR_CANT_RESOLVE_FILENAME:
return ERRNUM_LOOP;
355 case ERROR_DEVICE_DOOR_OPEN:
return ERRNUM_IO;
358 case ERROR_DEVICE_REQUIRES_CLEANING:
return ERRNUM_IO;
365 case ERROR_DISK_CORRUPT:
return ERRNUM_IO;
368 case ERROR_DS_GENERIC_ERROR:
return ERRNUM_IO;
373 #ifdef ERROR_ELEVATION_REQUIRED
377 case ERROR_EOM_OVERFLOW:
return ERRNUM_IO;
384 case ERROR_FILEMARK_DETECTED:
return ERRNUM_IO;
388 #ifdef ERROR_FLOAT_MULTIPLE_FAULTS
389 case ERROR_FLOAT_MULTIPLE_FAULTS:
return ERRNUM_DOM;
391 case ERROR_GEN_FAILURE:
return ERRNUM_IO;
395 #ifdef ERROR_ILLEGAL_CHARACTER
401 case ERROR_INVALID_AT_INTERRUPT_TIME:
return ERRNUM_INTR;
403 case ERROR_INVALID_BLOCK_LENGTH:
return ERRNUM_IO;
432 case ERROR_META_EXPANSION_TOO_LONG:
return ERRNUM_INVAL;
445 case ERROR_NONPAGED_SYSTEM_RESOURCES:
return ERRNUM_AGAIN;
448 case ERROR_NOT_ENOUGH_QUOTA:
return ERRNUM_IO;
456 case ERROR_NO_DATA_DETECTED:
return ERRNUM_IO;
461 case ERROR_NO_SIGNAL_SENT:
return ERRNUM_IO;
462 case ERROR_NO_SYSTEM_RESOURCES:
return ERRNUM_FBIG;
465 case ERROR_OPEN_FAILED:
return ERRNUM_IO;
487 case ERROR_SERVICE_REQUEST_TIMEOUT:
return ERRNUM_BUSY;
488 case ERROR_SETMARK_DETECTED:
return ERRNUM_IO;
489 case ERROR_SHARING_BUFFER_EXCEEDED:
return ERRNUM_NOLCK;
493 case ERROR_SIGNAL_REFUSED:
return ERRNUM_IO;
494 #ifdef ERROR_SYMLINK_NOT_SUPPORTED
502 case ERROR_UNEXP_NET_ERR:
return ERRNUM_IO;
505 case ERROR_WRITE_FAULT:
return ERRNUM_IO;
555 #if _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
751 #ifdef ENOTRECOVERABLE
784 #ifdef EPROTONOSUPPORT
846 #ifdef ERROR_FLOAT_MULTIPLE_FAULTS
847 case ERRNUM_DOM:
return ERROR_FLOAT_MULTIPLE_FAULTS;
852 case ERRNUM_FBIG:
return ERROR_NO_SYSTEM_RESOURCES;
856 #ifdef ERROR_ILLEGAL_CHARACTER
866 case ERRNUM_LOOP:
return ERROR_CANT_RESOLVE_FILENAME;
928 #if _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
950 return GetLastError();
977 if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM
978 | FORMAT_MESSAGE_IGNORE_INSERTS,
979 NULL, errc, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
980 errstr,
sizeof(errstr), NULL))
984 size_t n = strlen(errstr);
986 errstr[n - 2] =
'\0';
989 #if _POSIX_C_SOURCE >= 200112L && !defined(__NEWLIB__)
991 case -
ABS(EAI_AGAIN):
return gai_strerror(EAI_AGAIN);
992 case -
ABS(EAI_BADFLAGS):
return gai_strerror(EAI_BADFLAGS);
993 case -
ABS(EAI_FAIL):
return gai_strerror(EAI_FAIL);
994 case -
ABS(EAI_FAMILY):
return gai_strerror(EAI_FAMILY);
995 case -
ABS(EAI_MEMORY):
return gai_strerror(EAI_MEMORY);
996 case -
ABS(EAI_NONAME):
return gai_strerror(EAI_NONAME);
997 case -
ABS(EAI_OVERFLOW):
return gai_strerror(EAI_OVERFLOW);
998 case -
ABS(EAI_SERVICE):
return gai_strerror(EAI_SERVICE);
999 case -
ABS(EAI_SOCKTYPE):
return gai_strerror(EAI_SOCKTYPE);
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.
int errnum2no(errnum_t errnum)
Transforms a platform-independent error number to a standard C error number.
const char * errno2str(int errnum)
Returns a string describing a standard C error number.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
const char * errc2str(int errc)
Returns a string describing a native error code.
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....