From 497e7b45d489802a16bf2bba97efa7f303e88206 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 23 Feb 2021 03:28:19 +0800 Subject: [PATCH] remove minilibc --- components/libc/compilers/minilibc/SConscript | 15 - components/libc/compilers/minilibc/ctype.c | 49 -- components/libc/compilers/minilibc/ctype.h | 18 - components/libc/compilers/minilibc/errno.h | 16 - components/libc/compilers/minilibc/inttypes.h | 14 - components/libc/compilers/minilibc/math.c | 176 ----- components/libc/compilers/minilibc/math.h | 20 - components/libc/compilers/minilibc/qsort.c | 52 -- components/libc/compilers/minilibc/rand.c | 43 -- components/libc/compilers/minilibc/signal.h | 20 - components/libc/compilers/minilibc/stddef.h | 15 - components/libc/compilers/minilibc/stdint.h | 266 -------- components/libc/compilers/minilibc/stdio.h | 26 - components/libc/compilers/minilibc/stdlib.c | 75 --- components/libc/compilers/minilibc/stdlib.h | 33 - components/libc/compilers/minilibc/string.c | 630 ------------------ components/libc/compilers/minilibc/string.h | 69 -- components/libc/compilers/minilibc/sys/mman.h | 58 -- components/libc/compilers/minilibc/sys/stat.h | 44 -- components/libc/compilers/minilibc/sys/time.h | 54 -- .../libc/compilers/minilibc/sys/types.h | 50 -- components/libc/compilers/minilibc/time.c | 287 -------- components/libc/compilers/minilibc/time.h | 24 - 23 files changed, 2054 deletions(-) delete mode 100644 components/libc/compilers/minilibc/SConscript delete mode 100644 components/libc/compilers/minilibc/ctype.c delete mode 100644 components/libc/compilers/minilibc/ctype.h delete mode 100644 components/libc/compilers/minilibc/errno.h delete mode 100644 components/libc/compilers/minilibc/inttypes.h delete mode 100644 components/libc/compilers/minilibc/math.c delete mode 100644 components/libc/compilers/minilibc/math.h delete mode 100644 components/libc/compilers/minilibc/qsort.c delete mode 100644 components/libc/compilers/minilibc/rand.c delete mode 100644 components/libc/compilers/minilibc/signal.h delete mode 100644 components/libc/compilers/minilibc/stddef.h delete mode 100644 components/libc/compilers/minilibc/stdint.h delete mode 100644 components/libc/compilers/minilibc/stdio.h delete mode 100644 components/libc/compilers/minilibc/stdlib.c delete mode 100644 components/libc/compilers/minilibc/stdlib.h delete mode 100644 components/libc/compilers/minilibc/string.c delete mode 100644 components/libc/compilers/minilibc/string.h delete mode 100644 components/libc/compilers/minilibc/sys/mman.h delete mode 100644 components/libc/compilers/minilibc/sys/stat.h delete mode 100644 components/libc/compilers/minilibc/sys/time.h delete mode 100644 components/libc/compilers/minilibc/sys/types.h delete mode 100644 components/libc/compilers/minilibc/time.c delete mode 100644 components/libc/compilers/minilibc/time.h diff --git a/components/libc/compilers/minilibc/SConscript b/components/libc/compilers/minilibc/SConscript deleted file mode 100644 index dec657028f..0000000000 --- a/components/libc/compilers/minilibc/SConscript +++ /dev/null @@ -1,15 +0,0 @@ -from building import * -Import('rtconfig') - -src = Glob('*.c') + Glob('*.cpp') -cwd = GetCurrentDir() -group = [] - -CPPPATH = [cwd] -CPPDEFINES = ['RT_USING_MINILIBC'] - -if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC') and GetDepend('RT_USING_MINILIBC'): - group = DefineGroup('libc', src, depend = [''], - CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) - -Return('group') diff --git a/components/libc/compilers/minilibc/ctype.c b/components/libc/compilers/minilibc/ctype.c deleted file mode 100644 index b94ff2dae8..0000000000 --- a/components/libc/compilers/minilibc/ctype.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2008-08-14 Bernard the first version - */ - -#include -#include - -#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; -} - -int isdigit (int ch) -{ - return (unsigned int)(ch - '0') < 10u; -} - -int isspace(int ch) -{ - switch(ch) - { - case ' ': - case '\n': - case '\f': - case '\r': - case '\t': - case '\v': - return 1; - default: - return 0; - } -} - -#endif diff --git a/components/libc/compilers/minilibc/ctype.h b/components/libc/compilers/minilibc/ctype.h deleted file mode 100644 index 5f41376ed8..0000000000 --- a/components/libc/compilers/minilibc/ctype.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * 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__)); -int isdigit (int ch) __attribute__ ((__const__)); -int isspace(int ch) __attribute__ ((__const__)); - -#endif diff --git a/components/libc/compilers/minilibc/errno.h b/components/libc/compilers/minilibc/errno.h deleted file mode 100644 index a7ee380594..0000000000 --- a/components/libc/compilers/minilibc/errno.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __ERRNO_H__ -#define __ERRNO_H__ - -#include "libc/libc_errno.h" -/* Others defined in libc/libc_errno.h */ -#define ENSRNOTFOUND 163 /* Domain name not found */ - -#endif diff --git a/components/libc/compilers/minilibc/inttypes.h b/components/libc/compilers/minilibc/inttypes.h deleted file mode 100644 index 8bab743655..0000000000 --- a/components/libc/compilers/minilibc/inttypes.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __INTTYPES_H__ -#define __INTTYPES_H__ - -#include "stdint.h" - -#endif diff --git a/components/libc/compilers/minilibc/math.c b/components/libc/compilers/minilibc/math.c deleted file mode 100644 index cd5770178e..0000000000 --- a/components/libc/compilers/minilibc/math.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#include - -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS CRT - * FILE: lib/crt/math/cos.c - * PURPOSE: Generic C Implementation of cos - * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) - */ - -#define PRECISION 9 - -static double cos_off_tbl[] = {0.0, -M_PI/2., 0, -M_PI/2.}; -static double cos_sign_tbl[] = {1,-1,-1,1}; - -static double sin_off_tbl[] = {0.0, -M_PI/2., 0, -M_PI/2.}; -static double sin_sign_tbl[] = {1,-1,-1,1}; - -double sin(double x) -{ - int quadrant; - double x2, result; - - /* Calculate the quadrant */ - quadrant = x * (2./M_PI); - - /* Get offset inside quadrant */ - x = x - quadrant * (M_PI/2.); - - /* Normalize quadrant to [0..3] */ - quadrant = (quadrant - 1) & 0x3; - - /* Fixup value for the generic function */ - x += sin_off_tbl[quadrant]; - - /* Calculate the negative of the square of x */ - x2 = - (x * x); - - /* This is an unrolled taylor series using iterations - * Example with 4 iterations: - * result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! - * To save multiplications and to keep the precision high, it's performed - * like this: - * result = 1 - x^2 * (1/2! - x^2 * (1/4! - x^2 * (1/6! - x^2 * (1/8!)))) - */ - - /* Start with 0, compiler will optimize this away */ - result = 0; - -#if (PRECISION >= 10) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20); - result *= x2; -#endif -#if (PRECISION >= 9) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18); - result *= x2; -#endif -#if (PRECISION >= 8) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16); - result *= x2; -#endif -#if (PRECISION >= 7) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14); - result *= x2; -#endif -#if (PRECISION >= 6) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12); - result *= x2; -#endif -#if (PRECISION >= 5) - result += 1./(1.*2*3*4*5*6*7*8*9*10); - result *= x2; -#endif - result += 1./(1.*2*3*4*5*6*7*8); - result *= x2; - - result += 1./(1.*2*3*4*5*6); - result *= x2; - - result += 1./(1.*2*3*4); - result *= x2; - - result += 1./(1.*2); - result *= x2; - - result += 1; - - /* Apply correct sign */ - result *= sin_sign_tbl[quadrant]; - - return result; -} - -double cos(double x) -{ - int quadrant; - double x2, result; - - /* Calculate the quadrant */ - quadrant = x * (2./M_PI); - - /* Get offset inside quadrant */ - x = x - quadrant * (M_PI/2.); - - /* Normalize quadrant to [0..3] */ - quadrant = quadrant & 0x3; - - /* Fixup value for the generic function */ - x += cos_off_tbl[quadrant]; - - /* Calculate the negative of the square of x */ - x2 = - (x * x); - - /* This is an unrolled taylor series using iterations - * Example with 4 iterations: - * result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! - * To save multiplications and to keep the precision high, it's performed - * like this: - * result = 1 - x^2 * (1/2! - x^2 * (1/4! - x^2 * (1/6! - x^2 * (1/8!)))) - */ - - /* Start with 0, compiler will optimize this away */ - result = 0; - -#if (PRECISION >= 10) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20); - result *= x2; -#endif -#if (PRECISION >= 9) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18); - result *= x2; -#endif -#if (PRECISION >= 8) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14*15*16); - result *= x2; -#endif -#if (PRECISION >= 7) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12*13*14); - result *= x2; -#endif -#if (PRECISION >= 6) - result += 1./(1.*2*3*4*5*6*7*8*9*10*11*12); - result *= x2; -#endif -#if (PRECISION >= 5) - result += 1./(1.*2*3*4*5*6*7*8*9*10); - result *= x2; -#endif - result += 1./(1.*2*3*4*5*6*7*8); - result *= x2; - - result += 1./(1.*2*3*4*5*6); - result *= x2; - - result += 1./(1.*2*3*4); - result *= x2; - - result += 1./(1.*2); - result *= x2; - - result += 1; - - /* Apply correct sign */ - result *= cos_sign_tbl[quadrant]; - - return result; -} - diff --git a/components/libc/compilers/minilibc/math.h b/components/libc/compilers/minilibc/math.h deleted file mode 100644 index 49b80d8219..0000000000 --- a/components/libc/compilers/minilibc/math.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __MATH_H__ -#define __MATH_H__ - -#define M_PI 3.141592653589793238462643 - -double sin(double x); -double cos(double x); - -typedef float float_t; -typedef double double_t; - -#endif diff --git a/components/libc/compilers/minilibc/qsort.c b/components/libc/compilers/minilibc/qsort.c deleted file mode 100644 index 2b97ce763c..0000000000 --- a/components/libc/compilers/minilibc/qsort.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#include -#include - -static void exch(char* base,size_t size,size_t a,size_t b) { - char* x=base+a*size; - char* y=base+b*size; - while (size) { - char z=*x; - *x=*y; - *y=z; - --size; ++x; ++y; - } -} - -/* Quicksort with 3-way partitioning, ala Sedgewick */ -/* Blame him for the scary variable names */ -/* http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf */ -static void quicksort(char* base,size_t size,ssize_t l,ssize_t r, - int (*compar)(const void*,const void*)) { - ssize_t i=l-1, j=r, p=l-1, q=r, k; - char* v=base+r*size; - if (r<=l) return; - for (;;) { - while (++i != r && compar(base+i*size,v)<0) ; - while (compar(v,base+(--j)*size)<0) if (j == l) break; - if (i >= j) break; - exch(base,size,i,j); - if (compar(base+i*size,v)==0) exch(base,size,++p,i); - if (compar(v,base+j*size)==0) exch(base,size,j,--q); - } - exch(base,size,i,r); j = i-1; ++i; - for (k=l; kq; k--, i++) exch(base,size,i,k); - quicksort(base,size,l,j,compar); - quicksort(base,size,i,r,compar); -} - -void qsort(void* base,size_t nmemb,size_t size,int (*compar)(const void*,const void*)) { - /* check for integer overflows */ - if (nmemb >= (((size_t)-1)>>1) || - size >= (((size_t)-1)>>1)) return; - if (nmemb>1) - quicksort(base,size,0,nmemb-1,compar); -} diff --git a/components/libc/compilers/minilibc/rand.c b/components/libc/compilers/minilibc/rand.c deleted file mode 100644 index 88603dc808..0000000000 --- a/components/libc/compilers/minilibc/rand.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#include -#include -#include - -static unsigned int _seed=1; - -/* Knuth's TAOCP section 3.6 */ -#define M ((1U<<31) -1) -#define A 48271 -#define Q 44488 // M/A -#define R 3399 // M%A; R < Q !!! - -int rand_r(unsigned int* seed) -{ int32_t X; - - X = *seed; - X = A*(X%Q) - R * (int32_t) (X/Q); - if (X < 0) - X += M; - - *seed = X; - return X; -} - -int rand(void) { - return rand_r(&_seed); -} - -void srand(unsigned int i) -{ - _seed=i; -} - -int random(void) __attribute__((alias("rand"))); -void srandom(unsigned int i) __attribute__((alias("srand"))); diff --git a/components/libc/compilers/minilibc/signal.h b/components/libc/compilers/minilibc/signal.h deleted file mode 100644 index f52f1e1009..0000000000 --- a/components/libc/compilers/minilibc/signal.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2017-09-12 Bernard The first version - */ - -#ifndef SIGNAL_H__ -#define SIGNAL_H__ - -#include - -#define SIG_DFL ((_sig_func_ptr)0) /* Default action */ -#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */ -#define SIG_ERR ((_sig_func_ptr)-1) /* Error return */ - -#endif diff --git a/components/libc/compilers/minilibc/stddef.h b/components/libc/compilers/minilibc/stddef.h deleted file mode 100644 index 7353a157cb..0000000000 --- a/components/libc/compilers/minilibc/stddef.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __STDDEF_H__ -#define __STDDEF_H__ - -#include -typedef signed long ptrdiff_t; - -#endif diff --git a/components/libc/compilers/minilibc/stdint.h b/components/libc/compilers/minilibc/stdint.h deleted file mode 100644 index bd5fdc83f5..0000000000 --- a/components/libc/compilers/minilibc/stdint.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -/* - * ISO C Standard: 7.18 Integer types - */ - -#ifndef __STDINT_H__ -#define __STDINT_H__ - -/* 7.8.1.1 Exact-width integer types */ - -#ifdef __INT8_TYPE__ -typedef __INT8_TYPE__ int8_t; -#endif -#ifdef __INT16_TYPE__ -typedef __INT16_TYPE__ int16_t; -#endif -#ifdef __INT32_TYPE__ -typedef __INT32_TYPE__ int32_t; -#endif -#ifdef __INT64_TYPE__ -typedef __INT64_TYPE__ int64_t; -#endif -#ifdef __UINT8_TYPE__ -typedef __UINT8_TYPE__ uint8_t; -#endif -#ifdef __UINT16_TYPE__ -typedef __UINT16_TYPE__ uint16_t; -#endif -#ifdef __UINT32_TYPE__ -typedef __UINT32_TYPE__ uint32_t; -#endif -#ifdef __UINT64_TYPE__ -typedef __UINT64_TYPE__ uint64_t; -#endif - -/* 7.8.1.2 Minimum-width integer types */ - -typedef __INT_LEAST8_TYPE__ int_least8_t; -typedef __INT_LEAST16_TYPE__ int_least16_t; -typedef __INT_LEAST32_TYPE__ int_least32_t; -typedef __INT_LEAST64_TYPE__ int_least64_t; -typedef __UINT_LEAST8_TYPE__ uint_least8_t; -typedef __UINT_LEAST16_TYPE__ uint_least16_t; -typedef __UINT_LEAST32_TYPE__ uint_least32_t; -typedef __UINT_LEAST64_TYPE__ uint_least64_t; - -/* 7.8.1.3 Fastest minimum-width integer types */ - -typedef __INT_FAST8_TYPE__ int_fast8_t; -typedef __INT_FAST16_TYPE__ int_fast16_t; -typedef __INT_FAST32_TYPE__ int_fast32_t; -typedef __INT_FAST64_TYPE__ int_fast64_t; -typedef __UINT_FAST8_TYPE__ uint_fast8_t; -typedef __UINT_FAST16_TYPE__ uint_fast16_t; -typedef __UINT_FAST32_TYPE__ uint_fast32_t; -typedef __UINT_FAST64_TYPE__ uint_fast64_t; - -/* 7.8.1.4 Integer types capable of holding object pointers */ - -#ifdef __INTPTR_TYPE__ -typedef __INTPTR_TYPE__ intptr_t; -#endif -#ifdef __UINTPTR_TYPE__ -typedef __UINTPTR_TYPE__ uintptr_t; -#endif - -/* 7.8.1.5 Greatest-width integer types */ - -typedef __INTMAX_TYPE__ intmax_t; -typedef __UINTMAX_TYPE__ uintmax_t; - -#if (!defined __cplusplus || __cplusplus >= 201103L \ - || defined __STDC_LIMIT_MACROS) - -/* - * 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 */ - -#ifdef __INT8_MAX__ -# undef INT8_MAX -# define INT8_MAX __INT8_MAX__ -# undef INT8_MIN -# define INT8_MIN (-INT8_MAX - 1) -#endif -#ifdef __UINT8_MAX__ -# undef UINT8_MAX -# define UINT8_MAX __UINT8_MAX__ -#endif -#ifdef __INT16_MAX__ -# undef INT16_MAX -# define INT16_MAX __INT16_MAX__ -# undef INT16_MIN -# define INT16_MIN (-INT16_MAX - 1) -#endif -#ifdef __UINT16_MAX__ -# undef UINT16_MAX -# define UINT16_MAX __UINT16_MAX__ -#endif -#ifdef __INT32_MAX__ -# undef INT32_MAX -# define INT32_MAX __INT32_MAX__ -# undef INT32_MIN -# define INT32_MIN (-INT32_MAX - 1) -#endif -#ifdef __UINT32_MAX__ -# undef UINT32_MAX -# define UINT32_MAX __UINT32_MAX__ -#endif -#ifdef __INT64_MAX__ -# undef INT64_MAX -# define INT64_MAX __INT64_MAX__ -# undef INT64_MIN -# define INT64_MIN (-INT64_MAX - 1) -#endif -#ifdef __UINT64_MAX__ -# undef UINT64_MAX -# define UINT64_MAX __UINT64_MAX__ -#endif - -#undef INT_LEAST8_MAX -#define INT_LEAST8_MAX __INT_LEAST8_MAX__ -#undef INT_LEAST8_MIN -#define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1) -#undef UINT_LEAST8_MAX -#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__ -#undef INT_LEAST16_MAX -#define INT_LEAST16_MAX __INT_LEAST16_MAX__ -#undef INT_LEAST16_MIN -#define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1) -#undef UINT_LEAST16_MAX -#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__ -#undef INT_LEAST32_MAX -#define INT_LEAST32_MAX __INT_LEAST32_MAX__ -#undef INT_LEAST32_MIN -#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1) -#undef UINT_LEAST32_MAX -#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__ -#undef INT_LEAST64_MAX -#define INT_LEAST64_MAX __INT_LEAST64_MAX__ -#undef INT_LEAST64_MIN -#define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1) -#undef UINT_LEAST64_MAX -#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__ - -#undef INT_FAST8_MAX -#define INT_FAST8_MAX __INT_FAST8_MAX__ -#undef INT_FAST8_MIN -#define INT_FAST8_MIN (-INT_FAST8_MAX - 1) -#undef UINT_FAST8_MAX -#define UINT_FAST8_MAX __UINT_FAST8_MAX__ -#undef INT_FAST16_MAX -#define INT_FAST16_MAX __INT_FAST16_MAX__ -#undef INT_FAST16_MIN -#define INT_FAST16_MIN (-INT_FAST16_MAX - 1) -#undef UINT_FAST16_MAX -#define UINT_FAST16_MAX __UINT_FAST16_MAX__ -#undef INT_FAST32_MAX -#define INT_FAST32_MAX __INT_FAST32_MAX__ -#undef INT_FAST32_MIN -#define INT_FAST32_MIN (-INT_FAST32_MAX - 1) -#undef UINT_FAST32_MAX -#define UINT_FAST32_MAX __UINT_FAST32_MAX__ -#undef INT_FAST64_MAX -#define INT_FAST64_MAX __INT_FAST64_MAX__ -#undef INT_FAST64_MIN -#define INT_FAST64_MIN (-INT_FAST64_MAX - 1) -#undef UINT_FAST64_MAX -#define UINT_FAST64_MAX __UINT_FAST64_MAX__ - -#ifdef __INTPTR_MAX__ -# undef INTPTR_MAX -# define INTPTR_MAX __INTPTR_MAX__ -# undef INTPTR_MIN -# define INTPTR_MIN (-INTPTR_MAX - 1) -#endif -#ifdef __UINTPTR_MAX__ -# undef UINTPTR_MAX -# define UINTPTR_MAX __UINTPTR_MAX__ -#endif - -#undef INTMAX_MAX -#define INTMAX_MAX __INTMAX_MAX__ -#undef INTMAX_MIN -#define INTMAX_MIN (-INTMAX_MAX - 1) -#undef UINTMAX_MAX -#define UINTMAX_MAX __UINTMAX_MAX__ - -/* 7.18.3 Limits of other integer types */ - -#undef PTRDIFF_MAX -#define PTRDIFF_MAX __PTRDIFF_MAX__ -#undef PTRDIFF_MIN -#define PTRDIFF_MIN (-PTRDIFF_MAX - 1) - -#undef SIG_ATOMIC_MAX -#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__ -#undef SIG_ATOMIC_MIN -#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__ - -#undef SIZE_MAX -#define SIZE_MAX __SIZE_MAX__ - -#undef WCHAR_MAX -#define WCHAR_MAX __WCHAR_MAX__ -#undef WCHAR_MIN -#define WCHAR_MIN __WCHAR_MIN__ - -#undef WINT_MAX -#define WINT_MAX __WINT_MAX__ -#undef WINT_MIN -#define WINT_MIN __WINT_MIN__ - -#endif /* (!defined __cplusplus || __cplusplus >= 201103L - || defined __STDC_LIMIT_MACROS) */ - -#if (!defined __cplusplus || __cplusplus >= 201103L \ - || defined __STDC_CONSTANT_MACROS) - -#undef INT8_C -#define INT8_C(c) __INT8_C(c) -#undef INT16_C -#define INT16_C(c) __INT16_C(c) -#undef INT32_C -#define INT32_C(c) __INT32_C(c) -#undef INT64_C -#define INT64_C(c) __INT64_C(c) -#undef UINT8_C -#define UINT8_C(c) __UINT8_C(c) -#undef UINT16_C -#define UINT16_C(c) __UINT16_C(c) -#undef UINT32_C -#define UINT32_C(c) __UINT32_C(c) -#undef UINT64_C -#define UINT64_C(c) __UINT64_C(c) -#undef INTMAX_C -#define INTMAX_C(c) __INTMAX_C(c) -#undef UINTMAX_C -#define UINTMAX_C(c) __UINTMAX_C(c) - -#endif /* (!defined __cplusplus || __cplusplus >= 201103L - || defined __STDC_CONSTANT_MACROS) */ - -#ifndef __INT_MAX__ -#define __INT_MAX__ 2147483647 -#endif -#define INT_MIN (-1 - INT_MAX) -#define INT_MAX (__INT_MAX__) -#define UINT_MAX (INT_MAX * 2U + 1U) - -#define LONG_MAX ((long)(~0UL>>1)) -#define LONG_MIN (-LONG_MAX - 1) -#define ULONG_MAX (~0UL) - -#endif diff --git a/components/libc/compilers/minilibc/stdio.h b/components/libc/compilers/minilibc/stdio.h deleted file mode 100644 index 678682cf5e..0000000000 --- a/components/libc/compilers/minilibc/stdio.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __STDIO_H__ -#define __STDIO_H__ - -#define BUFSIZ 128 -#define EOF (-1) - -#ifndef SEEK_SET -#define SEEK_SET 0 /* set file offset to offset */ -#endif -#ifndef SEEK_CUR -#define SEEK_CUR 1 /* set file offset to current plus offset */ -#endif -#ifndef SEEK_END -#define SEEK_END 2 /* set file offset to EOF plus offset */ -#endif - -#endif - diff --git a/components/libc/compilers/minilibc/stdlib.c b/components/libc/compilers/minilibc/stdlib.c deleted file mode 100644 index 8154ec5b8b..0000000000 --- a/components/libc/compilers/minilibc/stdlib.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2008-08-14 Bernard the first version - */ - -#include - -#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC) -#include "stdlib.h" - -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; -} - -long int atol(const char* s) -{ - long int v=0; - int sign=0; - 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?-v:v; -} - -#ifdef RT_USING_HEAP -void *malloc(size_t size) -{ - return rt_malloc(size); -} - -void free(void *ptr) -{ - rt_free(ptr); -} - -void *realloc(void *ptr, size_t size) -{ - return rt_realloc(ptr, size); -} - -void *calloc(size_t nelem, size_t elsize) -{ - return rt_calloc(nelem, elsize); -} -#endif - -#endif diff --git a/components/libc/compilers/minilibc/stdlib.h b/components/libc/compilers/minilibc/stdlib.h deleted file mode 100644 index d57d95b64d..0000000000 --- a/components/libc/compilers/minilibc/stdlib.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2008-08-14 Bernard the first version - */ - -#ifndef __STDLIB_H__ -#define __STDLIB_H__ - -#include - -#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC) -int atoi(const char *nptr); -long int atol(const char *nptr); - -int rand(void); -int rand_r(unsigned int *seed); -void srand(unsigned int seed); - -void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); - -void *malloc(size_t size); -void free(void *ptr); -void *realloc(void *ptr, size_t size); -void *calloc(size_t nelem, size_t elsize); -void abort(void); -#endif - -#endif diff --git a/components/libc/compilers/minilibc/string.c b/components/libc/compilers/minilibc/string.c deleted file mode 100644 index 1ab7c0509f..0000000000 --- a/components/libc/compilers/minilibc/string.c +++ /dev/null @@ -1,630 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2008-08-14 Bernard the first version - * 2010-02-15 Gary Lee add strlcpy - * 2010-03-17 Bernard add strlcpy implementation to this file. - * fix strlcpy declaration - * 2010-03-24 Bernard add strchr and strtok implementation. - */ - -#include -#include - -#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC) -#include "string.h" - -/* there is no strcpy and strcmp implementation in RT-Thread */ -char *strcpy(char *dest, const char *src) -{ - return (char *)rt_strncpy(dest, src, rt_strlen(src) + 1); -} - -char *strncpy(char *dest, const char *src, size_t siz) -{ - return (char *)rt_strncpy(dest, src, siz); -} - -size_t strlcpy(char *dst, const char *src, size_t siz) -{ - register char *d = dst; - register const char *s = src; - register size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) - { - do - { - if ((*d++ = *s++) == 0) break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) - { - if (siz != 0) *d = '\0'; /* NUL-terminate dst */ - while (*s++) ; - } - - return(s - src - 1); /* count does not include NUL */ -} - -int strcmp (const char *s1, const char *s2) -{ - while (*s1 && *s1 == *s2) - s1++, s2++; - return (*s1 - *s2); -} - -/** - * strncmp - Compare two length-limited strings - * @cs: One string - * @ct: Another string - * @count: The maximum number of bytes to compare - */ -int strncmp(const char *cs,const char *ct, size_t count) -{ - register signed char __res = 0; - - while (count) { - if ((__res = *cs - *ct++) != 0 || !*cs++) - break; - count--; - } - - return __res; -} - -char *strcat(char * dest, const char * src) -{ - char *tmp = dest; - - while (*dest) - dest++; - while ((*dest++ = *src++) != '\0') - ; - - return tmp; -} - -char *strncat(char *dest, const char *src, size_t count) -{ - char *tmp = dest; - - if (count) { - while (*dest) - dest++; - while ((*dest++ = *src++)) { - if (--count == 0) { - *dest = '\0'; - break; - } - } - } - - return tmp; -} - -char *strrchr(const char *t, int c) -{ - register char ch; - register const char *l=0; - - ch = c; - for (;;) - { - if (*t == ch) l=t; - if (!*t) return (char*)l; - ++t; - } - - return (char*)l; -} - - -int strncasecmp ( const char* s1, const char* s2, size_t len ) -{ - register unsigned int x2; - register unsigned int x1; - register const char* end = s1 + len; - - while (1) - { - if ((s1 >= end) ) - return 0; - - x2 = *s2 - 'A'; if ((x2 < 26u)) x2 += 32; - x1 = *s1 - 'A'; if ((x1 < 26u)) x1 += 32; - s1++; s2++; - - if (x2 != x1) - break; - - if (x1 == (unsigned int)-'A') - break; - } - - return x1 - x2; -} - -/* private function */ -#define isdigit(c) ((unsigned)((c) - '0') < 10) - -rt_inline int divide(int *n, int base) -{ - rt_int32_t res; - - /* optimized for processor which does not support divide instructions. */ - if (base == 10) - { - res = ((int)*n) % 10U; - *n = ((int)*n) / 10U; - } - else - { - res = ((int)*n) % 16U; - *n = ((int)*n) / 16U; - } - - return res; -} - -rt_inline int skip_atoi(const char **s) -{ - register int i=0; - while (isdigit(**s)) i = i*10 + *((*s)++) - '0'; - - return i; -} - -unsigned char _ctype[] = { -_C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ -_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ -_C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ -_C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ -_S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ -_P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ -_D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ -_D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ -_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ -_U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ -_U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ -_U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ -_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ -_L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ -_L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ -_L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ -_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */ -_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */ -_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ -_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ -_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ -_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ - -#define __ismask(x) (_ctype[(int)(unsigned char)(x)]) - -#define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) -#define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) -#define iscntrl(c) ((__ismask(c)&(_C)) != 0) -#define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) -#define islower(c) ((__ismask(c)&(_L)) != 0) -#define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) -#define ispunct(c) ((__ismask(c)&(_P)) != 0) -#define isspace(c) ((__ismask(c)&(_S)) != 0) -#define isupper(c) ((__ismask(c)&(_U)) != 0) -#define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) - -#define isascii(c) (((unsigned char)(c))<=0x7f) -#define toascii(c) (((unsigned char)(c))&0x7f) - -static inline unsigned char __tolower(unsigned char c) -{ - if (isupper(c)) - c -= 'A'-'a'; - return c; -} - -static inline unsigned char __toupper(unsigned char c) -{ - if (islower(c)) - c -= 'a'-'A'; - return c; -} - -int tolower(int c) -{ - return __tolower(c); -} - -int toupper(int c) -{ - return __toupper(c); -} - -/** - * simple_strtoul - convert a string to an unsigned long - * @cp: The start of the string - * @endp: A pointer to the end of the parsed string will be placed here - * @base: The number base to use - */ -unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) -{ - unsigned long result = 0,value; - - if (!base) { - base = 10; - if (*cp == '0') { - base = 8; - cp++; - if ((toupper(*cp) == 'X') && isxdigit(cp[1])) { - cp++; - base = 16; - } - } - } else if (base == 16) { - if (cp[0] == '0' && toupper(cp[1]) == 'X') - cp += 2; - } - while (isxdigit(*cp) && - (value = isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) { - result = result*base + value; - cp++; - } - if (endp) - *endp = (char *)cp; - return result; -} - -/** - * simple_strtol - convert a string to a signed long - * @cp: The start of the string - * @endp: A pointer to the end of the parsed string will be placed here - * @base: The number base to use - */ -long simple_strtol(const char *cp,char **endp,unsigned int base) -{ - if(*cp=='-') - return -simple_strtoul(cp+1,endp,base); - return simple_strtoul(cp,endp,base); -} - -/** - * simple_strtoull - convert a string to an unsigned long long - * @cp: The start of the string - * @endp: A pointer to the end of the parsed string will be placed here - * @base: The number base to use - */ -unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base) -{ - unsigned long long result = 0, value; - - if (*cp == '0') { - cp++; - if ((toupper(*cp) == 'X') && isxdigit (cp[1])) { - base = 16; - cp++; - } - if (!base) { - base = 8; - } - } - if (!base) { - base = 10; - } - while (isxdigit (*cp) && (value = isdigit (*cp) - ? *cp - '0' - : (islower (*cp) ? toupper (*cp) : *cp) - 'A' + 10) < base) { - result = result * base + value; - cp++; - } - if (endp) - *endp = (char *) cp; - return result; -} - -/** - * simple_strtoll - convert a string to a signed long long - * @cp: The start of the string - * @endp: A pointer to the end of the parsed string will be placed here - * @base: The number base to use - */ -long long simple_strtoll(const char *cp,char **endp,unsigned int base) -{ - if(*cp=='-') - return -simple_strtoull(cp+1,endp,base); - return simple_strtoull(cp,endp,base); -} - -/** - * vsscanf - Unformat a buffer into a list of arguments - * @buf: input buffer - * @fmt: format of buffer - * @args: arguments - */ -int vsscanf(const char * buf, const char * fmt, va_list args) -{ - const char *str = buf; - char *next; - int num = 0; - int qualifier; - int base; - int field_width = -1; - int is_sign = 0; - - while(*fmt && *str) { - /* skip any white space in format */ - /* white space in format matchs any amount of - * white space, including none, in the input. - */ - if (isspace(*fmt)) { - while (isspace(*fmt)) - ++fmt; - while (isspace(*str)) - ++str; - } - - /* anything that is not a conversion must match exactly */ - if (*fmt != '%' && *fmt) { - if (*fmt++ != *str++) - break; - continue; - } - - if (!*fmt) - break; - ++fmt; - - /* skip this conversion. - * advance both strings to next white space - */ - if (*fmt == '*') { - while (!isspace(*fmt) && *fmt) - fmt++; - while (!isspace(*str) && *str) - str++; - continue; - } - - /* get field width */ - if (isdigit(*fmt)) - field_width = skip_atoi(&fmt); - - /* get conversion qualifier */ - qualifier = -1; - if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'Z') { - qualifier = *fmt; - fmt++; - } - base = 10; - is_sign = 0; - - if (!*fmt || !*str) - break; - - switch(*fmt++) { - case 'c': - { - char *s = (char *) va_arg(args,char*); - if (field_width == -1) - field_width = 1; - do { - *s++ = *str++; - } while(field_width-- > 0 && *str); - num++; - } - continue; - case 's': - { - char *s = (char *) va_arg(args, char *); - if(field_width == -1) - field_width = INT_MAX; - /* first, skip leading white space in buffer */ - while (isspace(*str)) - str++; - - /* now copy until next white space */ - while (*str && !isspace(*str) && field_width--) { - *s++ = *str++; - } - *s = '\0'; - num++; - } - continue; - case 'n': - /* return number of characters read so far */ - { - int *i = (int *)va_arg(args,int*); - *i = str - buf; - } - continue; - case 'o': - base = 8; - break; - case 'x': - case 'X': - base = 16; - break; - case 'd': - case 'i': - is_sign = 1; - case 'u': - break; - case '%': - /* looking for '%' in str */ - if (*str++ != '%') - return num; - continue; - default: - /* invalid format; stop here */ - return num; - } - - /* have some sort of integer conversion. - * first, skip white space in buffer. - */ - while (isspace(*str)) - str++; - - if (!*str || !isdigit(*str)) - break; - - switch(qualifier) { - case 'h': - if (is_sign) { - short *s = (short *) va_arg(args,short *); - *s = (short) simple_strtol(str,&next,base); - } else { - unsigned short *s = (unsigned short *) va_arg(args, unsigned short *); - *s = (unsigned short) simple_strtoul(str, &next, base); - } - break; - case 'l': - if (is_sign) { - long *l = (long *) va_arg(args,long *); - *l = simple_strtol(str,&next,base); - } else { - unsigned long *l = (unsigned long*) va_arg(args,unsigned long*); - *l = simple_strtoul(str,&next,base); - } - break; - case 'L': - if (is_sign) { - long long *l = (long long*) va_arg(args,long long *); - *l = simple_strtoll(str,&next,base); - } else { - unsigned long long *l = (unsigned long long*) va_arg(args,unsigned long long*); - *l = simple_strtoull(str,&next,base); - } - break; - case 'Z': - { - unsigned long *s = (unsigned long*) va_arg(args,unsigned long*); - *s = (unsigned long) simple_strtoul(str,&next,base); - } - break; - default: - if (is_sign) { - int *i = (int *) va_arg(args, int*); - *i = (int) simple_strtol(str,&next,base); - } else { - unsigned int *i = (unsigned int*) va_arg(args, unsigned int*); - *i = (unsigned int) simple_strtoul(str,&next,base); - } - break; - } - num++; - - if (!next) - break; - str = next; - } - return num; -} - -/** - * sscanf - Unformat a buffer into a list of arguments - * @buf: input buffer - * @fmt: formatting of buffer - * @...: resulting arguments - */ -int sscanf(const char * buf, const char * fmt, ...) -{ - va_list args; - int i; - - va_start(args,fmt); - i = vsscanf(buf,fmt,args); - va_end(args); - - return i; -} - -size_t strspn(const char *s, const char *accept) -{ - size_t l=0; - int a=1,i, al=strlen(accept); - - while((a)&&(*s)) - { - for(a=i=0;(!a)&&(i terminate it */ - } - *ptrptr=s; - return tmp; -} - -char *strtok(char *s, const char *delim) -{ - static char *strtok_pos; - return strtok_r(s,delim,&strtok_pos); -} - -char *strchr(const char *s1, int i) -{ - const unsigned char *s = (const unsigned char *)s1; - unsigned char c = (unsigned int)i; - - while (*s && *s != c) - { - s++; - } - - if (*s != c) - { - s = NULL; - } - - return (char *) s; -} - -long strtol(const char *str, char **endptr, int base) -{ - return simple_strtol(str, endptr, base); -} - -long long strtoll(const char *str, char **endptr, int base) -{ - return simple_strtoll(str, endptr, base); -} - -#endif diff --git a/components/libc/compilers/minilibc/string.h b/components/libc/compilers/minilibc/string.h deleted file mode 100644 index 45524c7764..0000000000 --- a/components/libc/compilers/minilibc/string.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2008-08-14 Bernard the first version - */ -#ifndef __STRING_H__ -#define __STRING_H__ - -#include -#include - -/* 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 _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); - -long strtol(const char *str, char **endptr, int base); -long long strtoll(const char *str, char **endptr, int base); -#endif - -#endif diff --git a/components/libc/compilers/minilibc/sys/mman.h b/components/libc/compilers/minilibc/sys/mman.h deleted file mode 100644 index 8c61b32b7c..0000000000 --- a/components/libc/compilers/minilibc/sys/mman.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2017/11/30 Bernard The first version. - */ - -#ifndef _SYS_MMAN_H -#define _SYS_MMAN_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAP_FAILED ((void *) -1) - -#define MAP_SHARED 0x01 -#define MAP_PRIVATE 0x02 -#define MAP_TYPE 0x0f -#define MAP_FIXED 0x10 -#define MAP_ANON 0x20 -#define MAP_ANONYMOUS MAP_ANON -#define MAP_NORESERVE 0x4000 -#define MAP_GROWSDOWN 0x0100 -#define MAP_DENYWRITE 0x0800 -#define MAP_EXECUTABLE 0x1000 -#define MAP_LOCKED 0x2000 -#define MAP_POPULATE 0x8000 -#define MAP_NONBLOCK 0x10000 -#define MAP_STACK 0x20000 -#define MAP_HUGETLB 0x40000 -#define MAP_FILE 0 - -#define PROT_NONE 0 -#define PROT_READ 1 -#define PROT_WRITE 2 -#define PROT_EXEC 4 -#define PROT_GROWSDOWN 0x01000000 -#define PROT_GROWSUP 0x02000000 - -#define MS_ASYNC 1 -#define MS_INVALIDATE 2 -#define MS_SYNC 4 - -#define MCL_CURRENT 1 -#define MCL_FUTURE 2 -#define MCL_ONFAULT 4 - -void *mmap (void *start, size_t len, int prot, int flags, int fd, off_t off); -int munmap (void *start, size_t len); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/components/libc/compilers/minilibc/sys/stat.h b/components/libc/compilers/minilibc/sys/stat.h deleted file mode 100644 index 65db477a4a..0000000000 --- a/components/libc/compilers/minilibc/sys/stat.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __STAT_H__ -#define __STAT_H__ - -#include - -#ifdef RT_USING_DFS -#include -#else -#define _FREAD 0x0001 /* read enabled */ -#define _FWRITE 0x0002 /* write enabled */ -#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */ -#define _FMARK 0x0010 /* internal; mark during gc() */ -#define _FDEFER 0x0020 /* internal; defer for next gc pass */ -#define _FASYNC 0x0040 /* signal pgrp when data ready */ -#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */ -#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */ -#define _FCREAT 0x0200 /* open with file create */ -#define _FTRUNC 0x0400 /* open with truncation */ -#define _FEXCL 0x0800 /* error on open if file exists */ -#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */ -#define _FSYNC 0x2000 /* do all writes synchronously */ -#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ -#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */ -#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ - -#define O_RDONLY 0 /* +1 == FREAD */ -#define O_WRONLY 1 /* +1 == FWRITE */ -#define O_RDWR 2 /* +1 == FREAD|FWRITE */ -#define O_APPEND _FAPPEND -#define O_CREAT _FCREAT -#define O_TRUNC _FTRUNC -#define O_EXCL _FEXCL -#define O_SYNC _FSYNC -#endif - -#endif diff --git a/components/libc/compilers/minilibc/sys/time.h b/components/libc/compilers/minilibc/sys/time.h deleted file mode 100644 index 22a93f5c9d..0000000000 --- a/components/libc/compilers/minilibc/sys/time.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef _SYS_TIME_H_ -#define _SYS_TIME_H_ - -#include -typedef long time_t; - -/* - * 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. */ -}; - -int gettimeofday(struct timeval *tp, void *ignore); - -#endif diff --git a/components/libc/compilers/minilibc/sys/types.h b/components/libc/compilers/minilibc/sys/types.h deleted file mode 100644 index 746235273c..0000000000 --- a/components/libc/compilers/minilibc/sys/types.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __TYPES_H__ -#define __TYPES_H__ -#include - -typedef long off_t; - -#ifndef ARCH_CPU_64BIT -typedef unsigned int size_t; -typedef signed int ssize_t; /* Used for a count of bytes or an error indication. */ -#else -typedef long unsigned int size_t; -typedef long signed int ssize_t; /* Used for a count of bytes or an error indication. */ -#endif - -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; - -typedef unsigned long clockid_t; -typedef int pid_t; - -typedef int gid_t; -typedef int uid_t; -typedef int dev_t; -typedef int ino_t; -typedef int mode_t; -typedef int caddr_t; - -typedef unsigned int wint_t; -typedef unsigned long useconds_t; - -typedef unsigned long clock_t; /* clock() */ - -#ifndef NULL -#define NULL (0) -#endif - -#define __u_char_defined - -#endif - diff --git a/components/libc/compilers/minilibc/time.c b/components/libc/compilers/minilibc/time.c deleted file mode 100644 index 25e8f0e310..0000000000 --- a/components/libc/compilers/minilibc/time.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#include -#include - -/* 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 = {0}; - 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 mktime(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 > 24) - { - t->tm_mday += t->tm_hour / 24; - t->tm_hour %= 24; - } - 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)) - { - --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) - { - years -= 131; - 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; -} - -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)); -} - -#ifdef RT_USING_DEVICE -int gettimeofday(struct timeval *tp, void *ignore) -{ - time_t time; - rt_device_t device; - - device = rt_device_find("rtc"); - RT_ASSERT(device != RT_NULL); - - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (tp != RT_NULL) - { - tp->tv_sec = time; - tp->tv_usec = 0; - } - - return time; -} -#endif - -#ifndef _gettimeofday -/* Dummy function when hardware do not have RTC */ -int _gettimeofday( struct timeval *tv, void *ignore) -{ - tv->tv_sec = 0; // convert to seconds - tv->tv_usec = 0; // get remaining microseconds - return 0; // return non-zero for error -} -#endif - -/** - * Returns the current time. - * - * @param time_t * t the timestamp pointer, if not used, keep NULL. - * - * @return time_t return timestamp current. - * - */ -/* for IAR 6.2 later Compiler */ -#if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000 -#pragma module_name = "?time" -time_t (__time32)(time_t *t) /* Only supports 32-bit timestamp */ -#else -time_t time(time_t *t) -#endif -{ - time_t time_now = 0; - -#ifdef RT_USING_RTC - static rt_device_t device = RT_NULL; - - /* optimization: find rtc device only first. */ - if (device == RT_NULL) - { - device = rt_device_find("rtc"); - } - - /* read timestamp from RTC device. */ - if (device != RT_NULL) - { - if (rt_device_open(device, 0) == RT_EOK) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time_now); - rt_device_close(device); - } - } -#endif /* RT_USING_RTC */ - - /* if t is not NULL, write timestamp to *t */ - if (t != RT_NULL) - { - *t = time_now; - } - - return time_now; -} - -RT_WEAK clock_t clock(void) -{ - return rt_tick_get(); -} diff --git a/components/libc/compilers/minilibc/time.h b/components/libc/compilers/minilibc/time.h deleted file mode 100644 index 09fc7d2e67..0000000000 --- a/components/libc/compilers/minilibc/time.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2006-2018, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - */ -#ifndef __TIME_H__ -#define __TIME_H__ - -#include - -time_t mktime(struct tm * const t); - -char *asctime(const struct tm *timeptr); -char *ctime(const time_t *timep); -struct tm* localtime(const time_t* t); - -char *asctime_r(const struct tm *t, char *buf); -struct tm *gmtime_r(const time_t *timep, struct tm *r); -struct tm* localtime_r(const time_t* t, struct tm* r); - -#endif