1. 27 Jun, 2013 1 commit
    • Paul Eggert's avatar
      Do not tickle glib SIGCHLD handling if Cygwin. · dae2f5ef
      Paul Eggert authored
      This mostly consists of undoing recent changes.
      * callproc.c (Fcall_process):
      * process.c (create_process):
      Do not worry about catching SIGCHLD here, undoing previous change.
      * nsterm.m (ns_term_init): Re-catch SIGCHLD, undoing previous change.
      * process.c, process.h (catch_child_signal):
      No longer extern if !NS_IMPL_GNUSTEP, undoing 06-22 change.
      * process.c (catch_child_handler): Don't worry about being called
      lazily and do not assume caller has blocked SIGCHLD, undoing
      previous change.  Move first-time stuff back to
      init_process_emacs, undoing 06-22 change.  If CYGWIN, do not
      tickle glib, as that causes Cygwin bootstrap to fail.  Do not
      set lib_child_handler if it's already initialized, which may
      help avoid problems on GNUStep.
      dae2f5ef
  2. 23 Jun, 2013 1 commit
    • Paul Eggert's avatar
      Try to avoid malloc SEGVs on Cygwin. · c7041908
      Paul Eggert authored
      * callproc.c, process.h (block_child_signal, unblock_child_signal):
      Now extern.
      * emacs.c (main): Catch SIGCHLD just before initializing gfilenotify.
      * process.c (catch_child_signal): Block SIGCHLD while futzing with
      the SIGCHLD handler, since the code is not atomic and (due to glib)
      signals may be arriving now.
      * sysdep.c (init_signals): Do not catch child signals here;
      'main' now does that later, at a safer time.
      
      Fixes: debbugs:14569
      c7041908
  3. 22 Jun, 2013 1 commit
    • Paul Eggert's avatar
      Clean up SIGCHLD handling a bit. · 0dfeed58
      Paul Eggert authored
      * process.c, process.h (catch_child_signal):
      Now always extern, even if !NS_IMPL_GNUSTEP.
      * process.c (catch_child_signal): Move glib tickler here from
      init_process_emacs, so that it's done earlier in Emacs
      initialization.  Also move the noninteractive && !initialized
      check here from init_process_emacs.  This is all a bit cleaner for
      GNUish platforms, and I hope it works around the Cygwin bug.
      * sysdep.c (init_signals): Invoke catch_child_signal here, so
      that glib signal handling is tickled before glib creates threads.
      
      Fixes: debbugs:14569
      0dfeed58
  4. 03 Jun, 2013 1 commit
    • 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
  5. 02 Jun, 2013 1 commit
    • Jan Djärv's avatar
      Update the GNUStep port so it works OK. Redraw and sizing bugs remain. · c0342369
      Jan Djärv authored
      * nextstep/templates/Info-gnustep.plist.in: Add NSDocumentClass EmacsDocument.
      
      * src/nsfns.m (x_set_foreground_color, x_set_background_color): Use
      EmacsCGFloat.
      (ns_implicitly_set_icon_type, Fx_create_frame): Make static, remove
      unused variables.
      (Fns_read_file_name): Keep track if panel is for save.  Use
      ns_filename_from_panel/ns_directory_from_panel.
      (Fns_list_services): delegate only used for COCOA.
      (Fns_convert_utf8_nfd_to_nfc): Remove warning for GNUStep.  Just
      return the input if GNUStep.
      (x_screen_planes): Remove.
      (Fxw_color_values): Use EmacsCGFloat
      (Fns_display_monitor_attributes_list): Only get screen number for
      Cocoa.
      (getDirectory, getFilename): Removed from EmacsOpenPanel and
      EmacsSavePanel.
      (EmacsOpenPanel:ok:): Use ns_filename_from_panel and
      ns_directory_from_panel.
      
      * src/nsfont.m (ns_attribute_fvalue, ns_spec_to_descriptor)
      (ns_charset_covers, ns_get_covering_families, nsfont_open):
      Use F suffix on floats.
      (ns_char_width): Returns CGFloat.
      (ns_ascii_average_width): w is CGFloat instead of float.
      (nsfont_draw): cbuf and c are unsigned. Cast to char* in call to
      DPSxshow.
      (ns_glyph_metrics): CGFloat instead of float.
      
      * src/nsimage.m (setXBMColor:, getPixelAtX:Y:): Use EmacsCGFloat.
      
      * src/nsmenu.m (ns_update_menubar): Make static.
      (x_activate_menubar): Surround with ifdef NS_IMPL_COCOA
      (fillWithWidgetValue:): Add cast to SEL for setAction.
      (addSubmenuWithTitle:forFrame:): Add cast to SEL for action.
      (update_frame_tool_bar): Update code for GNUStep.
      (clearAll): New method.
      (addDisplayItemWithImage:idx:tag:helpText:enabled:): Handle new tag
      argument. Call insertItemWithItemIdentifier when NS_IMPL_GNUSTEP. Move
      identifierToItem setObject and activeIdentifiers addObject before
      call to insertItemWithItemIdentifier.
      (validateVisibleItems): Fix indentation.
      (toolbarAllowedItemIdentifiers:): Return activeIdentifiers.
      (initWithContentRect:styleMask:backing:defer:): Add ClosableWindow and
      UtilityWindow to aStyle, remove call to setStyleMask.
      
      * src/nsselect.m (ns_get_local_selection): Remove unused variable type.
      
      * src/nsterm.h (EmacsCGFloat): Typedef for OSX and GNUStep when the size
      of CGFloat differs.
      (EmacsApp): New variable nextappdefined.  Declare sendFromMainThread
      when NS_IMPL_GNUSTEP.
      (EmacsDocument): Declare when NS_IMPL_GNUSTEP.
      (EmacsView): Remove unlockFocusNeedsFlush, add windowDidMove.
      (EmacsToolbar): Add clearAll.  Add tag argument to
      addDisplayItemWithImage.
      (EmacsSavePanel, EmacsOpenPanel): Remove getFilename and getDirectory.
      
      * src/nsterm.m: Include src/process.h if NS_IMPL_GNUSTEP.
      (ns_menu_bar_is_hidden, menu_will_open_state): Define only if
      NS_IMPL_COCOA.
      (x_set_cursor_type): Remove declaration.
      (ns_update_begin): Only use r and bp if NS_IMPL_COCOA.
      (ns_update_end, ns_focus, ns_unfocus): Remove GNUStep specific code.
      (x_set_window_size): Remove 3 pixels from toolbar if NS_IMPL_GNUSTEP.
      (ns_get_color): Use F suffix on float.
      (ns_color_to_lisp, ns_query_color): Use EmacsCGFloat.
      (ns_get_rgb_color): Remove.
      (x_set_frame_alpha): Move view inside NS_IMPL_COCOA.
      (note_mouse_movement): x and y are CGFloat.
      (ns_draw_fringe_bitmap): Remove unused rowY.
      Change #if to COCOA && >= 10_6.
      (ns_draw_window_cursor): Remove unused overspill.
      (ns_draw_underwave): width and x are EamcsCGFloat.
      (ns_draw_box): thickness is CGFloat.
      (ns_dumpglyphs_image): Change #if to COCOA && >= 10_6.
      (ns_send_appdefined): When NS_IMPL_GNUSTEP, redirect to main thread
      if not in main thread.
      (ns_get_pending_menu_title, ns_check_menu_open)
      (ns_check_pending_open_menu): Put inside #if COCOA && >= 10_5.
      (ns_term_init): Call catch_child_signal if NS_IMPL_GNUSTEP && SIGCHLD.
      (sendFromMainThread:): New method.
      (changeFont:): size is CGFloat.
      (keyDown:): Check for Delete when NS_IMPL_GNUSTEP.
      Disable warning about permanent text.
      (characterIndexForPoint:): Adjust return type depending on GNUStep
      version.
      (mouseDown:): delta is CGFloat.
      (updateFrameSize): Remove unised variable f.
      (initFrameFromEmacs): Move toggleButton inside NS_IMPL_COCOA.
      Cast float to EmacsCGFloat.
      (windowWillUseStandardFrame:defaultFrame:): Set maximized_height
      also to -1 when restoring.
      (windowDidExitFullScreen:): Put call to updateCollectionBehaviour
      inside NS_IMPL_COCOA.
      (toggleFullScreen:): Put call to toggleFullScreen inside
      NS_IMPL_COCOA.  Cast float to EmacsCGFloat.
      (setPosition:portion:whole:): por is CGFloat.
      (getMouseMotionPart:window:x:y:): Add F suffix to float.
      (mouseDown:): Use CGFloat.
      (mouseDragged:): Remove unised variable edge.
      (EmacsDocument): Implement for NS_IMPL_GNUSTEP.
      
      * src/process.c (catch_child_signal): New function.
      (init_process_emacs): Call it.
      
      * src/process.h (catch_child_signal): Declare.
      c0342369
  6. 08 Mar, 2013 1 commit
    • Paul Eggert's avatar
      print.c, process.c: Use bool for booleans. · 0bce5d9e
      Paul Eggert authored
      * lisp.h (wait_reading_process_output):
      * print.c (print_output_debug_flag, PRINTDECLARE, printchar)
      (strout, debug_output_compilation_hack, float_to_string, print)
      (print_object):
      * process.c (kbd_is_on_hold, inhibit_sentinels, process_output_skip)
      (decode_status, status_message, create_process, create_pty)
      (Fmake_network_process, Fnetwork_interface_info)
      (wait_reading_process_output, read_process_output)
      (write_queue_push, write_queue_pop, process_send_signal)
      (handle_child_signal, keyboard_bit_set, kbd_on_hold_p):
      * process.h (struct Lisp_Process, inhibit_sentinels, kbd_on_hold_p):
      Use bool for booleans.
      * process.c (Fnetwork_interface_list): Remove unused local.
      (connect_counter): Now EMACS_INT, not int.
      0bce5d9e
  7. 01 Jan, 2013 1 commit
  8. 06 Dec, 2012 1 commit
    • Paul Eggert's avatar
      Fix a recently-introduced delete-process race condition. · 35fb8050
      Paul Eggert authored
      * callproc.c, process.h (record_kill_process):
      New function, containing part of the old call_process_kill.
      (call_process_kill): Use it.
      This does not change call_process_kill's behavior.
      * process.c (Fdelete_process): Use record_kill_process to fix a
      race condition that could cause Emacs to lose track of a child.
      35fb8050
  9. 03 Dec, 2012 1 commit
    • Paul Eggert's avatar
      Don't let call-process be a zombie factory. · bb5f74ee
      Paul Eggert authored
      Fixing this bug required some cleanup of the signal-handling code.
      As a side effect, this change also fixes a longstanding rare race
      condition whereby Emacs could mistakenly kill unrelated processes,
      and it fixes a bug where a second C-g does not kill a recalcitrant
      synchronous process in GNU/Linux and similar platforms.
      The patch should also fix the last vestiges of Bug#9488,
      a bug which has mostly been fixed on the trunk by other changes.
      * callproc.c, process.h (synch_process_alive, synch_process_death)
      (synch_process_termsig, sync_process_retcode):
      Remove.  All uses removed, to simplify analysis and so that
      less consing is done inside critical sections.
      * callproc.c (call_process_exited): Remove.  All uses replaced
      with !synch_process_pid.
      * callproc.c (synch_process_pid, synch_process_fd): New static vars.
      These take the role of what used to be in unwind-protect arg.
      All uses changed.
      (block_child_signal, unblock_child_signal):
      New functions, to avoid races that could kill innocent-victim processes.
      (call_process_kill, call_process_cleanup, Fcall_process): Use them.
      (call_process_kill): Record killed processes as deleted, so that
      zombies do not clutter up the system.  Do this inside a critical
      section, to avoid a race that would allow the clutter.
      (call_process_cleanup): Fix code so that the second C-g works again
      on common platforms such as GNU/Linux.
      (Fcall_process): Create the child process in a critical section,
      to fix a race condition.  If creating an asynchronous process,
      record it as deleted so that zombies do not clutter up the system.
      Do unwind-protect for WINDOWSNT too, as that's simpler in the
      light of these changes.  Omit unnecessary call to emacs_close
      before failure, as the unwind-protect code does that.
      * callproc.c (call_process_cleanup):
      * w32proc.c (waitpid): Simplify now that synch_process_alive is gone.
      * process.c (record_deleted_pid): New function, containing
      code refactored out of Fdelete_process.
      (Fdelete_process): Use it.
      (process_status_retrieved): Remove.  All callers changed to use
      child_status_change.
      (record_child_status_change): Remove, folding its contents into ...
      (handle_child_signal): ... this signal handler.  Now, this
      function is purely a handler for SIGCHLD, and is not called after
      a synchronous waitpid returns; the synchronous code is moved to
      wait_for_termination.  There is no need to worry about reaping
      more than one child now.
      * sysdep.c (get_child_status, child_status_changed): New functions.
      (wait_for_termination): Now takes int * status and bool
      interruptible arguments, too.  Do not record child status change;
      that's now the caller's responsibility.  All callers changed.
      Reimplement in terms of get_child_status.
      (wait_for_termination_1, interruptible_wait_for_termination):
      Remove.  All callers changed to use wait_for_termination.
      * syswait.h: Include <stdbool.h>, for bool.
      (record_child_status_change, interruptible_wait_for_termination):
      Remove decls.
      (record_deleted_pid, child_status_changed): New decls.
      (wait_for_termination): Adjust to API changes noted above.
      
      Fixes: debbugs:12980
      bb5f74ee
  10. 24 Nov, 2012 1 commit
  11. 23 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Fix a race condition with glib (Bug#8855). · 6d4e8f62
      Paul Eggert authored
      This is a backport from the trunk, consisting of:
      
      2012-11-17  Eli Zaretskii  <eliz@gnu.org>
      
      * nt/inc/sys/wait.h: New file, with prototype of waitpid and
      definitions of macros it needs.
      * nt/inc/ms-w32.h (wait): Don't define, 'wait' is not used anymore.
      (sys_wait): Remove prototype.
      * nt/config.nt (HAVE_SYS_WAIT_H): Define to 1.
      * src/w32proc.c (create_child): Don't clip the PID of the child
      process to fit into an Emacs integer, as this is no longer a
      restriction.
      (waitpid): Rename from sys_wait.  Emulate a Posix 'waitpid' by
      reaping only the process specified by PID argument, if that is
      positive.  Use PID instead of dead_child to know which process to
      reap.  Wait for the child to die only if WNOHANG is not in
      OPTIONS.
      (sys_select): Don't set dead_child.
      * src/sysdep.c (wait_for_termination_1): Remove the WINDOWSNT portion,
      as it is no longer needed.
      * src/process.c (waitpid, WUNTRACED) [!WNOHANG]: Remove definitions,
      no longer needed.
      (record_child_status_change): Remove the setting of
      record_at_most_one_child for the !WNOHANG case.
      
      2012-11-03  Paul Eggert  <eggert@cs.ucla.edu>
      
      Fix a race condition that causes Emacs to mess up glib (Bug#8855).
      This is a backport from the trunk.
      The symptom is a diagnostic "GLib-WARNING **: In call to
      g_spawn_sync(), exit status of a child process was requested but
      SIGCHLD action was set to SIG_IGN and ECHILD was received by
      waitpid(), so exit status can't be returned."  The diagnostic
      is partly wrong, as the SIGCHLD action is not set to SIG_IGN.
      The real bug is a race condition between Emacs and glib: Emacs
      does a waitpid (-1, ...) and reaps glib's subprocess by mistake,
      so that glib can't find it.  Work around the bug by invoking
      waitpid only on subprocesses that Emacs itself creates.
      * src/process.c (create_process, record_child_status_change):
      Don't use special value -1 in pid field, as the caller now must
      know the pid rather than having the callee infer it.  The
      inference was sometimes incorrect anyway, due to another race.
      (create_process): Set new 'alive' member if child is created.
      (process_status_retrieved): New function.
      (record_child_status_change): Use it.
      Accept negative 1st argument, which means to wait for the
      processes that Emacs already knows about.  Move special-case code
      for DOS_NT (which lacks WNOHANG) here, from caller.  Keep track of
      processes that have already been waited for, by testing and
      clearing new 'alive' member.
      (CAN_HANDLE_MULTIPLE_CHILDREN): Remove, as record_child_status_change
      now does this internally.
      (handle_child_signal): Let record_child_status_change do all
      the work, since we do not want to reap all exited child processes,
      only the child processes that Emacs itself created.
      * src/process.h (Lisp_Process): New boolean member 'alive'.
      6d4e8f62
  12. 03 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Fix a race condition that causes Emacs to mess up glib. · 0b3d4a47
      Paul Eggert authored
      The symptom is a diagnostic "GLib-WARNING **: In call to
      g_spawn_sync(), exit status of a child process was requested but
      SIGCHLD action was set to SIG_IGN and ECHILD was received by
      waitpid(), so exit status can't be returned."  The diagnostic
      is partly wrong, as the SIGCHLD action is not set to SIG_IGN.
      The real bug is a race condition between Emacs and glib: Emacs
      does a waitpid (-1, ...) and reaps glib's subprocess by mistake,
      so that glib can't find it.  Work around the bug by invoking
      waitpid only on subprocesses that Emacs itself creates.
      * process.c (create_process, record_child_status_change):
      Don't use special value -1 in pid field, as the caller now must
      know the pid rather than having the callee infer it.  The
      inference was sometimes incorrect anyway, due to another race.
      (create_process): Set new 'alive' member if child is created.
      (process_status_retrieved): New function.
      (record_child_status_change): Use it.
      Accept negative 1st argument, which means to wait for the
      processes that Emacs already knows about.  Move special-case code
      for DOS_NT (which lacks WNOHANG) here, from caller.  Keep track of
      processes that have already been waited for, by testing and
      clearing new 'alive' member.
      (CAN_HANDLE_MULTIPLE_CHILDREN): Remove, as record_child_status_change
      now does this internally.
      (handle_child_signal): Let record_child_status_change do all
      the work, since we do not want to reap all exited child processes,
      only the child processes that Emacs itself created.
      * process.h (Lisp_Process): New boolean member 'alive'.
      
      Fixes: debbugs:8855
      0b3d4a47
  13. 27 Aug, 2012 1 commit
    • Paul Eggert's avatar
      * composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans. · de1339b0
      Paul Eggert authored
      * composite.c (find_composition, composition_gstring_p)
      (composition_reseat_it, find_automatic_composition):
      * data.c (let_shadows_buffer_binding_p)
      (let_shadows_global_binding_p, set_internal, make_blv)
      (Fmake_variable_buffer_local, Fmake_local_variable)
      (Fmake_variable_frame_local, arithcompare, cons_to_unsigned)
      (cons_to_signed, arith_driver):
      * dbusbind.c (xd_in_read_queued_messages):
      * dired.c (directory_files_internal, file_name_completion):
      Use bool for booleans.
      * dired.c (file_name_completion):
      * process.h (fd_callback):
      Omit int (actually boolean) argument.  It wasn't being used.
      All uses changed.
      * composite.h, lisp.h: Reflect above API changes.
      de1339b0
  14. 25 Aug, 2012 1 commit
    • Paul Eggert's avatar
      * bytecode.c, callint.c, callproc.c: Use bool for boolean. · 2f221583
      Paul Eggert authored
      * bytecode.c (exec_byte_code):
      * callint.c (check_mark, Fcall_interactively):
      * callproc.c (Fcall_process, add_env, child_setup, getenv_internal_1)
      (getenv_internal, sync_process_alive, call_process_exited):
      * lisp.h (USE_SAFE_ALLOCA):
      Use bool for booleans, instead of int.
      * lisp.h, process.h: Adjust prototypes to match above changes.
      * callint.c (Fcall_interactively): Don't assume the mark's
      offset fits in 'int'.
      2f221583
  15. 18 Aug, 2012 1 commit
    • Paul Eggert's avatar
      * process.h (PSET): Remove. · 6a09a33b
      Paul Eggert authored
      Replace all uses with calls to new setter functions.
      Use INLINE_HEADER_BEGIN, INLINE_HEADER_END.
      (PROCESS_INLINE): New macro.
      (pset_childp): New setter function.
      (pset_gnutls_cred_type) [HAVE_GNUTLS]: New setter function.
      * process.c (PROCESS_INLINE):
      Define to EXTERN_INLINE, so that the corresponding functions
      are compiled into code.
      (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): New setter functions.
      
      Fixes: debbugs:12215
      6a09a33b
  16. 07 Aug, 2012 1 commit
  17. 06 Aug, 2012 1 commit
  18. 01 Aug, 2012 1 commit
    • Dmitry Antipov's avatar
      Use INTERNAL_FIELD for processes. · 3193acd2
      Dmitry Antipov authored
      * src/process.h (PVAR): New macro.  Adjust style.
      (struct Lisp_Process): Change Lisp_Object members to INTERNAL_FIELD.
      * src/print.c, src/process.c, src/sysdep.c, src/w32.c:
      * src/xdisp.c: Users changed.
      * admin/coccinelle/process.cocci: Semantic patch to replace direct
      access to Lisp_Object members of struct Lisp_Process to PVAR.
      3193acd2
  19. 31 Jul, 2012 1 commit
  20. 22 Jun, 2012 1 commit
  21. 17 Jun, 2012 1 commit
    • Troels Nielsen's avatar
      Ensure correct ordering of process writes. · 20ca2e94
      Troels Nielsen authored
      * process.c (make_process): Initialize write_queue.
      (write_queue_push, write_queue_pop): New functions.
      (send_process): Use them to maintain correct ordering of process writes.
      
      Fixes: debbugs:10815
      20ca2e94
  22. 22 Apr, 2012 1 commit
  23. 09 Apr, 2012 1 commit
    • Ted Zlatanov's avatar
      Limit number of GnuTLS handshakes per connection. · a18ecafa
      Ted Zlatanov authored
      * gnutls.c (gnutls_log_function2i): Convenience log function.
      (emacs_gnutls_read): Use new log functions,
      `gnutls_handshakes_tried' process member, and
      `GNUTLS_EMACS_HANDSHAKES_LIMIT' to limit the number of handshake
      attempts per process (connection).
      
      * gnutls.h: Add `GNUTLS_EMACS_HANDSHAKES_LIMIT' upper limit.  Add
      convenience `GNUTLS_LOG2i' macro.
      
      * process.c (make_process):
      * process.h: Add integer `gnutls_handshakes_tried' member to
      process struct.
      a18ecafa
  24. 11 Jan, 2012 1 commit
  25. 05 Jan, 2012 1 commit
  26. 18 Jul, 2011 1 commit
  27. 09 May, 2011 1 commit
    • Eli Zaretskii's avatar
      Backport revisions... · 14fe7b53
      Eli Zaretskii authored
      Backport revisions 2011-04-24T05:30:24Z!eggert@cs.ucla.edu..2011-04-25T19:40:22Z!eggert@cs.ucla.edu (inclusive) from trunk (bug#8623)
      
      	The next log entry shows the actual changes by Paul Eggert.
      
       Fix a problem with aliasing and vector headers.
       GCC 4.6.0 optimizes based on type-based alias analysis.  For
       example, if b is of type struct buffer * and v of type struct
       Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size
       != &v->size, and therefore "v->size = 1; b->size = 2; return
       v->size;" must therefore return 1.  This assumption is incorrect
       for Emacs, since it type-puns struct Lisp_Vector * with many other
       types.  To fix this problem, this patch adds a new type struct
       vector_header that documents the constraints on layout of vectors
       and pseudovectors, and helps optimizing compilers not get fooled
       by Emacs's type punning.  It also adds the macros XSETTYPED_PVECTYPE
       XSETTYPED_PSEUDOVECTOR, TYPED_PSEUDOVECTORP, for similar reasons.
       src/lisp.h (XVECTOR_SIZE): New convenience macro.  All previous uses of
       XVECTOR (foo)->size replaced to use this macro, to avoid the hassle
       of writing XVECTOR (foo)->header.size.
       src/lisp.h: Say "vectorlike header" rather than "vector header.
       (struct vectorlike_header): Rename from struct vector_header.
       (XVECTORLIKE_HEADER_SIZE): Renamed from XVECTOR_HEADER_SIZE.
       All uses changed.
       (XVECTOR_HEADER_SIZE): New macro, for use in XSETPSEUDOVECTOR.
       (XSETTYPED_PVECTYPE): New macro, specifying the name of the size
       member.
       (XSETPVECTYPE): Rewrite in terms of new macro.
       (XSETPVECTYPESIZE): New macro, specifying both type and size.
       This is a bit clearer, and further avoids the possibility of
       undesirable aliasing.
       (XSETTYPED_PSEUDOVECTOR): New macro, specifying the size.
       (XSETPSEUDOVECTOR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR
       and XVECTOR_HEADER_SIZE.
       (XSETSUBR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR and XSIZE,
       since Lisp_Subr is a special case (no "next" field).
       (ASIZE): Rewrite in terms of XVECTOR_SIZE.
       (struct vector_header): New type.
       (TYPED_PSEUDOVECTORP): New macro, also specifying the C type of the
       object, to help avoid aliasing.
       (PSEUDOVECTORP): Rewrite in terms of TYPED_PSEUDOVECTORP.
       (SUBRP): Likewise, since Lisp_Subr is a special case.
       src/lisp.h (struct Lisp_Vector, struct Lisp_Char_Table):
       (struct Lisp_Sub_Char_Table, struct Lisp_Bool_Vector):
       (struct Lisp_Hash_Table): Combine first two members into a single
       struct vector_header member.  All uses of "size" and "next" members
       changed to be "header.size" and "header.next".
       src/buffer.h (struct buffer): Likewise.
       src/font.h (struct font_spec, struct font_entity, struct font): Likewise.
       src/frame.h (struct frame): Likewise.
       src/process.h (struct Lisp_Process): Likewise.
       src/termhooks.h (struct terminal): Likewise.
       src/window.c (struct save_window_data, struct saved_window): Likewise.
       src/window.h (struct window): Likewise.
       src/alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector):
       Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems.
       src/buffer.c (init_buffer_once): Likewise.
       src/lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a
       special case.
       src/process.c (Fformat_network_address): Use local var for size,
       for brevity.
       src/fns.c (vector): Remove; this old hack is no longer needed.
       src/bytecode.c (exec_byte_code): Don't use XVECTOR before CHECK_VECTOR.
      14fe7b53
  28. 25 Apr, 2011 2 commits
    • Paul Eggert's avatar
      * lisp.h: Say "vectorlike header" rather than "vector header. · b102ceb1
      Paul Eggert authored
      (struct vectorlike_header): Rename from struct vector_header.
      (XVECTORLIKE_HEADER_SIZE): Renamed from XVECTOR_HEADER_SIZE.
      All uses changed.
      b102ceb1
    • Paul Eggert's avatar
      lisp.h: Fix a problem with aliasing and vector headers. · eab3844f
      Paul Eggert authored
      GCC 4.6.0 optimizes based on type-based alias analysis.  For
      example, if b is of type struct buffer * and v of type struct
      Lisp_Vector *, then gcc -O2 was incorrectly assuming that &b->size
      != &v->size, and therefore "v->size = 1; b->size = 2; return
      v->size;" must therefore return 1.  This assumption is incorrect
      for Emacs, since it type-puns struct Lisp_Vector * with many other
      types.  To fix this problem, this patch adds a new type struct
      vector_header that documents the constraints on layout of vectors
      and pseudovectors, and helps optimizing compilers not get fooled
      by Emacs's type punning.  It also adds the macros XSETTYPED_PVECTYPE
      XSETTYPED_PSEUDOVECTOR, TYPED_PSEUDOVECTORP, for similar reasons.
      * lisp.h (XVECTOR_SIZE): New convenience macro.  All previous uses of
      XVECTOR (foo)->size replaced to use this macro, to avoid the hassle
      of writing XVECTOR (foo)->header.size.
      (XVECTOR_HEADER_SIZE): New macro, for use in XSETPSEUDOVECTOR.
      (XSETTYPED_PVECTYPE): New macro, specifying the name of the size
      member.
      (XSETPVECTYPE): Rewrite in terms of new macro.
      (XSETPVECTYPESIZE): New macro, specifying both type and size.
      This is a bit clearer, and further avoids the possibility of
      undesirable aliasing.
      (XSETTYPED_PSEUDOVECTOR): New macro, specifying the size.
      (XSETPSEUDOVECTOR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR
      and XVECTOR_HEADER_SIZE.
      (XSETSUBR): Rewrite in terms of XSETTYPED_PSEUDOVECTOR and XSIZE,
      since Lisp_Subr is a special case (no "next" field).
      (ASIZE): Rewrite in terms of XVECTOR_SIZE.
      (struct vector_header): New type.
      (TYPED_PSEUDOVECTORP): New macro, also specifying the C type of the
      object, to help avoid aliasing.
      (PSEUDOVECTORP): Rewrite in terms of TYPED_PSEUDOVECTORP.
      (SUBRP): Likewise, since Lisp_Subr is a special case.
      * lisp.h (struct Lisp_Vector, struct Lisp_Char_Table):
      (struct Lisp_Sub_Char_Table, struct Lisp_Bool_Vector):
      (struct Lisp_Hash_Table): Combine first two members into a single
      struct vector_header member.  All uses of "size" and "next" members
      changed to be "header.size" and "header.next".
      * buffer.h (struct buffer): Likewise.
      * font.h (struct font_spec, struct font_entity, struct font): Likewise.
      * frame.h (struct frame): Likewise.
      * process.h (struct Lisp_Process): Likewise.
      * termhooks.h (struct terminal): Likewise.
      * window.c (struct save_window_data, struct saved_window): Likewise.
      * window.h (struct window): Likewise.
      * alloc.c (allocate_buffer, Fmake_bool_vector, allocate_pseudovector):
      Use XSETPVECTYPESIZE, not XSETPVECTYPE, to avoid aliasing problems.
      * buffer.c (init_buffer_once): Likewise.
      * lread.c (defsubr): Use XSETTYPED_PVECTYPE, since Lisp_Subr is a
      special case.
      * process.c (Fformat_network_address): Use local var for size,
      for brevity.
      eab3844f
  29. 14 Apr, 2011 1 commit
    • Paul Eggert's avatar
      * process.c: Make symbols static if they're not exported. · 40ccffa6
      Paul Eggert authored
      (process_tick, update_tick, create_process, chan_process):
      (Vprocess_alist, proc_buffered_char, datagram_access):
      (fd_callback_data, send_process_frame, process_sent_to): Now static.
      (deactivate_process): Mark defn as static, as well as decl.
      * lisp.h (create_process): Remove decl.
      * process.h (chan_process, Vprocess_alist): Remove decls.
      40ccffa6
  30. 11 Apr, 2011 1 commit
    • Paul Eggert's avatar
      Declare Lisp_Object Q* variables to be 'static' if not exproted. · 955cbe7b
      Paul Eggert authored
      This makes it easier for human readers (and static analyzers)
      to see whether these variables are used from other modules.
      * alloc.c, buffer.c, bytecode.c, callint.c, casetab.c, category.c:
      * ccl.c, character.c, charset.c, cmds.c, coding.c, composite.c:
      * data.c, dbusbind.c, dired.c, editfns.c, eval.c, fileio.c, fns.c:
      * font.c, frame.c, fringe.c, ftfont.c, image.c, keyboard.c, keymap.c:
      * lread.c, macros.c, minibuf.c, print.c, process.c, search.c:
      * sound.c, syntax.c, textprop.c, window.c, xdisp.c, xfaces.c, xfns.c:
      * xmenu.c, xselect.c:
      Declare Q* vars static if they are not used in other modules.
      * ccl.h, character.h, charset.h, coding.h, composite.h, font.h:
      * frame.h, intervals.h, keyboard.h, lisp.h, process.h, syntax.h:
      Remove decls of unexported vars.
      * keyboard.h (EVENT_HEAD_UNMODIFIED): Remove now-unused macro.
      955cbe7b
  31. 25 Jan, 2011 1 commit
  32. 15 Jan, 2011 1 commit
  33. 09 Jan, 2011 1 commit
  34. 02 Jan, 2011 1 commit
  35. 01 Nov, 2010 1 commit
    • Jan Djärv's avatar
      Backport fix for Bug#6571 from trunk. NOTE: May cause merge conflicts. · 3649d303
      Jan Djärv authored
      * src/keyboard.c (input_available_signal): Declare.
      (kbd_buffer_nr_stored): New function.
      (kbd_buffer_store_event_hold): If kbd_buffer_nr_stored returns
      more than KBD_BUFFER_SIZE/2, stop reding input (Bug#6571).
      (kbd_buffer_get_event): If input is suspended and kbd_buffer_nr_stored
      returns less than KBD_BUFFER_SIZE/4, resume reding input (Bug#6571).
      (tty_read_avail_input): If input is on hold, return.
      Don't read more that free slots in kbd_buffer (Bug#6571).
      
      * src/process.c (kbd_is_on_hold): New variable.
      (hold_keyboard_input, unhold_keyboard_input, kbd_on_hold_p):
      New functions.
      (wait_reading_process_output): If kbd_on_hold_p returns non-zero,
      select on empty input mask.
      (init_process): Initialize kbd_is_on_hold to 0.
      
      * src/process.h (hold_keyboard_input, unhold_keyboard_input)
      (kbd_on_hold_p): Declare.
      3649d303
  36. 29 Sep, 2010 1 commit
  37. 27 Sep, 2010 1 commit
  38. 26 Sep, 2010 2 commits
    • Jan D's avatar
      Add fd handling with callbacks to select, dbus needs it for async operation. · 3fad2ad2
      Jan D authored
      * src/dbusbind.c: Include process.h.
      (dbus_fd_cb, xd_find_watch_fd, xd_toggle_watch)
      (xd_read_message_1): New functions.
      (xd_add_watch, xd_remove_watch): Call xd_find_watch_fd.  Handle
      watch for both read and write.
      (Fdbus_init_bus): Also register xd_toggle_watch.
      (Fdbus_call_method_asynchronously, Fdbus_method_return_internal)
      (Fdbus_method_error_internal, Fdbus_send_signal): Remove call
      to dbus_connection_flush.
      (xd_read_message):  Move most of the code to xd_read_message_1.
      Call xd_read_message_1 until status is COMPLETE.
      
      * src/keyboard.c (readable_events, gobble_input): Remove DBUS code.
      
      * src/process.c (gpm_wait_mask, max_gpm_desc): Remove.
      (write_mask): New variable.
      (max_input_desc): Renamed from max_keyboard_desc.
      (fd_callback_info): New variable.
      (add_read_fd, delete_read_fd, add_write_fd, delete_write_fd): New
      functions.
      (Fmake_network_process): FD_SET write_mask.
      (deactivate_process): FD_CLR write_mask.
      (wait_reading_process_output): Connecting renamed to Writeok.
      check_connect removed.  check_write is new.  Remove references to
      gpm.  Use Writeok/check_write unconditionally (i.e. no #ifdef
      NON_BLOCKING_CONNECT) instead of Connecting.
      Loop over file descriptors and call callbacks in fd_callback_info
      if file descriptor is ready for I/O.
      (add_gpm_wait_descriptor): Just call add_keyboard_wait_descriptor.
      (delete_gpm_wait_descriptor): Just call delete_keyboard_wait_descriptor.
      (keyboard_bit_set): Use max_input_desc.
      (add_keyboard_wait_descriptor, delete_keyboard_wait_descriptor): Remove
      #ifdef subprocesses. Use max_input_desc.
      (init_process): Initialize write_mask and fd_callback_info.
      
      * src/process.h (add_read_fd, delete_read_fd, add_write_fd)
      (delete_write_fd): Declare.
      3fad2ad2
    • Ted Zlatanov's avatar
      Set up GnuTLS support. · 8af55556
      Ted Zlatanov authored
      * configure.in: Set up GnuTLS.
      
      * lisp/net/gnutls.el: GnuTLS glue code to set up a connection.
      
      * src/Makefile.in (LIBGNUTLS_LIBS, LIBGNUTLS_CFLAGS, ALL_CFLAGS)
      (obj, LIBES): Set up GnuTLS support.
      
      * src/config.in: Set up GnuTLS support.
      
      * src/emacs.c: Set up GnuTLS support and call syms_of_gnutls.
      
      * src/gnutls.c: The source code for GnuTLS support in Emacs.
      
      * src/gnutls.h: The GnuTLS glue for Emacs, macros and enums.
      
      * src/process.c (make_process, Fstart_process)
      (read_process_output, send_process): Set up GnuTLS support for
      process input/output file descriptors.
      
      * src/process.h: Set up GnuTLS support.
      8af55556