Mercurial > libavutil.hg
comparison intreadwrite.h @ 995:3ed4c58e9a0e libavutil
Make intreadwrite.h installation-safe
author | mru |
---|---|
date | Sat, 10 Jul 2010 22:22:03 +0000 |
parents | f8db9a2bae05 |
children |
comparison
equal
deleted
inserted
replaced
994:41878f66798f | 995:3ed4c58e9a0e |
---|---|
18 | 18 |
19 #ifndef AVUTIL_INTREADWRITE_H | 19 #ifndef AVUTIL_INTREADWRITE_H |
20 #define AVUTIL_INTREADWRITE_H | 20 #define AVUTIL_INTREADWRITE_H |
21 | 21 |
22 #include <stdint.h> | 22 #include <stdint.h> |
23 #include "config.h" | 23 #include "libavutil/avconfig.h" |
24 #include "attributes.h" | 24 #include "attributes.h" |
25 #include "bswap.h" | 25 #include "bswap.h" |
26 | 26 |
27 typedef union { | 27 typedef union { |
28 uint64_t u64; | 28 uint64_t u64; |
49 * Arch-specific headers can provide any combination of | 49 * Arch-specific headers can provide any combination of |
50 * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. | 50 * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. |
51 * Preprocessor symbols must be defined, even if these are implemented | 51 * Preprocessor symbols must be defined, even if these are implemented |
52 * as inline functions. | 52 * as inline functions. |
53 */ | 53 */ |
54 | |
55 #ifdef HAVE_AV_CONFIG_H | |
56 | |
57 #include "config.h" | |
54 | 58 |
55 #if ARCH_ARM | 59 #if ARCH_ARM |
56 # include "arm/intreadwrite.h" | 60 # include "arm/intreadwrite.h" |
57 #elif ARCH_AVR32 | 61 #elif ARCH_AVR32 |
58 # include "avr32/intreadwrite.h" | 62 # include "avr32/intreadwrite.h" |
64 # include "tomi/intreadwrite.h" | 68 # include "tomi/intreadwrite.h" |
65 #elif ARCH_X86 | 69 #elif ARCH_X86 |
66 # include "x86/intreadwrite.h" | 70 # include "x86/intreadwrite.h" |
67 #endif | 71 #endif |
68 | 72 |
73 #endif /* HAVE_AV_CONFIG_H */ | |
74 | |
69 /* | 75 /* |
70 * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. | 76 * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. |
71 */ | 77 */ |
72 | 78 |
73 #if HAVE_BIGENDIAN | 79 #if AV_HAVE_BIGENDIAN |
74 | 80 |
75 # if defined(AV_RN16) && !defined(AV_RB16) | 81 # if defined(AV_RN16) && !defined(AV_RB16) |
76 # define AV_RB16(p) AV_RN16(p) | 82 # define AV_RB16(p) AV_RN16(p) |
77 # elif !defined(AV_RN16) && defined(AV_RB16) | 83 # elif !defined(AV_RN16) && defined(AV_RB16) |
78 # define AV_RN16(p) AV_RB16(p) | 84 # define AV_RN16(p) AV_RB16(p) |
118 # define AV_WB64(p, v) AV_WN64(p, v) | 124 # define AV_WB64(p, v) AV_WN64(p, v) |
119 # elif !defined(AV_WN64) && defined(AV_WB64) | 125 # elif !defined(AV_WN64) && defined(AV_WB64) |
120 # define AV_WN64(p, v) AV_WB64(p, v) | 126 # define AV_WN64(p, v) AV_WB64(p, v) |
121 # endif | 127 # endif |
122 | 128 |
123 #else /* HAVE_BIGENDIAN */ | 129 #else /* AV_HAVE_BIGENDIAN */ |
124 | 130 |
125 # if defined(AV_RN16) && !defined(AV_RL16) | 131 # if defined(AV_RN16) && !defined(AV_RL16) |
126 # define AV_RL16(p) AV_RN16(p) | 132 # define AV_RL16(p) AV_RN16(p) |
127 # elif !defined(AV_RN16) && defined(AV_RL16) | 133 # elif !defined(AV_RN16) && defined(AV_RL16) |
128 # define AV_RN16(p) AV_RL16(p) | 134 # define AV_RN16(p) AV_RL16(p) |
168 # define AV_WL64(p, v) AV_WN64(p, v) | 174 # define AV_WL64(p, v) AV_WN64(p, v) |
169 # elif !defined(AV_WN64) && defined(AV_WL64) | 175 # elif !defined(AV_WN64) && defined(AV_WL64) |
170 # define AV_WN64(p, v) AV_WL64(p, v) | 176 # define AV_WN64(p, v) AV_WL64(p, v) |
171 # endif | 177 # endif |
172 | 178 |
173 #endif /* !HAVE_BIGENDIAN */ | 179 #endif /* !AV_HAVE_BIGENDIAN */ |
174 | 180 |
175 /* | 181 /* |
176 * Define AV_[RW]N helper macros to simplify definitions not provided | 182 * Define AV_[RW]N helper macros to simplify definitions not provided |
177 * by per-arch headers. | 183 * by per-arch headers. |
178 */ | 184 */ |
179 | 185 |
180 #if HAVE_ATTRIBUTE_PACKED | 186 #if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__) |
181 | 187 |
182 union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; | 188 union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; |
183 union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; | 189 union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; |
184 union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; | 190 union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; |
185 | 191 |
189 #elif defined(__DECC) | 195 #elif defined(__DECC) |
190 | 196 |
191 # define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) | 197 # define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) |
192 # define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) | 198 # define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) |
193 | 199 |
194 #elif HAVE_FAST_UNALIGNED | 200 #elif AV_HAVE_FAST_UNALIGNED |
195 | 201 |
196 # define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) | 202 # define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) |
197 # define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) | 203 # define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) |
198 | 204 |
199 #else | 205 #else |
300 ((uint8_t*)(p))[6] = (d)>>48; \ | 306 ((uint8_t*)(p))[6] = (d)>>48; \ |
301 ((uint8_t*)(p))[7] = (d)>>56; \ | 307 ((uint8_t*)(p))[7] = (d)>>56; \ |
302 } while(0) | 308 } while(0) |
303 #endif | 309 #endif |
304 | 310 |
305 #if HAVE_BIGENDIAN | 311 #if AV_HAVE_BIGENDIAN |
306 # define AV_RN(s, p) AV_RB##s(p) | 312 # define AV_RN(s, p) AV_RB##s(p) |
307 # define AV_WN(s, p, v) AV_WB##s(p, v) | 313 # define AV_WN(s, p, v) AV_WB##s(p, v) |
308 #else | 314 #else |
309 # define AV_RN(s, p) AV_RL##s(p) | 315 # define AV_RN(s, p) AV_RL##s(p) |
310 # define AV_WN(s, p, v) AV_WL##s(p, v) | 316 # define AV_WN(s, p, v) AV_WL##s(p, v) |
334 | 340 |
335 #ifndef AV_WN64 | 341 #ifndef AV_WN64 |
336 # define AV_WN64(p, v) AV_WN(64, p, v) | 342 # define AV_WN64(p, v) AV_WN(64, p, v) |
337 #endif | 343 #endif |
338 | 344 |
339 #if HAVE_BIGENDIAN | 345 #if AV_HAVE_BIGENDIAN |
340 # define AV_RB(s, p) AV_RN##s(p) | 346 # define AV_RB(s, p) AV_RN##s(p) |
341 # define AV_WB(s, p, v) AV_WN##s(p, v) | 347 # define AV_WB(s, p, v) AV_WN##s(p, v) |
342 # define AV_RL(s, p) av_bswap##s(AV_RN##s(p)) | 348 # define AV_RL(s, p) av_bswap##s(AV_RN##s(p)) |
343 # define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v)) | 349 # define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v)) |
344 #else | 350 #else |