1 /* 2 * Copyright (c) 2019-2020, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #include <stddef.h> 9 #include <stdint.h> 10 memcmp(const void * s1,const void * s2,size_t n)11int memcmp(const void *s1, const void *s2, size_t n) 12 { 13 int result = 0; 14 const uint8_t *p1 = (const uint8_t *)s1; 15 const uint8_t *p2 = (const uint8_t *)s2; 16 17 while (n--) { 18 if ((*p1 != *p2) && (result == 0)) { 19 result = *p1 - *p2; 20 } else { 21 p1++; 22 p2++; 23 } 24 } 25 return result; 26 } 27