]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FreeTDM: Add convenience macros ftdm_min(), ftdm_max() and ftdm_clamp().
authorStefan Knoblich <stkn@openisdn.net>
Wed, 25 Jul 2012 11:54:32 +0000 (13:54 +0200)
committerStefan Knoblich <stkn@openisdn.net>
Wed, 25 Jul 2012 12:03:22 +0000 (14:03 +0200)
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 <stkn@openisdn.net>
libs/freetdm/src/include/ftdm_os.h

index 151f8d935eba070bd5ccb50c4f01507152b31623..f8681111b6430e705889c94fe837f757b434898d 100644 (file)
@@ -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;