Fix retval of SCMemcmp for non-SIMD implementation.

remotes/origin/master-1.1.x
Victor Julien 15 years ago
parent a75556dfe5
commit 091f53ce4e

@ -67,8 +67,11 @@ static int MemcmpTest04 (void) {
uint8_t a[] = "abcd";
uint8_t b[] = "abcD";
if (SCMemcmp(a, b, sizeof(a)-1) != 1)
int r = SCMemcmp(a, b, sizeof(a)-1);
if (r != 1) {
printf("%s != %s, but memcmp returned %d: ", a, b, r);
return 0;
}
return 1;
}

@ -21,6 +21,9 @@
* \author Victor Julien <victor@inliniac.net>
*
* Memcmp implementations for SSE3, SSE4.1 and SSE4.2.
*
* Both SCMemcmp and SCMemcmpLowercase return 0 on a exact match,
* 1 on a failed match.
*/
#ifndef __UTIL_MEMCMP_H__
@ -302,7 +305,10 @@ static inline int SCMemcmpLowercase(void *s1, void *s2, size_t len) {
/* No SIMD support, fall back to plain memcmp and a home grown lowercase one */
#define SCMemcmp memcmp
/* wrapper around memcmp to match the retvals of the SIMD implementations */
#define SCMemcmp(a,b,c) ({ \
memcmp((a), (b), (c)) ? 1 : 0; \
})
static inline int
SCMemcmpLowercase(void *s1, void *s2, size_t n) {

Loading…
Cancel
Save