add minilibc

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@88 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong committed 2009-10-11 05:44:19 +00:00
1 parent 6718379b81
commit 939eaa338f
8 files changed
+708

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
/*
* File : ctype.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008, 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
* 2008-08-14 Bernard the first version
*/
#include <rtthread.h>
#include <sys/types.h>
#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC)
#include "ctype.h"
int isprint (int ch)
{
ch&=0x7f;
return (ch>=32 && ch<127);
}
int isalpha(int ch)
{
return (unsigned int)((ch | 0x20) - 'a') < 26u;
}
#endif
+20
View File
@@ -0,0 +1,20 @@
/*
* File : ctype.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008, 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
* 2008-08-14 Bernard the first version
*/
#ifndef __CTYPE_H__
#define __CTYPE_H__
int isprint(int c) __attribute__ ((__const__));
int isalpha (int c) __attribute__ ((__const__));
#endif
+4
View File
@@ -0,0 +1,4 @@
#ifndef __STDDEF_H__
#define __STDDEF_H__
#endif
+41
View File
@@ -0,0 +1,41 @@
/*
* File : stdlib.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008, 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
* 2008-08-14 Bernard the first version
*/
#include <rtthread.h>
#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC)
#include "stdlib.h"
int errno = 0;
int atoi(const char* s)
{
long int v=0;
int sign=1;
while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) s++;
switch (*s)
{
case '-':
sign=-1;
case '+':
++s;
}
while ((unsigned int) (*s - '0') < 10u)
{
v=v*10+*s-'0';
++s;
}
return sign==-1?-v:v;
}
#endif
+22
View File
@@ -0,0 +1,22 @@
/*
* File : stdlib.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008, 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
* 2008-08-14 Bernard the first version
*/
#ifndef __STDLIB_H__
#define __STDLIB_H__
#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC)
int atoi(const char *nptr);
#endif
#endif
File diff suppressed because it is too large. Load diff
+70
View File
@@ -0,0 +1,70 @@
/*
* File : string.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2008, 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
* 2008-08-14 Bernard the first version
*/
#ifndef __STRING_H__
#define __STRING_H__
#include <rtthread.h>
#include <sys/types.h>
/* replace for standard string library */
#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC)
#define ZEROPAD (1 << 0) /* pad with zero */
#define SIGN (1 << 1) /* unsigned/signed long */
#define PLUS (1 << 2) /* show plus */
#define SPACE (1 << 3) /* space if plus */
#define LEFT (1 << 4) /* left justified */
#define SPECIAL (1 << 5) /* 0x */
#define LARGE (1 << 6) /* use 'ABCDEF' instead of 'abcdef' */
#define INT_MAX ((int)(~0U>>1))
#define INT_MIN (-INT_MAX - 1)
#define UINT_MAX (~0U)
#define LONG_MAX ((long)(~0UL>>1))
#define LONG_MIN (-LONG_MAX - 1)
#define ULONG_MAX (~0UL)
#define _U 0x01 /* upper */
#define _L 0x02 /* lower */
#define _D 0x04 /* digit */
#define _C 0x08 /* cntrl */
#define _P 0x10 /* punct */
#define _S 0x20 /* white space (space/lf/tab) */
#define _X 0x40 /* hex digit */
#define _SP 0x80 /* hard space (0x20) */
void* memset(void *s, int c, size_t n);
void* memcpy(void *dest, const void *src, size_t n);
void* memmove(void *dest, const void *src, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
int tolower(int c);
int toupper(int c);
int strcmp (const char *s1, const char *s2);
int strcasecmp(const char *a, const char *b);
int strncasecmp(const char *cs, const char *ct, size_t count);
int sscanf(const char * buf, const char * fmt, ...);
size_t strlen(const char *s);
char * strstr(const char * s1,const char * s2);
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t n);
char *strncat(char *s, const char *t, size_t n) ;
char* strcat(register char* s,register const char* t);
char *strrchr(const char *t, int c);
char *strdup(const char *s);
#endif
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef __TYPES_H__
#define __TYPES_H__
#include <rtthread.h>
typedef rt_off_t off_t;
typedef rt_size_t size_t;
typedef rt_uint8_t u_char;
typedef rt_uint16_t u_short;
typedef rt_ubase_t u_int;
typedef rt_uint32_t u_long;
typedef rt_uint8_t u_int8_t;
typedef rt_uint16_t u_int16_t;
typedef rt_uint32_t u_int32_t;
#ifndef NULL
#define NULL RT_NULL
#endif
#endif