[LIBC] mv pthreads/libdl to libc and rename dfs_lwip to dfs_net

This commit is contained in:
Bernard Xiong 2016-05-10 09:22:01 +08:00
parent eb320a0104
commit 64feef0dde
41 changed files with 69 additions and 53 deletions

View File

@ -6,6 +6,6 @@ cwd = GetCurrentDir()
src = Glob('*.c') src = Glob('*.c')
CPPPATH = [cwd] CPPPATH = [cwd]
group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_LWIP'], CPPPATH = CPPPATH) group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_NET'], CPPPATH = CPPPATH)
Return('group') Return('group')

View File

@ -1,7 +1,7 @@
/* /*
* File : dfs_lwip.c * File : dfs_net.c
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team * COPYRIGHT (C) 2015-2016, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,15 +20,16 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2015-02-17 Bernard First version * 2015-02-17 Bernard First version
* 2016-05-07 Bernard Rename dfs_lwip to dfs_net
*/ */
#include <rtthread.h> #include <rtthread.h>
#include <dfs.h> #include <dfs.h>
#include <dfs_fs.h> #include <dfs_fs.h>
#include "dfs_lwip.h" #include "dfs_net.h"
int dfs_lwip_getsocket(int fd) int dfs_net_getsocket(int fd)
{ {
struct dfs_fd *_dfs_fd; struct dfs_fd *_dfs_fd;
@ -40,12 +41,12 @@ int dfs_lwip_getsocket(int fd)
return (int)_dfs_fd->data; return (int)_dfs_fd->data;
} }
int dfs_lwip_ioctl(struct dfs_fd* file, int cmd, void* args) int dfs_net_ioctl(struct dfs_fd* file, int cmd, void* args)
{ {
return -DFS_STATUS_EIO; return -DFS_STATUS_EIO;
} }
int dfs_lwip_read(struct dfs_fd* file, void *buf, rt_size_t count) int dfs_net_read(struct dfs_fd* file, void *buf, rt_size_t count)
{ {
int sock; int sock;
@ -55,7 +56,7 @@ int dfs_lwip_read(struct dfs_fd* file, void *buf, rt_size_t count)
return count; return count;
} }
int dfs_lwip_write(struct dfs_fd *file, const void *buf, rt_size_t count) int dfs_net_write(struct dfs_fd *file, const void *buf, rt_size_t count)
{ {
int sock; int sock;
@ -65,7 +66,7 @@ int dfs_lwip_write(struct dfs_fd *file, const void *buf, rt_size_t count)
return count; return count;
} }
int dfs_lwip_close(struct dfs_fd* file) int dfs_net_close(struct dfs_fd* file)
{ {
int sock; int sock;
int result; int result;
@ -78,9 +79,9 @@ int dfs_lwip_close(struct dfs_fd* file)
return -result; return -result;
} }
static const struct dfs_filesystem_operation _lwip_fs_ops = static const struct dfs_filesystem_operation _net_fs_ops =
{ {
"lwip", "net",
DFS_FS_FLAG_DEFAULT, DFS_FS_FLAG_DEFAULT,
RT_NULL, /* mount */ RT_NULL, /* mount */
RT_NULL, /* unmont */ RT_NULL, /* unmont */
@ -88,10 +89,10 @@ static const struct dfs_filesystem_operation _lwip_fs_ops =
RT_NULL, /* statfs */ RT_NULL, /* statfs */
RT_NULL, /* open */ RT_NULL, /* open */
dfs_lwip_close, dfs_net_close,
dfs_lwip_ioctl, dfs_net_ioctl,
dfs_lwip_read, dfs_net_read,
dfs_lwip_write, dfs_net_write,
RT_NULL, RT_NULL,
RT_NULL, /* lseek */ RT_NULL, /* lseek */
RT_NULL, /* getdents */ RT_NULL, /* getdents */
@ -100,28 +101,28 @@ static const struct dfs_filesystem_operation _lwip_fs_ops =
RT_NULL, /* rename */ RT_NULL, /* rename */
}; };
static struct dfs_filesystem _lwip_fs = static struct dfs_filesystem _net_fs =
{ {
0, /* dev_id */ 0, /* dev_id */
RT_NULL, /* path */ RT_NULL, /* path */
&_lwip_fs_ops, &_net_fs_ops,
RT_NULL /* data */ RT_NULL /* data */
}; };
struct dfs_filesystem* dfs_lwip_get_fs(void) struct dfs_filesystem* dfs_net_get_fs(void)
{ {
return &_lwip_fs; return &_net_fs;
} }
/* /*
NOTE: Beause we don't need to mount lwIP file system, the filesystem_ops is not NOTE: Beause we don't need to mount lwIP file system, the filesystem_ops is not
registered to the system. registered to the system.
int dfs_lwip_system_init(void) int dfs_net_system_init(void)
{ {
dfs_register(&_lwip_fs_ops); dfs_register(&_net_fs_ops);
return 0; return 0;
} }
INIT_FS_EXPORT(dfs_lwip_system_init); INIT_FS_EXPORT(dfs_net_system_init);
*/ */

View File

@ -1,7 +1,7 @@
/* /*
* File : dfs_lwip.h * File : dfs_net.h
* This file is part of RT-Thread RTOS * This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team * COPYRIGHT (C) 2015-2016, RT-Thread Development Team
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,10 +20,11 @@
* Change Logs: * Change Logs:
* Date Author Notes * Date Author Notes
* 2015-02-17 Bernard First version * 2015-02-17 Bernard First version
* 2016-05-05 Bernard rename dfs_lwip to dfs_net.
*/ */
#ifndef DFS_LWIP_H__ #ifndef DFS_NET_H__
#define DFS_LWIP_H__ #define DFS_NET_H__
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -31,10 +32,10 @@ extern "C" {
#include <lwip/sockets.h> #include <lwip/sockets.h>
struct dfs_filesystem* dfs_lwip_get_fs(void); struct dfs_filesystem* dfs_net_get_fs(void);
int dfs_lwip_getsocket(int fd); int dfs_net_getsocket(int fd);
int dfs_lwip_system_init(void); int dfs_net_system_init(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -27,7 +27,7 @@
#ifdef RT_USING_LWIP #ifdef RT_USING_LWIP
#include "dfs_lwip.h" #include "dfs_net.h"
int int
select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
@ -48,7 +48,7 @@ select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
for (index = 0; index < maxfdp1; index ++) for (index = 0; index < maxfdp1; index ++)
{ {
/* convert fd to sock */ /* convert fd to sock */
sock = dfs_lwip_getsocket(index); sock = dfs_net_getsocket(index);
if (sock == -1) continue; if (sock == -1) continue;
if (sock > maxfd) maxfd = sock; if (sock > maxfd) maxfd = sock;

View File

@ -28,12 +28,12 @@
#include <sys/socket.h> #include <sys/socket.h>
#include "dfs_lwip.h" #include "dfs_net.h"
int accept(int s, struct sockaddr *addr, socklen_t *addrlen) int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{ {
int new_client = -1; int new_client = -1;
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
new_client = lwip_accept(sock, addr, addrlen); new_client = lwip_accept(sock, addr, addrlen);
if (new_client != -1) if (new_client != -1)
@ -58,7 +58,7 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
d->type = FT_SOCKET; d->type = FT_SOCKET;
d->path = RT_NULL; d->path = RT_NULL;
d->fs = dfs_lwip_get_fs(); d->fs = dfs_net_get_fs();
d->flags = DFS_O_RDWR; /* set flags as read and write */ d->flags = DFS_O_RDWR; /* set flags as read and write */
d->size = 0; d->size = 0;
@ -79,7 +79,7 @@ RTM_EXPORT(accept);
int bind(int s, const struct sockaddr *name, socklen_t namelen) int bind(int s, const struct sockaddr *name, socklen_t namelen)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_bind(sock, name, namelen); return lwip_bind(sock, name, namelen);
} }
@ -98,7 +98,7 @@ int shutdown(int s, int how)
return -1; return -1;
} }
sock = dfs_lwip_getsocket(s); sock = dfs_net_getsocket(s);
if (lwip_shutdown(sock, how) == 0) if (lwip_shutdown(sock, how) == 0)
{ {
/* socket has been closed, delete it from file system fd */ /* socket has been closed, delete it from file system fd */
@ -114,7 +114,7 @@ RTM_EXPORT(shutdown);
int getpeername(int s, struct sockaddr *name, socklen_t *namelen) int getpeername(int s, struct sockaddr *name, socklen_t *namelen)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_getpeername(sock, name, namelen); return lwip_getpeername(sock, name, namelen);
} }
@ -122,7 +122,7 @@ RTM_EXPORT(getpeername);
int getsockname(int s, struct sockaddr *name, socklen_t *namelen) int getsockname(int s, struct sockaddr *name, socklen_t *namelen)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_getsockname(sock, name, namelen); return lwip_getsockname(sock, name, namelen);
} }
@ -130,7 +130,7 @@ RTM_EXPORT(getsockname);
int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_getsockopt(sock, level, optname, optval, optlen); return lwip_getsockopt(sock, level, optname, optval, optlen);
} }
@ -138,7 +138,7 @@ RTM_EXPORT(getsockopt);
int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_setsockopt(sock, level, optname, optval, optlen); return lwip_setsockopt(sock, level, optname, optval, optlen);
} }
@ -146,7 +146,7 @@ RTM_EXPORT(setsockopt);
int connect(int s, const struct sockaddr *name, socklen_t namelen) int connect(int s, const struct sockaddr *name, socklen_t namelen)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_connect(sock, name, namelen); return lwip_connect(sock, name, namelen);
} }
@ -154,7 +154,7 @@ RTM_EXPORT(connect);
int listen(int s, int backlog) int listen(int s, int backlog)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_listen(sock, backlog); return lwip_listen(sock, backlog);
} }
@ -162,7 +162,7 @@ RTM_EXPORT(listen);
int recv(int s, void *mem, size_t len, int flags) int recv(int s, void *mem, size_t len, int flags)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_recv(sock, mem, len, flags); return lwip_recv(sock, mem, len, flags);
} }
@ -171,7 +171,7 @@ RTM_EXPORT(recv);
int recvfrom(int s, void *mem, size_t len, int flags, int recvfrom(int s, void *mem, size_t len, int flags,
struct sockaddr *from, socklen_t *fromlen) struct sockaddr *from, socklen_t *fromlen)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_recvfrom(sock, mem, len, flags, from, fromlen); return lwip_recvfrom(sock, mem, len, flags, from, fromlen);
} }
@ -179,7 +179,7 @@ RTM_EXPORT(recvfrom);
int send(int s, const void *dataptr, size_t size, int flags) int send(int s, const void *dataptr, size_t size, int flags)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_send(sock, dataptr, size, flags); return lwip_send(sock, dataptr, size, flags);
} }
@ -188,7 +188,7 @@ RTM_EXPORT(send);
int sendto(int s, const void *dataptr, size_t size, int flags, int sendto(int s, const void *dataptr, size_t size, int flags,
const struct sockaddr *to, socklen_t tolen) const struct sockaddr *to, socklen_t tolen)
{ {
int sock = dfs_lwip_getsocket(s); int sock = dfs_net_getsocket(s);
return lwip_sendto(sock, dataptr, size, flags, to, tolen); return lwip_sendto(sock, dataptr, size, flags, to, tolen);
} }

View File

@ -17,4 +17,7 @@ else:
if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim': if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim':
objs = objs + SConscript('minilibc/SConscript') objs = objs + SConscript('minilibc/SConscript')
objs = objs + SConscript('pthreads/SConscript')
objs = objs + SConscript('libdl/SConscript')
Return('objs') Return('objs')

View File

@ -1,9 +1,9 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import * from building import *
src = Glob('*.c') src = Glob('*.c')
CPPPATH = [RTT_ROOT + '/components/libdl'] cwd = GetCurrentDir()
CPPPATH = [cwd]
group = DefineGroup('libdl', src, depend = ['RT_USING_MODULE', 'RT_USING_LIBDL'], CPPPATH = CPPPATH) group = DefineGroup('libdl', src, depend = ['RT_USING_MODULE', 'RT_USING_LIBDL'], CPPPATH = CPPPATH)
Return('group') Return('group')

View File

@ -450,5 +450,15 @@ void __libc_init_array(void)
void abort(void) void abort(void)
{ {
return ; if (rt_thread_self())
{
rt_thread_t self = rt_thread_self();
rt_kprintf("thread:%-8.*s abort!\n", RT_NAME_MAX, self->name);
rt_thread_suspend(self);
rt_schedule();
}
while (1);
} }

View File

@ -1,8 +1,9 @@
Import('RTT_ROOT')
from building import * from building import *
cwd = GetCurrentDir()
src = Glob('*.c') src = Glob('*.c')
CPPPATH = [RTT_ROOT + '/components/pthreads'] CPPPATH = [cwd]
group = DefineGroup('pthreads', src, depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH) group = DefineGroup('pthreads', src, depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH)
Return('group') Return('group')

View File

@ -76,7 +76,7 @@ typedef rt_uint32_t mem_ptr_t;
#define LWIP_TIMEVAL_PRIVATE 1 #define LWIP_TIMEVAL_PRIVATE 1
#endif #endif
#if defined(RT_USING_DFS_LWIP) #if defined(RT_USING_DFS_NET)
#define LWIP_COMPAT_SOCKETS 0 #define LWIP_COMPAT_SOCKETS 0
#endif #endif