diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-21 02:36:37 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-21 02:36:37 +0000 |
commit | c013a46ec61dea34c9cd40bfef19757c1f7b718a (patch) | |
tree | 840ebfbffcd09b2abfcb6059dc21b1f965cc1ab5 /gcc/c-common.c | |
parent | ba38213c59d1b22a63f8e16e37f5c06a85e456ca (diff) | |
download | gcc-c013a46ec61dea34c9cd40bfef19757c1f7b718a.tar.gz |
* builtin-attrs.def (__builtin_printf_unlocked,
__builtin_fprintf_unlocked, printf_unlocked, fprintf_unlocked):
Mark with the __printf__ attribute.
* builtins.c (expand_builtin_fputs): Add an `unlocked' parameter
and set the replacement function depending on it.
(expand_builtin): Skip BUILT_IN_*_UNLOCKED when not optimizing.
Handle BUILT_IN_*_UNLOCKED when optimizing.
* builtins.def (DEF_EXT_FALLBACK_BUILTIN,
DEF_EXT_FRONT_END_LIB_BUILTIN): New macros.
Declare the "unlocked" stdio functions.
* c-common.c (c_expand_builtin_printf, c_expand_builtin_fprintf):
Add an `unlocked' parameter and set the replacement function
depending on it.
(c_expand_builtin): Handle BUILT_IN_PRINTF_UNLOCKED and
BUILT_IN_FPRINTF_UNLOCKED.
* doc/extend.texi (printf_unlocked, fprintf_unlocked,
fputs_unlocked): Document.
testsuite:
* gcc.dg/format/builtin-1.c: Test unlocked stdio.
* gcc.dg/format/c90-printf-3.c: Likewise.
* gcc.dg/format/c99-printf-3.c: Likewise.
* gcc.dg/format/ext-1.c: Likewise.
* gcc.dg/format/ext-6.c: Likewise.
* gcc.dg/format/format.h: Prototype unlocked stdio.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48229 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 1a85f44ea57..d671e3bdf72 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -643,9 +643,9 @@ combine_strings (strings) static int is_valid_printf_arglist PARAMS ((tree)); static rtx c_expand_builtin PARAMS ((tree, rtx, enum machine_mode, enum expand_modifier)); static rtx c_expand_builtin_printf PARAMS ((tree, rtx, enum machine_mode, - enum expand_modifier, int)); + enum expand_modifier, int, int)); static rtx c_expand_builtin_fprintf PARAMS ((tree, rtx, enum machine_mode, - enum expand_modifier, int)); + enum expand_modifier, int, int)); /* Print a warning if a constant expression had overflow in folding. Invoke this function on every expression that the language @@ -3589,14 +3589,28 @@ c_expand_builtin (exp, target, tmode, modifier) { case BUILT_IN_PRINTF: target = c_expand_builtin_printf (arglist, target, tmode, - modifier, ignore); + modifier, ignore,/*unlocked=*/ 0); + if (target) + return target; + break; + + case BUILT_IN_PRINTF_UNLOCKED: + target = c_expand_builtin_printf (arglist, target, tmode, + modifier, ignore,/*unlocked=*/ 1); if (target) return target; break; case BUILT_IN_FPRINTF: target = c_expand_builtin_fprintf (arglist, target, tmode, - modifier, ignore); + modifier, ignore,/*unlocked=*/ 0); + if (target) + return target; + break; + + case BUILT_IN_FPRINTF_UNLOCKED: + target = c_expand_builtin_fprintf (arglist, target, tmode, + modifier, ignore,/*unlocked=*/ 1); if (target) return target; break; @@ -3649,15 +3663,18 @@ is_valid_printf_arglist (arglist) /* If the arguments passed to printf are suitable for optimizations, we attempt to transform the call. */ static rtx -c_expand_builtin_printf (arglist, target, tmode, modifier, ignore) +c_expand_builtin_printf (arglist, target, tmode, modifier, ignore, unlocked) tree arglist; rtx target; enum machine_mode tmode; enum expand_modifier modifier; int ignore; + int unlocked; { - tree fn_putchar = built_in_decls[BUILT_IN_PUTCHAR], - fn_puts = built_in_decls[BUILT_IN_PUTS]; + tree fn_putchar = unlocked ? + built_in_decls[BUILT_IN_PUTCHAR_UNLOCKED] : built_in_decls[BUILT_IN_PUTCHAR]; + tree fn_puts = unlocked ? + built_in_decls[BUILT_IN_PUTS_UNLOCKED] : built_in_decls[BUILT_IN_PUTS]; tree fn, format_arg, stripped_string; /* If the return value is used, or the replacement _DECL isn't @@ -3750,15 +3767,18 @@ c_expand_builtin_printf (arglist, target, tmode, modifier, ignore) /* If the arguments passed to fprintf are suitable for optimizations, we attempt to transform the call. */ static rtx -c_expand_builtin_fprintf (arglist, target, tmode, modifier, ignore) +c_expand_builtin_fprintf (arglist, target, tmode, modifier, ignore, unlocked) tree arglist; rtx target; enum machine_mode tmode; enum expand_modifier modifier; int ignore; + int unlocked; { - tree fn_fputc = built_in_decls[BUILT_IN_FPUTC], - fn_fputs = built_in_decls[BUILT_IN_FPUTS]; + tree fn_fputc = unlocked ? + built_in_decls[BUILT_IN_FPUTC_UNLOCKED] : built_in_decls[BUILT_IN_FPUTC]; + tree fn_fputs = unlocked ? + built_in_decls[BUILT_IN_FPUTS_UNLOCKED] : built_in_decls[BUILT_IN_FPUTS]; tree fn, format_arg, stripped_string; /* If the return value is used, or the replacement _DECL isn't |