Libav 0.7.1
|
00001 /* 00002 * This file is part of Libav. 00003 * 00004 * Libav is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * Libav is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with Libav; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00017 */ 00018 00019 #ifndef AVUTIL_ARM_INTREADWRITE_H 00020 #define AVUTIL_ARM_INTREADWRITE_H 00021 00022 #include <stdint.h> 00023 #include "config.h" 00024 00025 #if HAVE_FAST_UNALIGNED && HAVE_INLINE_ASM 00026 00027 #define AV_RN16 AV_RN16 00028 static av_always_inline unsigned AV_RN16(const void *p) 00029 { 00030 unsigned v; 00031 __asm__ ("ldrh %0, %1" : "=r"(v) : "m"(*(const uint16_t *)p)); 00032 return v; 00033 } 00034 00035 #define AV_WN16 AV_WN16 00036 static av_always_inline void AV_WN16(void *p, uint16_t v) 00037 { 00038 __asm__ ("strh %1, %0" : "=m"(*(uint16_t *)p) : "r"(v)); 00039 } 00040 00041 #define AV_RN32 AV_RN32 00042 static av_always_inline uint32_t AV_RN32(const void *p) 00043 { 00044 uint32_t v; 00045 __asm__ ("ldr %0, %1" : "=r"(v) : "m"(*(const uint32_t *)p)); 00046 return v; 00047 } 00048 00049 #define AV_WN32 AV_WN32 00050 static av_always_inline void AV_WN32(void *p, uint32_t v) 00051 { 00052 __asm__ ("str %1, %0" : "=m"(*(uint32_t *)p) : "r"(v)); 00053 } 00054 00055 #define AV_RN64 AV_RN64 00056 static av_always_inline uint64_t AV_RN64(const void *p) 00057 { 00058 uint64_t v; 00059 __asm__ ("ldr %Q0, %1 \n\t" 00060 "ldr %R0, %2 \n\t" 00061 : "=&r"(v) 00062 : "m"(*(const uint32_t*)p), "m"(*((const uint32_t*)p+1))); 00063 return v; 00064 } 00065 00066 #define AV_WN64 AV_WN64 00067 static av_always_inline void AV_WN64(void *p, uint64_t v) 00068 { 00069 __asm__ ("str %Q2, %0 \n\t" 00070 "str %R2, %1 \n\t" 00071 : "=m"(*(uint32_t*)p), "=m"(*((uint32_t*)p+1)) 00072 : "r"(v)); 00073 } 00074 00075 #endif /* HAVE_INLINE_ASM */ 00076 00077 #endif /* AVUTIL_ARM_INTREADWRITE_H */