Quick Reference

The following symbols were introduced in this chapter:

#include <linux/types.h> , typedef u8; , typedef u16; , typedef u32; , typedef u64;

These types are guaranteed to be 8-, 16-, 32-, and 64-bit unsigned integer values. The equivalent signed types exist as well. In user space, you can refer to the types as __u8, __u16, etc.

#include <asm/page.h> , PAGE_SIZE , PAGE_SHIFT

These symbols define the number of bytes per page for the current architecture and the number of bits in the page offset (12 for 4KB pages and 13 for 8KB pages).

#include <asm/byteorder.h> , __LITTLE_ENDIAN , __BIG_ENDIAN

Only one of the two symbols is defined, depending on the architecture. Version 1.3.18 and older declared the symbols without the leading underscores (thus conflicting with some of the network headers).

#include <asm/byteorder.h> , unsigned long ntohl(unsigned long); , unsigned short ntohs(unsigned short); , unsigned long htonl(unsigned long); , unsigned short htons(unsigned short);

These functions convert long and short data between the network byte order and the host byte order.

#include <asm/unaligned.h> , get_unaligned(ptr); , put_unaligned(val, ptr);

Some architectures need to protect unaligned data access using these macros. The macros expand to normal pointer dereferencing for architectures that permit you to access unaligned data.

Get Linux Device Drivers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.