13#ifndef __xwos_lib_type_h__
14#define __xwos_lib_type_h__
16#include <cfg/project.h>
24#include <xwos/ospl/soc/type.h>
28# define NULL ((void *)0)
35# define BITS_PER_CHAR 8U
41# define CHAR_MAX ((signed char)(UCHAR_MAX >> (unsigned char)1))
44# define CHAR_MIN ((signed char)(-CHAR_MAX - (signed char)1))
48# define BITS_PER_UCHAR 8U
51# define UCHAR_SHIFT 3U
54# define UCHAR_MAX ((unsigned char)(~((unsigned char)0)))
57# define UCHAR_MIN ((unsigned char)0)
62# define BITS_PER_SHRT 16U
68# define SHRT_MAX ((signed short)(USHRT_MAX >> (unsigned short)1))
71# define SHRT_MIN ((signed short)(-SHRT_MAX - (signed short)1))
75# define BITS_PER_USHRT 16U
78# define USHRT_SHIFT 4U
81# define USHRT_MAX ((unsigned short)(~((unsigned short)0)))
84# define USHRT_MIN (unsigned short)0)
89# define BITS_PER_INT 32U
95# define INT_MAX ((signed int)(UINT_MAX >> (unsigned int)1))
98# define INT_MIN ((signed int)(-INT_MAX - (signed int)1))
102# define BITS_PER_UINT 32U
105# define UINT_SHIFT 5U
108# define UINT_MAX ((unsigned int)(~((unsigned int)0)))
111# define UINT_MIN (unsigned int)0)
116# define BITS_PER_LONG 32U
119# define LONG_SHIFT 5U
122# define LONG_MAX ((signed long)(ULONG_MAX >> (unsigned long)1))
125# define LONG_MIN ((signed long)(-LONG_MAX - (signed long)1))
128#ifndef BITS_PER_ULONG
129# define BITS_PER_ULONG 32U
132# define LONG_SHIFT 5U
135# define ULONG_MAX ((unsigned long)(~((unsigned long)0)))
138# define ULONG_MIN ((unsigned long)0)
142#ifndef BITS_PER_LLONG
143# define BITS_PER_LLONG 64U
146# define LLONG_SHIFT 6U
149# define LLONG_MAX ((signed long long)(ULLONG_MAX >> (unsigned long long)1))
152# define LLONG_MIN ((signed long long)(-LLONG_MAX - (signed long long)1))
155#ifndef BITS_PER_ULLONG
156# define BITS_PER_ULLONG 64U
159# define ULLONG_SHIFT 6U
162# define ULLONG_MAX ((unsigned long long)(~((unsigned long long)0)))
165# define ULLONG_MIN (unsigned long long)0)
170# define BITS_PER_FLT 32U
178# define BITS_PER_DBL 64U
186# define BITS_PER_LDBL 128U
189# define LDBL_SHIFT 7U
193#if !defined(ARCH_HAVE_XWU8_T) || defined(__DOXYGEN__)
196#if !defined(ARCH_HAVE_ATOMIC_XWU8_T) || defined(__DOXYGEN__)
199#ifndef BITS_PER_XWU8_T
200# define BITS_PER_XWU8_T 8U
203# define XWU8_T_SHIFT 3U
206# define XWU8_MAX ((xwu8_t)(~((xwu8_t)0)))
209#if !defined(ARCH_HAVE_XWS8_T) || defined(__DOXYGEN__)
212#if !defined(ARCH_HAVE_ATOMIC_XWS8_T) || defined(__DOXYGEN__)
215#ifndef BITS_PER_XWS8_T
216# define BITS_PER_XWS8_T 8U
219# define XWS8_T_SHIFT 3U
222# define XWS8_MAX ((xws8_t)(XWU8_MAX >> (xwu8_t)1))
225# define XWS8_MIN ((xws8_t)(-XWS8_MAX - (xws8_t)1))
229#if !defined(ARCH_HAVE_XWU16_T) || defined(__DOXYGEN__)
232#if !defined(ARCH_HAVE_ATOMIC_XWU16_T) || defined(__DOXYGEN__)
235#ifndef BITS_PER_XWU16_T
236# define BITS_PER_XWU16_T 16U
239# define XWU16_T_SHIFT 4U
242# define XWU16_MAX ((xwu16_t)(~((xwu16_t)0)))
245#if !defined(ARCH_HAVE_XWS16_T) || defined(__DOXYGEN__)
248#if !defined(ARCH_HAVE_ATOMIC_XWS16_T) || defined(__DOXYGEN__)
251#ifndef BITS_PER_XWS16_T
252# define BITS_PER_XWS16_T 16U
255# define XWS16_T_SHIFT 4U
258# define XWS16_MAX ((xws16_t)(XWU16_MAX >> (xwu16_t)1))
261# define XWS16_MIN ((xws16_t)(-XWS16_MAX - (xws16_t)1))
265#if !defined(ARCH_HAVE_XWU32_T) || defined(__DOXYGEN__)
268#if !defined(ARCH_HAVE_ATOMIC_XWU32_T) || defined(__DOXYGEN__)
271#ifndef BITS_PER_XWU32_T
272# define BITS_PER_XWU32_T 32U
275# define XWU32_T_SHIFT 5U
278# define XWU32_MAX ((xwu32_t)(~((xwu32_t)0)))
282#if !defined(ARCH_HAVE_XWS32_T) || defined(__DOXYGEN__)
285#if !defined(ARCH_HAVE_ATOMIC_XWS32_T) || defined(__DOXYGEN__)
288#ifndef BITS_PER_XWS32_T
289# define BITS_PER_XWS32_T 32U
292# define XWS32_T_SHIFT 5U
295# define XWS32_MAX ((xws32_t)(XWU32_MAX >> (xwu32_t)1))
298# define XWS32_MIN ((xws32_t)(-XWS32_MAX - (xws32_t)1))
302#if !defined(ARCH_HAVE_XWU64_T) || defined(__DOXYGEN__)
305#if !defined(ARCH_HAVE_ATOMIC_XWU64_T) || defined(__DOXYGEN__)
308#ifndef BITS_PER_XWU64_T
309# define BITS_PER_XWU64_T 64U
312# define XWU64_T_SHIFT 6U
315# define XWU64_MAX ((xwu64_t)(~((xwu64_t)0)))
318#if !defined(ARCH_HAVE_XWS64_T) || defined(__DOXYGEN__)
321#if !defined(ARCH_HAVE_ATOMIC_XWS64_T) || defined(__DOXYGEN__)
324#ifndef BITS_PER_XWS64_T
325# define BITS_PER_XWS64_T 64U
328# define XWS64_T_SHIFT 6U
331# define XWS64_MAX ((xws64_t)(XWU64_MAX >> (xwu64_t)1))
334# define XWS64_MIN ((xws64_t)(-XWS64_MAX - (xws64_t)1))
338#if !defined(ARCH_HAVE_XWSZ_T) || defined(__DOXYGEN__)
341#if !defined(ARCH_HAVE_ATOMIC_XWSZ_T) || defined(__DOXYGEN__)
344#ifndef BITS_PER_XWSZ_T
345# define BITS_PER_XWSZ_T BITS_PER_ULONG
348# define XWSZ_T_SHIFT ULONG_SHIFT
351# define XWSZ_MAX ((xwsz_t)(~((xwsz_t)0)))
354#if !defined(ARCH_HAVE_XWSSZ_T) || defined(__DOXYGEN__)
357#if !defined(ARCH_HAVE_ATOMIC_XWSSZ_T) || defined(__DOXYGEN__)
360#ifndef BITS_PER_XWSSZ_T
361# define BITS_PER_XWSSZ_T BITS_PER_LONG
364# define XWSSZ_T_SHIFT LONG_SHIFT
367# define XWSSZ_MAX ((xwssz_t)(XWSZ_MAX >> (xwsz_t)1))
370# define XWSSZ_MIN ((xwssz_t)(-XWSSZ_MAX - (xwssz_t)1))
374#if !defined(ARCH_HAVE_XWPTR_T) || defined(__DOXYGEN__)
377#if !defined(ARCH_HAVE_ATOMIC_XWPTR_T) || defined(__DOXYGEN__)
380#ifndef BITS_PER_XWPTR_T
381# define BITS_PER_XWPTR_T BITS_PER_ULONG
384# define XWPTR_T_SHIFT ULONG_SHIFT
387# define XWPTR_MAX ((xwptr_t)(~(xwptr_t)0))
391#if !defined(ARCH_HAVE_XWSTK_T) || defined(__DOXYGEN__)
394#if !defined(ARCH_HAVE_ATOMIC_XWSTK_T) || defined(__DOXYGEN__)
397#ifndef BITS_PER_XWSTK_T
398# define BITS_PER_XWSTK_T BITS_PER_XWPTR_T
401# define XWSTK_T_SHIFT XWPTR_T_SHIFT
404# define XWSTK_MAX ((xwstk_t)(~(xwstk_t)0))
408#if !defined(ARCH_HAVE_XWREG_T) || defined(__DOXYGEN__)
411#if !defined(ARCH_HAVE_ATOMIC_XWREG_T) || defined(__DOXYGEN__)
414#ifndef BITS_PER_XWREG_T
415# define BITS_PER_XWREG_T BITS_PER_XWPTR_T
418# define XWREG_T_SHIFT XWPTR_T_SHIFT
421# define XWREG_MAX ((xwreg_t)(~((xwreg_t)0)))
424#if !defined(ARCH_HAVE_XWSREG_T) || defined(__DOXYGEN__)
427#if !defined(ARCH_HAVE_ATOMIC_XWSREG_T) || defined(__DOXYGEN__)
430#ifndef BITS_PER_XWSREG_T
431# define BITS_PER_XWSREG_T BITS_PER_XWREG_T
433#ifndef XWSREG_T_SHIFT
434# define XWSREG_T_SHIFT XWREG_T_SHIFT
437# define XWSREG_MAX ((xwsreg_t)(XWREG_MAX >> (xwreg_t)1))
440# define XWSREG_MIN ((xwsreg_t)(-XWSREG_MAX - (xwsreg_t)1))
444#if !defined(ARCH_HAVE_XWSQ_T) || defined(__DOXYGEN__)
447#if !defined(ARCH_HAVE_ATOMIC_XWSQ_T) || defined(__DOXYGEN__)
450#ifndef BITS_PER_XWSQ_T
451# define BITS_PER_XWSQ_T BITS_PER_ULONG
454# define XWSQ_T_SHIFT ULONG_SHIFT
457# define XWSQ_MAX ((xwsq_t)(~((xwsq_t)0)))
460#if !defined(ARCH_HAVE_XWSSQ_T) || defined(__DOXYGEN__)
463#if !defined(ARCH_HAVE_ATOMIC_XWSSQ_T) || defined(__DOXYGEN__)
466#ifndef BITS_PER_XWSSQ_T
467# define BITS_PER_XWSSQ_T BITS_PER_LONG
470# define XWSSQ_T_SHIFT LONG_SHIFT
473# define XWSSQ_MAX ((xwssq_t)(XWSQ_MAX >> (xwsq_t)1))
476# define XWSSQ_MIN ((xwssq_t)(-XWSSQ_MAX - (xwssq_t)1))
480#if !defined(ARCH_HAVE_XWID_T) || defined(__DOXYGEN__)
483#if !defined(ARCH_HAVE_ATOMIC_XWID_T) || defined(__DOXYGEN__)
486#ifndef BITS_PER_XWID_T
487# define BITS_PER_XWID_T BITS_PER_ULONG
490# define XWID_T_SHIFT ULONG_SHIFT
493# define XWID_MAX ((xwid_t)(~((xwid_t)0)))
496#if !defined(ARCH_HAVE_XWSID_T) || defined(__DOXYGEN__)
499#if !defined(ARCH_HAVE_ATOMIC_XWSID_T) || defined(__DOXYGEN__)
502#ifndef BITS_PER_XWSID_T
503# define BITS_PER_XWSID_T BITS_PER_LONG
506# define XWSID_T_SHIFT LONG_SHIFT
509# define XWSID_MAX ((xwsid_t)(XWID_MAX >> (xwid_t)1))
512# define XWSID_MIN ((xwsid_t)(-XWSID_MAX - (xwsid_t)1))
516#if !defined(ARCH_HAVE_XWIRQ_T) || defined(__DOXYGEN__)
519#ifndef BITS_PER_XWIRQ_T
520# define BITS_PER_XWIRQ_T BITS_PER_INT
523# define XWIRQ_T_SHIFT INT_SHIFT
526# define XWIRQ_MAX ((xwirq_t)((~(unsigned int)0) >> (unsigned int)1))
529# define XWIRQ_MIN ((xwirq_t)(-XWIRQ_MAX - (xwirq_t)1))
533#if !defined(ARCH_HAVE_XWPR_T) || defined(__DOXYGEN__)
536#if !defined(ARCH_HAVE_ATOMIC_XWPR_T) || defined(__DOXYGEN__)
539#ifndef BITS_PER_XWPR_T
540# define BITS_PER_XWPR_T BITS_PER_XWS32_T
543# define XWPR_T_SHIFT XWS32_T_SHIFT
546# define XWPR_MAX ((xwpr_t)((~(xwu32_t)0) >> (xwu32_t)1))
549# define XWPR_MIN ((xwpr_t)(-XWPR_MAX - (xwpr_t)1))
553#if !defined(ARCH_HAVE_XWER_T) || defined(__DOXYGEN__)
556#if !defined(ARCH_HAVE_ATOMIC_XWER_T) || defined(__DOXYGEN__)
559#ifndef BITS_PER_XWER_T
560# define BITS_PER_XWER_T BITS_PER_LONG
563# define XWER_T_SHIFT LONG_SHIFT
566# define XWER_MAX ((xwer_t)OK)
569# define XWER_MIN ((xwer_t)(-MAX_ERRNO))
573#if !defined(ARCH_HAVE_XWBMP_T) || defined(__DOXYGEN__)
576#if !defined(ARCH_HAVE_ATOMIC_XWBMP_T) || defined(__DOXYGEN__)
579#ifndef BITS_PER_XWBMP_T
580# define BITS_PER_XWBMP_T BITS_PER_XWU32_T
583# define XWBMP_T_SHIFT XWU32_T_SHIFT
586# define XWBMP_MAX ((xwbmp_t)(~((xwbmp_t)0)))
590#if !defined(ARCH_HAVE_XWLFQ_T) || defined(__DOXYGEN__)
593#if !defined(ARCH_HAVE_ATOMIC_XWLFQ_T) || defined(__DOXYGEN__)
596#ifndef BITS_PER_XWLFQ_T
597# define BITS_PER_XWLFQ_T BITS_PER_XWPTR_T
600# define XWLFQ_T_SHIFT XWPTR_T_SHIFT
706#if !defined(ARCH_HAVE_XWTK_T) || defined(__DOXYGEN__)
712#if !defined(ARCH_HAVE_ATOMIC_XWTK_T) || defined(__DOXYGEN__)
723# define XWTK_MAX ((xwtk_t)((~(xwu64_t)0)))
729# define XWTK_MIN ((xwtk_t)0)
731#ifndef BITS_PER_XWTK_T
732# define BITS_PER_XWTK_T BITS_PER_XWU64_T
735# define XWTK_T_SHIFT XWU64_T_SHIFT
738#if !defined(ARCH_HAVE_XWTM_T) || defined(__DOXYGEN__)
744#if !defined(ARCH_HAVE_ATOMIC_XWTM_T) || defined(__DOXYGEN__)
755# define XWTM_MAX ((xwtm_t)((~(xwu64_t)0) >> 1))
761# define XWTM_MIN ((xwtm_t)(-XWTM_MAX - (xwtm_t)1))
763#ifndef BITS_PER_XWTM_T
764# define BITS_PER_XWTM_T BITS_PER_XWS64_T
767# define XWTM_T_SHIFT XWS64_T_SHIFT
774#define XWTM_NS(ns) (ns)
780#define XWTM_US(us) ((us) * 1000LL)
786#define XWTM_MS(ms) ((ms) * 1000000LL)
792#define XWTM_S(s) ((s) * 1000000000LL)
798#define XWTM_M(m) ((m) * XWTM_S(60))
804#define XWTM_H(h) ((h) * XWTM_M(60))
810#define XWTM_D(d) ((d) * XWTM_H(24))
812#if !defined(ARCH_HAVE_XWTM_T)
__xwcc_atomic xwtk_t atomic_xwtk_t
XWOS系统滴答计数 (无符号,原子的)
#define XWTM_S(s)
系统时间的单位:秒
static __xwcc_inline xwtm_t xwtm_add_safely(const xwtm_t a, const xwtm_t b)
将两个系统时间相加,并检查溢出
xws64_t xwtm_t
XWOS系统时间 (有符号)
#define XWTM_M(m)
系统时间的单位:分
#define XWTM_US(us)
系统时间的单位:微秒
__xwcc_atomic xwtm_t atomic_xwtm_t
XWOS系统时间 (有符号,原子的)
#define XWTM_NS(ns)
系统时间的单位:纳秒
static __xwcc_inline xwtm_t xwtm_ns(xwtm_t ns)
返回以 纳秒 为单位的系统时间
static __xwcc_inline xwtm_t xwtm_ms(xwtm_t ms)
返回以 毫秒 为单位的系统时间
static __xwcc_inline xwtm_t xwtm_sub(const xwtm_t a, const xwtm_t b)
将两个系统时间相减
#define XWTM_D(d)
系统时间的单位:天
static __xwcc_inline xwtm_t xwtm_h(xwtm_t h)
返回以 时 为单位的系统时间
static __xwcc_inline xwtm_t xwtm_d(xwtm_t d)
返回以 天 为单位的系统时间
#define XWTM_H(h)
系统时间的单位:时
xwu64_t xwtk_t
XWOS系统滴答计数 (无符号)
#define XWTM_MAX
xwtm_t 的最大值
static __xwcc_inline xwer_t xwtm_cmp(const xwtm_t a, const xwtm_t b)
比较两个系统时间
static __xwcc_inline xwtm_t xwtm_s(xwtm_t s)
返回以 秒 为单位的系统时间
static __xwcc_inline xwtm_t xwtm_us(xwtm_t us)
返回以 微秒 为单位的系统时间
static __xwcc_inline xwtm_t xwtm_add(const xwtm_t a, const xwtm_t b)
将两个系统时间相加
#define XWTM_MS(ms)
系统时间的单位:毫秒
static __xwcc_inline xwtm_t xwtm_m(xwtm_t m)
返回以 分 为单位的系统时间
__xwcc_atomic xwu8_t atomic_xwu8_t
__xwcc_atomic xwssq_t atomic_xwssq_t
__xwcc_atomic xwssz_t atomic_xwssz_t
__xwcc_atomic xwlfq_t atomic_xwlfq_t
__xwcc_atomic xwu64_t atomic_xwu64_t
__xwcc_atomic xwsq_t atomic_xwsq_t
xwaop_memory_order_em
原子操作内存模型
__xwcc_atomic xwpr_t atomic_xwpr_t
__xwcc_atomic xwstk_t atomic_xwstk_t
xwer_t(* xwaop_tst_f)(const void *, void *)
原子变量测试函数指针类型
xws64_t(* xwsc_f)(void *,...)
__xwcc_atomic xwbmp_t atomic_xwbmp_t
__xwcc_atomic xwid_t atomic_xwid_t
__xwcc_atomic xwu32_t atomic_xwu32_t
__xwcc_atomic xwer_t atomic_xwer_t
__xwcc_atomic xwu16_t atomic_xwu16_t
__xwcc_atomic xwreg_t atomic_xwreg_t
__xwcc_atomic xws64_t atomic_xws64_t
__xwcc_atomic xws8_t atomic_xws8_t
__xwcc_atomic xwsreg_t atomic_xwsreg_t
void(* xwaop_op_f)(void *, const void *, void *)
原子变量操作函数指针类型
xwos_lock_type_em
XWOS的锁类型枚举
__xwcc_atomic xwptr_t atomic_xwptr_t
__xwcc_atomic xwsz_t atomic_xwsz_t
__xwcc_atomic xwsid_t atomic_xwsid_t
__xwcc_atomic xws32_t atomic_xws32_t
__xwcc_atomic xws16_t atomic_xws16_t
类型为XWOS_LK_CALLBACK时的抽象锁函数
union xwos_ulock::@7 xwup
union xwos_ulock::@8 osal
union xwos_ulock::@6 xwmp