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_defs\.h
/jemalloc/src/*.[od]
/jemalloc/VERSION

View File

@ -100,6 +100,7 @@ distclean: clean
relclean: distclean
rm -rf @objroot@autom4te.cache
rm -f @objroot@configure
rm -f @srcroot@VERSION
#===============================================================================
# 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 jemalloc configuration.
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`
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_major])
AC_SUBST([jemalloc_version_minor])
AC_SUBST([jemalloc_version_bugfix])
AC_SUBST([jemalloc_version_nrev])
AC_SUBST([jemalloc_version_gid])
dnl ============================================================================
dnl Configure pthreads.

View File

@ -640,6 +640,11 @@ introspection.
@roff_stats@can be used to access the summation of statistics from all arenas.
.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"
.Bd -ragged -offset indent -compact
If a value is passed in, refresh the data from which the

View File

@ -4,6 +4,13 @@
extern "C" {
#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"
#ifndef JEMALLOC_P
# 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,
size_t *mibp, size_t *depthp);
CTL_PROTO(version)
CTL_PROTO(epoch)
#ifdef JEMALLOC_TCACHE
CTL_PROTO(tcache_flush)
@ -426,6 +427,7 @@ static const ctl_node_t swap_node[] = {
#endif
static const ctl_node_t root_node[] = {
{NAME("version"), CTL(version)},
{NAME("epoch"), CTL(epoch)},
#ifdef JEMALLOC_TCACHE
{NAME("tcache"), CHILD(tcache)},
@ -916,6 +918,8 @@ RETURN: \
return (ret); \
}
CTL_RO_GEN(version, JEMALLOC_VERSION, const char *)
static int
epoch_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
void *newp, size_t newlen)