Comedi use of standard types

Dan Carpenter dan.carpenter at oracle.com
Wed Feb 22 21:56:15 UTC 2017


On Thu, Feb 23, 2017 at 07:48:59AM +1100, Tobin C. Harding wrote:
> On Wed, Feb 22, 2017 at 04:51:05PM +0300, Dan Carpenter wrote:
> > On Wed, Feb 22, 2017 at 11:46:07AM +0000, Ian Abbott wrote:
> > > On 21/02/17 21:27, Tobin C. Harding wrote:
> > > >Comedi drivers make heavy use of standard types i.e unsigned
> > > >short. According to Linux Device Drivers standard C data types are not
> > > >the same size of all architectures.
> > > >
> > > >Should we be converting comedi/drivers to use kernel types u8, u16 etc
> > > 
> > > Linux kernel C data types have stricter requirements than the C
> > > standard allows.  There is common agreement on the widths of 'char',
> > > 'short', 'int', and 'long long', a choice of two widths for 'long'.
> > > Signed integers are assumed to use 2's complement representation,
> > > and null pointers are assumed to have an "all bits zero"
> > > representation. Obviously, the "endianness" of the types will be
> > > arch-specific.  (I probably missed some stuff.  For example, I'm not
> > > sure if the Linux kernel requires a plain 'char' to be signed.  And
> > > I don't know if any of this is officially documented anywhere, so
> > > count it as my opinion.)
> 
> Thanks for clarifying. So, as I understand it now, as far as kernel
> code goes;
> 
> u8 <=> unsigned char
> u16 <=> unsigned short
> u32 <=> unsigned int
> u64 <=> unsigned long long
> 
> (where <=> means 'is equivalent to')

Yeah.  But they sort of communicate different things.  It's just like
we don't remove all the synomym duplicates from the English language.

regards,
dan carpenter



More information about the devel mailing list