qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 1/2] optionrom: add memcmp() implementation


From: Stefano Garzarella
Subject: [PATCH v2 1/2] optionrom: add memcmp() implementation
Date: Tue, 23 Mar 2021 10:22:10 +0100

Provide memcmp() implementation that can be used by optionroms.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
 pc-bios/optionrom/optrom.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/pc-bios/optionrom/optrom.h b/pc-bios/optionrom/optrom.h
index 357819259a..b98436e413 100644
--- a/pc-bios/optionrom/optrom.h
+++ b/pc-bios/optionrom/optrom.h
@@ -25,6 +25,7 @@
 #define OPTROM_H
 
 #include <stdint.h>
+#include <stddef.h>
 #include "../../include/standard-headers/linux/qemu_fw_cfg.h"
 
 #define barrier() asm("" : : : "memory")
@@ -107,4 +108,18 @@ static inline uint32_t be32_to_cpu(uint32_t x)
     return bswap32(x);
 }
 
+static inline int memcmp(const void *str1, const void *str2, size_t count)
+{
+    const unsigned char *c1 = str1, *c2 = str2;
+    int ret = 0;
+
+    while (count--) {
+        ret = *c1++ - *c2++;
+        if (ret) {
+            break;
+        }
+    }
+
+    return ret;
+}
 #endif /* OPTROM_H */
-- 
2.30.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]