# HG changeset patch # User mru # Date 1266500678 0 # Node ID c34612e84b06071d5a21d0e817ddaee705316b43 # Parent 8af0a7ac848212ba6b8895ca5acf38d8097362bb Add alias-safe aligned AV_[RW]N macros diff -r 8af0a7ac8482 -r c34612e84b06 intreadwrite.h --- a/intreadwrite.h Thu Feb 18 13:40:24 2010 +0000 +++ b/intreadwrite.h Thu Feb 18 13:44:38 2010 +0000 @@ -422,6 +422,38 @@ } while(0) #endif +/* + * The AV_[RW]NA macros access naturally aligned data + * in a type-safe way. + */ + +#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s) +#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#ifndef AV_RN16A +# define AV_RN16A(p) AV_RNA(16, p) +#endif + +#ifndef AV_RN32A +# define AV_RN32A(p) AV_RNA(32, p) +#endif + +#ifndef AV_RN64A +# define AV_RN64A(p) AV_RNA(64, p) +#endif + +#ifndef AV_WN16A +# define AV_WN16A(p, v) AV_WNA(16, p, v) +#endif + +#ifndef AV_WN32A +# define AV_WN32A(p, v) AV_WNA(32, p, v) +#endif + +#ifndef AV_WN64A +# define AV_WN64A(p, v) AV_WNA(64, p, v) +#endif + /* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be * naturally aligned. They may be implemented using MMX, * so emms_c() must be called before using any float code