From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
"Max Filippov" <jcmvbkbc@gmail.com>,
qemu-trivial@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Michael Tokarev" <mjt@tls.msk.ru>,
"Laurent Vivier" <laurent@vivier.eu>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Richard Zak" <richard.j.zak@gmail.com>
Subject: [PULL 7/9] target/xtensa/xtensa-semi: Fix compilation problem on Haiku
Date: Fri, 9 Jul 2021 22:28:22 +0200 [thread overview]
Message-ID: <20210709202824.578187-8-laurent@vivier.eu> (raw)
In-Reply-To: <20210709202824.578187-1-laurent@vivier.eu>
From: Thomas Huth <thuth@redhat.com>
The errno numbers are very large on Haiku, so the linking currently
fails there with a "final link failed: memory exhausted" error
message. We should not use the errno number as array indexes here,
thus convert the code to a switch-case statement instead. A clever
compiler should be able to optimize this code in a similar way
anway.
Reported-by: Richard Zak <richard.j.zak@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210706081822.1316551-1-thuth@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
target/xtensa/xtensa-semi.c | 84 +++++++++++++++++--------------------
1 file changed, 39 insertions(+), 45 deletions(-)
diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c
index 79f2b043f233..fa21b7e11fc2 100644
--- a/target/xtensa/xtensa-semi.c
+++ b/target/xtensa/xtensa-semi.c
@@ -95,59 +95,53 @@ enum {
static uint32_t errno_h2g(int host_errno)
{
- static const uint32_t guest_errno[] = {
- [EPERM] = TARGET_EPERM,
- [ENOENT] = TARGET_ENOENT,
- [ESRCH] = TARGET_ESRCH,
- [EINTR] = TARGET_EINTR,
- [EIO] = TARGET_EIO,
- [ENXIO] = TARGET_ENXIO,
- [E2BIG] = TARGET_E2BIG,
- [ENOEXEC] = TARGET_ENOEXEC,
- [EBADF] = TARGET_EBADF,
- [ECHILD] = TARGET_ECHILD,
- [EAGAIN] = TARGET_EAGAIN,
- [ENOMEM] = TARGET_ENOMEM,
- [EACCES] = TARGET_EACCES,
- [EFAULT] = TARGET_EFAULT,
+ switch (host_errno) {
+ case 0: return 0;
+ case EPERM: return TARGET_EPERM;
+ case ENOENT: return TARGET_ENOENT;
+ case ESRCH: return TARGET_ESRCH;
+ case EINTR: return TARGET_EINTR;
+ case EIO: return TARGET_EIO;
+ case ENXIO: return TARGET_ENXIO;
+ case E2BIG: return TARGET_E2BIG;
+ case ENOEXEC: return TARGET_ENOEXEC;
+ case EBADF: return TARGET_EBADF;
+ case ECHILD: return TARGET_ECHILD;
+ case EAGAIN: return TARGET_EAGAIN;
+ case ENOMEM: return TARGET_ENOMEM;
+ case EACCES: return TARGET_EACCES;
+ case EFAULT: return TARGET_EFAULT;
#ifdef ENOTBLK
- [ENOTBLK] = TARGET_ENOTBLK,
+ case ENOTBLK: return TARGET_ENOTBLK;
#endif
- [EBUSY] = TARGET_EBUSY,
- [EEXIST] = TARGET_EEXIST,
- [EXDEV] = TARGET_EXDEV,
- [ENODEV] = TARGET_ENODEV,
- [ENOTDIR] = TARGET_ENOTDIR,
- [EISDIR] = TARGET_EISDIR,
- [EINVAL] = TARGET_EINVAL,
- [ENFILE] = TARGET_ENFILE,
- [EMFILE] = TARGET_EMFILE,
- [ENOTTY] = TARGET_ENOTTY,
+ case EBUSY: return TARGET_EBUSY;
+ case EEXIST: return TARGET_EEXIST;
+ case EXDEV: return TARGET_EXDEV;
+ case ENODEV: return TARGET_ENODEV;
+ case ENOTDIR: return TARGET_ENOTDIR;
+ case EISDIR: return TARGET_EISDIR;
+ case EINVAL: return TARGET_EINVAL;
+ case ENFILE: return TARGET_ENFILE;
+ case EMFILE: return TARGET_EMFILE;
+ case ENOTTY: return TARGET_ENOTTY;
#ifdef ETXTBSY
- [ETXTBSY] = TARGET_ETXTBSY,
+ case ETXTBSY: return TARGET_ETXTBSY;
#endif
- [EFBIG] = TARGET_EFBIG,
- [ENOSPC] = TARGET_ENOSPC,
- [ESPIPE] = TARGET_ESPIPE,
- [EROFS] = TARGET_EROFS,
- [EMLINK] = TARGET_EMLINK,
- [EPIPE] = TARGET_EPIPE,
- [EDOM] = TARGET_EDOM,
- [ERANGE] = TARGET_ERANGE,
- [ENOSYS] = TARGET_ENOSYS,
+ case EFBIG: return TARGET_EFBIG;
+ case ENOSPC: return TARGET_ENOSPC;
+ case ESPIPE: return TARGET_ESPIPE;
+ case EROFS: return TARGET_EROFS;
+ case EMLINK: return TARGET_EMLINK;
+ case EPIPE: return TARGET_EPIPE;
+ case EDOM: return TARGET_EDOM;
+ case ERANGE: return TARGET_ERANGE;
+ case ENOSYS: return TARGET_ENOSYS;
#ifdef ELOOP
- [ELOOP] = TARGET_ELOOP,
+ case ELOOP: return TARGET_ELOOP;
#endif
};
- if (host_errno == 0) {
- return 0;
- } else if (host_errno > 0 && host_errno < ARRAY_SIZE(guest_errno) &&
- guest_errno[host_errno]) {
- return guest_errno[host_errno];
- } else {
- return TARGET_EINVAL;
- }
+ return TARGET_EINVAL;
}
typedef struct XtensaSimConsole {
--
2.31.1
next prev parent reply other threads:[~2021-07-09 20:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-09 20:28 [PULL 0/9] Trivial branch for 6.1 patches Laurent Vivier
2021-07-09 20:28 ` [PULL 1/9] qemu-option: Drop dead assertion Laurent Vivier
2021-07-09 20:28 ` [PULL 2/9] memory: Display MemoryRegion name in read/write ops trace events Laurent Vivier
2021-07-09 20:28 ` [PULL 3/9] misc: Fix "havn't" typo Laurent Vivier
2021-07-09 20:28 ` [PULL 4/9] virtiofsd: Add missing newline in error message Laurent Vivier
2021-07-09 20:28 ` [PULL 5/9] misc: Remove redundant new line in perror() Laurent Vivier
2021-07-09 20:28 ` [PULL 6/9] hw/virtio: Document *_should_notify() are called within rcu_read_lock() Laurent Vivier
2021-07-09 20:28 ` Laurent Vivier [this message]
2021-07-09 20:28 ` [PULL 8/9] migration: fix typo in mig_throttle_guest_down comment Laurent Vivier
2021-07-09 20:28 ` [PULL 9/9] util/guest-random: Fix size arg to tail memcpy Laurent Vivier
2021-07-11 21:20 ` [PULL 0/9] Trivial branch for 6.1 patches Peter Maydell
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=20210709202824.578187-8-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=f4bug@amsat.org \
--cc=jcmvbkbc@gmail.com \
--cc=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=richard.j.zak@gmail.com \
--cc=thuth@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).