From mboxrd@z Thu Jan 1 00:00:00 1970 From: john.chludzinski@vivaldi.net (John Chludzinski) Date: Fri, 15 Apr 2016 08:37:56 -0400 Subject: single, comprehensive kernel data types document? In-Reply-To: <20160415122724.GA7389@kroah.com> References: <20160415122724.GA7389@kroah.com> Message-ID: <3e0913de8af67a2489ffa472ea0186f0@mail.vivaldi.net> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Never use stdint.h? Wasn't that the intent of stdint.h ... for kernel code? For embedded code? ---John On 2016-04-15 08:27, Greg KH wrote: > On Fri, Apr 15, 2016 at 08:04:53AM -0400, Robert P. J. Day wrote: >> >> is there a single, decent online doc that explains the proper data >> types (int16_t, int32_t and so on) to use in kernel code? > > First off, never use int16_t and friends, that's not ok :) > > Second, it's simple, use: > u8 > u16 > u32 > u64 > and friends in kernel code (s8, s16, and so on for signed values.) > > 'int' is a return type, and for loops and other things that you know > will fit in that size. > >> including the relationship with types to be used in code to be >> exported to user space (include/uapi/linux/types.h)? > > For values that cross the user/kernel boundry, add '__' to the front of > the variable: > __u8 > __u16 > __u32 > and so on. NEVER use 'int' or 'long' crossing that boundry, it's not > going to work properly. > > I think one of the chapters in LDD3 describes all of this, you might > want to re-read it for the details. > > hope this helps, > > greg k-h > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies