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/sysdep.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/sysdep.c')
| -rw-r--r-- | src/sysdep.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index c7d7eefc2ab..99d3ee60698 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1472,7 +1472,7 @@ reset_sys_modes (struct tty_display_info *tty_out) | |||
| 1472 | { | 1472 | { |
| 1473 | if (noninteractive) | 1473 | if (noninteractive) |
| 1474 | { | 1474 | { |
| 1475 | fflush_unlocked (stdout); | 1475 | fflush (stdout); |
| 1476 | return; | 1476 | return; |
| 1477 | } | 1477 | } |
| 1478 | if (!tty_out->term_initted) | 1478 | if (!tty_out->term_initted) |
| @@ -1495,11 +1495,11 @@ reset_sys_modes (struct tty_display_info *tty_out) | |||
| 1495 | tty_turn_off_insert (tty_out); | 1495 | tty_turn_off_insert (tty_out); |
| 1496 | 1496 | ||
| 1497 | for (int i = cursorX (tty_out); i < FrameCols (tty_out) - 1; i++) | 1497 | for (int i = cursorX (tty_out); i < FrameCols (tty_out) - 1; i++) |
| 1498 | fputc_unlocked (' ', tty_out->output); | 1498 | putc (' ', tty_out->output); |
| 1499 | } | 1499 | } |
| 1500 | 1500 | ||
| 1501 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); | 1501 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
| 1502 | fflush_unlocked (tty_out->output); | 1502 | fflush (tty_out->output); |
| 1503 | 1503 | ||
| 1504 | if (tty_out->terminal->reset_terminal_modes_hook) | 1504 | if (tty_out->terminal->reset_terminal_modes_hook) |
| 1505 | tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal); | 1505 | tty_out->terminal->reset_terminal_modes_hook (tty_out->terminal); |
| @@ -2783,7 +2783,7 @@ close_output_streams (void) | |||
| 2783 | /* Do not close stderr if addresses are being sanitized, as the | 2783 | /* Do not close stderr if addresses are being sanitized, as the |
| 2784 | sanitizer might report to stderr after this function is invoked. */ | 2784 | sanitizer might report to stderr after this function is invoked. */ |
| 2785 | if (ADDRESS_SANITIZER | 2785 | if (ADDRESS_SANITIZER |
| 2786 | ? fflush_unlocked (stderr) != 0 || ferror (stderr) | 2786 | ? fflush (stderr) != 0 || ferror (stderr) |
| 2787 | : close_stream (stderr) != 0) | 2787 | : close_stream (stderr) != 0) |
| 2788 | _exit (EXIT_FAILURE); | 2788 | _exit (EXIT_FAILURE); |
| 2789 | } | 2789 | } |
| @@ -3184,7 +3184,7 @@ procfs_ttyname (int rdev) | |||
| 3184 | char minor[25]; /* 2 32-bit numbers + dash */ | 3184 | char minor[25]; /* 2 32-bit numbers + dash */ |
| 3185 | char *endp; | 3185 | char *endp; |
| 3186 | 3186 | ||
| 3187 | for (; !feof_unlocked (fdev) && !ferror_unlocked (fdev); name[0] = 0) | 3187 | for (; !feof (fdev) && !ferror (fdev); name[0] = 0) |
| 3188 | { | 3188 | { |
| 3189 | if (fscanf (fdev, "%*s %s %u %s %*s\n", name, &major, minor) >= 3 | 3189 | if (fscanf (fdev, "%*s %s %u %s %*s\n", name, &major, minor) >= 3 |
| 3190 | && major == MAJOR (rdev)) | 3190 | && major == MAJOR (rdev)) |
| @@ -3234,7 +3234,7 @@ procfs_get_total_memory (void) | |||
| 3234 | break; | 3234 | break; |
| 3235 | 3235 | ||
| 3236 | case 0: | 3236 | case 0: |
| 3237 | while ((c = getc_unlocked (fmem)) != EOF && c != '\n') | 3237 | while ((c = getc (fmem)) != EOF && c != '\n') |
| 3238 | continue; | 3238 | continue; |
| 3239 | done = c == EOF; | 3239 | done = c == EOF; |
| 3240 | break; | 3240 | break; |