1. 22 Jan, 2013 1 commit
  2. 19 Jan, 2013 2 commits
    • Chong Yidong's avatar
      73c14218
    • Paul Eggert's avatar
      Work around bug in CIFS and vboxsf file systems. · 9fe43ff6
      Paul Eggert authored
      The bug was observed on Ubuntu operating inside a virtual machine,
      editing files mounted via CIFS or vboxsf from the MS Windows 7 host.
      The workaround introduces a race condition on non-buggy hosts,
      but it's an unlikely race and anyway there's a nearly identical
      nearby race that can't be fixed.
      * fileio.c (valid_timestamp_file_system, timestamp_file_system):
      New static vars.
      (Fwrite_region): Test for file system time stamp bug.
      (init_fileio): New function.
      * lisp.h (init_fileio): Declare it.
      * emacs.c (main): Call it.
      
      Fixes: debbugs:13149
      9fe43ff6
  3. 11 Jan, 2013 1 commit
    • Paul Eggert's avatar
      Fix SIGDANGER handlers, for AIX. · b6f960a0
      Paul Eggert authored
      * sysdep.c.c (handle_danger_signal, deliver_danger_signal) [SIGDANGER]:
      Move handlers here from emacs.c; they were out of place.
      
      Fixes: debbugs:13408
      b6f960a0
  4. 01 Jan, 2013 1 commit
  5. 10 Dec, 2012 3 commits
    • Daniel Colascione's avatar
      Move fix for bug#12993 to trunk · 78f9ea87
      Daniel Colascione authored
      78f9ea87
    • Rüdiger Sonderfeld's avatar
      Support filesystem notification through inotify on GNU/Linux. · 81606b10
      Rüdiger Sonderfeld authored
       configure.ac (inotify): New option.
       (HAVE_INOTIFY): Test for inotify.
      
       src/termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add
       FILE_NOTIFY_EVENT.
       src/lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype.
       src/keyboard.c (Qfile_inotify) [HAVE_INOTIFY]: New variable.
       (syms_of_keyboard): DEFSYM it.
       (kbd_buffer_get_event) [HAVE_INOTIFY]: Generate FILE_NOTIFY_EVENT.
       (make_lispy_event): Support FILE_NOTIFY_EVENT by generating
       Qfile_inotify events.
       (keys_of_keyboard) [HAVE_INOTIFY]: Bind file-inotify events in
       special-event-map to inotify-handle-event.
       src/emacs.c (main) [HAVE_INOTIFY]: Call syms_of_inotify.
       src/Makefile.in (base_obj): Add inotify.o.
       src/inotify.c: New file.
      
       lisp/subr.el (inotify-event-p, inotify-handle-event): New functions.
      
       test/automated/inotify-test.el: New test.
      81606b10
    • Daniel Colascione's avatar
      1cf1bbd5
  6. 08 Dec, 2012 1 commit
    • Paul Eggert's avatar
      Use putenv+unsetenv instead of modifying environ directly. · 5745a7df
      Paul Eggert authored
      * admin/merge-gnulib (GNULIB_MODULES): Add putenv, unsetenv.
      * lib/putenv.c, lib/unsetenv.c, m4/putenv.m4, m4/setenv.m4:
      New files, copied automatically from gnulib.
      * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
      * src/alloc.c (xputenv): New function.
      * src/dbusbind.c (Fdbus_init_bus):
      * src/emacs.c (main):
      * src/xterm.c (x_term_init):
      Use xputenv instead of setenv or putenv, to detect memory exhaustion.
      * src/editfns.c (initial_tz): Move static var decl up.
      (tzvalbuf_in_environ): New static var.
      (init_editfns):	Initialize these two static vars.
      (Fencode_time): Don't assume arbitrary limit on EMACS_INT width.
      Save old TZ value on stack, if it's small.
      (Fencode_time, set_time_zone_rule): Don't modify 'environ' directly;
      instead, use xputenv+unsetenv to set and restore TZ.
      (environbuf): Remove static var.  All uses removed.
      (Fset_time_zone_rule): Do not save TZ and environ;
      no longer needed here.
      (set_time_zone_rule_tz1, set_time_zone_rule_tz2) [LOCALTIME_CACHE]:
      Move to inside set_time_zone_rule; they don't need file scope any more.
      (set_time_zone_rule): Maintain the TZ=value string separately.
      (syms_of_editfns): Don't initialize initial_tz;
      init_editfns now does it.
      * src/emacs.c (dump_tz) [HAVE_TZSET]: Now const.
      * src/lisp.h (xputenv): New decl.
      
      Fixes: debbugs:13070
      5745a7df
  7. 20 Nov, 2012 1 commit
  8. 17 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Assume POSIX 1003.1-1988 or later for fcntl.h. · 49cdacda
      Paul Eggert authored
      * admin/CPP-DEFINES (O_RDONLY, O_RDWR, HAVE_FCNTL_H): Remove.
      * admin/merge-gnulib (GNULIB_MODULES): Add fcntl-h.
      * configure.ac: Do not check for fcntl.h.
      * lib/gnulib.mk: Regenerate.
      * lib-src/movemail.c, lib-src/update-game-score.c: Assume <fcntl.h> exists.
      * nt/inc/sys/socket.h (O_NONBLOCK): Rename from O_NDELAY, since the
      POSIX name for this flag is O_NONBLOCK.  All uses changed.
      * nt/inc/unistd.h (O_RDWR, O_NOCTTY): New macros.  Like AT_FDCWD etc.
      these really should be moved to a replacement <fcntl.h> if and
      when that gets implemented.  In the meantime, include <fcntl.h>
      to make sure we don't override its definitions.
      * src/callproc.c (relocate_fd): Assume F_DUPFD.
      * src/emacs.c, src/term.c (O_RDWR): Remove.
      * src/keyboard.c (tty_read_avail_input): Use O_NONBLOCK rather than
      O_NDELAY, since O_NONBLOCK is the standard name for this flag.
      * src/nsterm.m: Assume <fcntl.h> exists.
      * src/process.c (NON_BLOCKING_CONNECT, allocate_pty, create_process)
      (create_pty, Fmake_network_process, server_accept_connection)
      (wait_reading_process_output, init_process_emacs):
      Assume O_NONBLOCK.
      (wait_reading_process_output): Put in a special case for WINDOWSNT
      to mimick the older behavior where it had O_NDELAY but not O_NONBLOCK.
      It's not clear this is needed, but it's a more-conservative change.
      (create_process): Assume FD_CLOEXEC.
      (create_process, create_pty): Assume O_NOCTTY.
      * src/sysdep.c (init_sys_modes, reset_sys_modes): Assume F_SETFL.
      (reset_sys_modes): Use O_NONBLOCK rather than O_NDELAY.
      Omit if not DOS_NT, since F_GETFL is not defined there.
      (serial_open): Assume O_NONBLOCK and O_NOCTTY.
      * src/term.c: Include <fcntl.h>, for flags like O_NOCTTY.
      (O_NOCTTY): Remove.
      (init_tty): Assume O_IGNORE_CTTY is defined to 0 on platforms that
      lack it, since gnulib guarantees this.
      * src/w32.c (fcntl): Test for O_NONBLOCK rather than O_NDELAY.
      
      Fixes: debbugs:12881
      49cdacda
  9. 08 Nov, 2012 1 commit
    • Stefan Monnier's avatar
      Use ad-hoc comparison function for the profiler's hash-tables. · b7432bb2
      Stefan Monnier authored
      * src/profiler.c (Qprofiler_backtrace_equal, hashtest_profiler): New vars.
      (make_log): Use them.
      (handle_profiler_signal): Don't inhibit quit any longer since we don't
      call Fequal any more.
      (Ffunction_equal): New function.
      (cmpfn_profiler, hashfn_profiler): New functions.
      (syms_of_profiler): Initialize them.
      * src/lisp.h (struct hash_table_test): New struct.
      (struct Lisp_Hash_Table): Use it.
      * src/alloc.c (mark_object): Mark hash_table_test fields of hash tables.
      * src/fns.c (make_hash_table): Take a struct to describe the test.
      (cmpfn_eql, cmpfn_equal, cmpfn_user_defined, hashfn_eq, hashfn_eql)
      (hashfn_equal, hashfn_user_defined): Adjust to new calling convention.
      (hash_lookup, hash_remove_from_table): Move assertion checking of
      hashfn result here.  Check hash-equality before calling cmpfn.
      (Fmake_hash_table): Adjust call to make_hash_table.
      (hashtest_eq, hashtest_eql, hashtest_equal): New structs.
      (syms_of_fns): Initialize them.
      * src/emacs.c (main): Move syms_of_fns earlier.
      * src/xterm.c (syms_of_xterm):
      * src/category.c (hash_get_category_set): Adjust call to make_hash_table.
      * src/print.c (print_object): Adjust to new hash-table struct.
      * src/composite.c (composition_gstring_put_cache): Adjust to new hashfn.
      b7432bb2
  10. 05 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Assume at least POSIX.1-1988 for getpgrp, setpgid, setsid. · dd0333b6
      Paul Eggert authored
      This removes code that has been obsolete since around 1990.
      * admin/CPP-DEFINES (HAVE_SETPGID, HAVE_SETSID, SETPGRP_RELEASES_CTTY):
      Remove; obsolete.
      * configure.ac (setpgid, setsid): Assume their existence.
      (AC_FUNC_GETPGRP, SETPGRP_RELEASES_CTTY): Remove; obsolete.
      * src/callproc.c (Fcall_process):
      * src/emacs.c (main):
      * src/process.c (create_process):
      * src/term.c (dissociate_if_controlling_tty):
      Assume setsid exists.
      * src/callproc.c (child_setup): Assume setpgid exists and behaves as
      per POSIX.1-1988 or later.
      * src/conf_post.h (setpgid) [!HAVE_SETPGID]: Remove.
      * src/emacs.c (shut_down_emacs):
      * src/sysdep.c (sys_suspend, init_foreground_group):
      Assume getpgrp behaves as per POSIX.1-1998 or later.
      * src/msdos.c (setpgrp): Remove.
      (tcgetpgrp, setpgid, setsid): New functions.
      * src/systty.h (EMACS_GETPGRP): Remove.  All callers now use getpgrp.
      * src/term.c (no_controlling_tty): Remove; unused.
      * src/w32proc.c (setpgrp): Remove.
      (setsid, tcgetpgrp): New functions.
      
      Fixes: debbugs:12800
      dd0333b6
  11. 04 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Fix data-loss with --version. · 76abf5e5
      Paul Eggert authored
      * emacs.c (close_output_streams): Use strerror, not emacs_strerror,
      as we can't assume that emacs_strerror is initialized, and strerror
      is good enough here.
      (main): Invoke atexit earlier, to catch earlier instances of
      sending data to stdout and exiting, e.g., "emacs --version >/dev/full".
      
      Fixes: debbugs:9574
      76abf5e5
  12. 03 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Fix data-loss with --batch. · 7ccfb720
      Paul Eggert authored
      * admin/merge-gnulib (GNULIB_MODULES): Add close-stream.
      * lib/close-stream.c, lib/close-stream.h, lib/fpending.c
      * lib/fpending.h, m4/close-stream.m4, m4/fpending.m4:
      New files, from gnulib.
      * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
      * src/emacs.c: Include <close-stream.h>.
      (close_output_streams): New function.
      (main): Pass it to atexit, so that Emacs closes stdout and stderr
      and handles errors appropriately.
      (Fkill_emacs): Don't worry about flushing, as close_output_stream
      does that now.
      
      Fixes: debbugs:9574
      7ccfb720
  13. 31 Oct, 2012 1 commit
    • Paul Eggert's avatar
      Fix crash when using Emacs as commit editor for git. · 322aea6d
      Paul Eggert authored
      * callproc.c (setpgrp): Remove macro, as we now use setpgid
      and it is configured in conf_post.h.
      (Fcall_process): Don't invoke both setsid and setpgid; the former
      is enough, if it exists.
      * callproc.c (Fcall_process, child_setup):
      * process.c (create_process): Use setpgid.
      * conf_post.h (setpgid) [!HAVE_SETPGID]: New macro, which substitutes
      for the real thing.
      * dispnew.c (init_display): Initialize the foreground group
      if we are running a tty display.
      * emacs.c (main): Do not worry about setpgrp; init_display does it now.
      * lisp.h (init_foreground_group): New decl.
      * sysdep.c (inherited_pgroup): New static var.
      (init_foreground_group, tcsetpgrp_without_stopping)
      (narrow_foreground_group, widen_foreground_group): New functions.
      (init_sys_modes): Narrow foreground group.
      (reset_sys_modes): Widen foreground group.
      
      Fixes: debbugs:12697
      322aea6d
  14. 25 Oct, 2012 1 commit
    • Paul Eggert's avatar
      Don't assume process IDs fit in int. · 69deda53
      Paul Eggert authored
      * emacs.c (shut_down_emacs) [!DOS_NT]:
      * sysdep.c (sys_suspend) [SIGTSTP && !MSDOS]:
      * term.c (dissociate_if_controlling_tty) [!DOS_NT]:
      Use pid_t, not int, to store process IDs, as 'int'
      is not wide enough on a few platforms (e.g., AIX and IRIX).
      69deda53
  15. 14 Oct, 2012 1 commit
  16. 08 Oct, 2012 3 commits
  17. 06 Oct, 2012 1 commit
    • Eli Zaretskii's avatar
      Initial version of the w32notify code. · 477f1e50
      Eli Zaretskii authored
      Adding and removing a watch seems to work: a new thread is launched
      when a watch is added and exits when the watch is removed.
      But there are no notifications, so it seems.  At least, the Lisp
      callback function passed to w32notify-add-watch is not called.
      477f1e50
  18. 01 Oct, 2012 3 commits
    • Paul Eggert's avatar
      Fix a malloc race condition involving strsignal. · aa1ba90e
      Paul Eggert authored
      A signal can arrive in the middle of a malloc, and Emacs's signal
      handler can invoke strsignal, which can invoke malloc, which is
      not portable.  This race condition bug makes Emacs hang on GNU/Linux.
      Fix it by altering the signal handler so that it does not invoke
      strsignal.
      * emacs.c (shut_down_emacs): Use safe_strsignal, not strsignal.
      * process.c (status_message): Use const pointer, in case strsignal
      is #defined to safe_strsignal.
      * sysdep.c (sys_siglist, init_signals): Always define and
      initialize a substitute sys_siglist if the system does not define
      one, even if HAVE_STRSIGNAL.
      (safe_strsignal): Rename from strsignal.  Always define,
      using sys_siglist.  Return a const pointer.
      * syssignal.h (safe_strsignal): New decl.
      (strsignal) [!HAVE_STRSIGNAL]: Define in terms of safe_strsignal.
      aa1ba90e
    • Fabrice Popineau's avatar
      Fix minor compilation problem with MSVC. · b3317662
      Fabrice Popineau authored
       src/emacs.c: Move the inclusion of TERM_HEADER after including
       windows.h on WINDOWSNT.  This avoids compilation problems with
       MSVC.
      b3317662
    • Eli Zaretskii's avatar
      Fix termination sequence on Windows wrt interval timers. · f0e5f225
      Eli Zaretskii authored
       src/w32proc.c <disable_itimers>: New static flag.
       (init_timers): Initialize it to zero, after creating the critical
       sections used by the timer threads.
       (term_timers): Set to 1 before deleting the critical sections.
       (getitimer, setitimer): If disable_itimers is non-zero, return an
       error indication without doing anything.  Reported by Fabrice
       Popineau <fabrice.popineau@supelec.fr> as part of bug#12544.
      f0e5f225
  19. 25 Sep, 2012 2 commits
    • Juanma Barranquero's avatar
      Move Vlibrary_cache to emacs.c and reset before dumping. · aa15c6bb
      Juanma Barranquero authored
      * src/lisp.h (reset_image_types): Declare.
      [WINDOWSNT] (Vlibrary_cache): Declare.
      
      * src/image.c (reset_image_types): New function.
      
      * src/emacs.c [WINDOWSNT] (Vlibrary_cache): Move from w32.c.
      (syms_of_emacs) [WINDOWSNT] <Vlibrary_cache>: Initialize and staticpro.
      (Fdump_emacs): Reset Vlibrary_cache and image_types.
      
      * src/w32.c (Vlibrary_cache): Do not define; moved to emacs.c
      (globals_of_w32) <Vlibrary_cache>: Do not initialize.
      
      * src/w32.h (Vlibrary_cache): Do not declare.
      aa15c6bb
    • Eli Zaretskii's avatar
      Fix handling of fatal signals and exceptions on MS-Windows. · 16b22fef
      Eli Zaretskii authored
       src/w32proc.c (sys_signal): Handle all signals defined by the
       MS-Windows runtime, not just SIGCHLD.  Actually install the signal
       handlers for signals supported by Windows.  Don't override
       term_ntproc as the handler for SIGABRT.
       (sigaction): Rewrite to call sys_signal instead of duplicating its
       code.
       (sys_kill): Improve commentary.
       src/w32.c (term_ntproc): Accept (and ignore) one argument, for
       consistency with a signature of a signal handler.  All callers
       changed.
       (init_ntproc): Accept an argument DUMPING.  If dumping, don't
       install term_ntproc as a signal handler for SIGABRT, as that
       should be done by the dumped Emacs.
       src/w32.h (init_ntproc, term_ntproc): Adjust prototypes.
       src/w32select.c (term_w32select): Protect against repeated
       invocation by setting clipboard_owner to NULL after calling
       DestroyWindow.
       src/emacs.c (shut_down_emacs, main): Adapt the calls to init_ntproc
       and term_ntproc to their modified signatures.
      16b22fef
  20. 23 Sep, 2012 2 commits
    • Paul Eggert's avatar
      Do not use SA_NODEFER. · 62a1d661
      Paul Eggert authored
      Problem reported by Dani Moncayo in
      <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00557.html>.
      * alloc.c (die):
      * sysdep.c (emacs_abort): Do not reset signal handler.
      * emacs.c (terminate_due_to_signal): Reset signal handler here.
      * sysdep.c (init_signals): Do not use SA_NODEFER.  It wasn't
      wanted even on POSIXish hosts, and it doesn't work on Windows.
      62a1d661
    • 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
  21. 22 Sep, 2012 2 commits
  22. 17 Sep, 2012 3 commits
    • Daniel Colascione's avatar
      ce9f00e4
    • Daniel Colascione's avatar
      Implement cygw32 · 0fda9b75
      Daniel Colascione authored
      Here, we use the generic window-system configuration system we just
      implemented to support the w32 window-system in the mainline build
      under Cygwin.  (Previously, the w32 window system could only be
      compiled as part of the NT-native Emacs build process.)
      
      The changes in this patch need to be applied atomically in order to
      avoid breaking Emacs.  The changes include:
      
        - Changes throughout the Lisp and C code to not assume that
            NT Emacs and the w32 window system are synonymous.
      
        - Wiring up the regular select(2) event loop to Windows messages
      
        - Cleaning up the w32 drag-and-drop receiving code.
      
        - Exposing Cygwin path conversion functions to elisp.
      
        - Unicode file dialog support when compiling for Cygwin.
      
        - Splitting the w32 term lisp initialization code into code
          applicable to any w32 window-system and code specific to
          system-type windows-nt.
      
        - Integrating the old and new w32 code into the build system.
      0fda9b75
    • Glenn Morris's avatar
      Reduce the number of versioned files storing the short copyright string · 78f83752
      Glenn Morris authored
      * configure.ac (copyright): New output variable.
      (COPYRIGHT): New AC_DEFINE.
      
      * admin/admin.el (set-copyright): No more need to set copyrights for
      nextstep, or .c files.  Add configure.ac and config.nt.
      
      * lib-src/ebrowse.c (version):
      * lib-src/etags.c (print_version): Use COPYRIGHT.
      
      * nextstep/templates/Info-gnustep.plist.in:
      * nextstep/templates/InfoPlist.strings.in:
      * nextstep/templates/Info.plist.in: Let configure set copyright.
      
      * nt/config.nt (COPYRIGHT): New.
      
      * src/emacs.c: Use COPYRIGHT.
      78f83752
  23. 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
  24. 15 Sep, 2012 1 commit
    • Paul Eggert's avatar
      Port better to POSIX hosts lacking _setjmp. · 0328b6de
      Paul Eggert authored
      * configure.ac (HAVE__SETJMP, HAVE_SIGSETJMP): New symbols.
      (_setjmp, _longjmp): Remove.
      * src/lisp.h: Include <setjmp.h> here, since we use its symbols here.
      All instances of '#include <setjmp.h>' removed, if the
      only reason for the instance was because "lisp.h" was included.
      (sys_jmp_buf, sys_setjmp, sys_longjmp): New symbols.
      Unless otherwise specified, replace all uses of jmp_buf, _setjmp,
      and _longjmp with the new symbols.  Emacs already uses _setjmp if
      available, so this change affects only POSIXish hosts that have
      sigsetjmp but not _setjmp, such as some versions of Solaris and
      Unixware.  (Also, POSIX-2008 marks _setjmp as obsolescent.)
      * src/image.c (_setjmp, _longjmp) [HAVE_PNG && !HAVE__SETJMP]: New macros.
      (png_load_body) [HAVE_PNG]:
      (PNG_LONGJMP) [HAVE_PNG && PNG_LIBPNG_VER < 10500]:
      (PNG_JMPBUF) [HAVE_PNG && PNG_LIBPNG_VER >= 10500]:
      Use _setjmp and _longjmp rather than sys_setjmp and sys_longjmp,
      since PNG requires jmp_buf.  This is the only exception to the
      general rule that we now use sys_setjmp and sys_longjmp.
      This exception is OK since this code does not change the signal
      mask or longjmp out of a signal handler.
      
      Fixes: debbugs:12446
      0328b6de
  25. 13 Sep, 2012 1 commit
    • Paul Eggert's avatar
      Simplify SIGIO usage. · 4a4bbad2
      Paul Eggert authored
      The code that dealt with SIGIO was crufty and confusing, e.g., it
      played tricks like "#undef SIGIO" but these tricks were not used
      consistently.  Simplify mostly by not #undeffing standard symbols,
      e.g., use "defined USABLE_SIGIO" (our symbol, which we can define
      or not as we please) rather than "defined SIGIO" (standard symbol
      that we probably shouldn't #undef).
      * configure.ac (NO_TERMIO, BROKEN_FIONREAD, BROKEN_SIGAIO)
      (BROKEN_SIGPOLL, BROKEN_SIGPTY): Remove.
      (USABLE_FIONREAD, USABLE_SIGIO): New symbols.  All uses of
      'defined SIGIO' replaced with 'defined USABLE_SIGIO', with no need
      to #undef SIGIO now (which was error-prone).  Likewise, all uses
      of 'defined FIONREAD' replaced with 'defined USABLE_FIONREAD'.
      * src/admin/CPP_DEFINES (BROKEN_SIGAIO, BROKEN_SIGIO, BROKEN_SIGPOLL)
      (BROKEN_SIGPTY, NO_TERMIO): Remove.
      * src/conf_post.h [USG5_4]: Do not include <sys/wait.h> here.
      Modules that need it can include it.
      [USG5_4 && emacs]: Likewise, do not include the streams stuff here.
      * src/dispextern.h (ignore_sigio): New decl.
      * src/emacs.c (shut_down_emacs): Invoke unrequest_sigio
      unconditionally, since it's now a no-op if !USABLE_SIGIO.
      * src/emacs.c (shut_down_emacs):
      * src/keyboard.c (kbd_buffer_store_event_hold):
      Use ignore_sigio rather than invoking 'signal' directly.
      * src/keyboard.c (USABLE_FIONREAD && USG5_4): Include <sys/filio.h>,
      for FIONREAD.
      (FIONREAD, SIGIO): Do not #undef.
      (tty_read_avail_input): Use #error rather than a syntax error.
      * src/process.c [USG5_4]: Include <sys/stream.h> and <sys/stropts.h>,
      for I_PIPE, used by SETUP_SLAVE_PTY.
      (DATAGRAM_SOCKETS): Simplify defn, based on USABLE_FIONREAD.
      * src/sysdep.c (croak): Remove; no longer needed.  This bit of
      temporary code, with Fred N. Fish's comment that it's temporary,
      has been in Emacs since at least 1992!
      (init_sigio, reset_sigio, request_sigio, unrequest_sigio):
      Arrange for them to be no-ops in all cases when ! USABLE_SIGIO.
      * src/syssignal.h (croak): Remove decl.
      (SIGIO, SIGPOO, SIGAIO, SIGPTY): Do not #undef; that's too fragile.
      * src/systty.h [!NO_TERMIO]: Do not include <termio.h>; no longer needed
      now that we're termios-only.
      (FIONREAD, ASYNC) [BROKEN_FIONREAD]: Do not #undef.
      * src/term.c (dissociate_if_controlling_tty): Use #error rather than
      a run-time error.
      
      Fixes: debbugs:12408
      4a4bbad2
  26. 09 Sep, 2012 1 commit
    • Paul Eggert's avatar
      Assume C89 or later for math functions. · f6196b87
      Paul Eggert authored
      This simplifies the code, and makes it a bit smaller and faster,
      and (most important) makes it easier to clean up signal handling
      since we can stop worring about floating-point exceptions in
      library code.  That was a problem before C89, but the problem
      went away many years ago on all practical Emacs targets.
      * configure.ac (frexp, fmod): Remove checks for these functions,
      as we now assume them.
      (FLOAT_CHECK_DOMAIN, HAVE_INVERSE_HYPERBOLIC, NO_MATHERR)
      (HAVE_EXCEPTION):
      Remove; no longer needed.
      * admin/CPP-DEFINES (HAVE_FMOD, HAVE_FREXP, FLOAT_CHECK_DOMAIN)
      (HAVE_INVERSE_HYPERBOLIC, NO_MATHERR): Remove.
      * src/data.c, src/image.c, src/lread.c, src/print.c:
      Don't include <math.h>; no longer needed.
      * src/data.c, src/floatfns.c (IEEE_FLOATING_POINT): Don't worry that it
      might be autoconfigured, as that never happens.
      * src/data.c (fmod):
      * src/doprnt.c (DBL_MAX_10_EXP):
      * src/print.c (DBL_DIG):
      Remove.  C89 or later always defines these.
      * src/floatfns.c (HAVE_MATHERR, FLOAT_CHECK_ERRNO, FLOAT_CHECK_DOMAIN)
      (in_float, float_error_arg, float_error_arg2, float_error_fn_name)
      (arith_error, domain_error, domain_error2):
      Remove all this pre-C89 cruft.  Do not include <errno.h> as that's
      no longer needed -- we simply return what C returns.  All uses removed.
      (IN_FLOAT, IN_FLOAT2): Remove.  All uses replaced with
      the wrapped code.
      (FLOAT_TO_INT, FLOAT_TO_INT2, range_error, range_error2):
      Remove.  All uses expanded, as these macros are no longer used
      more than once and are now more trouble than they're worth.
      (Ftan): Use tan, not sin / cos.
      (Flogb): Assume C89 frexp.
      (fmod_float): Assume C89 fmod.
      (matherr) [HAVE_MATHERR]: Remove; no longer needed.
      (init_floatfns): Remove.  All uses removed.
      f6196b87
  27. 07 Sep, 2012 2 commits
    • Paul Eggert's avatar
      * emacs.c (main): Convert three 'signal' calls to 'sigaction' calls. · eddb36a7
      Paul Eggert authored
      Problem introduced when merging patches.  Noted by Eli Zaretskii in
      <http://bugs.gnu.org/12327#67>.
      eddb36a7
    • Paul Eggert's avatar
      Signal-handler cleanup. · 2fe28299
      Paul Eggert authored
      Emacs's signal handlers were written in the old 4.2BSD style with
      sigblock and sigmask and so forth, and this led to some
      inefficiencies and confusion.  Rewrite these to use
      pthread_sigmask etc. without copying signal sets around.  Also,
      get rid of the confusing macros 'SIGNAL_THREAD_CHECK' and
      'signal', and instead use functions that do not attempt to take
      over the system name space.  This patch causes Emacs's text
      segment to shrink by 0.7% on my platform, Fedora 17 x86-64.
      * configure.ac (PTY_OPEN, PTY_TTY_NAME_SPRINTF):
      Adjust to syssignal.h changes.
      (SIGNAL_H_AB): Remove; no longer needed.
      * src/alloc.c, src/emacsgtkfixed.c, src/nsfns.m, src/widget.c, src/xmenu.c:
      Do not include <signal.h> or "syssignal.h", as these
      modules do not use signals.
      * src/atimer.c, src/callproc.c, src/data.c, src/dispnew.c, src/emacs.c:
      * src/floatfns.c, src/gtkutil.c, src/keyboard.c, src/process.c, src/sound.c:
      * src/sysdep.c, src/term.c, src/xterm.c:
      Do not include <signal.h>, as "syssignal.h" does that for us now.
      * src/atimer.c (sigmask_atimers): New function.
      (block_atimers, unblock_atimers): New functions,
      replacing the old macros BLOCK_ATIMERS and UNBLOCK_ATIMERS.
      All uses replaced.
      * src/conf_post.h [SIGNAL_H_AHB]: Do not include <signal.h>;
      no longer needed here.
      * src/emacs.c (main): Inspect existing signal handler with sigaction,
      so that there's	no need to block and unblock SIGHUP.
      * src/sysdep.c (struct save_signal): New member 'action', replacing
      old member 'handler'.
      (save_signal_handlers, restore_signal_handlers):
      Use sigaction instead of 'signal' to save and restore.
      (get_set_sighandler, set_sighandler) [!WINDOWSNT]:
      New function.  All users of 'signal' modified to use set_sighandler
      if they're writeonly, and to use sys_signal if they're read+write.
      (emacs_sigaction_init, forwarded_signal): New functions.
      (sys_signal): Remove.  All uses replaced by calls to sigaction
      and emacs_sigaction_init, or by direct calls to 'signal'.
      (sys_sigmask) [!__GNUC__]: Remove; no longer needed.
      (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove;
      all uses replaced by pthread_sigmask etc. calls.
      * src/syssignal.h: Include <signal.h>.
      (emacs_sigaction_init, forwarded_signal): New decls.
      (SIGMASKTYPE): Remove.  All uses replaced by its definiens, sigset_t.
      (SIGEMPTYMASK): Remove; all uses replaced by its definiens, empty_mask.
      (sigmask, sys_sigmask): Remove; no longer needed.
      (sigpause): Remove.  All uses replaced by its definiens, sigsuspend.
      (sigblock, sigunblock, sigfree):
      (sigsetmask) [!defined sigsetmask]:
      Remove.  All uses replaced by pthread_sigmask.
      (signal): Remove.  Its remaining uses (with SIG_DFL and SIG_IGN)
      no longer need to be replaced, and its typical old uses
      are now done via emacs_sigaction_init and sigaction.
      (sys_sigblock, sys_sigunblock, sys_sigsetmask): Remove decls.
      (sys_sigdel): Remove; unused.
      (NSIG): Remove a FIXME; the code's fine.  Remove an unnecessary ifdef.
      
      Fixes: debbugs:12327
      2fe28299