Utility routines for libmetal. More...
#include <stdint.h>#include <limits.h>#include <metal/assert.h>Go to the source code of this file.
Macros | |
| #define | MB (1024UL << 10UL) |
| #define | GB (MB << 10UL) |
| #define | metal_unused(x) |
| Marker for unused function arguments/variables. | |
| #define | metal_dim(x) |
| Figure out number of elements in an array. | |
| #define | metal_min(x, y) |
| Minimum of two numbers (warning: multiple evaluation!). | |
| #define | metal_max(x, y) |
| Maximum of two numbers (warning: multiple evaluation!). | |
| #define | metal_sign(x) |
| Sign of a number [-1, 0, or 1] (warning: multiple evaluation!). | |
| #define | metal_align_down(size, align) |
| Align 'size' down to a multiple of 'align' (must be a power of two). | |
| #define | metal_align_up(size, align) |
| Align 'size' up to a multiple of 'align' (must be a power of two). | |
| #define | metal_div_round_down(num, den) |
| Divide (and round down). | |
| #define | metal_div_round_up(num, den) |
| Divide (and round up). | |
| #define | metal_ptr_align_down(ptr, align) |
| Align 'ptr' down to a multiple of 'align' (must be a power of two). | |
| #define | metal_ptr_align_up(ptr, align) |
| Align 'ptr' up to a multiple of 'align' (must be a power of two). | |
| #define | metal_offset_of(structure, member) |
| Compute offset of a field within a structure. | |
| #define | metal_container_of(ptr, structure, member) |
| Compute pointer to a structure given a pointer to one of its fields. | |
| #define | METAL_BITS_PER_ULONG (CHAR_BIT * sizeof(unsigned long)) |
| #define | metal_bit(bit) |
| #define | metal_bitmap_longs(x) |
| #define | metal_bitmap_for_each_set_bit(bitmap, bit, max) |
| #define | metal_bitmap_for_each_clear_bit(bitmap, bit, max) |
Functions | |
| static void | metal_bitmap_set_bit (unsigned long *bitmap, int bit) |
| static int | metal_bitmap_is_bit_set (unsigned long *bitmap, int bit) |
| static void | metal_bitmap_clear_bit (unsigned long *bitmap, int bit) |
| static int | metal_bitmap_is_bit_clear (unsigned long *bitmap, int bit) |
| static unsigned int | metal_bitmap_next_set_bit (unsigned long *bitmap, unsigned int start, unsigned int max) |
| static unsigned int | metal_bitmap_next_clear_bit (unsigned long *bitmap, unsigned int start, unsigned int max) |
| static unsigned long | metal_log2 (unsigned long in) |
Utility routines for libmetal.