Created
April 10, 2010 22:06
-
-
Save tyler/362328 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile b/Makefile | |
index fe1e2b2..22546c1 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -5,7 +5,7 @@ PHP_EXT_BUILD=$(REDIS_HOME)/php/build | |
libredis: src/batch.o src/connection.o src/ketama.o src/md5.o src/module.o src/parser.o src/buffer.o | |
mkdir -p lib | |
- gcc -shared -o"lib/libredis.so" ./src/batch.o ./src/buffer.o ./src/connection.o ./src/ketama.o ./src/md5.o ./src/module.o ./src/parser.o -lm -lrt | |
+ gcc -shared -o "lib/libredis.so" ./src/batch.o ./src/buffer.o ./src/connection.o ./src/ketama.o ./src/md5.o ./src/module.o ./src/parser.o -lm | |
php_ext: | |
rm -rf $(PHP_EXT_BUILD) | |
diff --git a/src/connection.c b/src/connection.c | |
index 9b04541..f09645a 100644 | |
--- a/src/connection.c | |
+++ b/src/connection.c | |
@@ -31,6 +31,29 @@ | |
#include "batch.h" | |
+#ifndef CLOCK_MONOTONIC | |
+ | |
+#include <mach/mach_time.h> | |
+#define CLOCK_MONOTONIC 1 | |
+typedef int clockid_t; | |
+ | |
+int clock_gettime(clockid_t clk_id, struct timespec *tp) { | |
+ uint64_t t = mach_absolute_time(); | |
+ static mach_timebase_info_data_t info = {0,0}; | |
+ if (info.denom == 0) | |
+ mach_timebase_info(&info); | |
+ | |
+ uint64_t t_nano = t * (info.numer / info.denom); | |
+ | |
+ tp->tv_sec = t_nano * 1e-9; | |
+ tp->tv_nsec = t_nano - (tp->tv_sec * 1e9); | |
+ | |
+ return 0; | |
+} | |
+ | |
+#endif | |
+ | |
+ | |
#define ADDR_SIZE 22 //max size of ip:port addr string | |
typedef enum _ConnectionState |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment