xref: /haiku/src/system/libroot/posix/string/strcmp.c (revision e5d65858f2361fe0552495b61620c84dcee6bc00)
1 /*
2  * Copyright 2008, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT license.
4  */
5 
6 
7 #include <stdbool.h>
8 #include <string.h>
9 #include <SupportDefs.h>
10 
11 
12 #define LACKS_ZERO_BYTE(value) \
13 	(((value - 0x01010101) & ~value & 0x80808080) == 0)
14 
15 int
16 strcmp(char const *a, char const *b)
17 {
18 	while (true) {
19 		int cmp = (unsigned char)*a - (unsigned char)*b++;
20 		if (cmp != 0 || *a++ == '\0')
21 			return cmp;
22 	}
23 }
24