summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/libc/minilibc/errno.h34
-rw-r--r--components/libc/minilibc/rand.c7
-rw-r--r--components/libc/minilibc/stdint.h11
-rw-r--r--components/libc/minilibc/string.c1
-rw-r--r--components/libc/minilibc/string.h7
5 files changed, 41 insertions, 19 deletions
diff --git a/components/libc/minilibc/errno.h b/components/libc/minilibc/errno.h
index 305b48871d..74bed5196b 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 d97e91bdba..387d605d4c 100644
--- a/components/libc/minilibc/rand.c
+++ b/components/libc/minilibc/rand.c
@@ -2,7 +2,7 @@
#include <stdint.h>
#include <sys/types.h>
-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 6c8dd6bfaa..11c07179a6 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 52726f2cbf..568e9795ef 100644
--- a/components/libc/minilibc/string.c
+++ b/components/libc/minilibc/string.c
@@ -17,6 +17,7 @@
*/
#include <rtthread.h>
+#include <stdint.h>
#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 f9cc9a6591..4bfec8fecd 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 */