1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-25 15:00:45 -08:00
Commit graph

926 commits

Author SHA1 Message Date
Glenn Morris
2bf2618007 * src/process.c (start_process_unwind): Treat any pid <= 0, except -2,
as an error, not just -1.
For example, make_process inits the pid to 0.

Fixes: debbugs:10217
2011-12-06 00:17:35 -08:00
Paul Eggert
dbf312256d Remove GCPRO-related macros that exist only to avoid shadowing locals.
* lisp.h (GCPRO1_VAR, GCPRO2_VAR, GCPRO3_VAR, GCPRO4_VAR, GCPRO5_VAR)
(GCPRO6_VAR, UNGCPRO_VAR): Remove.  See
<http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
All uses changed to use GCPRO1 etc.
(GCPRO1, GCPRO2, GCPRO3, GCPRO4, GCPRO5, GCPRO6, UNGCPRO):
Revert to old implementation (i.e., before 2011-03-11).
2011-11-28 00:20:58 -08:00
Paul Eggert
5b76caa476 Rename locals to avoid shadowing.
* fileio.c (Finsert_file_contents):
Rename inner 'gcpro1' to 'inner_gcpro1' to avoid shadowing.
* process.c (wait_reading_process_output):
Rename inner 'proc' to 'p' to avoid shadowing.
Indent for consistency with usual Emacs style.
2011-11-25 23:42:44 -08:00
Paul Eggert
e4920bc99d Spelling fixes. 2011-11-24 23:14:48 -08:00
Lars Magne Ingebrigtsen
16c1ad08dc (wait_reading_process_output): Add comment and URL. 2011-11-21 21:39:44 +01:00
Lars Magne Ingebrigtsen
261b6fd466 Fix asynchrounous GnuTLS socket handling on some versions of the GnuTLS library.
Some versions of the GnuTLS library doesn't respons to poll reliably.
Work around this by checking all GnuTLS sockets explicitly from the
idle loop.
2011-11-21 19:21:42 +01:00
Paul Eggert
e1dbe924b5 Spelling fixes. 2011-11-19 18:29:42 -08:00
Paul Eggert
c5e87d104b Spelling fixes. 2011-11-17 09:40:48 -08:00
Paul Eggert
da6062e6ea Spelling fixes. 2011-11-14 23:55:13 -08:00
Kenichi Handa
a0241d014e Set members of the struct coding_system before accessing them (bug#9910,9911,9912). 2011-11-07 10:57:07 +09:00
Glenn Morris
83ed7b5c7e Revert problematic change to wait_reading_process_output.
* src/process.c (wait_reading_process_output): Revert 2009-08-30 change.
Not clear what it was for, and it causes various bugs.  (Bug#9839)
2011-10-28 20:12:02 -04:00
Chong Yidong
435c1d6793 More gnutls memory fixes.
* src/gnutls.c (emacs_gnutls_deinit): Deinit the gnutls_state if it is
non-NULL, regardless of GNUTLS_INITSTAGE.
(Fgnutls_boot): Cleanups.  Call emacs_gnutls_deinit if we signal
an error.  Set process slots as soon as we allocate them.

* src/gnutls.h (GNUTLS_LOG, GNUTLS_LOG2): Fix macros.

* src/process.c (make_process): Set gnutls_state to NULL.
2011-10-27 16:07:28 +08:00
Chong Yidong
9c6c6f495b Fix a memory leak in the built-in GnuTLS support.
* src/gnutls.c (emacs_gnutls_deinit): New function.  Deallocate
credentials structures as well as calling gnutls_deinit.
(Fgnutls_deinit, Fgnutls_boot): Use it.

* src/process.c (make_process): Initialize GnuTLS credentials to NULL.
(deactivate_process): Call emacs_gnutls_deinit.
2011-10-27 14:07:09 +08:00
Juanma Barranquero
5e617bc2b6 Whitespace changes. 2011-09-09 03:06:52 +02:00
Paul Eggert
31c286f79d * process.c (make_process): Use printmax_t, not int, to format
process-name gensyms.
2011-08-29 12:46:15 -07:00
Paul Eggert
011ba6eaac Merge from trunk. 2011-08-24 14:20:36 -07:00
Stefan Monnier
963b492b63 * lisp/mpc.el (mpc--proc-filter): Don't signal mpc-proc-error since signals
from process filters aren't reliably transmitted to the surrounding
accept-process-output.
(mpc-proc-check): New function.
(mpc-proc-sync): Use it

Fixes: debbugs:8293
2011-08-23 21:55:10 -04:00
Paul Eggert
76667214e7 Merge from trunk. 2011-08-18 10:01:52 -07:00
Andreas Schwab
156bffbe26 * src/process.c (Fnetwork_interface_list): Correctly determine buffer
size.
2011-08-18 17:33:22 +02:00
Paul Eggert
c881564470 Merge from trunk. 2011-08-14 22:30:45 -07:00
Kenichi Handa
5cf2b69bdb Avoid crash with invalid default-process-coding-system.
* src/process.c (create_process): Call setup_process_coding_systems
after the pid of the process is set to -1.
2011-08-14 13:51:08 -04:00
Paul Eggert
70c60eb2f9 Merge from trunk. 2011-08-13 23:40:45 -07:00
Paul Eggert
0a0d27fb45 * process.c (Fnetwork_interface_info): Declare local only if needed. 2011-08-13 22:23:51 -07:00
Jan Djärv
377538cbcf Fix network-interface-list|info on newer BSD derived OS:es.
* configure.in: Add header check: sys/socket.h,
ifaddrs.h, net/if_dl.h.  Check for getifaddrs and freeifaddrs.
Check for sa_len in struct ifreq.ifr_addr (Bug#8477).

* src/process.c: Include ifaddrs.h and net/if_dl.h if available (Bug#8477).
(Fnetwork_interface_list): Allocate in increments of bytes instead
of sizeof (struct ifreq).  Iterate over ifconf.ifc_req by counting
bytes (Bug#8477).  Count bytes correctly when ifr_addr is a struct
sockaddr.
(struct ifflag_def): notrailers is smart on OSX.
(Fnetwork_interface_info): Handle case when ifr_flags is negative.
Get hardware address with getifaddrs if available.
2011-08-13 12:48:03 +02:00
Paul Eggert
0065d05491 Adjust in response to jan.h.d's comments.
See, for example <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9196#26>.
2011-08-04 19:15:35 -07:00
Paul Eggert
bf2da747e9 * process.c (Fnetwork_interface_list): Check for overflow
in size calculation.
2011-07-28 18:05:39 -07:00
Lars Magne Ingebrigtsen
dd88932771 Use the same condition for POLL_FOR_INPUT in both keyboard.c and process.c
Fixes: debbugs:1858
2011-07-16 20:27:08 +02:00
Paul Eggert
123403e42f Use pthread_sigmask, not sigprocmask.
* callproc.c (Fcall_process):
* sysdep.c (sys_sigblock, sys_sigunblock, sys_sigsetmask):
* process.c (create_process):
sigprocmask is portable only for single-threaded applications, and
Emacs can be multi-threaded when it uses GTK.
2011-07-06 11:04:23 -07:00
Jan Djärv
0949d2b6ba * process.c: Add defined (HAVE_GSETTINGS) for xgselect.h
(wait_reading_process_output): Add defined (HAVE_GSETTINGS) for
xg_select.

* xgselect.c: Add defined (HAVE_GSETTINGS).
(xgselect_initialize): Ditto.

* xsettings.c (store_monospaced_changed): Take new font as arg and
check for change against current_mono_font.
(EMACS_TYPE_SETTINGS): Remove this and related defines.
(emacs_settings_constructor, emacs_settings_get_property)
(emacs_settings_set_property, emacs_settings_class_init)
(emacs_settings_init, gsettings_obj): Remove.
(something_changedCB): New function for HAVE_GSETTINGS.
(something_changedCB): HAVE_GCONF: Call store_monospaced_changed
with value as argument.
(init_gsettings): Check that GSETTINGS_SCHEMA exists before calling
g_settings_new.  Do not create gsettings_obj.
Remove calls to g_settings_bind. Connect something_changedCB to
"changed".

Fixes: debbugs:8967
2011-07-01 11:18:46 +02:00
Chong Yidong
029529ac6f Fix handling of pending signals in wait_reading_process_output (Bug#8869).
* process.c (wait_reading_process_output): Bypass select if
waiting for a cell while ignoring keyboard input, and input is
pending.  Suggested by Jan Djärv.
2011-06-25 23:40:40 -04:00
Juanma Barranquero
cd3520a41d Move DEFSYM to lisp.h and use everywhere. 2011-06-24 23:25:22 +02:00
Paul Eggert
51cab52b05 Merge from trunk. 2011-06-20 17:59:02 -07:00
Deniz Dogan
76147d94eb * src/process.c (Fset_process_buffer): Clarify return value in docstring. 2011-06-20 14:54:05 +02:00
Paul Eggert
3d1e65a18a * process.c (Fformat_network_address): Use EMACS_INT, not EMACS_UINT.
We prefer signed integers, even for size calculations.
2011-06-19 11:38:58 -07:00
Paul Eggert
f66c7cf8f7 Variadic C functions now count arguments with ptrdiff_t.
This partly undoes my 2011-03-30 change, which replaced int with size_t.
Back then I didn't know that the Emacs coding style prefers signed int.
Also, in the meantime I found a few more instances where arguments
were being counted with int, which may truncate counts on 64-bit
machines, or EMACS_INT, which may be unnecessarily wide.
* lisp.h (struct Lisp_Subr.function.aMANY)
(DEFUN_ARGS_MANY, internal_condition_case_n, safe_call):
Arg counts are now ptrdiff_t, not size_t.
All variadic functions and their callers changed accordingly.
(struct gcpro.nvars): Now size_t, not size_t.  All uses changed.
* bytecode.c (exec_byte_code): Check maxdepth for overflow,
to avoid potential buffer overrun.  Don't assume arg counts fit in 'int'.
* callint.c (Fcall_interactively): Check arg count for overflow,
to avoid potential buffer overrun.  Use signed char, not 'int',
for 'varies' array, so that we needn't bother to check its size
calculation for overflow.
* editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args.
* eval.c (apply_lambda):
* fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length.
(struct textprop_rec.argnum): Now ptrdiff_t, not int.  All uses changed.
(mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args.
2011-06-14 11:57:19 -07:00
Paul Eggert
4475bec4dd * buffer.c (Qclone_number): Remove for now, as it's unused.
(record_buffer, Funrecord_buffer): Rename local to avoid shadowing.
(record_buffer): Remove unused local.
* frame.c (other_visible_frames, frame_buffer_list): Now static.
(set_frame_buffer_list): Remove; unused.
* frame.h (other_visible_frames): Remove decl.
* keyboard.h (menu_items_inuse): Declare only if USE_GTK || USE_MOTIF.
* lisp.h (frame_buffer_list, set_frame_buffer_list): Remove decls.
(add_gpm_wait_descriptor, delete_gpm_wait_descriptor): Declare only
if HAVE_GPM.
* menu.c (menu_items_inuse): Now static unless USE_GTK || USE_MOTIF.
* process.c (add_gpm_wait_descriptor, delete_gpm_wait_descriptor):
Define only if HAVE_GPM.
* widget.c (EmacsFrameResize, emacsFrameClassRec): Now static.
(update_hints_inhibit): Remove; never set.  All uses removed.
* widgetprv.h (emacsFrameClassRec): Remove decl.
* window.c (delete_deletable_window): Now returns void, since it
wasn't returning anything.
(compare_window_configurations): Remove unused locals.
* xfns.c (x_set_scroll_bar_default_width): Remove unused locals.
* xmenu.c (x_menu_set_in_use): Define only if USE_GTK || USE_MOTIF.
Omit no-longer-needed #ifdef USE_X_TOOLKIT, since USE_X_TOOLKIT is
implied by USE_GTK || USE_MOTIF.
(dialog_selection_callback) [!USE_GTK]: Prefer intptr_t for integers
the same widths as pointers.  This follows up on the 2011-05-06 patch.
* xterm.c (x_alloc_lighter_color_for_widget): Define only if USE_LUCID.
* xterm.h: Likewise.
(x_menu_set_in_use): Declare only if USE_GTK || USE_MOTIF.
2011-06-11 14:31:32 -07:00
Paul Eggert
55d4c1b248 [ChangeLog]
Use 'inline', not 'INLINE'.
* configure.in, autogen/config.in (INLINE): Remove.
[lib-src/ChangeLog]
Use 'inline', not 'INLINE'.
* etags.c (hash): Now inline unconditionally.
* make-docfile.c (put_char): inline, not INLINE.
[nt/ChangeLog]
Use 'inline', not 'INLINE'.
* config.nt (INLINE): Remove.
[src/ChangeLog]
Use 'inline', not 'INLINE'.
* alloc.c, fontset.c (INLINE): Remove.
* alloc.c, bidi.c, charset.c, coding.c, dispnew.c, fns.c, image.c:
* intervals.c, keyboard.c, process.c, syntax.c, textprop.c, w32term.c:
* xdisp.c, xfaces.c, xterm.c: Replace all uses of INLINE with inline.
* gmalloc.c (register_heapinfo): Use inline unconditionally.
* lisp.h (LISP_MAKE_RVALUE): Use inline, not __inline__.
2011-05-28 15:39:39 -07:00
Paul Eggert
852a74a59b Merge from mainline. 2011-05-04 22:31:24 -07:00
Juanma Barranquero
e968f4f300 src/gnutls.c: Remove unused parameter `fildes'.
* gnutls.h (emacs_gnutls_write, emacs_gnutls_read):
* gnutls.c (emacs_gnutls_write, emacs_gnutls_read):
  Remove unused parameter `fildes'.
* process.c (read_process_output, send_process): Don't pass it.
2011-05-05 01:56:09 +02:00
Juanma Barranquero
0898ca10c0 Implement dynamic loading of GnuTLS on Windows.
* lisp/term/w32-win.el (dynamic-library-alist): Add `gnutls'.

* nt/INSTALL: Clarify GnuTLS support.

* src/callproc.c, src/emacs.c: Include lisp.h before src/w32.h, not after.

* src/gnutls.c (Qgnutls_dll): Define.
  (DEF_GNUTLS_FN, LOAD_GNUTLS_FN): New macros.
  (gnutls_*): Declare function pointers.
  (init_gnutls_functions): New function to initialize function pointers.
  (emacs_gnutls_handshake, Fgnutls_error_string, Fgnutls_deinit)
  (emacs_gnutls_global_init, Fgnutls_bye): Use function pointers.
  (emacs_gnutls_record_check_pending, emacs_gnutls_transport_set_errno):
  Wrappers for gnutls_record_check_pending and gnutls_transport_set_errno.
  (emacs_gnutls_write, emacs_gnutls_read)
  (emacs_gnutls_handle_error, Fgnutls_error_fatalp)
  (Fgnutls_available_p): New function.
  (Fgnutls_boot): Call Fgnutls_available_p.  Use function pointers.
  (syms_of_gnutls) <Qgnutls_dll>: Initialize and staticpro it.
  (syms_of_gnutls) <Sgnutls_available_p>: defsubr it.

* src/gnutls.h (GNUTLS_EMACS_ERROR_NOT_LOADED): New macro.
  (emacs_gnutls_write, emacs_gnutls_read): Mark as extern.
  (emacs_gnutls_record_check_pending, emacs_gnutls_transport_set_errno):
  Declare.

* src/w32.c (QCloaded_from, Vlibrary_cache): Define.
  (w32_delayed_load): Move from image.c.  When loading a library, record
  its filename in the :loaded-from property of the library id.
  (globals_of_w32) <QCloaded_from, Vlibrary_cache>:
  Initialize and staticpro them.
  (emacs_gnutls_pull, emacs_gnutls_push): Call emacs_gnutls_* functions.

* src/image.c: Include w32.h.
  (Vimage_type_cache): Delete.
  (syms_of_image) <Vimage_type_cache>: Don't initialize and staticpro it.
  (CACHE_IMAGE_TYPE, Finit_image_library): Use Vlibrary_cache instead.
  (w32_delayed_load): Move to w32.c.

* src/process.c: Include lisp.h before src/w32.h, not after.
  (wait_reading_process_output): Call emacs_gnutls_record_check_pending
  instead of gnutls_record_check_pending.

* src/w32.h (VlibraryCache, QCloaded_from, w32_delayed_load): Declare.
2011-05-04 16:03:16 +02:00
Paul Eggert
dd5963ea21 * process.c (Fformat_network_address): Fix typo: args2 -> *args2. 2011-05-02 23:13:54 -07:00
Eli Zaretskii
330d880c3a Don't test HAVE_INTTYPES_H in process.c.
src/process.c: Remove HAVE_INTTYPES_H condition from inclusion of
 inttypes.h, as a gnulib replacement is used if it not available in
 system headers.
2011-04-30 12:31:01 +03:00
Paul Eggert
8727937b96 * lread.c, process.c: Do not include <inttypes.h>; lisp.h does it now. 2011-04-29 00:55:25 -07:00
Paul Eggert
671875dac1 Merge from mainline. 2011-04-25 23:17:52 -07:00
Paul Eggert
eab3844f96 lisp.h: 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.
* 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.
2011-04-25 00:14:46 -07:00
Ted Zlatanov
e061a11b5a Add GnuTLS support for W32 and certificate and hostname verification in GnuTLS.
* src/gnutls.c: Renamed global_initialized to
gnutls_global_initialized.  Added internals for the
:verify-hostname-error, :verify-error, and :verify-flags
parameters of `gnutls-boot' and documented those parameters in the
docstring.  Start callback support.
(emacs_gnutls_handshake): Add Woe32 support. Retry handshake
unless a fatal error occured. Call gnutls_alert_send_appropriate
on error. Return error code.
(emacs_gnutls_write): Call emacs_gnutls_handle_error.
(emacs_gnutls_read): Likewise.
(Fgnutls_boot): Return handshake error code.
(emacs_gnutls_handle_error): New function.
(wsaerror_to_errno): Likewise.

* src/gnutls.h: Add GNUTLS_STAGE_CALLBACKS enum to denote we're in the
callbacks stage.

* src/w32.c (emacs_gnutls_pull): New function for GnuTLS on Woe32.
(emacs_gnutls_push): Likewise.

* src/w32.h (emacs_gnutls_pull): Add prototype.
(emacs_gnutls_push): Likewise.
2011-04-24 20:30:51 -05:00
Paul Eggert
fa3c87e1f2 * process.c (Fnetwork_interface_info): Avoid left-shift undefined
behavior with 1 << 31.  GCC 4.6.0 warns about this on 32-bit hosts.
2011-04-18 23:42:12 -07:00
Paul Eggert
c2982e87d3 Replace pEd with more-general pI, and fix some printf arg casts.
* lisp.h (pI): New macro, generalizing old pEd macro to other
conversion specifiers.  For example, use "...%"pI"d..." rather
than "...%"pEd"...".
(pEd): Remove.  All uses replaced with similar uses of pI.
* src/m/amdx86-64.h, src/m/ia64.h, src/m/ibms390x.h: Likewise.
* alloc.c (check_pure_size): Don't overflow by converting size to int.
* bidi.c (bidi_dump_cached_states): Use pI to avoid cast.
* data.c (Fnumber_to_string): Use pI instead of if-then-else-abort.
* dbusbind.c (xd_append_arg): Use pI to avoid cast.
(Fdbus_method_return_internal, Fdbus_method_error_internal): Likewise.
* font.c (font_unparse_xlfd): Avoid potential buffer overrun on
64-bit hosts.
(font_unparse_xlfd, font_unparse_fcname): Use pI to avoid casts.
* keyboard.c (record_char, modify_event_symbol): Use pI to avoid casts.
* print.c (safe_debug_print, print_object): Likewise.
(print_object): Don't overflow by converting EMACS_INT or EMACS_UINT
to int.
Use pI instead of if-then-else-abort.  Use %p to avoid casts.
* process.c (Fmake_network_process): Use pI to avoid cast.
* region-cache.c (pp_cache): Likewise.
* xdisp.c (decode_mode_spec): Likewise.
* xrdb.c (x_load_resources) [USE_MOTIF]: Use pI to avoid undefined
behavior on 64-bit hosts with printf arg.
* xselect.c (x_queue_event): Use %p to avoid casts.
(x_stop_queuing_selection_requests): Likewise.
(x_get_window_property): Don't truncate byte count to an 'int'
when tracing.
2011-04-18 17:34:42 -07:00
Paul Eggert
006c5daa68 * process.c (keyboard_bit_set): Define only if SIGIO.
(send_process_trap): Mark it with NO_RETURN if it doesn't return.
(send_process): Repair possible setjmp clobbering.
2011-04-16 15:04:41 -07:00
Paul Eggert
3d6c254321 * process.c (send_process): Change a size_t to EMACS_INT. 2011-04-15 01:35:53 -07:00