1. 28 Aug, 2013 1 commit
  2. 12 Aug, 2013 1 commit
    • Paul Eggert's avatar
      Fix some fd issues when running subprocesses. · 94fcd171
      Paul Eggert authored
      Fix bugs that can leak files or file descriptors on errors.
      Don't unlink open temp files, as that's hard for users to diagnose
      when things go awry (e.g., temp disk exhausted).
      Don't bother to lock temp files.  Check for invalid recursion.
      * callproc.c (synch_process_fd): Remove.  All uses removed.
      (synch_process_tempfile): New var or macro.
      (CALLPROC_STDOUT, CALLPROC_STDERR, CALLPROC_PIPEREAD, CALLPROC_FDS):
      New constants.
      (record_kill_process): New arg, the temp name.  All callers changed.
      (delete_temp_file): Now just a simple wrapper around unlink.
      (call_process_kill): New arg, the call_process_fd array.
      Close them all.  Clear synch_process_pid.  Remove the temp file,
      or arrange for it to be removed.
      (call_process_cleanup) [MSDOS]: Arg no longer contains file name;
      that's been moved to synch_process_tempfile.  Caller changed.
      Do not remove the tempfile; that's now call_process_kill's
      responsibility.
      (call_process_cleanup) [!MSDOS]: Do not record unwind-protect for
      call_process_kill; the caller now does that.
      (call_process_cleanup): Do not close the process fd; that's now
      call_process_kill's responsibility.
      (Fcall_process): Implement via new function call_process, which
      has most of the old body of Fcall_process, but with a different API.
      (call_process): New function that does not open or close filefd if
      it is nonnegative.  Record which fds need to be closed, and let
      call_process_kill close (and remove the tempfile, on MSDOS) on error.
      Signal an error if invoked recursively (could be done via a hook).
      Simplify creation of the tempfile in the MSDOS case.
      Don't create the output file until after checking for the executable.
      Report any failure to open /dev/null.
      Don't open /dev/null for writing twice; once is enough.
      Don't create pipe if all output is being discarded or sent to file.
      Don't worry about setting up the coding system or reading from the
      pipe if all output is being discarded.
      Hoist fd_error local into top level, to lessen block nesting.
      Don't record deleted pid here; now done by Fcall_process_region.
      (Fcall_process) [MSDOS]: Report mktemp failure immediately,
      and note its success in synch_process_tempfile.
      Do not leak resources when child_setup fails.
      (Fcall_process) [!MSDOS && !WINDOWSNT]: Remove duplicate assignment
      to child_errno.  Remove unnecessary close of fd0; it's close-on-exec.
      (create_temp_file): Now returns open fd, with an additional
      Lisp_Object * argument to return the name.  All callers changed.
      Do not close the file; rewind it instead, and leave it open for
      the caller.  Do not lock the temp file.  Unwind-protect the file
      and the file-descriptor.
      (Fcall_process_region): If the input is /dev/null, unwind-protect it.
      If an asynchrounous process, record it here, not in call_process.
      (syms_of_callproc) [MSDOS]: Initialize synch_process_tempfile.
      * eval.c (set_unwind_protect): New function.
      * fileio.c (write_region): New function, generalized from the
      old Fwrite_region.  Do not lock temp files.
      (Fwrite_region): Use it.
      * lisp.h (set_unwind_protect, write_region): New decls.
      * process.c: Include <verify.h>.
      (make_process): Mark fds as initially closed.
      (deleted_pid_list): Now a list of pid-filename pairs.
      All uses changed.
      (close_process_fd): New function.
      (SUBPROCESS_STDIN, WRITE_TO_SUBPROCESS, READ_FROM_SUBPROCESS)
      (SUBPROCESS_STDOUT, READ_FROM_EXEC_MONITOR, EXEC_MONITOR_OUTPUT):
      New constants.  Verify that their number matches PROCESS_OPEN_FDS.
      (create_process, create_pty, Fmake_serial_process)
      (server_accept_connection): Record which fds need to be closed,
      and let deactivate_process close them.
      (Fmake_network_process): Do not discard the unwind-protect
      until it's safe to do so.
      (deactivate_process): Close the fds opened by create_process etc.
      (Fprocess_send_eof): Adjust to new way of recording open fds.
      Report an error if /dev/null can't be opened, instead of aborting.
      * process.h (PROCESS_OPEN_FDS): New constant.
      (struct Lisp_Process): New member open_fds.
      (record_kill_process, record_deleted_pid): Adjust signatures.
      (record_deleted_pid): Move decl here ...
      * syswait.h (record_deleted_pid): ... from here.
      
      Fixes: debbugs:15035
      94fcd171
  3. 02 Aug, 2013 1 commit
    • Stefan Monnier's avatar
      Make defvar affect the default binding outside of any let. · a104f656
      Stefan Monnier authored
      * src/eval.c (default_toplevel_binding): New function.
      (Fdefvar): Use it.
      (unbind_to, backtrace_eval_unrewind): Do a bit of CSE simplification.
      (Fdefault_toplevel_value, Fset_default_toplevel_value): New subrs.
      (syms_of_eval): Export them.
      * src/data.c (Fdefault_value): Micro cleanup.
      * src/term.c (init_tty): Use "false".
      * lisp/custom.el (custom-initialize-default, custom-initialize-set)
      (custom-initialize-reset, custom-initialize-changed): Affect the
      toplevel-default-value (bug#6275, bug#14586).
      * lisp/emacs-lisp/advice.el (ad-compile-function): Undo previous workaround
      for bug#6275.
      * test/automated/core-elisp-tests.el: New file.
      a104f656
  4. 27 Jul, 2013 1 commit
  5. 26 Jul, 2013 2 commits
    • Paul Eggert's avatar
      Fix minor problems found by static checking. · d5a7a9d9
      Paul Eggert authored
      * eval.c (get_backtrace_frame, backtrace_eval_unrewind): Now static.
      (backtrace_eval_unrewind): ';' -> '{}' to pacify GCC.
      d5a7a9d9
    • Stefan Monnier's avatar
      Add support for lexical variables to the debugger's `e' command. · 56ea7291
      Stefan Monnier authored
      * lisp/emacs-lisp/debug.el (debug): Don't let-bind the debugger-outer-*
      vars, except for debugger-outer-match-data.
      (debugger-frame-number): Move check for "on a function call" from
      callers into it.  Add `skip-base' argument.
      (debugger-frame, debugger-frame-clear): Simplify accordingly.
      (debugger-env-macro): Only reset the state stored in non-variables,
      i.e. current-buffer and match-data.
      (debugger-eval-expression): Rewrite using backtrace-eval.
      * lisp/subr.el (internal--called-interactively-p--get-frame): Remove.
      (called-interactively-p):
      * lisp/emacs-lisp/edebug.el (edebug--called-interactively-skip): Use the new
      `base' arg of backtrace-frame instead.
      * src/eval.c (set_specpdl_old_value): New function.
      (unbind_to): Minor simplification.
      (get_backtrace_frame): New function.
      (Fbacktrace_frame): Use it.  Add `base' argument.
      (backtrace_eval_unrewind, Fbacktrace_eval): New functions.
      (syms_of_eval): Export backtrace-eval.
      * src/xterm.c (x_focus_changed): Simplify.
      56ea7291
  6. 24 Jul, 2013 1 commit
  7. 23 Jul, 2013 2 commits
  8. 21 Jul, 2013 1 commit
  9. 18 Jul, 2013 1 commit
    • Paul Eggert's avatar
      * charset.c: Fix file descriptor leaks and errno issues. · f4b1eb36
      Paul Eggert authored
      Include <errno.h>.
      (load_charset_map_from_file): Don't leak file descriptor on error.
      Use plain record_xmalloc since the allocation is larger than
      MAX_ALLOCA; that's simpler here.  Simplify test for exhaustion
      of entries.
      * eval.c (record_unwind_protect_nothing):
      * fileio.c (fclose_unwind):
      New functions.
      * lread.c (load_unwind): Remove.  All uses replaced by fclose_unwind.
      The replacement doesn't block input, but that no longer seems
      necessary.
      f4b1eb36
  10. 17 Jul, 2013 1 commit
    • Paul Eggert's avatar
      * lread.c: Fix file descriptor leaks and errno issues. · a0931322
      Paul Eggert authored
      (Fload): Close some races that leaked fds or streams when 'load'
      was interrupted.
      (Fload, openp): Report error number of last nontrivial failure to open.
      ENOENT counts as trivial.
      * eval.c (do_nothing, clear_unwind_protect, set_unwind_protect_ptr):
      New functions.
      * fileio.c (close_file_unwind): No need to test whether FD is nonnegative,
      now that the function is always called with a nonnegative arg.
      * lisp.h (set_unwind_protect_ptr, set_unwind_protect_int): Remove.
      All uses replaced with ...
      (clear_unwind_protect, set_unwind_protect_ptr): New decls.
      a0931322
  11. 16 Jul, 2013 2 commits
    • Paul Eggert's avatar
      New unwind-protect flavors to better type-check C callbacks. · 27e498e6
      Paul Eggert authored
      This also lessens the need to write wrappers for callbacks,
      and the need for make_save_pointer.
      * alloca.c (free_save_value):
      * atimer.c (run_all_atimers):
      Now extern.
      * alloc.c (safe_alloca_unwind):
      * atimer.c (unwind_stop_other_atimers):
      * keyboard.c (cancel_hourglass_unwind) [HAVE_WINDOW_SYSTEM]:
      * menu.c (cleanup_popup_menu) [HAVE_NS]:
      * minibuf.c (choose_minibuf_frame_1):
      * process.c (make_serial_process_unwind):
      * xdisp.h (pop_message_unwind):
      * xselect.c (queue_selection_requests_unwind):
      Remove no-longer-needed wrapper.  All uses replaced by the wrappee.
      * alloca.c (record_xmalloc):
      Prefer record_unwind_protect_ptr to record_unwind_protect with
      make_save_pointer.
      * alloca.c (Fgarbage_collect):
      Prefer record_unwind_protect_void to passing a dummy.
      * buffer.c (restore_buffer):
      * window.c (restore_window_configuration):
      * xfns.c, w32fns.c (do_unwind_create_frame)
      New wrapper.  All record-unwind uses of wrappee changed.
      * buffer.c (set_buffer_if_live):
      * callproc.c (call_process_cleanup, delete_temp_file):
      * coding.c (code_conversion_restore):
      * dired.c (directory_files_internal_w32_unwind) [WINDOWSNT]:
      * editfns.c (save_excursion_restore)
      (subst_char_in_region_unwind, subst_char_in_region_unwind_1)
      (save_restriction_restore):
      * eval.c (restore_stack_limits, un_autoload):
      * fns.c (require_unwind):
      * keyboard.c (recursive_edit_unwind, tracking_off):
      * lread.c (record_load_unwind, load_warn_old_style_backquotes):
      * macros.c (pop_kbd_macro, restore_menu_items):
      * nsfns.m (unwind_create_frame):
      * print.c (print_unwind):
      * process.c (start_process_unwind):
      * search.c (unwind_set_match_data):
      * window.c (select_window_norecord, select_frame_norecord):
      * xdisp.c (unwind_with_echo_area_buffer, unwind_format_mode_line)
      (fast_set_selected_frame):
      * xfns.c, w32fns.c (unwind_create_tip_frame):
      Return void, not a dummy Lisp_Object.  All uses changed.
      * buffer.h (set_buffer_if_live): Move decl here from lisp.h.
      * callproc.c (call_process_kill):
      * fileio.c (restore_point_unwind, decide_coding_unwind)
      (build_annotations_unwind):
      * insdel.c (Fcombine_after_change_execute_1):
      * keyboard.c (read_char_help_form_unwind):
      * menu.c (unuse_menu_items):
      * minibuf.c (run_exit_minibuf_hook, read_minibuf_unwind):
      * sound.c (sound_cleanup):
      * xdisp.c (unwind_redisplay):
      * xfns.c (clean_up_dialog):
      * xselect.c (x_selection_request_lisp_error, x_catch_errors_unwind):
      Accept no args and return void, instead of accepting and returning
      a dummy Lisp_Object.  All uses changed.
      * cygw32.c (fchdir_unwind):
      * fileio.c (close_file_unwind):
      * keyboard.c (restore_kboard_configuration):
      * lread.c (readevalllop_1):
      * process.c (wait_reading_process_output_unwind):
      Accept int and return void, rather than accepting an Emacs integer
      and returning a dummy object.  In some cases this fixes an
      unlikely bug when the corresponding int is outside Emacs integer
      range.  All uses changed.
      * dired.c (directory_files_internal_unwind):
      * fileio.c (do_auto_save_unwind):
      * gtkutil.c (pop_down_dialog):
      * insdel.c (reset_var_on_error):
      * lread.c (load_unwind):
      * xfns.c (clean_up_file_dialog):
      * xmenu.c, nsmenu.m (pop_down_menu):
      * xmenu.c (cleanup_widget_value_tree):
      * xselect.c (wait_for_property_change_unwind):
      Accept pointer and return void, rather than accepting an Emacs
      save value encapsulating the pointer and returning a dummy object.
      All uses changed.
      * editfns.c (Fformat): Update the saved pointer directly via
      set_unwind_protect_ptr rather than indirectly via make_save_pointer.
      * eval.c (specpdl_func): Remove.  All uses replaced by definiens.
      (unwind_body): New function.
      (record_unwind_protect): First arg is now a function returning void,
      not a dummy Lisp_Object.
      (record_unwind_protect_ptr, record_unwind_protect_int)
      (record_unwind_protect_void): New functions.
      (unbind_to): Support SPECPDL_UNWIND_PTR etc.
      * fileio.c (struct auto_save_unwind): New type.
      (do_auto_save_unwind): Use it.
      (do_auto_save_unwind_1): Remove; subsumed by new do_auto_save_unwind.
      * insdel.c (struct rvoe_arg): New type.
      (reset_var_on_error): Use it.
      * lisp.h (SPECPDL_UNWIND_PTR, SPECPDL_UNWIND_INT, SPECPDL_UNWIND_VOID):
      New constants.
      (specbinding_func): Remove; there are now several such functions.
      (union specbinding): New members unwind_ptr, unwind_int, unwind_void.
      (set_unwind_protect_ptr): New function.
      * xselect.c: Remove unnecessary forward decls, to simplify maintenance.
      27e498e6
    • Paul Eggert's avatar
      Prefer list1 (X) to Fcons (X, Qnil) when building lists. · 6c6f1994
      Paul Eggert authored
      This makes the code easier to read and the executable a bit smaller.
      Do not replace all calls to Fcons that happen to create lists,
      just calls that are intended to create lists.  For example, when
      creating an alist that maps FOO to nil, use list1 (Fcons (FOO, Qnil))
      rather than list1 (list1 (FOO)) or Fcons (Fcons (FOO, Qnil), Qnil).
      Similarly for list2 through list5.
      * buffer.c (Fget_buffer_create, Fmake_indirect_buffer):
      * bytecode.c (exec_byte_code):
      * callint.c (quotify_arg, Fcall_interactively):
      * callproc.c (Fcall_process, create_temp_file):
      * charset.c (load_charset_map_from_file)
      (Fdefine_charset_internal, init_charset):
      * coding.c (get_translation_table, detect_coding_system)
      (Fcheck_coding_systems_region)
      (Fset_terminal_coding_system_internal)
      (Fdefine_coding_system_internal, Fdefine_coding_system_alias):
      * composite.c (update_compositions, Ffind_composition_internal):
      * dired.c (directory_files_internal, file_name_completion)
      (Fsystem_users):
      * dispnew.c (Fopen_termscript, bitch_at_user, init_display):
      * doc.c (Fsnarf_documentation):
      * editfns.c (Fmessage_box):
      * emacs.c (main):
      * eval.c (do_debug_on_call, signal_error, maybe_call_debugger)
      (Feval, eval_sub, Ffuncall, apply_lambda):
      * fileio.c (make_temp_name, Fcopy_file, Faccess_file)
      (Fset_file_selinux_context, Fset_file_acl, Fset_file_modes)
      (Fset_file_times, Finsert_file_contents)
      (Fchoose_write_coding_system, Fwrite_region):
      * fns.c (Flax_plist_put, Fyes_or_no_p, syms_of_fns):
      * font.c (font_registry_charsets, font_parse_fcname)
      (font_prepare_cache, font_update_drivers, Flist_fonts):
      * fontset.c (Fset_fontset_font, Ffontset_info, syms_of_fontset):
      * frame.c (make_frame, Fmake_terminal_frame)
      (x_set_frame_parameters, x_report_frame_params)
      (x_default_parameter, Fx_parse_geometry):
      * ftfont.c (syms_of_ftfont):
      * image.c (gif_load):
      * keyboard.c (command_loop_1):
      * keymap.c (Fmake_keymap, Fmake_sparse_keymap, access_keymap_1)
      (Fcopy_keymap, append_key, Fcurrent_active_maps)
      (Fminor_mode_key_binding, accessible_keymaps_1)
      (Faccessible_keymaps, Fwhere_is_internal):
      * lread.c (read_emacs_mule_char):
      * menu.c (find_and_return_menu_selection):
      * minibuf.c (get_minibuffer):
      * nsfns.m (Fns_perform_service):
      * nsfont.m (ns_script_to_charset):
      * nsmenu.m (ns_popup_dialog):
      * nsselect.m (ns_get_local_selection, ns_string_from_pasteboard)
      (Fx_own_selection_internal):
      * nsterm.m (append2):
      * print.c (Fredirect_debugging_output)
      (print_prune_string_charset):
      * process.c (Fdelete_process, Fprocess_contact)
      (Fformat_network_address, set_socket_option)
      (read_and_dispose_of_process_output, write_queue_push)
      (send_process, exec_sentinel):
      * sound.c (Fplay_sound_internal):
      * textprop.c (validate_plist, add_properties)
      (Fput_text_property, Fadd_face_text_property)
      (copy_text_properties, text_property_list, syms_of_textprop):
      * unexaix.c (report_error):
      * unexcoff.c (report_error):
      * unexsol.c (unexec):
      * xdisp.c (redisplay_tool_bar, store_mode_line_string)
      (Fformat_mode_line, syms_of_xdisp):
      * xfaces.c (set_font_frame_param)
      (Finternal_lisp_face_attribute_values)
      (Finternal_merge_in_global_face, syms_of_xfaces):
      * xfns.c (x_default_scroll_bar_color_parameter)
      (x_default_font_parameter, x_create_tip_frame):
      * xfont.c (xfont_supported_scripts):
      * xmenu.c (Fx_popup_dialog, xmenu_show, xdialog_show)
      (menu_help_callback, xmenu_show):
      * xml.c (make_dom):
      * xterm.c (set_wm_state):
      Prefer list1 (FOO) to Fcons (FOO, Qnil) when creating a list,
      and similarly for list2 through list5.
      6c6f1994
  12. 13 Jul, 2013 1 commit
    • Paul Eggert's avatar
      Don't lose top specpdl entry when memory is exhausted. · 5e301d76
      Paul Eggert authored
      * eval.c (grow_specpdl): Increment specpdl top by 1 and check for
      specpdl overflow here, to simplify callers; all callers changed.
      Always reserve an unused entry at the stack top; this avoids
      losing the top entry's information when memory is exhausted.
      5e301d76
  13. 11 Jul, 2013 1 commit
  14. 18 Jun, 2013 1 commit
    • Paul Eggert's avatar
      Porting fixes for merged specpdl and backtrace stacks. · 9349e5f7
      Paul Eggert authored
      In particular this ports to 32-bit sparc Sun cc.
      * eval.c (init_eval_once, grow_specpdl): Allocate a specbinding
      array with a dummy element at specpdl[-1], so that its address can
      be taken portably.
      (unbind_to): Do not copy the binding; not needed, now that we
      copy old_value in the one place where the copy is needed.
      * fileio.c (Fwrite_region): Use ptrdiff_t, not int, for specpdl count.
      * lisp.h (BITS_PER_PTRDIFF_T): Remove; no longer needed.
      (union specbinding): Rename from struct specbinding.  Redo layout
      to avoid the need for 'ptrdiff_t nargs : BITS_PER_PTRDIFF_T - 1;',
      which is not portable.  With Sun C 5.12 32-bit sparc, the
      declaration causes nargs to be an unsigned bitfield, a behavior
      that the C standard allows; but Emacs wants nargs to be signed.
      The overall type is now a union of structures rather than a
      structure of union of structures, and the 'kind' member is now a
      bitfield, so that the overall type doesn't grow.  All uses changed.
      * process.c (Fmake_serial_process): Remove unnecessary initialization.
      
      Fixes: debbugs:14643
      9349e5f7
  15. 17 Jun, 2013 1 commit
    • Paul Eggert's avatar
      Use functions, not macros, for XINT etc. · 84575e67
      Paul Eggert authored
      In lisp.h, prefer functions to function-like macros, and
      constants to object-like macros, when either will do.  This:
       . simplifies use, as there's no more need to worry about
         arguments' side effects being evaluated multiple times.
       . makes the code easier to debug on some platforms.
      However, when using gcc -O0, keep using function-like macros
      for a few critical operations, for performance reasons.
      This sort of thing isn't needed with gcc -Og, but -Og
      is a GCC 4.8 feature and isn't widely-enough available yet.
      Also, move functions from lisp.h to individual modules when possible.
      From a suggestion by Andreas Schwab in <http://bugs.gnu.org/11935#68>.
      * alloc.c (XFLOAT_INIT, set_symbol_name):
      * buffer.c (CHECK_OVERLAY):
      * chartab.c (CHECK_CHAR_TABLE, set_char_table_ascii)
      (set_char_table_parent):
      * coding.c (CHECK_NATNUM_CAR, CHECK_NATNUM_CDR):
      * data.c (BOOLFWDP, INTFWDP, KBOARD_OBJFWDP, OBJFWDP, XBOOLFWD)
      (XKBOARD_OBJFWD, XINTFWD, XOBJFWD, CHECK_SUBR, set_blv_found)
      (blv_value, set_blv_value, set_blv_where, set_blv_defcell)
      (set_blv_valcell):
      * emacs.c (setlocale) [!HAVE_SETLOCALE]:
      * eval.c (specpdl_symbol, specpdl_old_value, specpdl_where)
      (specpdl_arg, specpdl_func, backtrace_function, backtrace_nargs)
      (backtrace_args, backtrace_debug_on_exit):
      * floatfns.c (CHECK_FLOAT):
      * fns.c (CHECK_HASH_TABLE, CHECK_LIST_END)
      (set_hash_key_and_value, set_hash_next, set_hash_next_slot)
      (set_hash_hash, set_hash_hash_slot, set_hash_index)
      (set_hash_index_slot):
      * keymap.c (CHECK_VECTOR_OR_CHAR_TABLE):
      * marker.c (CHECK_MARKER):
      * textprop.c (CHECK_STRING_OR_BUFFER):
      * window.c (CHECK_WINDOW_CONFIGURATION):
      Move here from lisp.h, and make these functions static rather than
      extern inline.
      * buffer.c (Qoverlayp):
      * data.c (Qsubrp):
      * fns.c (Qhash_table_p):
      * window.c (Qwindow_configuration_p):
      Now static.
      * lisp.h: Remove the abovementioned defns and decls.
      
      * configure.ac (WARN_CFLAGS): Remove -Wbad-function-cast,
      as it generates bogus warnings about reasonable casts of calls.
      * alloc.c (gdb_make_enums_visible) [USE_LSB_TAG]:
      Remove enum lsb_bits; no longer needed.
      (allocate_misc, free_misc): Don't use XMISCTYPE as an lvalue.
      * buffer.c (Qoverlap):
      * data.c (Qsubrp):
      * fns.c (Qhash_table_p):
      Now extern, so lisp.h can use these symbols.
      * dispextern.h: Include character.h, for MAX_CHAR etc.
      (GLYPH, GLYPH_CHAR, GLYPH_FACE, SET_GLYPH_CHAR, SET_GLYPH_FACE)
      (SET_GLYPH, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
      (SET_GLYPH_FROM_GLYPH_CODE, GLYPH_MODE_LINE_FACE, GLYPH_CHAR_VALID_P)
      (GLYPH_CODE_P): Move here from lisp.h.
      (GLYPH_CHAR, GLYPH_FACE, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
      (GLYPH_CHAR_VALID_P, GLYPH_CODE_P): Now functions, not macros.
      (GLYPH_MODE_LINE_FACE): Now enums, not macros.
      * eval.c (Fautoload): Cast XUNTAG output to intptr_t, since
      XUNTAG now returns void *.
      * lisp.h (lisp_h_XLI, lisp_h_XIL, lisp_h_CHECK_LIST_CONS)
      (lisp_h_CHECK_NUMBER CHECK_SYMBOL, lisp_h_CHECK_TYPE)
      (lisp_h_CONSP, lisp_h_EQ, lisp_h_FLOATP, lisp_h_INTEGERP)
      (lisp_h_MARKERP, lisp_h_MISCP, lisp_h_NILP)
      (lisp_h_SET_SYMBOL_VAL, lisp_h_SYMBOL_CONSTANT_P)
      (lisp_h_SYMBOL_VAL, lisp_h_SYMBOLP, lisp_h_VECTORLIKEP)
      (lisp_h_XCAR, lisp_h_XCDR, lisp_h_XCONS, lisp_h_XHASH)
      (lisp_h_XPNTR, lisp_h_XSYMBOL):
      New macros, renamed from their sans-lisp_h_ counterparts.
      (XLI, XIL, CHECK_LIST_CONS, CHECK_NUMBER CHECK_SYMBOL)
      (CHECK_TYPE, CONSP, EQ, FLOATP, INTEGERP, MARKERP)
      (MISCP, NILP, SET_SYMBOL_VAL, SYMBOL_CONSTANT_P, SYMBOL_VAL, SYMBOLP)
      (VECTORLIKEP, XCAR, XCDR, XCONS, XHASH, XPNTR, XSYMBOL):
      If compiling via GCC without optimization, define these as macros
      in addition to inline functions.
      To disable this, compile with -DINLINING=0.
      (LISP_MACRO_DEFUN, LISP_MACRO_DEFUN_VOID): New macros.
      (check_cons_list) [!GC_CHECK_CONS_LIST]: Likewise.
      (make_number, XFASTINT, XINT, XTYPE, XUNTAG): Likewise, but
      hand-optimize only in the USE_LSB_TAG case, as GNUish hosts do that.
      (INTMASK, VALMASK): Now macros, since static values cannot be
      accessed from extern inline functions.
      (VALMASK): Also a constant, for benefit of old GDB.
      (LISP_INT_TAG_P): Remove; no longer needed as the only caller
      is INTEGERP, which can fold it in.
      (XLI, XIL, XHASH, XTYPE,XINT, XFASTINT, XUINT)
      (make_number, XPNTR, XUNTAG, EQ, XCONS, XVECTOR, XSTRING, XSYMBOL)
      (XFLOAT, XPROCESS, XWINDOW, XTERMINAL, XSUBR, XBUFFER, XCHAR_TABLE)
      (XSUB_CHAR_TABLE, XBOOL_VECTOR, make_lisp_ptr, CHECK_TYPE)
      (CHECK_STRING_OR_BUFFER, XCAR, XCDR, XSETCAR, XSETCDR, CAR, CDR)
      (CAR_SAFE, CDR_SAFE, STRING_MULTIBYTE, SDATA, SSDATA, SREF, SSET)
      (SCHARS, STRING_BYTES, SBYTES, STRING_SET_CHARS, STRING_COPYIN, AREF)
      (ASIZE, ASET, CHAR_TABLE_REF_ASCII, CHAR_TABLE_REF)
      (CHAR_TABLE_SET, CHAR_TABLE_EXTRA_SLOTS, SYMBOL_VAL, SYMBOL_ALIAS)
      (SYMBOL_BLV, SYMBOL_FWD, SET_SYMBOL_VAL, SET_SYMBOL_ALIAS)
      (SET_SYMBOL_BLV, SET_SYMBOL_FWD, SYMBOL_NAME, SYMBOL_INTERNED_P)
      (SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P, SYMBOL_CONSTANT_P)
      (XHASH_TABLE, HASH_TABLE_P, CHECK_HASH_TABLE, HASH_KEY, HASH_VALUE)
      (HASH_NEXT, HASH_HASH, HASH_INDEX, HASH_TABLE_SIZE)
      (XMISC, XMISCANY, XMARKER, XOVERLAY, XSAVE_VALUE, XFWDTYPE)
      (XINTFWD, XBOOLFWD, XOBJFWD, XBUFFER_OBJFWD, XKBOARD_OBJFWD)
      (XFLOAT_DATA, XFLOAT_INIT, NILP, NUMBERP, NATNUMP)
      (RANGED_INTEGERP, CONSP, FLOATP, MISCP, STRINGP, SYMBOLP)
      (INTEGERP, VECTORLIKEP, VECTORP, OVERLAYP)
      (MARKERP, SAVE_VALUEP, AUTOLOADP, INTFWDP, BOOLFWDP, OBJFWDP)
      (BUFFER_OBJFWDP, KBOARD_OBJFWDP, PSEUDOVECTOR_TYPEP)
      (PSEUDOVECTORP, WINDOW_CONFIGURATIONP, PROCESSP, WINDOWP)
      (TERMINALP, SUBRP, COMPILEDP, BUFFERP, CHAR_TABLE_P)
      (SUB_CHAR_TABLE_P, BOOL_VECTOR_P, FRAMEP, IMAGEP, ARRAYP)
      (CHECK_LIST, CHECK_LIST_CONS, CHECK_LIST_END, CHECK_STRING)
      (CHECK_STRING_CAR, CHECK_CONS, CHECK_SYMBOL, CHECK_CHAR_TABLE)
      (CHECK_VECTOR, CHECK_VECTOR_OR_STRING, CHECK_ARRAY)
      (CHECK_VECTOR_OR_CHAR_TABLE, CHECK_BUFFER, CHECK_WINDOW)
      (CHECK_WINDOW_CONFIGURATION, CHECK_PROCESS, CHECK_SUBR)
      (CHECK_NUMBER, CHECK_NATNUM, CHECK_MARKER, XFLOATINT)
      (CHECK_FLOAT, CHECK_NUMBER_OR_FLOAT, CHECK_OVERLAY)
      (CHECK_NUMBER_CAR, CHECK_NUMBER_CDR, CHECK_NATNUM_CAR)
      (CHECK_NATNUM_CDR, FUNCTIONP, SPECPDL_INDEX, LOADHIST_ATTACH)
      Now functions.
      (check_cons_list) [!GC_CHECK_CONS_LIST]: New empty function.
      (LISP_MAKE_RVALUE, TYPEMASK): Remove; no longer needed.
      (VALMASK): Define in one place rather than in two, merging the
      USE_LSB_TAG parts; this is simpler.
      (aref_addr, gc_aset, MOST_POSITIVE_FIXNUM, MOST_NEGATIVE_FIXNUM)
      (max, min, struct Lisp_String, UNSIGNED_CMP, ASCII_CHAR_P):
      Move up, to avoid use before definition.
      Also include "globals.h" earlier, for the same reason.
      (make_natnum): New function.
      (XUNTAG): Now returns void *, not intptr_t, as this means fewer casts.
      (union Lisp_Fwd, BOOLFWDP, BOOL_VECTOR_P, BUFFER_OBJFWDP, BUFFERP)
      (CHAR_TABLE_P, CHAR_TABLE_REF_ASCII, CONSP, FLOATP, INTEGERP, INTFWDP)
      (KBOARD_OBJFWDP, MARKERP, MISCP, NILP, OBJFWDP, OVERLAYP, PROCESSP)
      (PSEUDOVECTORP, SAVE_VALUEP, STRINGP, SUB_CHAR_TABLE_P, SUBRP, SYMBOLP)
      (VECTORLIKEP, WINDOWP, Qoverlayp, char_table_ref, char_table_set)
      (char_table_translate, Qarrayp, Qbufferp, Qbuffer_or_string_p)
      (Qchar_table_p, Qconsp, Qfloatp, Qintegerp, Qlambda, Qlistp, Qmarkerp)
      (Qnil, Qnumberp, Qsubrp, Qstringp, Qsymbolp, Qvectorp)
      (Qvector_or_char_table_p, Qwholenump, Ffboundp, wrong_type_argument)
      (initialized, Qhash_table_p, extract_float, Qprocessp, Qwindowp)
      (Qwindow_configuration_p, Qimage): New forward declarations.
      (XSETFASTINT): Simplify by rewriting in terms of make_natnum.
      (STRING_COPYIN): Remove; unused.
      (XCAR_AS_LVALUE, XCDR_AS_LVALUE): Remove these macros, replacing with ...
      (xcar_addr, xcdr_addr): New functions.  All uses changed.
      (IEEE_FLOATING_POINT): Now a constant, not a macro.
      (GLYPH, GLYPH_CHAR, GLYPH_FACE, SET_GLYPH_CHAR, SET_GLYPH_FACE)
      (SET_GLYPH, GLYPH_CODE_CHAR, GLYPH_CODE_FACE)
      (SET_GLYPH_FROM_GLYPH_CODE, GLYPH_MODE_LINE_FACE, GLYPH_CHAR_VALID_P)
      (GLYPH_CODE_P): Move to dispextern.h, to avoid define-before-use.
      (TYPE_RANGED_INTEGERP): Simplify.
      (Qsubrp, Qhash_table_p, Qoverlayp): New extern decls.
      (setlocale, fixup_locale, synchronize_system_messages_locale)
      (synchronize_system_time_locale) [!HAVE_SETLOCALE]:
      Now empty functions, not macros.
      (functionp): Return bool, not int.
      * window.c (Qwindow_configuration_p): Now extern,
      so window.h can use it.
      * window.h (Qwindowp): Move decl back to lisp.h.
      84575e67
  16. 03 Jun, 2013 3 commits
    • Paul Eggert's avatar
      Fix minor problems found by static checking. · 3d5ee10a
      Paul Eggert authored
      * data.c (pure_write_error):
      Use xsignal2, not Fsignal, as Fsignal might return.
      * eval.c (set_backtrace_debug_on_exit): Now static.
      (backtrace_p, backtrace_top, backtrace_next, record_in_backtrace):
      No longer inline.  EXTERN_INLINE is needed only for functions
      defined in .h files.  Reindent function header as per GNU style.
      (backtrace_p, backtrace_top, backtrace_next):
      Mark EXTERNALLY_VISIBLE so they don't get optimized away by the
      compiler or linker.  Add extern decls to pacify gcc -Wall.
      * frame.c, frame.h (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource):
      Now static.
      * frame.c (free_monitors): Define only on platforms that need it.
      * nsterm.m (ns_term_init):
      * process.c (catch_child_signal):
      Don't worry about whether SIGCHLD is defined, as SIGCHLD is
      defined on all porting targets these days.
      * process.c, process.h (catch_child_signal):
      Make it extern only if NS_IMPL_GNUSTEP is defined.
      3d5ee10a
    • Stefan Monnier's avatar
      * src/eval.c (backtrace_p, backtrace_top, backtrace_next): Export them to · a8a7c5f6
      Stefan Monnier authored
      .gdbinit.
      * src/data.c (pure_write_error): Add `object' argument.
      * src/puresize.h (CHECK_IMPURE): Use it.
      * src/keyboard.c (safe_run_hooks_error): Improve error message.
      a8a7c5f6
    • Stefan Monnier's avatar
      Merge the specpdl and backtrace stacks. Make the structure of the · 2f592f95
      Stefan Monnier authored
      specpdl entries more obvious via a tagged union of structs.
      * src/lisp.h (BITS_PER_PTRDIFF_T): New constant.
      (enum specbind_tag): New enum.
      (struct specbinding): Make it a tagged union of structs.
      Add a case for backtrace records.
      (specpdl_symbol, specpdl_old_value, specpdl_where, specpdl_arg)
      (specpdl_func, backtrace_function, backtrace_nargs, backtrace_args)
      (backtrace_debug_on_exit): New accessors.
      (struct backtrace): Remove.
      (struct catchtag): Remove backlist field.
      * src/data.c (let_shadows_buffer_binding_p, let_shadows_global_binding_p):
      Move to eval.c.
      (Flocal_variable_p): Speed up the common case where the binding is
      already loaded.
      * src/eval.c (backtrace_list): Remove.
      (set_specpdl_symbol, set_specpdl_old_value): Remove.
      (set_backtrace_args, set_backtrace_nargs)
      (set_backtrace_debug_on_exit, backtrace_p, backtrace_top)
      (backtrace_next): New functions.
      (Fdefvaralias, Fdefvar): Adjust to new specpdl format.
      (unwind_to_catch, internal_lisp_condition_case)
      (internal_condition_case, internal_condition_case_1)
      (internal_condition_case_2, internal_condition_case_n): Don't bother
      with backtrace_list any more.
      (Fsignal): Adjust to new backtrace format.
      (grow_specpdl): Move up.
      (record_in_backtrace): New function.
      (eval_sub, Ffuncall): Use it.
      (apply_lambda): Adjust to new backtrace format.
      (let_shadows_buffer_binding_p, let_shadows_global_binding_p): Move from
      data.c.
      (specbind): Adjust to new specpdl format.  Simplify.
      (record_unwind_protect, unbind_to): Adjust to new specpdl format.
      (Fbacktrace_debug, Fbacktrace, Fbacktrace_frame): Adjust to new
      backtrace format.
      (mark_backtrace): Remove.
      (mark_specpdl, get_backtrace, backtrace_top_function): New functions.
      * src/xdisp.c (redisplay_internal): Use record_in_backtrace.
      * src/alloc.c (Fgarbage_collect): Use record_in_backtrace.
      Use mark_specpdl.
      * src/profiler.c (record_backtrace): Use get_backtrace.
      (handle_profiler_signal): Use backtrace_top_function.
      * src/.gdbinit (xbacktrace, hookpost-backtrace): Use new backtrace
      accessor functions.
      2f592f95
  17. 13 Mar, 2013 1 commit
    • Paul Eggert's avatar
      Static checking by Sun C 5.12. · d9df6f40
      Paul Eggert authored
      * lib-src/etags.c (analyse_regex): Omit unreachable code.
      * src/alloc.c (buffer_memory_full) [REL_ALLOC]:
      * src/bytecode.c (exec_byte_code):
      * src/dispnew.c (init_display):
      * src/eval.c (error):
      * src/fileio.c (Fsubstitute_in_file_name):
      * src/keyboard.c (Fevent_convert_list):
      * src/keymap.c (Fsingle_key_description):
      * src/term.c (maybe_fatal, fatal):
      * src/xfns.c (Fx_display_backing_store, Fx_display_visual_class):
      * src/xsmfns.c (Fhandle_save_session):
      Omit unreachable code.
      * src/keymap.c (map_keymap_char_table_item): Cast void * to
      a function pointer type; the C Standard requires this.
      d9df6f40
  18. 25 Feb, 2013 1 commit
  19. 14 Feb, 2013 1 commit
    • Paul Eggert's avatar
      Backport GCPRO fix from trunk. · 974c7646
      Paul Eggert authored
      The bug was reported for AIX before today's changes.
      I reproduced the problem on Fedora 17 x86-64 when setting
      GC_MARK_STACK by hand, and I presume it occurs with default
      configurations on HP-UX and Unixware.
      Trunk fix on 2013-01-14 by Dmitry Antipov <dmantipov@yandex.ru>:
      Fix compilation with GC_MARK_STACK == GC_USE_GCPROS_AS_BEFORE.
      * eval.c (eval_sub): Protect `form' from being GCed before its
      car and cdr becomes protected with the backtrace entry.
      
      Fixes: debbugs:13650
      974c7646
  20. 14 Jan, 2013 1 commit
  21. 11 Jan, 2013 1 commit
  22. 01 Jan, 2013 1 commit
  23. 20 Nov, 2012 3 commits
    • Stefan Monnier's avatar
      Conflate Qnil and Qunbound for `symbol-function'. · eadf1faa
      Stefan Monnier authored
      * src/alloc.c (Fmake_symbol): Initialize `function' to Qnil.
      * src/lread.c (init_obarray): Set `function' fields to Qnil.
      * src/eval.c (Fcommandp): Ignore Qunbound.
      (Fautoload, eval_sub, Fapply, Ffuncall, Fmacroexpand):
      * src/data.c (Ffset, Ffboundp, indirect_function, Findirect_function):
      Test NILP rather than Qunbound.
      (Ffmakunbound): Set to Qnil.
      (Fsymbol_function): Never signal an error.
      (Finteractive_form): Ignore Qunbound.
      eadf1faa
    • Paul Eggert's avatar
      b83fdfa9
    • Stefan Monnier's avatar
      Make called-interactively-p work for edebug or advised code. · 23ba2705
      Stefan Monnier authored
      * lisp/subr.el (called-interactively-p-functions): New var.
      (internal--called-interactively-p--get-frame): New macro.
      (called-interactively-p, interactive-p): Rewrite in Lisp.
      * lisp/emacs-lisp/nadvice.el (advice--called-interactively-skip): New fun.
      (called-interactively-p-functions): Use it.
      * lisp/emacs-lisp/edebug.el (edebug--called-interactively-skip): New fun.
      (called-interactively-p-functions): Use it.
      * lisp/allout.el (allout-called-interactively-p): Don't assume
      called-interactively-p is a subr.
      * src/eval.c (Finteractive_p, Fcalled_interactively_p, interactive_p): Remove.
      (syms_of_eval): Remove corresponding defsubr.
      * src/bytecode.c (exec_byte_code): `interactive-p' is now a Lisp function.
      * test/automated/advice-tests.el (advice-tests--data): Remove.
      (advice-tests): Move the tests directly here instead.
      Add called-interactively-p tests.
      23ba2705
  24. 15 Nov, 2012 2 commits
  25. 09 Nov, 2012 1 commit
    • Stefan Monnier's avatar
      Provide new `defalias-fset-function' symbol property. · 32e5c58c
      Stefan Monnier authored
      * src/lisp.h (AUTOLOADP): New macro.
      * src/eval.c (Fautoload): Don't attach to loadhist, call Fdefalias instead.
      * src/data.c (Ffset): Remove special ad-advice-info handling.
      (Fdefalias): Handle autoload definitions and new Qdefalias_fset_function.
      (Fsubr_arity): CSE.
      (Finteractive_form): Simplify.
      (Fquo): Don't insist on having at least 2 arguments.
      (Qdefalias_fset_function): New var.
      * lisp/emacs-lisp/advice.el (ad-set-advice-info): Set defalias-fset-function.
      (ad--defalias-fset): New function.
      (ad-safe-fset): Remove.
      (ad-make-freeze-definition): Use cl-letf*.
      32e5c58c
  26. 11 Oct, 2012 1 commit
  27. 01 Oct, 2012 1 commit
    • Paul Eggert's avatar
      Prefer plain 'static' to 'static inline'. · b0ab8123
      Paul Eggert authored
      With static functions, modern compilers inline pretty well by
      themselves; advice from programmers often hurts as much as it helps.
      On my host (x86-64, Fedora 17, GCC 4.7.2, default 'configure'),
      this change shrinks the text size of the Emacs executable by 1.1%
      without affecting CPU significantly in my benchmark.
      * alloc.c (mem_find, live_string_p, live_cons_p, live_symbol_p)
      (live_float_p, live_misc_p, live_vector_p, live_buffer_p)
      (mark_maybe_object, mark_maybe_pointer, bounded_number):
      * buffer.c (bset_abbrev_mode, bset_abbrev_table)
      (bset_auto_fill_function, bset_auto_save_file_format)
      (bset_auto_save_file_name, bset_backed_up, bset_begv_marker)
      (bset_bidi_display_reordering, bset_buffer_file_coding_system)
      (bset_cache_long_line_scans, bset_case_fold_search)
      (bset_ctl_arrow, bset_cursor_in_non_selected_windows)
      (bset_cursor_type, bset_display_table, bset_extra_line_spacing)
      (bset_file_format, bset_file_truename, bset_fringe_cursor_alist)
      (bset_fringe_indicator_alist, bset_fringes_outside_margins)
      (bset_header_line_format, bset_indicate_buffer_boundaries)
      (bset_indicate_empty_lines, bset_invisibility_spec)
      (bset_left_fringe_width, bset_major_mode, bset_mark)
      (bset_minor_modes, bset_mode_line_format, bset_mode_name)
      (bset_name, bset_overwrite_mode, bset_pt_marker)
      (bset_right_fringe_width, bset_save_length)
      (bset_scroll_bar_width, bset_scroll_down_aggressively)
      (bset_scroll_up_aggressively, bset_selective_display)
      (bset_selective_display_ellipses, bset_vertical_scroll_bar_type)
      (bset_word_wrap, bset_zv_marker, set_buffer_overlays_before)
      (set_buffer_overlays_after):
      * category.c (bset_category_table):
      * charset.c (read_hex):
      * coding.c (produce_composition, produce_charset)
      (handle_composition_annotation, handle_charset_annotation)
      (char_encodable_p):
      * dispnew.c (swap_glyph_pointers, copy_row_except_pointers)
      (assign_row, set_frame_matrix_frame, make_current)
      (add_row_entry):
      * eval.c (set_specpdl_symbol, set_specpdl_old_value):
      * fns.c (maybe_resize_hash_table):
      * frame.c (fset_buffer_predicate, fset_minibuffer_window):
      * gmalloc.c (register_heapinfo):
      * image.c (lookup_image_type):
      * intervals.c (set_interval_object, set_interval_left)
      (set_interval_right, copy_interval_parent, rotate_right)
      (rotate_left, balance_possible_root_interval):
      * keyboard.c (kset_echo_string, kset_kbd_queue)
      (kset_keyboard_translate_table, kset_last_prefix_arg)
      (kset_last_repeatable_command, kset_local_function_key_map)
      (kset_overriding_terminal_local_map, kset_real_last_command)
      (kset_system_key_syms, clear_event, set_prop):
      * lread.c (digit_to_number):
      * marker.c (attach_marker, live_buffer, set_marker_internal):
      * nsterm.m (ns_compute_glyph_string_overhangs):
      * process.c (pset_buffer, pset_command)
      (pset_decode_coding_system, pset_decoding_buf)
      (pset_encode_coding_system, pset_encoding_buf, pset_filter)
      (pset_log, pset_mark, pset_name, pset_plist, pset_sentinel)
      (pset_status, pset_tty_name, pset_type, pset_write_queue):
      * syntax.c (bset_syntax_table, dec_bytepos):
      * terminal.c (tset_param_alist):
      * textprop.c (interval_has_some_properties)
      (interval_has_some_properties_list):
      * window.c (wset_combination_limit, wset_dedicated)
      (wset_display_table, wset_hchild, wset_left_fringe_width)
      (wset_left_margin_cols, wset_new_normal, wset_new_total)
      (wset_normal_cols, wset_normal_lines, wset_parent, wset_pointm)
      (wset_right_fringe_width, wset_right_margin_cols)
      (wset_scroll_bar_width, wset_start, wset_temslot, wset_vchild)
      (wset_vertical_scroll_bar_type, wset_window_parameters):
      * xdisp.c (wset_base_line_number, wset_base_line_pos)
      (wset_column_number_displayed, wset_region_showing)
      (window_box_edges, run_window_scroll_functions)
      (append_glyph_string_lists, prepend_glyph_string_lists)
      (append_glyph_string, set_glyph_string_background_width)
      (append_glyph, append_composite_glyph)
      (take_vertical_position_into_account):
      * xfaces.c (x_create_gc, x_free_gc, merge_face_vectors)
      (face_attr_equal_p, lface_equal_p, hash_string_case_insensitive)
      (lface_hash, lface_same_font_attributes_p, lookup_face):
      * xml.c (libxml2_loaded_p):
      * xterm.c (x_set_mode_line_face_gc, x_set_glyph_string_gc)
      (x_set_glyph_string_clipping, x_clear_glyph_string_rect):
      Now 'static', not 'static inline'.
      
      Fixes: debbugs:12541
      b0ab8123
  28. 29 Sep, 2012 1 commit
  29. 24 Sep, 2012 1 commit
    • Glenn Morris's avatar
      Doc fixes · d393cefb
      Glenn Morris authored
      * src/eval.c (Frun_hook_with_args, Frun_hook_with_args_until_success)
      (Frun_hook_with_args_until_failure): Doc fixes.
      d393cefb
  30. 23 Sep, 2012 1 commit
    • Paul Eggert's avatar
      Simplify and avoid signal-handling races. · 4d7e6e51
      Paul Eggert authored
      * nt/inc/ms-w32.h (emacs_raise): New macro.
      * src/alloc.c (die):
      * src/sysdep.c (emacs_abort) [HAVE_NTGUI]:
      Avoid recursive loop if there's a fatal error in the function itself.
      * src/atimer.c (pending_atimers):
      * src/blockinput.h: Don't include "atimer.h"; no longer needed.
      (interrupt_input_pending): Remove.  All uses removed.
      pending_signals now counts both atimers and ordinary interrupts.
      This is less racy than having three separate pending-signal flags.
      (block_input, unblock_input, totally_unblock_input, unblock_input_to)
      (input_blocked_p):
      Rename from their upper-case counterparts BLOCK_INPUT,
      UNBLOCK_INPUT, TOTALLY_UNBLOCK_INPUT, UNBLOCK_INPUT_TO,
      INPUT_BLOCKED_P, and turn into functions.  All uses changed.
      This makes it easier to access volatile variables more accurately.
      (BLOCK_INPUT_RESIGNAL): Remove.  All uses replaced by unblock_input ().
      (input_blocked_p): Prefer this to 'interrupt_input_blocked', as
      that's more reliable if the code is buggy and sets
      interrupt_input_blocked to a negative value.  All uses changed.
      * src/atimer.c (deliver_alarm_signal):
      Remove.  No need to deliver this to the parent; any thread can
      handle this signal now.  All uses replaced by underlying handler.
      * src/atimer.c (turn_on_atimers):
      * src/dispnew.c (handle_window_change_signal):
      * src/emacs.c (handle_danger_signal):
      * src/keyboard.c (kbd_buffer_get_event):
      Don't reestablish signal handler; not needed with sigaction.
      * src/blockinput.h (UNBLOCK_INPUT_TO, TOTALLY_UNBLOCK_INPUT)
      (UNBLOCK_INPUT_TO):
      Rework to avoid unnecessary accesses to volatile variables.
      (UNBLOCK_INPUT_TO): Now a function.
      (totally_unblock_input, unblock_input): New decls.
      * src/data.c (handle_arith_signal, deliver_arith_signal): Move to sysdep.c
      (init_data): Remove.  Necessary stuff now done in init_signal.
      * src/emacs.c, src/xdisp.c: Include "atimer.h", since we invoke atimer functions.
      * src/emacs.c (handle_fatal_signal, deliver_fatal_signal): Move to sysdep.c.
      (fatal_error_code): Remove; no longer needed.
      (terminate_due_to_signal): Rename from fatal_error_backtrace, since
      it doesn't always backtrace.  All uses changed.  No need to reset
      signal to default, since sigaction and/or die does that for us now.
      Use emacs_raise (FOO), not kill (getpid (), FOO).
      (main): Check more-accurately whether we're dumping.
      Move fatal-error setup to sysdep.c
      * src/floatfns.c: Do not include "syssignal.h"; no longer needed.
      * src/gtkutil.c (xg_get_file_name, xg_get_font):
      Remove no-longer-needed signal-mask manipulation.
      * src/keyboard.c, src/process.c (POLL_FOR_INPUT):
      Don't depend on USE_ASYNC_EVENTS, a symbol that is never defined.
      * src/keyboard.c (read_avail_input): Remove.
      All uses replaced by gobble_input.
      (Ftop_level): Use TOTALLY_UNBLOCK_INPUT rather than open code.
      (kbd_buffer_store_event_hold, gobble_input):
      (record_asynch_buffer_change) [USABLE_SIGIO]:
      (store_user_signal_events):
      No need to mess with signal mask.
      (gobble_input): If blocking input and there are terminals, simply
      set pending_signals to 1 and return.  All hooks changed to not
      worry about whether input is blocked.
      (process_pending_signals): Clear pending_signals before processing
      them, in case a signal comes in while we're processing.
      By convention callers now test pending_signals before calling us.
      (UNBLOCK_INPUT_TO, unblock_input, totally_unblock_input):
      New functions, to support changes to blockinput.h.
      (handle_input_available_signal): Now extern.
      (reinvoke_input_signal): Remove.  All uses replaced by
      handle_async_input.
      (quit_count): Now volatile, since a signal handler uses it.
      (handle_interrupt): Now takes bool IN_SIGNAL_HANDLER as arg.  All
      callers changed.  Block SIGINT only if not already blocked.
      Clear sigmask reliably, even if Fsignal returns, which it can.
      Omit unnecessary accesses to volatile var.
      (quit_throw_to_read_char): No need to restore sigmask.
      * src/keyboard.c (gobble_input, handle_user_signal):
      * src/process.c (wait_reading_process_output):
      Call signal-handling code rather than killing ourselves.
      * src/lisp.h: Include <float.h>, for...
      (IEEE_FLOATING_POINT): New macro, moved here to avoid duplication.
      (pending_signals): Now volatile.
      (syms_of_data): Now const if IEEE floating point.
      (handle_input_available_signal) [USABLE_SIGIO]:
      (terminate_due_to_signal, record_child_status_change): New decls.
      * src/process.c (create_process): Avoid disaster if memory is exhausted
      while we're processing a vfork, by tightening the critical section
      around the vfork.
      (send_process_frame, process_sent_to, handle_pipe_signal)
      (deliver_pipe_signal): Remove.  No longer needed, as Emacs now
      ignores SIGPIPE.
      (send_process): No need for setjmp/longjmp any more, since the
      SIGPIPE stuff is now gone.  Instead, report an error if errno
      is EPIPE.
      (record_child_status_change): Now extern.  PID and W are now args.
      Return void, not bool.  All callers changed.
      * src/sysdep.c (wait_debugging) [(BSD_SYSTEM || HPUX) && !defined (__GNU__)]:
      Remove.  All uses removed.  This bug should be fixed now in a
      different way.
      (wait_for_termination_1): Use waitpid rather than sigsuspend,
      and record the child status change directly.  This avoids the
      need to futz with the signal mask.
      (process_fatal_action): Move here from emacs.c.
      (emacs_sigaction_flags): New function, containing
      much of what used to be in emacs_sigaction_init.
      (emacs_sigaction_init): Use it.  Block nonfatal system signals that are
      caught by emacs, to make races less likely.
      (deliver_process_signal): Rename from handle_on_main_thread.
      All uses changed.
      (BACKTRACE_LIMIT_MAX): Now at top level.
      (thread_backtrace_buffer, threadback_backtrace_pointers):
      New static vars.
      (deliver_thread_signal, deliver_fatal_thread_signal):
      New functions, for more-accurate delivery of thread-specific signals.
      (handle_fatal_signal, deliver_fatal_signal): Move here from emacs.c.
      (deliver_arith_signal): Handle in this thread, not
      in the main thread, since it's triggered by this thread.
      (maybe_fatal_sig): New function.
      (init_signals): New arg DUMPING so that we can be more accurate
      about whether we're dumping.  Caller changed.
      Treat thread-specific signals differently from process-general signals.
      Block all signals while handling fatal error; that's safer.
      xsignal from SIGFPE only on non-IEEE hosts, treating it as fatal
      on IEEE hosts.
      When batch, ignore SIGHUP, SIGINT, SIGTERM if they were already ignored.
      Ignore SIGPIPE unless batch.
      (emacs_backtrace): Output backtrace for the appropriate thread,
      which is not necessarily the main thread.
      * src/syssignal.h: Include <stdbool.h>.
      (emacs_raise): New macro.
      * src/xterm.c (x_connection_signal): Remove; no longer needed
      now that we use sigaction.
      (x_connection_closed): No need to mess with sigmask now.
      (x_initialize): No need to reset SIGPIPE handler here, since
      init_signals does this for us now.
      
      Fixes: debbugs:12471
      4d7e6e51
  31. 18 Sep, 2012 1 commit
  32. 16 Sep, 2012 1 commit
    • Paul Eggert's avatar
      Remove configure's --without-sync-input option. · 0caaedb1
      Paul Eggert authored
      When auditing signal-handling in preparation for cleaning it up,
      I found that SYNC_INPUT has race conditions and would be a real
      pain to fix.  Since it's an undocumented and deprecated
      configure-time option, now seems like a good time to remove it.
      Also see <http://bugs.gnu.org/11080#16>.
      * configure.ac (SYNC_INPUT, BROKEN_SA_RESTART): Remove.
      * admin/CPP-DEFINES (BROKEN_SA_RESTART, SA_RESTART): Remove.
      * etc/TODO (Make SYNC_INPUT the default): Remove, as the code now
      behaves as if SYNC_INPUT is always true.
      * src/alloc.c (_bytes_used, __malloc_extra_blocks, _malloc_internal)
      (_free_internal) [!DOUG_LEA_MALLOC]: Remove decls.
      (alloc_mutex) [!SYSTEM_MALLOC && !SYNC_INPUT && HAVE_PTHREAD]:
      (malloc_hysteresis):
      (check_depth) [XMALLOC_OVERRUN_CHECK]:
      (MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT):
      (__malloc_hook, __realloc_hook, __free_hook, BYTES_USED)
      (dont_register_blocks, bytes_used_when_reconsidered)
      (bytes_used_when_full, emacs_blocked_free, emacs_blocked_malloc)
      (emacs_blocked_realloc, reset_malloc_hooks, uninterrupt_malloc):
      [!SYSTEM_MALLOC && !SYNC_INPUT]:
      Remove. All uses removed.
      (MALLOC_BLOCK_INPUT, MALLOC_UNBLOCK_INPUT): Use a different
      implementation, one that depends on whether the new macro
      XMALLOC_BLOCK_INPUT_CHECK is defined, not on whether SYNC_INPUT
      is defined.
      * src/atimer.c (run_timers, handle_alarm_signal):
      * src/keyboard.c (pending_signal, poll_for_input_1, poll_for_input)
      (handle_async_input, process_pending_signals)
      (handle_input_available_signal, init_keyboard):
      * src/nsterm.m (ns_read_socket):
      * src/process.c (wait_reading_process_output):
      * src/regex.c (immediate_quit, IMMEDIATE_QUIT_CHECK):
      * src/sysdep.c (emacs_sigaction_init) [SA_RESTART]:
      (emacs_write):
      * src/xterm.c (XTread_socket):
      Assume SYNC_INPUT.
      * src/conf_post.h (SA_RESTART) [IRIX6_5]: Do not #undef.
      * src/eval.c (handling_signal): Remove.  All uses removed.
      * src/lisp.h (ELSE_PENDING_SIGNALS): Remove.
      All uses replaced with the SYNC_INPUT version.
      (reset_malloc_hooks, uninterrupt_malloc, handling_signal):
      Remove decls.
      * src/sysdep.c, src/syssignal.h (main_thread) [FORWARD_SIGNAL_TO_MAIN_THREAD]:
      Now static.
      
      Fixes: debbugs:12450
      0caaedb1