aboutsummaryrefslogtreecommitdiffstats
path: root/test/data
diff options
context:
space:
mode:
authorEli Zaretskii2018-01-19 11:20:12 +0200
committerEli Zaretskii2018-01-19 11:20:12 +0200
commitc28d4b6d8e1ad3d8c96329239a01af9d1dc048c5 (patch)
treee72b683e98ddb68590356f2d2a34f9aad6d9c1bc /test/data
parent1d50c185f0c857bb1a85945314b522540071f796 (diff)
downloademacs-c28d4b6d8e1ad3d8c96329239a01af9d1dc048c5.tar.gz
emacs-c28d4b6d8e1ad3d8c96329239a01af9d1dc048c5.zip
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).
Diffstat (limited to 'test/data')
-rw-r--r--test/data/emacs-module/mod-test.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
index c1b1cade04a..a1c115f00d2 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -20,10 +20,35 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
20#include <assert.h> 20#include <assert.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <limits.h>
23#include <emacs-module.h> 24#include <emacs-module.h>
24 25
25int plugin_is_GPL_compatible; 26int plugin_is_GPL_compatible;
26 27
28#if INTPTR_MAX <= 0
29# error "INTPTR_MAX misconfigured"
30#elif INTPTR_MAX <= INT_MAX || INTPTR_MAX <= LONG_MAX
31# define pT "ld"
32# define pZ "lu"
33# define T_TYPE long
34# define Z_TYPE unsigned long
35#elif INTPTR_MAX <= INT64_MAX
36# ifdef __MINGW32__
37# define pT "lld"
38# define pZ "llu"
39# define T_TYPE long long
40# define Z_TYPE unsigned long long
41# else
42# define pT "ld"
43# define pZ "lu"
44# define T_TYPE long
45# define Z_TYPE unsigned long
46# endif
47#else
48# error "INTPTR_MAX too large"
49#endif
50
51
27/* Always return symbol 't'. */ 52/* Always return symbol 't'. */
28static emacs_value 53static emacs_value
29Fmod_test_return_t (emacs_env *env, ptrdiff_t nargs, emacs_value args[], 54Fmod_test_return_t (emacs_env *env, ptrdiff_t nargs, emacs_value args[],
@@ -287,9 +312,9 @@ emacs_module_init (struct emacs_runtime *ert)
287{ 312{
288 if (ert->size < sizeof *ert) 313 if (ert->size < sizeof *ert)
289 { 314 {
290 fprintf (stderr, "Runtime size of runtime structure (%td bytes) " 315 fprintf (stderr, "Runtime size of runtime structure (%"pT" bytes) "
291 "smaller than compile-time size (%zu bytes)", 316 "smaller than compile-time size (%"pZ" bytes)",
292 ert->size, sizeof *ert); 317 (T_TYPE) ert->size, (Z_TYPE) sizeof (*ert));
293 return 1; 318 return 1;
294 } 319 }
295 320
@@ -297,9 +322,9 @@ emacs_module_init (struct emacs_runtime *ert)
297 322
298 if (env->size < sizeof *env) 323 if (env->size < sizeof *env)
299 { 324 {
300 fprintf (stderr, "Runtime size of environment structure (%td bytes) " 325 fprintf (stderr, "Runtime size of environment structure (%"pT" bytes) "
301 "smaller than compile-time size (%zu bytes)", 326 "smaller than compile-time size (%"pZ" bytes)",
302 env->size, sizeof *env); 327 (T_TYPE) env->size, (Z_TYPE) sizeof (*env));
303 return 2; 328 return 2;
304 } 329 }
305 330