summaryrefslogtreecommitdiffstats
path: root/patches
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2011-02-13 20:16:04 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2011-02-14 11:01:25 +0100
commitd02300e1ee9a0d5c244bf845740602c7af0a0155 (patch)
treea714a137d90848efd4b7a47af7dff4f0aeab521a /patches
parentd1bf322af4e8eea8dad8a62cc937ceb817f898b7 (diff)
downloadptxdist-d02300e1ee9a0d5c244bf845740602c7af0a0155.tar.gz
ptxdist-d02300e1ee9a0d5c244bf845740602c7af0a0155.tar.xz
memcached: add upstream patch to fix compiling with gcc 4.5
Diffstat (limited to 'patches')
-rw-r--r--patches/memcached-1.4.5/0003-Fix-type-punning-issues-exposed-with-GCC-4.5.1.patch80
-rw-r--r--patches/memcached-1.4.5/series3
2 files changed, 82 insertions, 1 deletions
diff --git a/patches/memcached-1.4.5/0003-Fix-type-punning-issues-exposed-with-GCC-4.5.1.patch b/patches/memcached-1.4.5/0003-Fix-type-punning-issues-exposed-with-GCC-4.5.1.patch
new file mode 100644
index 000000000..653273996
--- /dev/null
+++ b/patches/memcached-1.4.5/0003-Fix-type-punning-issues-exposed-with-GCC-4.5.1.patch
@@ -0,0 +1,80 @@
+From: Dan McGee <dan@archlinux.org>
+Date: Tue, 2 Nov 2010 18:43:00 -0500
+Subject: [PATCH] Fix type-punning issues exposed with GCC 4.5.1
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The errors below are due to pointer magic that isn't allowed if following C
+strict-aliasing rules:
+
+ memcached.c: In function ‘complete_incr_bin’:
+ memcached.c:1023:16: error: dereferencing type-punned pointer will break
+ strict-aliasing rules
+ memcached.c:1044:13: error: dereferencing type-punned pointer will break
+ strict-aliasing rules
+ memcached.c:1061:17: error: dereferencing type-punned pointer will break
+ strict-aliasing rules
+
+Fix this by introducing a union type that allows access to the uint64_t
+member as necessary, but doesn't add any additional length to the structure.
+The size remains the same before and after; the only difference is explict
+casts are now refactored into union member accesses and all compilers should
+be happy.
+
+Signed-off-by: Dan McGee <dan@archlinux.org>
+---
+ memcached.h | 25 +++++++++++++++++--------
+ 1 files changed, 17 insertions(+), 8 deletions(-)
+
+diff --git a/memcached.h b/memcached.h
+index 4a7295b..74a6592 100644
+--- a/memcached.h
++++ b/memcached.h
+@@ -77,18 +77,22 @@
+ #define TAIL_REPAIR_TIME (3 * 3600)
+
+ /* warning: don't use these macros with a function, as it evals its arg twice */
+-#define ITEM_get_cas(i) ((uint64_t)(((i)->it_flags & ITEM_CAS) ? \
+- *(uint64_t*)&((i)->end[0]) : 0x0))
+-#define ITEM_set_cas(i,v) { if ((i)->it_flags & ITEM_CAS) { \
+- *(uint64_t*)&((i)->end[0]) = v; } }
++#define ITEM_get_cas(i) (((i)->it_flags & ITEM_CAS) ? \
++ (i)->data->cas : (uint64_t)0)
+
+-#define ITEM_key(item) (((char*)&((item)->end[0])) \
++#define ITEM_set_cas(i,v) { \
++ if ((i)->it_flags & ITEM_CAS) { \
++ (i)->data->cas = v; \
++ } \
++}
++
++#define ITEM_key(item) (((char*)&((item)->data)) \
+ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
+
+-#define ITEM_suffix(item) ((char*) &((item)->end[0]) + (item)->nkey + 1 \
++#define ITEM_suffix(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
+
+-#define ITEM_data(item) ((char*) &((item)->end[0]) + (item)->nkey + 1 \
++#define ITEM_data(item) ((char*) &((item)->data) + (item)->nkey + 1 \
+ + (item)->nsuffix \
+ + (((item)->it_flags & ITEM_CAS) ? sizeof(uint64_t) : 0))
+
+@@ -302,7 +306,12 @@ typedef struct _stritem {
+ uint8_t it_flags; /* ITEM_* above */
+ uint8_t slabs_clsid;/* which slab class we're in */
+ uint8_t nkey; /* key length, w/terminating null and padding */
+- void * end[];
++ /* this odd type prevents type-punning issues when we do
++ * the little shuffle to save space when not using CAS. */
++ union {
++ uint64_t cas;
++ char end;
++ } data[];
+ /* if it_flags & ITEM_CAS we have 8 bytes CAS */
+ /* then null-terminated key */
+ /* then " flags length\r\n" (no terminating null) */
+--
+1.7.2.3
+
diff --git a/patches/memcached-1.4.5/series b/patches/memcached-1.4.5/series
index 5a0ae45f9..90647cb8f 100644
--- a/patches/memcached-1.4.5/series
+++ b/patches/memcached-1.4.5/series
@@ -1,4 +1,5 @@
# generated by git-ptx-patches
0001-Switch-AC_RUN-to-AC_LINK.patch
0002-Change-configure.ac-to-use-AC_C_BIGENDIAN.patch
-# 09541c0db6fa5da1e383ec8ae47e9fa4 - git-ptx-patches magic
+0003-Fix-type-punning-issues-exposed-with-GCC-4.5.1.patch
+# 072bd6f23f8727b4c3060fb3d4197ee5 - git-ptx-patches magic