fix name of SConscript, add description to stubs.c and mem_std.c
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2435 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
0cdbd69d56
commit
9fb62a5ff1
|
@ -1,6 +1,12 @@
|
||||||
|
/*
|
||||||
|
* File: mem_std.c
|
||||||
|
* Brief: Replace memory management functions of arm standard c library
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include "rtthread.h"
|
#include "rtthread.h"
|
||||||
|
|
||||||
|
/* avoid the heap and heap-using library functions supplied by arm */
|
||||||
#pragma import(__use_no_heap)
|
#pragma import(__use_no_heap)
|
||||||
|
|
||||||
void * malloc(int n)
|
void * malloc(int n)
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
/**
|
/*
|
||||||
* reimplement arm c library's basic functions
|
* File : stubs.c
|
||||||
|
* Brief : reimplement some basic functions of arm standard c library
|
||||||
|
*
|
||||||
|
* This file is part of Device File System in RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE.
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2012-11-23 Yihui The first version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -9,21 +21,7 @@
|
||||||
|
|
||||||
#pragma import(__use_no_semihosting_swi)
|
#pragma import(__use_no_semihosting_swi)
|
||||||
|
|
||||||
int remove(const char *filename)
|
/* TODO: Standard IO device handles. */
|
||||||
{
|
|
||||||
RT_ASSERT(0);
|
|
||||||
for(;;);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* rename() */
|
|
||||||
|
|
||||||
int system(const char *string)
|
|
||||||
{
|
|
||||||
RT_ASSERT(0);
|
|
||||||
for(;;);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Standard IO device handles. */
|
|
||||||
#define STDIN 1
|
#define STDIN 1
|
||||||
#define STDOUT 2
|
#define STDOUT 2
|
||||||
#define STDERR 3
|
#define STDERR 3
|
||||||
|
@ -33,6 +31,14 @@ const char __stdin_name[] = "STDIN";
|
||||||
const char __stdout_name[] = "STDOUT";
|
const char __stdout_name[] = "STDOUT";
|
||||||
const char __stderr_name[] = "STDERR";
|
const char __stderr_name[] = "STDERR";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* required by fopen() and freopen().
|
||||||
|
*
|
||||||
|
* @param name - file name with path.
|
||||||
|
* @param openmode - a bitmap hose bits mostly correspond directly to
|
||||||
|
* the ISO mode specification.
|
||||||
|
* @return -1 if an error occurs.
|
||||||
|
*/
|
||||||
FILEHANDLE _sys_open(const char *name, int openmode)
|
FILEHANDLE _sys_open(const char *name, int openmode)
|
||||||
{
|
{
|
||||||
/* Register standard Input Output devices. */
|
/* Register standard Input Output devices. */
|
||||||
|
@ -44,7 +50,7 @@ FILEHANDLE _sys_open(const char *name, int openmode)
|
||||||
return (STDERR);
|
return (STDERR);
|
||||||
|
|
||||||
#ifndef RT_USING_DFS
|
#ifndef RT_USING_DFS
|
||||||
return 0;
|
return -1;
|
||||||
#else
|
#else
|
||||||
/* TODO: adjust open file mode */
|
/* TODO: adjust open file mode */
|
||||||
return open(name, openmode, 0);
|
return open(name, openmode, 0);
|
||||||
|
@ -63,6 +69,15 @@ int _sys_close(FILEHANDLE fh)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* read data
|
||||||
|
*
|
||||||
|
* @param fh - file handle
|
||||||
|
* @param buf - buffer to save read data
|
||||||
|
* @param len - max length of data buffer
|
||||||
|
* @param mode - useless, for historical reasons
|
||||||
|
* @return actual read data length
|
||||||
|
*/
|
||||||
int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
|
int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
|
||||||
{
|
{
|
||||||
if (fh == STDIN)
|
if (fh == STDIN)
|
||||||
|
@ -79,6 +94,15 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* write data
|
||||||
|
*
|
||||||
|
* @param fh - file handle
|
||||||
|
* @param buf - data buffer
|
||||||
|
* @param len - buffer length
|
||||||
|
* @param mode - useless, for historical reasons
|
||||||
|
* @return actual written data length
|
||||||
|
*/
|
||||||
int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
|
int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
|
||||||
{
|
{
|
||||||
if ((fh == STDOUT) || (fh == STDERR))
|
if ((fh == STDOUT) || (fh == STDERR))
|
||||||
|
@ -102,39 +126,55 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* put he file pointer at offset pos from the beginning of the file.
|
||||||
|
*
|
||||||
|
* @param pos - offset
|
||||||
|
* @return the current file position, or -1 on failed
|
||||||
|
*/
|
||||||
int _sys_seek(FILEHANDLE fh, long pos)
|
int _sys_seek(FILEHANDLE fh, long pos)
|
||||||
{
|
{
|
||||||
#ifndef RT_USING_DFS
|
#ifndef RT_USING_DFS
|
||||||
return 0;
|
return -1;
|
||||||
#else
|
#else
|
||||||
/* TODO: adjust last parameter */
|
/* position is relative to the start of file fh */
|
||||||
return lseek(fh, pos, 0);
|
return lseek(fh, pos, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int _sys_tmpnam(char *name, int fileno, unsigned maxlength)
|
/**
|
||||||
|
* used by tmpnam() or tmpfile()
|
||||||
|
*/
|
||||||
|
void_sys_tmpnam(char *name, int fileno, unsigned maxlength)
|
||||||
{
|
{
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *_sys_command_string(char *cmd, int len)
|
char *_sys_command_string(char *cmd, int len)
|
||||||
{
|
{
|
||||||
|
/* no support */
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _ttywrch(int ch)
|
void _ttywrch(int ch)
|
||||||
{
|
{
|
||||||
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
void _sys_exit(int return_code)
|
void _sys_exit(int return_code)
|
||||||
{
|
{
|
||||||
|
/* TODO: perhaps exit the thread which is invoking this function */
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return current length of file.
|
||||||
|
*
|
||||||
|
* @param fh - file handle
|
||||||
|
* @return file length, or -1 on failed
|
||||||
|
*/
|
||||||
long _sys_flen(FILEHANDLE fh)
|
long _sys_flen(FILEHANDLE fh)
|
||||||
{
|
{
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _sys_istty(FILEHANDLE fh)
|
int _sys_istty(FILEHANDLE fh)
|
||||||
|
@ -143,4 +183,17 @@ int _sys_istty(FILEHANDLE fh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int remove(const char *filename)
|
||||||
|
{
|
||||||
|
return unlink(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* rename() */
|
||||||
|
|
||||||
|
int system(const char *string)
|
||||||
|
{
|
||||||
|
RT_ASSERT(0);
|
||||||
|
for(;;);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue