Use unlocked I/O for a minor performance improvement on hosts like

GNU/Linux and Solaris that support unlocked I/O.  The basic idea
is to use the gnlib unlocked-io module, and to prefer putc and
puts to printf when either will work (since the latter doesn't
come in an unlocked flavor).
* bootstrap (gnulib_modules): Add unlocked-io.
* data/c.m4 (yysymprint): Prefer puts and putc to printf.
* data/glr.c (YYFPUTC, YYFPUTS, YYDPUTS): New macros.
Prefer them to YYFPRINTF and YYDPRINTF if either will do,
and similarly for puts and putc and printf.
* data/yacc.c: Likewise.
* lib/bitset.c (bitset_print): Likewise.
* lib/bitset.h [USE_UNLOCKED_IO]: Include unlocked-io.h.
* lib/bitsetv.c (bitsetv_dump, debug-bitsetv): Prefer putc and puts
to printf.
* lib/lbitset.c (debug_lbitset): Likewise.
* src/closure.c (print_firsts, print_fderives): Likewise.
* src/gram.c (grammar_dump): Likewise.
* src/lalr.c (look_ahead_tokens_print): Likewise.
* src/output.c (escaped_output): Likewise.
(user_actions_output): Coalesce two printfs.
* src/parse-gram.h (%printer): Prefer putc and puts to printf.
* src/reduce.c (reduce_print): Likewise.
* src/state.c (state_rule_look_ahead_tokens_print): Likewise.
* src/system.h: Include unlocked-io.h rathe than stdio.h.
This commit is contained in:
Paul Eggert
2005-10-02 21:24:12 +00:00
parent edb8f44f06
commit fb9c0b3360
17 changed files with 118 additions and 60 deletions

View File

@@ -303,7 +303,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
{
if (pos > 70)
{
fprintf (file, "\n");
fputc ('\n', file);
pos = 0;
}
@@ -312,7 +312,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
};
if (verbose)
fprintf (file, "}\n");
fputs ("}\n", file);
}

View File

@@ -26,6 +26,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "obstack.h"
#include <stdio.h>
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
/* Attributes used to select a bitset implementation. */
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
BITSET_VARIABLE = 2, /* Bitset size variable. */

View File

@@ -153,7 +153,7 @@ bitsetv_dump (FILE *file, char const *title, char const *subtitle,
bitset_dump (file, bsetv[i]);
}
fprintf (file, "\n");
fputc ('\n', file);
}
@@ -168,5 +168,5 @@ debug_bitsetv (bitsetv bsetv)
debug_bitset (bsetv[i]);
}
fprintf (stderr, "\n");
fputc ('\n', stderr);
}

View File

@@ -1400,7 +1400,7 @@ debug_lbitset (bitset bset)
for (j = 0; j < LBITSET_WORD_BITS; j++)
if ((word & ((bitset_word) 1 << j)))
fprintf (stderr, " %u", j);
fprintf (stderr, "\n");
fputc ('\n', stderr);
}
}
}