lkml.org 
[lkml]   [2024]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] include/linux/make_type.h: Helpers for making u16/u32/u64 values
On Wed, Feb 14, 2024 at 07:32:10PM +0200, Andy Shevchenko wrote:
> On Wed, Feb 14, 2024 at 08:20:55PM +0300, Alexey Dobriyan wrote:
>
> ...
>
> > Secondly,
> >
> > #define make_u64(hi__, lo__) ((u64)(hi__) << 32 | (u32)(lo__))
> >
> > doesn't truncate hi, why?
>
> Because it's not needed (the whole point AFAIU is to override promotion
> to a _signed_ type (int) and here it makes no difference)?

Well,

make_u64((u64)-1, 0)

will return (u64)-1 unlike

make_u16((u64)-1, 0)

which will return 0xff00.
BTW, I'm for truncation, but it should be done everywhere.

Thirdly, there were no users posted.

\
 
 \ /
  Last update: 2024-05-27 15:02    [W:0.069 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site