Skip to content

Commit

Permalink
lib/libc/string0.c: Remove include of std.h, replace with string.h.
Browse files Browse the repository at this point in the history
Much more portable this way.
  • Loading branch information
dpgeorge committed Apr 18, 2015
1 parent 1c9a499 commit f53a8e7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/libc/string0.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include <stdint.h>
#include "std.h"
#include <string.h>

#define likely(x) __builtin_expect((x), 1)

Expand Down Expand Up @@ -102,10 +102,12 @@ void *memset(void *s, int c, size_t n) {
return s;
}

int memcmp(const char *s1, const char *s2, size_t n) {
int memcmp(const void *s1, const void *s2, size_t n) {
const uint8_t *s1_8 = s1;
const uint8_t *s2_8 = s2;
while (n--) {
char c1 = *s1++;
char c2 = *s2++;
char c1 = *s1_8++;
char c2 = *s2_8++;
if (c1 < c2) return -1;
else if (c1 > c2) return 1;
}
Expand Down

0 comments on commit f53a8e7

Please sign in to comment.