From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: single, comprehensive kernel data types document?
Date: Fri, 15 Apr 2016 05:27:24 -0700 [thread overview]
Message-ID: <20160415122724.GA7389@kroah.com> (raw)
In-Reply-To: <alpine.LFD.2.20.1604150801170.6570@localhost.localdomain>
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
next prev parent reply other threads:[~2016-04-15 12:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-15 12:04 single, comprehensive kernel data types document? Robert P. J. Day
2016-04-15 12:27 ` Greg KH [this message]
2016-04-15 12:37 ` John Chludzinski
2016-04-15 13:08 ` Silvan Jegen
2016-04-15 13:09 ` Daniel.
2016-04-15 13:55 ` Greg KH
2016-04-15 16:28 ` Daniel.
2016-04-15 13:53 ` Greg KH
2016-04-15 15:59 ` Nicholas Mc Guire
2016-04-15 16:18 ` Greg KH
2016-04-15 17:07 ` Valdis.Kletnieks at vt.edu
2016-04-15 20:15 ` Greg KH
2016-04-20 20:37 ` Rob Groner
2016-04-21 2:51 ` Greg KH
2016-04-21 12:51 ` Rob Groner
2016-04-21 19:34 ` Josh Cartwright
2016-04-22 2:37 ` Greg KH
2016-04-22 3:02 ` Valdis.Kletnieks at vt.edu
2016-04-22 3:13 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160415122724.GA7389@kroah.com \
--to=greg@kroah.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).