/*-------------------------------------------------------------------------*/ /** @file byteswap.c @author N. Devillard @date Sep 1999 @version $Revision: 1.2 $ @brief Low-level byte-swapping routines This module offers portable and efficient byte-swapping routines. No reliance on any specific OS feature is made, these routines should work everywhere the same. */ /*--------------------------------------------------------------------------*/ /* $Id: byteswap.c,v 1.2 2002/01/10 08:53:08 ndevilla Exp $ $Author: ndevilla $ $Date: 2002/01/10 08:53:08 $ $Revision: 1.2 $ */ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include "byteswap.h" /*--------------------------------------------------------------------------- Function codes ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @fn swap_bytes @brief Swaps bytes in a variable of given size @param p pointer to void (generic pointer) @param s size of the element to swap, pointed to by p @return void This byte-swapper is portable and works for any even variable size. It is not truly the most efficient ever, but does its job fine everywhere this file compiles. */ /*--------------------------------------------------------------------------*/ void #ifdef __GNUC__ __attribute__((__no_instrument_function__)) #endif swap_bytes(void * p, int s) { unsigned char tmp, *a, *b ; a = (unsigned char*)p ; b = a + s ; while (a