1/*---------------------------------------------------------------------------* 2 * pendian.h * 3 * * 4 * Copyright 2007, 2008 Nuance Communciations, Inc. * 5 * * 6 * Licensed under the Apache License, Version 2.0 (the 'License'); * 7 * you may not use this file except in compliance with the License. * 8 * * 9 * You may obtain a copy of the License at * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, software * 13 * distributed under the License is distributed on an 'AS IS' BASIS, * 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 15 * See the License for the specific language governing permissions and * 16 * limitations under the License. * 17 * * 18 *---------------------------------------------------------------------------*/ 19 20#ifndef PENDIAN_H 21#define PENDIAN_H 22 23 24 25#include "PortPrefix.h" 26#include "ptypes.h" 27 28#ifdef __sgi 29/* */#include <sys/endian.h> 30 31#elif defined(__sparc) 32/* */#include <sys/isa_defs.h> 33/* */#ifdef __LITTLE_ENDIAN 34/* *//* */#define __LITTLE_ENDIAN 1234 35/* *//* */#define __BYTE_ORDER __LITTLE_ENDIAN 36/* */#elif defined(_BIG_ENDIAN) 37/* *//* */#define __BIG_ENDIAN 4321 38/* *//* */#define __BYTE_ORDER __BIG_ENDIAN 39/* */#endif 40 41#elif defined(ANDROID) 42 43/* */#ifdef HAVE_ENDIAN 44/* */#include <endian.h> 45 46/* */#elif defined(HAVE_LITTLE_ENDIAN) 47/* *//* */#define __LITTLE_ENDIAN 1234 48/* *//* */#define __BYTE_ORDER __LITTLE_ENDIAN 49 50/* */#elif defined(HAVE_BIG_ENDIAN) 51/* *//* */#define __BIG_ENDIAN 4321 52/* *//* */#define __BYTE_ORDER __BIG_ENDIAN 53 54/* */#endif 55 56#elif defined (__linux) 57/* */#include <endian.h> 58 59#elif defined(__FreeBSD__) || defined(_decunix_) 60/* */#include <machine/endian.h> 61 62#elif defined(__i386) || defined(_M_IX86) 63/* */#undef __LITTLE_ENDIAN 64/* */#define __LITTLE_ENDIAN 1234 65/* */#define __BYTE_ORDER __LITTLE_ENDIAN 66 67#elif defined(_sh4_)||defined(SH4) 68/* */#if defined (__vxworks) 69/* *//* */#if _BYTE_ORDER == _LITTLE_ENDIAN /* VxWorks defines _BYTE_ORDER and _LITTLE_ENDIAN */ 70/* *//* *//* */#undef __LITTLE_ENDIAN 71/* *//* *//* */#define __LITTLE_ENDIAN 1234 72/* *//* *//* */#define __BYTE_ORDER __LITTLE_ENDIAN 73/* *//* */#elif _BYTE_ORDER == _BIG_ENDIAN /* VxWorks defines _BYTE_ORDER and _BIG_ENDIAN */ 74/* *//* *//* */#undef __BIG_ENDIAN 75/* *//* *//* */#define __BIG_ENDIAN 4321 76/* *//* *//* */#define __BYTE_ORDER __BIG_ENDIAN 77/* *//* */#else 78/* *//* *//* */#error 79/* *//* */#endif 80/* */#else 81/* *//* */#error "Could not determine endianness of the machine Unknown OS for SH4 Chip." 82/* */#endif 83 84#else 85/* */#error "Could not determine endianness of the machine Chip Not Known." 86#endif 87 88 89/** 90 * @addtogroup ESR_PortableModule ESR_Portable API functions 91 * 92 * @{ 93 */ 94 95/** 96 * Swaps bytes of each item in buffer. 97 * 98 * @param buffer Buffer containing items to swap. 99 * @param count Number of items to swap. 100 * @param itemSize Size of each items. 101 */ 102PORTABLE_API void swap_byte_order(void *buffer, 103 size_t count, 104 size_t itemSize); 105 106/** 107 * @} 108 */ 109 110#endif 111