$OpenBSD: patch-src_cairoint_h,v 1.2 2014/11/27 03:23:57 brad Exp $

http://cgit.freedesktop.org/cairo/commit/?id=99a35dd273f3deb4ae54310f1ed1746bfd9fae70

    CFF: Fix unaligned access

http://cgit.freedesktop.org/cairo/commit/?id=adbeb3d53c6c6e8ddcc63988200da4c5c9627717

    Improve performance of cpu_to_be32 and be32_to_cpu

--- src/cairoint.h.orig	Mon Oct 13 21:46:33 2014
+++ src/cairoint.h	Mon Nov 17 19:57:23 2014
@@ -229,7 +229,7 @@ be16_to_cpu(uint16_t v)
 static inline uint32_t cairo_const
 cpu_to_be32(uint32_t v)
 {
-    return (cpu_to_be16 (v) << 16) | cpu_to_be16 (v >> 16);
+    return (v >> 24) | ((v >> 8) & 0xff00) | ((v << 8) & 0xff0000) | (v << 24);
 }
 
 static inline uint32_t cairo_const
@@ -240,6 +240,32 @@ be32_to_cpu(uint32_t v)
 
 #endif
 
+/* Unaligned big endian access
+ */
+
+static inline uint16_t get_unaligned_be16 (const unsigned char *p)
+{
+    return p[0] << 8 | p[1];
+}
+
+static inline uint32_t get_unaligned_be32 (const unsigned char *p)
+{
+    return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
+}
+
+static inline void put_unaligned_be16 (uint16_t v, unsigned char *p)
+{
+    p[0] = (v >> 8) & 0xff;
+    p[1] = v & 0xff;
+}
+
+static inline void put_unaligned_be32 (uint32_t v, unsigned char *p)
+{
+    p[0] = (v >> 24) & 0xff;
+    p[1] = (v >> 16) & 0xff;
+    p[2] = (v >> 8)  & 0xff;
+    p[3] = v & 0xff;
+}
 
 /* The glibc versions of ispace() and isdigit() are slow in UTF-8 locales.
  */
