aboutsummaryrefslogtreecommitdiff
path: root/src/btreeInt.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/btreeInt.h')
-rw-r--r--src/btreeInt.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/btreeInt.h b/src/btreeInt.h
index 92a4d4469..1ccdb0839 100644
--- a/src/btreeInt.h
+++ b/src/btreeInt.h
@@ -691,3 +691,16 @@ struct IntegrityCk {
#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))
#define get4byte sqlite3Get4byte
#define put4byte sqlite3Put4byte
+
+/*
+** get2byteAligned(), unlike get2byte(), requires that its argument point to a
+** two-byte aligned address. get2bytea() is only used for accessing the
+** cell addresses in a btree header.
+*/
+#if SQLITE_BYTEORDER==4321
+# define get2byteAligned(x) (*(u16*)(x))
+#elif SQLITE_BYTEORDER==1234 && defined(__GNUC__)
+# define get2byteAligned(x) __builtin_bswap16(*(u16*)(x))
+#else
+# define get2byteAligned(x) ((x)[0]<<8 | (x)[1])
+#endif