forwarded solaris patches

Brad Fitzpatrick brad at danga.com
Tue Jul 17 23:24:24 UTC 2007


Forwarding this on....

If anybody wants to review/commit.


---------- Forwarded message ----------
Date: Tue, 17 Jul 2007 15:53:01 +0100
From: Andy White <andy at milky.org.uk>
To: brad at danga.com
Subject: memcache

Hi Brad,

I downloaded memcached earlier today and spent a little bit of time
fixing it and getting it to compile on my solaris platform.

I've probably taken out and changed more than I need to and I apologise
if I've completely missed off how to go about submitting any form of patches
or missed whether this has been resolved before.

I'll attach the patch. It seems to pass "make test".

It needs tidying up a bit and I'm more than happy to do that if you think
it'll be useful.

If there's anything else I can do to help you at all, please let me know.

I also apologise in advance if I'm just wasting your time.

Kind regards,

Andy
-------------- next part --------------
Only in src/memcached-1.2.2/: .deps
Only in src/memcached-1.2.2/: Makefile
Only in src/memcached-1.2.2/: buildenviron
Only in src/memcached-1.2.2/: config.h
Only in src/memcached-1.2.2/: config.log
Only in src/memcached-1.2.2/: config.log.old
Only in src/memcached-1.2.2/: config.status
Only in t/memcached-1.2.2/: daemon.c
Common subdirectories: t/memcached-1.2.2//doc and src/memcached-1.2.2//doc
diff -uwr t/memcached-1.2.2//memcached.c src/memcached-1.2.2//memcached.c
--- t/memcached-1.2.2//memcached.c	Wed May  2 23:58:51 2007
+++ src/memcached-1.2.2//memcached.c	Tue Jul 17 10:49:30 2007
@@ -19,7 +19,7 @@
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-#include <sys/signal.h>
+#include <signal.h>
 #include <sys/resource.h>
 #include <sys/uio.h>
 
@@ -46,12 +46,7 @@
 #include <assert.h>
 #include <limits.h>
 
-#ifdef HAVE_MALLOC_H
-/* OpenBSD has a malloc.h, but warns to use stdlib.h instead */
-#ifndef __OpenBSD__
 #include <malloc.h>
-#endif
-#endif
 
 /* FreeBSD 4.x doesn't have IOV_MAX exposed. */
 #ifndef IOV_MAX
@@ -63,6 +58,7 @@
 /*
  * forward declarations
  */
+int daemon(int, int );
 static void drive_machine(conn *c);
 static int new_socket(const bool is_udp);
 static int server_socket(const int port, const bool is_udp);
@@ -635,7 +631,7 @@
 
     hdr = c->hdrbuf;
     for (i = 0; i < c->msgused; i++) {
-        c->msglist[i].msg_iov[0].iov_base = hdr;
+        c->msglist[i].msg_iov[0].iov_base = (char *) hdr;
         c->msglist[i].msg_iov[0].iov_len = UDP_HEADER_SIZE;
         *hdr++ = c->request_id / 256;
         *hdr++ = c->request_id % 256;
@@ -813,7 +809,7 @@
     return ntokens;
 }
 
-inline void process_stats_detail(conn *c, const char *command) {
+void process_stats_detail(conn *c, const char *command) {
     assert(c != NULL);
 
     if (strcmp(command, "on") == 0) {
@@ -1047,7 +1043,7 @@
 }
 
 /* ntokens is overwritten here... shrug.. */
-static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens) {
+static void process_get_command(conn *c, token_t *tokens, size_t ntokens) {
     char *key;
     size_t nkey;
     int i = 0;
@@ -2744,4 +2740,33 @@
     if (daemonize)
         remove_pidfile(pid_file);
     return 0;
+}
+
+int daemon(int nochdir, int noclose)
+{
+    int fd;
+
+    switch (fork()) {
+    case -1:
+        return (-1);
+    case 0:
+        break;
+    default:
+        _exit(EXIT_SUCCESS);
+    }
+
+    if (setsid() == -1)
+        return (-1);
+
+    if (nochdir == 0)
+        (void)chdir("/");
+
+    if (noclose==0 && (fd = open("/dev/null", O_RDWR, 0)) != -1) {
+        (void)dup2(fd, STDIN_FILENO);
+        (void)dup2(fd, STDOUT_FILENO);
+        (void)dup2(fd, STDERR_FILENO);
+        if (fd > STDERR_FILENO)
+            (void)close(fd);
+    }
+    return (0);
 }
Only in src/memcached-1.2.2/: memcached.c-orig
diff -uwr t/memcached-1.2.2//memcached.h src/memcached-1.2.2//memcached.h
--- t/memcached-1.2.2//memcached.h	Wed May  2 23:58:51 2007
+++ src/memcached-1.2.2//memcached.h	Tue Jul 17 10:50:56 2007
@@ -6,6 +6,8 @@
 #include <sys/time.h>
 #include <netinet/in.h>
 #include <event.h>
+#include <arpa/inet.h>
+#include <netdb.h>
 
 #define DATA_BUFFER_SIZE 2048
 #define UDP_READ_BUFFER_SIZE 65536
@@ -35,12 +37,6 @@
   typedef enum {false = 0, true = 1} bool;
 #endif
 
-#if HAVE_STDINT_H
-# include <stdint.h>
-#else
- typedef unsigned char             uint8_t;
-#endif
-
 /* Time relative to server start. Smaller than time_t on 64-bit systems. */
 typedef unsigned int rel_time_t;
 
@@ -102,17 +98,17 @@
     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[0];
+    char *end;
     /* then null-terminated key */
     /* then " flags length\r\n" (no terminating null) */
     /* then data with terminating \r\n (no terminating null; it's binary!) */
 } item;
 
-#define ITEM_key(item) ((char*)&((item)->end[0]))
+#define ITEM_key(item) ((char*) (&((item)->end) ))
 
 /* warning: don't use these macros with a function, as it evals its arg twice */
-#define ITEM_suffix(item) ((char*) &((item)->end[0]) + (item)->nkey + 1)
-#define ITEM_data(item) ((char*) &((item)->end[0]) + (item)->nkey + 1 + (item)->nsuffix)
+#define ITEM_suffix(item) ((char*) &((item)->end ) + (item)->nkey + 1)
+#define ITEM_data(item) ((char*) &((item)->end ) + (item)->nkey + 1 + (item)->nsuffix)
 #define ITEM_ntotal(item) (sizeof(struct _stritem) + (item)->nkey + 1 + (item)->nsuffix + (item)->nbytes)
 
 enum conn_states {
Only in src/memcached-1.2.2/: out
Common subdirectories: t/memcached-1.2.2//scripts and src/memcached-1.2.2//scripts
Only in src/memcached-1.2.2/: stamp-h1
Common subdirectories: t/memcached-1.2.2//t and src/memcached-1.2.2//t
diff -uwr t/memcached-1.2.2//doc/Makefile src/memcached-1.2.2//doc/Makefile
--- t/memcached-1.2.2//doc/Makefile	Thu May  3 00:21:23 2007
+++ src/memcached-1.2.2//doc/Makefile	Tue Jul 17 09:57:55 2007
@@ -23,7 +23,7 @@
 top_builddir = ..
 
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = /usr/bin/install -c
+INSTALL = /opt/csw/bin/ginstall -c
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
 install_sh_SCRIPT = $(install_sh) -c
@@ -35,22 +35,22 @@
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-build_triplet = i686-pc-linux-gnu
-host_triplet = i686-pc-linux-gnu
-target_triplet = i686-pc-linux-gnu
-ACLOCAL = ${SHELL} /home/lj/cvs/memcached/server/missing --run aclocal-1.7
+build_triplet = sparc-sun-solaris2.9
+host_triplet = sparc-sun-solaris2.9
+target_triplet = sparc-sun-solaris2.9
+ACLOCAL = ${SHELL} /home/andy/memcached-1.2.2/missing --run aclocal-1.7
 AMDEP_FALSE = #
 AMDEP_TRUE = 
-AMTAR = ${SHELL} /home/lj/cvs/memcached/server/missing --run tar
-AUTOCONF = ${SHELL} /home/lj/cvs/memcached/server/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/lj/cvs/memcached/server/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/lj/cvs/memcached/server/missing --run automake-1.7
-AWK = mawk
-CC = gcc
-CCDEPMODE = depmode=gcc3
-CFLAGS = -g -O2
-CPP = gcc -E
-CPPFLAGS = 
+AMTAR = ${SHELL} /home/andy/memcached-1.2.2/missing --run tar
+AUTOCONF = ${SHELL} /home/andy/memcached-1.2.2/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/andy/memcached-1.2.2/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/andy/memcached-1.2.2/missing --run automake-1.7
+AWK = nawk
+CC = /opt/SUNWspro/bin/cc
+CCDEPMODE = depmode=none
+CFLAGS = -I/usr/include -I/usr/local/packages/libevent-1.3b/include -I/opt/csw/include -I/opt/csw/include/openssl -I/opt/csw/gcc3/include -I/opt/csw/include/ncurses -I/opt/csw/gcc3/include/c++/3.4.5/ -xarch=v9a -xO3 -xmemalign=8s -xprefetch=auto,explicit
+CPP = /opt/SUNWspro/bin/cc -E
+CPPFLAGS = -I/usr/local/packages/libevent-1.3b/include 
 CYGPATH_W = echo
 DEFS = -DHAVE_CONFIG_H
 DEPDIR = .deps
@@ -57,17 +57,17 @@
 ECHO_C = 
 ECHO_N = -n
 ECHO_T = 
-EGREP = grep -E
+EGREP = egrep
 EXEEXT = 
 INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s
-LDFLAGS = 
+LDFLAGS = -L/usr/local/packages/libevent-1.3b/lib -L/opt/csw/lib -fast -L/opt/csw/gcc3/lib -xO3 -xarch=v9a -L/usr/local/packages/libevent-1.3b/lib -lresolv
 LIBOBJS = 
-LIBS = -lpthread  -levent
+LIBS = -lmalloc -lnsl -lsocket  -levent
 LTLIBOBJS = 
-MAKEINFO = ${SHELL} /home/lj/cvs/memcached/server/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/andy/memcached-1.2.2/missing --run makeinfo
 OBJEXT = o
 PACKAGE = memcached
 PACKAGE_BUGREPORT = brad at danga.com
@@ -77,47 +77,47 @@
 PACKAGE_VERSION = 1.2.2
 PATH_SEPARATOR = :
 SET_MAKE = 
-SHELL = /bin/sh
+SHELL = /bin/bash
 STRIP = 
 VERSION = 1.2.2
-ac_ct_CC = gcc
+ac_ct_CC = /opt/SUNWspro/bin/cc
 ac_ct_STRIP = 
-am__fastdepCC_FALSE = #
-am__fastdepCC_TRUE = 
+am__fastdepCC_FALSE = 
+am__fastdepCC_TRUE = #
 am__include = include
 am__leading_dot = .
 am__quote = 
 bindir = ${exec_prefix}/bin
-build = i686-pc-linux-gnu
+build = sparc-sun-solaris2.9
 build_alias = 
-build_cpu = i686
-build_os = linux-gnu
-build_vendor = pc
+build_cpu = sparc
+build_os = solaris2.9
+build_vendor = sun
 datadir = ${prefix}/share
 exec_prefix = ${prefix}
-host = i686-pc-linux-gnu
+host = sparc-sun-solaris2.9
 host_alias = 
-host_cpu = i686
-host_os = linux-gnu
-host_vendor = pc
+host_cpu = sparc
+host_os = solaris2.9
+host_vendor = sun
 includedir = ${prefix}/include
 infodir = ${prefix}/info
-install_sh = /home/lj/cvs/memcached/server/install-sh
+install_sh = /home/andy/memcached-1.2.2/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localstatedir = ${prefix}/var
 mandir = ${prefix}/man
 oldincludedir = /usr/include
-prefix = /usr/local
+prefix = /usr/local/packages/memcached-1.2.2
 program_transform_name = s,x,x,
 sbindir = ${exec_prefix}/sbin
 sharedstatedir = ${prefix}/com
 sysconfdir = ${prefix}/etc
-target = i686-pc-linux-gnu
+target = sparc-sun-solaris2.9
 target_alias = 
-target_cpu = i686
-target_os = linux-gnu
-target_vendor = pc
+target_cpu = sparc
+target_os = solaris2.9
+target_vendor = sun
 man_MANS = memcached.1
 
 EXTRA_DIST = *.txt
Common subdirectories: t/memcached-1.2.2//t/lib and src/memcached-1.2.2//t/lib


More information about the memcached mailing list