[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')
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')

View File

@ -1,7 +1,7 @@
/*
* File : dfs_lwip.c
* File : dfs_net.c
* 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
* it under the terms of the GNU General Public License as published by
@ -20,15 +20,16 @@
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
* 2016-05-07 Bernard Rename dfs_lwip to dfs_net
*/
#include <rtthread.h>
#include <dfs.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;
@ -40,12 +41,12 @@ int dfs_lwip_getsocket(int fd)
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;
}
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;
@ -55,7 +56,7 @@ int dfs_lwip_read(struct dfs_fd* file, void *buf, rt_size_t 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;
@ -65,7 +66,7 @@ int dfs_lwip_write(struct dfs_fd *file, const void *buf, rt_size_t count)
return count;
}
int dfs_lwip_close(struct dfs_fd* file)
int dfs_net_close(struct dfs_fd* file)
{
int sock;
int result;
@ -78,9 +79,9 @@ int dfs_lwip_close(struct dfs_fd* file)
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,
RT_NULL, /* mount */
RT_NULL, /* unmont */
@ -88,10 +89,10 @@ static const struct dfs_filesystem_operation _lwip_fs_ops =
RT_NULL, /* statfs */
RT_NULL, /* open */
dfs_lwip_close,
dfs_lwip_ioctl,
dfs_lwip_read,
dfs_lwip_write,
dfs_net_close,
dfs_net_ioctl,
dfs_net_read,
dfs_net_write,
RT_NULL,
RT_NULL, /* lseek */
RT_NULL, /* getdents */
@ -100,28 +101,28 @@ static const struct dfs_filesystem_operation _lwip_fs_ops =
RT_NULL, /* rename */
};
static struct dfs_filesystem _lwip_fs =
static struct dfs_filesystem _net_fs =
{
0, /* dev_id */
RT_NULL, /* path */
&_lwip_fs_ops,
&_net_fs_ops,
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
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;
}
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
* 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
* it under the terms of the GNU General Public License as published by
@ -20,10 +20,11 @@
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
* 2016-05-05 Bernard rename dfs_lwip to dfs_net.
*/
#ifndef DFS_LWIP_H__
#define DFS_LWIP_H__
#ifndef DFS_NET_H__
#define DFS_NET_H__
#ifdef __cplusplus
extern "C" {
@ -31,10 +32,10 @@ extern "C" {
#include <lwip/sockets.h>
struct dfs_filesystem* dfs_lwip_get_fs(void);
int dfs_lwip_getsocket(int fd);
struct dfs_filesystem* dfs_net_get_fs(void);
int dfs_net_getsocket(int fd);
int dfs_lwip_system_init(void);
int dfs_net_system_init(void);
#ifdef __cplusplus
}

View File

@ -27,7 +27,7 @@
#ifdef RT_USING_LWIP
#include "dfs_lwip.h"
#include "dfs_net.h"
int
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 ++)
{
/* convert fd to sock */
sock = dfs_lwip_getsocket(index);
sock = dfs_net_getsocket(index);
if (sock == -1) continue;
if (sock > maxfd) maxfd = sock;

View File

@ -28,12 +28,12 @@
#include <sys/socket.h>
#include "dfs_lwip.h"
#include "dfs_net.h"
int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
int new_client = -1;
int sock = dfs_lwip_getsocket(s);
int sock = dfs_net_getsocket(s);
new_client = lwip_accept(sock, addr, addrlen);
if (new_client != -1)
@ -58,7 +58,7 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
d->type = FT_SOCKET;
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->size = 0;
@ -79,7 +79,7 @@ RTM_EXPORT(accept);
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);
}
@ -98,7 +98,7 @@ int shutdown(int s, int how)
return -1;
}
sock = dfs_lwip_getsocket(s);
sock = dfs_net_getsocket(s);
if (lwip_shutdown(sock, how) == 0)
{
/* 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 sock = dfs_lwip_getsocket(s);
int sock = dfs_net_getsocket(s);
return lwip_getpeername(sock, name, namelen);
}
@ -122,7 +122,7 @@ RTM_EXPORT(getpeername);
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);
}
@ -130,7 +130,7 @@ RTM_EXPORT(getsockname);
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);
}
@ -138,7 +138,7 @@ RTM_EXPORT(getsockopt);
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);
}
@ -146,7 +146,7 @@ RTM_EXPORT(setsockopt);
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);
}
@ -154,7 +154,7 @@ RTM_EXPORT(connect);
int listen(int s, int backlog)
{
int sock = dfs_lwip_getsocket(s);
int sock = dfs_net_getsocket(s);
return lwip_listen(sock, backlog);
}
@ -162,7 +162,7 @@ RTM_EXPORT(listen);
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);
}
@ -171,7 +171,7 @@ RTM_EXPORT(recv);
int recvfrom(int s, void *mem, size_t len, int flags,
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);
}
@ -179,7 +179,7 @@ RTM_EXPORT(recvfrom);
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);
}
@ -188,7 +188,7 @@ RTM_EXPORT(send);
int sendto(int s, const void *dataptr, size_t size, int flags,
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);
}

View File

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

View File

@ -1,9 +1,9 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import *
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)
Return('group')

View File

@ -450,5 +450,15 @@ void __libc_init_array(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 *
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [RTT_ROOT + '/components/pthreads']
CPPPATH = [cwd]
group = DefineGroup('pthreads', src, depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH)
Return('group')

View File

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