diff options
Diffstat (limited to 'test/data')
| -rw-r--r-- | test/data/emacs-module/mod-test.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c index 85a7f28e50d..8ac08f71534 100644 --- a/test/data/emacs-module/mod-test.c +++ b/test/data/emacs-module/mod-test.c | |||
| @@ -382,6 +382,22 @@ Fmod_test_add_nanosecond (emacs_env *env, ptrdiff_t nargs, emacs_value *args, | |||
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | static emacs_value | 384 | static emacs_value |
| 385 | Fmod_test_nanoseconds (emacs_env *env, ptrdiff_t nargs, emacs_value *args, void *data) { | ||
| 386 | assert (nargs == 1); | ||
| 387 | struct timespec time = env->extract_time (env, args[0]); | ||
| 388 | struct emacs_mpz nanoseconds; | ||
| 389 | assert (LONG_MIN <= time.tv_sec && time.tv_sec <= LONG_MAX); | ||
| 390 | mpz_init_set_si (nanoseconds.value, time.tv_sec); | ||
| 391 | static_assert (1000000000 <= ULONG_MAX, "unsupported architecture"); | ||
| 392 | mpz_mul_ui (nanoseconds.value, nanoseconds.value, 1000000000); | ||
| 393 | assert (0 <= time.tv_nsec && time.tv_nsec <= ULONG_MAX); | ||
| 394 | mpz_add_ui (nanoseconds.value, nanoseconds.value, time.tv_nsec); | ||
| 395 | emacs_value result = env->make_big_integer (env, &nanoseconds); | ||
| 396 | mpz_clear (nanoseconds.value); | ||
| 397 | return result; | ||
| 398 | } | ||
| 399 | |||
| 400 | static emacs_value | ||
| 385 | Fmod_test_double (emacs_env *env, ptrdiff_t nargs, emacs_value *args, | 401 | Fmod_test_double (emacs_env *env, ptrdiff_t nargs, emacs_value *args, |
| 386 | void *data) | 402 | void *data) |
| 387 | { | 403 | { |
| @@ -465,6 +481,7 @@ emacs_module_init (struct emacs_runtime *ert) | |||
| 465 | NULL, NULL); | 481 | NULL, NULL); |
| 466 | DEFUN ("mod-test-sleep-until", Fmod_test_sleep_until, 2, 2, NULL, NULL); | 482 | DEFUN ("mod-test-sleep-until", Fmod_test_sleep_until, 2, 2, NULL, NULL); |
| 467 | DEFUN ("mod-test-add-nanosecond", Fmod_test_add_nanosecond, 1, 1, NULL, NULL); | 483 | DEFUN ("mod-test-add-nanosecond", Fmod_test_add_nanosecond, 1, 1, NULL, NULL); |
| 484 | DEFUN ("mod-test-nanoseconds", Fmod_test_nanoseconds, 1, 1, NULL, NULL); | ||
| 468 | DEFUN ("mod-test-double", Fmod_test_double, 1, 1, NULL, NULL); | 485 | DEFUN ("mod-test-double", Fmod_test_double, 1, 1, NULL, NULL); |
| 469 | 486 | ||
| 470 | #undef DEFUN | 487 | #undef DEFUN |