浏览代码

[pthreads] The pthread component is depended to libc component.

Bernard Xiong 10 年之前
父节点
当前提交
1f52f79d0b
共有 2 个文件被更改,包括 9 次插入77 次删除
  1. 1 1
      components/pthreads/SConscript
  2. 8 76
      components/pthreads/posix_types.h

+ 1 - 1
components/pthreads/SConscript

@@ -3,6 +3,6 @@ from building import *
 
 src	= Glob('*.c')
 CPPPATH = [RTT_ROOT + '/components/pthreads']
-group = DefineGroup('pthreads', src, depend = ['RT_USING_PTHREADS'], CPPPATH = CPPPATH)
+group = DefineGroup('pthreads', src, depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH)
 
 Return('group')

+ 8 - 76
components/pthreads/posix_types.h

@@ -27,90 +27,22 @@
 
 #include <rtthread.h>
 
-/* compatible in different compiler and C runtime library */
-#ifdef RT_USING_NEWLIB
-/* normarlly, GNU GCC will use newlib as C runtime library */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/signal.h>
-#include <sys/fcntl.h>
-
-#include <errno.h>
-#include <stdarg.h>
-
-#ifndef ESHUTDOWN
-#define ESHUTDOWN 180
-#endif
-
-#else
-
-/* ARM compiler and IAR compiler */
-#if defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__)   
 #include <stddef.h>
 #include <stdarg.h>
 #include <string.h>
 
-typedef rt_int32_t clockid_t;
-typedef rt_int32_t key_t;       /* Used for interprocess communication. */
-typedef rt_int32_t pid_t;       /* Used for process IDs and process group IDs. */
-typedef signed long ssize_t;    /* Used for a count of bytes or an error indication. */
-typedef signed long time_t;     /* Used for time in seconds. */
-
-struct timespec
-{
-    time_t tv_sec;          /* seconds */
-    long tv_nsec;           /* nanoseconds */
-};
-
-struct timeval
-{
-    long    tv_sec;         /* seconds */
-    long    tv_usec;        /* microseconds */
-};
-
-#ifdef RT_USING_LWIP
-#include <lwip/arch.h>
-#else
-#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 EBADF        9  /* Bad file number */
-#define EAGAIN      11  /* Try again */
-#define ENOMEM      12  /* Out of memory */
-#define EBUSY       16  /* Device or resource busy */
-#define EEXIST      17  /* File exists */
-#define EINVAL      22  /* Invalid argument */
-#define ENFILE      23  /* File table overflow */
-#define EDEADLK     45  /* Resource deadlock would occur */
-#define EBADMSG     77  /* Not a data message */
-#define ENOSYS      89  /* Function not implemented */
-#define EOPNOTSUPP  122 /* Operation not supported on transport endpoint */
-#define ETIMEDOUT   145 /* Connection timed out */
-#endif
+#include <sys/types.h>
+#include <sys/time.h>
 
-#ifdef RT_USING_DFS
-#include <dfs_posix.h>
+/* errno for Keil MDK */
+#if defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__)
+#include <sys/errno.h>
+#include <sys/unistd.h>
 #else
-typedef rt_uint16_t mode_t;
-#define O_RDONLY        0x0000000
-#define O_WRONLY        0x0000001
-#define O_RDWR          0x0000002
-#define O_ACCMODE       0x0000003
-#define O_CREAT         0x0000100
-#define O_EXCL          0x0000200
-#define O_TRUNC         0x0001000
-#define O_APPEND        0x0002000
-#define O_DIRECTORY     0x0200000
-#endif
-
-#elif defined (__GNUC__)                    /* GNU GCC Compiler, with minilibc */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <unistd.h>
 #include <errno.h>
+#include <fcntl.h>
 #endif
 
 #endif
 
-#endif