[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/12] linux-user/syscall: Refactor target_to_host_errno_table_in
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 10/12] linux-user/syscall: Refactor target_to_host_errno_table_init() |
Date: |
Sun, 4 Jul 2021 20:37:53 +0200 |
To be able to move the errno handling code out of syscall.c,
first refactor the target_to_host_errno_table[] initialization
as a new init() function.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
linux-user/syscall.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 64bbf331b28..33b7fef12a8 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -509,8 +509,10 @@ static inline int next_free_host_timer(void)
#define ERRNO_TABLE_SIZE 1200
-/* target_to_host_errno_table[] is initialized from
- * host_to_target_errno_table[] in syscall_init(). */
+/*
+ * target_to_host_errno_table[] is initialized from
+ * host_to_target_errno_table[] in target_to_host_errno_table_init().
+ */
static uint16_t target_to_host_errno_table[ERRNO_TABLE_SIZE] = {
};
@@ -637,6 +639,17 @@ static uint16_t
host_to_target_errno_table[ERRNO_TABLE_SIZE] = {
#endif
};
+static void target_to_host_errno_table_init(void)
+{
+ /*
+ * Build target_to_host_errno_table[] table
+ * from host_to_target_errno_table[].
+ */
+ for (int i = 0; i < ERRNO_TABLE_SIZE; i++) {
+ target_to_host_errno_table[host_to_target_errno_table[i]] = i;
+ }
+}
+
static inline int host_to_target_errno(int err)
{
if (err >= 0 && err < ERRNO_TABLE_SIZE &&
@@ -7102,7 +7115,6 @@ void syscall_init(void)
IOCTLEntry *ie;
const argtype *arg_type;
int size;
- int i;
thunk_init(STRUCT_MAX);
@@ -7112,11 +7124,7 @@ void syscall_init(void)
#undef STRUCT
#undef STRUCT_SPECIAL
- /* Build target_to_host_errno_table[] table from
- * host_to_target_errno_table[]. */
- for (i = 0; i < ERRNO_TABLE_SIZE; i++) {
- target_to_host_errno_table[host_to_target_errno_table[i]] = i;
- }
+ target_to_host_errno_table_init();
/* we patch the ioctl size if necessary. We rely on the fact that
no ioctl has all the bits at '1' in the size field */
--
2.31.1
- [PATCH 05/12] linux-user: Extract target errno to 'target_errno_defs.h', (continued)
- [PATCH 05/12] linux-user: Extract target errno to 'target_errno_defs.h', Philippe Mathieu-Daudé, 2021/07/04
- [PATCH 06/12] linux-user/alpha: Remove hardcoded tabs (code style), Philippe Mathieu-Daudé, 2021/07/04
- [PATCH 07/12] linux-user/alpha: Move errno definitions to 'target_errno_defs.h', Philippe Mathieu-Daudé, 2021/07/04
- [PATCH 08/12] linux-user/hppa: Move errno definitions to 'target_errno_defs.h', Philippe Mathieu-Daudé, 2021/07/04
- [PATCH 09/12] linux-user/mips: Move errno definitions to 'target_errno_defs.h', Philippe Mathieu-Daudé, 2021/07/04
- [PATCH 10/12] linux-user/syscall: Refactor target_to_host_errno_table_init(),
Philippe Mathieu-Daudé <=
- [PATCH 11/12] linux-user/syscall: Remove hardcoded tabs (code style), Philippe Mathieu-Daudé, 2021/07/04
- [PATCH 12/12] linux-user: Extract target errno related functions to 'target_errno.h', Philippe Mathieu-Daudé, 2021/07/04