Ingres CL BT

From Ingres Community Wiki

Jump to: navigation, search

Ingres Compatability Library
Architecture - Overview - Suggestions - GL: BA - BT - ERGL - handy - HSH - LC - LL - MEGL - MM - MO - MU - PM - SP - TMGL - CL: CI - CK - CM - CP - CS - CSMT - CV - CX - DI - DL - DS - ER - ERold - EX - FP - GC - GV - handy - ID - JF - LG - LK - LO - ME - MH - NM - OL - PC - PE - QU - SA - SI - SR - ST - TC - TE - TH - TM - TR - UT

Compatibility Library Specification - BT

Contents


Abstract

This is the specification of the BT facility provided by the compatibility library for bit manipulation.

Revision: 2.1, 27-Mar-1997

Document History

  • Revision 2.1, 27-Mar-1997
    • Formatted in html.
  • Revision 2.0, 29-Jul-94. The following changes were made as part of 6.5, a/k/a OpenINGRES 1.x.
    • <bt.h> was moved to the GL 7-aug-92. (Everything else went later).
    • BTdump doesn't exist; neither do BTcopy, BTfill and BTmask (4-sep-92)
    • Bit vectors are defined as (possibly signed) char *, and won't be changing. Beware (16-oct-92).
  • Revision 1.0, last modified 2-Jan-91.

Specification

Introduction

The routines in the BT module manipulate bits within the specified byte stream[s].

Though the practical limit is much lower, the maximum number of bits in any byte stream is (MAXI2 / BITSPERBYTE) * BITSPERBYTE. All counts number the least significant bit as zero. Routines with a size argument, specifying the number of bits to operate on, require that all of the more significant bits in the byte containing the bit size be zero'ed out, i.e. size arguments may be rounded internally to multiples of BITSPERBYTE. NOTE: size arguments are numbered from 1.

None of these routines return status or signal any exceptions.

These routines can be implemented in a system independent fashion.

Library

GL

Header File <bt.h>

The header file <bt.h> must be included before using any of the functions provided. (It is actually located in gl!hdr!hdr.)

Executable Interface

The following functions are provided.

BTand - set vector to AND with mask

Set *vector to logical AND of *vector and *mask (Similar to C &= operator). Both vectors have width size in bits.

Inputs:

size width of vector in bits
mask AND mask to apply to vector
vector bit array

Outputs:

None

Definition:

VOID
BTand(size, mask, vector)
i4	size;
char	*mask;
char	*vector;

BTclear - clear a bit

Clear bit pos of *vector.

Inputs:

pos bit position
vector bit array

Outputs:

None

Returns:

None

Definition:

VOID
BTclear(pos, vector)
i4	pos;
char	*vector;

BTcount - count set bits

Return the number of set bits in the bit map *vector, which is of width size in bits.

Inputs:

vector bit array
size width of vector, in bits

Outputs:

None

Returns:

Number of set bits

Definition:

i4
BTcount(vector, size)
char	*vector;
i4	size; 

BThigh - find most significant set bit

Return the position of the most significant set bit in *vector. Returns -1 if no bits are set within the first size bits of vector.

Inputs:

vector bit array
size width of vector, in bits

Outputs:

None

Returns:

Position of most significant bit, or -1

Definition:

i4
BThigh(vector, size)
char	*vector;
i4	size;

BTnext - find next set bit

Starting at position n+1, search the byte stream *vector. Return the position of the set bit or -1 if no bits are set within the first size bits of vector. The reason for starting at n+1 is to allow the return value position to be the n argument of another call to BTnext. Search from lsb to msb.

Inputs:

n starting position -1
vector bit array
size size of vector, in bits

Outputs:

None

Returns:

position of next set bit, or -1.

Definition:

i4
BTnext(n, vector, size)
i4	n;
char	*vector;
i4	size;

BTnot - unary bit-wise NOT of a vector

BTnot() performs a bit-wise NOT operation on a vector of size bits. Each bit that was set (1) before the BTnot() call will be clear (0) afterward; each bit that was clear will be set. It is assumed that the memory allocated to vector is a multiple of BITS_PER_BYTE bits in size.

Inputs:

size size of vector, in bits
vector bit array

Outputs:

None

Returns:

None

Definition:

VOID
BTnot(size, vector)
i4	size;
char	*vector;

BTor - set vector to OR with mask

Set *vector to bit-wise OR of *vector and *mask (Similar to C |= operator). Both vectors have width size in bits.

Inputs:

size size of both mask, and vector, in bits
mask OR mask
vector bit array

Outputs:

None

Returns:

None

Definition:

VOID
BTor(size, mask, vector)
i4	size;
char	*mask;
char	*vector;

BTset - set a bit in a vector

Set bit pos of *vector.

Inputs:

pos position of bit to set
vector bit array

Outputs:

None

Returns:

None

Definition:

VOID
BTset(pos, vector)
i4	pos;
char	*vector;

BTsubset - test for set inclusion

Is *vector a subset of *set. Both vectors have width size in bits.

*vector is considered a "subset" of *set if all bits which are set in *set are also set in *vector.

Inputs:

vector bit array
set subset bit array
size width of both vectors, in bits

Outputs:

None

Returns:

0 if vector is not a subset of set.

Definition:

bool
BTsubset(vector, set, size)
char	*vector;
char	*set;
i4	size;

BTtest - bit test

Test if bit pos is set in *vector.

Inputs:

pos bit position to test
vector bit array

Outputs:

None

Returns:

0 if bit is not set.

Definition:

#bool
BTtest(pos, vector)
i4	pos;
char	*vector;

Ingres Compatability Library
Architecture - Overview - Suggestions - GL: BA - BT - ERGL - handy - HSH - LC - LL - MEGL - MM - MO - MU - PM - SP - TMGL - CL: CI - CK - CM - CP - CS - CSMT - CV - CX - DI - DL - DS - ER - ERold - EX - FP - GC - GV - handy - ID - JF - LG - LK - LO - ME - MH - NM - OL - PC - PE - QU - SA - SI - SR - ST - TC - TE - TH - TM - TR - UT

Personal tools
Developing With