All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "ehabkost@redhat.com" <ehabkost@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"blauwirbel@gmail.com" <blauwirbel@gmail.com>,
	"imammedo@redhat.com" <imammedo@redhat.com>,
	"afaerber@suse.de" <afaerber@suse.de>,
	liguang <lig.fnst@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH v3 2/3] target-i386:make hw_breakpoint_enabled return bool type
Date: Fri, 07 Dec 2012 11:29:51 +0100	[thread overview]
Message-ID: <50C1C51F.80807@siemens.com> (raw)
In-Reply-To: <CAFEAcA97Cz=C2Rf4p86vPqMO9_z7ixLqY-QtR-VJC05X+9U6Qw@mail.gmail.com>

On 2012-12-07 11:24, Peter Maydell wrote:
> On 7 December 2012 01:25, liguang <lig.fnst@cn.fujitsu.com> wrote:
>> Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
>> ---
>>  target-i386/cpu.h |   15 +++++++++++++--
>>  1 files changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/target-i386/cpu.h b/target-i386/cpu.h
>> index 29245d1..3646128 100644
>> --- a/target-i386/cpu.h
>> +++ b/target-i386/cpu.h
>> @@ -996,9 +996,20 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr,
>>  #define cpu_handle_mmu_fault cpu_x86_handle_mmu_fault
>>  void cpu_x86_set_a20(CPUX86State *env, int a20_state);
>>
>> -static inline int hw_breakpoint_enabled(unsigned long dr7, int index)
>> +static inline bool hw_local_breakpoint_enabled(unsigned long dr7, int index)
>>  {
>> -    return (dr7 >> (index * 2)) & 3;
>> +    return !(((dr7 >> (index * 2)) ^ 1) & 3);
> 
> This is pretty confusing and I'm pretty sure the function is
> misnamed too. If we're checking "is local breakpoint enabled"
> then we only want to check one of the two enable bits, not both.
> 

Yes, and I already asked to define the proper constants that allow
checking for local vs. global enable bit. They have to be used here
instead of all the magic & 3 or ^ 1 stuff.

BTW, there is no need for "converting" ("!!") the result of the (value &
mask) to bool, the compiler will do this already.

Jan

> 
>> +}
>> +
>> +static inline bool hw_global_breakpoint_enabled(unsigned long dr7, int index)
>> +{
>> +    return !!((dr7 >> (index * 2)) & 2);
>> +}
>> +
>> +static inline bool hw_breakpoint_enabled(unsigned long dr7, int index)
>> +{
>> +    return (hw_global_breakpoint_enabled(dr7, index) ||
>> +            hw_local_breakpoint_enabled(dr7, index));
>>  }
> 
> -- PMM
> 

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux

  reply	other threads:[~2012-12-07 10:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  1:25 [Qemu-devel] [PATCH v3 1/3] target-i386:define name of breakpoint bit in dr7 liguang
2012-12-07  1:25 ` [Qemu-devel] [PATCH v3 2/3] target-i386:make hw_breakpoint_enabled return bool type liguang
2012-12-07 10:24   ` Peter Maydell
2012-12-07 10:29     ` Jan Kiszka [this message]
2012-12-10  2:24       ` li guang
2012-12-07  1:25 ` [Qemu-devel] [PATCH v3 3/3] target-i386:slightly refactor dr7 related function liguang
2012-12-07 10:27   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50C1C51F.80807@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=afaerber@suse.de \
    --cc=blauwirbel@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=lig.fnst@cn.fujitsu.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.