Commit 90186117 authored by Ulrich Huber's avatar Ulrich Huber Committed by Oliver Horst
Browse files

[fix] Correct errno headers to mirror newlib correctly

parent fdaa9389
#ifndef TOKI_ERRNO_H
#define TOKI_ERRNO_H
#include "sys/errno.h"
#endif //TOKI_ERRNO_H
// Dummy file so ports resemble capabilities
\ No newline at end of file
......@@ -15,6 +15,11 @@ find_package(
REQUIRED
)
find_package(
toki-elfloader-config-headers 0.1
REQUIRED
)
add_library(
toki-libc-repl-sys-headers
#
......@@ -24,6 +29,7 @@ add_library(
target_link_libraries(
toki-libc-repl-sys-headers
INTERFACE freertos-headers
toki-elfloader-config-headers
)
......
//
// Created by ulrich on 18.05.20.
//
/*
* List of error numbers as defined by newlib.
* It is important that these lists are matching, so applications get the correct error reported.
*/
#ifndef TOKI_ERRNO_H
#define TOKI_ERRNO_H
/* errno is not a global variable, because that would make using it
non-reentrant. Instead, its address is returned by the function
__errno. */
#ifndef TOKI_SYS_ERRNO_H
#define TOKI_SYS_ERRNO_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _REENT_ONLY
#define errno (*__errno())
extern int *__errno (void);
#endif
#include <toki/elfloader/config.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#ifdef __CYGWIN__
extern __IMPORT const char * const sys_errlist[];
extern __IMPORT int sys_nerr;
extern __IMPORT char *program_invocation_name;
extern __IMPORT char *program_invocation_short_name;
#endif
struct _reent {
int _errno;
};
#define __errno_r(ptr) ((ptr)->_errno)
#define errno \
(((struct _reent *) pvTaskGetThreadLocalStoragePointer( \
xTaskGetCurrentTaskHandle(), \
configAPPLICATION_TLS_INDEX \
) \
)->_errno)
#define EPERM 1 /* Not owner */
#define ENOENT 2 /* No such file or directory */
......@@ -40,9 +39,7 @@ extern __IMPORT char *program_invocation_short_name;
#define ENOMEM 12 /* Not enough space */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ENOTBLK 15 /* Block device required */
#endif
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
......@@ -64,7 +61,6 @@ extern __IMPORT char *program_invocation_short_name;
#define ERANGE 34 /* Result too large */
#define ENOMSG 35 /* No message of desired type */
#define EIDRM 36 /* Identifier removed */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ECHRNG 37 /* Channel number out of range */
#define EL2NSYNC 38 /* Level 2 not synchronized */
#define EL3HLT 39 /* Level 3 halted */
......@@ -73,10 +69,8 @@ extern __IMPORT char *program_invocation_short_name;
#define EUNATCH 42 /* Protocol driver not attached */
#define ENOCSI 43 /* No CSI structure available */
#define EL2HLT 44 /* Level 2 halted */
#endif
#define EDEADLK 45 /* Deadlock */
#define ENOLCK 46 /* No lock */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define EBADE 50 /* Invalid exchange */
#define EBADR 51 /* Invalid request descriptor */
#define EXFULL 52 /* Exchange full */
......@@ -85,31 +79,23 @@ extern __IMPORT char *program_invocation_short_name;
#define EBADSLT 55 /* Invalid slot */
#define EDEADLOCK 56 /* File locking deadlock error */
#define EBFONT 57 /* Bad font file fmt */
#endif
#define ENOSTR 60 /* Not a stream */
#define ENODATA 61 /* No data (for no delay io) */
#define ETIME 62 /* Stream ioctl timeout */
#define ENOSR 63 /* No stream resources */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ENONET 64 /* Machine is not on the network */
#define ENOPKG 65 /* Package not installed */
#define EREMOTE 66 /* The object is remote */
#endif
#define ENOLINK 67 /* Virtual circuit is gone */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define EADV 68 /* Advertise error */
#define ESRMNT 69 /* Srmount error */
#define ECOMM 70 /* Communication error on send */
#endif
#define EPROTO 71 /* Protocol error */
#define EMULTIHOP 74 /* Multihop attempted */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ELBIN 75 /* Inode is remote (not really error) */
#define EDOTDOT 76 /* Cross mount point (not really error) */
#endif
#define EBADMSG 77 /* Bad message */
#define EFTYPE 79 /* Inappropriate file type or format */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ENOTUNIQ 80 /* Given log. name not unique */
#define EBADFD 81 /* f.d. invalid for this operation */
#define EREMCHG 82 /* Remote address changed */
......@@ -118,11 +104,8 @@ extern __IMPORT char *program_invocation_short_name;
#define ELIBSCN 85 /* .lib section in a.out corrupted */
#define ELIBMAX 86 /* Attempting to link in too many libs */
#define ELIBEXEC 87 /* Attempting to exec a shared library */
#endif
#define ENOSYS 88 /* Function not implemented */
#ifdef __CYGWIN__
#define ENMFILE 89 /* No more files */
#endif
#define ENOTEMPTY 90 /* Directory not empty */
#define ENAMETOOLONG 91 /* File or path name too long */
#define ELOOP 92 /* Too many symbolic links */
......@@ -134,9 +117,7 @@ extern __IMPORT char *program_invocation_short_name;
#define EPROTOTYPE 107 /* Protocol wrong type for socket */
#define ENOTSOCK 108 /* Socket operation on non-socket */
#define ENOPROTOOPT 109 /* Protocol not available */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ESHUTDOWN 110 /* Can't send after socket shutdown */
#endif
#define ECONNREFUSED 111 /* Connection refused */
#define EADDRINUSE 112 /* Address already in use */
#define ECONNABORTED 113 /* Software caused connection abort */
......@@ -150,36 +131,26 @@ extern __IMPORT char *program_invocation_short_name;
#define EDESTADDRREQ 121 /* Destination address required */
#define EMSGSIZE 122 /* Message too long */
#define EPROTONOSUPPORT 123 /* Unknown protocol */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ESOCKTNOSUPPORT 124 /* Socket type not supported */
#endif
#define EADDRNOTAVAIL 125 /* Address not available */
#define ENETRESET 126 /* Connection aborted by network */
#define EISCONN 127 /* Socket is already connected */
#define ENOTCONN 128 /* Socket is not connected */
#define ETOOMANYREFS 129
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define EPROCLIM 130
#define EUSERS 131
#endif
#define EDQUOT 132
#define ESTALE 133
#define ENOTSUP 134 /* Not supported */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ENOMEDIUM 135 /* No medium (in tape drive) */
#endif
#ifdef __CYGWIN__
#define ENOSHARE 136 /* No such host or network path */
#define ECASECLASH 137 /* Filename exists with different case */
#endif
#define EILSEQ 138 /* Illegal byte sequence */
#define EOVERFLOW 139 /* Value too large for defined data type */
#define ECANCELED 140 /* Operation canceled */
#define ENOTRECOVERABLE 141 /* State not recoverable */
#define EOWNERDEAD 142 /* Previous owner died */
#ifdef __LINUX_ERRNO_EXTENSIONS__
#define ESTRPIPE 143 /* Streams pipe error */
#endif
#define EWOULDBLOCK EAGAIN /* Operation would block */
#define __ELASTERROR 2000 /* Users can add values starting here */
......@@ -188,4 +159,4 @@ extern __IMPORT char *program_invocation_short_name;
}
#endif
#endif //TOKI_ERRNO_H
#endif //TOKI_SYS_ERRNO_H
......@@ -3,6 +3,7 @@
include(CMakeFindDependencyMacro)
find_dependency(freertos-headers)
find_dependency(toki-elfloader-config-headers 0.1)
# Import targets
include(${CMAKE_CURRENT_LIST_DIR}/toki-libc-repl-sys-headers-targets.cmake)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment