Patchwork Change "xor" name in cpu_core to allow building with iso646.h or C++ compiler

login
register
mail settings
Submitter Компан, Вячеслав Олегович
Date Sept. 27, 2018, 8:49 p.m.
Message ID <CAJ+DsBPuZEd2EFZi-ckjCY94Z8i5pv_ybwA_rddYPfgcP40KYQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/29566/
State New
Headers show

Comments

This code was introduced back in 1998, and C99 appeared next year,
defining the `xor` as an 'alternative keyword' if iso646.h is
included. Moreover, C++98 defines it on the language level. As a
result, the code is not buildable with C++ compiler or if iso646.h is
included beforehand.
According to comment, `sim_cpu_core` is mostly a clone of `sim_core`,
so I renamed it to `byte_xor` as it's called in `sim_core`.

sim/common/ChangeLog:

* sim-core.h (sim_cpu_core): Rename cpu_core.xor to
cpu_core.byte_xor.
* sim-core.c (sim_core_set_xor): Likewise.
(sim_core_xor_read_buffer): Likewise.
(sim_core_xor_write_buffer): Likewise.
Simon Marchi - Sept. 28, 2018, 8:03 p.m.
CCing Mike so he knows there is a sim patch.

The patch has wrapped lines,  which makes it difficult to apply.  Since it is small
I was able to fix it up by hand, but for the future I suggest you look into using
git-send-email, which avoids these problems.

The patch looks obvious enough to me and I built-tested it, so I took the liberty
of pushing it.

Thanks!

Simon

Patch

diff --git a/sim/common/sim-core.c b/sim/common/sim-core.c
index f26a374bb3..5247097102 100644
--- a/sim/common/sim-core.c
+++ b/sim/common/sim-core.c
@@ -587,7 +587,7 @@  sim_core_set_xor (SIM_DESC sd,
      mask = 0;
    while (i - 1 < WITH_XOR_ENDIAN)
      {
-       cpu_core->xor[i-1] = mask;
+       cpu_core->byte_xor[i-1] = mask;
        mask = (mask << 1) & (WITH_XOR_ENDIAN - 1);
        i = (i << 1);
      }
@@ -634,7 +634,7 @@  sim_core_xor_read_buffer (SIM_DESC sd,
    address_word addr,
    unsigned nr_bytes)
 {
-  address_word byte_xor = (cpu == NULL ? STATE_CORE (sd)->byte_xor :
CPU_CORE (cpu)->xor[0]);
+  address_word byte_xor = (cpu == NULL ? STATE_CORE (sd)->byte_xor :
CPU_CORE (cpu)->byte_xor[0]);
   if (!WITH_XOR_ENDIAN || !byte_xor)
     return sim_core_read_buffer (sd, cpu, map, buffer, addr, nr_bytes);
   else
@@ -686,7 +686,7 @@  sim_core_xor_write_buffer (SIM_DESC sd,
     address_word addr,
     unsigned nr_bytes)
 {
-  address_word byte_xor = (cpu == NULL ? STATE_CORE (sd)->byte_xor :
CPU_CORE (cpu)->xor[0]);
+  address_word byte_xor = (cpu == NULL ? STATE_CORE (sd)->byte_xor :
CPU_CORE (cpu)->byte_xor[0]);
   if (!WITH_XOR_ENDIAN || !byte_xor)
     return sim_core_write_buffer (sd, cpu, map, buffer, addr, nr_bytes);
   else
diff --git a/sim/common/sim-core.h b/sim/common/sim-core.h
index ccfe48fba6..305d1564b3 100644
--- a/sim/common/sim-core.h
+++ b/sim/common/sim-core.h
@@ -89,7 +89,7 @@  struct _sim_core {

 typedef struct _sim_cpu_core {
   sim_core_common common;
-  address_word xor[WITH_XOR_ENDIAN + 1]; /* +1 to avoid zero-sized array */
+  address_word byte_xor[WITH_XOR_ENDIAN + 1]; /* +1 to avoid
zero-sized array */
 } sim_cpu_core;