Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 1 | /* |
Govindraj Raja | eee28e7 | 2023-08-01 15:52:40 -0500 | [diff] [blame] | 2 | * Copyright (c) 2013-2019, Arm Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stddef.h> |
Ambroise Vincent | b237bca | 2019-02-13 15:58:00 +0000 | [diff] [blame] | 8 | #include <string.h> |
Antonio Nino Diaz | 9eddb1e | 2018-08-16 14:53:05 +0100 | [diff] [blame] | 9 | |
| 10 | int memcmp(const void *s1, const void *s2, size_t len) |
| 11 | { |
| 12 | const unsigned char *s = s1; |
| 13 | const unsigned char *d = s2; |
| 14 | unsigned char sc; |
| 15 | unsigned char dc; |
| 16 | |
| 17 | while (len--) { |
| 18 | sc = *s++; |
| 19 | dc = *d++; |
| 20 | if (sc - dc) |
| 21 | return (sc - dc); |
| 22 | } |
| 23 | |
| 24 | return 0; |
| 25 | } |