00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef AVUTIL_ARM_INTREADWRITE_H
00020 #define AVUTIL_ARM_INTREADWRITE_H
00021
00022 #include <stdint.h>
00023 #include "config.h"
00024 #include "libavutil/attributes.h"
00025
00026 #if HAVE_FAST_UNALIGNED && HAVE_INLINE_ASM && !AV_GCC_VERSION_AT_LEAST(4,7)
00027
00028 #define AV_RN16 AV_RN16
00029 static av_always_inline unsigned AV_RN16(const void *p)
00030 {
00031 const uint8_t *q = p;
00032 unsigned v;
00033 #if !AV_GCC_VERSION_AT_LEAST(4,6)
00034 __asm__ ("ldrh %0, %1" : "=r"(v) : "m"(*(const uint16_t *)q));
00035 #elif defined __thumb__
00036 __asm__ ("ldrh %0, %1" : "=r"(v) : "m"(q[0]), "m"(q[1]));
00037 #else
00038 __asm__ ("ldrh %0, %1" : "=r"(v) : "Uq"(q[0]), "m"(q[1]));
00039 #endif
00040 return v;
00041 }
00042
00043 #define AV_WN16 AV_WN16
00044 static av_always_inline void AV_WN16(void *p, uint16_t v)
00045 {
00046 __asm__ ("strh %1, %0" : "=m"(*(uint16_t *)p) : "r"(v));
00047 }
00048
00049 #define AV_RN32 AV_RN32
00050 static av_always_inline uint32_t AV_RN32(const void *p)
00051 {
00052 const struct __attribute__((packed)) { uint32_t v; } *q = p;
00053 uint32_t v;
00054 __asm__ ("ldr %0, %1" : "=r"(v) : "m"(*q));
00055 return v;
00056 }
00057
00058 #define AV_WN32 AV_WN32
00059 static av_always_inline void AV_WN32(void *p, uint32_t v)
00060 {
00061 __asm__ ("str %1, %0" : "=m"(*(uint32_t *)p) : "r"(v));
00062 }
00063
00064 #if HAVE_ASM_MOD_Q
00065
00066 #define AV_RN64 AV_RN64
00067 static av_always_inline uint64_t AV_RN64(const void *p)
00068 {
00069 const struct __attribute__((packed)) { uint32_t v; } *q = p;
00070 uint64_t v;
00071 __asm__ ("ldr %Q0, %1 \n\t"
00072 "ldr %R0, %2 \n\t"
00073 : "=&r"(v)
00074 : "m"(q[0]), "m"(q[1]));
00075 return v;
00076 }
00077
00078 #define AV_WN64 AV_WN64
00079 static av_always_inline void AV_WN64(void *p, uint64_t v)
00080 {
00081 __asm__ ("str %Q2, %0 \n\t"
00082 "str %R2, %1 \n\t"
00083 : "=m"(*(uint32_t*)p), "=m"(*((uint32_t*)p+1))
00084 : "r"(v));
00085 }
00086
00087 #endif
00088
00089 #endif
00090
00091 #endif