aboutsummaryrefslogtreecommitdiffstats
path: root/src (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix version checks for emacs-module.hPhilipp Stephani2017-06-131-4/+7
| | | | | We don't need C11 or C++11 because stdbool.h is in C99, and for C++ we don't need it at all.
* Small portability fix for emacs-module.h (bug#27346)Glenn Morris2017-06-121-2/+5
| | | | | * src/emacs-module.h (EMACS_ATTRIBUTE_NONNULL) [!__has_attribute]: Avoid 'error: missing binary operator before token "("'.
* Add no-focus-on-map to NS build (bug#25408)Alan Third2017-06-123-6/+33
| | | | | | | | | | | * src/nsfns.m (ns_frame_parm_handlers): Add x_set_no_focus_on_map. (x-create-frame): Check for no-focus-on-map. * src/nsterm.h (x_set_no_focus_on_map): New function. * src/nsterm.m (x_set_no_focus_on_map): New function. (ns_raise_frame): Add parameter for specifying whether to focus the frame. (ns_frame_raise_lower): (x_make_frame_visible): Handle new parameter for ns_raise_frame.
* _Noreturn not noreturnPaul Eggert2017-06-121-10/+14
| | | | | | | _Noreturn is more portable to non-C11 platforms. See: https://www.gnu.org/software/gnulib/manual/html_node/stdnoreturn_002eh.html * src/emacs-module.c: Use _Noreturn, not noreturn. No need to include <stdnoreturn.h>. Reindent to fit in 80 columns.
* Avoid compilation warnings with pre-C99 libcEli Zaretskii2017-06-121-4/+5
| | | | | | * src/emacs-module.c (module_free_global_ref) (module_assert_runtime, module_assert_env, value_to_lisp): Use 'pD' instead of C99 't' format descriptor.
* Flush all output streams before abortingPhilipp Stephani2017-06-121-1/+1
| | | | | | | | Maybe the stdout buffer still contains something interesting that should be flushed. * src/emacs-module.c (module_abort): Flush all output streams before aborting.
* Remove an assertion that doesn't test Emacs invariantsPhilipp Stephani2017-06-121-2/+0
| | | | | * src/emacs-module.c (module_copy_string_contents): Remove an assertion that doesn't test Emacs invariants.
* Implement module assertions for usersPhilipp Stephani2017-06-123-63/+283
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new command-line option '-module-assertions' that users can enable developing or debugging a module. If this option is present, Emacs performs additional checks to verify that modules fulfill their requirements. These checks are expensive and crash Emacs if modules are invalid, so disable them by default. This is a command-line option instead of an ordinary variable because changing it while Emacs is running would cause data structure imbalances. * src/emacs.c (main): New command line option '-module-assertions'. * src/emacs-module.c (module_assert_main_thread) (module_assert_runtime, module_assert_env, module_assert_value): New functions to assert module requirements. (syms_of_module): New uninterned variable 'module-runtimes'. (init_module_assertions, in_main_thread, module_abort): New helper functions. (initialize_environment): Initialize value list. If assertions are enabled, use a heap-allocated environment object. (finalize_environment): Add assertion that environment list is never empty. (finalize_runtime_unwind): Pop module runtime object stack. (value_to_lisp): Assert that the value is valid. (lisp_to_value): Record new value if assertions are enabled. (mark_modules): Mark allocated object list. (MODULE_FUNCTION_BEGIN_NO_CATCH) (module_non_local_exit_check, module_non_local_exit_clear) (module_non_local_exit_get, module_non_local_exit_signal) (module_non_local_exit_throw): Assert thread and environment. (module_get_environment): Assert thread and runtime. (module_make_function, module_funcall, module_intern) (module_funcall, module_make_integer, module_make_float) (module_make_string, module_make_user_ptr, module_vec_get) (funcall_module, Fmodule_load): Adapt callers. (module_make_global_ref): If assertions are enabled, use the global environment to store global values. (module_free_global_ref): Remove value from global value list. * test/Makefile.in (EMACSOPT): Enable module assertions when testing modules. * test/data/emacs-module/mod-test.c (Fmod_test_invalid_store) (Fmod_test_invalid_load): New functions to test module assertions. (emacs_module_init): Bind the new functions. * test/src/emacs-module-tests.el (mod-test-emacs): New constant for the Emacs binary file. (mod-test-file): New constant for the test module file name. (module--test-assertions): New unit test.
* emacs-module: Use __attribute__((nonnull))Philipp Stephani2017-06-121-31/+67
| | | | | Annotate all parameters with __attribute__((nonnull)) that may not be NULL.
* Explicitly require C11 or C++11 in emacs-module.hPhilipp Stephani2017-06-121-1/+6
| | | | | | We already implicitly require them by including stdbool.h. Just make the error message a bit clearer, and remove an unnecessary version comparison.
* Remove Lisp_Misc_FloatPaul Eggert2017-06-112-5/+0
| | | | | | | * src/data.c (Ftype_of): Do not worry about Lisp_Misc_Float. * src/lisp.h (Lisp_Misc_Float): Remove. This placeholder has been unused for two decades; if we ever want to change floats to be a misc type we can bring it back then.
* Make two symbols private to emacs-module.cPaul Eggert2017-06-112-13/+10
| | | | | | * src/lisp.h (allocate_module_function, XSET_MODULE_FUNCTION): Move from here ... * src/emacs-module.c: ... to here.
* Support threads in modulesPhilipp Stephani2017-06-111-13/+16
| | | | | | | | | | | Rather than checking for the main thread, check for the current thread. * emacs-module.c (check_thread): New function. (MODULE_FUNCTION_BEGIN_NO_CATCH, module_get_environment) (module_non_local_exit_check, module_non_local_exit_clear) (module_non_local_exit_get, module_non_local_exit_signal) (module_non_local_exit_throw, module_is_not_nil, module_eq): Use it.
* Allow non-local exits in module initializersPhilipp Stephani2017-06-111-11/+23
| | | | | | | | | | | Previously signals, throws, and quits from module initialization functions were ignored. These function aren't special, and better errors can be reported using signals than with the initialization return code, so allow non-local exits. * src/emacs-module.c (module_signal_or_throw): New helper function. (Fmodule_load, funcall_module): Use it. (Fmodule_load): Also allow quitting.
* Don't wait for toolbar in NS native fullscreenAlan Third2017-06-101-1/+4
| | | | | * src/nsterm.m (EmacsView:updateFrameSize): Don't short-circuit the function when in fullscreen.
* ; Spelling fixesPaul Eggert2017-06-101-1/+1
|
* Fix the placement of GTK menus on multi-monitor systemsAlexander Gramiak2017-06-101-7/+39
| | | | | | | | | | | menu_position_func did not properly use the current monitor's resolution. Also see commit '2016-02-06 22:12:53 +0100'. * lisp/frame.el (frame-monitor-attribute, frame-monitor-geometry) (frame-monitor-workarea): New functions. * src/xmenu.c (menu_position_func): Take into account the workarea of the monitor that contains the mouse. (Bug#23568)
* Fix another compiler warning on macOSPhilipp Stephani2017-06-091-3/+2
| | | | | * src/image.c (x_query_frame_background_color): Don't define if we have NextStep but no image support.
* Add garbage collection support for module environmentsPhilipp Stephani2017-06-093-0/+19
| | | | | | * src/emacs-module.c (mark_modules): New function. (initialize_environment): Properly initialize Lisp objects. * src/alloc.c (garbage_collect_1): Call it.
* ; ChangeLog fixesGlenn Morris2017-06-051-1/+1
|
* Fix undefined behavior in mapbacktracePhilipp Stephani2017-06-051-1/+5
| | | | * src/eval.c (Fmapbacktrace): Don't assume that PDL is still valid.
* Fix emacs-module-tests on MS-WindowsEli Zaretskii2017-06-052-28/+33
| | | | | | | | * src/print.c (print_vectorlike): Make sure module function's address prints with a leading "0x". This fixes emacs-module-tests on MS-Windows. Fix whitespace. * src/dynlib.c (dynlib_addr): Remove unused variable. Update commentary.
* Use unwind protection to clean up data structures in modulesPhilipp Stephani2017-06-051-19/+26
| | | | | | | | | | | Reuse existing functionality and simplify the code a bit. * src/emacs-module.c (Fmodule_load): Use unwind protection to clean up runtime object. (funcall_module): Use unwind protection to clean up environment object. (finalize_environment): Simplify signature. (finalize_environment_unwind, finalize_runtime_unwind): New functions.
* Inline module_has_cleanupPhilipp Stephani2017-06-051-7/+1
| | | | | | | This constant is only used once, and we fail compilation anyway if it's false. * src/emacs-module.c (MODULE_SETJMP_1): Inline __has_attribute.
* Omit space that broke ‘make check’Paul Eggert2017-06-051-1/+1
| | | | * src/print.c (print_vectorlike): Omit stray space.
* Remove easserts etc. from emacs-module.cPaul Eggert2017-06-041-16/+0
| | | | | | | | | | | | | | | | | | | Most of these seem to run afoul of the comment "Do NOT use 'eassert' for checking validity of user code in the module." * src/emacs-module.c (MODULE_FUNCTION_BEGIN_NO_CATCH) (module_non_local_exit_check, module_non_local_exit_clear) (module_non_local_exit_get, module_non_local_exit_signal) (module_non_local_exit_throw, module_make_string): Remove unnecessary easserts that pointers are nonnull. Hardware checks this for us nowadays, and the checks just clutter up the code. (module_extract_integer): Remove unnecessary verify that a C signed integer is in the range INTMAX_MIN..INTMAX_MAX. The C standard guarantees this. (module_copy_string_contents): Remove unnecessary eassert that Lisp strings are null-terminated. (module_function_arity): Remove unnecessary easserts that function arities are in range.
* Remove unnecessary checking in emacs-module.cPaul Eggert2017-06-041-6/+3
| | | | | | | | | * src/emacs-module.c (module_copy_string_contents): Remove checking, as string lengths are always nonnegative and less than STRING_BYTES_BOUND, and this is checked elsewhere. (module_make_string): Check length against STRING_BYTES_BOUND, a tighter bound than MOST_POSITIVE_FIXNUM. (funcall_module): Don't assume that an out-of-range integer is nonnegative.
* SCHARS and STRING_BYTES are nonnegativePaul Eggert2017-06-041-4/+8
| | | | | | | | | | Tell the compiler that SCHARS and STRING_BYTES are nonnegative, in the hopes that this will optimize a bit better. Also, check this at runtime if ENABLE_CHECKING. * src/lisp.h (SCHARS, STRING_BYTES): eassume that these functions return nonnegative values. (STRING_SET_CHARS) [ENABLE_CHECKING]: eassert that newsize is nonnegative.
* Remove an unused error symbolPhilipp Stephani2017-06-041-5/+0
| | | | | * src/emacs-module.c (syms_of_module): Remove unused error symbol 'invalid-module-call'.
* Support quitting in modulesPhilipp Stephani2017-06-043-1/+22
| | | | | | | | | | | The idea is that modules should call env->should_quit from time to time and return as quickly as possible if it returns true. * src/emacs-module.c (module_should_quit): New module function. (initialize_environment): Use it. (funcall_module): Process potential pending quit. * src/eval.c (maybe_quit): Add reference to module_should_quit.
* Use more specific errors for module load failurePhilipp Stephani2017-06-041-4/+32
| | | | | | * src/emacs-module.c (syms_of_module): Add more specific error symbols. (Fmodule_load): Use them.
* Remove an unneeded assertionPhilipp Stephani2017-06-041-2/+0
| | | | | * src/emacs-module.c (module_copy_string_contents): Remove unneeded assertion. If this assertion triggers, we raise an error anyway.
* Guard against signed integer overflowsPhilipp Stephani2017-06-041-1/+7
| | | | | | * src/emacs-module.c (module_extract_integer) (module_copy_string_contents, module_make_string): Guard against signed integer overflows.
* Add a couple more assertions to the module codePhilipp Stephani2017-06-041-0/+16
| | | | | | | | | | These can help module authors debug crashes. * emacs-module.c (module_non_local_exit_check) (module_non_local_exit_clear, module_non_local_exit_get) (module_non_local_exit_signal, module_non_local_exit_throw) (module_copy_string_contents, module_make_string) (funcall_module, initialize_environment): Add assertions
* ; Grammar fixPhilipp Stephani2017-06-041-1/+1
|
* ; Small comment fixPhilipp Stephani2017-06-041-1/+1
| | | | | | * emacs-module.c (MODULE_FUNCTION_BEGIN): Don't say that the error value should be a sentinel value, because in almost all cases it isn't.
* Use ATTRIBUTE_MAY_ALIAS where alias violations are likelyPhilipp Stephani2017-06-042-5/+8
| | | | | | | In particular, alias violations are likely for the return values of dlsym(3), which get cast around arbitrarily. * src/emacs-module.c (Fmodule_load): Use ATTRIBUTE_MAY_ALIAS.
* Simplify interface of dynlib_attr.Philipp Stephani2017-06-042-20/+19
| | | | | | | Instead of returning bool, set the argument pointers to NULL if the information is not available. * src/dynlib.c (dynlib_addr): Don't return bool.
* Rationalize environment lifetime management functionsPhilipp Stephani2017-06-041-7/+7
| | | | | | * src/emacs-module.c (Fmodule_load, funcall_module): Adapt callers. (finalize_environment): Add parameter for public part of the environment, like 'initialize_environment'. Add assertions.
* Rework printing of module functionsPhilipp Stephani2017-06-044-43/+37
| | | | | | | | | | | | | | | | | | Fix a FIXME in emacs-module.c. Put the printing into print.c, like other types. * src/print.c (print_vectorlike): Add code to print module functions. * src/emacs-module.c (funcall_module): Stop calling 'module_format_fun_env'. Now that module functions are first-class objects, they can be added to signal data directly. (module_handle_signal): Remove now-unused function 'module_format_fun_env'. * test/src/emacs-module-tests.el (mod-test-sum-test): Adapt unit test. * src/eval.c (funcall_lambda): Adapt call to changed signature of 'funcall_module'.
* Define helper macro to reduce code duplicationPhilipp Stephani2017-06-041-10/+17
| | | | | | | * src/emacs-module.c (MODULE_FUNCTION_BEGIN_NO_CATCH): New helper macro. (MODULE_FUNCTION_BEGIN, module_type_of, module_is_not_nil, module_eq): Use it.
* Remove two FIXMEs that can't be fixedPhilipp Stephani2017-06-042-8/+4
|
* Tune ‘format’ after recent fixPaul Eggert2017-06-041-88/+66
| | | | | | | | | | | | | | | * doc/lispref/strings.texi (Formatting Strings): * src/editfns.c (Fformat): Format field numbers no longer need to be unique, reverting the previous doc change since that has now been fixed. Also, document that %% should not have modifiers. * src/editfns.c (styled_format): Improve performance. Remove the need for the new prepass over the format string, by using a typically-more-generous bound for the info array size. Initialize the info array lazily. Move string inspection to the same area to help caching. Avoid the need for a converted_to_string bitfield by using EQ. Cache arg in a local and avoid some potential aliasing issues to help the compiler. Info array is now 0-origin, not 1-origin.
* ; Fix off-by-one errorPhilipp Stephani2017-06-031-1/+1
|
* Fix a bug when using format field numbersPhilipp Stephani2017-06-031-56/+94
| | | | | | | | | | Previously styled_format overwrite the argument vector. This is no longer possible because there might be more than one specification per argument. Use the existing auxiliary info array instead. * src/editfns.c (styled_format): Record arguments in the info structure instead of overwriting them. * test/src/editfns-tests.el (format-with-field): Add unit test.
* Document uniqueness limitation of ‘format’Paul Eggert2017-06-031-3/+4
| | | | | | * doc/lispref/strings.texi (Formatting Strings): * src/editfns.c (Fformat): Document that field numbers should be unique within a format.
* Fix cursor position in Dired buffers after dired-sort-toggleEli Zaretskii2017-06-021-1/+20
| | | | | * src/xdisp.c (display_and_set_cursor): Record cursor coordinates even if the frame is marked as garbaged. (Bug#27187)
* Limit format fields to more POSIX-like specPaul Eggert2017-06-011-4/+4
| | | | | | | | | * doc/lispref/strings.texi (Formatting Strings): Don’t allow mixing numbered with unnumbered format specs. * src/editfns.c (styled_format): Don’t bother checking for field 0, since it doesn’t crash and the behavior is not specified. * test/src/editfns-tests.el (format-with-field): Adjust tests to match current doc. Add more tests for out-of-range fields.
* Improve performance by avoiding strtoumaxPaul Eggert2017-06-012-46/+56
| | | | | | | | | | | | | | | | This made (string-to-number "10") 20% faster on my old desktop, an AMD Phenom II X4 910e running Fedora 25 x86-64. * admin/merge-gnulib (GNULIB_MODULES): Remove strtoumax. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/strtoul.c, lib/strtoull.c, lib/strtoumax.c, m4/strtoull.m4: * m4/strtoumax.m4: Remove. * src/editfns.c (str2num): New function. (styled_format): Use it instead of strtoumax. Use ptrdiff_t instead of uintmax_t. Check for integer overflow. * src/lread.c (LEAD_INT, DOT_CHAR, TRAIL_INT, E_EXP): Move to private scope and make them enums. (string_to_number): Compute integer value directly during first pass instead of revisiting it with strtoumax later.
* Minor improvements to format field numbersPaul Eggert2017-06-021-36/+20
| | | | | | | * src/editfns.c (styled_format): Allow field numbers in a %% spec. No need for a special diagnostic for field numbers greater than PTRDIFF_MAX. Reword diagnostic for field 0. * test/src/editfns-tests.el (format-with-field): Adjust to match.