aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2001-12-21 02:36:37 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2001-12-21 02:36:37 +0000
commitb4c984fbec1caaaa03c2c2bf2c9b42d3f7679223 (patch)
tree840ebfbffcd09b2abfcb6059dc21b1f965cc1ab5 /gcc/builtins.c
parentbfa8af3e37f63413295d14f15eae6dda770d4a02 (diff)
downloadgcc-b4c984fbec1caaaa03c2c2bf2c9b42d3f7679223.zip
gcc-b4c984fbec1caaaa03c2c2bf2c9b42d3f7679223.tar.gz
gcc-b4c984fbec1caaaa03c2c2bf2c9b42d3f7679223.tar.bz2
builtin-attrs.def (__builtin_printf_unlocked, [...]): Mark with the __printf__ attribute.
* 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. From-SVN: r48229
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 8d86cc4..1df7a0d 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -142,7 +142,7 @@ static rtx expand_builtin_strrchr PARAMS ((tree, rtx,
static rtx expand_builtin_alloca PARAMS ((tree, rtx));
static rtx expand_builtin_ffs PARAMS ((tree, rtx, rtx));
static rtx expand_builtin_frame_address PARAMS ((tree));
-static rtx expand_builtin_fputs PARAMS ((tree, int));
+static rtx expand_builtin_fputs PARAMS ((tree, int, int));
static tree stabilize_va_list PARAMS ((tree, int));
static rtx expand_builtin_expect PARAMS ((tree, rtx));
static tree fold_builtin_constant_p PARAMS ((tree));
@@ -3287,12 +3287,16 @@ expand_builtin_ffs (arglist, target, subtarget)
long, we attempt to transform this call into __builtin_fputc(). */
static rtx
-expand_builtin_fputs (arglist, ignore)
+expand_builtin_fputs (arglist, ignore, unlocked)
tree arglist;
int ignore;
+ int unlocked;
{
- tree len, fn, fn_fputc = built_in_decls[BUILT_IN_FPUTC],
- fn_fwrite = built_in_decls[BUILT_IN_FWRITE];
+ tree len, fn;
+ tree fn_fputc = unlocked ? built_in_decls[BUILT_IN_FPUTC_UNLOCKED]
+ : built_in_decls[BUILT_IN_FPUTC];
+ tree fn_fwrite = unlocked ? built_in_decls[BUILT_IN_FWRITE_UNLOCKED]
+ : built_in_decls[BUILT_IN_FWRITE];
/* If the return value is used, or the replacement _DECL isn't
initialized, don't do the transformation. */
@@ -3581,6 +3585,12 @@ expand_builtin (exp, target, subtarget, mode, ignore)
case BUILT_IN_FPUTC:
case BUILT_IN_FPUTS:
case BUILT_IN_FWRITE:
+ case BUILT_IN_PUTCHAR_UNLOCKED:
+ case BUILT_IN_PUTS_UNLOCKED:
+ case BUILT_IN_PRINTF_UNLOCKED:
+ case BUILT_IN_FPUTC_UNLOCKED:
+ case BUILT_IN_FPUTS_UNLOCKED:
+ case BUILT_IN_FWRITE_UNLOCKED:
return expand_call (exp, target, ignore);
default:
@@ -3863,9 +3873,18 @@ expand_builtin (exp, target, subtarget, mode, ignore)
case BUILT_IN_PUTS:
case BUILT_IN_FPUTC:
case BUILT_IN_FWRITE:
+ case BUILT_IN_PUTCHAR_UNLOCKED:
+ case BUILT_IN_PUTS_UNLOCKED:
+ case BUILT_IN_FPUTC_UNLOCKED:
+ case BUILT_IN_FWRITE_UNLOCKED:
break;
case BUILT_IN_FPUTS:
- target = expand_builtin_fputs (arglist, ignore);
+ target = expand_builtin_fputs (arglist, ignore,/*unlocked=*/ 0);
+ if (target)
+ return target;
+ break;
+ case BUILT_IN_FPUTS_UNLOCKED:
+ target = expand_builtin_fputs (arglist, ignore,/*unlocked=*/ 1);
if (target)
return target;
break;