blob: a4c798b097fb0db9e33f2189d4151043f6acd3dc [file] [log] [blame]
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +01001/*
2 * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <stddef.h>
8
9int memcmp(const void *s1, const void *s2, size_t len)
10{
11 const unsigned char *s = s1;
12 const unsigned char *d = s2;
13 unsigned char sc;
14 unsigned char dc;
15
16 while (len--) {
17 sc = *s++;
18 dc = *d++;
19 if (sc - dc)
20 return (sc - dc);
21 }
22
23 return 0;
24}