瀏覽代碼

[DFS] fix the compiling issue under Keil MDK.

Bernard Xiong 10 年之前
父節點
當前提交
854d8866d3

+ 2 - 0
components/dfs/filesystems/lwip/dfs_lwip.h

@@ -29,6 +29,8 @@
 extern "C" {
 #endif
 
+#include <lwip/sockets.h>
+
 struct dfs_filesystem* dfs_lwip_get_fs(void);
 int dfs_lwip_getsocket(int fd);
 

+ 2 - 1
components/dfs/filesystems/lwip/lwip_sockets.c

@@ -24,7 +24,8 @@
 
 #include <dfs.h>
 #include <dfs_def.h>
-#include <lwip/sockets.h>
+#include <dfs_posix.h>
+
 #include <sys/socket.h>
 
 #include "dfs_lwip.h"

+ 46 - 0
components/dfs/filesystems/lwip/sys/select.h

@@ -0,0 +1,46 @@
+/*
+ * File      : select.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2015, RT-Thread Development Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2015-05-02     Bernard      First version
+ */
+
+#ifndef SELECT_H__
+#define SELECT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* select API */
+#ifdef RT_USING_LWIP
+/* we use lwIP's structure definitions. */
+#include <lwip/sockets.h>
+
+int
+select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
+            struct timeval *timeout);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

+ 3 - 1
components/dfs/filesystems/lwip/sys/socket.h

@@ -1,5 +1,5 @@
 /*
- * File      : netdb.h
+ * File      : socket.h
  * This file is part of RT-Thread RTOS
  * COPYRIGHT (C) 2015, RT-Thread Development Team
  *
@@ -29,6 +29,8 @@
 extern "C" {
 #endif
 
+#include <lwip/sockets.h>
+
 int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
 int bind(int s, const struct sockaddr *name, socklen_t namelen);
 int shutdown(int s, int how);

+ 10 - 0
components/dfs/include/dfs_posix.h

@@ -30,6 +30,10 @@
 #include <dfs_file.h>
 #include <dfs_def.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef RT_USING_NEWLIB
 #define O_RDONLY    DFS_O_RDONLY
 #define O_WRONLY    DFS_O_WRONLY
@@ -79,6 +83,7 @@
 
 #if defined(__CC_ARM)
 #include <stdio.h>
+#include <stdlib.h>
 #elif defined(_MSC_VER)
 #include <stdio.h>
 #else
@@ -109,6 +114,8 @@ int closedir(DIR* d);
 #include <sys/stat.h>
 #endif
 
+struct stat;
+
 /* file api*/
 int open(const char *file, int flags, int mode);
 int close(int d);
@@ -126,5 +133,8 @@ int rmdir(const char *path);
 int chdir(const char *path);
 char *getcwd(char *buf, size_t size);
 
+#ifdef __cplusplus
+}
 #endif
 
+#endif

+ 18 - 1
components/net/lwip-1.4.1/src/lwipopts.h

@@ -353,8 +353,25 @@
 #define LWIP_RAND                  rand
 #endif
 
-#ifdef RT_USING_DFS_LWIP
+#if defined(RT_USING_DFS_LWIP)
 #define LWIP_COMPAT_SOCKETS        0
 #endif
 
+#if defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__)
+
+#if defined(RT_USING_PTHREADS)
+#define LWIP_TIMEVAL_PRIVATE       0
+#include <posix_types.h>
+#else
+/* there is no timeval in CC_ARM and IAR */
+#define LWIP_TIMEVAL_PRIVATE       1
+#endif /* RT_USING_PTHREADS */
+
+#elif defined (__GNUC__)
+
+#define LWIP_TIMEVAL_PRIVATE       0
+#include <sys/time.h>
+
+#endif
+
 #endif /* __LWIPOPTS_H__ */