From 4d16b4937bb57c73212cb39d60a76835f35c5d2a Mon Sep 17 00:00:00 2001 From: eonaholic <1452381148@qq.com> Date: Mon, 1 Jan 2024 00:17:13 +0800 Subject: [PATCH] 12 --- src/kernel/include/los_typedef.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/kernel/include/los_typedef.h b/src/kernel/include/los_typedef.h index 98d5ce6..dedd290 100644 --- a/src/kernel/include/los_typedef.h +++ b/src/kernel/include/los_typedef.h @@ -25,9 +25,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * --------------------------------------------------------------------------- */ -/*以上代码是一个类型定义的头文件,用于定义各种数据类型。其中包括基本的整数类型(如UINT8、INT16)、浮点类型(如FLOAT、DOUBLE)、字符类型(CHAR)等。 -此外还定义了一些常用的宏和常量,如NULL、TRUE、FALSE、LOS_OK等。代码中还包含了一些编译器相关的宏定义和属性设置,用于控制变量对齐方式、变量和函数的节 -分配等。该头文件适用于嵌入式系统开发,可以提高代码的可读性和可移植性。*/ + /** * @defgroup los_typedef Type define * @ingroup kernel @@ -50,7 +48,8 @@ extern "C" { #define OS_STRING(x) #x #define X_STRING(x) OS_STRING(x) -/* type definitions *//*类型定义*/ +/* type definitions */ +//定义数据类型 typedef unsigned char UINT8; typedef unsigned short UINT16; typedef unsigned int UINT32; @@ -61,7 +60,10 @@ typedef float FLOAT; typedef double DOUBLE; typedef char CHAR; + + #ifdef __LP64__ +//64位数据模型 typedef long unsigned int UINT64; typedef long signed int INT64; typedef unsigned long UINTPTR; @@ -73,6 +75,7 @@ typedef INT64 ssize_t; typedef UINT64 size_t; #endif #else +//32位数据模型 typedef unsigned long long UINT64; typedef signed long long INT64; typedef unsigned int UINTPTR; @@ -82,7 +85,7 @@ typedef INT32 ssize_t; typedef UINT32 size_t; #endif #endif - +//一些常数的定义 typedef UINTPTR AARCHPTR; typedef size_t BOOL; @@ -151,7 +154,7 @@ typedef volatile INT64 Atomic64; #ifndef LOSARC_ALIGNMENT #define LOSARC_ALIGNMENT 8 #endif -/* And corresponding power of two alignment *//*使用 2 的幂次方作为对齐大小*/ +/* And corresponding power of two alignment */ #ifndef LOSARC_P2ALIGNMENT #ifdef LOSCFG_AARCH64 #define LOSARC_P2ALIGNMENT 3 @@ -160,12 +163,12 @@ typedef volatile INT64 Atomic64; #endif #endif -/* Give a type or object explicit minimum alignment *//*为类型或对象指定明确的最小对齐方式*/ +/* Give a type or object explicit minimum alignment */ #if !defined(LOSBLD_ATTRIB_ALIGN) #define LOSBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__))) #endif -/* Assign a defined variable to a specific section *//*将定义的变量分配给特定节*/ +/* Assign a defined variable to a specific section */ #if !defined(LOSBLD_ATTRIB_SECTION) #define LOSBLD_ATTRIB_SECTION(__sect__) __attribute__((section(__sect__))) #endif @@ -176,11 +179,6 @@ typedef volatile INT64 Atomic64; * but using the unused attribute should stop warnings. */ #define LOSBLD_ATTRIB_USED __attribute__((used)) -/*告诉编译器不要丢弃变量或函数。仅已知 - -*3.3.2或更高版本提供。旧版本没有把它们扔掉, - -*但是使用未使用的属性应该停止警告*/ #ifdef __cplusplus #if __cplusplus