@@ -375,6 +375,9 @@ extern "C" {
375
375
/**
376
376
* @cond INTERNAL_HIDDEN
377
377
*/
378
+ #define Z_INTERNAL_MAX (a , b ) (((a) > (b)) ? (a) : (b))
379
+ #define Z_INTERNAL_MIN (a , b ) (((a) < (b)) ? (a) : (b))
380
+
378
381
#define _minmax_unique (op , a , b , ua , ub ) ({ \
379
382
__typeof__(a) ua = (a); \
380
383
__typeof__(b) ub = (b); \
@@ -412,7 +415,7 @@ extern "C" {
412
415
*
413
416
* @returns Maximum value of @p a and @p b.
414
417
*/
415
- #define MAX (a , b ) (((a) > (b)) ? (a) : (b) )
418
+ #define MAX (a , b ) Z_INTERNAL_MAX(a, b )
416
419
#endif
417
420
418
421
#ifndef __cplusplus
@@ -425,15 +428,15 @@ extern "C" {
425
428
* - to generate constant integer, e.g. __aligned(max(4,5))
426
429
* - static variable, e.g. array like static uint8_t array[max(...)];
427
430
*/
428
- #define max (a , b ) _minmax_cnt(MAX , a, b, __COUNTER__)
431
+ #define max (a , b ) _minmax_cnt(Z_INTERNAL_MAX , a, b, __COUNTER__)
429
432
#endif
430
433
431
434
/** @brief Return larger value of three provided expressions.
432
435
*
433
436
* Macro ensures that expressions are evaluated only once. See @ref max for
434
437
* macro limitations.
435
438
*/
436
- #define max3 (a , b , c ) _minmax3_cnt(MAX , a, b, c, __COUNTER__)
439
+ #define max3 (a , b , c ) _minmax3_cnt(Z_INTERNAL_MAX , a, b, c, __COUNTER__)
437
440
438
441
#ifndef MIN
439
442
/**
@@ -447,7 +450,7 @@ extern "C" {
447
450
*
448
451
* @returns Minimum value of @p a and @p b.
449
452
*/
450
- #define MIN (a , b ) (((a) < (b)) ? (a) : (b) )
453
+ #define MIN (a , b ) Z_INTERNAL_MIN(a, b )
451
454
#endif
452
455
453
456
#ifndef __cplusplus
@@ -456,15 +459,15 @@ extern "C" {
456
459
* Macro ensures that expressions are evaluated only once. See @ref max for
457
460
* macro limitations.
458
461
*/
459
- #define min (a , b ) _minmax_cnt(MIN , a, b, __COUNTER__)
462
+ #define min (a , b ) _minmax_cnt(Z_INTERNAL_MIN , a, b, __COUNTER__)
460
463
#endif
461
464
462
465
/** @brief Return smaller value of three provided expressions.
463
466
*
464
467
* Macro ensures that expressions are evaluated only once. See @ref max for
465
468
* macro limitations.
466
469
*/
467
- #define min3 (a , b , c ) _minmax3_cnt(MIN , a, b, c, __COUNTER__)
470
+ #define min3 (a , b , c ) _minmax3_cnt(Z_INTERNAL_MIN , a, b, c, __COUNTER__)
468
471
469
472
470
473
#ifndef MAX_FROM_LIST
@@ -601,7 +604,7 @@ extern "C" {
601
604
*
602
605
* @returns Clamped value.
603
606
*/
604
- #define CLAMP (val , low , high ) (((val) <= (low)) ? (low) : MIN (val, high))
607
+ #define CLAMP (val , low , high ) (((val) <= (low)) ? (low) : Z_INTERNAL_MIN (val, high))
605
608
#endif
606
609
607
610
#ifndef __cplusplus
0 commit comments