@@ -376,8 +376,8 @@ extern "C" {
376
376
/**
377
377
* @brief Obtain the maximum of two values.
378
378
*
379
- * @note Arguments are evaluated twice. Use Z_MAX for a GCC-only, single
380
- * evaluation version
379
+ * @note Arguments are evaluated twice. Use @ref max for a single evaluation
380
+ * version.
381
381
*
382
382
* @param a First value.
383
383
* @param b Second value.
@@ -387,28 +387,30 @@ extern "C" {
387
387
#define MAX (a , b ) (((a) > (b)) ? (a) : (b))
388
388
#endif
389
389
390
+ #ifndef __cplusplus
390
391
/** @brief Return larger value of two provided expressions.
391
392
*
392
393
* Macro ensures that expressions are evaluated only once.
393
394
*
394
395
* @note Macro has limited usage compared to the standard macro as it cannot be
395
396
* used:
396
- * - to generate constant integer, e.g. __aligned(Z_MAX (4,5))
397
- * - static variable, e.g. array like static uint8_t array[Z_MAX (...)];
397
+ * - to generate constant integer, e.g. __aligned(max (4,5))
398
+ * - static variable, e.g. array like static uint8_t array[max (...)];
398
399
*/
399
- #define Z_MAX (a , b ) ({ \
400
+ #define max (a , b ) ({ \
400
401
/* random suffix to avoid naming conflict */ \
401
402
__typeof__ (a ) _value_a_ = (a ); \
402
403
__typeof__ (b ) _value_b_ = (b ); \
403
404
(_value_a_ > _value_b_ ) ? _value_a_ : _value_b_ ; \
404
405
})
406
+ #endif
405
407
406
408
#ifndef MIN
407
409
/**
408
410
* @brief Obtain the minimum of two values.
409
411
*
410
- * @note Arguments are evaluated twice. Use Z_MIN for a GCC-only, single
411
- * evaluation version
412
+ * @note Arguments are evaluated twice. Use @ref min for a single evaluation
413
+ * version.
412
414
*
413
415
* @param a First value.
414
416
* @param b Second value.
@@ -418,17 +420,19 @@ extern "C" {
418
420
#define MIN (a , b ) (((a) < (b)) ? (a) : (b))
419
421
#endif
420
422
423
+ #ifndef __cplusplus
421
424
/** @brief Return smaller value of two provided expressions.
422
425
*
423
- * Macro ensures that expressions are evaluated only once. See @ref Z_MAX for
426
+ * Macro ensures that expressions are evaluated only once. See @ref max for
424
427
* macro limitations.
425
428
*/
426
- #define Z_MIN (a , b ) ({ \
429
+ #define min (a , b ) ({ \
427
430
/* random suffix to avoid naming conflict */ \
428
431
__typeof__ (a ) _value_a_ = (a ); \
429
432
__typeof__ (b ) _value_b_ = (b ); \
430
433
(_value_a_ < _value_b_ ) ? _value_a_ : _value_b_ ; \
431
434
})
435
+ #endif
432
436
433
437
#ifndef MAX_FROM_LIST
434
438
/**
@@ -555,8 +559,8 @@ extern "C" {
555
559
/**
556
560
* @brief Clamp a value to a given range.
557
561
*
558
- * @note Arguments are evaluated multiple times. Use Z_CLAMP for a GCC-only,
559
- * single evaluation version.
562
+ * @note Arguments are evaluated multiple times. Use @ref clamp for a single
563
+ * evaluation version.
560
564
*
561
565
* @param val Value to be clamped.
562
566
* @param low Lowest allowed value (inclusive).
@@ -567,12 +571,13 @@ extern "C" {
567
571
#define CLAMP (val , low , high ) (((val) <= (low)) ? (low) : MIN(val, high))
568
572
#endif
569
573
574
+ #ifndef __cplusplus
570
575
/** @brief Return a value clamped to a given range.
571
576
*
572
- * Macro ensures that expressions are evaluated only once. See @ref Z_MAX for
577
+ * Macro ensures that expressions are evaluated only once. See @ref max for
573
578
* macro limitations.
574
579
*/
575
- #define Z_CLAMP (val , low , high ) ({ \
580
+ #define clamp (val , low , high ) ({ \
576
581
/* random suffix to avoid naming conflict */ \
577
582
__typeof__ (val ) _value_val_ = (val ); \
578
583
__typeof__ (low ) _value_low_ = (low ); \
@@ -581,6 +586,7 @@ extern "C" {
581
586
(_value_val_ > _value_high_ ) ? _value_high_ : \
582
587
_value_val_ ; \
583
588
})
589
+ #endif
584
590
585
591
/**
586
592
* @brief Checks if a value is within range.
0 commit comments