/*************************************************************************
  (c) Copyright.  Digital Equipment Corporation, 1995.  All Rights
  Reserved.

  Permission is hereby granted to use, copy, modify, or enhance this 
  software freely, as long as the foregoing copyright of Digital Equipment
  Corporation and this notice are retained on the software.  This 
  software may not be distributed or sublicensed for a fee.  Digital      
  makes this software available "AS IS" and without warranties of any
  kind.  
 *************************************************************************/
/*
 * Marko Kiiskila carnil@cs.tut.fi 
 * 
 * Tampere University of Technology - Telecommunications Laboratory
 *
 * Permission to use, copy, modify and distribute this
 * software and its documentation is hereby granted,
 * provided that both the copyright notice and this
 * permission notice appear in all copies of the software,
 * derivative works or modified versions, and any portions
 * thereof, that both notices appear in supporting
 * documentation, and that the use of this software is
 * acknowledged in any publications resulting from using
 * the software.
 * 
 * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
 * SOFTWARE.
 * 
 */

/* g_endian.h
 */

#define hton16(x) ((UINT16) (((((UINT16) (x)) & 0xff00) >> 8) | \
                             ((((UINT16) (x)) & 0x00ff) << 8)))

#define ntoh16(x) ((UINT16) (((((UINT16) (x)) & 0xff00) >> 8) | \
                             ((((UINT16) (x)) & 0x00ff) << 8)))

#define hton32(x) ((UINT32) (((((UINT32) (x)) & 0xff000000) >> 24) | \
                             ((((UINT32) (x)) & 0x00ff0000) >> 8)  | \
                             ((((UINT32) (x)) & 0x0000ff00) << 8)  | \
                             ((((UINT32) (x)) & 0x000000ff) << 24)))

#define ntoh32(x) ((UINT32) (((((UINT32) (x)) & 0xff000000) >> 24) | \
                             ((((UINT32) (x)) & 0x00ff0000) >> 8)  | \
                             ((((UINT32) (x)) & 0x0000ff00) << 8)  | \
                             ((((UINT32) (x)) & 0x000000ff) << 24)))
