diff options
| author | Paul Eggert | 2019-07-08 17:50:39 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-08 17:50:39 -0700 |
| commit | f8ab90839fe64b2ec8b398a50e8fb4f33e8e95e1 (patch) | |
| tree | c3909d7ae6d78c78cc9e293c20cd764f49931bc2 /src/term.c | |
| parent | 7b70efb740a04517e2764b0986c6e92305c1dd3e (diff) | |
| download | emacs-f8ab90839fe64b2ec8b398a50e8fb4f33e8e95e1.tar.gz emacs-f8ab90839fe64b2ec8b398a50e8fb4f33e8e95e1.zip | |
Use fewer locks when accessing stdio
* src/alloc.c, src/bidi.c, src/emacs-module.c, src/pdumper.c:
* src/regex-emacs.c, src/unexhp9k800.c, src/unexmacosx.c:
* src/widget.c, src/xdisp.c, src/xselect.c, src/xterm.c:
Include sysstdio.h instead of stdio.h, to avoid locking
stdio streams in many cases.
* src/alloc.c (test_setjmp):
* src/bidi.c (bidi_dump_cached_states):
* src/cm.c (calccost):
* src/dispnew.c (init_display_interactive):
* src/emacs.c (main):
* src/image.c (convert_mono_to_color_image):
* src/minibuf.c (read_minibuf_noninteractive):
* src/nsfont.m (ns_descriptor_to_entity)
(ns_dump_glyphstring):
* src/nsterm.h (NSTRACE_MSG_NO_DASHES):
* src/nsterm.m (ns_mouse_position)
(sendEvent:, keyDown:, performDragOperation:):
* src/pdumper.c (dump_fingerprint, print_paths_to_root_1):
* src/print.c (debug_print):
* src/regex-emacs.c (debug_putchar, print_fastmap)
(print_partial_compiled_pattern, print_compiled_pattern)
(print_double_string, regex_compile):
* src/term.c (vfatal):
* src/unexhp9k800.c (read_header):
* src/unexmacosx.c (unexec_error):
* src/widget.c (EmacsFrameInitialize):
* src/xdisp.c (message_to_stderr, vmessage, dump_glyph_row)
(Fdump_glyph_matrix, Fdump_frame_glyph_matrix, dump_glyph_string):
* src/xfaces.c (Fdump_colors, Fdump_face):
* src/xselect.c (x_clipboard_manager_error_2):
* src/xterm.c (x_initialize):
* src/xwidget.c (WEBKIT_FN_INIT):
Prefer unlocked calls like fputs to locked calls like fprintf.
* src/charset.c (read_hex):
* src/cm.c (cmputc, cmcheckmagic):
* src/dispnew.c (update_frame, update_frame_with_menu)
(update_frame_1, Fsend_string_to_terminal, Fding)
(bitch_at_user):
* src/emacs.c (main, Fdump_emacs):
* src/emacs-module.c (module_abort):
* src/fileio.c (Fdo_auto_save):
* src/image.c (slurp_file)
(png_read_from_file, png_load_body, our_stdio_fill_input_buffer):
* src/keyboard.c (record_char, kbd_buffer_get_event)
(handle_interrupt):
* src/lread.c (readbyte_from_stdio, read1):
* src/minibuf.c (read_minibuf_noninteractive):
* src/print.c (printchar_to_stream, strout)
(Fredirect_debugging_output):
* src/sysdep.c (reset_sys_modes, close_output_streams)
(procfs_ttyname, procfs_get_total_memory):
* src/term.c (tty_ring_bell, tty_send_additional_strings)
(tty_set_terminal_modes, tty_reset_terminal_modes)
(tty_update_end, tty_clear_end_of_line, tty_write_glyphs)
(tty_write_glyphs_with_face, tty_insert_glyphs)
(tty_menu_activate):
* src/xfaces.c (Fx_load_color_file):
Simplify by using ordinary calls like putc to explicitly-unlocked
calls like putc_unlocked, since the ordinary calls are now
unlocked anyway.
* src/emacs.c (main, Fdump_emacs):
* src/pdumper.c (Fdump_emacs_portable):
Coalesce adjacent printfs.
* src/nsterm.h: Include sysstdio.h as this file’s macros rely on it.
* src/regex-emacs.c (print_compiled_pattern):
Omit redundant fflush.
* src/sysstdio.h: Include unlocked-io.h.
(clearerr_unlocked, feof_unlocked, ferror_unlocked)
(fflush_unlocked, fgets_unlocked, fputc_unlocked)
(fputs_unlocked, fread_unlocked, fwrite_unlocked)
(getc_unlocked, getchar_unlocked, putc_unlocked)
(putchar_unlocked): Remove these macros; now done by unlocked-io.h.
* src/xwidget.c: Include sysstdio.h.
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/term.c b/src/term.c index 8b5a710d80a..b058d8bdad0 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -145,7 +145,7 @@ tty_ring_bell (struct frame *f) | |||
| 145 | OUTPUT (tty, (tty->TS_visible_bell && visible_bell | 145 | OUTPUT (tty, (tty->TS_visible_bell && visible_bell |
| 146 | ? tty->TS_visible_bell | 146 | ? tty->TS_visible_bell |
| 147 | : tty->TS_bell)); | 147 | : tty->TS_bell)); |
| 148 | fflush_unlocked (tty->output); | 148 | fflush (tty->output); |
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | 151 | ||
| @@ -170,10 +170,9 @@ tty_send_additional_strings (struct terminal *terminal, Lisp_Object sym) | |||
| 170 | Lisp_Object string = XCAR (extra_codes); | 170 | Lisp_Object string = XCAR (extra_codes); |
| 171 | if (STRINGP (string)) | 171 | if (STRINGP (string)) |
| 172 | { | 172 | { |
| 173 | fwrite_unlocked (SDATA (string), 1, SBYTES (string), tty->output); | 173 | fwrite (SDATA (string), 1, SBYTES (string), tty->output); |
| 174 | if (tty->termscript) | 174 | if (tty->termscript) |
| 175 | fwrite_unlocked (SDATA (string), 1, SBYTES (string), | 175 | fwrite (SDATA (string), 1, SBYTES (string), tty->termscript); |
| 176 | tty->termscript); | ||
| 177 | } | 176 | } |
| 178 | } | 177 | } |
| 179 | } | 178 | } |
| @@ -201,7 +200,7 @@ tty_set_terminal_modes (struct terminal *terminal) | |||
| 201 | OUTPUT_IF (tty, tty->TS_keypad_mode); | 200 | OUTPUT_IF (tty, tty->TS_keypad_mode); |
| 202 | losecursor (tty); | 201 | losecursor (tty); |
| 203 | tty_send_additional_strings (terminal, Qtty_mode_set_strings); | 202 | tty_send_additional_strings (terminal, Qtty_mode_set_strings); |
| 204 | fflush_unlocked (tty->output); | 203 | fflush (tty->output); |
| 205 | } | 204 | } |
| 206 | } | 205 | } |
| 207 | 206 | ||
| @@ -224,7 +223,7 @@ tty_reset_terminal_modes (struct terminal *terminal) | |||
| 224 | /* Output raw CR so kernel can track the cursor hpos. */ | 223 | /* Output raw CR so kernel can track the cursor hpos. */ |
| 225 | current_tty = tty; | 224 | current_tty = tty; |
| 226 | cmputc ('\r'); | 225 | cmputc ('\r'); |
| 227 | fflush_unlocked (tty->output); | 226 | fflush (tty->output); |
| 228 | } | 227 | } |
| 229 | } | 228 | } |
| 230 | 229 | ||
| @@ -239,7 +238,7 @@ tty_update_end (struct frame *f) | |||
| 239 | tty_show_cursor (tty); | 238 | tty_show_cursor (tty); |
| 240 | tty_turn_off_insert (tty); | 239 | tty_turn_off_insert (tty); |
| 241 | tty_background_highlight (tty); | 240 | tty_background_highlight (tty); |
| 242 | fflush_unlocked (tty->output); | 241 | fflush (tty->output); |
| 243 | } | 242 | } |
| 244 | 243 | ||
| 245 | /* The implementation of set_terminal_window for termcap frames. */ | 244 | /* The implementation of set_terminal_window for termcap frames. */ |
| @@ -501,8 +500,8 @@ tty_clear_end_of_line (struct frame *f, int first_unused_hpos) | |||
| 501 | for (i = curX (tty); i < first_unused_hpos; i++) | 500 | for (i = curX (tty); i < first_unused_hpos; i++) |
| 502 | { | 501 | { |
| 503 | if (tty->termscript) | 502 | if (tty->termscript) |
| 504 | fputc_unlocked (' ', tty->termscript); | 503 | putc (' ', tty->termscript); |
| 505 | fputc_unlocked (' ', tty->output); | 504 | putc (' ', tty->output); |
| 506 | } | 505 | } |
| 507 | cmplus (tty, first_unused_hpos - curX (tty)); | 506 | cmplus (tty, first_unused_hpos - curX (tty)); |
| 508 | } | 507 | } |
| @@ -775,11 +774,10 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len) | |||
| 775 | if (coding->produced > 0) | 774 | if (coding->produced > 0) |
| 776 | { | 775 | { |
| 777 | block_input (); | 776 | block_input (); |
| 778 | fwrite_unlocked (conversion_buffer, 1, coding->produced, tty->output); | 777 | fwrite (conversion_buffer, 1, coding->produced, tty->output); |
| 779 | clearerr_unlocked (tty->output); | 778 | clearerr (tty->output); |
| 780 | if (tty->termscript) | 779 | if (tty->termscript) |
| 781 | fwrite_unlocked (conversion_buffer, 1, coding->produced, | 780 | fwrite (conversion_buffer, 1, coding->produced, tty->termscript); |
| 782 | tty->termscript); | ||
| 783 | unblock_input (); | 781 | unblock_input (); |
| 784 | } | 782 | } |
| 785 | string += n; | 783 | string += n; |
| @@ -836,11 +834,10 @@ tty_write_glyphs_with_face (register struct frame *f, register struct glyph *str | |||
| 836 | if (coding->produced > 0) | 834 | if (coding->produced > 0) |
| 837 | { | 835 | { |
| 838 | block_input (); | 836 | block_input (); |
| 839 | fwrite_unlocked (conversion_buffer, 1, coding->produced, tty->output); | 837 | fwrite (conversion_buffer, 1, coding->produced, tty->output); |
| 840 | clearerr_unlocked (tty->output); | 838 | clearerr (tty->output); |
| 841 | if (tty->termscript) | 839 | if (tty->termscript) |
| 842 | fwrite_unlocked (conversion_buffer, 1, coding->produced, | 840 | fwrite (conversion_buffer, 1, coding->produced, tty->termscript); |
| 843 | tty->termscript); | ||
| 844 | unblock_input (); | 841 | unblock_input (); |
| 845 | } | 842 | } |
| 846 | 843 | ||
| @@ -922,11 +919,10 @@ tty_insert_glyphs (struct frame *f, struct glyph *start, int len) | |||
| 922 | if (coding->produced > 0) | 919 | if (coding->produced > 0) |
| 923 | { | 920 | { |
| 924 | block_input (); | 921 | block_input (); |
| 925 | fwrite_unlocked (conversion_buffer, 1, coding->produced, tty->output); | 922 | fwrite (conversion_buffer, 1, coding->produced, tty->output); |
| 926 | clearerr_unlocked (tty->output); | 923 | clearerr (tty->output); |
| 927 | if (tty->termscript) | 924 | if (tty->termscript) |
| 928 | fwrite_unlocked (conversion_buffer, 1, coding->produced, | 925 | fwrite (conversion_buffer, 1, coding->produced, tty->termscript); |
| 929 | tty->termscript); | ||
| 930 | unblock_input (); | 926 | unblock_input (); |
| 931 | } | 927 | } |
| 932 | 928 | ||
| @@ -3331,7 +3327,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3331 | which calls tty_show_cursor. Re-hide it, so it doesn't show | 3327 | which calls tty_show_cursor. Re-hide it, so it doesn't show |
| 3332 | through the menus. */ | 3328 | through the menus. */ |
| 3333 | tty_hide_cursor (tty); | 3329 | tty_hide_cursor (tty); |
| 3334 | fflush_unlocked (tty->output); | 3330 | fflush (tty->output); |
| 3335 | } | 3331 | } |
| 3336 | 3332 | ||
| 3337 | sf->mouse_moved = 0; | 3333 | sf->mouse_moved = 0; |
| @@ -3339,7 +3335,7 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3339 | while (statecount--) | 3335 | while (statecount--) |
| 3340 | free_saved_screen (state[statecount].screen_behind); | 3336 | free_saved_screen (state[statecount].screen_behind); |
| 3341 | tty_show_cursor (tty); /* Turn cursor back on. */ | 3337 | tty_show_cursor (tty); /* Turn cursor back on. */ |
| 3342 | fflush_unlocked (tty->output); | 3338 | fflush (tty->output); |
| 3343 | 3339 | ||
| 3344 | /* Clean up any mouse events that are waiting inside Emacs event queue. | 3340 | /* Clean up any mouse events that are waiting inside Emacs event queue. |
| 3345 | These events are likely to be generated before the menu was even | 3341 | These events are likely to be generated before the menu was even |
| @@ -4398,10 +4394,10 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\ | |||
| 4398 | static void | 4394 | static void |
| 4399 | vfatal (const char *str, va_list ap) | 4395 | vfatal (const char *str, va_list ap) |
| 4400 | { | 4396 | { |
| 4401 | fprintf (stderr, "emacs: "); | 4397 | fputs ("emacs: ", stderr); |
| 4402 | vfprintf (stderr, str, ap); | 4398 | vfprintf (stderr, str, ap); |
| 4403 | if (! (str[0] && str[strlen (str) - 1] == '\n')) | 4399 | if (! (str[0] && str[strlen (str) - 1] == '\n')) |
| 4404 | fprintf (stderr, "\n"); | 4400 | putc ('\n', stderr); |
| 4405 | exit (1); | 4401 | exit (1); |
| 4406 | } | 4402 | } |
| 4407 | 4403 | ||