How to print __u128_t in kernel?
Philipp Hortmann
philipp.g.hortmann at gmail.com
Mon Sep 20 15:39:15 EDT 2021
On 9/18/21 3:35 PM, Dongliang Mu wrote:
> Hello everyone,
>
> I encounter one object with __uint128_t type in the following code.
> But I am not sure how to print the content of __uint128_t.
>
> struct user_fpsimd_state {
> __uint128_t vregs[32];
> __u32 fpsr;
> __u32 fpcr;
> __u32 __reserved[2];
> };
>
> At first, I would like to use:
> pr_alert("0x%lx %lx\n", i, (uint64_t)(fpreg.vregs[i] >> 64),
> (uint64_t)(fpreg.vregs[i]));
>
> However, gcc reports error with "-Werror" enabled:
>
> In function ‘print_fpregs_in_coredump’:
> error: iteration 32 invokes undefined behavior
> [-Werror=aggressive-loop-optimizations]
> 89 | pr_alert("V%d 0x%lx %lx\n", i, (uint64_t)(fpreg.vregs[i] >> 64),
>
> Any idea to eliminate this error?
>
> --
> My best regards to you.
>
> No System Is Safe!
> Dongliang Mu
>
Hi
I do like this example:
https://lwn.net/Articles/745261/
...
pr_err("%llx%llx\n", (u64) (val >> 64), (u64) val);
pr_err("%llx%llx\n", (u64) (v >> 64), (u64) v);
...
But I have not tried it.
Bye Philipp
More information about the Kernelnewbies
mailing list