From e71bacb2f58d9bdd4131ac1e3461e7ca78de2aa6 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Wed, 25 Jul 2012 13:54:32 +0200 Subject: [PATCH] FreeTDM: Add convenience macros ftdm_min(), ftdm_max() and ftdm_clamp(). ftdm_min(x,y) - Returns the smaller of the two values x and y. ftdm_max(x,y) - Returns the larger of the two values x and y. ftdm_clamp(val, min, max) - Returns value that is in the range [vmin,vmax]. Signed-off-by: Stefan Knoblich --- libs/freetdm/src/include/ftdm_os.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libs/freetdm/src/include/ftdm_os.h b/libs/freetdm/src/include/ftdm_os.h index 151f8d935e..f8681111b6 100644 --- a/libs/freetdm/src/include/ftdm_os.h +++ b/libs/freetdm/src/include/ftdm_os.h @@ -78,6 +78,16 @@ typedef uint64_t ftdm_time_t; /*! \brief array len helper */ #define ftdm_array_len(array) sizeof(array)/sizeof(array[0]) +/*! \brief Get smaller value */ +#define ftdm_min(x,y) ((x) < (y) ? (x) : (y)) + +/*! \brief Get larger value */ +#define ftdm_max(x,y) ((x) > (y) ? (x) : (y)) + +/*! \brief Get value that is in range [vmin,vmax] */ +#define ftdm_clamp(val,vmin,vmax) ftdm_max(vmin,ftdm_min(val,vmax)) + + /*! \brief The memory handler. Do not use directly this variable, use the memory macros and ftdm_global_set_memory_handler to override */ FT_DECLARE_DATA extern ftdm_memory_handler_t g_ftdm_mem_handler;