]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/intreadwrite.h
cosmetics: Reformat Apple cc check.
[ffmpeg] / libavutil / intreadwrite.h
index d6c1b67ffafd507f8a1c4bf618aa0ca06908f454..cbf5163b3e8db11891915fcca1d0d32d6b2b8841 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef INTREADWRITE_H
-#define INTREADWRITE_H
+#ifndef FFMPEG_INTREADWRITE_H
+#define FFMPEG_INTREADWRITE_H
 
 #include <stdint.h>
+#include "config.h"
 #include "bswap.h"
 
 #ifdef __GNUC__
@@ -38,9 +39,9 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
 
 #else /* __GNUC__ */
 
-#define AV_RN16(a) (*((uint16_t*)(a)))
-#define AV_RN32(a) (*((uint32_t*)(a)))
-#define AV_RN64(a) (*((uint64_t*)(a)))
+#define AV_RN16(a) (*((const uint16_t*)(a)))
+#define AV_RN32(a) (*((const uint32_t*)(a)))
+#define AV_RN64(a) (*((const uint64_t*)(a)))
 
 #define AV_WN16(a, b) *((uint16_t*)(a)) = (b)
 #define AV_WN32(a, b) *((uint32_t*)(a)) = (b)
@@ -49,7 +50,7 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
 #endif /* !__GNUC__ */
 
 /* endian macros */
-#define AV_RB8(x)     (((uint8_t*)(x))[0])
+#define AV_RB8(x)     (((const uint8_t*)(x))[0])
 #define AV_WB8(p, d)  do { ((uint8_t*)(p))[0] = (d); } while(0)
 
 #define AV_RL8(x)     AV_RB8(x)
@@ -70,29 +71,29 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
 #  define AV_WL16(p, d) AV_WN16(p, d)
 # endif
 #else /* HAVE_FAST_UNALIGNED */
-#define AV_RB16(x)  ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+#define AV_RB16(x)  ((((const uint8_t*)(x))[0] << 8) | ((const uint8_t*)(x))[1])
 #define AV_WB16(p, d) do { \
                     ((uint8_t*)(p))[1] = (d); \
                     ((uint8_t*)(p))[0] = (d)>>8; } while(0)
 
-#define AV_RL16(x)  ((((uint8_t*)(x))[1] << 8) | \
-                      ((uint8_t*)(x))[0])
+#define AV_RL16(x)  ((((const uint8_t*)(x))[1] << 8) | \
+                      ((const uint8_t*)(x))[0])
 #define AV_WL16(p, d) do { \
                     ((uint8_t*)(p))[0] = (d); \
                     ((uint8_t*)(p))[1] = (d)>>8; } while(0)
 #endif
 
-#define AV_RB24(x)  ((((uint8_t*)(x))[0] << 16) | \
-                     (((uint8_t*)(x))[1] <<  8) | \
-                      ((uint8_t*)(x))[2])
+#define AV_RB24(x)  ((((const uint8_t*)(x))[0] << 16) | \
+                     (((const uint8_t*)(x))[1] <<  8) | \
+                      ((const uint8_t*)(x))[2])
 #define AV_WB24(p, d) do { \
                     ((uint8_t*)(p))[2] = (d); \
                     ((uint8_t*)(p))[1] = (d)>>8; \
                     ((uint8_t*)(p))[0] = (d)>>16; } while(0)
 
-#define AV_RL24(x)  ((((uint8_t*)(x))[2] << 16) | \
-                     (((uint8_t*)(x))[1] <<  8) | \
-                      ((uint8_t*)(x))[0])
+#define AV_RL24(x)  ((((const uint8_t*)(x))[2] << 16) | \
+                     (((const uint8_t*)(x))[1] <<  8) | \
+                      ((const uint8_t*)(x))[0])
 #define AV_WL24(p, d) do { \
                     ((uint8_t*)(p))[0] = (d); \
                     ((uint8_t*)(p))[1] = (d)>>8; \
@@ -113,20 +114,20 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
 #  define AV_WL32(p, d) AV_WN32(p, d)
 # endif
 #else /* HAVE_FAST_UNALIGNED */
-#define AV_RB32(x)  ((((uint8_t*)(x))[0] << 24) | \
-                     (((uint8_t*)(x))[1] << 16) | \
-                     (((uint8_t*)(x))[2] <<  8) | \
-                      ((uint8_t*)(x))[3])
+#define AV_RB32(x)  ((((const uint8_t*)(x))[0] << 24) | \
+                     (((const uint8_t*)(x))[1] << 16) | \
+                     (((const uint8_t*)(x))[2] <<  8) | \
+                      ((const uint8_t*)(x))[3])
 #define AV_WB32(p, d) do { \
                     ((uint8_t*)(p))[3] = (d); \
                     ((uint8_t*)(p))[2] = (d)>>8; \
                     ((uint8_t*)(p))[1] = (d)>>16; \
                     ((uint8_t*)(p))[0] = (d)>>24; } while(0)
 
-#define AV_RL32(x) ((((uint8_t*)(x))[3] << 24) | \
-                    (((uint8_t*)(x))[2] << 16) | \
-                    (((uint8_t*)(x))[1] <<  8) | \
-                     ((uint8_t*)(x))[0])
+#define AV_RL32(x) ((((const uint8_t*)(x))[3] << 24) | \
+                    (((const uint8_t*)(x))[2] << 16) | \
+                    (((const uint8_t*)(x))[1] <<  8) | \
+                     ((const uint8_t*)(x))[0])
 #define AV_WL32(p, d) do { \
                     ((uint8_t*)(p))[0] = (d); \
                     ((uint8_t*)(p))[1] = (d)>>8; \
@@ -149,14 +150,14 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
 #  define AV_WL64(p, d) AV_WN64(p, d)
 # endif
 #else /* HAVE_FAST_UNALIGNED */
-#define AV_RB64(x)  (((uint64_t)((uint8_t*)(x))[0] << 56) | \
-                     ((uint64_t)((uint8_t*)(x))[1] << 48) | \
-                     ((uint64_t)((uint8_t*)(x))[2] << 40) | \
-                     ((uint64_t)((uint8_t*)(x))[3] << 32) | \
-                     ((uint64_t)((uint8_t*)(x))[4] << 24) | \
-                     ((uint64_t)((uint8_t*)(x))[5] << 16) | \
-                     ((uint64_t)((uint8_t*)(x))[6] <<  8) | \
-                      (uint64_t)((uint8_t*)(x))[7])
+#define AV_RB64(x)  (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
+                     ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
+                     ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
+                     ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
+                     ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
+                     ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
+                     ((uint64_t)((const uint8_t*)(x))[6] <<  8) | \
+                      (uint64_t)((const uint8_t*)(x))[7])
 #define AV_WB64(p, d) do { \
                     ((uint8_t*)(p))[7] = (d);     \
                     ((uint8_t*)(p))[6] = (d)>>8;  \
@@ -167,14 +168,14 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
                     ((uint8_t*)(p))[1] = (d)>>48; \
                     ((uint8_t*)(p))[0] = (d)>>56; } while(0)
 
-#define AV_RL64(x)  (((uint64_t)((uint8_t*)(x))[7] << 56) | \
-                     ((uint64_t)((uint8_t*)(x))[6] << 48) | \
-                     ((uint64_t)((uint8_t*)(x))[5] << 40) | \
-                     ((uint64_t)((uint8_t*)(x))[4] << 32) | \
-                     ((uint64_t)((uint8_t*)(x))[3] << 24) | \
-                     ((uint64_t)((uint8_t*)(x))[2] << 16) | \
-                     ((uint64_t)((uint8_t*)(x))[1] <<  8) | \
-                      (uint64_t)((uint8_t*)(x))[0])
+#define AV_RL64(x)  (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
+                     ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
+                     ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
+                     ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
+                     ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
+                     ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
+                     ((uint64_t)((const uint8_t*)(x))[1] <<  8) | \
+                      (uint64_t)((const uint8_t*)(x))[0])
 #define AV_WL64(p, d) do { \
                     ((uint8_t*)(p))[0] = (d);     \
                     ((uint8_t*)(p))[1] = (d)>>8;  \
@@ -186,4 +187,4 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
                     ((uint8_t*)(p))[7] = (d)>>56; } while(0)
 #endif
 
-#endif /* INTREADWRITE_H */
+#endif /* FFMPEG_INTREADWRITE_H */