import RT-Thread@9217865c without bsp, libcpu and components/net
This commit is contained in:
commit
e2376a3709
1414 changed files with 390370 additions and 0 deletions
3
components/libc/compilers/dlib/README.md
Normal file
3
components/libc/compilers/dlib/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# DLIB (IAR) porting for RT-Thread
|
||||
|
||||
http://www.iarsys.co.jp/download/LMS2/arm/7502/ewarm7502doc/arm/doc/EWARM_DevelopmentGuide.ENU.pdf P.130
|
21
components/libc/compilers/dlib/SConscript
Normal file
21
components/libc/compilers/dlib/SConscript
Normal file
|
@ -0,0 +1,21 @@
|
|||
from building import *
|
||||
Import('rtconfig')
|
||||
|
||||
src = Glob('*.c')
|
||||
group = []
|
||||
|
||||
if rtconfig.PLATFORM in ['iccarm']:
|
||||
CPPDEFINES = ['RT_USING_DLIBC', 'RT_USING_LIBC', '_DLIB_ADD_EXTRA_SYMBOLS=0']
|
||||
AddDepend(['RT_USING_DLIBC', 'RT_USING_LIBC'])
|
||||
|
||||
if GetDepend('DFS_USING_POSIX'):
|
||||
from distutils.version import LooseVersion
|
||||
from iar import IARVersion
|
||||
|
||||
CPPDEFINES = CPPDEFINES + ['_DLIB_FILE_DESCRIPTOR']
|
||||
if LooseVersion(IARVersion()) < LooseVersion("8.20.1"):
|
||||
CPPDEFINES = CPPDEFINES + ['_DLIB_THREAD_SUPPORT']
|
||||
|
||||
group = DefineGroup('Compiler', src, depend = [''], CPPDEFINES = CPPDEFINES)
|
||||
|
||||
Return('group')
|
12
components/libc/compilers/dlib/environ.c
Normal file
12
components/libc/compilers/dlib/environ.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-01-28 Bernard first version
|
||||
*/
|
||||
|
||||
const char *__environ = "OS=RT-Thread";
|
||||
|
38
components/libc/compilers/dlib/syscall_close.c
Normal file
38
components/libc/compilers/dlib/syscall_close.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-01-28 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <LowLevelIOInterface.h>
|
||||
#include <unistd.h>
|
||||
#include <compiler_private.h>
|
||||
#define DBG_TAG "dlib.syscall.close"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*
|
||||
* The "__close" function should close the file corresponding to
|
||||
* "handle". It should return 0 on success and nonzero on failure.
|
||||
*/
|
||||
|
||||
#pragma module_name = "?__close"
|
||||
|
||||
int __close(int handle)
|
||||
{
|
||||
if (handle == _LLIO_STDOUT ||
|
||||
handle == _LLIO_STDERR ||
|
||||
handle == _LLIO_STDIN)
|
||||
return _LLIO_ERROR;
|
||||
#ifdef DFS_USING_POSIX
|
||||
return close(handle);
|
||||
#else
|
||||
LOG_W(_WARNING_WITHOUT_FS);
|
||||
return _LLIO_ERROR;
|
||||
#endif /* DFS_USING_POSIX */
|
||||
}
|
47
components/libc/compilers/dlib/syscall_lseek.c
Normal file
47
components/libc/compilers/dlib/syscall_lseek.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-01-28 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <LowLevelIOInterface.h>
|
||||
#include <unistd.h>
|
||||
#include <compiler_private.h>
|
||||
#define DBG_TAG "dlib.syscall.lseek"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*
|
||||
* The "__lseek" function makes the next file operation (__read or
|
||||
* __write) act on a new location. The parameter "whence" specifies
|
||||
* how the "offset" parameter should be interpreted according to the
|
||||
* following table:
|
||||
*
|
||||
* 0 (=SEEK_SET) - Goto location "offset".
|
||||
* 1 (=SEEK_CUR) - Go "offset" bytes from the current location.
|
||||
* 2 (=SEEK_END) - Go to "offset" bytes from the end.
|
||||
*
|
||||
* This function should return the current file position, or -1 on
|
||||
* failure.
|
||||
*/
|
||||
|
||||
#pragma module_name = "?__lseek"
|
||||
|
||||
long __lseek(int handle, long offset, int whence)
|
||||
{
|
||||
if (handle == _LLIO_STDOUT ||
|
||||
handle == _LLIO_STDERR ||
|
||||
handle == _LLIO_STDIN)
|
||||
return _LLIO_ERROR;
|
||||
#ifdef DFS_USING_POSIX
|
||||
return lseek(handle, offset, whence);
|
||||
#else
|
||||
LOG_W(_WARNING_WITHOUT_FS);
|
||||
return _LLIO_ERROR;
|
||||
#endif /* DFS_USING_POSIX */
|
||||
}
|
61
components/libc/compilers/dlib/syscall_mem.c
Normal file
61
components/libc/compilers/dlib/syscall_mem.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-01-28 Bernard first version
|
||||
* 2021-11-13 Meco Man implement no-heap warning
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef RT_USING_HEAP
|
||||
#define DBG_TAG "dlib.syscall.mem"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
#define _NO_HEAP_ERROR() do{LOG_E("Please enable RT_USING_HEAP");\
|
||||
RT_ASSERT(0);\
|
||||
}while(0)
|
||||
#endif /* RT_USING_HEAP */
|
||||
|
||||
void *malloc(size_t n)
|
||||
{
|
||||
#ifdef RT_USING_HEAP
|
||||
return rt_malloc(n);
|
||||
#else
|
||||
_NO_HEAP_ERROR();
|
||||
return RT_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *realloc(void *rmem, size_t newsize)
|
||||
{
|
||||
#ifdef RT_USING_HEAP
|
||||
return rt_realloc(rmem, newsize);
|
||||
#else
|
||||
_NO_HEAP_ERROR();
|
||||
return RT_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *calloc(size_t nelem, size_t elsize)
|
||||
{
|
||||
#ifdef RT_USING_HEAP
|
||||
return rt_calloc(nelem, elsize);
|
||||
#else
|
||||
_NO_HEAP_ERROR();
|
||||
return RT_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void free(void *rmem)
|
||||
{
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_free(rmem);
|
||||
#else
|
||||
_NO_HEAP_ERROR();
|
||||
#endif
|
||||
}
|
83
components/libc/compilers/dlib/syscall_open.c
Normal file
83
components/libc/compilers/dlib/syscall_open.c
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-01-28 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <LowLevelIOInterface.h>
|
||||
#include <fcntl.h>
|
||||
#include <compiler_private.h>
|
||||
#define DBG_TAG "dlib.syscall.open"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*
|
||||
* The "__open" function opens the file named "filename" as specified
|
||||
* by "mode".
|
||||
*/
|
||||
|
||||
#pragma module_name = "?__open"
|
||||
|
||||
int __open(const char *filename, int mode)
|
||||
{
|
||||
#ifdef DFS_USING_POSIX
|
||||
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_TRUNC)
|
||||
{
|
||||
/* Truncate the existsing file. */
|
||||
open_mode |= O_TRUNC;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode & _LLIO_TEXT)
|
||||
{
|
||||
/* we didn't support text mode */
|
||||
}
|
||||
|
||||
switch (mode & _LLIO_RDWRMASK)
|
||||
{
|
||||
case _LLIO_RDONLY:
|
||||
break;
|
||||
|
||||
case _LLIO_WRONLY:
|
||||
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 _LLIO_ERROR;
|
||||
}
|
||||
|
||||
handle = open(filename, open_mode, 0);
|
||||
if (handle < 0)
|
||||
{
|
||||
return _LLIO_ERROR;
|
||||
}
|
||||
return handle;
|
||||
#else
|
||||
LOG_W(_WARNING_WITHOUT_FS);
|
||||
return _LLIO_ERROR;
|
||||
#endif /* DFS_USING_POSIX */
|
||||
}
|
65
components/libc/compilers/dlib/syscall_read.c
Normal file
65
components/libc/compilers/dlib/syscall_read.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-01-28 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <LowLevelIOInterface.h>
|
||||
#include <unistd.h>
|
||||
#ifdef RT_USING_POSIX_STDIO
|
||||
#include "libc.h"
|
||||
#endif /* RT_USING_POSIX_STDIO */
|
||||
#include <compiler_private.h>
|
||||
#define DBG_TAG "dlib.syscall.read"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*
|
||||
* The "__read" function reads a number of bytes, at most "size" into
|
||||
* the memory area pointed to by "buffer". It returns the number of
|
||||
* bytes read, 0 at the end of the file, or _LLIO_ERROR if failure
|
||||
* occurs.
|
||||
*
|
||||
* The template implementation below assumes that the application
|
||||
* provides the function "MyLowLevelGetchar". It should return a
|
||||
* character value, or -1 on failure.
|
||||
*/
|
||||
|
||||
#pragma module_name = "?__read"
|
||||
|
||||
size_t __read(int handle, unsigned char *buf, size_t len)
|
||||
{
|
||||
#ifdef DFS_USING_POSIX
|
||||
int size;
|
||||
|
||||
if (handle == _LLIO_STDIN)
|
||||
{
|
||||
#ifdef RT_USING_POSIX_STDIO
|
||||
if (libc_stdio_get_console() < 0)
|
||||
{
|
||||
LOG_W("Do not invoke standard input before initializing Compiler");
|
||||
return 0; /* error, but keep going */
|
||||
}
|
||||
return read(STDIN_FILENO, buf, len); /* return the length of the data read */
|
||||
#else
|
||||
LOG_W(_WARNING_WITHOUT_STDIO);
|
||||
return _LLIO_ERROR;
|
||||
#endif /* RT_USING_POSIX_STDIO */
|
||||
}
|
||||
else if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
|
||||
{
|
||||
return _LLIO_ERROR;
|
||||
}
|
||||
|
||||
size = read(handle, buf, len);
|
||||
return size; /* return the length of the data read */
|
||||
#else
|
||||
LOG_W(_WARNING_WITHOUT_FS);
|
||||
return _LLIO_ERROR;
|
||||
#endif /* DFS_USING_POSIX */
|
||||
}
|
34
components/libc/compilers/dlib/syscall_remove.c
Normal file
34
components/libc/compilers/dlib/syscall_remove.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-01-28 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <LowLevelIOInterface.h>
|
||||
#include <unistd.h>
|
||||
#include <compiler_private.h>
|
||||
#define DBG_TAG "dlib.syscall.remove"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*
|
||||
* The "remove" function should remove the file named "filename". It
|
||||
* should return 0 on success and nonzero on failure.
|
||||
*/
|
||||
|
||||
#pragma module_name = "?remove"
|
||||
|
||||
int remove(const char *filename)
|
||||
{
|
||||
#ifdef DFS_USING_POSIX
|
||||
return unlink(filename);
|
||||
#else
|
||||
LOG_W(_WARNING_WITHOUT_FS);
|
||||
return _LLIO_ERROR;
|
||||
#endif /* DFS_USING_POSIX */
|
||||
}
|
71
components/libc/compilers/dlib/syscall_write.c
Normal file
71
components/libc/compilers/dlib/syscall_write.c
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-01-28 Bernard first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <LowLevelIOInterface.h>
|
||||
#include <unistd.h>
|
||||
#include <compiler_private.h>
|
||||
#define DBG_TAG "dlib.syscall.write"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*
|
||||
* The "__write" function should output "size" number of bytes from
|
||||
* "buffer" in some application-specific way. It should return the
|
||||
* number of characters written, or _LLIO_ERROR on failure.
|
||||
*
|
||||
* If "buffer" is zero then __write should perform flushing of
|
||||
* internal buffers, if any. In this case "handle" can be -1 to
|
||||
* indicate that all handles should be flushed.
|
||||
*
|
||||
* The template implementation below assumes that the application
|
||||
* provides the function "MyLowLevelPutchar". It should return the
|
||||
* character written, or -1 on failure.
|
||||
*/
|
||||
|
||||
#pragma module_name = "?__write"
|
||||
|
||||
size_t __write(int handle, const unsigned char *buf, size_t len)
|
||||
{
|
||||
#ifdef DFS_USING_POSIX
|
||||
int size;
|
||||
#endif /* DFS_USING_POSIX */
|
||||
|
||||
if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
|
||||
{
|
||||
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
|
||||
rt_device_t console_device;
|
||||
|
||||
console_device = rt_console_get_device();
|
||||
if (console_device)
|
||||
{
|
||||
rt_device_write(console_device, 0, buf, len);
|
||||
}
|
||||
|
||||
return len; /* return the length of the data written */
|
||||
#else
|
||||
return _LLIO_ERROR;
|
||||
#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */
|
||||
}
|
||||
else if (handle == _LLIO_STDIN)
|
||||
{
|
||||
return _LLIO_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DFS_USING_POSIX
|
||||
size = write(handle, buf, len);
|
||||
return size; /* return the length of the data written */
|
||||
#else
|
||||
LOG_W(_WARNING_WITHOUT_FS);
|
||||
return _LLIO_ERROR;
|
||||
#endif /* DFS_USING_POSIX */
|
||||
}
|
||||
}
|
19
components/libc/compilers/dlib/syscalls.c
Normal file
19
components/libc/compilers/dlib/syscalls.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-02-13 Meco Man implement exit() and abort()
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
/* for exit() and abort() */
|
||||
void __exit (int status)
|
||||
{
|
||||
extern void __rt_libc_exit(int status);
|
||||
__rt_libc_exit(status);
|
||||
while(1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue