//
// $Id: ByteOrder.h,v 1.4 2005/07/12 19:15:36 will_mason Exp $
//
// vi: set ft=objc:

/*
 * ObjectiveLib - a library of containers and algorithms for Objective-C
 *
 * Copyright (c) 2004
 * Will Mason
 *
 * Portions:
 *
 * Copyright (c) 1994
 * Hewlett-Packard Company
 *
 * Copyright (c) 1996,1997
 * Silicon Graphics Computer Systems, Inc.
 *
 * Copyright (c) 1997
 * Moscow Center for SPARC Technology
 *
 * Copyright (c) 1999 
 * Boris Fomitchev
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * You may contact the author at will_mason@users.sourceforge.net.
 */

#if !defined(BYTEORDER_OL_GUARD)
#define BYTEORDER_OL_GUARD

#if defined(GNUSTEP)

#import <Foundation/NSByteOrder.h>

#define H16_TO_N(val) GSSwapHostI16ToBig(val)
#define H32_TO_N(val) GSSwapHostI32ToBig(val)
#define H64_TO_N(val) GSSwapHostI64ToBig(val)
#define N16_TO_H(val) GSSwapBigI16ToHost(val)
#define N32_TO_H(val) GSSwapBigI32ToHost(val)
#define N64_TO_H(val) GSSwapBigI64ToHost(val)
#define H16_TO_L(val) GSSwapHostI16ToLittle(val)
#define H32_TO_L(val) GSSwapHostI32ToLittle(val)
#define L16_TO_H(val) GSSwapLittleI16ToHost(val)
#define L32_TO_H(val) GSSwapLittleI32ToHost(val)

#else

#import <architecture/byte_order.h>

#define H16_TO_N(val) OSSwapHostToBigInt16(val)
#define H32_TO_N(val) OSSwapHostToBigInt32(val)
#define H64_TO_N(val) OSSwapHostToBigInt64(val)
#define N16_TO_H(val) OSSwapBigToHostInt16(val)
#define N32_TO_H(val) OSSwapBigToHostInt32(val)
#define N64_TO_H(val) OSSwapBigToHostInt64(val)
#define H16_TO_L(val) OSSwapHostToLittleInt16(val)
#define H32_TO_L(val) OSSwapHostToLittleInt32(val)
#define L16_TO_H(val) OSSwapLittleToHostInt16(val)
#define L32_TO_H(val) OSSwapLittleToHostInt32(val)

#endif

#endif
