BRL-CAD
#include "common.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include "bu/bitv.h"
#include "bu/log.h"
#include "bu/malloc.h"
#include "bu/vls.h"
#include "./bu_internals.h"
Include dependency graph for bitv.c:

Go to the source code of this file.

Macros

#define COUNT_ONES32(x)
 
#define FLOOR_ILOG2(x)
 

Functions

size_t bu_bitv_shift (void)
 
struct bu_bitvbu_bitv_new (size_t nbits)
 
void bu_bitv_free (struct bu_bitv *bv)
 
void bu_bitv_clear (struct bu_bitv *bv)
 
void bu_bitv_or (struct bu_bitv *ov, const struct bu_bitv *iv)
 
void bu_bitv_and (struct bu_bitv *ov, const struct bu_bitv *iv)
 
void bu_bitv_vls (struct bu_vls *v, register const struct bu_bitv *bv)
 
void bu_pr_bitv (const char *str, register const struct bu_bitv *bv)
 
void bu_bitv_to_hex (struct bu_vls *v, const struct bu_bitv *bv)
 
struct bu_bitvbu_hex_to_bitv (const char *str)
 
struct bu_bitvbu_bitv_dup (register const struct bu_bitv *bv)
 
void bu_bitv_to_binary (struct bu_vls *v, const struct bu_bitv *bv)
 
struct bu_bitvbu_binary_to_bitv (const char *str)
 
struct bu_bitvbu_binary_to_bitv2 (const char *str, const int nbytes)
 
int bu_bitv_compare_equal (const struct bu_bitv *bv1, const struct bu_bitv *bv2)
 
int bu_bitv_compare_equal2 (const struct bu_bitv *bv1, const struct bu_bitv *bv2)
 
int bu_binstr_to_hexstr (const char *bstr, struct bu_vls *h)
 
int bu_hexstr_to_binstr (const char *hstr, struct bu_vls *b)
 

Detailed Description

Routines for managing efficient high-performance bit vectors of arbitrary length.

The basic type "bitv_t" is defined in include/bu.h; it is the widest integer datatype for which efficient hardware support exists. BU_BITV_SHIFT and BU_BITV_MASK are also defined in bu.h

These bit vectors are "little endian", bit 0 is in the right hand side of the [0] word.

Definition in file bitv.c.

Macro Definition Documentation

#define COUNT_ONES32 (   x)
Value:
{ \
x -= ((x >> 1) & 0x55555555); \
x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); \
x = (((x >> 4) + x) & 0x0f0f0f0f); \
x += (x >> 8); \
x += (x >> 16); \
x &= 0x0000003f; \
}

Private 32-bit recursive reduction using "SIMD Within A Register" (SWAR) to count the number of one bits in a given integer. The first step is mapping 2-bit values into sum of 2 1-bit values in sneaky way. This technique was taken from the University of Kentucky's Aggregate Magic Algorithms collection.

LLVM 3.2 complains about a static inline function here, so use a macro instead

Definition at line 45 of file bitv.c.

#define FLOOR_ILOG2 (   x)
Value:
{ \
x |= (x >> 1); \
x |= (x >> 2); \
x |= (x >> 4); \
x |= (x >> 8); \
x |= (x >> 16); \
x >>= 1; \
}
#define COUNT_ONES32(x)
Definition: bitv.c:45

Private 32-bit recursive reduction using "SIMD Within A Register" (SWAR) to compute a base-2 integer logarithm for a given integer. This technique was taken from the University of Kentucky's Aggregate Magic Algorithms collection.

LLVM 3.2 complains about a static inline function here, so use a macro instead

Definition at line 63 of file bitv.c.

Referenced by bu_bitv_shift().

Function Documentation

void bu_bitv_vls ( struct bu_vls v,
register const struct bu_bitv bv 
)

Definition at line 178 of file bitv.c.

References BU_BITTEST, BU_CK_BITV, BU_CK_VLS, bu_vls_printf(), bu_vls_strcat(), and bu_bitv::nbits.

Referenced by bu_pr_bitv().

Here is the call graph for this function:

void bu_pr_bitv ( const char *  str,
register const struct bu_bitv bv 
)

Definition at line 205 of file bitv.c.

References bu_bitv_vls(), BU_CK_BITV, bu_log(), bu_vls_addr(), bu_vls_free(), BU_VLS_INIT_ZERO, and bu_vls_strcat().

Here is the call graph for this function:

struct bu_bitv* bu_bitv_dup ( register const struct bu_bitv bv)

Definition at line 334 of file bitv.c.

References bu_bitv_new(), bu_bitv_or(), and bu_bitv::nbits.

Here is the call graph for this function: