Add release versioning support.

Base version string on 'git describe --long', and provide cpp
macros in jemalloc.h.

Add the version mallctl.
This commit is contained in:
Jason Evans 2010-03-02 13:01:16 -08:00
parent 22ca855e8f
commit a40bc7afe8
7 changed files with 33 additions and 2 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@
/jemalloc/src/jemalloc\.h /jemalloc/src/jemalloc\.h
/jemalloc/src/jemalloc_defs\.h /jemalloc/src/jemalloc_defs\.h
/jemalloc/src/*.[od] /jemalloc/src/*.[od]
/jemalloc/VERSION

View File

@ -100,6 +100,7 @@ distclean: clean
relclean: distclean relclean: distclean
rm -rf @objroot@autom4te.cache rm -rf @objroot@autom4te.cache
rm -f @objroot@configure rm -f @objroot@configure
rm -f @srcroot@VERSION
#=============================================================================== #===============================================================================
# Re-configuration rules. # Re-configuration rules.

View File

@ -1 +0,0 @@
0.0.0

View File

@ -563,9 +563,23 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM(
dnl ============================================================================ dnl ============================================================================
dnl jemalloc configuration. dnl jemalloc configuration.
dnl dnl
dnl Set VERSION if source directory has an embedded git repository.
if test -d "${srcroot}../.git" ; then
git describe --long > ${srcroot}VERSION
fi
jemalloc_version=`cat ${srcroot}VERSION` jemalloc_version=`cat ${srcroot}VERSION`
AC_DEFINE_UNQUOTED([JEMALLOC_VERSION], ["$jemalloc_version"]) jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
AC_SUBST([jemalloc_version]) AC_SUBST([jemalloc_version])
AC_SUBST([jemalloc_version_major])
AC_SUBST([jemalloc_version_minor])
AC_SUBST([jemalloc_version_bugfix])
AC_SUBST([jemalloc_version_nrev])
AC_SUBST([jemalloc_version_gid])
dnl ============================================================================ dnl ============================================================================
dnl Configure pthreads. dnl Configure pthreads.

View File

@ -640,6 +640,11 @@ introspection.
@roff_stats@can be used to access the summation of statistics from all arenas. @roff_stats@can be used to access the summation of statistics from all arenas.
.Bl -ohang .Bl -ohang
.\"----------------------------------------------------------------------------- .\"-----------------------------------------------------------------------------
.It Sy "version (const char *) r-"
.Bd -ragged -offset indent -compact
Return the jemalloc version string.
.Ed
.\"-----------------------------------------------------------------------------
.It Sy "epoch (uint64_t) rw" .It Sy "epoch (uint64_t) rw"
.Bd -ragged -offset indent -compact .Bd -ragged -offset indent -compact
If a value is passed in, refresh the data from which the If a value is passed in, refresh the data from which the

View File

@ -4,6 +4,13 @@
extern "C" { extern "C" {
#endif #endif
#define JEMALLOC_VERSION "@jemalloc_version@"
#define JEMALLOC_VERSION_MAJOR @jemalloc_version_major@
#define JEMALLOC_VERSION_MINOR @jemalloc_version_minor@
#define JEMALLOC_VERSION_BUGFIX @jemalloc_version_bugfix@
#define JEMALLOC_VERSION_NREV @jemalloc_version_nrev@
#define JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
#include "jemalloc_defs@install_suffix@.h" #include "jemalloc_defs@install_suffix@.h"
#ifndef JEMALLOC_P #ifndef JEMALLOC_P
# define JEMALLOC_P(s) s # define JEMALLOC_P(s) s

View File

@ -30,6 +30,7 @@ static bool ctl_init(void);
static int ctl_lookup(const char *name, ctl_node_t const **nodesp, static int ctl_lookup(const char *name, ctl_node_t const **nodesp,
size_t *mibp, size_t *depthp); size_t *mibp, size_t *depthp);
CTL_PROTO(version)
CTL_PROTO(epoch) CTL_PROTO(epoch)
#ifdef JEMALLOC_TCACHE #ifdef JEMALLOC_TCACHE
CTL_PROTO(tcache_flush) CTL_PROTO(tcache_flush)
@ -426,6 +427,7 @@ static const ctl_node_t swap_node[] = {
#endif #endif
static const ctl_node_t root_node[] = { static const ctl_node_t root_node[] = {
{NAME("version"), CTL(version)},
{NAME("epoch"), CTL(epoch)}, {NAME("epoch"), CTL(epoch)},
#ifdef JEMALLOC_TCACHE #ifdef JEMALLOC_TCACHE
{NAME("tcache"), CHILD(tcache)}, {NAME("tcache"), CHILD(tcache)},
@ -916,6 +918,8 @@ RETURN: \
return (ret); \ return (ret); \
} }
CTL_RO_GEN(version, JEMALLOC_VERSION, const char *)
static int static int
epoch_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, epoch_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
void *newp, size_t newlen) void *newp, size_t newlen)