diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-07-06 23:21:20 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-10-31 04:50:44 -0400 |
commit | b868a2393bfd65221fe94e4ef2eebf218dee5a71 (patch) | |
tree | 21a05a8a3759bf111590424492a108128fda227e /sim/common/callback.c | |
parent | 88c8370b25c6a76cb7de19a3ef50a34abc090756 (diff) | |
download | gdb-b868a2393bfd65221fe94e4ef2eebf218dee5a71.zip gdb-b868a2393bfd65221fe94e4ef2eebf218dee5a71.tar.gz gdb-b868a2393bfd65221fe94e4ef2eebf218dee5a71.tar.bz2 |
sim: nltvals: localize TARGET_<open> defines
Code should not be using these directly, instead they should be
resolving these dynamically via the open_map. Rework the common
callback code that was using the defines to use symbolic names
instead, and localize some of the defines in the ARM code (since
it's a bit unclear how many different APIs it supports currently),
then remove the defines out of the header so no new code can rely on
them.
Diffstat (limited to 'sim/common/callback.c')
-rw-r--r-- | sim/common/callback.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/sim/common/callback.c b/sim/common/callback.c index 39d068c..941f430 100644 --- a/sim/common/callback.c +++ b/sim/common/callback.c @@ -37,7 +37,6 @@ #include <sys/types.h> #include <sys/stat.h> #include "sim/callback.h" -#include "targ-vals.h" /* For xmalloc. */ #include "libiberty.h" @@ -886,29 +885,44 @@ cb_target_to_host_open (host_callback *cb, int target_val) { int host_val = 0; CB_TARGET_DEFS_MAP *m; + int o_rdonly = 0; + int o_wronly = 0; + int o_rdwr = 0; + int o_binary = 0; + int o_rdwrmask; + /* O_RDONLY can be (and usually is) 0 which needs to be treated specially. */ for (m = &cb->open_map[0]; m->host_val != -1; ++m) { - switch (m->target_val) + if (!strcmp (m->name, "O_RDONLY")) + o_rdonly = m->target_val; + else if (!strcmp (m->name, "O_WRONLY")) + o_wronly = m->target_val; + else if (!strcmp (m->name, "O_RDWR")) + o_rdwr = m->target_val; + else if (!strcmp (m->name, "O_BINARY")) + o_binary = m->target_val; + } + o_rdwrmask = o_rdonly | o_wronly | o_rdwr; + + for (m = &cb->open_map[0]; m->host_val != -1; ++m) + { + if (m->target_val == o_rdonly || m->target_val == o_wronly + || m->target_val == o_rdwr) { - /* O_RDONLY can be (and usually is) 0 which needs to be treated - specially. */ - case TARGET_O_RDONLY : - case TARGET_O_WRONLY : - case TARGET_O_RDWR : - if ((target_val & (TARGET_O_RDONLY | TARGET_O_WRONLY | TARGET_O_RDWR)) - == m->target_val) + if ((target_val & o_rdwrmask) == m->target_val) host_val |= m->host_val; /* Handle the host/target differentiating between binary and text mode. Only one case is of importance */ -#if ! defined (TARGET_O_BINARY) && defined (O_BINARY) - host_val |= O_BINARY; +#ifdef O_BINARY + if (o_binary == 0) + host_val |= O_BINARY; #endif - break; - default : + } + else + { if ((m->target_val & target_val) == m->target_val) host_val |= m->host_val; - break; } } |