]> err.no Git - varnish/commitdiff
Fix build on MacOS X: add a fake clock_gettime() and fix some includes.
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 9 Oct 2006 09:58:58 +0000 (09:58 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 9 Oct 2006 09:58:58 +0000 (09:58 +0000)
WARNING: varnish will build and run, but the lack of a monotonic clock
may lead to strange behaviour if the clock is stepped (rather than skewed)
while varnish is running.

Thanks to Niklas Saers for providing a test environment.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1145 d4fa192b-c00b-0410-8231-f00ffab90ce4

22 files changed:
varnish-cache/bin/varnishd/cache_acceptor.c
varnish-cache/bin/varnishd/cache_acceptor_epoll.c
varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
varnish-cache/bin/varnishd/cache_acceptor_poll.c
varnish-cache/bin/varnishd/cache_ban.c
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_pass.c
varnish-cache/bin/varnishd/cache_pipe.c
varnish-cache/bin/varnishd/cache_response.c
varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/bin/varnishd/cache_vrt_acl.c
varnish-cache/bin/varnishd/cache_vrt_re.c
varnish-cache/bin/varnishd/hash_simple_list.c
varnish-cache/bin/varnishd/mgt_event.c
varnish-cache/bin/varnishd/rfc2616.c
varnish-cache/bin/varnishd/storage_malloc.c
varnish-cache/bin/varnishstat/varnishstat.c
varnish-cache/configure.ac
varnish-cache/include/Makefile.am
varnish-cache/include/compat/clock_gettime.h [new file with mode: 0644]
varnish-cache/lib/libcompat/Makefile.am
varnish-cache/lib/libcompat/clock_gettime.c [new file with mode: 0644]

index 73d5ab5c630df9d1e2dd89fbd71b73970cc9c4a1..ddddaaacc612ec61d7ba9da00508d27a76de759e 100644 (file)
 #include <sys/types.h>
 #include <sys/socket.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #ifndef HAVE_SRANDOMDEV
 #include "compat/srandomdev.h"
 #endif
index 6a29422de30590c182daf847598f58051d179a07..be5796c143c4b71f9046700793edff24425525be 100644 (file)
 
 #include <sys/epoll.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "heritage.h"
 #include "shmlog.h"
 #include "cache.h"
index 41545da83dd7c9cc0a7e9a51335fded0fe9ef466..a82eec9997806214fd0ed163694009dc90a33c8a 100644 (file)
 
 #include <sys/event.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "heritage.h"
 #include "shmlog.h"
 #include "cache.h"
index c6b3e50507e0db85ba9d07e926840a923c43731d..6e16d5a5f386cf423ac89c240a1a67fa83eb648d 100644 (file)
 #include <unistd.h>
 #include <poll.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "heritage.h"
 #include "shmlog.h"
 #include "cache.h"
index dea282886ceed4432edd73c03b482d6b426bf9a7..d5a7799056c9ea89ddf7e779aaa95a85326814dc 100644 (file)
@@ -31,6 +31,8 @@
  * Ban processing
  */
 
+#include <sys/types.h>
+
 #include <stdlib.h>
 #include <string.h>
 #include <regex.h>
index fa3c12ca1d94f817468f1e438edbc519b8ee3f75..0714599f40c09c3f33e2e4458f099be76767d35b 100644 (file)
@@ -60,6 +60,10 @@ DOT start -> RECV
 #include <string.h>
 #include <unistd.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "shmlog.h"
 #include "vcl.h"
 #include "cache.h"
index 7df39b4737b0173179729057c973928a0a3b6559..3861c98acbbb570dcfba0dd5ea9b8a872a847300 100644 (file)
 #include <sys/socket.h>
 #include <netdb.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "shmlog.h"
 #include "cache.h"
 
index 5bf99156eaed38499ec5afd119b566e66398c75b..359ddaa079abd4f852bd6a314f9b07a76437e45e 100644 (file)
 #include <stdlib.h>
 #include <sys/socket.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "shmlog.h"
 #include "heritage.h"
 #include "cache.h"
index 0ba7db105381b6772aca79239ce7f0c0baf39aa5..b882485ee8d19591bd69042df73de4f532c00ba8 100644 (file)
 #include <sys/types.h>
 #include <sys/time.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "shmlog.h"
 #include "heritage.h"
 #include "cache.h"
index 936384868b9388925dec9061bb16a4adbb57a094..0dffc9b2319028fe181b0370ac8cfaffb8963d19 100644 (file)
@@ -31,6 +31,7 @@
  * Runtime support for compiled VCL programs
  */
 
+#include <sys/types.h>
 
 #include <stdio.h>
 #include <string.h>
index 9ce33085d419866da10fcb1b223a3188ec588df4..ad26b1dd1069e66c7ab462986fd2a2f1783a8b91 100644 (file)
@@ -34,6 +34,8 @@
  * XXX: a refresh facility.
  */
 
+#include <sys/types.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
index 5318bb0d2873984f8bbc01d7b6af43ab9e1ecd87..36ce083e0c0a3fe477a6244e94cababca1cde80d 100644 (file)
@@ -31,6 +31,8 @@
  * Runtime support for compiled VCL programs, regexps
  */
 
+#include <sys/types.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
index a5785a70ed578b63790a6873d7191514296421af..9d294fa05972e9b9b106bf44c381b3b8a447d58a 100644 (file)
@@ -31,6 +31,8 @@
  * This is the reference hash(/lookup) implementation
  */
 
+#include <sys/types.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index b98bdaad47b0d616f9b086435ae9de3c1822aab1..112b11d61563a81f2e6630e971ad6b9958bbdc7c 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "mgt.h"
 #include "mgt_event.h"
 #include "miniobj.h"
index fdfc3d5f2336d8ad22740eff336edabc120b09c1..be56c743b8af1821d1295593f2a38707c4b78124 100644 (file)
@@ -29,6 +29,8 @@
  * $Id$
  */
 
+#include <sys/types.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
index 2a24fc254b6b5de790c029a2854386afc6c8e9cb..0ddd20aec8a44e07b3dd4a6a2687b06468d0b3db 100644 (file)
@@ -31,6 +31,8 @@
  * Storage method based on malloc(3)
  */
 
+#include <sys/types.h>
+
 #include <stdlib.h>
 
 #include "cache.h"
index 93374d348e34bb009514bcbbf42dd7824f79ed9b..b2305b92597bf0705b9cf5a753399fdcdb98e27d 100644 (file)
 #include <curses.h>
 #include <time.h>
 
+#ifndef HAVE_CLOCK_GETTIME
+#include "compat/clock_gettime.h"
+#endif
+
 #include "libvarnish.h"
 #include "shmlog.h"
 #include "varnishapi.h"
index a9ffae52ba3d4bc1e9fed433dae59bd06a844392..95182bec0e19328af6da9d26d21d229cc3409976 100644 (file)
@@ -78,6 +78,7 @@ AC_CHECK_FUNCS([srandomdev])
 AC_CHECK_FUNCS([strlcat strlcpy])
 AC_CHECK_FUNCS([strndup])
 AC_CHECK_FUNCS([vis strvis strvisx])
+AC_CHECK_FUNCS([clock_gettime])
 
 # Check which mechanism to use for the acceptor
 AC_CHECK_FUNCS([kqueue])
index e9a5e28b8c87adbbb78ad555c74456915ff83bba..af9f1aa9cc8e266ab061fcf94b57a8b79870787a 100644 (file)
@@ -6,6 +6,7 @@ noinst_HEADERS = \
        cli_common.h \
        cli_priv.h \
        compat/asprintf.h \
+       compat/clock_gettime.h \
        compat/setproctitle.h \
        compat/srandomdev.h \
        compat/strlcat.h \
diff --git a/varnish-cache/include/compat/clock_gettime.h b/varnish-cache/include/compat/clock_gettime.h
new file mode 100644 (file)
index 0000000..03367dd
--- /dev/null
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Dag-Erling Smørgrav <des@linpro.no>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ */
+
+#ifndef COMPAT_CLOCK_GETTIME_H_INCLUDED
+#define COMPAT_CLOCK_GETTIME_H_INCLUDED
+
+#ifndef HAVE_CLOCK_GETTIME
+typedef enum {
+       CLOCK_REALTIME,
+       CLOCK_MONOTONIC,
+} clockid_t;
+
+int clock_gettime(clockid_t clk_id, struct timespec *tp);
+#endif
+
+#endif
index 885d3a075677a6db6446e5f0b350f5f272199b9c..7bbeada8d58b07ad90fbd24b0a995eb59cefb27f 100644 (file)
@@ -6,6 +6,7 @@ noinst_LIBRARIES = libcompat.a
 
 libcompat_a_SOURCES = \
        asprintf.c \
+       clock_gettime.c \
        vasprintf.c \
        setproctitle.c \
        srandomdev.c \
diff --git a/varnish-cache/lib/libcompat/clock_gettime.c b/varnish-cache/lib/libcompat/clock_gettime.c
new file mode 100644 (file)
index 0000000..7bca9e6
--- /dev/null
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Dag-Erling Smørgrav <des@linpro.no>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef HAVE_CLOCK_GETTIME
+
+#include <sys/time.h>
+
+#include <errno.h>
+#include <time.h>
+
+#include "compat/clock_gettime.h"
+
+int
+clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+       struct timeval tv;
+
+       switch (clk_id) {
+       case CLOCK_REALTIME:
+       case CLOCK_MONOTONIC:
+               if (gettimeofday(&tv, NULL) != 0)
+                       return (-1);
+               tp->tv_sec = tv.tv_sec;
+               tp->tv_nsec = tv.tv_usec * 1000;
+               return (0);
+       default:
+               errno = EINVAL;
+               return (-1);
+       }
+}
+#endif