Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame^] | 1 | /* |
2 | * SPDX-License-Identifier: BSD-3-Clause | ||||
3 | * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. | ||||
4 | */ | ||||
5 | |||||
6 | #include <stddef.h> | ||||
7 | #include <string.h> | ||||
8 | |||||
9 | int 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 | |||||
24 | return 0; | ||||
25 | } |