include/bitops.h File Reference

Generic bit operations. More...

#include <stdbool.h>
#include <types.h>
#include <assert.h>
#include <arch/bitops.h>

Include dependency graph for bitops.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define bit_mask(nr)   (1 << ((nr) & (BITS_PER_LONG - 1)))
 Generate a bit mask with only bit nr set.
#define bit_word(nr)   ((nr) / BITS_PER_LONG)
 Return the offset of the word containing bit nr in a multi-word bitfield.

Functions

static void set_bit (unsigned int nr, unsigned long *bitmap)
 Set bit nr in the multi-word bitfield bitmap.
static void clear_bit (unsigned int nr, unsigned long *bitmap)
 Clear bit nr in the multi-word bitfield bitmap.
static void toggle_bit (unsigned int nr, unsigned long *bitmap)
 Toggle bit nr in the multi-word bitfield bitmap.
static bool test_bit (unsigned int nr, unsigned long *bitmap)
 Test bit nr in the multi-word bitfield bitmap.
static uint32_t extract_aligned_bitfield (unsigned int start, unsigned int length, const uint32_t *bitmap)
 Get the bitfield of length starting at bit nr start in the multi-word bitfield bitmap.
static uint32_t extract_bitfield (unsigned int start, unsigned int length, const uint32_t *bitmap)
 Get the bitfield of length starting at bit nr start in the multi-word bitfield bitmap.


Detailed Description

Generic bit operations.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file bitops.h.


Define Documentation

#define bit_mask ( nr   )     (1 << ((nr) & (BITS_PER_LONG - 1)))

Generate a bit mask with only bit nr set.

Definition at line 49 of file bitops.h.

Referenced by atomic_clear_bit(), atomic_set_bit(), atomic_test_and_clear_bit(), atomic_test_and_set_bit(), atomic_toggle_bit(), clear_bit(), set_bit(), and toggle_bit().

#define bit_word ( nr   )     ((nr) / BITS_PER_LONG)

Return the offset of the word containing bit nr in a multi-word bitfield.

Definition at line 54 of file bitops.h.

Referenced by atomic_clear_bit(), atomic_set_bit(), atomic_test_and_clear_bit(), atomic_test_and_set_bit(), atomic_toggle_bit(), clear_bit(), extract_aligned_bitfield(), extract_bitfield(), set_bit(), test_bit(), and toggle_bit().


Function Documentation

static void clear_bit ( unsigned int  nr,
unsigned long *  bitmap 
) [inline, static]

static uint32_t extract_aligned_bitfield ( unsigned int  start,
unsigned int  length,
const uint32_t *  bitmap 
) [inline, static]

Get the bitfield of length starting at bit nr start in the multi-word bitfield bitmap.

Precondition:
The desired bitfield must not cross word boundaries
Return values:
The desired bitfield

Definition at line 102 of file bitops.h.

References bit_word, and BITS_PER_LONG.

Referenced by extract_bitfield().

static uint32_t extract_bitfield ( unsigned int  start,
unsigned int  length,
const uint32_t *  bitmap 
) [inline, static]

Get the bitfield of length starting at bit nr start in the multi-word bitfield bitmap.

Return values:
The desired bitfield

Definition at line 120 of file bitops.h.

References assert, bit_word, BITS_PER_LONG, and extract_aligned_bitfield().

Referenced by sdmmc_decode_mmc_cid(), sdmmc_decode_mmc_csd(), sdmmc_decode_sd_cid(), and sdmmc_decode_sd_csd().

Here is the call graph for this function:

static void set_bit ( unsigned int  nr,
unsigned long *  bitmap 
) [inline, static]

static bool test_bit ( unsigned int  nr,
unsigned long *  bitmap 
) [inline, static]

static void toggle_bit ( unsigned int  nr,
unsigned long *  bitmap 
) [inline, static]

Toggle bit nr in the multi-word bitfield bitmap.

Definition at line 77 of file bitops.h.

References bit_mask, and bit_word.


Generated on Tue Sep 15 10:17:54 2009 for libavr32 by  doxygen 1.5.8