qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 3/3] capstone: Add s390x skipdata callback


From: Richard Henderson
Subject: Re: [PATCH v3 3/3] capstone: Add s390x skipdata callback
Date: Tue, 15 Oct 2019 12:22:01 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 10/15/19 11:46 AM, Thomas Huth wrote:
>> +cap_skipdata_s390x_cb(const uint8_t *code, size_t code_size,
>> +                      size_t offset, void *user_data)
>> +{
>> +    size_t ilen;
>> +
>> +    /* See get_ilen() in target/s390x/internal.h.  */
>> +    switch (code[offset] >> 6) {
>> +    case 0:
>> +        ilen = 2;
>> +        break;
>> +    case 1:
>> +    case 2:
>> +        ilen = 4;
>> +        break;
>> +    default:
>> +        ilen = 6;
>> +        break;
>> +    }
>> +
>> +    return ilen;
>> +}
> 
> The kernel has also a nice function to calculate this:
> 
> static inline int insn_length(unsigned char code)
> {
>         return ((((int) code + 64) >> 7) + 1) << 1;
> }
> 
> ... but the switch-case is likely easier to read, so anyway:

Clever.

I don't mind swapping to the kernel version, so long as we convert the
target/s390x/internal.h function as well.


r~



reply via email to

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