/*-------------------------------------------------------------------------*/ /** @file byteswap.h @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.h,v 1.2 2002/01/10 08:53:08 ndevilla Exp $ $Author: ndevilla $ $Date: 2002/01/10 08:53:08 $ $Revision: 1.2 $ */ #ifndef _BYTESWAP_H_ #define _BYTESWAP_H_ #ifdef __cplusplus extern "C" { #endif #include #include "config.h" /*--------------------------------------------------------------------------- Function ANSI C prototypes ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @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 swap_bytes(void * p, int s); /*-------------------------------------------------------------------------*/ /** @brief Find out if the local machine is big or little endian @return int 1 if local machine needs byteswapping (INTEL), 0 else. This function determines at run-time the endian-ness of the local machine. An INTEL-like processor needs byte-swapping, a MOTOROLA-like one does not. */ /*--------------------------------------------------------------------------*/ int need_byteswapping(void); #ifdef __cplusplus } #endif #endif /* vim: set ts=4 et sw=4 tw=75 */