Commit f597b86d authored by Federico G. Schwindt's avatar Federico G. Schwindt

Drop libvarnishcompat

Move its remainings to libvarnishapi and include them conditionally.
parent bb44c36c
...@@ -14,6 +14,5 @@ varnishadm_CFLAGS = @LIBEDIT_CFLAGS@ \ ...@@ -14,6 +14,5 @@ varnishadm_CFLAGS = @LIBEDIT_CFLAGS@ \
varnishadm_LDADD = \ varnishadm_LDADD = \
$(top_builddir)/lib/libvarnish/libvarnish.a \ $(top_builddir)/lib/libvarnish/libvarnish.a \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
${PTHREAD_LIBS} ${RT_LIBS} ${NET_LIBS} @LIBEDIT_LIBS@ ${LIBM} \ ${PTHREAD_LIBS} ${RT_LIBS} ${NET_LIBS} @LIBEDIT_LIBS@ ${LIBM} \
@SAN_LDFLAGS@ @SAN_LDFLAGS@
...@@ -151,7 +151,6 @@ varnishd_LDFLAGS = -export-dynamic ...@@ -151,7 +151,6 @@ varnishd_LDFLAGS = -export-dynamic
varnishd_LDADD = \ varnishd_LDADD = \
$(top_builddir)/lib/libvarnish/libvarnish.a \ $(top_builddir)/lib/libvarnish/libvarnish.a \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvcc/libvcc.a \ $(top_builddir)/lib/libvcc/libvcc.a \
$(top_builddir)/lib/libvgz/libvgz.a \ $(top_builddir)/lib/libvgz/libvgz.a \
@SAN_LDFLAGS@ \ @SAN_LDFLAGS@ \
......
...@@ -29,12 +29,7 @@ ...@@ -29,12 +29,7 @@
#include "config.h" #include "config.h"
#ifndef HAVE_EXECINFO_H
#include "compat/execinfo.h"
#else
#include <execinfo.h> #include <execinfo.h>
#endif
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
......
...@@ -29,7 +29,6 @@ flexelint \ ...@@ -29,7 +29,6 @@ flexelint \
storage/*.c \ storage/*.c \
waiter/*.c \ waiter/*.c \
../../lib/libvarnish/*.c \ ../../lib/libvarnish/*.c \
../../lib/libvarnishcompat/execinfo.c \
../../lib/libvcc/*.c \ ../../lib/libvcc/*.c \
../../lib/libvmod_std/*.c \ ../../lib/libvmod_std/*.c \
../../lib/libvmod_debug/*.c \ ../../lib/libvmod_debug/*.c \
......
...@@ -15,7 +15,6 @@ varnishhist_CFLAGS = \ ...@@ -15,7 +15,6 @@ varnishhist_CFLAGS = \
@SAN_CFLAGS@ @SAN_CFLAGS@
varnishhist_LDADD = \ varnishhist_LDADD = \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
-lm \ -lm \
@SAN_LDFLAGS@ \ @SAN_LDFLAGS@ \
......
...@@ -15,7 +15,6 @@ varnishlog_CFLAGS = \ ...@@ -15,7 +15,6 @@ varnishlog_CFLAGS = \
@SAN_CFLAGS@ @SAN_CFLAGS@
varnishlog_LDADD = \ varnishlog_LDADD = \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
@SAN_LDFLAGS@ \ @SAN_LDFLAGS@ \
${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS}
...@@ -17,7 +17,6 @@ varnishncsa_CFLAGS = \ ...@@ -17,7 +17,6 @@ varnishncsa_CFLAGS = \
@SAN_CFLAGS@ @SAN_CFLAGS@
varnishncsa_LDADD = \ varnishncsa_LDADD = \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
@SAN_LDFLAGS@ \ @SAN_LDFLAGS@ \
${RT_LIBS} ${LIBM} ${RT_LIBS} ${LIBM}
...@@ -17,7 +17,6 @@ varnishstat_CFLAGS = \ ...@@ -17,7 +17,6 @@ varnishstat_CFLAGS = \
@SAN_CFLAGS@ @SAN_CFLAGS@
varnishstat_LDADD = \ varnishstat_LDADD = \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
@SAN_LDFLAGS@ \ @SAN_LDFLAGS@ \
@CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} @CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS}
......
...@@ -51,7 +51,6 @@ varnishtest_SOURCES = \ ...@@ -51,7 +51,6 @@ varnishtest_SOURCES = \
varnishtest_LDADD = \ varnishtest_LDADD = \
$(top_builddir)/lib/libvarnish/libvarnish.a \ $(top_builddir)/lib/libvarnish/libvarnish.a \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
$(top_builddir)/lib/libvgz/libvgz.a \ $(top_builddir)/lib/libvgz/libvgz.a \
@SAN_LDFLAGS@ \ @SAN_LDFLAGS@ \
......
...@@ -15,7 +15,6 @@ varnishtop_CFLAGS = \ ...@@ -15,7 +15,6 @@ varnishtop_CFLAGS = \
@SAN_CFLAGS@ @SAN_CFLAGS@
varnishtop_LDADD = \ varnishtop_LDADD = \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \
@SAN_LDFLAGS@ \ @SAN_LDFLAGS@ \
@CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} @CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS}
...@@ -190,7 +190,6 @@ AC_CHECK_HEADERS([sys/personality.h]) ...@@ -190,7 +190,6 @@ AC_CHECK_HEADERS([sys/personality.h])
AC_CHECK_HEADERS([sys/statvfs.h]) AC_CHECK_HEADERS([sys/statvfs.h])
AC_CHECK_HEADERS([sys/vfs.h]) AC_CHECK_HEADERS([sys/vfs.h])
AC_CHECK_HEADERS([endian.h]) AC_CHECK_HEADERS([endian.h])
AC_CHECK_HEADERS([execinfo.h])
AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>]) AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
AC_CHECK_HEADERS([priv.h]) AC_CHECK_HEADERS([priv.h])
...@@ -284,10 +283,10 @@ case $target in ...@@ -284,10 +283,10 @@ case $target in
esac esac
AC_SUBST(JEMALLOC_LDADD) AC_SUBST(JEMALLOC_LDADD)
# These functions are provided by libcompat on platforms where they
# are not available
AC_CHECK_FUNCS([setproctitle]) AC_CHECK_FUNCS([setproctitle])
AC_SEARCH_LIBS(backtrace, [execinfo],[AC_DEFINE([HAVE_BACKTRACE],[1],[Define to 1 if the backtrace function exists])]) AC_SEARCH_LIBS(backtrace, [execinfo], [], [
AC_MSG_ERROR([Could not find backtrace() support])
])
# white lie - we don't actually test it # white lie - we don't actually test it
AC_MSG_CHECKING([whether daemon() works]) AC_MSG_CHECKING([whether daemon() works])
case $target in case $target in
...@@ -300,6 +299,7 @@ case $target in ...@@ -300,6 +299,7 @@ case $target in
AC_CHECK_FUNCS([daemon]) AC_CHECK_FUNCS([daemon])
;; ;;
esac esac
AM_CONDITIONAL(HAVE_DAEMON, [test "x$HAVE_DAEMON" != "xno"])
AC_SYS_LARGEFILE AC_SYS_LARGEFILE
...@@ -699,7 +699,6 @@ AC_CONFIG_FILES([ ...@@ -699,7 +699,6 @@ AC_CONFIG_FILES([
lib/Makefile lib/Makefile
lib/libvarnish/Makefile lib/libvarnish/Makefile
lib/libvarnishapi/Makefile lib/libvarnishapi/Makefile
lib/libvarnishcompat/Makefile
lib/libvcc/Makefile lib/libvcc/Makefile
lib/libvgz/Makefile lib/libvgz/Makefile
lib/libvmod_debug/Makefile lib/libvmod_debug/Makefile
......
...@@ -79,7 +79,6 @@ nobase_pkginclude_HEADERS += \ ...@@ -79,7 +79,6 @@ nobase_pkginclude_HEADERS += \
nobase_noinst_HEADERS = \ nobase_noinst_HEADERS = \
binary_heap.h \ binary_heap.h \
compat/daemon.h \ compat/daemon.h \
compat/execinfo.h \
vfl.h \ vfl.h \
libvcc.h \ libvcc.h \
vcli_serve.h \ vcli_serve.h \
......
/*
* Copyright (c) 2003 Maxim Sobolev <sobomax@FreeBSD.org>
* All rights reserved.
*
* 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 THE 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 THE 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.
*
*/
#ifndef COMPAT_EXECINFO_H_INCLUDED
#define COMPAT_EXECINFO_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
int backtrace(void **, int);
char ** backtrace_symbols(void *const *, int);
#ifdef __cplusplus
}
#endif
#endif /* COMPAT_EXECINFO_H_INCLUDED */
# #
SUBDIRS = \ SUBDIRS = \
libvarnishcompat \
libvarnish \ libvarnish \
libvarnishapi \ libvarnishapi \
libvcc \ libvcc \
......
...@@ -44,6 +44,10 @@ libvarnishapi_la_SOURCES = \ ...@@ -44,6 +44,10 @@ libvarnishapi_la_SOURCES = \
vxp_fixed_token.c \ vxp_fixed_token.c \
libvarnishapi.map libvarnishapi.map
if ! HAVE_DAEMON
libvarnishapi_la_SOURCES += daemon.c
endif
libvarnishapi_la_CFLAGS = \ libvarnishapi_la_CFLAGS = \
-DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \ -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \
@SAN_CFLAGS@ @SAN_CFLAGS@
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
//lint -e{766} //lint -e{766}
#include "config.h" #include "config.h"
#ifndef HAVE_DAEMON
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
...@@ -92,5 +90,3 @@ varnish_daemon(int nochdir, int noclose) ...@@ -92,5 +90,3 @@ varnish_daemon(int nochdir, int noclose)
} }
return (0); return (0);
} }
#endif
#
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_builddir)/include
AM_LDFLAGS = $(AM_LT_LDFLAGS)
pkglib_LTLIBRARIES = libvarnishcompat.la
libvarnishcompat_la_CFLAGS = \
@SAN_CFLAGS@
libvarnishcompat_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version \
@SAN_LDFLAGS@
libvarnishcompat_la_SOURCES = \
daemon.c \
execinfo.c
/*
* Copyright (c) 2003 Maxim Sobolev <sobomax@FreeBSD.org>
* All rights reserved.
*
* 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 THE 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 THE 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.
*/
//lint -e{766}
#include "config.h"
#ifndef HAVE_BACKTRACE
#include "compat/execinfo.h"
#if defined (__GNUC__) && __GNUC__ >= 4 /* XXX Correct version to check for ? */
#include <sys/types.h>
#include <sys/uio.h>
#include <dlfcn.h>
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static void *getreturnaddr(int);
static void *getframeaddr(int);
int
backtrace(void **buffer, int size)
{
int i;
for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) {
buffer[i - 1] = getreturnaddr(i);
if (buffer[i - 1] == NULL)
break;
}
return (i - 1);
}
/*
* XXX: This implementation should be changed to a much more conservative
* XXX: memory strategy: Allocate 4k up front, realloc 4K more as needed.
*/
char **
backtrace_symbols(void *const *buffer, int size)
{
size_t clen, alen;
int i;
char **rval;
clen = size * sizeof(char *);
rval = malloc(clen);
if (rval == NULL)
return (NULL);
for (i = 0; i < size; i++) {
#ifdef HAVE_DLADDR
{
Dl_info info;
int offset;
if (dladdr(buffer[i], &info) != 0) {
if (info.dli_sname == NULL)
info.dli_sname = "?";
if (info.dli_saddr == NULL)
info.dli_saddr = buffer[i];
offset = (const char*)buffer[i] -
(const char*)info.dli_saddr;
/* "0x01234567 <function+offset> at filename" */
alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
2 + /* " <" */
strlen(info.dli_sname) + /* "function" */
1 + /* "+" */
10 + /* "offset */
5 + /* "> at " */
strlen(info.dli_fname) + /* "filename" */
1; /* "\0" */
rval = realloc(rval, clen + alen);
if (rval == NULL)
return NULL;
(void)snprintf((char *) rval + clen, alen,
"%p <%s+%d> at %s", buffer[i], info.dli_sname,
offset, info.dli_fname);
rval[i] = (char *) clen;
clen += alen;
continue;
}
}
#endif
alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
1; /* "\0" */
rval = realloc(rval, clen + alen);
if (rval == NULL)
return NULL;
(void)snprintf((char *) rval + clen, alen, "%p", buffer[i]);
rval[i] = (char *) clen;
clen += alen;
}
for (i = 0; i < size; i++)
rval[i] += (long) rval;
return (rval);
}
/* Binary expansion */
#define DO_P2_TIMES_1(x) DO_P2_TIMES_0(x); DO_P2_TIMES_0((x) + (1<<0))
#define DO_P2_TIMES_2(x) DO_P2_TIMES_1(x); DO_P2_TIMES_1((x) + (1<<1))
#define DO_P2_TIMES_3(x) DO_P2_TIMES_2(x); DO_P2_TIMES_2((x) + (1<<2))
#define DO_P2_TIMES_4(x) DO_P2_TIMES_3(x); DO_P2_TIMES_3((x) + (1<<3))
#define DO_P2_TIMES_5(x) DO_P2_TIMES_4(x); DO_P2_TIMES_4((x) + (1<<4))
#define DO_P2_TIMES_6(x) DO_P2_TIMES_5(x); DO_P2_TIMES_5((x) + (1<<5))
#define DO_P2_TIMES_7(x) DO_P2_TIMES_6(x); DO_P2_TIMES_6((x) + (1<<6))
static void *
getreturnaddr(int level)
{
switch(level) {
#define DO_P2_TIMES_0(x) case (x): return __builtin_return_address((x) + 1)
DO_P2_TIMES_7(0);
#undef DO_P2_TIMES_0
default: return NULL;
}
}
static void *
getframeaddr(int level)
{
switch(level) {
#define DO_P2_TIMES_0(x) case (x): return __builtin_frame_address((x) + 1)
DO_P2_TIMES_7(0);
#undef DO_P2_TIMES_0
default: return NULL;
}
}
#else
int
backtrace(void **buffer, int size)
{
(void)buffer;
(void)size;
return (0);
}
char **
backtrace_symbols(void *const *buffer, int size)
{
(void)buffer;
(void)size;
return (0);
}
#endif /* (__GNUC__) && __GNUC__ >= 4 */
#endif /* HAVE_BACKTRACE */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment