提交 a714c65c 编写于 作者: mysterywolf's avatar mysterywolf 提交者: guo

[kernel] 统一kernel内置rt_xxx的libc和标准libc库,防止割裂越来越大

上级 584d06bd
/* /*
* Copyright (c) 2006-2021, RT-Thread Development Team * Copyright (c) 2006-2022, RT-Thread Development Team
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
...@@ -42,13 +42,18 @@ ...@@ -42,13 +42,18 @@
* 2022-01-07 Gabriel move some __on_rt_xxxxx_hook to dedicated c source files * 2022-01-07 Gabriel move some __on_rt_xxxxx_hook to dedicated c source files
* 2022-01-12 Meco Man remove RT_THREAD_BLOCK * 2022-01-12 Meco Man remove RT_THREAD_BLOCK
* 2022-04-20 Meco Man change version number to v4.1.1 * 2022-04-20 Meco Man change version number to v4.1.1
* 2022-06-29 Meco Man add RT_USING_LIBC and standard libc headers
*/ */
#ifndef __RT_DEF_H__ #ifndef __RT_DEF_H__
#define __RT_DEF_H__ #define __RT_DEF_H__
/* include rtconfig header to import configuration */
#include <rtconfig.h> #include <rtconfig.h>
#ifdef RT_USING_LIBC
#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
#endif /* RT_USING_LIBC */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -72,8 +77,6 @@ extern "C" { ...@@ -72,8 +77,6 @@ extern "C" {
/* RT-Thread basic data type definitions */ /* RT-Thread basic data type definitions */
#ifndef RT_USING_ARCH_DATA_TYPE #ifndef RT_USING_ARCH_DATA_TYPE
#ifdef RT_USING_LIBC #ifdef RT_USING_LIBC
#include <stdint.h>
#include <stddef.h>
typedef int8_t rt_int8_t; /**< 8bit integer type */ typedef int8_t rt_int8_t; /**< 8bit integer type */
typedef int16_t rt_int16_t; /**< 16bit integer type */ typedef int16_t rt_int16_t; /**< 16bit integer type */
typedef int32_t rt_int32_t; /**< 32bit integer type */ typedef int32_t rt_int32_t; /**< 32bit integer type */
...@@ -119,12 +122,26 @@ typedef rt_base_t rt_off_t; /**< Type for offset */ ...@@ -119,12 +122,26 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_TRUE 1 /**< boolean true */ #define RT_TRUE 1 /**< boolean true */
#define RT_FALSE 0 /**< boolean fails */ #define RT_FALSE 0 /**< boolean fails */
/* null pointer definition */
#ifdef RT_USING_LIBC
#define RT_NULL NULL /**< null pointer */
#else
#define RT_NULL (0) /**< null pointer */
#endif /* RT_USING_LIBC */
/**@}*/ /**@}*/
/* maximum value of base type */ /* maximum value of base type */
#ifdef RT_USING_LIBC
#define RT_UINT8_MAX UINT8_MAX /**< Maximum number of UINT8 */
#define RT_UINT16_MAX UINT16_MAX /**< Maximum number of UINT16 */
#define RT_UINT32_MAX UINT32_MAX /**< Maximum number of UINT32 */
#else
#define RT_UINT8_MAX 0xff /**< Maximum number of UINT8 */ #define RT_UINT8_MAX 0xff /**< Maximum number of UINT8 */
#define RT_UINT16_MAX 0xffff /**< Maximum number of UINT16 */ #define RT_UINT16_MAX 0xffff /**< Maximum number of UINT16 */
#define RT_UINT32_MAX 0xffffffff /**< Maximum number of UINT32 */ #define RT_UINT32_MAX 0xffffffff /**< Maximum number of UINT32 */
#endif /* RT_USING_LIBC */
#define RT_TICK_MAX RT_UINT32_MAX /**< Maximum number of tick */ #define RT_TICK_MAX RT_UINT32_MAX /**< Maximum number of tick */
/* maximum value of ipc type */ /* maximum value of ipc type */
...@@ -138,84 +155,76 @@ typedef rt_base_t rt_off_t; /**< Type for offset */ ...@@ -138,84 +155,76 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
/* Compiler Related Definitions */ /* Compiler Related Definitions */
#if defined(__ARMCC_VERSION) /* ARM Compiler */ #if defined(__ARMCC_VERSION) /* ARM Compiler */
#include <stdarg.h> #define RT_SECTION(x) __attribute__((section(x)))
#define RT_SECTION(x) __attribute__((section(x))) #define RT_USED __attribute__((used))
#define RT_USED __attribute__((used)) #define ALIGN(n) __attribute__((aligned(n)))
#define ALIGN(n) __attribute__((aligned(n))) #define RT_WEAK __attribute__((weak))
#define RT_WEAK __attribute__((weak)) #define rt_inline static __inline
#define rt_inline static __inline /* module compiling */
/* module compiling */ #ifdef RT_USING_MODULE
#ifdef RT_USING_MODULE #define RTT_API __declspec(dllimport)
#define RTT_API __declspec(dllimport) #else
#else #define RTT_API __declspec(dllexport)
#define RTT_API __declspec(dllexport) #endif /* RT_USING_MODULE */
#endif /* RT_USING_MODULE */
#elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */ #elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
#include <stdarg.h> #define RT_SECTION(x) @ x
#define RT_SECTION(x) @ x #define RT_USED __root
#define RT_USED __root #define PRAGMA(x) _Pragma(#x)
#define PRAGMA(x) _Pragma(#x) #define ALIGN(n) PRAGMA(data_alignment=n)
#define ALIGN(n) PRAGMA(data_alignment=n) #define RT_WEAK __weak
#define RT_WEAK __weak #define rt_inline static inline
#define rt_inline static inline #define RTT_API
#define RTT_API
#elif defined (__GNUC__) /* GNU GCC Compiler */ #elif defined (__GNUC__) /* GNU GCC Compiler */
#ifdef RT_USING_NEWLIB #ifndef RT_USING_LIBC
#include <stdarg.h> /* the version of GNU GCC must be greater than 4.x */
#else typedef __builtin_va_list __gnuc_va_list;
/* the version of GNU GCC must be greater than 4.x */ typedef __gnuc_va_list va_list;
typedef __builtin_va_list __gnuc_va_list; #define va_start(v,l) __builtin_va_start(v,l)
typedef __gnuc_va_list va_list; #define va_end(v) __builtin_va_end(v)
#define va_start(v,l) __builtin_va_start(v,l) #define va_arg(v,l) __builtin_va_arg(v,l)
#define va_end(v) __builtin_va_end(v) #endif /* RT_USING_LIBC */
#define va_arg(v,l) __builtin_va_arg(v,l) #define RT_SECTION(x) __attribute__((section(x)))
#endif /* RT_USING_NEWLIB */ #define RT_USED __attribute__((used))
#define RT_SECTION(x) __attribute__((section(x))) #define ALIGN(n) __attribute__((aligned(n)))
#define RT_USED __attribute__((used)) #define RT_WEAK __attribute__((weak))
#define ALIGN(n) __attribute__((aligned(n))) #define rt_inline static __inline
#define RT_WEAK __attribute__((weak)) #define RTT_API
#define rt_inline static __inline
#define RTT_API
#elif defined (__ADSPBLACKFIN__) /* for VisualDSP++ Compiler */ #elif defined (__ADSPBLACKFIN__) /* for VisualDSP++ Compiler */
#include <stdarg.h> #define RT_SECTION(x) __attribute__((section(x)))
#define RT_SECTION(x) __attribute__((section(x))) #define RT_USED __attribute__((used))
#define RT_USED __attribute__((used)) #define ALIGN(n) __attribute__((aligned(n)))
#define ALIGN(n) __attribute__((aligned(n))) #define RT_WEAK __attribute__((weak))
#define RT_WEAK __attribute__((weak)) #define rt_inline static inline
#define rt_inline static inline #define RTT_API
#define RTT_API
#elif defined (_MSC_VER) #elif defined (_MSC_VER)
#include <stdarg.h> #define RT_SECTION(x)
#define RT_SECTION(x) #define RT_USED
#define RT_USED #define ALIGN(n) __declspec(align(n))
#define ALIGN(n) __declspec(align(n)) #define RT_WEAK
#define RT_WEAK #define rt_inline static __inline
#define rt_inline static __inline #define RTT_API
#define RTT_API
#elif defined (__TI_COMPILER_VERSION__) #elif defined (__TI_COMPILER_VERSION__)
#include <stdarg.h> /* The way that TI compiler set section is different from other(at least
/* The way that TI compiler set section is different from other(at least * GCC and MDK) compilers. See ARM Optimizing C/C++ Compiler 5.9.3 for more
* GCC and MDK) compilers. See ARM Optimizing C/C++ Compiler 5.9.3 for more * details. */
* details. */ #define RT_SECTION(x)
#define RT_SECTION(x) #define RT_USED
#define RT_USED #define PRAGMA(x) _Pragma(#x)
#define PRAGMA(x) _Pragma(#x) #define ALIGN(n)
#define ALIGN(n) #define RT_WEAK
#define RT_WEAK #define rt_inline static inline
#define rt_inline static inline #define RTT_API
#define RTT_API
#elif defined (__TASKING__) #elif defined (__TASKING__)
#include <stdarg.h> #define RT_SECTION(x) __attribute__((section(x)))
#define RT_SECTION(x) __attribute__((section(x))) #define RT_USED __attribute__((used, protect))
#define RT_USED __attribute__((used, protect)) #define PRAGMA(x) _Pragma(#x)
#define PRAGMA(x) _Pragma(#x) #define ALIGN(n) __attribute__((__align(n)))
#define ALIGN(n) __attribute__((__align(n))) #define RT_WEAK __attribute__((weak))
#define RT_WEAK __attribute__((weak)) #define rt_inline static inline
#define rt_inline static inline #define RTT_API
#define RTT_API
#else #else
#error not supported tool chain #error not supported tool chain
#endif #endif /* __ARMCC_VERSION */
/* initialization export */ /* initialization export */
#ifdef RT_USING_COMPONENTS_INIT #ifdef RT_USING_COMPONENTS_INIT
...@@ -353,14 +362,6 @@ typedef int (*init_fn_t)(void); ...@@ -353,14 +362,6 @@ typedef int (*init_fn_t)(void);
*/ */
#define RT_ALIGN_DOWN(size, align) ((size) & ~((align) - 1)) #define RT_ALIGN_DOWN(size, align) ((size) & ~((align) - 1))
/**
* @ingroup BasicDef
*
* @def RT_NULL
* Similar as the \c NULL in C library.
*/
#define RT_NULL (0)
/** /**
* Double List structure * Double List structure
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册