Rename _DTRACE_VERSION
PATCH v2 1/4 Rename _DTRACE_VERSION
From: Eugene Loh <[email protected]>
There are many DTrace version numbers (for version, API version, package version, etc.). Meanwhile, _DTRACE_VERSION is not a version number at all. It's a preprocessor macro in USDT .h header files. Prior to commit e2fb0ecd9
("Ensure multiple passes through dtrace -G work."), it was perhaps not even set. With that commit, it was always set to 1, with the rationale:
Also add an explicit define for _DTRACE__VERSION in the generated header file from 'dtrace -h' invocations. This seems silly, but it is there to give people a skeleton to work with if they want to pre-generate header files and select whether to actually compile on the probes at a later time.
Rename to _DTRACE_USE_USDT for better clarity. Define it only once per file. Place the definition inside an #ifndef test so that a developer could set the value without manually changing the file.
--- libdtrace/dt_program.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
libdtrace/dt_program.c +7 -3
@@ -505,13 +505,12 @@ dt_header_provider(dtrace_hdl_t *dtp, dt_provider_t *pvp, FILE *out) info.dthi_pfname =alloca (strlen (pvp->desc.dtvd_name) +1 + i);dt_header_fmt_func (info.dthi_pfname, pvp->desc.dtvd_name); -if (fprintf (out,"#define _DTRACE_VERSION 1\n\n" -"#if _DTRACE_VERSION\n\n" ) <0 ) +if (fprintf (out,"#if _DTRACE_USE_USDT\n\n" ) <0 )return dt_set_errno (dtp, errno);if (dt_idhash_iter (pvp->pv_probes, dt_header_probe, &info) !=0 )return -1 ;/* dt_errno is set for us */ -if (fprintf (out,"\n\n" ) <0 ) +if (fprintf (out,"\n" ) <0 )return dt_set_errno (dtp, errno);if (dt_idhash_iter (pvp->pv_probes, dt_header_decl, &info) !=0 )return -1 ;/* dt_errno is set for us */
@@ -560,6 +559,11 @@ dtrace_program_header(dtrace_hdl_t *dtp, FILE *out, const char *fname) "#endif\n\n") < 0)return -1 ; +if (fprintf (out,"#ifndef _DTRACE_USE_USDT\n" +"# define _DTRACE_USE_USDT 1\n" +"#endif\n\n" ) <0 ) +return -1 ; +while ((pvp =dt_htab_next (dtp->dt_provs, &it)) !=NULL ) {if (dt_header_provider (dtp, pvp, out) !=0 ) {dt_htab_next_destroy (it);
Signature · 1 line
2.43.5
Quoted 11 lines · On Thu, Feb 27, 2025 at 02:01:54PM -0500, [email protected] wrote:
From: Eugene Loh <[email protected]>
There are many DTrace version numbers (for version, API version, package version, etc.). Meanwhile,
_DTRACE_VERSIONis not a version number at all. It's a preprocessor macro in USDT .h header files. Prior to commite2fb0ecd9
("Ensure multiple passes through dtrace -G work."), it was perhaps not even set. With that commit, it was always set to 1, with the rationale:Also add an explicit define for
_DTRACE__VERSIONin the generated
__ -> _ (will fix when I merge)
Quoted 10 lines
header file from 'dtrace -h' invocations. This seems silly, but it is there to give people a skeleton to work with if they want to pre-generate header files and select whether to actually compile on the probes at a later time.
Rename to
_DTRACE_USE_USDTfor better clarity. Define it only once per file. Place the definition inside an #ifndef test so that a developer could set the value without manually changing the file.Signed-off-by Eugene Loh <[email protected]>
Quoted 39 lines
--- libdtrace/dt_program.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)libdtrace/dt_program.c +7
-3@@ -505,13 +505,12 @@ dt_header_provider(dtrace_hdl_t *dtp, dt_provider_t *pvp, FILE *out) info.dthi_pfname =alloca (strlen (pvp->desc.dtvd_name) +1 + i);dt_header_fmt_func (info.dthi_pfname, pvp->desc.dtvd_name); -if (fprintf (out,"#define _DTRACE_VERSION 1\n\n" -"#if _DTRACE_VERSION\n\n" ) <0 ) +if (fprintf (out,"#if _DTRACE_USE_USDT\n\n" ) <0 )return dt_set_errno (dtp, errno);if (dt_idhash_iter (pvp->pv_probes, dt_header_probe, &info) !=0 )return -1 ;/* dt_errno is set for us */ -if (fprintf (out,"\n\n" ) <0 ) +if (fprintf (out,"\n" ) <0 )return dt_set_errno (dtp, errno);if (dt_idhash_iter (pvp->pv_probes, dt_header_decl, &info) !=0 )return -1 ;/* dt_errno is set for us */ @@ -560,6 +559,11 @@ dtrace_program_header(dtrace_hdl_t *dtp, FILE *out, const char *fname) "#endif\n\n") < 0)return -1 ; +if (fprintf (out,"#ifndef _DTRACE_USE_USDT\n" +"# define _DTRACE_USE_USDT 1\n" +"#endif\n\n" ) <0 ) +return -1 ; +while ((pvp =dt_htab_next (dtp->dt_provs, &it)) !=NULL ) {if (dt_header_provider (dtp, pvp, out) !=0 ) {dt_htab_next_destroy (it);Signature · 1 line
2.43.5