qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 1/2] cpu: Provide a proper prototype for targ


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2 1/2] cpu: Provide a proper prototype for target_words_bigendian() in a header
Date: Fri, 5 Oct 2018 14:32:35 +0100

On 5 October 2018 at 14:20, Laszlo Ersek <address@hidden> wrote:
> On 10/05/18 15:01, Thomas Huth wrote:
>> We've got three places already that provide a prototype for this
>> function in a .c file - that's ugly. Let's provide a proper prototype
>> in a header instead, with a proper description why this function should
>> not be used in most cases.
>>
>> Signed-off-by: Thomas Huth <address@hidden>
>> ---

>> +/**
>> + * target_words_bigendian:
>> + * Returns true if the (default) endianness of the target is big endian,
>> + * false otherwise. Note that in target-specifc code, you can use

"specific"

>> + * TARGET_WORDS_BIGENDIAN directly instead. On the other hand, common
>> + * code should normally never need to know about the endianness of the
>> + * target, so please do *not* use this function unless you know very well
>> + * what you are doing!
>> + */
>> +bool target_words_bigendian(void);
>> +
>>  #ifdef NEED_CPU_H
>>
>>  #ifdef CONFIG_SOFTMMU
>> diff --git a/qom/cpu.c b/qom/cpu.c
>> index 92599f3..f774654 100644
>> --- a/qom/cpu.c
>> +++ b/qom/cpu.c
>> @@ -194,7 +194,6 @@ static bool cpu_common_debug_check_watchpoint(CPUState 
>> *cpu, CPUWatchpoint *wp)
>>      return true;
>>  }
>>
>> -bool target_words_bigendian(void);
>>  static bool cpu_common_virtio_is_big_endian(CPUState *cpu)
>>  {
>>      return target_words_bigendian();
>>
>
> This makes sense to me. First I wasn't convinced, because I didn't
> immediately get "target-specifc code". However, after looking at the 2nd
> patch, I think I understand better (= the obj-XXX vs. common-obj-XXX
> distinction). I also think that distinction is clear to any practicing
> QEMU developers.

Yes; target-specific code is compiled for each qemu-system-*
executable (and has access to #defines and so on that relate
specifically to that target); common code is built just once
and the same .o linked into each executable.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]