Mercurial > libavutil.hg
comparison avr32/intreadwrite.h @ 812:f849545df4e5 libavutil
Mark all intreadwrite functions av_always_inline
author | mru |
---|---|
date | Mon, 18 Jan 2010 01:35:19 +0000 |
parents | c2556eaf12ca |
children | f8db9a2bae05 |
comparison
equal
deleted
inserted
replaced
811:c08dd82b122e | 812:f849545df4e5 |
---|---|
38 * AP processors, so we override the generic code. The 64-bit | 38 * AP processors, so we override the generic code. The 64-bit |
39 * versions are improved by using our optimised 32-bit functions. | 39 * versions are improved by using our optimised 32-bit functions. |
40 */ | 40 */ |
41 | 41 |
42 #define AV_RL16 AV_RL16 | 42 #define AV_RL16 AV_RL16 |
43 static inline uint16_t AV_RL16(const void *p) | 43 static av_always_inline uint16_t AV_RL16(const void *p) |
44 { | 44 { |
45 uint16_t v; | 45 uint16_t v; |
46 __asm__ ("ld.ub %0, %1 \n\t" | 46 __asm__ ("ld.ub %0, %1 \n\t" |
47 "ldins.b %0:l, %2 \n\t" | 47 "ldins.b %0:l, %2 \n\t" |
48 : "=&r"(v) | 48 : "=&r"(v) |
49 : "m"(*(const uint8_t*)p), "RKs12"(*((const uint8_t*)p+1))); | 49 : "m"(*(const uint8_t*)p), "RKs12"(*((const uint8_t*)p+1))); |
50 return v; | 50 return v; |
51 } | 51 } |
52 | 52 |
53 #define AV_RB16 AV_RB16 | 53 #define AV_RB16 AV_RB16 |
54 static inline uint16_t AV_RB16(const void *p) | 54 static av_always_inline uint16_t AV_RB16(const void *p) |
55 { | 55 { |
56 uint16_t v; | 56 uint16_t v; |
57 __asm__ ("ld.ub %0, %2 \n\t" | 57 __asm__ ("ld.ub %0, %2 \n\t" |
58 "ldins.b %0:l, %1 \n\t" | 58 "ldins.b %0:l, %1 \n\t" |
59 : "=&r"(v) | 59 : "=&r"(v) |
60 : "RKs12"(*(const uint8_t*)p), "m"(*((const uint8_t*)p+1))); | 60 : "RKs12"(*(const uint8_t*)p), "m"(*((const uint8_t*)p+1))); |
61 return v; | 61 return v; |
62 } | 62 } |
63 | 63 |
64 #define AV_RB24 AV_RB24 | 64 #define AV_RB24 AV_RB24 |
65 static inline uint32_t AV_RB24(const void *p) | 65 static av_always_inline uint32_t AV_RB24(const void *p) |
66 { | 66 { |
67 uint32_t v; | 67 uint32_t v; |
68 __asm__ ("ld.ub %0, %3 \n\t" | 68 __asm__ ("ld.ub %0, %3 \n\t" |
69 "ldins.b %0:l, %2 \n\t" | 69 "ldins.b %0:l, %2 \n\t" |
70 "ldins.b %0:u, %1 \n\t" | 70 "ldins.b %0:u, %1 \n\t" |
74 "m" (*((const uint8_t*)p+2))); | 74 "m" (*((const uint8_t*)p+2))); |
75 return v; | 75 return v; |
76 } | 76 } |
77 | 77 |
78 #define AV_RL24 AV_RL24 | 78 #define AV_RL24 AV_RL24 |
79 static inline uint32_t AV_RL24(const void *p) | 79 static av_always_inline uint32_t AV_RL24(const void *p) |
80 { | 80 { |
81 uint32_t v; | 81 uint32_t v; |
82 __asm__ ("ld.ub %0, %1 \n\t" | 82 __asm__ ("ld.ub %0, %1 \n\t" |
83 "ldins.b %0:l, %2 \n\t" | 83 "ldins.b %0:l, %2 \n\t" |
84 "ldins.b %0:u, %3 \n\t" | 84 "ldins.b %0:u, %3 \n\t" |
90 } | 90 } |
91 | 91 |
92 #if ARCH_AVR32_AP | 92 #if ARCH_AVR32_AP |
93 | 93 |
94 #define AV_RB32 AV_RB32 | 94 #define AV_RB32 AV_RB32 |
95 static inline uint32_t AV_RB32(const void *p) | 95 static av_always_inline uint32_t AV_RB32(const void *p) |
96 { | 96 { |
97 uint32_t v; | 97 uint32_t v; |
98 __asm__ ("ld.w %0, %1" : "=r"(v) : "m"(*(const uint32_t*)p)); | 98 __asm__ ("ld.w %0, %1" : "=r"(v) : "m"(*(const uint32_t*)p)); |
99 return v; | 99 return v; |
100 } | 100 } |
101 | 101 |
102 #define AV_WB32 AV_WB32 | 102 #define AV_WB32 AV_WB32 |
103 static inline void AV_WB32(void *p, uint32_t v) | 103 static av_always_inline void AV_WB32(void *p, uint32_t v) |
104 { | 104 { |
105 __asm__ ("st.w %0, %1" : "=m"(*(uint32_t*)p) : "r"(v)); | 105 __asm__ ("st.w %0, %1" : "=m"(*(uint32_t*)p) : "r"(v)); |
106 } | 106 } |
107 | 107 |
108 /* These two would be defined by generic code, but we need them sooner. */ | 108 /* These two would be defined by generic code, but we need them sooner. */ |
109 #define AV_RL32(p) bswap_32(AV_RB32(p)) | 109 #define AV_RL32(p) bswap_32(AV_RB32(p)) |
110 #define AV_WL32(p, v) AV_WB32(p, bswap_32(v)) | 110 #define AV_WL32(p, v) AV_WB32(p, bswap_32(v)) |
111 | 111 |
112 #define AV_WB64 AV_WB64 | 112 #define AV_WB64 AV_WB64 |
113 static inline void AV_WB64(void *p, uint64_t v) | 113 static av_always_inline void AV_WB64(void *p, uint64_t v) |
114 { | 114 { |
115 union { uint64_t v; uint32_t hl[2]; } vv = { v }; | 115 union { uint64_t v; uint32_t hl[2]; } vv = { v }; |
116 AV_WB32(p, vv.hl[0]); | 116 AV_WB32(p, vv.hl[0]); |
117 AV_WB32((uint32_t*)p+1, vv.hl[1]); | 117 AV_WB32((uint32_t*)p+1, vv.hl[1]); |
118 } | 118 } |
119 | 119 |
120 #define AV_WL64 AV_WL64 | 120 #define AV_WL64 AV_WL64 |
121 static inline void AV_WL64(void *p, uint64_t v) | 121 static av_always_inline void AV_WL64(void *p, uint64_t v) |
122 { | 122 { |
123 union { uint64_t v; uint32_t hl[2]; } vv = { v }; | 123 union { uint64_t v; uint32_t hl[2]; } vv = { v }; |
124 AV_WL32(p, vv.hl[1]); | 124 AV_WL32(p, vv.hl[1]); |
125 AV_WL32((uint32_t*)p+1, vv.hl[0]); | 125 AV_WL32((uint32_t*)p+1, vv.hl[0]); |
126 } | 126 } |
127 | 127 |
128 #else /* ARCH_AVR32_AP */ | 128 #else /* ARCH_AVR32_AP */ |
129 | 129 |
130 #define AV_RB32 AV_RB32 | 130 #define AV_RB32 AV_RB32 |
131 static inline uint32_t AV_RB32(const void *p) | 131 static av_always_inline uint32_t AV_RB32(const void *p) |
132 { | 132 { |
133 uint32_t v; | 133 uint32_t v; |
134 __asm__ ("ld.ub %0, %4 \n\t" | 134 __asm__ ("ld.ub %0, %4 \n\t" |
135 "ldins.b %0:l, %3 \n\t" | 135 "ldins.b %0:l, %3 \n\t" |
136 "ldins.b %0:u, %2 \n\t" | 136 "ldins.b %0:u, %2 \n\t" |
142 "m" (*((const uint8_t*)p+3))); | 142 "m" (*((const uint8_t*)p+3))); |
143 return v; | 143 return v; |
144 } | 144 } |
145 | 145 |
146 #define AV_RL32 AV_RL32 | 146 #define AV_RL32 AV_RL32 |
147 static inline uint32_t AV_RL32(const void *p) | 147 static av_always_inline uint32_t AV_RL32(const void *p) |
148 { | 148 { |
149 uint32_t v; | 149 uint32_t v; |
150 __asm__ ("ld.ub %0, %1 \n\t" | 150 __asm__ ("ld.ub %0, %1 \n\t" |
151 "ldins.b %0:l, %2 \n\t" | 151 "ldins.b %0:l, %2 \n\t" |
152 "ldins.b %0:u, %3 \n\t" | 152 "ldins.b %0:u, %3 \n\t" |
160 } | 160 } |
161 | 161 |
162 #endif /* ARCH_AVR32_AP */ | 162 #endif /* ARCH_AVR32_AP */ |
163 | 163 |
164 #define AV_RB64 AV_RB64 | 164 #define AV_RB64 AV_RB64 |
165 static inline uint64_t AV_RB64(const void *p) | 165 static av_always_inline uint64_t AV_RB64(const void *p) |
166 { | 166 { |
167 union { uint64_t v; uint32_t hl[2]; } v; | 167 union { uint64_t v; uint32_t hl[2]; } v; |
168 v.hl[0] = AV_RB32(p); | 168 v.hl[0] = AV_RB32(p); |
169 v.hl[1] = AV_RB32((const uint32_t*)p+1); | 169 v.hl[1] = AV_RB32((const uint32_t*)p+1); |
170 return v.v; | 170 return v.v; |
171 } | 171 } |
172 | 172 |
173 #define AV_RL64 AV_RL64 | 173 #define AV_RL64 AV_RL64 |
174 static inline uint64_t AV_RL64(const void *p) | 174 static av_always_inline uint64_t AV_RL64(const void *p) |
175 { | 175 { |
176 union { uint64_t v; uint32_t hl[2]; } v; | 176 union { uint64_t v; uint32_t hl[2]; } v; |
177 v.hl[1] = AV_RL32(p); | 177 v.hl[1] = AV_RL32(p); |
178 v.hl[0] = AV_RL32((const uint32_t*)p+1); | 178 v.hl[0] = AV_RL32((const uint32_t*)p+1); |
179 return v.v; | 179 return v.v; |