00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVUTIL_MIPS_INTREADWRITE_H
00022 #define AVUTIL_MIPS_INTREADWRITE_H
00023
00024 #include <stdint.h>
00025 #include "config.h"
00026
00027 #if HAVE_INLINE_ASM
00028
00029 #define AV_RN32 AV_RN32
00030 static av_always_inline uint32_t AV_RN32(const void *p)
00031 {
00032 uint32_t v;
00033 __asm__ ("lwl %0, %1 \n\t"
00034 "lwr %0, %2 \n\t"
00035 : "=&r"(v)
00036 : "m"(*(const uint32_t *)((const uint8_t *)p+3*!HAVE_BIGENDIAN)),
00037 "m"(*(const uint32_t *)((const uint8_t *)p+3*HAVE_BIGENDIAN)));
00038 return v;
00039 }
00040
00041 #define AV_WN32 AV_WN32
00042 static av_always_inline void AV_WN32(void *p, uint32_t v)
00043 {
00044 __asm__ ("swl %2, %0 \n\t"
00045 "swr %2, %1 \n\t"
00046 : "=m"(*(uint32_t *)((uint8_t *)p+3*!HAVE_BIGENDIAN)),
00047 "=m"(*(uint32_t *)((uint8_t *)p+3*HAVE_BIGENDIAN))
00048 : "r"(v));
00049 }
00050
00051 #if ARCH_MIPS64
00052
00053 #define AV_RN64 AV_RN64
00054 static av_always_inline uint64_t AV_RN64(const void *p)
00055 {
00056 uint64_t v;
00057 __asm__ ("ldl %0, %1 \n\t"
00058 "ldr %0, %2 \n\t"
00059 : "=&r"(v)
00060 : "m"(*(const uint64_t *)((const uint8_t *)p+7*!HAVE_BIGENDIAN)),
00061 "m"(*(const uint64_t *)((const uint8_t *)p+7*HAVE_BIGENDIAN)));
00062 return v;
00063 }
00064
00065 #define AV_WN64 AV_WN64
00066 static av_always_inline void AV_WN64(void *p, uint64_t v)
00067 {
00068 __asm__ ("sdl %2, %0 \n\t"
00069 "sdr %2, %1 \n\t"
00070 : "=m"(*(uint64_t *)((uint8_t *)p+7*!HAVE_BIGENDIAN)),
00071 "=m"(*(uint64_t *)((uint8_t *)p+7*HAVE_BIGENDIAN))
00072 : "r"(v));
00073 }
00074
00075 #else
00076
00077 #define AV_RN64 AV_RN64
00078 static av_always_inline uint64_t AV_RN64(const void *p)
00079 {
00080 union { uint64_t v; uint32_t hl[2]; } v;
00081 v.hl[0] = AV_RN32(p);
00082 v.hl[1] = AV_RN32((const uint8_t *)p + 4);
00083 return v.v;
00084 }
00085
00086 #define AV_WN64 AV_WN64
00087 static av_always_inline void AV_WN64(void *p, uint64_t v)
00088 {
00089 union { uint64_t v; uint32_t hl[2]; } vv = { v };
00090 AV_WN32(p, vv.hl[0]);
00091 AV_WN32((uint8_t *)p + 4, vv.hl[1]);
00092 }
00093
00094 #endif
00095
00096 #endif
00097
00098 #endif