Browse Source

Add more errno definitions.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2401 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong@gmail.com 12 years ago
parent
commit
e6942f9a09

+ 26 - 8
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

+ 3 - 4
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")));

+ 11 - 0
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

+ 1 - 0
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"

+ 0 - 7
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 */