diff --git a/components/libc/minilibc/errno.h b/components/libc/minilibc/errno.h index 305b48871d87a9abaff09c8349e8b04ed0a1f5eb..74bed5196b8582cea3d39d10c57f46aea104ab15 100644 --- a/components/libc/minilibc/errno.h +++ b/components/libc/minilibc/errno.h @@ -47,13 +47,31 @@ #endif -#define EPERM 1 /* Not super-user */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define ENFILE 23 /* Too many open files in system */ -#define EDEADLK 45 /* Deadlock condition */ -#define EBADMSG 77 /* Trying to read unreadable message */ -#define ETIMEDOUT 116 /* Connection timed out */ -#define ENOTSUP 134 /* Not supported */ +#define EPERM 1 /* Not super-user */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EFAULT 14 /* Bad address */ +#define ENFILE 23 /* Too many open files in system */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 45 /* Deadlock condition */ +#define EBADMSG 77 /* Trying to read unreadable message */ +#define EMSGSIZE 90 /* Message too long */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ETIMEDOUT 116 /* Connection timed out */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define ENOTSUP 134 /* Not supported */ +#define ENSRNOTFOUND 163 /* Domain name not found */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ #endif diff --git a/components/libc/minilibc/rand.c b/components/libc/minilibc/rand.c index d97e91bdbac634004cdff5e07aa1033e8320b91e..387d605d4c6d207b8eec8634e97bea04174583a6 100644 --- a/components/libc/minilibc/rand.c +++ b/components/libc/minilibc/rand.c @@ -2,7 +2,7 @@ #include #include -static unsigned int seed=1; +static unsigned int _seed=1; /* Knuth's TAOCP section 3.6 */ #define M ((1U<<31) -1) @@ -10,7 +10,6 @@ static unsigned int seed=1; #define Q 44488 // M/A #define R 3399 // M%A; R < Q !!! -// FIXME: ISO C/SuS want a longer period int rand_r(unsigned int* seed) { int32_t X; @@ -24,12 +23,12 @@ int rand_r(unsigned int* seed) } int rand(void) { - return rand_r(&seed); + return rand_r(&_seed); } void srand(unsigned int i) { - seed=i; + _seed=i; } int random(void) __attribute__((alias("rand"))); diff --git a/components/libc/minilibc/stdint.h b/components/libc/minilibc/stdint.h index 6c8dd6bfaa15096873cc0573e9af9112836b417a..11c07179a61a3db547601e7001858586cc7e7009 100644 --- a/components/libc/minilibc/stdint.h +++ b/components/libc/minilibc/stdint.h @@ -32,4 +32,15 @@ typedef unsigned long long uint64_t; #define UINT16_MAX 0xffff #define UINT32_MAX 0xffffffffU +#ifndef __INT_MAX__ +#define __INT_MAX__ 2147483647 +#endif +#define INT_MIN (-1 - INT_MAX) +#define INT_MAX (__INT_MAX__) +#define UINT_MAX (INT_MAX * 2U + 1U) + +#define LONG_MAX ((long)(~0UL>>1)) +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX (~0UL) + #endif diff --git a/components/libc/minilibc/string.c b/components/libc/minilibc/string.c index 52726f2cbfa5723a4fa47e5144b3d75a23e6aaba..568e9795ef4a174b542f195538213c1656087141 100644 --- a/components/libc/minilibc/string.c +++ b/components/libc/minilibc/string.c @@ -17,6 +17,7 @@ */ #include +#include #if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC) #include "string.h" diff --git a/components/libc/minilibc/string.h b/components/libc/minilibc/string.h index f9cc9a659116a4672411d8996fd26b438c803a0d..4bfec8fecdc1f485271e2c3a886103fe005121af 100644 --- a/components/libc/minilibc/string.h +++ b/components/libc/minilibc/string.h @@ -28,13 +28,6 @@ #define SPECIAL (1 << 5) /* 0x */ #define LARGE (1 << 6) /* use 'ABCDEF' instead of 'abcdef' */ -#define INT_MAX ((int)(~0U>>1)) -#define INT_MIN (-INT_MAX - 1) -#define UINT_MAX (~0U) -#define LONG_MAX ((long)(~0UL>>1)) -#define LONG_MIN (-LONG_MAX - 1) -#define ULONG_MAX (~0UL) - #define _U 0x01 /* upper */ #define _L 0x02 /* lower */ #define _D 0x04 /* digit */