[LIBC] fix compiling issue for dlib (IAR).
This commit is contained in:
parent
622e6d8238
commit
2c88533659
|
@ -11,6 +11,8 @@ if GetDepend('RT_USING_LIBC'):
|
|||
objs = objs + SConscript('newlib/SConscript')
|
||||
elif rtconfig.PLATFORM == 'armcc':
|
||||
objs = objs + SConscript('armlibc/SConscript')
|
||||
elif rtconfig.PLATFORM == 'iar':
|
||||
objs = objs + SConscript('dlib/SConscript')
|
||||
else:
|
||||
if rtconfig.PLATFORM == 'gcc':
|
||||
objs = objs + SConscript('minilibc/SConscript')
|
||||
|
|
|
@ -10,6 +10,6 @@ CPPDEFINES = ['RT_USING_DLIBC']
|
|||
|
||||
if rtconfig.PLATFORM == 'iar':
|
||||
group = DefineGroup('dlib', src, depend = ['RT_USING_LIBC'],
|
||||
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
|
||||
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
*/
|
||||
|
||||
#if _DLIB_THREAD_SUPPORT
|
||||
typedef void* _Rmtx;
|
||||
void _Mtxinit(_Rmtx *m)
|
||||
{
|
||||
rt_mutex_t mutex;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* File : syscall_close.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 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-01-28 Bernard first version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
#include <yfuns.h>
|
||||
|
||||
#pragma module_name = "?__close"
|
||||
int __close(int handle)
|
||||
{
|
||||
if (handle == _LLIO_STDOUT ||
|
||||
handle == _LLIO_STDERR ||
|
||||
handle == _LLIO_STDIN)
|
||||
return _LLIO_ERROR;
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
return close(handle);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* File : syscalls.c
|
||||
* File : syscall_lseek.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||
*
|
||||
|
@ -23,46 +23,21 @@
|
|||
*/
|
||||
#include <rtthread.h>
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_file.h>
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
#include <yfuns.h>
|
||||
|
||||
#pragma module_name = "?__close"
|
||||
int __close(int handle)
|
||||
{
|
||||
if (handle == _LLIO_STDOUT ||
|
||||
handle == _LLIO_STDERR ||
|
||||
handle == _LLIO_STDIN)
|
||||
return _LLIO_ERROR;
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
return close(handle);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma module_name = "?remove"
|
||||
int remove(const char *val)
|
||||
{
|
||||
#ifdef RT_USING_DFS
|
||||
dfs_file_unlink(val);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma module_name = "?__lseek"
|
||||
long __lseek(int handle, long offset, int whence)
|
||||
{
|
||||
#ifdef RT_USING_DFS
|
||||
#endif
|
||||
|
||||
if (handle == _LLIO_STDOUT ||
|
||||
handle == _LLIO_STDERR ||
|
||||
handle == _LLIO_STDIN)
|
||||
return _LLIO_ERROR;
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
return lseek(handle, offset, whence);
|
||||
#else
|
||||
return _LLIO_ERROR;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* File : syscall_mem.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 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-01-28 Bernard first version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
|
||||
void *malloc(rt_size_t n)
|
||||
{
|
||||
return rt_malloc(n);
|
||||
}
|
||||
|
||||
void *realloc(void *rmem, rt_size_t newsize)
|
||||
{
|
||||
return rt_realloc(rmem, newsize);
|
||||
}
|
||||
|
||||
void *calloc(rt_size_t nelem, rt_size_t elsize)
|
||||
{
|
||||
return rt_calloc(nelem, elsize);
|
||||
}
|
||||
|
||||
void free(void *rmem)
|
||||
{
|
||||
rt_free(rmem);
|
||||
}
|
|
@ -1,26 +1,26 @@
|
|||
/*
|
||||
* File : syscall_open.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 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-01-28 Bernard first version
|
||||
*/
|
||||
* File : syscall_open.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 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-01-28 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <yfuns.h>
|
||||
|
@ -32,33 +32,57 @@
|
|||
|
||||
int __open(const char *filename, int mode)
|
||||
{
|
||||
if (mode & _LLIO_CREAT)
|
||||
#ifndef RT_USING_DFS
|
||||
return -1;
|
||||
#else
|
||||
int handle;
|
||||
int open_mode = O_RDONLY;
|
||||
|
||||
if (mode & _LLIO_CREAT)
|
||||
{
|
||||
open_mode |= O_CREAT;
|
||||
|
||||
/* Check what we should do with it if it exists. */
|
||||
if (mode & _LLIO_APPEND)
|
||||
{
|
||||
/* Append to the existing file. */
|
||||
open_mode |= O_APPEND;
|
||||
}
|
||||
|
||||
if (mode & _LLIO_TEXT)
|
||||
if (mode & _LLIO_TRUNC)
|
||||
{
|
||||
/* we didn't support text mode */
|
||||
/* Truncate the existsing file. */
|
||||
open_mode |= O_TRUNC;
|
||||
}
|
||||
|
||||
switch (mode & _LLIO_RDWRMASK)
|
||||
{
|
||||
}
|
||||
|
||||
if (mode & _LLIO_TEXT)
|
||||
{
|
||||
/* we didn't support text mode */
|
||||
}
|
||||
|
||||
switch (mode & _LLIO_RDWRMASK)
|
||||
{
|
||||
case _LLIO_RDONLY:
|
||||
/* The file should be opened for read only. */
|
||||
break;
|
||||
|
||||
|
||||
case _LLIO_WRONLY:
|
||||
/* The file should be opened for write only. */
|
||||
open_mode |= O_WRONLY;
|
||||
break;
|
||||
|
||||
|
||||
case _LLIO_RDWR:
|
||||
/* The file should be opened for both reads and writes. */
|
||||
open_mode |= O_RDWR;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return handle;
|
||||
|
||||
handle = open(filename, open_mode, 0);
|
||||
if (handle < 0)
|
||||
return -1;
|
||||
|
||||
return handle + _LLIO_STDERR + 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
#include <yfuns.h>
|
||||
|
||||
#pragma module_name = "?__read"
|
||||
|
@ -44,8 +47,7 @@ size_t __read(int handle, unsigned char *buf, size_t len)
|
|||
#ifndef RT_USING_DFS
|
||||
return _LLIO_ERROR;
|
||||
#else
|
||||
size = read(handle - STDERR - 1, buf, len);
|
||||
size = read(handle - _LLIO_STDERR - 1, buf, len);
|
||||
return size;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* File : syscall_remove.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 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-01-28 Bernard first version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_file.h>
|
||||
#endif
|
||||
#include <yfuns.h>
|
||||
|
||||
#pragma module_name = "?remove"
|
||||
int remove(const char *val)
|
||||
{
|
||||
#ifdef RT_USING_DFS
|
||||
dfs_file_unlink(val);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -23,6 +23,9 @@
|
|||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
#include <yfuns.h>
|
||||
|
||||
#pragma module_name = "?__write"
|
||||
|
@ -47,12 +50,12 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (handle == STDIN) return -1;
|
||||
if (handle == _LLIO_STDIN) return -1;
|
||||
|
||||
#ifndef RT_USING_DFS
|
||||
return _LLIO_ERROR;
|
||||
#else
|
||||
size = write(handle - STDERR - 1, buf, len);
|
||||
size = write(handle - _LLIO_STDERR - 1, buf, len);
|
||||
return size;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue