XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
type.h
浏览该文件的文档.
1
13#ifndef __xwos_lib_type_h__
14#define __xwos_lib_type_h__
15
16#include <cfg/project.h>
17
24#include <xwos/ospl/soc/type.h>
25#include <stdarg.h>
26
27#ifndef NULL
28# define NULL ((void *)0)
29#endif
30#ifndef NIL
31# define NIL NULL
32#endif
33
34#ifndef BITS_PER_CHAR
35# define BITS_PER_CHAR 8U
36#endif
37#ifndef CHAR_SHIFT
38# define CHAR_SHIFT 3U
39#endif
40#ifndef CHAR_MAX
41# define CHAR_MAX ((signed char)(UCHAR_MAX >> (unsigned char)1))
42#endif
43#ifndef CHAR_MIN
44# define CHAR_MIN ((signed char)(-CHAR_MAX - (signed char)1))
45#endif
46
47#ifndef BITS_PER_UCHAR
48# define BITS_PER_UCHAR 8U
49#endif
50#ifndef UCHAR_SHIFT
51# define UCHAR_SHIFT 3U
52#endif
53#ifndef UCHAR_MAX
54# define UCHAR_MAX ((unsigned char)(~((unsigned char)0)))
55#endif
56#ifndef UCHAR_MIN
57# define UCHAR_MIN ((unsigned char)0)
58#endif
59
60
61#ifndef BITS_PER_SHRT
62# define BITS_PER_SHRT 16U
63#endif
64#ifndef SHRT_SHIFT
65# define SHRT_SHIFT 4U
66#endif
67#ifndef SHRT_MAX
68# define SHRT_MAX ((signed short)(USHRT_MAX >> (unsigned short)1))
69#endif
70#ifndef SHRT_MIN
71# define SHRT_MIN ((signed short)(-SHRT_MAX - (signed short)1))
72#endif
73
74#ifndef BITS_PER_USHRT
75# define BITS_PER_USHRT 16U
76#endif
77#ifndef USHRT_SHIFT
78# define USHRT_SHIFT 4U
79#endif
80#ifndef USHRT_MAX
81# define USHRT_MAX ((unsigned short)(~((unsigned short)0)))
82#endif
83#ifndef USHRT_MIN
84# define USHRT_MIN (unsigned short)0)
85#endif
86
87
88#ifndef BITS_PER_INT
89# define BITS_PER_INT 32U
90#endif
91#ifndef INT_SHIFT
92# define INT_SHIFT 5U
93#endif
94#ifndef INT_MAX
95# define INT_MAX ((signed int)(UINT_MAX >> (unsigned int)1))
96#endif
97#ifndef INT_MIN
98# define INT_MIN ((signed int)(-INT_MAX - (signed int)1))
99#endif
100
101#ifndef BITS_PER_UINT
102# define BITS_PER_UINT 32U
103#endif
104#ifndef UINT_SHIFT
105# define UINT_SHIFT 5U
106#endif
107#ifndef UINT_MAX
108# define UINT_MAX ((unsigned int)(~((unsigned int)0)))
109#endif
110#ifndef UINT_MIN
111# define UINT_MIN (unsigned int)0)
112#endif
113
114
115#ifndef BITS_PER_LONG
116# define BITS_PER_LONG 32U
117#endif
118#ifndef LONG_SHIFT
119# define LONG_SHIFT 5U
120#endif
121#ifndef LONG_MAX
122# define LONG_MAX ((signed long)(ULONG_MAX >> (unsigned long)1))
123#endif
124#ifndef LONG_MIN
125# define LONG_MIN ((signed long)(-LONG_MAX - (signed long)1))
126#endif
127
128#ifndef BITS_PER_ULONG
129# define BITS_PER_ULONG 32U
130#endif
131#ifndef LONG_SHIFT
132# define LONG_SHIFT 5U
133#endif
134#ifndef ULONG_MAX
135# define ULONG_MAX ((unsigned long)(~((unsigned long)0)))
136#endif
137#ifndef ULONG_MIN
138# define ULONG_MIN ((unsigned long)0)
139#endif
140
141
142#ifndef BITS_PER_LLONG
143# define BITS_PER_LLONG 64U
144#endif
145#ifndef LLONG_SHIFT
146# define LLONG_SHIFT 6U
147#endif
148#ifndef LLONG_MAX
149# define LLONG_MAX ((signed long long)(ULLONG_MAX >> (unsigned long long)1))
150#endif
151#ifndef LLONG_MIN
152# define LLONG_MIN ((signed long long)(-LLONG_MAX - (signed long long)1))
153#endif
154
155#ifndef BITS_PER_ULLONG
156# define BITS_PER_ULLONG 64U
157#endif
158#ifndef ULLONG_SHIFT
159# define ULLONG_SHIFT 6U
160#endif
161#ifndef ULLONG_MAX
162# define ULLONG_MAX ((unsigned long long)(~((unsigned long long)0)))
163#endif
164#ifndef ULLONG_MIN
165# define ULLONG_MIN (unsigned long long)0)
166#endif
167
168
169#ifndef BITS_PER_FLT
170# define BITS_PER_FLT 32U
171#endif
172#ifndef FLT_SHIFT
173# define FLT_SHIFT 5U
174#endif
175
176
177#ifndef BITS_PER_DBL
178# define BITS_PER_DBL 64U
179#endif
180#ifndef DBL_SHIFT
181# define DBL_SHIFT 6U
182#endif
183
184
185#ifndef BITS_PER_LDBL
186# define BITS_PER_LDBL 128U
187#endif
188#ifndef LDBL_SHIFT
189# define LDBL_SHIFT 7U
190#endif
191
192
193#if !defined(ARCH_HAVE_XWU8_T) || defined(__DOXYGEN__)
194typedef uint8_t xwu8_t;
195#endif
196#if !defined(ARCH_HAVE_ATOMIC_XWU8_T) || defined(__DOXYGEN__)
198#endif
199#ifndef BITS_PER_XWU8_T
200# define BITS_PER_XWU8_T 8U
201#endif
202#ifndef XWU8_T_SHIFT
203# define XWU8_T_SHIFT 3U
204#endif
205#ifndef XWU8_MAX
206# define XWU8_MAX ((xwu8_t)(~((xwu8_t)0)))
207#endif
208
209#if !defined(ARCH_HAVE_XWS8_T) || defined(__DOXYGEN__)
210typedef int8_t xws8_t;
211#endif
212#if !defined(ARCH_HAVE_ATOMIC_XWS8_T) || defined(__DOXYGEN__)
214#endif
215#ifndef BITS_PER_XWS8_T
216# define BITS_PER_XWS8_T 8U
217#endif
218#ifndef XWS8_T_SHIFT
219# define XWS8_T_SHIFT 3U
220#endif
221#ifndef XWS8_MAX
222# define XWS8_MAX ((xws8_t)(XWU8_MAX >> (xwu8_t)1))
223#endif
224#ifndef XWS8_MIN
225# define XWS8_MIN ((xws8_t)(-XWS8_MAX - (xws8_t)1))
226#endif
227
228
229#if !defined(ARCH_HAVE_XWU16_T) || defined(__DOXYGEN__)
230typedef uint16_t xwu16_t;
231#endif
232#if !defined(ARCH_HAVE_ATOMIC_XWU16_T) || defined(__DOXYGEN__)
234#endif
235#ifndef BITS_PER_XWU16_T
236# define BITS_PER_XWU16_T 16U
237#endif
238#ifndef XWU16_T_SHIFT
239# define XWU16_T_SHIFT 4U
240#endif
241#ifndef XWU16_MAX
242# define XWU16_MAX ((xwu16_t)(~((xwu16_t)0)))
243#endif
244
245#if !defined(ARCH_HAVE_XWS16_T) || defined(__DOXYGEN__)
246typedef int16_t xws16_t;
247#endif
248#if !defined(ARCH_HAVE_ATOMIC_XWS16_T) || defined(__DOXYGEN__)
250#endif
251#ifndef BITS_PER_XWS16_T
252# define BITS_PER_XWS16_T 16U
253#endif
254#ifndef XWS16_T_SHIFT
255# define XWS16_T_SHIFT 4U
256#endif
257#ifndef XWS16_MAX
258# define XWS16_MAX ((xws16_t)(XWU16_MAX >> (xwu16_t)1))
259#endif
260#ifndef XWS16_MIN
261# define XWS16_MIN ((xws16_t)(-XWS16_MAX - (xws16_t)1))
262#endif
263
264
265#if !defined(ARCH_HAVE_XWU32_T) || defined(__DOXYGEN__)
266typedef uint32_t xwu32_t;
267#endif
268#if !defined(ARCH_HAVE_ATOMIC_XWU32_T) || defined(__DOXYGEN__)
270#endif
271#ifndef BITS_PER_XWU32_T
272# define BITS_PER_XWU32_T 32U
273#endif
274#ifndef XWU32_T_SHIFT
275# define XWU32_T_SHIFT 5U
276#endif
277#ifndef XWU32_MAX
278# define XWU32_MAX ((xwu32_t)(~((xwu32_t)0)))
279#endif
280
281
282#if !defined(ARCH_HAVE_XWS32_T) || defined(__DOXYGEN__)
283typedef int32_t xws32_t;
284#endif
285#if !defined(ARCH_HAVE_ATOMIC_XWS32_T) || defined(__DOXYGEN__)
287#endif
288#ifndef BITS_PER_XWS32_T
289# define BITS_PER_XWS32_T 32U
290#endif
291#ifndef XWS32_T_SHIFT
292# define XWS32_T_SHIFT 5U
293#endif
294#ifndef XWS32_MAX
295# define XWS32_MAX ((xws32_t)(XWU32_MAX >> (xwu32_t)1))
296#endif
297#ifndef XWS32_MIN
298# define XWS32_MIN ((xws32_t)(-XWS32_MAX - (xws32_t)1))
299#endif
300
301
302#if !defined(ARCH_HAVE_XWU64_T) || defined(__DOXYGEN__)
303typedef uint64_t xwu64_t;
304#endif
305#if !defined(ARCH_HAVE_ATOMIC_XWU64_T) || defined(__DOXYGEN__)
307#endif
308#ifndef BITS_PER_XWU64_T
309# define BITS_PER_XWU64_T 64U
310#endif
311#ifndef XWU64_T_SHIFT
312# define XWU64_T_SHIFT 6U
313#endif
314#ifndef XWU64_MAX
315# define XWU64_MAX ((xwu64_t)(~((xwu64_t)0)))
316#endif
317
318#if !defined(ARCH_HAVE_XWS64_T) || defined(__DOXYGEN__)
319typedef int64_t xws64_t;
320#endif
321#if !defined(ARCH_HAVE_ATOMIC_XWS64_T) || defined(__DOXYGEN__)
323#endif
324#ifndef BITS_PER_XWS64_T
325# define BITS_PER_XWS64_T 64U
326#endif
327#ifndef XWS64_T_SHIFT
328# define XWS64_T_SHIFT 6U
329#endif
330#ifndef XWS64_MAX
331# define XWS64_MAX ((xws64_t)(XWU64_MAX >> (xwu64_t)1))
332#endif
333#ifndef XWS64_MIN
334# define XWS64_MIN ((xws64_t)(-XWS64_MAX - (xws64_t)1))
335#endif
336
337
338#if !defined(ARCH_HAVE_XWSZ_T) || defined(__DOXYGEN__)
339typedef unsigned long xwsz_t;
340#endif
341#if !defined(ARCH_HAVE_ATOMIC_XWSZ_T) || defined(__DOXYGEN__)
343#endif
344#ifndef BITS_PER_XWSZ_T
345# define BITS_PER_XWSZ_T BITS_PER_ULONG
346#endif
347#ifndef XWSZ_T_SHIFT
348# define XWSZ_T_SHIFT ULONG_SHIFT
349#endif
350#ifndef XWSZ_MAX
351# define XWSZ_MAX ((xwsz_t)(~((xwsz_t)0)))
352#endif
353
354#if !defined(ARCH_HAVE_XWSSZ_T) || defined(__DOXYGEN__)
355typedef signed long xwssz_t;
356#endif
357#if !defined(ARCH_HAVE_ATOMIC_XWSSZ_T) || defined(__DOXYGEN__)
359#endif
360#ifndef BITS_PER_XWSSZ_T
361# define BITS_PER_XWSSZ_T BITS_PER_LONG
362#endif
363#ifndef XWSSZ_T_SHIFT
364# define XWSSZ_T_SHIFT LONG_SHIFT
365#endif
366#ifndef XWSSZ_MAX
367# define XWSSZ_MAX ((xwssz_t)(XWSZ_MAX >> (xwsz_t)1))
368#endif
369#ifndef XWSSZ_MIN
370# define XWSSZ_MIN ((xwssz_t)(-XWSSZ_MAX - (xwssz_t)1))
371#endif
372
373
374#if !defined(ARCH_HAVE_XWPTR_T) || defined(__DOXYGEN__)
375typedef unsigned long xwptr_t;
376#endif
377#if !defined(ARCH_HAVE_ATOMIC_XWPTR_T) || defined(__DOXYGEN__)
379#endif
380#ifndef BITS_PER_XWPTR_T
381# define BITS_PER_XWPTR_T BITS_PER_ULONG
382#endif
383#ifndef XWPTR_T_SHIFT
384# define XWPTR_T_SHIFT ULONG_SHIFT
385#endif
386#ifndef XWPTR_MAX
387# define XWPTR_MAX ((xwptr_t)(~(xwptr_t)0))
388#endif
389
390
391#if !defined(ARCH_HAVE_XWSTK_T) || defined(__DOXYGEN__)
393#endif
394#if !defined(ARCH_HAVE_ATOMIC_XWSTK_T) || defined(__DOXYGEN__)
396#endif
397#ifndef BITS_PER_XWSTK_T
398# define BITS_PER_XWSTK_T BITS_PER_XWPTR_T
399#endif
400#ifndef XWSTK_T_SHIFT
401# define XWSTK_T_SHIFT XWPTR_T_SHIFT
402#endif
403#ifndef XWSTK_MAX
404# define XWSTK_MAX ((xwstk_t)(~(xwstk_t)0))
405#endif
406
407
408#if !defined(ARCH_HAVE_XWREG_T) || defined(__DOXYGEN__)
410#endif
411#if !defined(ARCH_HAVE_ATOMIC_XWREG_T) || defined(__DOXYGEN__)
413#endif
414#ifndef BITS_PER_XWREG_T
415# define BITS_PER_XWREG_T BITS_PER_XWPTR_T
416#endif
417#ifndef XWREG_T_SHIFT
418# define XWREG_T_SHIFT XWPTR_T_SHIFT
419#endif
420#ifndef XWREG_MAX
421# define XWREG_MAX ((xwreg_t)(~((xwreg_t)0)))
422#endif
423
424#if !defined(ARCH_HAVE_XWSREG_T) || defined(__DOXYGEN__)
425typedef ptrdiff_t xwsreg_t;
426#endif
427#if !defined(ARCH_HAVE_ATOMIC_XWSREG_T) || defined(__DOXYGEN__)
429#endif
430#ifndef BITS_PER_XWSREG_T
431# define BITS_PER_XWSREG_T BITS_PER_XWREG_T
432#endif
433#ifndef XWSREG_T_SHIFT
434# define XWSREG_T_SHIFT XWREG_T_SHIFT
435#endif
436#ifndef XWSREG_MAX
437# define XWSREG_MAX ((xwsreg_t)(XWREG_MAX >> (xwreg_t)1))
438#endif
439#ifndef XWSREG_MIN
440# define XWSREG_MIN ((xwsreg_t)(-XWSREG_MAX - (xwsreg_t)1))
441#endif
442
443
444#if !defined(ARCH_HAVE_XWSQ_T) || defined(__DOXYGEN__)
445typedef unsigned long xwsq_t;
446#endif
447#if !defined(ARCH_HAVE_ATOMIC_XWSQ_T) || defined(__DOXYGEN__)
449#endif
450#ifndef BITS_PER_XWSQ_T
451# define BITS_PER_XWSQ_T BITS_PER_ULONG
452#endif
453#ifndef XWSQ_T_SHIFT
454# define XWSQ_T_SHIFT ULONG_SHIFT
455#endif
456#ifndef XWSQ_MAX
457# define XWSQ_MAX ((xwsq_t)(~((xwsq_t)0)))
458#endif
459
460#if !defined(ARCH_HAVE_XWSSQ_T) || defined(__DOXYGEN__)
461typedef signed long xwssq_t;
462#endif
463#if !defined(ARCH_HAVE_ATOMIC_XWSSQ_T) || defined(__DOXYGEN__)
465#endif
466#ifndef BITS_PER_XWSSQ_T
467# define BITS_PER_XWSSQ_T BITS_PER_LONG
468#endif
469#ifndef XWSSQ_T_SHIFT
470# define XWSSQ_T_SHIFT LONG_SHIFT
471#endif
472#ifndef XWSSQ_MAX
473# define XWSSQ_MAX ((xwssq_t)(XWSQ_MAX >> (xwsq_t)1))
474#endif
475#ifndef XWSSQ_MIN
476# define XWSSQ_MIN ((xwssq_t)(-XWSSQ_MAX - (xwssq_t)1))
477#endif
478
479
480#if !defined(ARCH_HAVE_XWID_T) || defined(__DOXYGEN__)
481typedef unsigned long xwid_t;
482#endif
483#if !defined(ARCH_HAVE_ATOMIC_XWID_T) || defined(__DOXYGEN__)
485#endif
486#ifndef BITS_PER_XWID_T
487# define BITS_PER_XWID_T BITS_PER_ULONG
488#endif
489#ifndef XWID_T_SHIFT
490# define XWID_T_SHIFT ULONG_SHIFT
491#endif
492#ifndef XWID_MAX
493# define XWID_MAX ((xwid_t)(~((xwid_t)0)))
494#endif
495
496#if !defined(ARCH_HAVE_XWSID_T) || defined(__DOXYGEN__)
497typedef signed long xwsid_t;
498#endif
499#if !defined(ARCH_HAVE_ATOMIC_XWSID_T) || defined(__DOXYGEN__)
501#endif
502#ifndef BITS_PER_XWSID_T
503# define BITS_PER_XWSID_T BITS_PER_LONG
504#endif
505#ifndef XWSID_T_SHIFT
506# define XWSID_T_SHIFT LONG_SHIFT
507#endif
508#ifndef XWSID_MAX
509# define XWSID_MAX ((xwsid_t)(XWID_MAX >> (xwid_t)1))
510#endif
511#ifndef XWSID_MIN
512# define XWSID_MIN ((xwsid_t)(-XWSID_MAX - (xwsid_t)1))
513#endif
514
515
516#if !defined(ARCH_HAVE_XWIRQ_T) || defined(__DOXYGEN__)
517typedef signed int xwirq_t;
518#endif
519#ifndef BITS_PER_XWIRQ_T
520# define BITS_PER_XWIRQ_T BITS_PER_INT
521#endif
522#ifndef XWIRQ_T_SHIFT
523# define XWIRQ_T_SHIFT INT_SHIFT
524#endif
525#ifndef XWIRQ_MAX
526# define XWIRQ_MAX ((xwirq_t)((~(unsigned int)0) >> (unsigned int)1))
527#endif
528#ifndef XWIRQ_MIN
529# define XWIRQ_MIN ((xwirq_t)(-XWIRQ_MAX - (xwirq_t)1))
530#endif
531
532
533#if !defined(ARCH_HAVE_XWPR_T) || defined(__DOXYGEN__)
535#endif
536#if !defined(ARCH_HAVE_ATOMIC_XWPR_T) || defined(__DOXYGEN__)
538#endif
539#ifndef BITS_PER_XWPR_T
540# define BITS_PER_XWPR_T BITS_PER_XWS32_T
541#endif
542#ifndef XWPR_T_SHIFT
543# define XWPR_T_SHIFT XWS32_T_SHIFT
544#endif
545#ifndef XWPR_MAX
546# define XWPR_MAX ((xwpr_t)((~(xwu32_t)0) >> (xwu32_t)1))
547#endif
548#ifndef XWPR_MIN
549# define XWPR_MIN ((xwpr_t)(-XWPR_MAX - (xwpr_t)1))
550#endif
551
552
553#if !defined(ARCH_HAVE_XWER_T) || defined(__DOXYGEN__)
554typedef signed long xwer_t;
555#endif
556#if !defined(ARCH_HAVE_ATOMIC_XWER_T) || defined(__DOXYGEN__)
558#endif
559#ifndef BITS_PER_XWER_T
560# define BITS_PER_XWER_T BITS_PER_LONG
561#endif
562#ifndef XWER_T_SHIFT
563# define XWER_T_SHIFT LONG_SHIFT
564#endif
565#ifndef XWER_MAX
566# define XWER_MAX ((xwer_t)OK)
567#endif
568#ifndef XWER_MIN
569# define XWER_MIN ((xwer_t)(-MAX_ERRNO))
570#endif
571
572
573#if !defined(ARCH_HAVE_XWBMP_T) || defined(__DOXYGEN__)
575#endif
576#if !defined(ARCH_HAVE_ATOMIC_XWBMP_T) || defined(__DOXYGEN__)
578#endif
579#ifndef BITS_PER_XWBMP_T
580# define BITS_PER_XWBMP_T BITS_PER_XWU32_T
581#endif
582#ifndef XWBMP_T_SHIFT
583# define XWBMP_T_SHIFT XWU32_T_SHIFT
584#endif
585#ifndef XWBMP_MAX
586# define XWBMP_MAX ((xwbmp_t)(~((xwbmp_t)0)))
587#endif
588
589
590#if !defined(ARCH_HAVE_XWLFQ_T) || defined(__DOXYGEN__)
592#endif
593#if !defined(ARCH_HAVE_ATOMIC_XWLFQ_T) || defined(__DOXYGEN__)
595#endif
596#ifndef BITS_PER_XWLFQ_T
597# define BITS_PER_XWLFQ_T BITS_PER_XWPTR_T
598#endif
599#ifndef XWLFQ_T_SHIFT
600# define XWLFQ_T_SHIFT XWPTR_T_SHIFT
601#endif
602
603
604typedef void (* ctor_f)(void * /*obj*/);
605typedef void (* dtor_f)(void * /*obj*/);
606typedef void (* xwisr_f)(void);
607typedef xws64_t (* xwsc_f)(void * /*arg*/, ...);
612typedef xwer_t (* xwaop_tst_f)(const void * /* ov */ ,
613 void * /* args */);
614
618typedef void (* xwaop_op_f)(void * /* nv */,
619 const void * /* ov */,
620 void * /* args */);
621
634};
635
647};
648
652struct xwos_cblk {
653 xwer_t (* lock)(void * /*arg*/);
654 xwer_t (* unlock)(void * /*arg*/);
655};
656
663};
664
665struct xwos_mtx;
666struct xwos_splk;
667struct xwos_sqlk;
668struct xwmp_mtx;
669struct xwmp_splk;
670struct xwmp_sqlk;
671struct xwmp_mtx;
672struct xwmp_splk;
673struct xwmp_sqlk;
674
681 union {
682 struct xwmp_mtx * mtx;
683 struct xwmp_splk * splk;
684 struct xwmp_sqlk * sqlk;
686 union {
687 struct xwup_mtx * mtx;
688 struct xwup_splk * splk;
689 struct xwup_sqlk * sqlk;
691 union {
692 struct xwos_mtx * mtx;
693 struct xwos_splk * splk;
694 struct xwos_sqlk * sqlk;
696 struct xwos_cblk * cb;
697 void * anon;
699};
700
706#if !defined(ARCH_HAVE_XWTK_T) || defined(__DOXYGEN__)
711#endif
712#if !defined(ARCH_HAVE_ATOMIC_XWTK_T) || defined(__DOXYGEN__)
717#endif
718
719#ifndef XWTK_MAX
723# define XWTK_MAX ((xwtk_t)((~(xwu64_t)0)))
724#endif
725#ifndef XWTK_MIN
729# define XWTK_MIN ((xwtk_t)0)
730#endif
731#ifndef BITS_PER_XWTK_T
732# define BITS_PER_XWTK_T BITS_PER_XWU64_T
733#endif
734#ifndef XWTK_T_SHIFT
735# define XWTK_T_SHIFT XWU64_T_SHIFT
736#endif
737
738#if !defined(ARCH_HAVE_XWTM_T) || defined(__DOXYGEN__)
743#endif
744#if !defined(ARCH_HAVE_ATOMIC_XWTM_T) || defined(__DOXYGEN__)
749#endif
750
751#ifndef XWTM_MAX
755# define XWTM_MAX ((xwtm_t)((~(xwu64_t)0) >> 1))
756#endif
757#ifndef XWTM_MIN
761# define XWTM_MIN ((xwtm_t)(-XWTM_MAX - (xwtm_t)1))
762#endif
763#ifndef BITS_PER_XWTM_T
764# define BITS_PER_XWTM_T BITS_PER_XWS64_T
765#endif
766#ifndef XWTM_T_SHIFT
767# define XWTM_T_SHIFT XWS64_T_SHIFT
768#endif
769
774#define XWTM_NS(ns) (ns)
775
780#define XWTM_US(us) ((us) * 1000LL)
781
786#define XWTM_MS(ms) ((ms) * 1000000LL)
787
792#define XWTM_S(s) ((s) * 1000000000LL)
793
798#define XWTM_M(m) ((m) * XWTM_S(60))
799
804#define XWTM_H(h) ((h) * XWTM_M(60))
805
810#define XWTM_D(d) ((d) * XWTM_H(24))
811
812#if !defined(ARCH_HAVE_XWTM_T)
821static __xwcc_inline
823{
824 xwtm_t res;
825
826 res = a + b;
827 if (res < 0) {
828 res = XWTM_MAX;
829 }
830 return res;
831}
832
839static __xwcc_inline
840xwtm_t xwtm_add(const xwtm_t a, const xwtm_t b)
841{
842 return a + b;
843}
844
851static __xwcc_inline
852xwtm_t xwtm_sub(const xwtm_t a, const xwtm_t b)
853{
854 return a - b;
855}
856
866static __xwcc_inline
867xwer_t xwtm_cmp(const xwtm_t a, const xwtm_t b)
868{
869 xwer_t rc;
870
871 if (a > b) {
872 rc = 1;
873 } else if (a < b) {
874 rc = -1;
875 } else {
876 rc = 0;
877 }
878 return rc;
879}
880
886static __xwcc_inline
888{
889 return XWTM_NS(ns);
890}
891
897static __xwcc_inline
899{
900 return XWTM_US(us);
901}
902
908static __xwcc_inline
910{
911 return XWTM_MS(ms);
912}
913
919static __xwcc_inline
921{
922 return XWTM_S(s);
923}
924
930static __xwcc_inline
932{
933 return XWTM_M(m);
934}
935
941static __xwcc_inline
943{
944 return XWTM_H(h);
945}
946
952static __xwcc_inline
954{
955 return XWTM_D(d);
956}
957#endif
958 // xwos_lib_type_time // xwos_lib_type
961
962#endif /* xwos/lib/type.h */
#define __xwcc_inline
Definition compiler.h:77
#define __xwcc_atomic
Definition compiler.h:109
__xwcc_atomic xwtk_t atomic_xwtk_t
XWOS系统滴答计数 (无符号,原子的)
Definition type.h:716
#define XWTM_S(s)
系统时间的单位:秒
Definition type.h:792
static __xwcc_inline xwtm_t xwtm_add_safely(const xwtm_t a, const xwtm_t b)
将两个系统时间相加,并检查溢出
Definition type.h:822
xws64_t xwtm_t
XWOS系统时间 (有符号)
Definition type.h:742
#define XWTM_M(m)
系统时间的单位:分
Definition type.h:798
#define XWTM_US(us)
系统时间的单位:微秒
Definition type.h:780
__xwcc_atomic xwtm_t atomic_xwtm_t
XWOS系统时间 (有符号,原子的)
Definition type.h:748
#define XWTM_NS(ns)
系统时间的单位:纳秒
Definition type.h:774
static __xwcc_inline xwtm_t xwtm_ns(xwtm_t ns)
返回以 纳秒 为单位的系统时间
Definition type.h:887
static __xwcc_inline xwtm_t xwtm_ms(xwtm_t ms)
返回以 毫秒 为单位的系统时间
Definition type.h:909
static __xwcc_inline xwtm_t xwtm_sub(const xwtm_t a, const xwtm_t b)
将两个系统时间相减
Definition type.h:852
#define XWTM_D(d)
系统时间的单位:天
Definition type.h:810
static __xwcc_inline xwtm_t xwtm_h(xwtm_t h)
返回以 时 为单位的系统时间
Definition type.h:942
static __xwcc_inline xwtm_t xwtm_d(xwtm_t d)
返回以 天 为单位的系统时间
Definition type.h:953
#define XWTM_H(h)
系统时间的单位:时
Definition type.h:804
xwu64_t xwtk_t
XWOS系统滴答计数 (无符号)
Definition type.h:710
#define XWTM_MAX
xwtm_t 的最大值
Definition type.h:755
static __xwcc_inline xwer_t xwtm_cmp(const xwtm_t a, const xwtm_t b)
比较两个系统时间
Definition type.h:867
static __xwcc_inline xwtm_t xwtm_s(xwtm_t s)
返回以 秒 为单位的系统时间
Definition type.h:920
static __xwcc_inline xwtm_t xwtm_us(xwtm_t us)
返回以 微秒 为单位的系统时间
Definition type.h:898
static __xwcc_inline xwtm_t xwtm_add(const xwtm_t a, const xwtm_t b)
将两个系统时间相加
Definition type.h:840
#define XWTM_MS(ms)
系统时间的单位:毫秒
Definition type.h:786
static __xwcc_inline xwtm_t xwtm_m(xwtm_t m)
返回以 分 为单位的系统时间
Definition type.h:931
__xwcc_atomic xwu8_t atomic_xwu8_t
Definition type.h:197
signed long xwer_t
Definition type.h:554
unsigned long xwid_t
Definition type.h:481
__xwcc_atomic xwssq_t atomic_xwssq_t
Definition type.h:464
xws32_t xwpr_t
Definition type.h:534
xwptr_t xwstk_t
Definition type.h:392
signed int xwirq_t
Definition type.h:517
__xwcc_atomic xwssz_t atomic_xwssz_t
Definition type.h:358
__xwcc_atomic xwlfq_t atomic_xwlfq_t
Definition type.h:594
__xwcc_atomic xwu64_t atomic_xwu64_t
Definition type.h:306
__xwcc_atomic xwsq_t atomic_xwsq_t
Definition type.h:448
unsigned long xwsz_t
Definition type.h:339
xwaop_memory_order_em
原子操作内存模型
Definition type.h:627
__xwcc_atomic xwpr_t atomic_xwpr_t
Definition type.h:537
__xwcc_atomic xwstk_t atomic_xwstk_t
Definition type.h:395
xwer_t(* xwaop_tst_f)(const void *, void *)
原子变量测试函数指针类型
Definition type.h:612
xwos_lkst_em
XWOS锁状态
Definition type.h:660
uint8_t xwu8_t
Definition type.h:194
xws64_t(* xwsc_f)(void *,...)
Definition type.h:607
__xwcc_atomic xwbmp_t atomic_xwbmp_t
Definition type.h:577
unsigned long xwsq_t
Definition type.h:445
int64_t xws64_t
Definition type.h:319
__xwcc_atomic xwid_t atomic_xwid_t
Definition type.h:484
__xwcc_atomic xwu32_t atomic_xwu32_t
Definition type.h:269
__xwcc_atomic xwer_t atomic_xwer_t
Definition type.h:557
ptrdiff_t xwsreg_t
Definition type.h:425
__xwcc_atomic xwu16_t atomic_xwu16_t
Definition type.h:233
uint64_t xwu64_t
Definition type.h:303
xwptr_t xwlfq_t
Definition type.h:591
__xwcc_atomic xwreg_t atomic_xwreg_t
Definition type.h:412
signed long xwssq_t
Definition type.h:461
__xwcc_atomic xws64_t atomic_xws64_t
Definition type.h:322
__xwcc_atomic xws8_t atomic_xws8_t
Definition type.h:213
signed long xwsid_t
Definition type.h:497
signed long xwssz_t
Definition type.h:355
__xwcc_atomic xwsreg_t atomic_xwsreg_t
Definition type.h:428
void(* xwaop_op_f)(void *, const void *, void *)
原子变量操作函数指针类型
Definition type.h:618
xwos_lock_type_em
XWOS的锁类型枚举
Definition type.h:639
__xwcc_atomic xwptr_t atomic_xwptr_t
Definition type.h:378
unsigned long xwptr_t
Definition type.h:375
xwptr_t xwreg_t
Definition type.h:409
__xwcc_atomic xwsz_t atomic_xwsz_t
Definition type.h:342
__xwcc_atomic xwsid_t atomic_xwsid_t
Definition type.h:500
uint16_t xwu16_t
Definition type.h:230
uint32_t xwu32_t
Definition type.h:266
__xwcc_atomic xws32_t atomic_xws32_t
Definition type.h:286
int16_t xws16_t
Definition type.h:246
__xwcc_atomic xws16_t atomic_xws16_t
Definition type.h:249
void(* xwisr_f)(void)
Definition type.h:606
int8_t xws8_t
Definition type.h:210
xwu32_t xwbmp_t
Definition type.h:574
void(* ctor_f)(void *)
Definition type.h:604
int32_t xws32_t
Definition type.h:283
void(* dtor_f)(void *)
Definition type.h:605
@ xwaop_mo_acquire
Definition type.h:630
@ xwaop_mo_consume
Definition type.h:629
@ xwaop_mo_seq_cst
Definition type.h:633
@ xwaop_mo_acq_rel
Definition type.h:632
@ xwaop_mo_release
Definition type.h:631
@ xwaop_mo_relaxed
Definition type.h:628
@ XWOS_LKST_UNLOCKED
Definition type.h:661
@ XWOS_LKST_LOCKED
Definition type.h:662
@ XWOS_LK_NONE
Definition type.h:640
@ XWOS_LK_CALLBACK
Definition type.h:645
@ XWOS_LK_MTX
Definition type.h:641
@ XWOS_LK_SQLK_RDEX
Definition type.h:644
@ XWOS_LK_NUM
Definition type.h:646
@ XWOS_LK_SPLK
Definition type.h:642
@ XWOS_LK_SQLK_WR
Definition type.h:643
类型为XWOS_LK_CALLBACK时的抽象锁函数
Definition type.h:652
xwer_t(* lock)(void *)
Definition type.h:653
xwer_t(* unlock)(void *)
Definition type.h:654
XWOS API:互斥锁
Definition mtx.h:82
XWOS API:自旋锁
Definition spinlock.h:73
XWOS API:顺序锁
Definition seqlock.h:112
所有锁的联合
Definition type.h:680
struct xwup_sqlk * sqlk
Definition type.h:689
struct xwos_cblk * cb
Definition type.h:696
struct xwup_mtx * mtx
Definition type.h:687
union xwos_ulock::@7 xwup
struct xwup_splk * splk
Definition type.h:688
xwptr_t ptr
Definition type.h:698
struct xwmp_mtx * mtx
Definition type.h:682
struct xwmp_splk * splk
Definition type.h:683
void * anon
Definition type.h:697
union xwos_ulock::@8 osal
struct xwos_mtx * mtx
Definition type.h:692
struct xwos_splk * splk
Definition type.h:693
union xwos_ulock::@6 xwmp
struct xwos_sqlk * sqlk
Definition type.h:694
struct xwmp_sqlk * sqlk
Definition type.h:684