All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Garzarella <sgarzare@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH v2 1/2] optionrom: add memcmp() implementation
Date: Tue, 23 Mar 2021 10:22:10 +0100	[thread overview]
Message-ID: <20210323092211.44597-2-sgarzare@redhat.com> (raw)
In-Reply-To: <20210323092211.44597-1-sgarzare@redhat.com>

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	other threads:[~2021-03-23  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23  9:22 [PATCH v2 0/2] optionrom/pvh: use memcmp() to find the RSDP signature Stefano Garzarella
2021-03-23  9:22 ` Stefano Garzarella [this message]
2021-03-23  9:22 ` [PATCH v2 2/2] " Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210323092211.44597-2-sgarzare@redhat.com \
    --to=sgarzare@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.