aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorPaul Eggert2019-07-08 17:50:39 -0700
committerPaul Eggert2019-07-08 17:50:39 -0700
commitf8ab90839fe64b2ec8b398a50e8fb4f33e8e95e1 (patch)
treec3909d7ae6d78c78cc9e293c20cd764f49931bc2 /src/print.c
parent7b70efb740a04517e2764b0986c6e92305c1dd3e (diff)
downloademacs-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/print.c')
-rw-r--r--src/print.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/print.c b/src/print.c
index dc44b1e89e0..6623244c598 100644
--- a/src/print.c
+++ b/src/print.c
@@ -233,7 +233,7 @@ printchar_to_stream (unsigned int ch, FILE *stream)
233 { 233 {
234 if (ASCII_CHAR_P (ch)) 234 if (ASCII_CHAR_P (ch))
235 { 235 {
236 putc_unlocked (ch, stream); 236 putc (ch, stream);
237#ifdef WINDOWSNT 237#ifdef WINDOWSNT
238 /* Send the output to a debugger (nothing happens if there 238 /* Send the output to a debugger (nothing happens if there
239 isn't one). */ 239 isn't one). */
@@ -251,7 +251,7 @@ printchar_to_stream (unsigned int ch, FILE *stream)
251 if (encode_p) 251 if (encode_p)
252 encoded_ch = code_convert_string_norecord (encoded_ch, 252 encoded_ch = code_convert_string_norecord (encoded_ch,
253 coding_system, true); 253 coding_system, true);
254 fwrite_unlocked (SSDATA (encoded_ch), 1, SBYTES (encoded_ch), stream); 254 fwrite (SSDATA (encoded_ch), 1, SBYTES (encoded_ch), stream);
255#ifdef WINDOWSNT 255#ifdef WINDOWSNT
256 if (print_output_debug_flag && stream == stderr) 256 if (print_output_debug_flag && stream == stderr)
257 OutputDebugString (SSDATA (encoded_ch)); 257 OutputDebugString (SSDATA (encoded_ch));
@@ -303,7 +303,7 @@ printchar (unsigned int ch, Lisp_Object fun)
303 if (DISP_TABLE_P (Vstandard_display_table)) 303 if (DISP_TABLE_P (Vstandard_display_table))
304 printchar_to_stream (ch, stdout); 304 printchar_to_stream (ch, stdout);
305 else 305 else
306 fwrite_unlocked (str, 1, len, stdout); 306 fwrite (str, 1, len, stdout);
307 noninteractive_need_newline = 1; 307 noninteractive_need_newline = 1;
308 } 308 }
309 else 309 else
@@ -374,7 +374,7 @@ strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte,
374 } 374 }
375 } 375 }
376 else 376 else
377 fwrite_unlocked (ptr, 1, size_byte, stdout); 377 fwrite (ptr, 1, size_byte, stdout);
378 378
379 noninteractive_need_newline = 1; 379 noninteractive_need_newline = 1;
380 } 380 }
@@ -825,7 +825,7 @@ append to existing target file. */)
825 report_file_error ("Cannot open debugging output stream", file); 825 report_file_error ("Cannot open debugging output stream", file);
826 } 826 }
827 827
828 fflush_unlocked (stderr); 828 fflush (stderr);
829 if (dup2 (fd, STDERR_FILENO) < 0) 829 if (dup2 (fd, STDERR_FILENO) < 0)
830 report_file_error ("dup2", file); 830 report_file_error ("dup2", file);
831 if (fd != stderr_dup) 831 if (fd != stderr_dup)
@@ -840,7 +840,7 @@ void
840debug_print (Lisp_Object arg) 840debug_print (Lisp_Object arg)
841{ 841{
842 Fprin1 (arg, Qexternal_debugging_output); 842 Fprin1 (arg, Qexternal_debugging_output);
843 fprintf (stderr, "\r\n"); 843 fputs ("\r\n", stderr);
844} 844}
845 845
846void safe_debug_print (Lisp_Object) EXTERNALLY_VISIBLE; 846void safe_debug_print (Lisp_Object) EXTERNALLY_VISIBLE;