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 #define AV_RN64 AV_RN64
00065 static av_always_inline uint64_t AV_RN64(const void *p)
00066 {
00067 const struct __attribute__((packed)) { uint32_t v; } *q = p;
00068 uint64_t v;
00069 __asm__ ("ldr %Q0, %1 \n\t"
00070 "ldr %R0, %2 \n\t"
00071 : "=&r"(v)
00072 : "m"(q[0]), "m"(q[1]));
00073 return v;
00074 }
00075
00076 #define AV_WN64 AV_WN64
00077 static av_always_inline void AV_WN64(void *p, uint64_t v)
00078 {
00079 __asm__ ("str %Q2, %0 \n\t"
00080 "str %R2, %1 \n\t"
00081 : "=m"(*(uint32_t*)p), "=m"(*((uint32_t*)p+1))
00082 : "r"(v));
00083 }
00084
00085 #endif
00086
00087 #endif