# HG changeset patch # User Mike Becker # Date 1525333778 -7200 # Node ID 7be3ae7ffb588e5c08e29da5fac3f7d4f8ce400f # Parent d7e43c4b2992ccac1173a603dfbad7ea7afaa6de adds ucx_longintcmp() compare function diff -r d7e43c4b2992 -r 7be3ae7ffb58 src/ucx/utils.h --- a/src/ucx/utils.h Thu May 03 09:26:06 2018 +0200 +++ b/src/ucx/utils.h Thu May 03 09:49:38 2018 +0200 @@ -166,6 +166,16 @@ int ucx_intcmp(const void *i1, const void *i2, void *data); /** + * Compares two integers of type long int. + * @param i1 pointer to long integer one + * @param i2 pointer to long integer two + * @param data omitted + * @return -1, if *i1 is less than *i2, 0 if both are equal, + * 1 if *i1 is greater than *i2 + */ +int ucx_longintcmp(const void *i1, const void *i2, void *data); + +/** * Compares two real numbers of type float. * @param f1 pointer to float one * @param f2 pointer to float two diff -r d7e43c4b2992 -r 7be3ae7ffb58 src/utils.c --- a/src/utils.c Thu May 03 09:26:06 2018 +0200 +++ b/src/utils.c Thu May 03 09:49:38 2018 +0200 @@ -106,6 +106,16 @@ } } +int ucx_longintcmp(const void *i1, const void *i2, void *data) { + int a = *((const long int*) i1); + int b = *((const long int*) i2); + if (a == b) { + return 0; + } else { + return a < b ? -1 : 1; + } +} + int ucx_floatcmp(const void *f1, const void *f2, void *epsilon) { float a = *((const float*) f1); float b = *((const float*) f2);