[Asterisk-code-review] asterisk.h: Add ASTERISK REGISTER FILE macro (asterisk[13])

Joshua Colp asteriskteam at digium.com
Wed Jan 6 06:08:53 CST 2016


Joshua Colp has submitted this change and it was merged.

Change subject: asterisk.h: Add ASTERISK_REGISTER_FILE macro
......................................................................


asterisk.h: Add ASTERISK_REGISTER_FILE macro

The 11/13 branches and master use 2 different file version macros. 11/13
uses ASTERISK_FILE_VERSION but master uses ASTERISK_REGISTER_FILE. This
means a new file added to 11/13 can't just be cherry-picked to master
because the macro has to be changed.

To make cherry-picking possible, ASTERISK_REGISTER_FILE was added
to asterisk.h as a simple alias for ASTERISK_FILE_VERSION(__FILE__, NULL)
The "$Revision$" tag doesn't do anything since Asterisk moved to git so
just passing NULL as the verison works fine.  asterisk.h was also
annotated to deprecate ASTERISK_FILE_VERSION and suggest using
ASTERISK_REGISTER_FILE for all new files.

Finally, 2 recent file additions, pbx_builtins.c and pbx_functions.c,
were modified to use the new macro to make sure it actually worked.
'core show file version' showed the correct output.

Change-Id: I5867ed898818d26ee49bb6e5c7d4c1a45d4789a5
---
M include/asterisk.h
M main/pbx_builtins.c
M main/pbx_functions.c
3 files changed, 22 insertions(+), 2 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved
  Corey Farrell: Looks good to me, but someone else must approve



diff --git a/include/asterisk.h b/include/asterisk.h
index c501c44..873ed5c 100644
--- a/include/asterisk.h
+++ b/include/asterisk.h
@@ -222,6 +222,9 @@
  * SVN from modifying them in this file; under normal circumstances they would
  * not be present and SVN would expand the Revision keyword into the file's
  * revision number.
+ *
+ * \deprecated All new files should use ASTERISK_REGISTER_FILE instead.
+ * \version 11.22.0 deprecated
  */
 #ifdef MTX_PROFILE
 #define	HAVE_MTX_PROFILE	/* used in lock.h */
@@ -251,6 +254,23 @@
 #define ASTERISK_FILE_VERSION(file, x)
 #endif /* LOW_MEMORY */
 
+/*!
+ * \since 11.22.0
+ * \brief Register/unregister a source code file with the core.
+ *
+ * This macro will place a file-scope constructor and destructor into the
+ * source of the module using it; this will cause the file to be
+ * registered with the Asterisk core (and unregistered) at the appropriate
+ * times.
+ *
+ * Example:
+ *
+ * \code
+ * ASTERISK_REGISTER_FILE()
+ * \endcode
+ */
+#define ASTERISK_REGISTER_FILE() ASTERISK_FILE_VERSION(__FILE__, NULL)
+
 #if !defined(LOW_MEMORY)
 /*!
  * \brief support for event profiling
diff --git a/main/pbx_builtins.c b/main/pbx_builtins.c
index ce5a92b..fa15588 100644
--- a/main/pbx_builtins.c
+++ b/main/pbx_builtins.c
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+ASTERISK_REGISTER_FILE()
 
 #include "asterisk/_private.h"
 #include "asterisk/pbx.h"
diff --git a/main/pbx_functions.c b/main/pbx_functions.c
index b8be2bc..bc738b0 100644
--- a/main/pbx_functions.c
+++ b/main/pbx_functions.c
@@ -29,7 +29,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+ASTERISK_REGISTER_FILE()
 
 #include "asterisk/_private.h"
 #include "asterisk/cli.h"

-- 
To view, visit https://gerrit.asterisk.org/1918
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5867ed898818d26ee49bb6e5c7d4c1a45d4789a5
Gerrit-PatchSet: 4
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list