diff mbox

[2/2] m68k: Build the opcode table only once to avoid multithreading issues

Message ID 1454492221-30625-3-git-send-email-glaubitz@physik.fu-berlin.de
State New
Headers show

Commit Message

John Paul Adrian Glaubitz Feb. 3, 2016, 9:37 a.m. UTC
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
---
 target-m68k/translate.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Laurent Vivier Feb. 3, 2016, 9:39 a.m. UTC | #1
Le 03/02/2016 10:37, John Paul Adrian Glaubitz a écrit :
> Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> ---
>  target-m68k/translate.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/target-m68k/translate.c b/target-m68k/translate.c
> index 535d7f9..f508d1e 100644
> --- a/target-m68k/translate.c
> +++ b/target-m68k/translate.c
> @@ -2828,6 +2828,10 @@ register_opcode (disas_proc proc, uint16_t opcode, uint16_t mask)
>     Later insn override earlier ones.  */
>  void register_m68k_insns (CPUM68KState *env)
>  {
> +    /* Build the opcode table only once to avoid
> +       issues with multithreading. */
> +    if(opcode_table[0] != NULL)
> +       return;
>  #define INSN(name, opcode, mask, feature) do { \
>      if (m68k_feature(env, M68K_FEATURE_##feature)) \
>          register_opcode(disas_##name, 0x##opcode, 0x##mask); \
> 
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Laurent Vivier Feb. 3, 2016, 9:57 a.m. UTC | #2
Le 03/02/2016 10:39, Laurent Vivier a écrit :
> 
> 
> Le 03/02/2016 10:37, John Paul Adrian Glaubitz a écrit :
>> Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
>> ---
>>  target-m68k/translate.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/target-m68k/translate.c b/target-m68k/translate.c
>> index 535d7f9..f508d1e 100644
>> --- a/target-m68k/translate.c
>> +++ b/target-m68k/translate.c
>> @@ -2828,6 +2828,10 @@ register_opcode (disas_proc proc, uint16_t opcode, uint16_t mask)
>>     Later insn override earlier ones.  */
>>  void register_m68k_insns (CPUM68KState *env)
>>  {
>> +    /* Build the opcode table only once to avoid
>> +       issues with multithreading. */
>> +    if(opcode_table[0] != NULL)
>> +       return;
>>  #define INSN(name, opcode, mask, feature) do { \
>>      if (m68k_feature(env, M68K_FEATURE_##feature)) \
>>          register_opcode(disas_##name, 0x##opcode, 0x##mask); \
>>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>

In fact, the line should be:

+    if (opcode_table[0] != NULL)
+        return;

thanks to scripts/checkpatch.pl.

Laurent
John Paul Adrian Glaubitz Feb. 3, 2016, 10:06 a.m. UTC | #3
On 02/03/2016 10:57 AM, Laurent Vivier wrote:
> In fact, the line should be:
> 
> +    if (opcode_table[0] != NULL)
> +        return;
> 
> thanks to scripts/checkpatch.pl.

Want me to re-send it?
Laurent Vivier Feb. 3, 2016, 10:13 a.m. UTC | #4
Le 03/02/2016 11:06, John Paul Adrian Glaubitz a écrit :
> On 02/03/2016 10:57 AM, Laurent Vivier wrote:
>> In fact, the line should be:
>>
>> +    if (opcode_table[0] != NULL)
>> +        return;
>>
>> thanks to scripts/checkpatch.pl.
> 
> Want me to re-send it?
> 

I don't know if the one who will commit this to the tree will want to
update this.

BTW, Peter, perhaps it's the time to add me as m68k maintainer ?
(so I will manage that :) )

Laurent
John Paul Adrian Glaubitz Feb. 3, 2016, 10:17 a.m. UTC | #5
On 02/03/2016 11:13 AM, Laurent Vivier wrote:
> I don't know if the one who will commit this to the tree will want to
> update this.

Just sent an updated one, just in case :).

> BTW, Peter, perhaps it's the time to add me as m68k maintainer ?
> (so I will manage that :) )

Yes, please. I'm all for that! I'm really motivated to get m68k
support into best shape. qemu-m68k is fun to hack on!

Adrian
diff mbox

Patch

diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index 535d7f9..f508d1e 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -2828,6 +2828,10 @@  register_opcode (disas_proc proc, uint16_t opcode, uint16_t mask)
    Later insn override earlier ones.  */
 void register_m68k_insns (CPUM68KState *env)
 {
+    /* Build the opcode table only once to avoid
+       issues with multithreading. */
+    if(opcode_table[0] != NULL)
+       return;
 #define INSN(name, opcode, mask, feature) do { \
     if (m68k_feature(env, M68K_FEATURE_##feature)) \
         register_opcode(disas_##name, 0x##opcode, 0x##mask); \