diff options
author | Carlo Landmeter <clandmeter@gmail.com> | 2011-04-13 10:37:05 +0000 |
---|---|---|
committer | Carlo Landmeter <clandmeter@gmail.com> | 2011-04-13 10:37:05 +0000 |
commit | d799936de683061e7c04c2fb34a6541d2fb2a6c4 (patch) | |
tree | b0c95bac3229ad3ff54cae7658bd569f97e2b590 /main/memcached | |
parent | 8728a1db8aad5cfec5228f65921fb4d777956037 (diff) | |
download | aports-d799936de683061e7c04c2fb34a6541d2fb2a6c4.tar.bz2 aports-d799936de683061e7c04c2fb34a6541d2fb2a6c4.tar.xz |
main/memcached: moved from testing to main
Diffstat (limited to 'main/memcached')
-rw-r--r-- | main/memcached/0001-fix-type-punning-issues.patch | 73 | ||||
-rw-r--r-- | main/memcached/APKBUILD | 50 | ||||
-rw-r--r-- | main/memcached/memcached.confd | 35 | ||||
-rw-r--r-- | main/memcached/memcached.initd | 80 | ||||
-rw-r--r-- | main/memcached/memcached.pre-install | 5 |
5 files changed, 243 insertions, 0 deletions
diff --git a/main/memcached/0001-fix-type-punning-issues.patch b/main/memcached/0001-fix-type-punning-issues.patch new file mode 100644 index 0000000000..eb2c7355d1 --- /dev/null +++ b/main/memcached/0001-fix-type-punning-issues.patch @@ -0,0 +1,73 @@ +commit df15887584f0025e7b188e408dd3c9f638d68518 +Author: Dan McGee <dan@archlinux.org> +Date: Tue Nov 2 18:43:00 2010 -0500 + + Fix type-punning issues exposed with GCC 4.5.1 + + 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> + +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) */ diff --git a/main/memcached/APKBUILD b/main/memcached/APKBUILD new file mode 100644 index 0000000000..fbbd9b1929 --- /dev/null +++ b/main/memcached/APKBUILD @@ -0,0 +1,50 @@ +# Contributor: Jeff Bilyk <jbilyk@alpinelinux.org> +# Maintainer: Natanael Copa <ncopa@alpinelinux.org> +pkgname=memcached +pkgver=1.4.5 +pkgrel=1 +pkgdesc="Distributed memory object caching system" +url="http://memcached.org" +arch="all" +license="GPL" +depends="perl" +depends_dev="libevent-dev" +makedepends="$depends_dev" +install="$pkgname.pre-install" +subpackages="$pkgname-dev $pkgname-doc" +source="http://memcached.googlecode.com/files/$pkgname-$pkgver.tar.gz + 0001-fix-type-punning-issues.patch + $pkgname.confd + $pkgname.initd" + +_builddir="$srcdir/$pkgname-$pkgver" + +prepare() { + local i + cd "$_builddir" + for i in $source; do + case $i in + *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;; + esac + done +} + +build() { + cd "$_builddir" + ./configure --prefix=/usr + make || return 1 +} + +package() { + cd "$_builddir" + make DESTDIR="$pkgdir" install || return 1 + install -m755 -D "$srcdir/$pkgname.initd" \ + "$pkgdir/etc/init.d/$pkgname" || return 1 + install -m644 -D "$srcdir/$pkgname.confd" \ + "$pkgdir/etc/conf.d/$pkgname" || return 1 +} + +md5sums="583441a25f937360624024f2881e5ea8 memcached-1.4.5.tar.gz +a5b61a9b9a92a2619d9e99338a9a2a64 0001-fix-type-punning-issues.patch +9d7396bf77c72ca3845118424cd1898b memcached.confd +cc344c9aead89042ca2fbf45cd3930a6 memcached.initd" diff --git a/main/memcached/memcached.confd b/main/memcached/memcached.confd new file mode 100644 index 0000000000..7acf662a84 --- /dev/null +++ b/main/memcached/memcached.confd @@ -0,0 +1,35 @@ +# Copyright 2003 Gentoo Technologies, Inc +# $Header: /var/cvsroot/gentoo-x86/net-misc/memcached/files/1.3.3/conf,v 1.1 2009/05/26 00:03:09 robbat2 Exp $ +# memcached config file + +MEMCACHED_BINARY="/usr/bin/memcached" + +#Specify memory usage in megabytes (do not use letters) +#64MB is default +MEMUSAGE="64" + +#User to run as +MEMCACHED_RUNAS="memcached" + +#Specify maximum number of concurrent connections +#1024 is default +MAXCONN="1024" + +#Listen for connections on what address? +# If this is empty, memcached will listen on 0.0.0.0 +# be sure you have a firewall in place! +LISTENON="" + +#Listen for connections on what port? +PORT="11211" + +# Listen for UDP connecitons on what port? 0 means turn off UDP +UDPPORT="${PORT}" + +#PID file location +# '-${PORT}.${CONF}.pid' will be appended to this! +# You do not normally need to change this. +PIDBASE="/var/run/memcached/memcached" + +#Other Options +MISC_OPTS="" diff --git a/main/memcached/memcached.initd b/main/memcached/memcached.initd new file mode 100644 index 0000000000..74b2c60918 --- /dev/null +++ b/main/memcached/memcached.initd @@ -0,0 +1,80 @@ +#!/sbin/runscript +# $Header: /var/cvsroot/gentoo-x86/net-misc/memcached/files/1.3.3/init,v 1.1 2009/05/26 00:03:09 robbat2 Exp $ + +CONF="${SVCNAME#*.}" +CONFBASE="/etc/conf.d/memcached" + +[ -z "${PIDBASE}" ] && PIDBASE="/var/run/memcached/memcached" +[ "${CONF}" == "memcached" ] && CONF='' + +if [ -n "${CONF}" ]; then + PIDFILE="${PIDBASE}-${PORT}.${CONF}.pid" + CONFSRC="${CONFBASE}.${CONF}" + if [ -f "${CONFSRC}" ]; then + source "${CONFSRC}" + else + eerror "The configuration file $CONFSRC was not found!" + fi +else + PIDFILE="${PIDBASE}-${PORT}.pid" + CONFSRC="${CONFBASE}" +fi + +depend() { + need net + # per bug #269022, accurate time is important for memcached! + # We include the full list of ways it might be set on boot. + after ntp-client ntpd rdate openrdate adjtimex hwclock +} + +checkconfig() { + if [ -z "${LISTENON}" ]; then + ewarn "You should edit $CONFSRC and specify an address to listen on." + ewarn "Listening on any address (check your firewall!)" + fi + +} + +start() { + if [ -n "${CONF}" ]; then + ebegin "Starting memcached (${CONF})" + else + ebegin "Starting memcached" + fi + checkconfig + local dir="$(dirname ${PIDFILE})" + if [ ! -d "${dir}" ]; then + einfo " Creating ${dir}" + mkdir -p "${dir}" + fi + chown ${MEMCACHED_RUNAS} "${dir}" + if [ -f "${PIDFILE}" ]; then + einfo " Removing stale pidfile ${PIDFILE}" + rm -f "${PIDFILE}" 1>/dev/null + fi + + if [ -z "${LISTENON}" ]; then + c_LISTENON="" + else + c_LISTENON="-l ${LISTENON}" + fi + + /sbin/start-stop-daemon --start --pidfile "${PIDFILE}" \ + --exec "${MEMCACHED_BINARY}" \ + --startas "${MEMCACHED_BINARY}" -- \ + -d -p ${PORT} -U ${UDPPORT} ${c_LISTENON} -m ${MEMUSAGE} \ + -c ${MAXCONN} -u ${MEMCACHED_RUNAS} -P "${PIDFILE}" \ + ${MISC_OPTS} + eend $? +} + +stop() { + if [ -n "${CONF}" ]; then + ebegin "Stopping memcached (${CONF})" + else + ebegin "Stopping memcached" + fi + start-stop-daemon --stop --quiet --pidfile "${PIDFILE}" + rm -f "${PIDFILE}" + eend $? +} diff --git a/main/memcached/memcached.pre-install b/main/memcached/memcached.pre-install new file mode 100644 index 0000000000..f9d7c71690 --- /dev/null +++ b/main/memcached/memcached.pre-install @@ -0,0 +1,5 @@ +#!/bin/sh + +adduser -H -s /bin/false -D memcached 2>/dev/null +exit 0 + |