Commit c28d4b6d authored by Eli Zaretskii's avatar Eli Zaretskii

Portability fixes in emacs-module-tests

* test/Makefile.in (abs_top_srcdir): Add variable, needed by
CPPFLAGS.
* test/data/emacs-module/mod-test.c: Include <limits.h>.
(pT, pZ, T_TYPE, Z_TYPE): Compatibility macros, for systems that
don't support %td and %zu format specs.
(emacs_module_init): Use compatibility macros to make the error
messages print meaningful values (and avoid compiler warnings).
parent 1d50c185
......@@ -31,6 +31,7 @@
SHELL = @SHELL@
srcdir = @srcdir@
abs_top_srcdir=@abs_top_srcdir@
VPATH = $(srcdir)
FIND_DELETE = @FIND_DELETE@
......
......@@ -20,10 +20,35 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <emacs-module.h>
int plugin_is_GPL_compatible;
#if INTPTR_MAX <= 0
# error "INTPTR_MAX misconfigured"
#elif INTPTR_MAX <= INT_MAX || INTPTR_MAX <= LONG_MAX
# define pT "ld"
# define pZ "lu"
# define T_TYPE long
# define Z_TYPE unsigned long
#elif INTPTR_MAX <= INT64_MAX
# ifdef __MINGW32__
# define pT "lld"
# define pZ "llu"
# define T_TYPE long long
# define Z_TYPE unsigned long long
# else
# define pT "ld"
# define pZ "lu"
# define T_TYPE long
# define Z_TYPE unsigned long
# endif
#else
# error "INTPTR_MAX too large"
#endif
/* Always return symbol 't'. */
static emacs_value
Fmod_test_return_t (emacs_env *env, ptrdiff_t nargs, emacs_value args[],
......@@ -287,9 +312,9 @@ emacs_module_init (struct emacs_runtime *ert)
{
if (ert->size < sizeof *ert)
{
fprintf (stderr, "Runtime size of runtime structure (%td bytes) "
"smaller than compile-time size (%zu bytes)",
ert->size, sizeof *ert);
fprintf (stderr, "Runtime size of runtime structure (%"pT" bytes) "
"smaller than compile-time size (%"pZ" bytes)",
(T_TYPE) ert->size, (Z_TYPE) sizeof (*ert));
return 1;
}
......@@ -297,9 +322,9 @@ emacs_module_init (struct emacs_runtime *ert)
if (env->size < sizeof *env)
{
fprintf (stderr, "Runtime size of environment structure (%td bytes) "
"smaller than compile-time size (%zu bytes)",
env->size, sizeof *env);
fprintf (stderr, "Runtime size of environment structure (%"pT" bytes) "
"smaller than compile-time size (%"pZ" bytes)",
(T_TYPE) env->size, (Z_TYPE) sizeof (*env));
return 2;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment