[DTrace-devel] [PATCH 2/4] Eliminate DT_VERS_LATEST

Kris Van Hees kris.van.hees at oracle.com
Thu Feb 27 16:40:45 UTC 2025


On Sat, Feb 08, 2025 at 02:06:20PM -0500, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Updating the DTrace version number requires too many distinct
> changes.  Eliminate DT_VERS_LATEST, since it can be determined
> on the fly.
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  libdtrace/dt_open.c    |  3 ++-
>  libdtrace/dt_version.h | 14 +++++---------
>  2 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
> index a02058871..b4d160359 100644
> --- a/libdtrace/dt_open.c
> +++ b/libdtrace/dt_open.c
> @@ -721,7 +721,8 @@ dt_vopen(int version, int flags, int *errp,
>  	dtp->dt_proc_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
>  	if (dt_aggregate_init(dtp) == -1)
>  		return set_open_errno(dtp, errp, dtrace_errno(dtp));
> -	dtp->dt_vmax = DT_VERS_LATEST;
> +	for (i = 0; _dtrace_versions[i] != 0; i++)
> +		dtp->dt_vmax = _dtrace_versions[i];

dtp->dt_vmax = _dtrace_versions[ARRAY_SIZE(_dtrace_versions) - 2];

(-2 to account for the 0 sentinel value)

But this will only be accurate if you also add 2.0.1 to the _dtrace_versions
array, and then you should probably add 2.0.2 to it also for accuracy.

>  	dtp->dt_cpp_path = strdup(_dtrace_defcpp);
>  	dtp->dt_cpp_argv = malloc(sizeof(char *));
>  	dtp->dt_cpp_argc = 1;
> diff --git a/libdtrace/dt_version.h b/libdtrace/dt_version.h
> index 3fd1b3d1e..bef3243e9 100644
> --- a/libdtrace/dt_version.h
> +++ b/libdtrace/dt_version.h
> @@ -38,18 +38,15 @@ extern "C" {
>   *
>   * These #defines are used in identifier tables to fill in the version fields
>   * associated with each identifier.  The DT_VERS_* macros declare the encoded
> - * integer values of all versions used so far.  DT_VERS_LATEST must correspond
> - * to the latest version value among all versions exported by the D compiler.
> - * DT_VERS_STRING must be an ASCII string that contains DT_VERS_LATEST within
> - * it along with any suffixes (e.g. Beta).
> + * integer values of all versions used so far.  DT_VERS_STRING must be an ASCII
> + * string that contains the latest version within it along with any suffixes
> + * (e.g. Beta).  You must update DT_VERS_STRING when adding a new version,
> + * and then add the new version to the _dtrace_versions[] array declared in
> + * dt_open.c.
>   *
>   * Refer to the Solaris Dynamic Tracing Guide Versioning chapter for an
>   * explanation of these DTrace features and their values.
>   *
> - * You must update DT_VERS_LATEST and DT_VERS_STRING when adding a new version,
> - * and then add the new version to the _dtrace_versions[] array declared in
> - * dt_open.c..
> - *
>   * NOTE: Although the DTrace versioning scheme supports the labeling and
>   *       introduction of incompatible changes (e.g. dropping an interface in a
>   *       major release), the libdtrace code does not currently support this.
> @@ -85,7 +82,6 @@ extern "C" {
>  #define	DT_VERS_2_0	DT_VERSION_NUMBER(2, 0, 0)
>  #define	DT_VERS_2_0_1	DT_VERSION_NUMBER(2, 0, 1)
>  
> -#define	DT_VERS_LATEST	DT_VERS_2_0_1
>  #define	DT_VERS_STRING	"Oracle D 2.0"

You should add 2.0.2 and update the DT_VERS_STRING also.

>  
>  #ifdef  __cplusplus
> -- 
> 2.43.5
> 



More information about the DTrace-devel mailing list