VxWorks Reference Manual : Libraries
bLib - buffer manipulation library
bcmp( ) - compare one buffer to another
binvert( ) - invert the order of bytes in a buffer
bswap( ) - swap buffers
swab( ) - swap bytes
uswab( ) - swap bytes with buffers that are not necessarily aligned
bzero( ) - zero out a buffer
bcopy( ) - copy one buffer to another
bcopyBytes( ) - copy one buffer to another one byte at a time
bcopyWords( ) - copy one buffer to another one word at a time
bcopyLongs( ) - copy one buffer to another one long word at a time
bfill( ) - fill a buffer with a specified character
bfillBytes( ) - fill buffer with a specified character one byte at a time
index( ) - find the first occurrence of a character in a string
rindex( ) - find the last occurrence of a character in a string
This library contains routines to manipulate buffers of variable-length byte arrays. Operations are performed on long words when possible, even though the buffer lengths are specified in bytes. This occurs only when source and destination buffers start on addresses that are both odd or both even. If one buffer is even and the other is odd, operations must be done one byte at a time (because of alignment problems inherent in the MC68000), thereby slowing down the process.
Certain applications, such as byte-wide memory-mapped peripherals, may require that only byte operations be performed. For this purpose, the routines bcopyBytes( ) and bfillBytes( ) provide the same functions as bcopy( ) and bfill( ), but use only byte-at-a-time operations. These routines do not check for null termination.
string.h
bLib, ansiString
bcmp( ) - compare one buffer to another
int bcmp ( char * buf1, /* pointer to first buffer */ char * buf2, /* pointer to second buffer */ int nbytes /* number of bytes to compare */ )
This routine compares the first nbytes characters of buf1 to buf2.
0 if the first nbytes of buf1 and buf2 are identical,
less than 0 if buf1 is less than buf2, or
greater than 0 if buf1 is greater than buf2.
binvert( ) - invert the order of bytes in a buffer
void binvert ( char * buf, /* pointer to buffer to invert */ int nbytes /* number of bytes in buffer */ )
This routine inverts an entire buffer, byte by byte. For example, the buffer {1, 2, 3, 4, 5} would become {5, 4, 3, 2, 1}.
N/A
bswap( ) - swap buffers
void bswap ( char * buf1, /* pointer to first buffer */ char * buf2, /* pointer to second buffer */ int nbytes /* number of bytes to swap */ )
This routine exchanges the first nbytes of the two specified buffers.
N/A
swab( ) - swap bytes
void swab ( char * source, /* pointer to source buffer */ char * destination, /* pointer to destination buffer */ int nbytes /* number of bytes to exchange */ ) #if (CPU_FAMILY == ARM)
This routine gets the specified number of bytes from source, exchanges the adjacent even and odd bytes, and puts them in destination. The buffers source and destination should not overlap.
On some CPUs, swab( ) will cause an exception if the buffers are unaligned. In such cases, use uswab( ) for unaligned swaps. On ARM family CPUs, swab( ) may reorder the bytes incorrectly without causing an exception if the buffers are unaligned. Again, use uswab( ) for unaligned swaps.
It is an error for nbytes to be odd.
N/A
uswab( ) - swap bytes with buffers that are not necessarily aligned
void uswab ( char * source, /* pointer to source buffer */ char * destination, /* pointer to destination buffer */ int nbytes /* number of bytes to exchange */ )
This routine gets the specified number of bytes from source, exchanges the adjacent even and odd bytes, and puts them in destination.
Due to speed considerations, this routine should only be used when absolutely necessary. Use swab( ) for aligned swaps.
It is an error for nbytes to be odd.
N/A
bzero( ) - zero out a buffer
void bzero ( char * buffer, /* buffer to be zeroed */ int nbytes /* number of bytes in buffer */ )
This routine fills the first nbytes characters of the specified buffer with 0.
N/A
bcopy( ) - copy one buffer to another
void bcopy ( const char * source, /* pointer to source buffer */ char * destination, /* pointer to destination buffer */ int nbytes /* number of bytes to copy */ )
This routine copies the first nbytes characters from source to destination. Overlapping buffers are handled correctly. Copying is done in the most efficient way possible, which may include long-word, or even multiple-long-word moves on some architectures. In general, the copy will be significantly faster if both buffers are long-word aligned. (For copying that is restricted to byte, word, or long-word moves, see the manual entries for bcopyBytes( ), bcopyWords( ), and bcopyLongs( ).)
N/A
bLib, bcopyBytes( ), bcopyWords( ), bcopyLongs( )
bcopyBytes( ) - copy one buffer to another one byte at a time
void bcopyBytes ( char * source, /* pointer to source buffer */ char * destination, /* pointer to destination buffer */ int nbytes /* number of bytes to copy */ )
This routine copies the first nbytes characters from source to destination one byte at a time. This may be desirable if a buffer can only be accessed with byte instructions, as in certain byte-wide memory-mapped peripherals.
N/A
bcopyWords( ) - copy one buffer to another one word at a time
void bcopyWords ( char * source, /* pointer to source buffer */ char * destination, /* pointer to destination buffer */ int nwords /* number of words to copy */ )
This routine copies the first nwords words from source to destination one word at a time. This may be desirable if a buffer can only be accessed with word instructions, as in certain word-wide memory-mapped peripherals. The source and destination must be word-aligned.
N/A
bcopyLongs( ) - copy one buffer to another one long word at a time
void bcopyLongs ( char * source, /* pointer to source buffer */ char * destination, /* pointer to destination buffer */ int nlongs /* number of longs to copy */ )
This routine copies the first nlongs characters from source to destination one long word at a time. This may be desirable if a buffer can only be accessed with long instructions, as in certain long-word-wide memory-mapped peripherals. The source and destination must be long-aligned.
N/A
bfill( ) - fill a buffer with a specified character
void bfill ( char * buf, /* pointer to buffer */ int nbytes, /* number of bytes to fill */ int ch /* char with which to fill buffer */ )
This routine fills the first nbytes characters of a buffer with the character ch. Filling is done in the most efficient way possible, which may be long-word, or even multiple-long-word stores, on some architectures. In general, the fill will be significantly faster if the buffer is long-word aligned. (For filling that is restricted to byte stores, see the manual entry for bfillBytes( ).)
N/A
bLib, bfillBytes( )
bfillBytes( ) - fill buffer with a specified character one byte at a time
void bfillBytes ( char * buf, /* pointer to buffer */ int nbytes, /* number of bytes to fill */ int ch /* char with which to fill buffer */ )
This routine fills the first nbytes characters of the specified buffer with the character ch one byte at a time. This may be desirable if a buffer can only be accessed with byte instructions, as in certain byte-wide memory-mapped peripherals.
N/A
index( ) - find the first occurrence of a character in a string
char *index ( const char * s, /* string in which to find character */ int c /* character to find in string */ )
This routine finds the first occurrence of character c in string s.
A pointer to the located character, or NULL if c is not found.
rindex( ) - find the last occurrence of a character in a string
char *rindex ( const char * s, /* string in which to find character */ int c /* character to find in string */ )
This routine finds the last occurrence of character c in string s.
A pointer to c, or NULL if c is not found.