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~