summaryrefslogtreecommitdiff
path: root/components/libc
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-10-19 08:18:24 +0000
committerbernard.xiong <[email protected]>2010-10-19 08:18:24 +0000
commitb4a98e4457c3a58301b41db5db50bfbca4546255 (patch)
tree161b79af9aa9f3cebeab41905ec795a69658c2e9 /components/libc
parent14a0eaf61780622995868dc00e9fb0bf7dddd4f8 (diff)
Improve the Device File System of the POSIX compatibility
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1015 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/libc')
-rw-r--r--components/libc/minilibc/rand.c1
-rw-r--r--components/libc/minilibc/sys/types.h10
-rw-r--r--components/libc/newlib/sys/dirent.h57
-rw-r--r--components/libc/newlib/sys/fcntl.h15
-rw-r--r--components/libc/newlib/sys/statfs.h13
5 files changed, 88 insertions, 8 deletions
diff --git a/components/libc/minilibc/rand.c b/components/libc/minilibc/rand.c
index 46a96ac5bb..d97e91bdba 100644
--- a/components/libc/minilibc/rand.c
+++ b/components/libc/minilibc/rand.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <stdint.h>
#include <sys/types.h>
static unsigned int seed=1;
diff --git a/components/libc/minilibc/sys/types.h b/components/libc/minilibc/sys/types.h
index 2be1f34403..fa0a236636 100644
--- a/components/libc/minilibc/sys/types.h
+++ b/components/libc/minilibc/sys/types.h
@@ -3,7 +3,7 @@
#include <rtthread.h>
-typedef rt_off_t off_t;
+typedef long off_t;
typedef rt_size_t size_t;
typedef rt_uint8_t u_char;
@@ -11,14 +11,8 @@ typedef rt_uint16_t u_short;
typedef rt_ubase_t u_int;
typedef rt_uint32_t u_long;
-typedef rt_uint8_t u_int8_t;
-typedef rt_uint16_t u_int16_t;
-typedef rt_uint32_t u_int32_t;
-typedef rt_int8_t int8_t;
-typedef rt_int16_t int16_t;
-typedef rt_int32_t int32_t;
-
typedef rt_time_t time_t;
+typedef int mode_t;
#ifndef NULL
#define NULL RT_NULL
diff --git a/components/libc/newlib/sys/dirent.h b/components/libc/newlib/sys/dirent.h
new file mode 100644
index 0000000000..18c5d02e11
--- /dev/null
+++ b/components/libc/newlib/sys/dirent.h
@@ -0,0 +1,57 @@
+#ifndef __RTT_DIRENT_H__
+#define __RTT_DIRENT_H__
+
+#include <rtthread.h>
+
+/*
+* dirent.h - format of directory entries
+ * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
+ */
+
+/* File types */
+#define FT_REGULAR 0 /* regular file */
+#define FT_SOCKET 1 /* socket file */
+#define FT_DIRECTORY 2 /* directory */
+#define FT_USER 3 /* user defined */
+
+#define DT_UNKNOWN 0x00
+#define DT_REG 0x01
+#define DT_DIR 0x02
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef HAVE_DIR_STRUCTURE
+typedef struct
+{
+ int fd; /* directory file */
+ char buf[512];
+ int num;
+ int cur;
+} DIR;
+#endif
+
+#ifndef HAVE_DIRENT_STRUCTURE
+struct dirent
+{
+ rt_uint8_t d_type; /* The type of the file */
+ rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */
+ rt_uint16_t d_reclen; /* length of this record */
+ char d_name[256]; /* The null-terminated file name */
+};
+#endif
+
+int closedir(DIR *);
+DIR *opendir(const char *);
+struct dirent *readdir(DIR *);
+int readdir_r(DIR *, struct dirent *, struct dirent **);
+void rewinddir(DIR *);
+void seekdir(DIR *, long int);
+long telldir(DIR *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/libc/newlib/sys/fcntl.h b/components/libc/newlib/sys/fcntl.h
new file mode 100644
index 0000000000..3638029eb2
--- /dev/null
+++ b/components/libc/newlib/sys/fcntl.h
@@ -0,0 +1,15 @@
+#ifndef __RTT_FCNTL_H__
+#define __RTT_FCNTL_H__
+
+/* Operation flags */
+#define O_RDONLY 0000000
+#define O_WRONLY 0000001
+#define O_RDWR 0000002
+#define O_ACCMODE 0000003
+#define O_CREAT 0000100
+#define O_EXCL 0000200
+#define O_TRUNC 0001000
+#define O_APPEND 0002000
+#define O_DIRECTORY 0200000
+
+#endif
diff --git a/components/libc/newlib/sys/statfs.h b/components/libc/newlib/sys/statfs.h
new file mode 100644
index 0000000000..c3bc9be359
--- /dev/null
+++ b/components/libc/newlib/sys/statfs.h
@@ -0,0 +1,13 @@
+#ifndef __RTT_STATFS_H__
+#define __RTT_STATFS_H__
+
+#include <rtthread.h>
+
+struct statfs
+{
+ rt_size_t f_bsize; /* block size */
+ rt_size_t f_blocks; /* total data blocks in file system */
+ rt_size_t f_bfree; /* free blocks in file system */
+};
+
+#endif