move to components directory

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@636 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong
2010-04-18 15:03:27 +00:00
parent b90694ead1
commit 6f3e01a9c5
16 changed files with 0 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
Import('env')
Import('RTT_ROOT')
# The set of source files associated with this SConscript file.
src_local = Glob('*.c')
env.Append(CPPPATH = RTT_ROOT + '/libc/minilibc')
obj = env.Object(src_local)
Return('obj')
+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
+12
View File
@@ -0,0 +1,12 @@
#include <math.h>
/* Fix me */
double sin(double x)
{
#warning sin function not supported for this platform
}
double cos(double x)
{
#warning cos function not supported for this platform
}
+4
View File
@@ -0,0 +1,4 @@
#ifndef __STDIO_H__
#define __STDIO_H__
#endif
+4
View File
@@ -0,0 +1,4 @@
#ifndef __STDDEF_H__
#define __STDDEF_H__
#endif
+33
View File
@@ -0,0 +1,33 @@
#ifndef __STDINT_H__
#define __STDINT_H__
#include <rtthread.h>
typedef rt_int8_t int8_t;
typedef rt_uint8_t uint8_t;
typedef rt_int16_t int16_t;
typedef rt_uint16_t uint16_t;
typedef rt_int32_t int32_t;
typedef rt_uint32_t uint32_t;
/*
* 7.18.2 Limits of specified-width integer types.
*
* The following object-like macros specify the minimum and maximum limits
* of integer types corresponding to the typedef names defined above.
*/
/* 7.18.2.1 Limits of exact-width integer types */
#define INT8_MIN (-0x7f - 1)
#define INT16_MIN (-0x7fff - 1)
#define INT32_MIN (-0x7fffffff - 1)
#define INT8_MAX 0x7f
#define INT16_MAX 0x7fff
#define INT32_MAX 0x7fffffff
#define UINT8_MAX 0xff
#define UINT16_MAX 0xffff
#define UINT32_MAX 0xffffffffU
#endif
+5
View File
@@ -0,0 +1,5 @@
#ifndef __STDIO_H__
#define __STDIO_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
+27
View File
@@ -0,0 +1,27 @@
/*
* 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
#define malloc rt_malloc
#define free rt_free
#define realloc rt_realloc
#define calloc rt_calloc
#endif
File diff suppressed because it is too large Load Diff
+78
View File
@@ -0,0 +1,78 @@
/*
* 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 strncmp(const char *cs,const char *ct, size_t count);
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);
size_t strlcpy(char *dst, const char *src, size_t siz);
char *strncat(char *dest, const char *src, size_t count);
char *strcat(char * dest, const char * src);
char *strchr(const char *s1, int i);
char *strrchr(const char *t, int c);
char *strdup(const char *s);
char *strtok(char *s, const char *delim);
char*strtok_r(char*s, const char*delim, char**ptrptr);
size_t strcspn(const char *s, const char *reject);
size_t strspn (const char *s, const char *accept);
#endif
#endif
+43
View File
@@ -0,0 +1,43 @@
#ifndef _SYS_TIME_H_
#define _SYS_TIME_H_
#include <sys/types.h>
/*
* Structure returned by gettimeofday(2) system call,
* and used in other calls.
*/
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
/*
* Structure defined by POSIX.1b to be like a timeval.
*/
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
struct tm {
int tm_sec; /* Seconds. [0-60] (1 leap second) */
int tm_min; /* Minutes. [0-59] */
int tm_hour; /* Hours. [0-23] */
int tm_mday; /* Day. [1-31] */
int tm_mon; /* Month. [0-11] */
int tm_year; /* Year - 1900. */
int tm_wday; /* Day of week. [0-6] */
int tm_yday; /* Days in year.[0-365] */
int tm_isdst; /* DST. [-1/0/1]*/
long int tm_gmtoff; /* Seconds east of UTC. */
const char *tm_zone; /* Timezone abbreviation. */
};
#endif
+24
View File
@@ -0,0 +1,24 @@
#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;
typedef rt_time_t time_t;
#ifndef NULL
#define NULL RT_NULL
#endif
#endif
+174
View File
@@ -0,0 +1,174 @@
#include <time.h>
/* days per month -- nonleap! */
const short __spm[13] =
{ 0,
(31),
(31+28),
(31+28+31),
(31+28+31+30),
(31+28+31+30+31),
(31+28+31+30+31+30),
(31+28+31+30+31+30+31),
(31+28+31+30+31+30+31+31),
(31+28+31+30+31+30+31+31+30),
(31+28+31+30+31+30+31+31+30+31),
(31+28+31+30+31+30+31+31+30+31+30),
(31+28+31+30+31+30+31+31+30+31+30+31),
};
static long int timezone;
static const char days[] = "Sun Mon Tue Wed Thu Fri Sat ";
static const char months[] = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
/* seconds per day */
#define SPD 24*60*60
int __isleap(int year) {
/* every fourth year is a leap year except for century years that are
* not divisible by 400. */
/* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */
return (!(year%4) && ((year%100) || !(year%400)));
}
struct tm *gmtime_r(const time_t *timep, struct tm *r) {
time_t i;
register time_t work=*timep%(SPD);
r->tm_sec=work%60; work/=60;
r->tm_min=work%60; r->tm_hour=work/60;
work=*timep/(SPD);
r->tm_wday=(4+work)%7;
for (i=1970; ; ++i) {
register time_t k=__isleap(i)?366:365;
if (work>=k)
work-=k;
else
break;
}
r->tm_year=i-1900;
r->tm_yday=work;
r->tm_mday=1;
if (__isleap(i) && (work>58)) {
if (work==59) r->tm_mday=2; /* 29.2. */
work-=1;
}
for (i=11; i && (__spm[i]>work); --i) ;
r->tm_mon=i;
r->tm_mday+=work-__spm[i];
return r;
}
struct tm* localtime_r(const time_t* t, struct tm* r) {
time_t tmp;
struct timezone tz;
gettimeofday(0, &tz);
timezone=tz.tz_minuteswest*60L;
tmp=*t+timezone;
return gmtime_r(&tmp,r);
}
struct tm* localtime(const time_t* t) {
static struct tm tmp;
return localtime_r(t,&tmp);
}
time_t timegm(struct tm *const t) {
register time_t day;
register time_t i;
register time_t years = t->tm_year - 70;
if (t->tm_sec>60) { t->tm_min += t->tm_sec/60; t->tm_sec%=60; }
if (t->tm_min>60) { t->tm_hour += t->tm_min/60; t->tm_min%=60; }
if (t->tm_hour>60) { t->tm_mday += t->tm_hour/60; t->tm_hour%=60; }
if (t->tm_mon>12) { t->tm_year += t->tm_mon/12; t->tm_mon%=12; }
while (t->tm_mday>__spm[1+t->tm_mon]) {
if (t->tm_mon==1 && __isleap(t->tm_year+1900)) {
if (t->tm_mon==31+29) break;
--t->tm_mday;
}
t->tm_mday-=__spm[t->tm_mon];
++t->tm_mon;
if (t->tm_mon>11) { t->tm_mon=0; ++t->tm_year; }
}
if (t->tm_year < 70)
return (time_t) -1;
/* Days since 1970 is 365 * number of years + number of leap years since 1970 */
day = years * 365 + (years + 1) / 4;
/* After 2100 we have to substract 3 leap years for every 400 years
This is not intuitive. Most mktime implementations do not support
dates after 2059, anyway, so we might leave this out for it's
bloat. */
if ((years -= 131) >= 0) {
years /= 100;
day -= (years >> 2) * 3 + 1;
if ((years &= 3) == 3) years--;
day -= years;
}
day += t->tm_yday = __spm [t->tm_mon] + t->tm_mday-1 + ( __isleap (t->tm_year+1900) & (t->tm_mon > 1) );
/* day is now the number of days since 'Jan 1 1970' */
i = 7;
t->tm_wday = (day + 4) % i; /* Sunday=0, Monday=1, ..., Saturday=6 */
i = 24;
day *= i;
i = 60;
return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec;
}
time_t mktime(register struct tm* const t) {
time_t x=timegm(t);
struct timezone tz;
gettimeofday(0, &tz);
timezone=tz.tz_minuteswest*60L;
x+=timezone;
return x;
}
static void num2str(char *c,int i) {
c[0]=i/10+'0';
c[1]=i%10+'0';
}
char *asctime_r(const struct tm *t, char *buf) {
/* "Wed Jun 30 21:49:08 1993\n" */
*(int*)buf=*(int*)(days+(t->tm_wday<<2));
*(int*)(buf+4)=*(int*)(months+(t->tm_mon<<2));
num2str(buf+8,t->tm_mday);
if (buf[8]=='0') buf[8]=' ';
buf[10]=' ';
num2str(buf+11,t->tm_hour);
buf[13]=':';
num2str(buf+14,t->tm_min);
buf[16]=':';
num2str(buf+17,t->tm_sec);
buf[19]=' ';
num2str(buf+20,(t->tm_year+1900)/100);
num2str(buf+22,(t->tm_year+1900)%100);
buf[24]='\n';
return buf;
}
char *asctime(const struct tm *timeptr) {
static char buf[25];
return asctime_r(timeptr,buf);
}
char *ctime(const time_t *timep) {
return asctime(localtime(timep));
}
int gettimeofday (struct timeval *tp, void *ignore)
{
time_t t;
t = time(NULL);
tp->tv_sec = t;
tp->tv_usec = 0;
return 0;
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef __TIME_H__
#define __TIME_H__
#include <sys/time.h>
#endif