summaryrefslogtreecommitdiff
path: root/src/emacs-module.h
Commit message (Collapse)AuthorAgeFilesLines
* Rework C source files to avoid ^(Paul Eggert2016-03-101-2/+2
| | | | | | | | Work around Bug#22884 by rewording comments and strings to avoid ‘(’ at the start of a line unless it starts a function. This change is a short-term hack; in the longer run we plan to fix cc-mode’s performance for C files that have ‘(’ at the start of a line in a comment or string.
* Revert attempt to use 'noexcept' in typedefPaul Eggert2016-01-101-15/+4
| | | | | | | | | | | | | | This use of 'noexcept' runs afoul of the C++11 standard. Problem reported by Philipp Stephani in: http://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00706.html * src/emacs-module.c (emacs_finalizer_function): Move this typedef here ... * src/emacs-module.h: ... from here, and use only the C version of the typedef. The typedef is now private since it is never used in the .h file now and anyway it seemed to be causing more confusion than it cured. (make_user_ptr, get_user_finalizer, set_user_finalizer): Open-code the type instead.
* Update copyright year to 2016Paul Eggert2016-01-011-1/+1
| | | | Run admin/update-copyright.
* * src/emacs-module.h: Fix finalizer typedef for C++11Aurélien Aptel2015-11-301-3/+11
| | | | | | C++11 standard doesn't allow exception-specification in typedef. The workaround is to declare a dummy function prototype and use decltype on it.
* Rely on conservative stack scanning to find "emacs_value"sStefan Monnier2015-11-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/emacs-module.c (struct emacs_value_tag) (struct emacs_value_frame, struct emacs_value_storage): Remove. (value_frame_size): Remove constant. (struct emacs_env_private): Use Lisp_Object for non_local_exit info. (lisp_to_value): Remove first arg. (module_nil): New constant. Use it instead of NULL when returning an emacs_value. (module_make_function): Adjust to new calling convention of Qinternal_module_call. (DEFUN): Receive args in an array rather than a list. Use SAFE_ALLOCA rather than xnmalloc. Skip the lisp_to_value loop when we don't have WIDE_EMACS_INT. Adjust to new type of non_local_exit info. (module_non_local_exit_signal_1, module_non_local_exit_throw_1): Adjust to new type of non_local_exit info. (ltv_mark) [WIDE_EMACS_INT]: New constant. (value_to_lisp, lisp_to_value): Rewrite. (initialize_frame, initialize_storage, finalize_storage): Remove functions. (allocate_emacs_value): Remove function. (mark_modules): Gut it. (initialize_environment): Don't initialize storage any more. Keep the actual env object on Vmodule_environments. (finalize_environment): Don't finalize storage any more. (syms_of_module): Initialize ltv_mark and module_nil. * src/emacs-module.h (emacs_value): Make it more clear that this type is really opaque, including the fact that NULL may not be valid. * modules/mod-test/mod-test.c (Fmod_test_signal, Fmod_test_throw): Don't assume that NULL is a valid emacs_value.
* Simplify use of emacs_finalizer_function typePaul Eggert2015-11-231-5/+5
| | | | | | * src/emacs-module.h (emacs_finalizer_function): Now EMACS_NOEXCEPT. All users simplified to omit EMACS_NOEXCEPT. (struct emacs_env_25): Use emacs_finalizer_function where applicable.
* Declare emacs_module_init in the module APIPaul Eggert2015-11-201-0/+3
| | | | | | | * src/emacs-module.h (emacs_module_init): New decl. Without it, GCC might complain about a module that defines emacs_module_init without using it. This also checks the API better.
* Module function arg counts are ptrdiff_t, not intPaul Eggert2015-11-201-7/+9
| | | | | | | | | | | | | | | | | | | | | | * src/emacs-module.c (struct module_fun_env) (module_make_function, module_funcall, Fmodule_call): * src/emacs-module.h (struct emacs_runtime, struct emacs_env_25): Use ptrdiff_t, not int, for arg counts. * src/emacs-module.c (module_make_function): Don’t bother checking arity against MOST_POSITIVE_FIXNUM, as that’s unnecessary here. Make the checking clearer by negating it. (module_make_function, Fmodule_call): No need to use xzalloc since the storage doesn’t need to be cleared. (module_funcall): Don’t use VLA, since C11 doesn’t guarantee support for it, and many implementations are buggy with large VLAs anyway. Use SAFE_ALLOCA_LISP instead. (module_vec_set): Don’t crash if i < 0. (module_vec_get): Don’t crash if i < MOST_NEGATIVE_FIXNUM. (module_vec_set, module_vec_get): Do fixnum checks only when i is out of array bounds, for efficiency in the usual case. (Fmodule_load): Simplify fixnum range check. (Fmodule_call): Simplify arity check. Use xnmalloc to detect integer overflow in array allocation size.
* * src/emacs-module.h: Include stddef.h, not stdlib.h.Paul Eggert2015-11-191-1/+1
|
* Prefer signed integer types in module codePaul Eggert2015-11-191-7/+7
| | | | | | | | | | | | | | | | | | Generally speaking, at the C level the Emacs source code prefers signed types like ‘ptrdiff_t’ to unsigned types like ‘size_t’, partly to avoid the usual signedness confusion when comparing values. Change the module API to follow this convention. Use ‘int’ for small values that can’t exceed INT_MAX. * modules/mod-test/mod-test.c (Fmod_test_globref_make) (Fmod_test_string_a_to_b, Fmod_test_vector_fill) (Fmod_test_vector_eq): * src/emacs-module.c (struct emacs_value_frame) (module_make_global_ref, module_free_global_ref) (module_copy_string_contents, module_make_string) (module_vec_set, module_vec_get, module_vec_size): * src/emacs-module.h (struct emacs_runtime, struct emacs_env_25): * src/lread.c (suffix_p): Prefer signed to unsigned integer types.
* Prefer intmax_t to int64_t in module codePaul Eggert2015-11-191-3/+2
| | | | | | | | | | | * modules/mod-test/mod-test.c (sum, Fmod_test_sum): * src/emacs-module.c (module_extract_integer) (module_make_integer): * src/emacs-module.h (struct emacs_env_25): Prefer intmax_t to int64_t. This doesn’t change the generated code on any of the machines Emacs currently ports to, but it’s at least in theory more future-proof as C99 doesn’t guarantee that int64_t exists.
* Rename module.c to emacs-module.c, etc.Paul Eggert2015-11-191-0/+202
* src/emacs-module.c: Rename from src/module.c. * src/emacs-module.h: Rename from src/module.h. All uses changed.