From 3688d7f308877dd2e2c0c786ffa1e46d6bb34a13 Mon Sep 17 00:00:00 2001
From: antirez <antirez@metal.(none)>
Date: Thu, 1 Jul 2010 21:13:38 +0200
Subject: [PATCH] Compilation fixed on Linux after the source code split

---
 src/aof.c     | 4 ++++
 src/debug.c   | 2 ++
 src/rdb.c     | 5 +++++
 src/redis.c   | 7 ++++---
 src/redis.h   | 1 +
 src/ziplist.c | 2 +-
 6 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/aof.c b/src/aof.c
index 1f615cf1..c92798c5 100644
--- a/src/aof.c
+++ b/src/aof.c
@@ -3,6 +3,10 @@
 #include <signal.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
 
 /* Called when the user switches from "appendonly yes" to "appendonly no"
  * at runtime using the CONFIG command. */
diff --git a/src/debug.c b/src/debug.c
index 10b620d6..ba183d72 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -1,6 +1,8 @@
 #include "redis.h"
 #include "sha1.h"   /* SHA1 is used for DEBUG DIGEST */
 
+#include <arpa/inet.h>
+
 /* ================================= Debugging ============================== */
 
 /* Compute the sha1 of string at 's' with 'len' bytes long.
diff --git a/src/rdb.c b/src/rdb.c
index 5bda5e56..509c70c3 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -2,6 +2,11 @@
 #include "lzf.h"    /* LZF compression library */
 
 #include <math.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <arpa/inet.h>
 
 int rdbSaveType(FILE *fp, unsigned char type) {
     if (fwrite(&type,1,1,fp) == 0) return -1;
diff --git a/src/redis.c b/src/redis.c
index 5f539216..86536b43 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -41,7 +41,6 @@
 #include <assert.h>
 #include <ctype.h>
 #include <stdarg.h>
-#include <inttypes.h>
 #include <arpa/inet.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -1443,8 +1442,10 @@ void *getMcontextEip(ucontext_t *uc) {
   #else
     return (void*) uc->uc_mcontext->__ss.__eip;
   #endif
-#elif defined(__i386__) || defined(__X86_64__) || defined(__x86_64__)
-    return (void*) uc->uc_mcontext.gregs[REG_EIP]; /* Linux 32/64 bit */
+#elif defined(__i386__)
+    return (void*) uc->uc_mcontext.gregs[14]; /* Linux 32 */
+#elif defined(__X86_64__) || defined(__x86_64__)
+    return (void*) uc->uc_mcontext.gregs[16]; /* Linux 64 */
 #elif defined(__ia64__) /* Linux IA64 */
     return (void*) uc->uc_mcontext.sc_ip;
 #else
diff --git a/src/redis.h b/src/redis.h
index e54caa2a..545a3e0f 100644
--- a/src/redis.h
+++ b/src/redis.h
@@ -15,6 +15,7 @@
 #include <limits.h>
 #include <unistd.h>
 #include <errno.h>
+#include <inttypes.h>
 
 #include "ae.h"     /* Event driven programming library */
 #include "sds.h"    /* Dynamic safe strings */
diff --git a/src/ziplist.c b/src/ziplist.c
index 4b9d0fad..6c5827b9 100644
--- a/src/ziplist.c
+++ b/src/ziplist.c
@@ -551,7 +551,7 @@ void ziplistRepr(unsigned char *zl) {
         if (entry.encoding == ZIP_ENC_RAW) {
             fwrite(p,entry.len,1,stdout);
         } else {
-            printf("%lld", zipLoadInteger(p,entry.encoding));
+            printf("%lld", (long long) zipLoadInteger(p,entry.encoding));
         }
         printf("\n");
         p += entry.len;