Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros
getorder.h File Reference
#include <linux/compiler.h>
#include <linux/log2.h>

Go to the source code of this file.

Macros

#define get_order(n)
 

Macro Definition Documentation

#define get_order (   n)
Value:
( \
__builtin_constant_p(n) ? ( \
((n) == 0UL) ? BITS_PER_LONG - PAGE_SHIFT : \
(((n) < (1UL << PAGE_SHIFT)) ? 0 : \
ilog2((n) - 1) - PAGE_SHIFT + 1) \
) : \
__get_order(n) \
)

get_order - Determine the allocation order of a memory size : The size for which to get the order

Determine the allocation order of a particular sized block of memory. This is on a logarithmic scale, where:

0 -> 2^0 * PAGE_SIZE and below 1 -> 2^1 * PAGE_SIZE to 2^0 * PAGE_SIZE + 1 2 -> 2^2 * PAGE_SIZE to 2^1 * PAGE_SIZE + 1 3 -> 2^3 * PAGE_SIZE to 2^2 * PAGE_SIZE + 1 4 -> 2^4 * PAGE_SIZE to 2^3 * PAGE_SIZE + 1 ...

The order returned is used to find the smallest allocation granule required to hold an object of the specified size.

The result is undefined if the size is 0.

This function may be used to initialise variables with compile time evaluations of constants.

Definition at line 49 of file getorder.h.