sipxmedialib  Version 3.3
MpDspUtilsSerials.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2007 SIPez LLC.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 // Author: Alexander Chemeris <Alexander DOT Chemeris AT SIPez DOT com>
12 
13 #ifndef _MpDspUtilsSerials_h_
14 #define _MpDspUtilsSerials_h_
15 
23 // DEFINES
24 #define UINT32_HALF UINT32_C(2147483648)
25 #define UINT16_HALF UINT16_C(32768)
26 
27 // MACROS
28 #define MP_COMPARE_SERIALS(val1, val2, range_half) \
29  (((val1) == (val2)) ? 0 : \
30  ((val1) >= (range_half)) ? ((((val1)-(range_half) < (val2)) && ((val2) < (val1))) ? 1 : -1) : \
31  ((((val1)+(range_half) < (val2)) || ((val2) < (val1))) ? 1 : -1))
32 
33 /* ============================ INLINE METHODS ============================ */
34 
35 int MpDspUtils::compareSerials(uint32_t val1, uint32_t val2)
36 {
37  return MP_COMPARE_SERIALS(val1, val2, UINT32_HALF);
38 }
39 
40 int MpDspUtils::compareSerials(uint16_t val1, uint16_t val2)
41 {
42  return MP_COMPARE_SERIALS(val1, val2, UINT16_HALF);
43 }
44 
45 #endif // _MpDspUtilsSerials_h_
static int compareSerials(uint32_t val1, uint32_t val2)
Is val1 bigger, equal or lesser then val2.
Definition: MpDspUtilsSerials.h:35
#define UINT16_HALF
Half of unsigned 16-bit integer range (2^15)
Definition: MpDspUtilsSerials.h:25
#define MP_COMPARE_SERIALS(val1, val2, range_half)
Definition: MpDspUtilsSerials.h:28
#define UINT32_HALF
Half of unsigned 32-bit integer range (2^31)
Definition: MpDspUtilsSerials.h:24