]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
builtin-attrs.def (__builtin_printf_unlocked, [...]): Mark with the __printf__ attribute.
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Fri, 21 Dec 2001 02:36:37 +0000 (02:36 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Fri, 21 Dec 2001 02:36:37 +0000 (02:36 +0000)
* 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

13 files changed:
gcc/ChangeLog
gcc/builtin-attrs.def
gcc/builtins.c
gcc/builtins.def
gcc/c-common.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/format/builtin-1.c
gcc/testsuite/gcc.dg/format/c90-printf-3.c
gcc/testsuite/gcc.dg/format/c99-printf-3.c
gcc/testsuite/gcc.dg/format/ext-1.c
gcc/testsuite/gcc.dg/format/ext-6.c
gcc/testsuite/gcc.dg/format/format.h

index 0db4281e9891ebb742a7a9d81de3f141133c62ab..33602270c7ec34278d38648e992038a988790d82 100644 (file)
@@ -1,3 +1,27 @@
+2001-12-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * 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.
+
 2001-12-20  Josef Zlomek  <zlomek@matfyz.cz>
 
        * cfgloop.c (flow_loops_find): Use the information of the depth
index de98501cf36aca3516249335c32d11b028a130fb..10b370893e2e89e9f835487a58f803dfc08e2099 100644 (file)
@@ -125,6 +125,8 @@ DEF_ATTR_TREE_LIST (ATTR_FORMAT_ARG_2, ATTR_FORMAT_ARG, ATTR_LIST_2, ATTR_NULL)
    -ffreestanding.  */
 DEF_FN_ATTR_IDENT (__builtin_printf, ATTR_FORMAT_PRINTF_1_2, true)
 DEF_FN_ATTR_IDENT (__builtin_fprintf, ATTR_FORMAT_PRINTF_2_3, true)
+DEF_FN_ATTR_IDENT (__builtin_printf_unlocked, ATTR_FORMAT_PRINTF_1_2, true)
+DEF_FN_ATTR_IDENT (__builtin_fprintf_unlocked, ATTR_FORMAT_PRINTF_2_3, true)
 
 /* Functions from ISO/IEC 9899:1990.  */
 #define DEF_C89_ATTR(NAME, ATTRS) DEF_FN_ATTR_IDENT (NAME, ATTRS, flag_hosted)
@@ -162,5 +164,8 @@ DEF_EXT_ATTR (dgettext, ATTR_FORMAT_ARG_2)
 DEF_EXT_ATTR (dcgettext, ATTR_FORMAT_ARG_2)
 /* X/Open strfmon function.  */
 DEF_EXT_ATTR (strfmon, ATTR_FORMAT_STRFMON_3_4)
+/* Glibc thread-unsafe stdio functions.  */
+DEF_EXT_ATTR (printf_unlocked, ATTR_FORMAT_PRINTF_1_2)
+DEF_EXT_ATTR (fprintf_unlocked, ATTR_FORMAT_PRINTF_2_3)
 #undef DEF_EXT_ATTR
 #undef DEF_FN_ATTR_IDENT
index 8d86cc47511218c9b13eeb3aafe25ea7f6083b84..1df7a0d0b5a4bfe88f155f8978488755ed587633 100644 (file)
@@ -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;
index 58d949325047230a3aa8fdb195af86b29be8e8de..7b58bef1ae156e010a54acfbd672333badd45d48 100644 (file)
@@ -70,6 +70,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE,        \
               false, true, false)
 
+/* Like DEF_FALLBACK_BUILTIN, except that the function is not one that
+   is specified by ANSI/ISO C.  So, when we're being fully conformant
+   we ignore the version of these builtins that does not begin with
+   __builtin.  */
+#undef DEF_EXT_FALLBACK_BUILTIN
+#define DEF_EXT_FALLBACK_BUILTIN(ENUM, NAME, TYPE)     \
+  DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE,        \
+              false, true, true)
+
 /* A library builtin (like __builtin_strchr) is a builtin equivalent
    of an ANSI/ISO standard library function.  In addition to the
    `__builtin' version, we will create an ordinary version (e.g,
@@ -111,6 +120,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   DEF_BUILTIN (ENUM, NAME, BUILT_IN_FRONTEND, TYPE, TYPE,      \
               true, true, false)
 
+/* Like DEF_FRONT_END_LIB_BUILTIN, except that the function is not one
+   that is specified by ANSI/ISO C.  So, when we're being fully
+   conformant we ignore the version of these builtins that does not
+   begin with __builtin.  */
+#undef DEF_EXT_FRONT_END_LIB_BUILTIN                   
+#define DEF_EXT_FRONT_END_LIB_BUILTIN(ENUM, NAME, TYPE)                \
+  DEF_BUILTIN (ENUM, NAME, BUILT_IN_FRONTEND, TYPE, TYPE,      \
+              true, true, true)
+
 /* A built-in that is not currently used.  */
 #undef DEF_UNUSED_BUILTIN                                      
 #define DEF_UNUSED_BUILTIN(X)                                  \
@@ -370,6 +388,37 @@ DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF,
                         "__builtin_fprintf",
                         BT_FN_INT_PTR_CONST_STRING_VAR)
 
+/* Stdio unlocked builtins.  */
+
+DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR_UNLOCKED,
+                        "__builtin_putchar_unlocked",
+                        BT_FN_INT_INT)
+DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTS_UNLOCKED,
+                        "__builtin_puts_unlocked",
+                        BT_FN_INT_CONST_STRING)
+DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF_UNLOCKED,
+                             "__builtin_printf_unlocked",
+                             BT_FN_INT_CONST_STRING_VAR)
+DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FPUTC_UNLOCKED,
+                        "__builtin_fputc_unlocked",
+                        BT_FN_INT_INT_PTR)
+/* Declare the __builtin_ style with arguments and the regular style
+   without them.  We rely on stdio.h to supply the arguments for the
+   regular style declaration since we had to use void* instead of
+   FILE* in the __builtin_ prototype supplied here.  */
+DEF_BUILTIN (BUILT_IN_FPUTS_UNLOCKED,
+            "__builtin_fputs_unlocked",
+            BUILT_IN_NORMAL,
+            BT_FN_INT_CONST_STRING_PTR,
+            BT_FN_INT_VAR,
+            true, true, true)
+DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FWRITE_UNLOCKED,
+                        "__builtin_fwrite_unlocked",
+                        BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR)
+DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF_UNLOCKED,
+                             "__builtin_fprintf_unlocked",
+                             BT_FN_INT_PTR_CONST_STRING_VAR)
+
   /* ISO C99 floating point unordered comparisons.  */
 DEF_GCC_BUILTIN(BUILT_IN_ISGREATER, 
                "__builtin_isgreater",
index 1a85f44ea57dcbebc533ce0216aa3d0fa34726bd..d671e3bdf7275270739e7da5958de7aff87add26 100644 (file)
@@ -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));
 \f
 /* 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
index a9f659d7c5753ff76440d4b84ab1cfad75684f58..a224770953b9cfffa916d5ddb0542ae078be7774 100644 (file)
@@ -2047,7 +2047,8 @@ warnings are requested (using @option{-Wformat}), so there is no need to
 modify the header file @file{stdio.h}.  In C99 mode, the functions
 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
 @code{vsscanf} are also checked.  Except in strictly conforming C
-standard modes, the X/Open function @code{strfmon} is also checked.
+standard modes, the X/Open function @code{strfmon} is also checked as
+are @code{printf_unlocked} and @code{fprintf_unlocked}.
 @xref{C Dialect Options,,Options Controlling C Dialect}.
 
 @item format_arg (@var{string-index})
@@ -4259,7 +4260,9 @@ v4si f (v4si a, v4si b, v4si c)
 @findex fabsl
 @findex ffs
 @findex fprintf
+@findex fprintf_unlocked
 @findex fputs
+@findex fputs_unlocked
 @findex imaxabs
 @findex index
 @findex labs
@@ -4268,6 +4271,7 @@ v4si f (v4si a, v4si b, v4si c)
 @findex memcpy
 @findex memset
 @findex printf
+@findex printf_unlocked
 @findex rindex
 @findex sin
 @findex sinf
@@ -4315,8 +4319,9 @@ in.  @code{_exit} is not recognized in strict ISO C mode (@option{-ansi},
 strict C89 mode (@option{-ansi} or @option{-std=c89}).
 
 Outside strict ISO C mode, the functions @code{alloca}, @code{bcmp},
-@code{bzero}, @code{index}, @code{rindex} and @code{ffs} may be handled
-as built-in functions.  All these functions have corresponding versions
+@code{bzero}, @code{index}, @code{rindex}, @code{ffs}, @code{fputs_unlocked},
+@code{printf_unlocked} and @code{fprintf_unlocked} may be handled as
+built-in functions.  All these functions have corresponding versions
 prefixed with @code{__builtin_}, which may be used even in strict C89
 mode.
 
index 56f40ec828673fd4bdd80be7a111f7edb2a8f0a9..1a1c24d998038aaa6807b981a057de3028c72195 100644 (file)
@@ -1,3 +1,12 @@
+2001-12-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * 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.
+
 2001-12-20  Richard Henderson  <rth@redhat.com>
 
        * g++.old-deja/g++.eh/badalloc1.C (arena_size): New.
index e128635b99acd951b81c73b3461677ed9f40e512..ba1cab6473a7936aa1e8f1b733496690076fe6fc 100644 (file)
@@ -14,4 +14,9 @@ foo (int i)
   __builtin_fprintf (stdout, "%ld", i); /* { dg-warning "format" "__builtin_fprintf" } */
   __builtin_printf ("%d", i);
   __builtin_printf ("%ld", i); /* { dg-warning "format" "__builtin_printf" } */
+
+  __builtin_fprintf_unlocked (stdout, "%d", i);
+  __builtin_fprintf_unlocked (stdout, "%ld", i); /* { dg-warning "format" "__builtin_fprintf_unlocked" } */
+  __builtin_printf_unlocked ("%d", i);
+  __builtin_printf_unlocked ("%ld", i); /* { dg-warning "format" "__builtin_printf_unlocked" } */
 }
index 78518a2b6599df2fae8eb0424b9eb7de4938018c..1d53de32f6582b4b56a20d44ac1d2d2863f6d1bb 100644 (file)
@@ -16,6 +16,9 @@ foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
   fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
   printf ("%d", i);
   printf ("%ld", i); /* { dg-warning "format" "printf" } */
+  /* The "unlocked" functions shouldn't warn in c90 mode.  */
+  fprintf_unlocked (stdout, "%ld", i); /* { dg-bogus "format" "fprintf_unlocked" } */
+  printf_unlocked ("%ld", i); /* { dg-bogus "format" "printf_unlocked" } */
   sprintf (s, "%d", i);
   sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
   vfprintf (stdout, "%d", v0);
index 23ef33d29d00922a578a0c8cf7212130444a58f5..b8ae405b299a25c6ce20ce2cbc0a396135b1482b 100644 (file)
@@ -15,6 +15,9 @@ foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
   fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
   printf ("%d", i);
   printf ("%ld", i); /* { dg-warning "format" "printf" } */
+  /* The "unlocked" functions shouldn't warn in c99 mode.  */
+  fprintf_unlocked (stdout, "%ld", i); /* { dg-bogus "format" "fprintf_unlocked" } */
+  printf_unlocked ("%ld", i); /* { dg-bogus "format" "printf_unlocked" } */
   sprintf (s, "%d", i);
   sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
   snprintf (s, n, "%d", i);
index dd780321c0a261c730ae2e7fc9f962b315796c7a..e69e756085cf5f438efb354815acbebb98b2f0d8 100644 (file)
@@ -116,4 +116,11 @@ foo (quad_t q, u_quad_t uq, quad_t *qn, size_t z, size_t *zn, long long int ll,
   printf ("%IC", lc); /* { dg-warning "flag" "bad use of I flag" } */
   printf ("%IS", ls); /* { dg-warning "flag" "bad use of I flag" } */
   printf ("%Im"); /* { dg-warning "flag" "bad use of I flag" } */
+
+  /* As an extension, GCC does format checking on "unlocked"
+     i.e. thread unsafe versions of these functions.  */
+  fprintf_unlocked (stdout, "%d", i);
+  fprintf_unlocked (stdout, "%ld", i); /* { dg-warning "format" "fprintf_unlocked" } */
+  printf_unlocked ("%d", i);
+  printf_unlocked ("%ld", i); /* { dg-warning "format" "printf_unlocked" } */
 }
index a9653a1ea75580d9f2ad729290fde9297b3e9fd9..08d24cbf745963c12144b606e4147c9ba047a577 100644 (file)
@@ -16,6 +16,10 @@ foo (int i, char *s, size_t n, int *ip, va_list v0, va_list v1, va_list v2,
   fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
   printf ("%d", i);
   printf ("%ld", i); /* { dg-warning "format" "printf" } */
+  fprintf_unlocked (stdout, "%d", i);
+  fprintf_unlocked (stdout, "%ld", i); /* { dg-warning "format" "fprintf_unlocked" } */
+  printf_unlocked ("%d", i);
+  printf_unlocked ("%ld", i); /* { dg-warning "format" "printf_unlocked" } */
   sprintf (s, "%d", i);
   sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
   snprintf (s, n, "%d", i);
index b41ebd924976b2eded0442f97c1831d53f497b9a..230d1410136935650a8f53bc082b6ca664c46ce2 100644 (file)
@@ -67,6 +67,8 @@ extern FILE *stdout;
 
 extern int fprintf (FILE *restrict, const char *restrict, ...);
 extern int printf (const char *restrict, ...);
+extern int fprintf_unlocked (FILE *restrict, const char *restrict, ...);
+extern int printf_unlocked (const char *restrict, ...);
 extern int sprintf (char *restrict, const char *restrict, ...);
 extern int vfprintf (FILE *restrict, const char *restrict, va_list);
 extern int vprintf (const char *restrict, va_list);