sim: nltvals: localize TARGET_<ERRNO> defines

Code should not be using these directly, instead they should be
resolving these dynamically via cb_host_to_target_errno maps.
Fix the Blackfin code and remove the defines out of the header
so no new code can rely on them.
This commit is contained in:
Mike Frysinger 2021-07-06 22:23:02 -04:00
parent 9335d9f823
commit 10d8e25c4d
2 changed files with 11 additions and 17 deletions

View File

@ -37,8 +37,6 @@
#include "sim-syscall.h" #include "sim-syscall.h"
#include "sim-hw.h" #include "sim-hw.h"
#include "targ-vals.h"
/* The numbers here do not matter. They just need to be unique. They also /* The numbers here do not matter. They just need to be unique. They also
need not be static across releases -- they're used internally only. The need not be static across releases -- they're used internally only. The
mapping from the Linux ABI to the CB values is in linux-targ-map.h. */ mapping from the Linux ABI to the CB values is in linux-targ-map.h. */
@ -228,7 +226,7 @@ bfin_syscall (SIM_CPU *cpu)
else else
{ {
sc.result = -1; sc.result = -1;
sc.errcode = TARGET_EINVAL; sc.errcode = cb_host_to_target_errno (cb, EINVAL);
} }
break; break;
@ -245,7 +243,7 @@ bfin_syscall (SIM_CPU *cpu)
if (sc.arg4 & 0x20 /*MAP_ANONYMOUS*/) if (sc.arg4 & 0x20 /*MAP_ANONYMOUS*/)
/* XXX: We don't handle zeroing, but default is all zeros. */; /* XXX: We don't handle zeroing, but default is all zeros. */;
else if (args[4] >= MAX_CALLBACK_FDS) else if (args[4] >= MAX_CALLBACK_FDS)
sc.errcode = TARGET_ENOSYS; sc.errcode = cb_host_to_target_errno (cb, ENOSYS);
else else
{ {
#ifdef HAVE_PREAD #ifdef HAVE_PREAD
@ -255,11 +253,11 @@ bfin_syscall (SIM_CPU *cpu)
if (pread (cb->fdmap[args[4]], data, sc.arg2, args[5] << 12) == sc.arg2) if (pread (cb->fdmap[args[4]], data, sc.arg2, args[5] << 12) == sc.arg2)
sc.write_mem (cb, &sc, heap, data, sc.arg2); sc.write_mem (cb, &sc, heap, data, sc.arg2);
else else
sc.errcode = TARGET_EINVAL; sc.errcode = cb_host_to_target_errno (cb, EINVAL);
free (data); free (data);
#else #else
sc.errcode = TARGET_ENOSYS; sc.errcode = cb_host_to_target_errno (cb, ENOSYS);
#endif #endif
} }
@ -288,7 +286,7 @@ bfin_syscall (SIM_CPU *cpu)
if (sc.arg1 >= MAX_CALLBACK_FDS || sc.arg2 >= MAX_CALLBACK_FDS) if (sc.arg1 >= MAX_CALLBACK_FDS || sc.arg2 >= MAX_CALLBACK_FDS)
{ {
sc.result = -1; sc.result = -1;
sc.errcode = TARGET_EINVAL; sc.errcode = cb_host_to_target_errno (cb, EINVAL);
} }
else else
{ {
@ -304,7 +302,7 @@ bfin_syscall (SIM_CPU *cpu)
if (sc.arg2) if (sc.arg2)
{ {
sc.result = -1; sc.result = -1;
sc.errcode = TARGET_EINVAL; sc.errcode = cb_host_to_target_errno (cb, EINVAL);
} }
else else
{ {
@ -327,7 +325,7 @@ bfin_syscall (SIM_CPU *cpu)
if (sc.arg1 >= MAX_CALLBACK_FDS) if (sc.arg1 >= MAX_CALLBACK_FDS)
{ {
sc.result = -1; sc.result = -1;
sc.errcode = TARGET_EINVAL; sc.errcode = cb_host_to_target_errno (cb, EINVAL);
} }
else else
{ {
@ -376,7 +374,7 @@ bfin_syscall (SIM_CPU *cpu)
if (getcwd (p, sc.arg2) == NULL) if (getcwd (p, sc.arg2) == NULL)
{ {
sc.result = -1; sc.result = -1;
sc.errcode = TARGET_EINVAL; sc.errcode = cb_host_to_target_errno (cb, EINVAL);
} }
else else
{ {
@ -446,7 +444,7 @@ bfin_syscall (SIM_CPU *cpu)
if (sc.arg1 != getpid ()) if (sc.arg1 != getpid ())
{ {
sc.result = -1; sc.result = -1;
sc.errcode = TARGET_EPERM; sc.errcode = cb_host_to_target_errno (cb, EPERM);
} }
else else
{ {
@ -455,7 +453,7 @@ bfin_syscall (SIM_CPU *cpu)
goto sys_finish; goto sys_finish;
#else #else
sc.result = -1; sc.result = -1;
sc.errcode = TARGET_ENOSYS; sc.errcode = cb_host_to_target_errno (cb, ENOSYS);
#endif #endif
} }
break; break;

View File

@ -53,11 +53,6 @@ gen_targ_vals_h (void)
printf ("#define TARGET_%s %d\n", t->symbol, t->value); printf ("#define TARGET_%s %d\n", t->symbol, t->value);
printf ("\n"); printf ("\n");
printf ("/* errno values */\n");
for (t = &errno_tdefs[0]; t->symbol; ++t)
printf ("#define TARGET_%s %d\n", t->symbol, t->value);
printf ("\n");
printf ("/* signal values */\n"); printf ("/* signal values */\n");
for (t = &signal_tdefs[0]; t->symbol; ++t) for (t = &signal_tdefs[0]; t->symbol; ++t)
printf ("#define TARGET_%s %d\n", t->symbol, t->value); printf ("#define TARGET_%s %d\n", t->symbol, t->value);
@ -104,6 +99,7 @@ gen_targ_map_c (void)
printf ("CB_TARGET_DEFS_MAP cb_init_errno_map[] = {\n"); printf ("CB_TARGET_DEFS_MAP cb_init_errno_map[] = {\n");
for (t = &errno_tdefs[0]; t->symbol; ++t) for (t = &errno_tdefs[0]; t->symbol; ++t)
{ {
printf ("#define TARGET_%s %d\n", t->symbol, t->value);
printf ("#ifdef %s\n", t->symbol); printf ("#ifdef %s\n", t->symbol);
printf (" { \"%s\", %s, TARGET_%s },\n", t->symbol, t->symbol, t->symbol); printf (" { \"%s\", %s, TARGET_%s },\n", t->symbol, t->symbol, t->symbol);
printf ("#endif\n"); printf ("#endif\n");