1/* libasf - An Advanced Systems Format media file parser 2 * Copyright (C) 2006-2010 Juho Vähä-Herttua 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19#ifndef COMPAT_H 20#define COMPAT_H 21 22#ifdef __GNUC__ 23# define INLINE __inline__ 24#else 25# define INLINE 26#endif 27 28static INLINE uint16_t 29GetWLE(const void *pointer) 30{ 31 const uint8_t *data = pointer; 32 return ((uint16_t)data[1] << 8) | 33 ((uint16_t)data[0]); 34} 35 36static INLINE uint32_t 37GetDWLE(const void *pointer) 38{ 39 const uint8_t *data = pointer; 40 return ((uint32_t)data[3] << 24) | 41 ((uint32_t)data[2] << 16) | 42 ((uint32_t)data[1] << 8) | 43 ((uint32_t)data[0]); 44} 45 46static INLINE uint64_t 47GetQWLE(const void *pointer) 48{ 49 const uint8_t *data = pointer; 50 return ((uint64_t)data[7] << 56) | 51 ((uint64_t)data[6] << 48) | 52 ((uint64_t)data[5] << 40) | 53 ((uint64_t)data[4] << 32) | 54 ((uint64_t)data[3] << 24) | 55 ((uint64_t)data[2] << 16) | 56 ((uint64_t)data[1] << 8) | 57 ((uint64_t)data[0]); 58} 59 60#endif 61