aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-02-12 16:05:17 +0100
committerMattias EngdegÄrd2022-02-12 18:00:21 +0100
commita8245e122075175df2f124b20e9e5b1b583eff89 (patch)
tree4e7c180a785879d056149013c2933b62445f1361 /src/process.c
parentbe06b40ebdd6cfbd23558ce210a8a7ad2b4c7a40 (diff)
downloademacs-a8245e122075175df2f124b20e9e5b1b583eff89.tar.gz
emacs-a8245e122075175df2f124b20e9e5b1b583eff89.zip
Replace ptrdiff_t with new specpdl_ref type for specpdl references
The specpdl_ref type is just an alias for ptrdiff_t; the compiled code remains the same. All operations on specpdl_ref (arithmetic, comparison etc) now go through inline functions. The bulk of the change is almost completely mechanical. It is done to prepare for a type-safe representation and subsequent performance improvement. * src/lisp.h (specpdl_ref, specpdl_count_to_ref, specpdl_ref_to_count) (specpdl_ref_eq, specpdl_ref_lt, specpdl_ref_valid_p) (make_invalid_specpdl_ref, specpdl_ref_add, specpdl_ref_to_ptr): New. (SPECPDL_INDEX, struct handler, USE_SAFE_ALLOCA, safe_free) (safe_free_unbind_to): * src/alloc.c (run_finalizer_function, inhibit_garbage_collection) (garbage_collect, Fgarbage_collect, which_symbols): * src/bidi.c (bidi_at_paragraph_end, bidi_find_paragraph_start): * src/buffer.c (Fkill_buffer, Fset_buffer_major_mode, Fmove_overlay) (Fdelete_overlay): * src/bytecode.c (exec_byte_code): * src/callint.c (Ffuncall_interactively, Fcall_interactively): * src/callproc.c (Fcall_process, call_process, create_temp_file) (Fcall_process_region): * src/charset.c (load_charset_map_from_file): * src/coding.c (decode_coding_gap, decode_coding_object) (encode_coding_object, Fread_coding_system): * src/comp.c (emit_static_object, helper_unbind_n, load_comp_unit): * src/composite.c (update_compositions, autocmp_chars): * src/cygw32.c (conv_filename_to_w32_unicode) (conv_filename_from_w32_unicode): * src/data.c (notify_variable_watchers): * src/decompress.c (Fzlib_decompress_region): * src/dired.c (directory_files_internal, file_name_completion) (file_attributes): * src/dispnew.c (Fredisplay): * src/doc.c (get_doc_string, Fsnarf_documentation): * src/editfns.c (Fsave_excursion, Fsave_current_buffer) (Freplace_buffer_contents, Fsubst_char_in_region, Fsave_restriction) (styled_format): * src/emacs-module.c (Fmodule_load, funcall_module): * src/emacs.c (init_cmdargs, Fdump_emacs): * src/eval.c (call_debugger, do_debug_on_call, FletX, Flet) (Ffuncall_with_delayed_message, Funwind_protect) (internal_lisp_condition_case, signal_or_quit) (load_with_autoload_queue, Feval, grow_specpdl_allocation) (record_in_backtrace, eval_sub, Ffuncall, apply_lambda) (funcall_lambda, clear_unwind_protect, set_unwind_protect) (set_unwind_protect_ptr, unbind_to, Fbacktrace_eval): * src/fileio.c (Fmake_temp_file_internal, Fcopy_file, Frename_file) (Finsert_file_contents, write_region, Fdo_auto_save): * src/fns.c (Fyes_or_no_p, Frequire, hash_table_user_defined_call): * src/fringe.c (update_window_fringes): * src/gtkutil.c (xg_dialog_run): * src/haiku_io.c (c_specpdl_idx_from_cxx): * src/haiku_support.cc (be_popup_file_dialog): * src/haiku_support.h (c_specpdl_idx_from_cxx): * src/haikufns.c (haiku_create_frame, haiku_create_tip_frame) (haiku_hide_tip, Fx_show_tip, Fhaiku_read_file_name): * src/haikumenu.c (haiku_popup_dialog, set_frame_menubar): * src/image.c (slurp_file): * src/indent.c (line_number_display_width, Fvertical_motion): * src/insdel.c (signal_before_change, signal_after_change) (Fcombine_after_change_execute): * src/intervals.c (get_local_map): * src/json.c (lisp_to_json_nonscalar_1, Fjson_serialize, Fjson_insert) (Fjson_parse_string, Fjson_parse_buffer): * src/keyboard.c (recursive_edit_1, Frecursive_edit, cmd_error) (Finternal_track_mouse, command_loop_1, read_menu_command) (safe_run_hooks, read_event_from_main_queue, read_char, timer_check_2) (menu_item_eval_property, read_key_sequence, read_key_sequence_vs) (Fsuspend_emacs): * src/keymap.c (Fcurrent_active_maps, Fdescribe_vector) (Fhelp__describe_vector): * src/lread.c (Fload, save_match_data_load, readevalloop) (Feval_buffer, Feval_region, grow_read_buffer, read_integer, read1): * src/macros.c (Fexecute_kbd_macro): * src/menu.c (x_popup_menu_1): * src/minibuf.c (read_minibuf, set_minibuffer_mode) (read_minibuf_unwind, Fread_string, Fread_buffer): * src/nsfns.m (Fx_create_frame, Fx_show_tip): * src/nsmenu.m (ns_update_menubar, ns_menu_show, ns_popup_dialog): * src/pdumper.c (Fdump_emacs_portable): * src/pgtkfns.c (Fx_create_frame, x_create_tip_frame, x_hide_tip) (Fx_show_tip, Fpgtk_print_frames_dialog, Fx_file_dialog, Fx_select_font): * src/pgtkmenu.c (set_frame_menubar, create_and_show_popup_menu) (pgtk_menu_show, create_and_show_dialog, pgtk_dialog_show) (pgtk_popup_dialog): * src/pgtkterm.c (pgtk_cr_export_frames): * src/print.c (PRINTPREPARE, temp_output_buffer_setup) (Fprin1_to_string, print_vectorlike): * src/process.c (Fmake_process, create_process, Fmake_pipe_process) (Fmake_serial_process, connect_network_socket, Fmake_network_process) (network_interface_info, server_accept_connection) (wait_reading_process_output, read_process_output, exec_sentinel): * src/regex-emacs.c (re_match_2_internal): * src/search.c (looking_at_1, fast_looking_at, search_buffer_re): * src/sound.c (Fplay_sound_internal): * src/sysdep.c (system_process_attributes): * src/term.c (tty_menu_show): * src/textprop.c (Fnext_single_char_property_change) (Fprevious_single_char_property_change, add_text_properties_1) (set_text_properties, set_text_properties_1, Fremove_text_properties) (Fremove_list_of_text_properties): * src/thread.c (Fmutex_lock, invoke_thread_function): * src/undo.c (truncate_undo_list): * src/w32fns.c (Fx_create_frame, w32_create_tip_frame, w32_hide_tip) (Fx_show_tip, Fx_file_dialog): * src/w32font.c (Fx_select_font): * src/w32menu.c (set_frame_menubar): * src/window.c (window_list, next_window, window_list_1) (run_window_configuration_change_hook, Frun_window_scroll_functions) (run_window_change_functions, set_window_buffer) (temp_output_buffer_show, window_scroll, scroll_command) (Fscroll_other_window, Fscroll_other_window_down): * src/xdisp.c (safe__call, handle_fontified_prop, handle_face_prop) (handle_single_display_spec, Fbuffer_text_pixel_size) (message_dolog, with_echo_area_buffer, setup_echo_area_for_printing) (display_echo_area, set_message, clear_message, echo_area_display) (gui_consider_frame_title, prepare_menu_bars, update_menu_bar) (update_tab_bar, update_tool_bar, redisplay_internal) (redisplay_preserve_echo_area, run_window_scroll_functions) (redisplay_window, extend_face_to_end_of_line) (display_count_lines_logically, display_count_lines_visually) (display_mode_lines, display_mode_line, Fformat_mode_line) (decode_mode_spec): * src/xfns.c (Fx_create_frame, x_create_tip_frame, x_hide_tip) (Fx_show_tip, Fx_file_dialog, Fx_select_font, Fx_print_frames_dialog): * src/xmenu.c (set_frame_menubar, create_and_show_popup_menu) (x_menu_show, create_and_show_dialog, x_dialog_show) (xw_popup_dialog): * src/xselect.c (x_get_local_selection, x_reply_selection_request) (x_handle_selection_request, wait_for_property_change): * src/xterm.c (x_cr_export_frames, x_connection_closed): Replace ptrdiff_t with specpdl_ref for referencing specpdl and use the corresponding functions instead of direct arithmetic.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/process.c b/src/process.c
index e9125953935..94cc8800970 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1752,7 +1752,7 @@ usage: (make-process &rest ARGS) */)
1752{ 1752{
1753 Lisp_Object buffer, name, command, program, proc, contact, current_dir, tem; 1753 Lisp_Object buffer, name, command, program, proc, contact, current_dir, tem;
1754 Lisp_Object xstderr, stderrproc; 1754 Lisp_Object xstderr, stderrproc;
1755 ptrdiff_t count = SPECPDL_INDEX (); 1755 specpdl_ref count = SPECPDL_INDEX ();
1756 1756
1757 if (nargs == 0) 1757 if (nargs == 0)
1758 return Qnil; 1758 return Qnil;
@@ -2173,7 +2173,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2173 && !EQ (p->filter, Qt)) 2173 && !EQ (p->filter, Qt))
2174 add_process_read_fd (inchannel); 2174 add_process_read_fd (inchannel);
2175 2175
2176 ptrdiff_t count = SPECPDL_INDEX (); 2176 specpdl_ref count = SPECPDL_INDEX ();
2177 2177
2178 /* This may signal an error. */ 2178 /* This may signal an error. */
2179 setup_process_coding_systems (process); 2179 setup_process_coding_systems (process);
@@ -2340,7 +2340,6 @@ usage: (make-pipe-process &rest ARGS) */)
2340 struct Lisp_Process *p; 2340 struct Lisp_Process *p;
2341 Lisp_Object name, buffer; 2341 Lisp_Object name, buffer;
2342 Lisp_Object tem; 2342 Lisp_Object tem;
2343 ptrdiff_t specpdl_count;
2344 int inchannel, outchannel; 2343 int inchannel, outchannel;
2345 2344
2346 if (nargs == 0) 2345 if (nargs == 0)
@@ -2351,7 +2350,7 @@ usage: (make-pipe-process &rest ARGS) */)
2351 name = Fplist_get (contact, QCname); 2350 name = Fplist_get (contact, QCname);
2352 CHECK_STRING (name); 2351 CHECK_STRING (name);
2353 proc = make_process (name); 2352 proc = make_process (name);
2354 specpdl_count = SPECPDL_INDEX (); 2353 specpdl_ref specpdl_count = SPECPDL_INDEX ();
2355 record_unwind_protect (remove_process, proc); 2354 record_unwind_protect (remove_process, proc);
2356 p = XPROCESS (proc); 2355 p = XPROCESS (proc);
2357 2356
@@ -2471,7 +2470,7 @@ usage: (make-pipe-process &rest ARGS) */)
2471 eassert (p->decoding_carryover == 0); 2470 eassert (p->decoding_carryover == 0);
2472 pset_encoding_buf (p, empty_unibyte_string); 2471 pset_encoding_buf (p, empty_unibyte_string);
2473 2472
2474 specpdl_ptr = specpdl + specpdl_count; 2473 specpdl_ptr = specpdl_ref_to_ptr (specpdl_count);
2475 2474
2476 return proc; 2475 return proc;
2477} 2476}
@@ -3079,7 +3078,6 @@ usage: (make-serial-process &rest ARGS) */)
3079 struct Lisp_Process *p; 3078 struct Lisp_Process *p;
3080 Lisp_Object name, buffer; 3079 Lisp_Object name, buffer;
3081 Lisp_Object tem, val; 3080 Lisp_Object tem, val;
3082 ptrdiff_t specpdl_count;
3083 3081
3084 if (nargs == 0) 3082 if (nargs == 0)
3085 return Qnil; 3083 return Qnil;
@@ -3101,7 +3099,7 @@ usage: (make-serial-process &rest ARGS) */)
3101 name = port; 3099 name = port;
3102 CHECK_STRING (name); 3100 CHECK_STRING (name);
3103 proc = make_process (name); 3101 proc = make_process (name);
3104 specpdl_count = SPECPDL_INDEX (); 3102 specpdl_ref specpdl_count = SPECPDL_INDEX ();
3105 record_unwind_protect (remove_process, proc); 3103 record_unwind_protect (remove_process, proc);
3106 p = XPROCESS (proc); 3104 p = XPROCESS (proc);
3107 3105
@@ -3179,7 +3177,7 @@ usage: (make-serial-process &rest ARGS) */)
3179 3177
3180 Fserial_process_configure (nargs, args); 3178 Fserial_process_configure (nargs, args);
3181 3179
3182 specpdl_ptr = specpdl + specpdl_count; 3180 specpdl_ptr = specpdl_ref_to_ptr (specpdl_count);
3183 3181
3184 return proc; 3182 return proc;
3185} 3183}
@@ -3341,9 +3339,9 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3341 s = -1; 3339 s = -1;
3342 3340
3343 struct sockaddr *sa = NULL; 3341 struct sockaddr *sa = NULL;
3344 ptrdiff_t count = SPECPDL_INDEX (); 3342 specpdl_ref count = SPECPDL_INDEX ();
3345 record_unwind_protect_nothing (); 3343 record_unwind_protect_nothing ();
3346 ptrdiff_t count1 = SPECPDL_INDEX (); 3344 specpdl_ref count1 = SPECPDL_INDEX ();
3347 3345
3348 while (!NILP (addrinfos)) 3346 while (!NILP (addrinfos))
3349 { 3347 {
@@ -3528,7 +3526,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3528#endif /* !WINDOWSNT */ 3526#endif /* !WINDOWSNT */
3529 3527
3530 /* Discard the unwind protect closing S. */ 3528 /* Discard the unwind protect closing S. */
3531 specpdl_ptr = specpdl + count1; 3529 specpdl_ptr = specpdl_ref_to_ptr (count1);
3532 emacs_close (s); 3530 emacs_close (s);
3533 s = -1; 3531 s = -1;
3534 if (0 <= socket_to_use) 3532 if (0 <= socket_to_use)
@@ -3621,7 +3619,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3621 p->outfd = outch; 3619 p->outfd = outch;
3622 3620
3623 /* Discard the unwind protect for closing S, if any. */ 3621 /* Discard the unwind protect for closing S, if any. */
3624 specpdl_ptr = specpdl + count1; 3622 specpdl_ptr = specpdl_ref_to_ptr (count1);
3625 3623
3626 if (p->is_server && p->socktype != SOCK_DGRAM) 3624 if (p->is_server && p->socktype != SOCK_DGRAM)
3627 pset_status (p, Qlisten); 3625 pset_status (p, Qlisten);
@@ -3879,7 +3877,7 @@ usage: (make-network-process &rest ARGS) */)
3879#ifdef HAVE_GETADDRINFO_A 3877#ifdef HAVE_GETADDRINFO_A
3880 struct gaicb *dns_request = NULL; 3878 struct gaicb *dns_request = NULL;
3881#endif 3879#endif
3882 ptrdiff_t count = SPECPDL_INDEX (); 3880 specpdl_ref count = SPECPDL_INDEX ();
3883 3881
3884 if (nargs == 0) 3882 if (nargs == 0)
3885 return Qnil; 3883 return Qnil;
@@ -4208,7 +4206,7 @@ usage: (make-network-process &rest ARGS) */)
4208 if (! postpone_connection) 4206 if (! postpone_connection)
4209 connect_network_socket (proc, addrinfos, use_external_socket_p); 4207 connect_network_socket (proc, addrinfos, use_external_socket_p);
4210 4208
4211 specpdl_ptr = specpdl + count; 4209 specpdl_ptr = specpdl_ref_to_ptr (count);
4212 return proc; 4210 return proc;
4213} 4211}
4214 4212
@@ -4380,7 +4378,6 @@ network_interface_info (Lisp_Object ifname)
4380 Lisp_Object elt; 4378 Lisp_Object elt;
4381 int s; 4379 int s;
4382 bool any = false; 4380 bool any = false;
4383 ptrdiff_t count;
4384#if (! (defined SIOCGIFHWADDR && defined HAVE_STRUCT_IFREQ_IFR_HWADDR) \ 4381#if (! (defined SIOCGIFHWADDR && defined HAVE_STRUCT_IFREQ_IFR_HWADDR) \
4385 && defined HAVE_GETIFADDRS && defined LLADDR) 4382 && defined HAVE_GETIFADDRS && defined LLADDR)
4386 struct ifaddrs *ifap; 4383 struct ifaddrs *ifap;
@@ -4395,7 +4392,7 @@ network_interface_info (Lisp_Object ifname)
4395 s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); 4392 s = socket (AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
4396 if (s < 0) 4393 if (s < 0)
4397 return Qnil; 4394 return Qnil;
4398 count = SPECPDL_INDEX (); 4395 specpdl_ref count = SPECPDL_INDEX ();
4399 record_unwind_protect_int (close_file_unwind, s); 4396 record_unwind_protect_int (close_file_unwind, s);
4400 4397
4401 elt = Qnil; 4398 elt = Qnil;
@@ -4839,7 +4836,6 @@ server_accept_connection (Lisp_Object server, int channel)
4839 int s; 4836 int s;
4840 union u_sockaddr saddr; 4837 union u_sockaddr saddr;
4841 socklen_t len = sizeof saddr; 4838 socklen_t len = sizeof saddr;
4842 ptrdiff_t count;
4843 4839
4844 s = accept4 (channel, &saddr.sa, &len, SOCK_CLOEXEC); 4840 s = accept4 (channel, &saddr.sa, &len, SOCK_CLOEXEC);
4845 4841
@@ -4861,7 +4857,7 @@ server_accept_connection (Lisp_Object server, int channel)
4861 return; 4857 return;
4862 } 4858 }
4863 4859
4864 count = SPECPDL_INDEX (); 4860 specpdl_ref count = SPECPDL_INDEX ();
4865 record_unwind_protect_int (close_file_unwind, s); 4861 record_unwind_protect_int (close_file_unwind, s);
4866 4862
4867 connect_counter++; 4863 connect_counter++;
@@ -4980,7 +4976,7 @@ server_accept_connection (Lisp_Object server, int channel)
4980 eassert (p->pid == 0); 4976 eassert (p->pid == 0);
4981 4977
4982 /* Discard the unwind protect for closing S. */ 4978 /* Discard the unwind protect for closing S. */
4983 specpdl_ptr = specpdl + count; 4979 specpdl_ptr = specpdl_ref_to_ptr (count);
4984 4980
4985 p->open_fd[SUBPROCESS_STDIN] = s; 4981 p->open_fd[SUBPROCESS_STDIN] = s;
4986 p->infd = s; 4982 p->infd = s;
@@ -5177,7 +5173,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5177#if defined HAVE_GETADDRINFO_A || defined HAVE_GNUTLS 5173#if defined HAVE_GETADDRINFO_A || defined HAVE_GNUTLS
5178 bool retry_for_async; 5174 bool retry_for_async;
5179#endif 5175#endif
5180 ptrdiff_t count = SPECPDL_INDEX (); 5176 specpdl_ref count = SPECPDL_INDEX ();
5181 5177
5182 /* Close to the current time if known, an invalid timespec otherwise. */ 5178 /* Close to the current time if known, an invalid timespec otherwise. */
5183 struct timespec now = invalid_timespec (); 5179 struct timespec now = invalid_timespec ();
@@ -6027,7 +6023,7 @@ read_process_output (Lisp_Object proc, int channel)
6027 struct coding_system *coding = proc_decode_coding_system[channel]; 6023 struct coding_system *coding = proc_decode_coding_system[channel];
6028 int carryover = p->decoding_carryover; 6024 int carryover = p->decoding_carryover;
6029 ptrdiff_t readmax = clip_to_bounds (1, read_process_output_max, PTRDIFF_MAX); 6025 ptrdiff_t readmax = clip_to_bounds (1, read_process_output_max, PTRDIFF_MAX);
6030 ptrdiff_t count = SPECPDL_INDEX (); 6026 specpdl_ref count = SPECPDL_INDEX ();
6031 Lisp_Object odeactivate; 6027 Lisp_Object odeactivate;
6032 char *chars; 6028 char *chars;
6033 6029
@@ -7438,7 +7434,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason)
7438{ 7434{
7439 Lisp_Object sentinel, odeactivate; 7435 Lisp_Object sentinel, odeactivate;
7440 struct Lisp_Process *p = XPROCESS (proc); 7436 struct Lisp_Process *p = XPROCESS (proc);
7441 ptrdiff_t count = SPECPDL_INDEX (); 7437 specpdl_ref count = SPECPDL_INDEX ();
7442 bool outer_running_asynch_code = running_asynch_code; 7438 bool outer_running_asynch_code = running_asynch_code;
7443 int waiting = waiting_for_user_input_p; 7439 int waiting = waiting_for_user_input_p;
7444 7440