*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> swap_words (9r)              
Title
Content
Arch
Section
 

swap_lw_bytes(9r)

Contents


NAME    [Toc]    [Back]

       swap_lw_bytes, swap_word_bytes, swap_words - General: Perform
 byte-swapping operations

SYNOPSIS    [Toc]    [Back]

       unsigned int swap_lw_bytes(
               unsigned    int    buffer    );    unsigned    int
       swap_word_bytes(
               unsigned int buffer ); unsigned int swap_words(
               unsigned int buffer );

ARGUMENTS    [Toc]    [Back]

       Specifies a 32-bit (4 bytes) quantity.

DESCRIPTION    [Toc]    [Back]

       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    [Toc]    [Back]

       Upon  successful  completion,  these interfaces return the
       swapped bytes.



                                                swap_lw_bytes(9r)
[ Back ]
 Similar pages
Name OS Title
wmemcmp Tru64 Perform
wmemcpy Tru64 Perform
wmemset Tru64 Perform
wmemmove Tru64 Perform
wmemchr Tru64 Perform
SSL_do_handshake Tru64 Perform a TLS/SSL handshake
SSL_do_handshake OpenBSD perform a TLS/SSL handshake
SSL_do_handshake NetBSD perform a TLS/SSL handshake
pci_configure_bus NetBSD perform PCI bus configuration
pci_conf_interrupt NetBSD perform PCI bus configuration
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service