From 59f8dbd3a0252e2cd90276b13832f260555732e9 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 17 Mar 2007 16:18:49 +0000 Subject: Add strerror() git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@80 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 1 + nuttx/Documentation/NuttX.html | 1 + nuttx/include/errno.h | 395 +++++++++++++++++++++++++++-------------- nuttx/include/string.h | 2 +- nuttx/lib/Makefile | 2 +- nuttx/lib/lib_strerror.c | 236 ++++++++++++++++++++++++ nuttx/sched/os_start.c | 4 +- 7 files changed, 501 insertions(+), 140 deletions(-) create mode 100644 nuttx/lib/lib_strerror.c diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index c5e9f17c07..d2b64ea0d0 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -35,6 +35,7 @@ 0.1.2 2007-xx-xx Gregory Nutt * Add dirent.h, opendir(), readdir(), closedir(), etc. + * Add strerror() * Added 'ls' command to nsh * Added C5471 watchdog driver * Added support for the Neuros OSD / DM320 diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 5db2ce4e08..3f80f7bbad 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -396,6 +396,7 @@ Other memory: 0.1.2 2007-xx-xx Gregory Nutt * Add dirent.h, opendir(), readdir(), closedir(), etc. + * Add strerror() * Added 'ls' command to nsh * Added C5471 watchdog driver * Added support for the Neuros OSD / DM320 diff --git a/nuttx/include/errno.h b/nuttx/include/errno.h index 6f362cfc90..1291a2cffc 100644 --- a/nuttx/include/errno.h +++ b/nuttx/include/errno.h @@ -1,4 +1,4 @@ -/************************************************************ +/************************************************************************ * errno.h * * Copyright (C) 2007 Gregory Nutt. All rights reserved. @@ -31,154 +31,277 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************/ + ************************************************************************/ #ifndef __ERRNO_H #define __ERRNO_H -/************************************************************ +/************************************************************************ * Included Files - ************************************************************/ + ************************************************************************/ -/************************************************************ +/************************************************************************ * Definitions - ************************************************************/ + ************************************************************************/ -#define EPERM 1 /* Operation not permitted */ -#define ENOENT 2 /* No such file or directory */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* I/O error */ -#define ENXIO 6 /* No such device or address */ -#define E2BIG 7 /* Arg list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file number */ -#define ECHILD 10 /* No child processes */ -#define EAGAIN 11 /* Try again */ -#define ENOMEM 12 /* Out of memory */ -#define EACCES 13 /* Permission denied */ -#define EFAULT 14 /* Bad address */ -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Device or resource busy */ -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* No such device */ -#define ENOTDIR 20 /* Not a directory */ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* File table overflow */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Not a typewriter */ -#define ETXTBSY 26 /* Text file busy */ -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read-only file system */ -#define EMLINK 31 /* Too many links */ -#define EPIPE 32 /* Broken pipe */ -#define EDOM 33 /* Math argument out of domain of func */ -#define ERANGE 34 /* Math result not representable */ -#define EDEADLK 35 /* Resource deadlock would occur */ -#define ENAMETOOLONG 36 /* File name too long */ -#define ENOLCK 37 /* No record locks available */ -#define ENOSYS 38 /* Function not implemented */ -#define ENOTEMPTY 39 /* Directory not empty */ -#define ELOOP 40 /* Too many symbolic links encountered */ -#define EWOULDBLOCK EAGAIN /* Operation would block */ -#define ENOMSG 42 /* No message of desired type */ -#define EIDRM 43 /* Identifier removed */ -#define ECHRNG 44 /* Channel number out of range */ -#define EL2NSYNC 45 /* Level 2 not synchronized */ -#define EL3HLT 46 /* Level 3 halted */ -#define EL3RST 47 /* Level 3 reset */ -#define ELNRNG 48 /* Link number out of range */ -#define EUNATCH 49 /* Protocol driver not attached */ -#define ENOCSI 50 /* No CSI structure available */ -#define EL2HLT 51 /* Level 2 halted */ -#define EBADE 52 /* Invalid exchange */ -#define EBADR 53 /* Invalid request descriptor */ -#define EXFULL 54 /* Exchange full */ -#define ENOANO 55 /* No anode */ -#define EBADRQC 56 /* Invalid request code */ -#define EBADSLT 57 /* Invalid slot */ +/* Definitions of error numbers and the string that would be + * returned by strerror(). + */ -#define EDEADLOCK EDEADLK +#define EPERM 1 +#define EPERM_STR "Operation not permitted" +#define ENOENT 2 +#define ENOENT_STR "No such file or directory" +#define ESRCH 3 +#define ESRCH_STR "No such process" +#define EINTR 4 +#define EINTR_STR "Interrupted system call" +#define EIO 5 +#define EIO_STR "I/O error" +#define ENXIO 6 +#define ENXIO_STR "No such device or address" +#define E2BIG 7 +#define E2BIG_STR "Arg list too long" +#define ENOEXEC 8 +#define ENOEXEC_STR "Exec format error" +#define EBADF 9 +#define EBADF_STR "Bad file number" +#define ECHILD 10 +#define ECHILD_STR "No child processes" +#define EAGAIN 11 +#define EWOULDBLOCK EAGAIN +#define EAGAIN_STR "Try again" +#define ENOMEM 12 +#define ENOMEM_STR "Out of memory" +#define EACCES 13 +#define EACCES_STR "Permission denied" +#define EFAULT 14 +#define EFAULT_STR "Bad address" +#define ENOTBLK 15 +#define ENOTBLK_STR "Block device required" +#define EBUSY 16 +#define EBUSY_STR "Device or resource busy" +#define EEXIST 17 +#define EEXIST_STR "File exists" +#define EXDEV 18 +#define EXDEV_STR "Cross-device link" +#define ENODEV 19 +#define ENODEV_STR "No such device" +#define ENOTDIR 20 +#define ENOTDIR_STR "Not a directory" +#define EISDIR 21 +#define EISDIR_STR "Is a directory" +#define EINVAL 22 +#define EINVAL_STR "Invalid argument" +#define ENFILE 23 +#define ENFILE_STR "File table overflow" +#define EMFILE 24 +#define EMFILE_STR "Too many open files" +#define ENOTTY 25 +#define ENOTTY_STR "Not a typewriter" +#define ETXTBSY 26 +#define ETXTBSY_STR "Text file busy" +#define EFBIG 27 +#define EFBIG_STR "File too large" +#define ENOSPC 28 +#define ENOSPC_STR "No space left on device" +#define ESPIPE 29 +#define ESPIPE_STR "Illegal seek" +#define EROFS 30 +#define EROFS_STR "Read-only file system" +#define EMLINK 31 +#define EMLINK_STR "Too many links" +#define EPIPE 32 +#define EPIPE_STR "Broken pipe" +#define EDOM 33 +#define EDOM_STR "Math argument out of domain of func" +#define ERANGE 34 +#define ERANGE_STR "Math result not representable" +#define EDEADLK 35 +#define EDEADLOCK EDEADLK +#define EDEADLK_STR "Resource deadlock would occur" +#define ENAMETOOLONG 36 +#define ENAMETOOLONG_STR "File name too long" +#define ENOLCK 37 +#define ENOLCK_STR "No record locks available" +#define ENOSYS 38 +#define ENOSYS_STR "Function not implemented" +#define ENOTEMPTY 39 +#define ENOTEMPTY_STR "Directory not empty" +#define ELOOP 40 +#define ELOOP_STR "Too many symbolic links encountered" +#define ENOMSG 42 +#define ENOMSG_STR "No message of desired type" +#define EIDRM 43 +#define EIDRM_STR "Identifier removed" +#define ECHRNG 44 +#define ECHRNG_STR "Channel number out of range" +#define EL2NSYNC 45 +#define EL2NSYNC_STR "Level 2 not synchronized" +#define EL3HLT 46 +#define EL3HLT_STR "Level 3 halted" +#define EL3RST 47 +#define EL3RST_STR "Level 3 reset" +#define ELNRNG 48 +#define ELNRNG_STR "Link number out of range" +#define EUNATCH 49 +#define EUNATCH_STR "Protocol driver not attached" +#define ENOCSI 50 +#define ENOCSI_STR "No CSI structure available" +#define EL2HLT 51 +#define EL2HLT_STR "Level 2 halted" +#define EBADE 52 +#define EBADE_STR "Invalid exchange" +#define EBADR 53 +#define EBADR_STR "Invalid request descriptor" +#define EXFULL 54 +#define EXFULL_STR "Exchange full" +#define ENOANO 55 +#define ENOANO_STR "No anode" +#define EBADRQC 56 +#define EBADRQC_STR "Invalid request code" +#define EBADSLT 57 +#define EBADSLT_STR "Invalid slot" +#define EBFONT 59 +#define EBFONT_STR "Bad font file format" +#define ENOSTR 60 +#define ENOSTR_STR "Device not a stream" +#define ENODATA 61 +#define ENODATA_STR "No data available" +#define ETIME 62 +#define ETIME_STR "Timer expired" +#define ENOSR 63 +#define ENOSR_STR "Out of streams resources" +#define ENONET 64 +#define ENONET_STR "Machine is not on the network" +#define ENOPKG 65 +#define ENOPKG_STR "Package not installed" +#define EREMOTE 66 +#define EREMOTE_STR "Object is remote" +#define ENOLINK 67 +#define ENOLINK_STR "Link has been severed" +#define EADV 68 +#define EADV_STR "Advertise error" +#define ESRMNT 69 +#define ESRMNT_STR "Srmount error" +#define ECOMM 70 +#define ECOMM_STR "Communication error on send" +#define EPROTO 71 +#define EPROTO_STR "Protocol error" +#define EMULTIHOP 72 +#define EMULTIHOP_STR "Multihop attempted" +#define EDOTDOT 73 +#define EDOTDOT_STR "RFS specific error" +#define EBADMSG 74 +#define EBADMSG_STR "Not a data message" +#define EOVERFLOW 75 +#define EOVERFLOW_STR "Value too large for defined data type" +#define ENOTUNIQ 76 +#define ENOTUNIQ_STR "Name not unique on network" +#define EBADFD 77 +#define EBADFD_STR "File descriptor in bad state" +#define EREMCHG 78 +#define EREMCHG_STR "Remote address changed" +#define ELIBACC 79 +#define ELIBACC_STR "Can not access a needed shared library" +#define ELIBBAD 80 +#define ELIBBAD_STR "Accessing a corrupted shared library" +#define ELIBSCN 81 +#define ELIBSCN_STR ".lib section in a.out corrupted" +#define ELIBMAX 82 +#define ELIBMAX_STR "Attempting to link in too many shared libraries" +#define ELIBEXEC 83 +#define ELIBEXEC_STR "Cannot exec a shared library directly" +#define EILSEQ 84 +#define EILSEQ_STR "Illegal byte sequence" +#define ERESTART 85 +#define ERESTART_STR "Interrupted system call should be restarted" +#define ESTRPIPE 86 +#define ESTRPIPE_STR "Streams pipe error" +#define EUSERS 87 +#define EUSERS_STR "Too many users" +#define ENOTSOCK 88 +#define ENOTSOCK_STR "Socket operation on non-socket" +#define EDESTADDRREQ 89 +#define EDESTADDRREQ_STR "Destination address required" +#define EMSGSIZE 90 +#define EMSGSIZE_STR "Message too long" +#define EPROTOTYPE 91 +#define EPROTOTYPE_STR "Protocol wrong type for socket" +#define ENOPROTOOPT 92 +#define ENOPROTOOPT_STR "Protocol not available" +#define EPROTONOSUPPORT 93 +#define EPROTONOSUPPORT_STR "Protocol not supported" +#define ESOCKTNOSUPPORT 94 +#define ESOCKTNOSUPPORT_STR "Socket type not supported" +#define EOPNOTSUPP 95 +#define EOPNOTSUPP_STR "Operation not supported on transport endpoint" +#define EPFNOSUPPORT 96 +#define EPFNOSUPPORT_STR "Protocol family not supported" +#define EAFNOSUPPORT 97 +#define EAFNOSUPPORT_STR "Address family not supported by protocol" +#define EADDRINUSE 98 +#define EADDRINUSE_STR "Address already in use" +#define EADDRNOTAVAIL 99 +#define EADDRNOTAVAIL_STR "Cannot assign requested address" +#define ENETDOWN 100 +#define ENETDOWN_STR "Network is down" +#define ENETUNREACH 101 +#define ENETUNREACH_STR "Network is unreachable" +#define ENETRESET 102 +#define ENETRESET_STR "Network dropped connection because of reset" +#define ECONNABORTED 103 +#define ECONNABORTED_STR "Software caused connection abort" +#define ECONNRESET 104 +#define ECONNRESET_STR "Connection reset by peer" +#define ENOBUFS 105 +#define ENOBUFS_STR "No buffer space available" +#define EISCONN 106 +#define EISCONN_STR "Transport endpoint is already connected" +#define ENOTCONN 107 +#define ENOTCONN_STR "Transport endpoint is not connected" +#define ESHUTDOWN 108 +#define ESHUTDOWN_STR "Cannot send after transport endpoint shutdown" +#define ETOOMANYREFS 109 +#define ETOOMANYREFS_STR "Too many references: cannot splice" +#define ETIMEDOUT 110 +#define ETIMEDOUT_STR "Connection timed out" +#define ECONNREFUSED 111 +#define ECONNREFUSED_STR "Connection refused" +#define EHOSTDOWN 112 +#define EHOSTDOWN_STR "Host is down" +#define EHOSTUNREACH 113 +#define EHOSTUNREACH_STR "No route to host" +#define EALREADY 114 +#define EALREADY_STR "Operation already in progress" +#define EINPROGRESS 115 +#define EINPROGRESS_STR "Operation now in progress" +#define ESTALE 116 +#define ESTALE_STR "Stale NFS file handle" +#define EUCLEAN 117 +#define EUCLEAN_STR "Structure needs cleaning" +#define ENOTNAM 118 +#define ENOTNAM_STR "Not a XENIX named type file" +#define ENAVAIL 119 +#define ENAVAIL_STR "No XENIX semaphores available" +#define EISNAM 120 +#define EISNAM_STR "Is a named type file" +#define EREMOTEIO 121 +#define EREMOTEIO_STR "Remote I/O error" +#define EDQUOT 122 +#define EDQUOT_STR "Quota exceeded" +#define ENOMEDIUM 123 +#define ENOMEDIUM_STR "No medium found" +#define EMEDIUMTYPE 124 +#define EMEDIUMTYPE_STR "Wrong medium type" -#define EBFONT 59 /* Bad font file format */ -#define ENOSTR 60 /* Device not a stream */ -#define ENODATA 61 /* No data available */ -#define ETIME 62 /* Timer expired */ -#define ENOSR 63 /* Out of streams resources */ -#define ENONET 64 /* Machine is not on the network */ -#define ENOPKG 65 /* Package not installed */ -#define EREMOTE 66 /* Object is remote */ -#define ENOLINK 67 /* Link has been severed */ -#define EADV 68 /* Advertise error */ -#define ESRMNT 69 /* Srmount error */ -#define ECOMM 70 /* Communication error on send */ -#define EPROTO 71 /* Protocol error */ -#define EMULTIHOP 72 /* Multihop attempted */ -#define EDOTDOT 73 /* RFS specific error */ -#define EBADMSG 74 /* Not a data message */ -#define EOVERFLOW 75 /* Value too large for defined data type */ -#define ENOTUNIQ 76 /* Name not unique on network */ -#define EBADFD 77 /* File descriptor in bad state */ -#define EREMCHG 78 /* Remote address changed */ -#define ELIBACC 79 /* Can not access a needed shared library */ -#define ELIBBAD 80 /* Accessing a corrupted shared library */ -#define ELIBSCN 81 /* .lib section in a.out corrupted */ -#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ -#define ELIBEXEC 83 /* Cannot exec a shared library directly */ -#define EILSEQ 84 /* Illegal byte sequence */ -#define ERESTART 85 /* Interrupted system call should be restarted */ -#define ESTRPIPE 86 /* Streams pipe error */ -#define EUSERS 87 /* Too many users */ -#define ENOTSOCK 88 /* Socket operation on non-socket */ -#define EDESTADDRREQ 89 /* Destination address required */ -#define EMSGSIZE 90 /* Message too long */ -#define EPROTOTYPE 91 /* Protocol wrong type for socket */ -#define ENOPROTOOPT 92 /* Protocol not available */ -#define EPROTONOSUPPORT 93 /* Protocol not supported */ -#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ -#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define EPFNOSUPPORT 96 /* Protocol family not supported */ -#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ -#define EADDRINUSE 98 /* Address already in use */ -#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ -#define ENETDOWN 100 /* Network is down */ -#define ENETUNREACH 101 /* Network is unreachable */ -#define ENETRESET 102 /* Network dropped connection because of reset */ -#define ECONNABORTED 103 /* Software caused connection abort */ -#define ECONNRESET 104 /* Connection reset by peer */ -#define ENOBUFS 105 /* No buffer space available */ -#define EISCONN 106 /* Transport endpoint is already connected */ -#define ENOTCONN 107 /* Transport endpoint is not connected */ -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ -#define ETOOMANYREFS 109 /* Too many references: cannot splice */ -#define ETIMEDOUT 110 /* Connection timed out */ -#define ECONNREFUSED 111 /* Connection refused */ -#define EHOSTDOWN 112 /* Host is down */ -#define EHOSTUNREACH 113 /* No route to host */ -#define EALREADY 114 /* Operation already in progress */ -#define EINPROGRESS 115 /* Operation now in progress */ -#define ESTALE 116 /* Stale NFS file handle */ -#define EUCLEAN 117 /* Structure needs cleaning */ -#define ENOTNAM 118 /* Not a XENIX named type file */ -#define ENAVAIL 119 /* No XENIX semaphores available */ -#define EISNAM 120 /* Is a named type file */ -#define EREMOTEIO 121 /* Remote I/O error */ -#define EDQUOT 122 /* Quota exceeded */ - -#define ENOMEDIUM 123 /* No medium found */ -#define EMEDIUMTYPE 124 /* Wrong medium type */ - -/************************************************************ +/************************************************************************ * Type Declarations - ************************************************************/ + ************************************************************************/ -/************************************************************ +/************************************************************************ * Global Function Prototypes - ************************************************************/ + ************************************************************************/ #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/include/string.h b/nuttx/include/string.h index 38163eb030..84c17cc39f 100644 --- a/nuttx/include/string.h +++ b/nuttx/include/string.h @@ -61,7 +61,7 @@ extern "C" { EXTERN char *strchr(const char *s, int c); EXTERN FAR char *strdup(const char *s); -EXTERN char *strerror(int); +EXTERN const char *strerror(int); EXTERN size_t strlen(const char *); EXTERN char *strncat(char *, const char *, size_t); EXTERN int strcmp(const char *, const char *); diff --git a/nuttx/lib/Makefile b/nuttx/lib/Makefile index 6d89ccaef7..a861d43a71 100644 --- a/nuttx/lib/Makefile +++ b/nuttx/lib/Makefile @@ -44,7 +44,7 @@ MISC_SRCS = lib_init.c lib_streamsem.c lib_filesem.c STRING_SRCS = lib_memset.c lib_memcpy.c lib_memcmp.c lib_memmove.c \ lib_strcpy.c lib_strncpy.c lib_strcmp.c \ lib_strlen.c lib_strdup.c lib_strtol.c lib_strchr.c \ - lib_strtok.c lib_strtokr.c + lib_strtok.c lib_strtokr.c lib_strerror.c CTYPE_SRCS = STDIO_SRCS = lib_fopen.c lib_fclose.c \ lib_fread.c lib_libfread.c lib_fgetc.c lib_fgets.c lib_gets.c \ diff --git a/nuttx/lib/lib_strerror.c b/nuttx/lib/lib_strerror.c new file mode 100644 index 0000000000..994af8d5bb --- /dev/null +++ b/nuttx/lib/lib_strerror.c @@ -0,0 +1,236 @@ +/************************************************************************ + * lib_strerror.c + * + * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************/ + +/************************************************************************ + * Included Files + ************************************************************************/ + +#include +#include +#include +#include + +/************************************************************************ + * Definitions + ************************************************************************/ + +/************************************************************************ + * Private Types + ************************************************************************/ + +struct errno_strmap_s +{ + ubyte errnum; + const char *str; +}; + +/************************************************************************ + * Private Data + ************************************************************************/ + +/* This table maps all error numbers to descriptive strings. + * The only assumption that the code makes with regard to this + * this table is that it is order by error number. + * + * The size of this table is quite large. Its size can be + * reduced by eliminating some of the more obscure error + * strings. + */ + +struct errno_strmap_s g_errnomap[] = +{ + { EPERM, EPERM_STR }, + { ENOENT, ENOENT_STR }, + { ESRCH, ESRCH_STR }, + { EINTR, EINTR_STR }, + { EIO, EIO_STR }, + { ENXIO, ENXIO_STR }, + { E2BIG, E2BIG_STR }, + { ENOEXEC, ENOEXEC_STR }, + { EBADF, EBADF_STR }, + { ECHILD, ECHILD_STR }, + { EAGAIN, EAGAIN_STR }, + { ENOMEM, ENOMEM_STR }, + { EACCES, EACCES_STR }, + { EFAULT, EFAULT_STR }, + { ENOTBLK, ENOTBLK_STR }, + { EBUSY, EBUSY_STR }, + { EEXIST, EEXIST_STR }, + { EXDEV, EXDEV_STR }, + { ENODEV, ENODEV_STR }, + { ENOTDIR, ENOTDIR_STR }, + { EISDIR, EISDIR_STR }, + { EINVAL, EINVAL_STR }, + { ENFILE, ENFILE_STR }, + { EMFILE, EMFILE_STR }, + { ENOTTY, ENOTTY_STR }, + { ETXTBSY, ETXTBSY_STR }, + { EFBIG, EFBIG_STR }, + { ENOSPC, ENOSPC_STR }, + { ESPIPE, ESPIPE_STR }, + { EROFS, EROFS_STR }, + { EMLINK, EMLINK_STR }, + { EPIPE, EPIPE_STR }, + { EDOM, EDOM_STR }, + { ERANGE, ERANGE_STR }, + { EDEADLK, EDEADLK_STR }, + { ENAMETOOLONG, ENAMETOOLONG_STR }, + { ENOLCK, ENOLCK_STR }, + { ENOSYS, ENOSYS_STR }, + { ENOTEMPTY, ENOTEMPTY_STR }, + { ELOOP, ELOOP_STR }, + { ENOMSG, ENOMSG_STR }, + { EIDRM, EIDRM_STR }, + { ECHRNG, ECHRNG_STR }, + { EL2NSYNC, EL2NSYNC_STR }, + { EL3HLT, EL3HLT_STR }, + { EL3RST, EL3RST_STR }, + { ELNRNG, ELNRNG_STR }, + { EUNATCH, EUNATCH_STR }, + { ENOCSI, ENOCSI_STR }, + { EL2HLT, EL2HLT_STR }, + { EBADE, EBADE_STR }, + { EBADR, EBADR_STR }, + { EXFULL, EXFULL_STR }, + { ENOANO, ENOANO_STR }, + { EBADRQC, EBADRQC_STR }, + { EBADSLT, EBADSLT_STR }, + { EBFONT, EBFONT_STR }, + { ENOSTR, ENOSTR_STR }, + { ENODATA, ENODATA_STR }, + { ETIME, ETIME_STR }, + { ENOSR, ENOSR_STR }, + { ENONET, ENONET_STR }, + { ENOPKG, ENOPKG_STR }, + { EREMOTE, EREMOTE_STR }, + { ENOLINK, ENOLINK_STR }, + { EADV, EADV_STR }, + { ESRMNT, ESRMNT_STR }, + { ECOMM, ECOMM_STR }, + { EPROTO, EPROTO_STR }, + { EMULTIHOP, EMULTIHOP_STR }, + { EDOTDOT, EDOTDOT_STR }, + { EBADMSG, EBADMSG_STR }, + { EOVERFLOW, EOVERFLOW_STR }, + { ENOTUNIQ, ENOTUNIQ_STR }, + { EBADFD, EBADFD_STR }, + { EREMCHG, EREMCHG_STR }, + { ELIBACC, ELIBACC_STR }, + { ELIBBAD, ELIBBAD_STR }, + { ELIBSCN, ELIBSCN_STR }, + { ELIBMAX, ELIBMAX_STR }, + { ELIBEXEC, ELIBEXEC_STR }, + { EILSEQ, EILSEQ_STR }, + { ERESTART, ERESTART_STR }, + { ESTRPIPE, ESTRPIPE_STR }, + { EUSERS, EUSERS_STR }, + { ENOTSOCK, ENOTSOCK_STR }, + { EDESTADDRREQ, EDESTADDRREQ_STR }, + { EMSGSIZE, EMSGSIZE_STR }, + { EPROTOTYPE, EPROTOTYPE_STR }, + { ENOPROTOOPT, ENOPROTOOPT_STR }, + { EPROTONOSUPPORT, EPROTONOSUPPORT_STR }, + { ESOCKTNOSUPPORT, ESOCKTNOSUPPORT_STR }, + { EOPNOTSUPP, EOPNOTSUPP_STR }, + { EPFNOSUPPORT, EPFNOSUPPORT_STR }, + { EAFNOSUPPORT, EAFNOSUPPORT_STR }, + { EADDRINUSE, EADDRINUSE_STR }, + { EADDRNOTAVAIL, EADDRNOTAVAIL_STR }, + { ENETDOWN, ENETDOWN_STR }, + { ENETUNREACH, ENETUNREACH_STR }, + { ENETRESET, ENETRESET_STR }, + { ECONNABORTED, ECONNABORTED_STR }, + { ECONNRESET, ECONNRESET_STR }, + { ENOBUFS, ENOBUFS_STR }, + { EISCONN, EISCONN_STR }, + { ENOTCONN, ENOTCONN_STR }, + { ESHUTDOWN, ESHUTDOWN_STR }, + { ETOOMANYREFS, ETOOMANYREFS_STR }, + { ETIMEDOUT, ETIMEDOUT_STR }, + { ECONNREFUSED, ECONNREFUSED_STR }, + { EHOSTDOWN, EHOSTDOWN_STR }, + { EHOSTUNREACH, EHOSTUNREACH_STR }, + { EALREADY, EALREADY_STR }, + { EINPROGRESS, EINPROGRESS_STR }, + { ESTALE, ESTALE_STR }, + { EUCLEAN, EUCLEAN_STR }, + { ENOTNAM, ENOTNAM_STR }, + { ENAVAIL, ENAVAIL_STR }, + { EISNAM, EISNAM_STR }, + { EREMOTEIO, EREMOTEIO_STR }, + { EDQUOT, EDQUOT_STR }, + { ENOMEDIUM, ENOMEDIUM_STR }, + { EMEDIUMTYPE, EMEDIUMTYPE_STR } +}; + +#define NERRNO_STRS (sizeof(g_errnomap) / sizeof(struct errno_strmap_s)) + +/************************************************************************ + * Private Functions + ************************************************************************/ + +/************************************************************************ + * Public Functions + ************************************************************************/ + +/************************************************************************ + * Name: strerror + ************************************************************************/ + +const char *strerror(int errnum) +{ + int ndxlow = 0; + int ndxhi = NERRNO_STRS - 1; + int ndxmid; + + do + { + ndxmid = (ndxlow + ndxhi) >> 1; + if (errnum > g_errnomap[ndxmid].errnum) + { + ndxlow = ndxmid + 1; + } + else if (errnum < g_errnomap[ndxmid].errnum) + { + ndxhi = ndxmid - 1; + } + else + { + return g_errnomap[ndxmid].str; + } + } + while (ndxlow <= ndxhi); + return "Unknown error"; +} diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c index 2c5da51a2b..30a8cb5873 100644 --- a/nuttx/sched/os_start.c +++ b/nuttx/sched/os_start.c @@ -264,7 +264,7 @@ void os_start(void) /* Then add the idle task's TCB to the head of the ready to run list */ - dq_addfirst((FAR dq_entry_t*)&g_idletcb, &g_readytorun); + dq_addfirst((FAR dq_entry_t*)&g_idletcb, (dq_queue_t*)&g_readytorun); /* Initialize the processor-specific portion of the TCB */ @@ -435,7 +435,7 @@ void os_start(void) /* Remove the first delayed deallocation. */ irqstate_t saved_state = irqsave(); - void *address = (void*)sq_remfirst(&g_delayeddeallocations); + void *address = (void*)sq_remfirst((sq_queue_t*)&g_delayeddeallocations); irqrestore(saved_state); /* Then deallocate it */ -- cgit v1.2.3