\hypertarget{BSWP_8ih}{
\section{BSWP.ih File Reference}
\label{BSWP_8ih}\index{BSWP.ih@{BSWP.ih}}
}
Byteswapping, inline versions.  


{\tt \#include $<$PBI/BSWP.ih$>$}\par


\subsection{Detailed Description}
Byteswapping, inline versions. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}

    CVS $Id: BSWP.ih,v 1.9 2011/03/24 23:05:41 apw Exp $
\end{verbatim}
\normalsize


{\bf SYNOPSIS} \par
 This provides a generic interface to the inline byte swapping. These routines are inspired by the PPC instructions that perform byte swapping operations.

The PPC provides three sets of instuctions, one that operates on 16 bit values one that operates on 32 bit values and one that operates on 64 bit values. All three sets have five instructions. The first two byte swaps the data as in loads it from memory, while the second one byte swaps the data as it stores it in memory. These instructions come in two flavors, a straight addressing mode and an indexed addressing mode. The final two do the byteswapping as immediate value. This final one is provided only in this sense of completing the complement of operations. Unfortunately there is no instruction to byte swap a value already in a register. All 6 of these instructions are made available as inline functions.

In addition to splitting the routines into 16, 32 and 64 bit versions, the routines can be split along another axis, single and array versions. The array versions are really just convenience routines in that all they do is wrap the single word routines in a loop. Since this is a common thing to do, they are also provided, although only in a callable form (see \hyperlink{BSWP_8h}{BSWP.h}).

The single word swapping routines have only an inline implementation. This is because these routines are so simple and efficiency is a major design driver, there is no reason to use a callable version. 