From: Trond Norbye Date: Wed, 7 Jan 2009 13:28:25 +0000 (+0100) Subject: Fixed the support for DTrace so that it also builds on Mac OSX X-Git-Tag: 0.26~24 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=5ef15e8c3826baead436f0d4fe6a4889956a3124;p=m6w6%2Flibmemcached Fixed the support for DTrace so that it also builds on Mac OSX --- diff --git a/.hgignore b/.hgignore index 1c1d8c09..323f7477 100644 --- a/.hgignore +++ b/.hgignore @@ -30,7 +30,7 @@ tests/atomsmasher tests/startservers tests/stopservers tests/udptest - +^libmemcached/dtrace_probes.h$ Makefile(.in)?$ diff --git a/config/dtrace.m4 b/config/dtrace.m4 index af27ed49..ee39c69a 100644 --- a/config/dtrace.m4 +++ b/config/dtrace.m4 @@ -4,16 +4,33 @@ dnl --------------------------------------------------------------------------- AC_ARG_ENABLE(dtrace, [ --enable-dtrace Build with support for the DTRACE.], [ + AC_PATH_PROG([DTRACE], [dtrace], "no", [/usr/sbin:$PATH]) + if test "x$DTRACE" != "xno"; then AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support]) - AC_CHECK_PROGS(DTRACE, dtrace) - ENABLE_DTRACE="yes" - AC_SUBST(DTRACEFLAGS) + DTRACE_HEADER=dtrace_probes.h + + # DTrace on MacOSX does not use -G option + $DTRACE -G -o conftest.$$ -s libmemcached/libmemcached_probes.d 2>/dev/zero + if test $? -eq 0 + then + DTRACE_OBJ=libmemcached_probes.lo + rm conftest.$$ + fi + + ENABLE_DTRACE="yes" AC_SUBST(HAVE_DTRACE) + else + AC_MSG_ERROR([Need dtrace binary and OS support.]) + fi ], [ ENABLE_DTRACE="no" ] ) + +AC_SUBST(DTRACEFLAGS) +AC_SUBST(DTRACE_HEADER) +AC_SUBST(DTRACE_OBJ) AM_CONDITIONAL([HAVE_DTRACE], [ test "$ENABLE_DTRACE" = "yes" ]) dnl --------------------------------------------------------------------------- dnl End Macro: DTRACE_TEST diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index ec62fb2e..7e117b94 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -1,5 +1,7 @@ EXTRA_DIST = libmemcached_probes.d memcached/README.txt +BUILT_SOURCES= @DTRACE_HEADER@ + INCLUDES = -I$(top_builddir) LIBS = @LIBS@ @@ -73,18 +75,23 @@ libmemcached_la_SOURCES = crc.c \ jenkins_hash.c \ byteorder.c -libmemcached_la_LIBADD = +libmemcached_la_DEPENDENCIES = @DTRACE_OBJ@ +libmemcached_la_LIBADD = @DTRACE_OBJ@ libmemcached_la_LDFLAGS = -version-info $(MEMCACHED_LIBRARY_VERSION) -if HAVE_DTRACE - libmemcached_la_LIBADD += libmemcached_probes.o -endif +dtrace_probes.h: libmemcached_probes.d + $(DTRACE) $(DTRACEFLAGS) -o dtrace_probes.tmp -h -s libmemcached_probes.d + sed "s/#include //g" dtrace_probes.tmp > dtrace_probes.h + rm dtrace_probes.tmp + + +# So libtool doesn't support dtrace, but just copy one of the existing +# lo-file and replace the file name ;-) +libmemcached_probes.lo: libmemcached_probes.o + sed "s,jenkins_hash,libmemcached_probes,g" jenkins_hash.lo > libmemcached_probes.tmp + mv libmemcached_probes.tmp libmemcached_probes.lo -libmemcached_probes.h: libmemcached_probes.d - $(DTRACE) $(DTRACEFLAGS) -h -s libmemcached_probes.d - mv libmemcached_probes.h libmemcached_probes.h.bak - sed "s/#include //g" libmemcached_probes.h.bak > libmemcached_probes.h - rm libmemcached_probes.h.bak +libmemcached_probes.o: $(libmemcached_la_OBJECTS) + $(DTRACE) $(DTRACEFLAGS) -o .libs/libmemcached_probes.o -G -s libmemcached_probes.d `grep pic_object *.lo | cut -f 2 -d\' | grep -v non_pic_object` + $(DTRACE) $(DTRACEFLAGS) -o libmemcached_probes.o -G -s libmemcached_probes.d `grep non_pic_object *.lo | cut -f 2 -d\' ` -libmemcached_probes.o: - $(DTRACE) $(DTRACEFLAGS) -G -s libmemcached_probes.d $(DTRACEFILES) diff --git a/libmemcached/common.h b/libmemcached/common.h index 3e688dc9..ab61a22c 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -52,13 +52,6 @@ #define unlikely(x) if(__builtin_expect((x), 0)) #endif - -#ifdef HAVE_DTRACE -#define _DTRACE_VERSION 1 -#else -#undef _DTRACE_VERSION -#endif - #include "libmemcached_probes.h" #define MEMCACHED_BLOCK_SIZE 1024 diff --git a/libmemcached/libmemcached_probes.h b/libmemcached/libmemcached_probes.h index 2c8114be..7db979ce 100644 --- a/libmemcached/libmemcached_probes.h +++ b/libmemcached/libmemcached_probes.h @@ -1,155 +1,24 @@ /* - * Generated by dtrace(1M). + * This file contains the definition of the various probes supported by + * libmemcached. Currently it only support DTRACE, but just create an + * implementation of the following macros to create your own sort of + * probing :) */ +#ifndef LIBMEMCACHED_PROBES_H +#define LIBMEMCACHED_PROBES_H -#ifndef _LIBMEMCACHED_PROBES_H -#define _LIBMEMCACHED_PROBES_H - - - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _DTRACE_VERSION - -#define LIBMEMCACHED_MEMCACHED_ADD_END() \ - __dtrace_libmemcached___memcached_add_end() -#define LIBMEMCACHED_MEMCACHED_ADD_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_add_end() -#define LIBMEMCACHED_MEMCACHED_ADD_START() \ - __dtrace_libmemcached___memcached_add_start() -#define LIBMEMCACHED_MEMCACHED_ADD_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_add_start() -#define LIBMEMCACHED_MEMCACHED_CONNECT_END() \ - __dtrace_libmemcached___memcached_connect_end() -#define LIBMEMCACHED_MEMCACHED_CONNECT_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_connect_end() -#define LIBMEMCACHED_MEMCACHED_CONNECT_START() \ - __dtrace_libmemcached___memcached_connect_start() -#define LIBMEMCACHED_MEMCACHED_CONNECT_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_connect_start() -#define LIBMEMCACHED_MEMCACHED_DECREMENT_END() \ - __dtrace_libmemcached___memcached_decrement_end() -#define LIBMEMCACHED_MEMCACHED_DECREMENT_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_decrement_end() -#define LIBMEMCACHED_MEMCACHED_DECREMENT_START() \ - __dtrace_libmemcached___memcached_decrement_start() -#define LIBMEMCACHED_MEMCACHED_DECREMENT_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_decrement_start() -#define LIBMEMCACHED_MEMCACHED_DELETE_END() \ - __dtrace_libmemcached___memcached_delete_end() -#define LIBMEMCACHED_MEMCACHED_DELETE_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_delete_end() -#define LIBMEMCACHED_MEMCACHED_DELETE_START() \ - __dtrace_libmemcached___memcached_delete_start() -#define LIBMEMCACHED_MEMCACHED_DELETE_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_delete_start() -#define LIBMEMCACHED_MEMCACHED_FLUSH_END() \ - __dtrace_libmemcached___memcached_flush_end() -#define LIBMEMCACHED_MEMCACHED_FLUSH_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_flush_end() -#define LIBMEMCACHED_MEMCACHED_FLUSH_START() \ - __dtrace_libmemcached___memcached_flush_start() -#define LIBMEMCACHED_MEMCACHED_FLUSH_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_flush_start() -#define LIBMEMCACHED_MEMCACHED_GET_END() \ - __dtrace_libmemcached___memcached_get_end() -#define LIBMEMCACHED_MEMCACHED_GET_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_get_end() -#define LIBMEMCACHED_MEMCACHED_GET_START() \ - __dtrace_libmemcached___memcached_get_start() -#define LIBMEMCACHED_MEMCACHED_GET_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_get_start() -#define LIBMEMCACHED_MEMCACHED_INCREMENT_END() \ - __dtrace_libmemcached___memcached_increment_end() -#define LIBMEMCACHED_MEMCACHED_INCREMENT_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_increment_end() -#define LIBMEMCACHED_MEMCACHED_INCREMENT_START() \ - __dtrace_libmemcached___memcached_increment_start() -#define LIBMEMCACHED_MEMCACHED_INCREMENT_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_increment_start() -#define LIBMEMCACHED_MEMCACHED_MGET_END() \ - __dtrace_libmemcached___memcached_mget_end() -#define LIBMEMCACHED_MEMCACHED_MGET_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_mget_end() -#define LIBMEMCACHED_MEMCACHED_MGET_START() \ - __dtrace_libmemcached___memcached_mget_start() -#define LIBMEMCACHED_MEMCACHED_MGET_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_mget_start() -#define LIBMEMCACHED_MEMCACHED_REPLACE_END() \ - __dtrace_libmemcached___memcached_replace_end() -#define LIBMEMCACHED_MEMCACHED_REPLACE_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_replace_end() -#define LIBMEMCACHED_MEMCACHED_REPLACE_START() \ - __dtrace_libmemcached___memcached_replace_start() -#define LIBMEMCACHED_MEMCACHED_REPLACE_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_replace_start() -#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END() \ - __dtrace_libmemcached___memcached_server_add_end() -#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_server_add_end() -#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START() \ - __dtrace_libmemcached___memcached_server_add_start() -#define LIBMEMCACHED_MEMCACHED_SERVER_ADD_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_server_add_start() -#define LIBMEMCACHED_MEMCACHED_SET_END() \ - __dtrace_libmemcached___memcached_set_end() -#define LIBMEMCACHED_MEMCACHED_SET_END_ENABLED() \ - __dtraceenabled_libmemcached___memcached_set_end() -#define LIBMEMCACHED_MEMCACHED_SET_START() \ - __dtrace_libmemcached___memcached_set_start() -#define LIBMEMCACHED_MEMCACHED_SET_START_ENABLED() \ - __dtraceenabled_libmemcached___memcached_set_start() - - -extern void __dtrace_libmemcached___memcached_add_end(void); -extern int __dtraceenabled_libmemcached___memcached_add_end(void); -extern void __dtrace_libmemcached___memcached_add_start(void); -extern int __dtraceenabled_libmemcached___memcached_add_start(void); -extern void __dtrace_libmemcached___memcached_connect_end(void); -extern int __dtraceenabled_libmemcached___memcached_connect_end(void); -extern void __dtrace_libmemcached___memcached_connect_start(void); -extern int __dtraceenabled_libmemcached___memcached_connect_start(void); -extern void __dtrace_libmemcached___memcached_decrement_end(void); -extern int __dtraceenabled_libmemcached___memcached_decrement_end(void); -extern void __dtrace_libmemcached___memcached_decrement_start(void); -extern int __dtraceenabled_libmemcached___memcached_decrement_start(void); -extern void __dtrace_libmemcached___memcached_delete_end(void); -extern int __dtraceenabled_libmemcached___memcached_delete_end(void); -extern void __dtrace_libmemcached___memcached_delete_start(void); -extern int __dtraceenabled_libmemcached___memcached_delete_start(void); -extern void __dtrace_libmemcached___memcached_flush_end(void); -extern int __dtraceenabled_libmemcached___memcached_flush_end(void); -extern void __dtrace_libmemcached___memcached_flush_start(void); -extern int __dtraceenabled_libmemcached___memcached_flush_start(void); -extern void __dtrace_libmemcached___memcached_get_end(void); -extern int __dtraceenabled_libmemcached___memcached_get_end(void); -extern void __dtrace_libmemcached___memcached_get_start(void); -extern int __dtraceenabled_libmemcached___memcached_get_start(void); -extern void __dtrace_libmemcached___memcached_increment_end(void); -extern int __dtraceenabled_libmemcached___memcached_increment_end(void); -extern void __dtrace_libmemcached___memcached_increment_start(void); -extern int __dtraceenabled_libmemcached___memcached_increment_start(void); -extern void __dtrace_libmemcached___memcached_mget_end(void); -extern int __dtraceenabled_libmemcached___memcached_mget_end(void); -extern void __dtrace_libmemcached___memcached_mget_start(void); -extern int __dtraceenabled_libmemcached___memcached_mget_start(void); -extern void __dtrace_libmemcached___memcached_replace_end(void); -extern int __dtraceenabled_libmemcached___memcached_replace_end(void); -extern void __dtrace_libmemcached___memcached_replace_start(void); -extern int __dtraceenabled_libmemcached___memcached_replace_start(void); -extern void __dtrace_libmemcached___memcached_server_add_end(void); -extern int __dtraceenabled_libmemcached___memcached_server_add_end(void); -extern void __dtrace_libmemcached___memcached_server_add_start(void); -extern int __dtraceenabled_libmemcached___memcached_server_add_start(void); -extern void __dtrace_libmemcached___memcached_set_end(void); -extern int __dtraceenabled_libmemcached___memcached_set_end(void); -extern void __dtrace_libmemcached___memcached_set_start(void); -extern int __dtraceenabled_libmemcached___memcached_set_start(void); +#ifdef HAVE_DTRACE +/* + * Create the DTrace probes on the system using it (to support both Solaris + * and MacOS X + */ +#include "dtrace_probes.h" #else +/* + * Provide dummy macros so that we don't need to clutter the code with + * ifdefs when we want to use the probes. + */ #define LIBMEMCACHED_MEMCACHED_ADD_END() #define LIBMEMCACHED_MEMCACHED_ADD_END_ENABLED() (0) @@ -198,9 +67,4 @@ extern int __dtraceenabled_libmemcached___memcached_set_start(void); #endif - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBMEMCACHED_PROBES_H */ +#endif /* LIBMEMCACHED_PROBES_H */