blob: 14582082bde00b614639c8a03fb5212ef0e3c267 [file] [log] [blame]
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +01001/*
Boyan Karatotev7ab30812025-03-17 10:31:03 +00002 * Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <stddef.h>
Boyan Karatotev7ab30812025-03-17 10:31:03 +00008#include <string_private.h>
Antonio Nino Diaz9eddb1e2018-08-16 14:53:05 +01009
10int 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}