[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 4d97e1a: Export major version of latest Emacs suppo
From: |
Philipp Stephani |
Subject: |
[Emacs-diffs] master 4d97e1a: Export major version of latest Emacs supported by emacs-module.h. |
Date: |
Sun, 28 Apr 2019 14:09:17 -0400 (EDT) |
branch: master
commit 4d97e1a9ea35c3a1d9f03abb7a822d57f384c1a5
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
Export major version of latest Emacs supported by emacs-module.h.
This is useful if module authors want to support multiple versions of
emacs-module.h.
* configure.ac (emacs_major_version): Define substitution.
* src/emacs-module.h.in (EMACS_MAJOR_VERSION): Define macro.
* doc/lispref/internals.texi (Module Initialization): Document
EMACS_MAJOR_VERSION preprocessor macro.
* test/data/emacs-module/mod-test.c (emacs_module_init): Verify
behavior of EMACS_MAJOR_VERSION.
---
configure.ac | 2 ++
doc/lispref/internals.texi | 11 +++++++++++
etc/NEWS | 3 +++
src/emacs-module.h.in | 2 ++
test/data/emacs-module/mod-test.c | 5 +++++
5 files changed, 23 insertions(+)
diff --git a/configure.ac b/configure.ac
index 810c321..79fe0c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3697,6 +3697,8 @@ AC_SUBST_FILE([module_env_snippet_27])
module_env_snippet_25="$srcdir/src/module-env-25.h"
module_env_snippet_26="$srcdir/src/module-env-26.h"
module_env_snippet_27="$srcdir/src/module-env-27.h"
+emacs_major_version="${PACKAGE_VERSION%%.*}"
+AC_SUBST(emacs_major_version)
### Use -lpng if available, unless '--with-png=no'.
HAVE_PNG=no
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index 5ae71af..cfeb492 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -1191,6 +1191,17 @@ grow with new Emacs releases. Given the version of
Emacs, the module
can use only the parts of the module @acronym{API} that existed in
that version, since those parts are identical in later versions.
address@hidden defines a preprocessor macro
address@hidden It expands to an integer literal which is
+the latest major version of Emacs supported by the header.
address@hidden Info}. Note that the value of
address@hidden is a compile-time constant and does not
+represent the version of Emacs that is currently running and has
+loaded your module. If you want your module to be compatible with
+various versions of @file{emacs-module.h} as well as various versions
+of Emacs, you can use conditional compilation based on
address@hidden
+
We recommend that modules always perform the compatibility
verification, unless they do their job entirely in the initialization
function, and don't access any Lisp objects or use any Emacs functions
diff --git a/etc/NEWS b/etc/NEWS
index cf6f4fe..9b32d72 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1933,6 +1933,9 @@ convert between timespec structures and Emacs Lisp time
values.
'extract_big_integer' to create and extract arbitrary-size integer
values.
+** emacs-module.h now defines a macro EMACS_MAJOR_VERSION that expands
+to the major version of the latest Emacs supported by the header.
+
* Changes in Emacs 27.1 on Non-Free Operating Systems
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in
index fbc62a6..9955e30 100644
--- a/src/emacs-module.h.in
+++ b/src/emacs-module.h.in
@@ -32,6 +32,8 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
#include <gmp.h>
#endif
+#define EMACS_MAJOR_VERSION @emacs_major_version@
+
#if defined __cplusplus && __cplusplus >= 201103L
# define EMACS_NOEXCEPT noexcept
#else
diff --git a/test/data/emacs-module/mod-test.c
b/test/data/emacs-module/mod-test.c
index b7007bd..a9154fa 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -445,6 +445,11 @@ bind_function (emacs_env *env, const char *name,
emacs_value Sfun)
int
emacs_module_init (struct emacs_runtime *ert)
{
+ /* Check that EMACS_MAJOR_VERSION is defined and an integral
+ constant. */
+ char dummy[EMACS_MAJOR_VERSION];
+ assert (27 <= sizeof dummy);
+
if (ert->size < sizeof *ert)
{
fprintf (stderr, "Runtime size of runtime structure (%"pT" bytes) "
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 4d97e1a: Export major version of latest Emacs supported by emacs-module.h.,
Philipp Stephani <=