Arm-2D
2D Image Processing Library for Cortex-M Processors
arm_2d_utils.h
1
/*
2
* Copyright (C) 2010-2022 Arm Limited or its affiliates. All rights reserved.
3
*
4
* SPDX-License-Identifier: Apache-2.0
5
*
6
* Licensed under the Apache License, Version 2.0 (the License); you may
7
* not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
19
/* ----------------------------------------------------------------------
20
* Project: Arm-2D Library
21
* Title: arm_2d_utils.h
22
* Description: Public header file for Arm-2D Library
23
*
24
* $Date: 12. April 2024
25
* $Revision: V.1.4.3
26
*
27
* -------------------------------------------------------------------- */
28
29
#ifndef __ARM_2D_UTILS_H__
30
#define __ARM_2D_UTILS_H__
31
32
/*============================ INCLUDES ======================================*/
33
34
#if defined(__clang__)
35
# pragma clang diagnostic push
36
# pragma clang diagnostic ignored "-Wunknown-warning-option"
37
# pragma clang diagnostic ignored "-Wreserved-identifier"
38
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
39
# pragma clang diagnostic ignored "-Wpadded"
40
# pragma clang diagnostic ignored "-Wsign-conversion"
41
# pragma clang diagnostic ignored "-Wimplicit-int-conversion"
42
# pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
43
# pragma clang diagnostic ignored "-Wundef"
44
#elif defined(__IS_COMPILER_GCC__)
45
# pragma GCC diagnostic push
46
# pragma GCC diagnostic ignored "-Wpedantic"
47
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
48
# pragma GCC diagnostic ignored "-Wnonnull-compare"
49
#endif
50
51
#ifdef __ARM_2D_HAS_USER_HEADER__
52
# include __ARM_2D_HAS_USER_HEADER__
53
#endif
54
55
56
57
#undef __IS_SUPPORTED_ARM_ARCH__
58
#if ( (defined(__ARM_ARCH) && __ARM_ARCH) \
59
|| defined(__TARGET_ARCH_ARM)) && !defined(__APPLE__)
60
# define __IS_SUPPORTED_ARM_ARCH__ 1
61
#else
62
# define __IS_SUPPORTED_ARM_ARCH__ 0
63
#endif
64
65
/*! \note arm-2d relies on CMSIS 5.8.0 and above.
66
*/
67
#if __IS_SUPPORTED_ARM_ARCH__
68
69
#ifdef __cplusplus
70
extern
"C"
{
71
#endif
72
73
# include "cmsis_compiler.h"
74
75
#ifdef __cplusplus
76
}
77
#endif
78
79
#else
80
# include "arm_2d_user_arch_port.h"
81
#endif
82
83
84
#ifdef __cplusplus
85
extern
"C"
{
86
#endif
87
88
/*!
89
* \addtogroup gKernel 1 Kernel
90
* @{
91
*/
92
93
/*============================ MACROS ========================================*/
94
95
96
/*----------------------------------------------------------------------------*
97
* Environment Detection *
98
*----------------------------------------------------------------------------*/
99
100
101
/* The macros to identify compilers */
102
103
/* detect IAR */
104
#undef __IS_COMPILER_IAR__
105
#if defined(__IAR_SYSTEMS_ICC__)
106
# define __IS_COMPILER_IAR__ 1
107
#endif
108
109
/* detect arm compiler 5 */
110
#undef __IS_COMPILER_ARM_COMPILER_5__
111
#if ((__ARMCC_VERSION >= 5000000) && (__ARMCC_VERSION < 6000000))
112
# define __IS_COMPILER_ARM_COMPILER_5__ 1
113
#endif
114
115
116
/* detect arm compiler 6 */
117
#undef __IS_COMPILER_ARM_COMPILER_6__
118
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
119
# define __IS_COMPILER_ARM_COMPILER_6__ 1
120
#endif
121
122
/* detect arm compilers */
123
#undef __IS_COMPILER_ARM_COMPILER__
124
#if defined(__IS_COMPILER_ARM_COMPILER_5__) && __IS_COMPILER_ARM_COMPILER_5__ \
125
|| defined(__IS_COMPILER_ARM_COMPILER_6__) && __IS_COMPILER_ARM_COMPILER_6__
126
# define __IS_COMPILER_ARM_COMPILER__ 1
127
#endif
128
129
/* detect clang (llvm) */
130
#undef __IS_COMPILER_LLVM__
131
#if defined(__clang__) && !__IS_COMPILER_ARM_COMPILER_6__
132
# define __IS_COMPILER_LLVM__ 1
133
#else
134
135
/* detect gcc */
136
# undef __IS_COMPILER_GCC__
137
# if defined(__GNUC__) && !( defined(__IS_COMPILER_ARM_COMPILER__) \
138
|| defined(__IS_COMPILER_LLVM__) \
139
|| defined(__IS_COMPILER_IAR__))
140
# define __IS_COMPILER_GCC__ 1
141
# endif
142
143
#endif
144
145
/*----------------------------------------------------------------------------*
146
* OOC and Private Protection *
147
*----------------------------------------------------------------------------*/
148
/* minimal support for OOPC */
149
#undef __implement_ex
150
#undef __implement
151
#undef implement
152
#undef implement_ex
153
#undef inherit
154
#undef inherit_ex
155
156
/*!
157
* \note do NOT use this macro directly
158
*/
159
#ifdef __cplusplus
160
# define __implement_ex(__type, __name) __type __name
161
#else
162
# define __implement_ex(__type, __name) \
163
union { \
164
__type __name; \
165
__type; \
166
}
167
#endif
168
/*!
169
* \note do NOT use this macro
170
*/
171
#define __inherit_ex(__type, __name) __type __name
172
173
174
/*!
175
* \note do NOT use this macro directly
176
*/
177
#define __implement(__type) __implement_ex( __type, \
178
use_as__##__type)
179
180
181
/*!
182
* \note do NOT use this macro directly
183
*/
184
#define __inherit(__type) __inherit_ex(__type,use_as__##__type)
185
186
187
/*!
188
* \brief inherit a given class
189
* \param __type the base class, you can use .use_as_xxxxx for referencing
190
* the base.
191
* \note this macro supports microsoft extensions (-fms-extensions)
192
*/
193
#define implement(__type) __implement(__type)
194
195
/*!
196
* \brief inherit a given class and give it an alias name
197
* \param __type the base class
198
* \param __name an alias name for referencing the base class
199
* \note this macro supports microsoft extensions (-fms-extensions)
200
*/
201
#define implement_ex(__type, __name) __implement_ex(__type, __name)
202
203
204
/*!
205
* \brief inherit a given class
206
* \param __type the base class, you can use .use_as_xxxxx for referencing
207
* the base.
208
* \note this macro does NOT support microsoft extensions (-fms-extensions)
209
*/
210
#define inherit(__type) __inherit(__type)
211
212
/*!
213
* \brief inherit a given class and give it an alias name
214
* \param __type the base class
215
* \param __name an alias name for referencing the base class
216
* \note this macro does NOT support microsoft extensions (-fms-extensions)
217
*/
218
#define inherit_ex(__type, __name) __inherit_ex(__type, __name)
219
220
221
/*----------------------------------------------------------------------------*
222
* Misc *
223
*----------------------------------------------------------------------------*/
224
225
/*!
226
* \brief a macro to mark unused variables and let the compiler happy
227
*/
228
#ifndef ARM_2D_UNUSED
229
# define ARM_2D_UNUSED(__VAR) (void)(__VAR)
230
#endif
231
232
#ifndef ARM_2D_PARAM
233
# define ARM_2D_PARAM(__VAR) (void)(__VAR)
234
#endif
235
236
#undef ARM_TYPE_CONVERT
237
/*!
238
* \brief convert a given variable to a specified type, the converted result
239
* can be used as lvalue.
240
* \param __VAR the target variable
241
* \param __TYPE the target type
242
*/
243
#define ARM_TYPE_CONVERT(__VAR, __TYPE) (*((__TYPE *)&(__VAR)))
244
245
/*!
246
* \brief a macro to test the boolean result for a given value using a given
247
* bitmask
248
* \param[in] __VALUE the target value
249
* \param[in] __BITS a bitmask
250
* \retval true all bits in the bitmask is 1
251
* \retval false not all bits in the bitmask is 1
252
*/
253
#ifndef ARM_TEST_BITS
254
# define ARM_TEST_BITS(__VALUE, __BITS) ((__BITS) == ((__VALUE) & (__BITS)))
255
#endif
256
257
/*!
258
* \brief get the number of items in an given array
259
*/
260
#ifndef dimof
261
# define dimof(__array) (sizeof(__array)/sizeof(__array[0]))
262
#endif
263
264
/*!
265
* \brief get the offset of a given member in a specified structure/union
266
* \param __type the host type
267
* \param __member the name of the target member
268
* \return size_t the offset (in bytes)
269
*/
270
#ifndef offsetof
271
# define offsetof(__type, __member) \
272
((uintptr_t)&(((__type *)NULL)->__member))
273
#endif
274
275
/*!
276
* \note do NOT use this macro directly
277
*/
278
#define __ARM_TO_STRING(__STR) #__STR
279
280
/*!
281
* \brief convert a string to C string
282
*/
283
#define ARM_TO_STRING(__STR) __ARM_TO_STRING(__STR)
284
285
/*!
286
* \note do NOT use this macro directly
287
*/
288
#define __ARM_VA_NUM_ARGS_IMPL( _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12, \
289
_13,_14,_15,_16,__N,...) __N
290
291
/*!
292
* \brief A macro to count the number of parameters
293
*
294
* \note if GNU extension is not supported or enabled, the following express will
295
* be false: (__ARM_VA_NUM_ARGS() != 0)
296
* This might cause problems when in this library.
297
*/
298
#define __ARM_VA_NUM_ARGS(...) \
299
__ARM_VA_NUM_ARGS_IMPL( 0,##__VA_ARGS__,16,15,14,13,12,11,10,9, \
300
8,7,6,5,4,3,2,1,0)
301
302
/*!
303
* \brief detect whether GNU extension is enabled in compilation or not
304
*/
305
#if __ARM_VA_NUM_ARGS() != 0
306
# warning Please enable GNU extensions, it is required by the Arm-2D.
307
#endif
308
309
310
#undef ARM_2D_PARAM
311
312
/*!
313
* \brief a macro helper to be used with ARM_2D_INVODE to improve the
314
* readability of the code
315
*/
316
#define ARM_2D_PARAM(...) __VA_ARGS__
317
318
#ifndef ARM_2D_INVOKE
319
/*!
320
* \brief A macro to safely invode a function pointer
321
*
322
* \param[in] __FUNC_PTR the target function pointer
323
* \param[in] ... an optional parameter list
324
*/
325
# define ARM_2D_INVOKE(__FUNC_PTR, ...) \
326
((NULL == (__FUNC_PTR)) ? 0 : ((*(__FUNC_PTR))(__VA_ARGS__)))
327
328
#endif
329
330
#ifndef ARM_2D_INVOKE_RT_VOID
331
/*!
332
* \brief A macro to safely call a function pointer that has no return value
333
*
334
* \param[in] __FUNC_PTR the target function pointer
335
* \param[in] ... an optional parameter list
336
*/
337
# define ARM_2D_INVOKE_RT_VOID(__FUNC_PTR, ...) \
338
if (NULL != (__FUNC_PTR)) (*(__FUNC_PTR))(__VA_ARGS__)
339
340
#endif
341
342
/*!
343
* \note do NOT use this macro directly
344
*/
345
#define __ARM_CONNECT2(__A, __B) __A##__B
346
347
/*!
348
* \note do NOT use this macro directly
349
*/
350
#define __ARM_CONNECT2_ALT(__A, __B) __A##__B
351
352
/*!
353
* \note do NOT use this macro directly
354
*/
355
#define __ARM_CONNECT3(__A, __B, __C) __A##__B##__C
356
357
/*!
358
* \note do NOT use this macro directly
359
*/
360
#define __ARM_CONNECT4(__A, __B, __C, __D) __A##__B##__C##__D
361
362
/*!
363
* \note do NOT use this macro directly
364
*/
365
#define __ARM_CONNECT5(__A, __B, __C, __D, __E) __A##__B##__C##__D##__E
366
367
/*!
368
* \note do NOT use this macro directly
369
*/
370
#define __ARM_CONNECT6(__A, __B, __C, __D, __E, __F) \
371
__A##__B##__C##__D##__E##__F
372
373
/*!
374
* \note do NOT use this macro directly
375
*/
376
#define __ARM_CONNECT7(__A, __B, __C, __D, __E, __F, __G) \
377
__A##__B##__C##__D##__E##__F##__G
378
379
/*!
380
* \note do NOT use this macro directly
381
*/
382
#define __ARM_CONNECT8(__A, __B, __C, __D, __E, __F, __G, __H) \
383
__A##__B##__C##__D##__E##__F##__G##__H
384
385
/*!
386
* \note do NOT use this macro directly
387
*/
388
#define __ARM_CONNECT9(__A, __B, __C, __D, __E, __F, __G, __H, __I) \
389
__A##__B##__C##__D##__E##__F##__G##__H##__I
390
391
/*!
392
* \brief connect two symbol names as one
393
*/
394
#define ARM_CONNECT2(__A, __B) __ARM_CONNECT2(__A, __B)
395
396
/*!
397
* \brief connect two symbol names as one
398
*/
399
#define ARM_CONNECT2_ALT(__A, __B) __ARM_CONNECT2_ALT(__A, __B)
400
401
/*!
402
* \brief connect three symbol names as one
403
*/
404
#define ARM_CONNECT3(__A, __B, __C) __ARM_CONNECT3(__A, __B, __C)
405
406
/*!
407
* \brief connect four symbol names as one
408
*/
409
#define ARM_CONNECT4(__A, __B, __C, __D) __ARM_CONNECT4(__A, __B, __C, __D)
410
411
/*!
412
* \brief connect five symbol names as one
413
*/
414
#define ARM_CONNECT5(__A, __B, __C, __D, __E) \
415
__ARM_CONNECT5(__A, __B, __C, __D, __E)
416
417
/*!
418
* \brief connect six symbol names as one
419
*/
420
#define ARM_CONNECT6(__A, __B, __C, __D, __E, __F) \
421
__ARM_CONNECT6(__A, __B, __C, __D, __E, __F)
422
423
/*!
424
* \brief connect seven symbol names as one
425
*/
426
#define ARM_CONNECT7(__A, __B, __C, __D, __E, __F, __G) \
427
__ARM_CONNECT7(__A, __B, __C, __D, __E, __F, __G)
428
429
/*!
430
* \brief connect eight symbol names as one
431
*/
432
#define ARM_CONNECT8(__A, __B, __C, __D, __E, __F, __G, __H) \
433
__ARM_CONNECT8(__A, __B, __C, __D, __E, __F, __G, __H)
434
435
/*!
436
* \brief connect nine symbol names as one
437
*/
438
#define ARM_CONNECT9(__A, __B, __C, __D, __E, __F, __G, __H, __I) \
439
__ARM_CONNECT9(__A, __B, __C, __D, __E, __F, __G, __H, __I)
440
441
/*!
442
* \brief connect up to 9 symbol names as one
443
*/
444
#define arm_connect(...) \
445
ARM_CONNECT2_ALT(ARM_CONNECT, __ARM_VA_NUM_ARGS(__VA_ARGS__)) \
446
(__VA_ARGS__)
447
448
/*!
449
* \brief connect up to 9 symbol names as one
450
*/
451
#define ARM_CONNECT(...) arm_connect(__VA_ARGS__)
452
453
/*!
454
* \note do NOT use this macro directly
455
*/
456
#define __ARM_USING1(__declare) \
457
for (__declare, *ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr) = NULL; \
458
ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr)++ == NULL; \
459
)
460
461
/*!
462
* \note do NOT use this macro directly
463
*/
464
#define __ARM_USING2(__declare, __on_leave_expr) \
465
for (__declare, *ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr) = NULL; \
466
ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr)++ == NULL; \
467
(__on_leave_expr) \
468
)
469
470
/*!
471
* \note do NOT use this macro directly
472
*/
473
#define __ARM_USING3(__declare, __on_enter_expr, __on_leave_expr) \
474
for (__declare, *ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr) = NULL; \
475
ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr)++ == NULL ? \
476
((__on_enter_expr),1) : 0; \
477
(__on_leave_expr) \
478
)
479
480
/*!
481
* \note do NOT use this macro directly
482
*/
483
#define __ARM_USING4(__dcl1, __dcl2, __on_enter_expr, __on_leave_expr) \
484
for (__dcl1,__dcl2,*ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr)= NULL;\
485
ARM_CONNECT3(__ARM_USING_, __LINE__,_ptr)++ == NULL ? \
486
((__on_enter_expr),1) : 0; \
487
(__on_leave_expr) \
488
)
489
490
/*!
491
* \brief create a code segment with up to two local variables and
492
* entering/leaving operations
493
* \note prototype 1
494
* arm_using(local variable declaration) {
495
* code body
496
* }
497
*
498
* \note prototype 2
499
* arm_using(local variable declaration, {code segment before leaving the body}) {
500
* code body
501
* }
502
*
503
* \note prototype 3
504
* arm_using( local variable declaration,
505
* {code segment before entering the body},
506
* {code segment before leaving the body}
507
* ) {
508
* code body
509
* }
510
*
511
* \note prototype 4
512
* arm_using( local variable1 declaration,
513
local variable2 with the same type as the local variable 1,
514
* {code segment before entering the body},
515
* {code segment before leaving the body}
516
* ) {
517
* code body
518
* }
519
*/
520
#define arm_using(...) \
521
ARM_CONNECT2(__ARM_USING, __ARM_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)
522
523
524
/*!
525
* \note do NOT use this macro directly
526
*/
527
#define __ARM_WITH2(__type, __addr) \
528
arm_using(__type *_=(__addr))
529
530
/*!
531
* \note do NOT use this macro directly
532
*/
533
#define __ARM_WITH3(__type, __addr, __item) \
534
arm_using(__type *_=(__addr), *__item = _, (void)_, (void)0)
535
536
/*!
537
* \brief a with block to access members of a given object
538
*
539
* \note prototype 1
540
* arm_with(object type, address of the object) {
541
* you can use _.xxxx to access the members of the object
542
* }
543
*
544
* \note prototype 2
545
* arm_with(object type, address of the object, name of the iterator) {
546
* you can use your own iterator to access the members of the object
547
* }
548
*/
549
#define arm_with(...) \
550
ARM_CONNECT2(__ARM_WITH, __ARM_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)
551
552
/*!
553
* \brief access each items in a given array
554
* \param __type the type of the array
555
* \param __array the target array
556
* \note you can use "_" as the current object (iterator)
557
*/
558
#define ARM_FOREACH2(__type, __array) \
559
arm_using(__type *_ = __array) \
560
for ( uint_fast32_t ARM_CONNECT2(count,__LINE__) = dimof(__array);\
561
ARM_CONNECT2(count,__LINE__) > 0; \
562
_++, ARM_CONNECT2(count,__LINE__)-- \
563
)
564
565
/*!
566
* \brief access each items in a given array
567
* \param __type the type of the array
568
* \param __array the target array
569
* \param __item a name for the current item (iterator)
570
*/
571
#define ARM_FOREACH3(__type, __array, __item) \
572
arm_using(__type *_ = __array, *__item = _, (void)_, (void)0 ) \
573
for ( uint_fast32_t ARM_CONNECT2(count,__LINE__) = dimof(__array);\
574
ARM_CONNECT2(count,__LINE__) > 0; \
575
_++, __item = _, ARM_CONNECT2(count,__LINE__)-- \
576
)
577
578
/*!
579
* \brief access each items in a given array
580
* \param __type the type of the array
581
* \param __array the target array or the pointer of an memory block
582
* \param __count number of items in the array/memory block
583
* \param __item a name for the current item (iterator)
584
*/
585
#define ARM_FOREACH4(__type, __array, __count, __item) \
586
arm_using(__type *_ = __array, *__item = _, (void)_, (void)0) \
587
for ( uint_fast32_t ARM_CONNECT2(count,__LINE__) = (__count); \
588
ARM_CONNECT2(count,__LINE__) > 0; \
589
_++, __item = _, ARM_CONNECT2(count,__LINE__)-- \
590
)
591
592
/*!
593
* \brief access each items in a given array
594
* \note there are 3 prototypes, please refer to ARM_FOREACH1/2/3 for details
595
*/
596
#define arm_foreach(...) \
597
ARM_CONNECT2(ARM_FOREACH, __ARM_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)
598
599
600
/*!
601
* \brief a wrapper for __attribute__((nonnull))
602
*/
603
#ifndef ARM_NONNULL
604
# if defined(__IS_COMPILER_ARM_COMPILER_5__) ||\
605
defined(__IS_COMPILER_ARM_COMPILER_6__) ||\
606
defined(__IS_COMPILER_GCC__) ||\
607
defined(__IS_COMPILER_LLVM__)
608
# define ARM_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
609
# else
610
# define ARM_NONNULL(...)
611
# endif
612
#endif
613
614
/*!
615
* \note do NOT use this macro directly
616
*/
617
#define __ARM_SECTION(__X) __attribute__((section(__X)))
618
619
/*!
620
* \brief an attribute to specify the section
621
* \note it works for both functions and static/global variables
622
*/
623
#ifndef ARM_SECTION
624
# define ARM_SECTION(__X) __ARM_SECTION(__X)
625
#endif
626
627
/*!
628
* \brief an attribute for static variables that no initialisation is required
629
* in the C startup process.
630
*/
631
#ifndef ARM_NOINIT
632
# if defined(__IS_COMPILER_ARM_COMPILER_5__)
633
# define ARM_NOINIT __attribute__(( section( ".bss.noinit"
),zero_init))
634
# elif defined(__IS_COMPILER_ARM_COMPILER_6__)
635
# define ARM_NOINIT __attribute__(( section( ".bss.noinit"
)))
636
# elif defined(__IS_COMPILER_IAR__)
637
# define ARM_NOINIT __no_init
638
# elif (defined(__IS_COMPILER_GCC__) || defined(__IS_COMPILER_LLVM__)) && !defined(__APPLE__)
639
# define ARM_NOINIT __attribute__(( section( ".bss.noinit"
)))
640
# else
641
# define ARM_NOINIT
642
# endif
643
#endif
644
645
#undef __ARM_ALIGN
646
647
/*!
648
* \note do NOT use this macro directly
649
*/
650
#define __ARM_ALIGN(__N) __attribute__((aligned(__N)))
651
652
/*!
653
* \brief an attribute to specify aligment requirement
654
* \note it works for both functions and static/global variables
655
*/
656
#ifndef ARM_ALIGN
657
# define ARM_ALIGN(__N) __ARM_ALIGN(__N)
658
#endif
659
660
661
662
/*!
663
* \brief local variable decoration for pointers: restrict
664
*/
665
#ifndef __RESTRICT
666
# define __RESTRICT __restrict
667
#endif
668
669
/*!
670
* \brief an decoration for claiming that the immediate following symbol
671
* (variable / function) is not WEAK. If there is an __WEAK symbol, the
672
* __OVERRIDE_WEAK one can override it.
673
*
674
*/
675
#ifndef __OVERRIDE_WEAK
676
# define __OVERRIDE_WEAK
677
#endif
678
679
/*!
680
* \brief A macro to generate a safe name, usually used in macro template as the
681
* name of local variables
682
*
683
*/
684
#define ARM_2D_SAFE_NAME(...) ARM_CONNECT(__,__LINE__,##__VA_ARGS__)
685
686
/*!
687
* \brief A macro to generate a safe name, usually used in macro template as the
688
* name of local variables
689
*
690
*/
691
#define arm_2d_safe_name(...) ARM_2D_SAFE_NAME(__VA_ARGS__)
692
693
/*!
694
* \brief a decoration to make the immediate following code irq-safe
695
*
696
* \code
697
arm_irq_safe {
698
// code inside the brackets are IRQ safe
699
...
700
}
701
702
// the printf is IRQ safe
703
arm_irq_safe printf("IRQ safe printf\n");
704
705
\endcode
706
*/
707
#if __IS_SUPPORTED_ARM_ARCH__
708
# undef arm_irq_safe
709
# undef arm_exit_irq_safe
710
# define arm_irq_safe \
711
arm_using( uint32_t ARM_2D_SAFE_NAME(temp) = \
712
({uint32_t temp=__get_PRIMASK();__disable_irq();temp;}),\
713
__set_PRIMASK(ARM_2D_SAFE_NAME(temp)))
714
# define arm_exit_irq_safe continue
715
#endif
716
717
718
#undef ARM_2D_WRAP_FUNC
719
#undef __ARM_2D_WRAP_FUNC
720
#undef ARM_2D_ORIG_FUNC
721
#undef __ARM_2D_ORIG_FUNC
722
723
#if defined(__IS_COMPILER_ARM_COMPILER_6__)
724
725
/*!
726
* \note do NOT use this macro directly
727
*/
728
# define __ARM_2D_WRAP_FUNC(__FUNC) $Sub$$##__FUNC
729
730
/*!
731
* \note do NOT use this macro directly
732
*/
733
# define __ARM_2D_ORIG_FUNC(__FUNC) $Super$$## __FUNC
734
#else
735
736
/*!
737
* \note do NOT use this macro directly
738
*/
739
# define __ARM_2D_WRAP_FUNC(x) __wrap_ ## x
740
741
/*!
742
* \note do NOT use this macro directly
743
*/
744
# define __ARM_2D_ORIG_FUNC(x) __real_ ## x
745
#endif
746
747
/*!
748
* \brief a symbol wrapper to override a specified function
749
*/
750
#define ARM_2D_WRAP_FUNC(__FUNC) __ARM_2D_WRAP_FUNC(__FUNC)
751
752
/*!
753
* \brief a symbol wrapper to refer the original function with a given name
754
*/
755
#define ARM_2D_ORIG_FUNC(__FUNC) __ARM_2D_ORIG_FUNC(__FUNC)
756
757
/*----------------------------------------------------------------------------*
758
* List Operations *
759
*----------------------------------------------------------------------------*/
760
761
/* ALL the parameters passed to following macros must be pointer variables. */
762
763
/*!
764
* \note do NOT use this macro directly
765
*/
766
#define __ARM_LIST_STACK_PUSH(__P_TOP, __P_NODE) \
767
do { \
768
((__arm_slist_node_t *)(__P_NODE))->ptNext = \
769
(__arm_slist_node_t *)(__P_TOP); \
770
(*(__arm_slist_node_t **)&(__P_TOP)) = \
771
(__arm_slist_node_t *)(__P_NODE); \
772
} while(0)
773
774
/*!
775
* \brief push a item to a list
776
* \param[in] __P_TOP a pointer points to the first item of a list
777
* \param[in] __P_NODE a pointer points to the new item
778
*/
779
#define ARM_LIST_STACK_PUSH(__P_TOP, __P_NODE) \
780
__ARM_LIST_STACK_PUSH((__P_TOP), (__P_NODE))
781
782
/*!
783
* \brief insert a item after a specified node
784
* \param[in] __P_TARGET a pointer points to the target node
785
* \param[in] __P_NODE a pointer points to the new item
786
*/
787
#define ARM_LIST_INSERT_AFTER(__P_TARGET, __P_NODE) \
788
__ARM_LIST_STACK_PUSH((__P_TARGET), (__P_NODE))
789
790
/*!
791
* \note do NOT use this macro directly
792
*/
793
#define __ARM_LIST_STACK_POP(__P_TOP, __P_NODE) \
794
do { \
795
(*(__arm_slist_node_t **)&(__P_NODE)) = \
796
(__arm_slist_node_t *)(__P_TOP); \
797
if (NULL != (__P_TOP)) { \
798
(*(__arm_slist_node_t **)&(__P_TOP)) = \
799
((__arm_slist_node_t *)(__P_NODE))->ptNext; \
800
((__arm_slist_node_t *)(__P_NODE))->ptNext = NULL; \
801
} \
802
} while(0)
803
804
/*!
805
* \brief pop a item from a list
806
* \param[in] __P_TOP a pointer points to the first item of a list
807
* \param[out] __P_NODE a pointer variable for the node
808
*/
809
#define ARM_LIST_STACK_POP(__P_TOP, __P_NODE) \
810
__ARM_LIST_STACK_POP((__P_TOP), (__P_NODE))
811
812
/*!
813
* \brief remove a item after a specified node
814
* \param[in] __P_TARGET a pointer points to the target node
815
* \param[out] __P_NODE a pointer variable for the node
816
*/
817
#define ARM_LIST_REMOVE_AFTER(__P_TARGET, __P_NODE) \
818
ARM_LIST_STACK_POP((__P_TARGET), (__P_NODE))
819
820
/*!
821
* \note do NOT use this macro directly
822
*/
823
#define __ARM_LIST_QUEUE_ENQUEUE(__HEAD, __TAIL, __ITEM) \
824
do { \
825
if (NULL == (__TAIL)) { \
826
(*((__arm_slist_node_t **)&(__TAIL))) = \
827
(__arm_slist_node_t *)(__ITEM); \
828
(*((__arm_slist_node_t **)&(__HEAD))) = \
829
(__arm_slist_node_t *)(__ITEM); \
830
} else { \
831
((__arm_slist_node_t *)(__TAIL))->ptNext = \
832
(__arm_slist_node_t *)(__ITEM); \
833
(*(__arm_slist_node_t **)&(__TAIL)) = \
834
(__arm_slist_node_t *)(__ITEM); \
835
} \
836
((__arm_slist_node_t *)(__ITEM))->ptNext = NULL; \
837
} while(0)
838
839
/*!
840
* \brief enter a node to a queue
841
* \param[in] __HEAD a pointer points to the queue head
842
* \param[in] __TAIL a pointer points to the queue tail
843
* \param[in] __ITEM a pointer variable for the new node
844
*/
845
#define ARM_LIST_QUEUE_ENQUEUE(__HEAD, __TAIL, __ITEM) \
846
__ARM_LIST_QUEUE_ENQUEUE((__HEAD), (__TAIL), (__ITEM))
847
848
/*!
849
* \note do NOT use this macro directly
850
*/
851
#define __ARM_LIST_QUEUE_DEQUEUE(__HEAD, __TAIL, __ITEM) \
852
do { \
853
(*(__arm_slist_node_t **)&(__ITEM)) = (__arm_slist_node_t *)(__HEAD); \
854
if (NULL != (__HEAD)) { \
855
(*(__arm_slist_node_t **)&(__HEAD)) = \
856
((__arm_slist_node_t *)(__HEAD))->ptNext; \
857
if (NULL == (__HEAD)) { \
858
(__TAIL) = NULL; \
859
} \
860
} \
861
} while(0)
862
863
/*!
864
* \brief fetch a node from a queue
865
* \param[in] __HEAD a pointer points to the queue head
866
* \param[in] __TAIL a pointer points to the queue tail
867
* \param[out] __ITEM a pointer variable for the node
868
*/
869
#define ARM_LIST_QUEUE_DEQUEUE(__HEAD, __TAIL, __ITEM) \
870
__ARM_LIST_QUEUE_DEQUEUE((__HEAD), (__TAIL), (__ITEM))
871
872
/*!
873
* \note do NOT use this macro directly
874
*/
875
#define __ARM_LIST_QUEUE_PEEK(__HEAD, __TAIL, __ITEM) \
876
do { \
877
(*(__arm_slist_node_t **)&(__ITEM)) = (__arm_slist_node_t *)(__HEAD); \
878
} while(0)
879
880
/*!
881
* \brief peek a node from a queue
882
* \param[in] __HEAD a pointer points to the queue head
883
* \param[in] __TAIL a pointer points to the queue tail
884
* \param[out] __ITEM a pointer variable for the node
885
*/
886
#define ARM_LIST_QUEUE_PEEK(__HEAD, __TAIL, __ITEM) \
887
__ARM_LIST_QUEUE_PEEK((__HEAD), (__TAIL), (__ITEM)) \
888
889
/*----------------------------------------------------------------------------*
890
* PT Operations *
891
*----------------------------------------------------------------------------*/
892
/*
893
Protothreads open source BSD-style license
894
The protothreads library is released under an open source license that allows
895
both commercial and non-commercial use without restrictions. The only
896
requirement is that credits is given in the source code and in the documentation
897
for your product.
898
899
The full license text follows.
900
901
Copyright (c) 2004-2005, Swedish Institute of Computer Science.
902
All rights reserved.
903
904
Redistribution and use in source and binary forms, with or without
905
modification, are permitted provided that the following conditions
906
are met:
907
1. Redistributions of source code must retain the above copyright
908
notice, this list of conditions and the following disclaimer.
909
2. Redistributions in binary form must reproduce the above copyright
910
notice, this list of conditions and the following disclaimer in the
911
documentation and/or other materials provided with the distribution.
912
3. Neither the name of the Institute nor the names of its contributors
913
may be used to endorse or promote products derived from this software
914
without specific prior written permission.
915
916
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS `AS IS' AND
917
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
918
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
919
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
920
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
921
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
922
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
923
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
924
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
925
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
926
SUCH DAMAGE.
927
928
Author: Adam Dunkels
929
*/
930
931
#define ARM_PT_BEGIN(__STATE) \
932
enum { \
933
count_offset = __COUNTER__ + 1, \
934
}; \
935
uint8_t *ptPTState = &(__STATE); \
936
switch (__STATE) { \
937
case __COUNTER__ - count_offset:
938
939
#define ARM_PT_ENTRY(...) \
940
(*ptPTState) = (__COUNTER__ - count_offset + 1) >> 1; \
941
__VA_ARGS__ \
942
case (__COUNTER__ - count_offset) >> 1: (void)(*ptPTState);
943
944
#define ARM_PT_YIELD(...) \
945
ARM_PT_ENTRY(return __VA_ARGS__;)
946
947
#define ARM_PT_END() \
948
(*ptPTState) = 0; \
949
break;}
950
951
#define ARM_PT_GOTO_PREV_ENTRY(...) return __VA_ARGS__;
952
953
954
#define ARM_PT_REPORT_STATUS(...) \
955
ARM_PT_ENTRY( \
956
return __VA_ARGS__; \
957
)
958
959
#define ARM_PT_RETURN(...) \
960
(*ptPTState) = 0; \
961
return __VA_ARGS__;
962
963
/*----------------------------------------------------------------------------*
964
* Definition Template *
965
*----------------------------------------------------------------------------*/
966
967
/*!
968
* \note do NOT use this macro directly
969
*/
970
#define __def_low_lv_io(__NAME, __SW, ...) \
971
const __arm_2d_low_level_io_t LOW_LEVEL_IO##__NAME = { \
972
.SW = (__arm_2d_io_func_t *)&(__SW), \
973
.HW = (NULL, ##__VA_ARGS__) \
974
}
975
976
977
/*!
978
* \brief a template to implement a specified low-level io interface
979
* \param __NAME the IO name
980
* \param __SW the default c implementation
981
* \param ... you can specify an optional implementation using some acceleration.
982
*/
983
#define def_low_lv_io(__NAME, __SW, ...) \
984
__def_low_lv_io(__NAME, __SW, ##__VA_ARGS__)
985
986
/*!
987
* \note do NOT use this macro directly
988
*/
989
#define __ref_low_lv_io(__NAME) &LOW_LEVEL_IO##__NAME
990
991
/*!
992
* \brief a symbol wrapper for referencing a specified low-level IO
993
*/
994
#define ref_low_lv_io(__NAME) __ref_low_lv_io(__NAME)
995
996
/*----------------------------------------------------------------------------*
997
* LOG *
998
*----------------------------------------------------------------------------*/
999
1000
/*!
1001
* \brief the bit-mask for log channels
1002
*/
1003
#define ARM_2D_LOG_CHN_TYPE_USER _BV(28)
//!< the channel for user messages
1004
#define ARM_2D_LOG_CHN_TYPE_INFO _BV(29)
//!< the channel for generic information
1005
#define ARM_2D_LOG_CHN_TYPE_WARNING _BV(30)
//!< the channel for warnings messages
1006
#define ARM_2D_LOG_CHN_TYPE_ERROR _BV(31)
//!< the channel for error messages
1007
1008
#define ARM_2D_LOG_CHN_PIPELINE _BV(0)
//!< the channel dedicated to the pixel-pipeline
1009
#define ARM_2D_LOG_CHN_OPCODE _BV(1)
//!< the channel dedicated to OPCODEs and related algorithms
1010
#define ARM_2D_LOG_CHN_HELPER _BV(2)
//!< the channel dedicated to Helper services
1011
#define ARM_2D_LOG_CHN_HELPER_PFB _BV(3)
//!< the channel dedicated to the PFB helper service
1012
#define ARM_2D_LOG_CHN_SCENE_PLAYER _BV(4)
//!< the channel dedicated to the scene player service
1013
#define ARM_2D_LOG_CHN_DIRTY_REGION_OPTIMISATION _BV(5)
//!< the channel dedicated to the dirty region optimization services
1014
#define ARM_2D_LOG_CHN_STATISTICS _BV(6)
//!< the channel dedicated to show statistics
1015
#define ARM_2D_LOG_CHN_CONTROLS _BV(7)
//!< the channel dedicated to example controls
1016
#define ARM_2D_LOG_CHN_APP _BV(24)
//!< the channel dedicated to applications and examples
1017
1018
1019
#if defined(__ARM_2D_CFG_LOG_OUTPUT_SUPPORT_COLOUR__) && __ARM_2D_CFG_LOG_OUTPUT_SUPPORT_COLOUR__
1020
# define ARM_2D_TERMINAL_COLOUR_DEFAULT "\x1b[0m"
1021
# define ARM_2D_TERMINAL_COLOUR_GREEN "\x1b[32m"
1022
# define ARM_2D_TERMINAL_COLOUR_RED "\x1b[31m"
1023
# define ARM_2D_TERMINAL_COLOUR_YELLOW "\x1b[33m"
1024
# define ARM_2D_TERMINAL_COLOUR_WHITE "\x1b[97m"
1025
# define ARM_2D_TERMINAL_COLOUR_BRIGHT_BLACK "\x1b[90m"
1026
#else
1027
# define ARM_2D_TERMINAL_COLOUR_DEFAULT
1028
# define ARM_2D_TERMINAL_COLOUR_GREEN
1029
# define ARM_2D_TERMINAL_COLOUR_RED
1030
# define ARM_2D_TERMINAL_COLOUR_YELLOW
1031
# define ARM_2D_TERMINAL_COLOUR_WHITE
1032
# define ARM_2D_TERMINAL_COLOUR_BRIGHT_BLACK
1033
#endif
1034
1035
/*!
1036
* \brief the filter to enable log channels
1037
*/
1038
#ifndef __ARM_2D_LOG_CHANNEL_MASK_FILTER__
1039
# define __ARM_2D_LOG_CHANNEL_MASK_FILTER__ 0xFFFFFFFF
1040
#endif
1041
1042
#ifndef __ARM_2D_LOG_PRINTF_PIPELINE
1043
1044
/*!
1045
* \brief the log printf entry dedicated to pixel pipeline
1046
*/
1047
# define __ARM_2D_LOG_PRINTF_PIPELINE __arm_2d_log_printf
1048
#endif
1049
1050
#ifndef __ARM_2D_LOG_PRINTF_OPCODE
1051
/*!
1052
* \brief the log printf entry dedicated to OPCODEs and related algorithms
1053
*/
1054
# define __ARM_2D_LOG_PRINTF_OPCODE __arm_2d_log_printf
1055
#endif
1056
1057
#ifndef __ARM_2D_LOG_PRINTF_HELPER
1058
/*!
1059
* \brief the log printf entry dedicated to Helper services
1060
*/
1061
# define __ARM_2D_LOG_PRINTF_HELPER __arm_2d_log_printf
1062
#endif
1063
1064
#ifndef __ARM_2D_LOG_PRINTF_HELPER_PFB
1065
/*!
1066
* \brief the log printf entry dedicated to the PFB helper service
1067
*/
1068
# define __ARM_2D_LOG_PRINTF_HELPER_PFB __arm_2d_log_printf
1069
#endif
1070
1071
#ifndef __ARM_2D_LOG_PRINTF_SCENE_PLAYER
1072
/*!
1073
* \brief the log printf entry dedicated to the scene player service
1074
*/
1075
# define __ARM_2D_LOG_PRINTF_SCENE_PLAYER __arm_2d_log_printf
1076
#endif
1077
1078
#ifndef __ARM_2D_LOG_PRINTF_DIRTY_REGION_OPTIMISATION
1079
/*!
1080
* \brief the log printf entry dedicated to the dirty region optimization service
1081
*/
1082
# define __ARM_2D_LOG_PRINTF_DIRTY_REGION_OPTIMISATION \
1083
__arm_2d_log_printf
1084
#endif
1085
1086
#ifndef __ARM_2D_LOG_PRINTF_STATISTICS
1087
/*!
1088
* \brief the log printf entry dedicated to show statistics
1089
*/
1090
# define __ARM_2D_LOG_PRINTF_STATISTICS __arm_2d_log_printf
1091
#endif
1092
1093
#ifndef __ARM_2D_LOG_PRINTF_CONTROLS
1094
/*!
1095
* \brief the log printf entry dedicated to example controls
1096
*/
1097
# define __ARM_2D_LOG_PRINTF_CONTROLS __arm_2d_log_printf
1098
#endif
1099
1100
#ifndef __ARM_2D_LOG_PRINTF_APP
1101
/*!
1102
* \brief the log printf entry dedicated to applications and examples
1103
*/
1104
# define __ARM_2D_LOG_PRINTF_APP __arm_2d_log_printf
1105
#endif
1106
1107
#if defined(__ARM_2D_CFG_ENABLE_LOG__) && __ARM_2D_CFG_ENABLE_LOG__
1108
/*!
1109
* \brief the log entry for generic information
1110
* \param[in] __CHN the channel name, e.g. PIPELINE, OPCODE, HELPER, HELPER_PFB etc.
1111
* \param[in] __INDENT number of indents before print actual content
1112
* \param[in] __PREFIX a string used as prefix, we can use it to print content
1113
* like function name, service name etc.
1114
* \param[in] __FORMAT_STR the format string used in printf
1115
* \param[in] ... the optional parameters
1116
*/
1117
# define ARM_2D_LOG_INFO(__CHN, __INDENT, __PREFIX, __FORMAT_STR, ...) \
1118
__ARM_2D_LOG_PRINTF_##__CHN( \
1119
(__INDENT), \
1120
(ARM_2D_LOG_CHN_TYPE_INFO | ARM_2D_LOG_CHN_##__CHN), \
1121
(__PREFIX), \
1122
(__FORMAT_STR),##__VA_ARGS__)
1123
1124
/*!
1125
* \brief the log entry for warning messages
1126
* \param[in] __CHN the channel name, e.g. PIPELINE, OPCODE, HELPER, HELPER_PFB etc.
1127
* \param[in] __INDENT number of indents before print actual content
1128
* \param[in] __PREFIX a string used as prefix, we can use it to print content
1129
* like function name, service name etc.
1130
* \param[in] __FORMAT_STR the format string used in printf
1131
* \param[in] ... the optional parameters
1132
*/
1133
# define ARM_2D_LOG_WARNING(__CHN, __INDENT, __PREFIX, __FORMAT_STR, ...) \
1134
__ARM_2D_LOG_PRINTF_##__CHN( \
1135
(__INDENT), \
1136
(ARM_2D_LOG_CHN_TYPE_WARNING | ARM_2D_LOG_CHN_##__CHN), \
1137
(__PREFIX), \
1138
(__FORMAT_STR),##__VA_ARGS__)
1139
1140
/*!
1141
* \brief the log entry for error messages
1142
* \param[in] __CHN the channel name, e.g. PIPELINE, OPCODE, HELPER, HELPER_PFB etc.
1143
* \param[in] __INDENT number of indents before print actual content
1144
* \param[in] __PREFIX a string used as prefix, we can use it to print content
1145
* like function name, service name etc.
1146
* \param[in] __FORMAT_STR the format string used in printf
1147
* \param[in] ... the optional parameters
1148
*/
1149
# define ARM_2D_LOG_ERROR(__CHN, __INDENT, __PREFIX, __FORMAT_STR, ...) \
1150
__ARM_2D_LOG_PRINTF_##__CHN( \
1151
(__INDENT), \
1152
(ARM_2D_LOG_CHN_TYPE_ERROR | ARM_2D_LOG_CHN_##__CHN), \
1153
(__PREFIX), \
1154
(__FORMAT_STR),##__VA_ARGS__)
1155
1156
/*!
1157
* \brief the log entry for user messages
1158
* \param[in] __CHN the channel name, e.g. PIPELINE, OPCODE, HELPER, HELPER_PFB etc.
1159
* \param[in] __INDENT number of indents before print actual content
1160
* \param[in] __PREFIX a string used as prefix, we can use it to print content
1161
* like function name, service name etc.
1162
* \param[in] __FORMAT_STR the format string used in printf
1163
* \param[in] ... the optional parameters
1164
*/
1165
# define ARM_2D_LOG_USER(__CHN, __INDENT, __PREFIX, __FORMAT_STR, ...) \
1166
__ARM_2D_LOG_PRINTF_##__CHN( \
1167
(__INDENT), \
1168
(ARM_2D_LOG_CHN_TYPE_USER | ARM_2D_LOG_CHN_##__CHN), \
1169
(__PREFIX), \
1170
(__FORMAT_STR),##__VA_ARGS__)
1171
1172
#else
1173
# define ARM_2D_LOG_INFO(__CHN, __INDENT, __PREFIX, __FORMAT_STR, ...)
1174
# define ARM_2D_LOG_WARNING(__CHN, __INDENT, __PREFIX, __FORMAT_STR, ...)
1175
# define ARM_2D_LOG_ERROR(__CHN, __INDENT, __PREFIX, __FORMAT_STR, ...)
1176
# define ARM_2D_LOG_USER(__CHN, __INDENT, __PREFIX, __FORMAT_STR, ...)
1177
#endif
1178
1179
1180
#ifndef __ARM_2D_PORT_PRINTF__
1181
/*!
1182
* \brief the low level entry for printf
1183
* \note you can define this macro for retargeting
1184
*/
1185
# define __ARM_2D_PORT_PRINTF__(__format, ...) printf((__format), ##__VA_ARGS__)
1186
#endif
1187
1188
#ifndef __ARM_2D_LOG_MAX_STRING_LEN__
1189
/*!
1190
* \brief the maximum allowed string length. The log service requests the specified
1191
* number of bytes for storing string. default value is 256
1192
* \note please make sure there are sufficient memory in HEAP.
1193
*/
1194
# define __ARM_2D_LOG_MAX_STRING_LEN__ 256
1195
#endif
1196
1197
/*============================ TYPES =========================================*/
1198
1199
/*!
1200
* \brief a type for generic list
1201
*
1202
* \note to avoid using container_of() operand, please put __arm_slist_node_t
1203
* at the beginning of a class/structure
1204
*/
1205
typedef
struct
__arm_slist_node_t
__arm_slist_node_t
;
1206
struct
__arm_slist_node_t
{
1207
__arm_slist_node_t
*
ptNext
;
//!< the next node
1208
};
1209
1210
1211
/*============================ GLOBAL VARIABLES ==============================*/
1212
/*============================ PROTOTYPES ====================================*/
1213
1214
/*!
1215
* \brief an entry for log printf
1216
* \param[in] nIndentLevel number of indents before print actual content
1217
* \param[in] wChannelMask a bit-mask to indicate the log channel
1218
* \param[in] pchPrefix a string used as prefix, we can use it to print content
1219
* like function name, service name etc.
1220
* \param[in] pchFormatString the format string used in printf
1221
* \param[in] ... the optional parameters
1222
*/
1223
extern
1224
void
__arm_2d_log_printf
(int32_t nIndentLevel,
1225
uint32_t wChannelMask,
1226
const
char
*pchPrefix,
1227
const
char
*pchFormatString,
1228
...);
1229
1230
1231
#if defined(__clang__)
1232
# pragma clang diagnostic pop
1233
#elif __IS_COMPILER_ARM_COMPILER_5__
1234
#elif __IS_COMPILER_GCC__
1235
# pragma GCC diagnostic pop
1236
#endif
1237
1238
#ifdef __cplusplus
1239
}
1240
#endif
1241
1242
1243
#endif
/* end of __ARM_2D_UTILS_H__ */
1244
1245
1246
/*! @} */
1247
1248
/*============================ MACROS ========================================*/
1249
/*----------------------------------------------------------------------------*
1250
* Reentrant Macros *
1251
*----------------------------------------------------------------------------*/
1252
1253
/* un-define macros */
1254
#undef ARM_PRIVATE
1255
#undef ARM_PROTECTED
1256
1257
/* redefine macros */
1258
#if defined(__cplusplus)
1259
# define ARM_PRIVATE(...) \
1260
struct { \
1261
__VA_ARGS__ \
1262
};
1263
1264
# define ARM_PROTECTED(...) \
1265
struct { \
1266
__VA_ARGS__ \
1267
};
1268
1269
#elif defined(__ARM_2D_IMPL__) || defined(__IS_COMPILER_IAR__)
1270
1271
# define ARM_PRIVATE(...) \
1272
struct { \
1273
__VA_ARGS__ \
1274
} __ALIGNED(__alignof__(struct {__VA_ARGS__}));
1275
1276
# define ARM_PROTECTED(...) \
1277
struct { \
1278
__VA_ARGS__ \
1279
} __ALIGNED(__alignof__(struct {__VA_ARGS__}));
1280
1281
#elif defined(__ARM_2D_INHERIT__)
1282
1283
# define ARM_PRIVATE(...) \
1284
uint8_t ARM_CONNECT3(chMask,__LINE__,__COUNTER__) \
1285
[sizeof(struct {__VA_ARGS__})] \
1286
__ALIGNED(__alignof__(struct {__VA_ARGS__}));
1287
1288
# define ARM_PROTECTED(...) \
1289
struct { \
1290
__VA_ARGS__ \
1291
} __ALIGNED(__alignof__(struct {__VA_ARGS__}));
1292
1293
#else
1294
# define ARM_PRIVATE(...) \
1295
uint8_t ARM_CONNECT3(chMask,__LINE__,__COUNTER__) \
1296
[sizeof(struct {__VA_ARGS__})] \
1297
__ALIGNED(__alignof__(struct {__VA_ARGS__}));
1298
1299
# define ARM_PROTECTED(...) \
1300
uint8_t ARM_CONNECT3(chMask,__LINE__,__COUNTER__) \
1301
[sizeof(struct {__VA_ARGS__})] \
1302
__ALIGNED(__alignof__(struct {__VA_ARGS__}));
1303
#endif
1304
1305
1306
1307
1308
/* post un-define macros */
1309
1310
#undef __ARM_2D_IMPL__
1311
#undef __ARM_2D_INHERIT__
Library
Include
arm_2d_utils.h