1 /* 2 * Copyright (C) 2005-2008 Team XBMC 3 * http://www.xbmc.org 4 * Copyright (C) 2008-2009 Andrej Stepanchuk 5 * Copyright (C) 2009-2010 Howard Chu 6 * 7 * This file is part of librtmp. 8 * 9 * librtmp is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation; either version 2.1, 12 * or (at your option) any later version. 13 * 14 * librtmp is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public License 20 * along with librtmp see the file COPYING. If not, write to 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 * Boston, MA 02110-1301, USA. 23 * http://www.gnu.org/copyleft/lgpl.html 24 */ 25 26 #ifndef __BYTES_H__ 27 #define __BYTES_H__ 28 29 #include <stdint.h> 30 31 #ifdef _WIN32 32 /* Windows is little endian only */ 33 #define __LITTLE_ENDIAN 1234 34 #define __BIG_ENDIAN 4321 35 #define __BYTE_ORDER __LITTLE_ENDIAN 36 #define __FLOAT_WORD_ORDER __BYTE_ORDER 37 38 typedef unsigned char uint8_t; 39 40 #else /* !_WIN32 */ 41 42 #include <sys/param.h> 43 44 #if defined(BYTE_ORDER) && !defined(__BYTE_ORDER) 45 #define __BYTE_ORDER BYTE_ORDER 46 #endif 47 48 #if defined(BIG_ENDIAN) && !defined(__BIG_ENDIAN) 49 #define __BIG_ENDIAN BIG_ENDIAN 50 #endif 51 52 #if defined(LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN) 53 #define __LITTLE_ENDIAN LITTLE_ENDIAN 54 #endif 55 56 #endif /* !_WIN32 */ 57 58 /* define default endianness */ 59 #ifndef __LITTLE_ENDIAN 60 #define __LITTLE_ENDIAN 1234 61 #endif 62 63 #ifndef __BIG_ENDIAN 64 #define __BIG_ENDIAN 4321 65 #endif 66 67 #ifndef __BYTE_ORDER 68 #warning "Byte order not defined on your system, assuming little endian!" 69 #define __BYTE_ORDER __LITTLE_ENDIAN 70 #endif 71 72 /* ok, we assume to have the same float word order and byte order if float word order is not defined */ 73 #ifndef __FLOAT_WORD_ORDER 74 #warning "Float word order not defined, assuming the same as byte order!" 75 #define __FLOAT_WORD_ORDER __BYTE_ORDER 76 #endif 77 78 #if !defined(__BYTE_ORDER) || !defined(__FLOAT_WORD_ORDER) 79 #error "Undefined byte or float word order!" 80 #endif 81 82 #if __FLOAT_WORD_ORDER != __BIG_ENDIAN && __FLOAT_WORD_ORDER != __LITTLE_ENDIAN 83 #error "Unknown/unsupported float word order!" 84 #endif 85 86 #if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN 87 #error "Unknown/unsupported byte order!" 88 #endif 89 90 #endif 91 92