Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

swap_lw_bytes(9r) [osf1 man page]

swap_lw_bytes(9r)														 swap_lw_bytes(9r)

NAME
swap_lw_bytes, swap_word_bytes, swap_words - General: Perform byte-swapping operations SYNOPSIS
unsigned int swap_lw_bytes( unsigned int buffer ); unsigned int swap_word_bytes( unsigned int buffer ); unsigned int swap_words( unsigned int buffer ); ARGUMENTS
Specifies a 32-bit (4 bytes) quantity. DESCRIPTION
The swap_lw_bytes interface performs a longword byte swap. The swap_word_bytes interface performs a short word byte swap. The swap_words interface performs a word byte swap. Many computer vendors support devices that use a big endian model of byte ordering. Because Digital devices support the little endian model of byte ordering, there is a need for these byte-swapping interfaces. In addition, some buses (for example, the VMEbus) can have specific or implied byte ordering that may require the use of these interfaces. Given that a longword is equal to 4 bytes; a short word is equal to 2 bytes; and 1 byte is equal to 8 bits, these interfaces swap bytes as follows: The swap_lw_bytes interface takes the 32-bit quantity specified by the buffer argument and swaps all 4 bytes. The swap_word_bytes interface takes the 32-bit quantity specified by the buffer argument and swaps the individual bytes that make up each word of the 32-bit quantity. The swap_words interface takes the 32-bit quantity specified by the buffer argument and swaps the two 16-bit words. The following illustration compares the byte swapping performed by these interfaces. 31 0 +---+---+---+---+ Starting value: | a | b | c | d | +---+---+---+---+ Long word byte swap (swap_lw_bytes) 31 0 +---+---+---+---+ Ending value: | d | c | b | a | +-------+---+---+ Short word byte swap (swap_word_bytes) 31 0 +---+---+---+---+ Ending value: | b | a | d | c | +---+---+---+---+ 31 0 +---+---+---+---+ Starting value: | ab | cd | +---+---+---+---+ Word byte swap (swap_words) 31 0 +---+---+---+---+ Ending value: | cd | ab | +---+---+---+---+ RETURN VALUES
Upon successful completion, these interfaces return the swapped bytes. swap_lw_bytes(9r)

Check Out this Related Man Page

TIFFswab(3tiff) 														   TIFFswab(3tiff)

NAME
TIFFswab, TIFFGetBitRevTable, TIFFReverseBits, TIFFSwabShort, TIFFSwabLong, TIFFSwabArrayOfShort, TIFFSwabArrayOfLong - byte- and bit-swap- ping routines SYNOPSIS
#include <tiffio.h> const unsigned char* TIFFGetBitRevTable(int reversed); void TIFFReverseBits(u_char* data, unsigned long nbytes) void TIFFSwabShort(uint16* data) void TIFFSwabLong(uint32* data) void TIFFSwabArrayOfShort(uint16* data, unsigned long nshorts) void TIFFSwabArrayOfLong(uint32* data, unsigned long nlongs) The following routines are used by the library to swap 16- and 32-bit data and to reverse the order of bits in bytes. TIFFSwabShort and TIFFSwabLong swap the bytes in a single 16-bit and 32-bit item, respectively. TIFFSwabArrayOfShort and TIFFSwabArrayOfLong swap the bytes in an array of 16-bit and 32-bit items, respectively. TIFFReverseBits replaces each byte in data with the equivalent bit-reversed value. This operation is done with a lookup table, TIFFBi- tRevTable, which is declared public. A second table, TIFFNoBitRevTable, is also declared public, and is a lookup table that can be used as an identity function. That is, TIFFNoBitRevTable[n] == n. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWTiff | +-----------------------------+-----------------------------+ |Interface stability |Uncommitted | +-----------------------------+-----------------------------+ libtiff(3) This man page was originally written by Sam Leffler. Updated by Breda McColgan, Sun Microsystems Inc., 2004. 05 Apr 2004 TIFFswab(3tiff)
Man Page