From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: [PATCH] Export major version of latest Emacs supported by emacs-module.h. Date: Wed, 24 Apr 2019 10:31:40 +0200 Message-ID: <20190424083140.1948-1-phst@google.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="34674"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Philipp Stephani To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 24 10:33:44 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJDLb-0008r7-Tf for ged-emacs-devel@m.gmane.org; Wed, 24 Apr 2019 10:33:44 +0200 Original-Received: from localhost ([127.0.0.1]:37888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJDLa-00087e-Pv for ged-emacs-devel@m.gmane.org; Wed, 24 Apr 2019 04:33:42 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJDLS-00083L-SU for emacs-devel@gnu.org; Wed, 24 Apr 2019 04:33:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJDJZ-00036D-0Z for emacs-devel@gnu.org; Wed, 24 Apr 2019 04:31:40 -0400 Original-Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:38573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hJDJY-00035l-Q1 for emacs-devel@gnu.org; Wed, 24 Apr 2019 04:31:36 -0400 Original-Received: by mail-wr1-x42e.google.com with SMTP id f14so23290237wrj.5 for ; Wed, 24 Apr 2019 01:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UYyjQXxfVtmVyvrdmWc3VT93QLeoa8PZsJIrWJt3hHk=; b=g6ZrBSCaKTXmgsfnthmlfNUh3ggHX6dZlm2N6wuoB9+iPqvCG+7SD6+d+06XDFXMXY sIx4+6woaC2z6PqzzSIrEH2ev7C4WW4hgVhEjn0id3xMpgmPx8ZHnXVvSbYhdqCz/WRG 3vqC3aVT6U9WaCZOdPynsyG9wp16/xFphVI3PnMNXibu3ih/QKXSxBwefPLcnbwZ+xYq T/O/a5WyMpBVU+aaDzDO4JMjoeLwOsR5STvLsHbGrbdJKt+81TtPIJQ8EteCufEJg/ME cMNEw4t03G2L6RPr6yyzu+XmOIqvFtok+rxXl0bKNGOgk7ITq2I00IdkminUFkz3IftT 4omA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UYyjQXxfVtmVyvrdmWc3VT93QLeoa8PZsJIrWJt3hHk=; b=NVJgdxPyRdNvZfgXLNx8XInA5I89L+f3ditnP/abUFVfwwHNh+vHjkbUQwPntvs3qt RX9WeRmyrfEy4FLgIj88IsKTkM8kekJaJfNR11Bk3WH9YRgoPnOHYsC8+mBWa71258AI WTvI3t4e2w8Jv62wY4iE176aLlqpcxI3txpugQmh8GsahmMSrrU9BvolbzEf/jOFq7aK hQ6VFQa2LrQXp+Ejb4lqCO65osTYZo3ysLTioo1zCeQGLwXNjXuhg6UX0sWJFeDGgTVq q8+FeSPXK3vSXAR5p9USJ4ktta/52l2Zs3yuI2SAjS1d8xo8AEtRPebcSKAXF5b+FNdM djWA== X-Gm-Message-State: APjAAAXGQ1twKmBvYQnBQuAVLjmA/a+WzZ0AG/s4K6ZfIweaAPA6t2yM pKeeyw4wT4NVY4NpUhGAf6WihxP7 X-Google-Smtp-Source: APXvYqwFffGD/tFgeeM+Ryb3YrDAOzlQRKZNk+IUxavL6n/UObUXhUDQmK3Q/e8D4D+HrTHwHHlJsQ== X-Received: by 2002:adf:ed87:: with SMTP id c7mr6797370wro.34.1556094695153; Wed, 24 Apr 2019 01:31:35 -0700 (PDT) Original-Received: from p.cm.cablesurf.de (85.233.42.145.dynamic.cablesurf.de. [85.233.42.145]) by smtp.gmail.com with ESMTPSA id 6sm5808131wra.85.2019.04.24.01.31.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Apr 2019 01:31:34 -0700 (PDT) X-Google-Original-From: Philipp Stephani X-Mailer: git-send-email 2.20.1 (Apple Git-117) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235852 Archived-At: 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_MODULE_VERSION preprocessor macro. --- configure.ac | 2 ++ doc/lispref/internals.texi | 11 +++++++++++ etc/NEWS | 3 +++ src/emacs-module.h.in | 2 ++ 4 files changed, 18 insertions(+) diff --git a/configure.ac b/configure.ac index 810c3219e4..79fe0c98c6 100644 --- a/configure.ac +++ b/configure.ac @@ -3697,6 +3697,8 @@ AC_DEFUN 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 25892d4b57..d4adb1d7d9 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -1191,6 +1191,17 @@ Module Initialization can use only the parts of the module @acronym{API} that existed in that version, since those parts are identical in later versions. +@file{emacs-module.h} defines a preprocessor macro +@code{EMACS_MODULE_VERSION}. It expands to an integer literal which +is the latest major version of Emacs supported by the header. +@xref{Version Info}. Note that the value of +@code{EMACS_MODULE_VERSION} 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 +@code{EMACS_MODULE_VERSION}. + 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 b13ab47768..483f1dc958 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1910,6 +1910,9 @@ returns a regexp that never matches anything, which is an identity for this operation. Previously, the empty string was returned in this case. +** 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 009d1583fe..dad4453cd8 100644 --- a/src/emacs-module.h.in +++ b/src/emacs-module.h.in @@ -27,6 +27,8 @@ along with GNU Emacs. If not, see . */ #include #endif +#define EMACS_MAJOR_VERSION @emacs_major_version@ + #if defined __cplusplus && __cplusplus >= 201103L # define EMACS_NOEXCEPT noexcept #else -- 2.20.1 (Apple Git-117)