about summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
authorOndřej Bílka <neleai@seznam.cz>2014-02-10 14:45:42 +0100
committerOndřej Bílka <neleai@seznam.cz>2014-02-10 15:07:12 +0100
commita1ffb40e32741f992c743e7b16c061fefa3747ac (patch)
tree246a29a87b26cfd5d07b17070f85eb3785018de9 /stdio-common
parent1448f3244714a9dabb5240ec18b094f100887d5c (diff)
downloadglibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.gz
glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.xz
glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.zip
Use glibc_likely instead __builtin_expect.
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/_i18n_number.h2
-rw-r--r--stdio-common/perror.c2
-rw-r--r--stdio-common/printf_fp.c8
-rw-r--r--stdio-common/tmpnam.c2
-rw-r--r--stdio-common/vfscanf.c74
5 files changed, 44 insertions, 44 deletions
diff --git a/stdio-common/_i18n_number.h b/stdio-common/_i18n_number.h
index 061c4d47f8..299c3e083f 100644
--- a/stdio-common/_i18n_number.h
+++ b/stdio-common/_i18n_number.h
@@ -42,7 +42,7 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end)
   wint_t wthousands = __towctrans (L',', map);
 
 #ifndef COMPILE_WPRINTF
-  if (__builtin_expect (map != NULL, 0))
+  if (__glibc_unlikely (map != NULL))
     {
       mbstate_t state;
       memset (&state, '\0', sizeof (state));
diff --git a/stdio-common/perror.c b/stdio-common/perror.c
index acd97d2f7d..4b470156a6 100644
--- a/stdio-common/perror.c
+++ b/stdio-common/perror.c
@@ -60,7 +60,7 @@ perror (const char *s)
       || (fd = __dup (fd)) == -1
       || (fp = fdopen (fd, "w+")) == NULL)
     {
-      if (__builtin_expect (fd != -1, 0))
+      if (__glibc_unlikely (fd != -1))
 	__close (fd);
 
       /* Use standard error as is.  */
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 7a3292cf97..9cd4b4b00c 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -1094,7 +1094,7 @@ ___printf_fp (FILE *fp,
     /* Write the exponent if it is needed.  */
     if (type != 'f')
       {
-	if (__builtin_expect (expsign != 0 && exponent == 4 && spec == 'g', 0))
+	if (__glibc_unlikely (expsign != 0 && exponent == 4 && spec == 'g'))
 	  {
 	    /* This is another special case.  The exponent of the number is
 	       really smaller than -4, which requires the 'e'/'E' format.
@@ -1180,7 +1180,7 @@ ___printf_fp (FILE *fp,
 
 	  size_t nbuffer = (2 + chars_needed * factor + decimal_len
 			    + ngroups * thousands_sep_len);
-	  if (__builtin_expect (buffer_malloced, 0))
+	  if (__glibc_unlikely (buffer_malloced))
 	    {
 	      buffer = (char *) malloc (nbuffer);
 	      if (buffer == NULL)
@@ -1208,7 +1208,7 @@ ___printf_fp (FILE *fp,
 	}
 
       tmpptr = buffer;
-      if (__builtin_expect (info->i18n, 0))
+      if (__glibc_unlikely (info->i18n))
 	{
 #ifdef COMPILE_WPRINTF
 	  wstartp = _i18n_number_rewrite (wstartp, wcp,
@@ -1228,7 +1228,7 @@ ___printf_fp (FILE *fp,
       PRINT (tmpptr, wstartp, wide ? wcp - wstartp : cp - tmpptr);
 
       /* Free the memory if necessary.  */
-      if (__builtin_expect (buffer_malloced, 0))
+      if (__glibc_unlikely (buffer_malloced))
 	{
 	  free (buffer);
 	  free (wbuffer);
diff --git a/stdio-common/tmpnam.c b/stdio-common/tmpnam.c
index 3d0386269e..d8cd50907f 100644
--- a/stdio-common/tmpnam.c
+++ b/stdio-common/tmpnam.c
@@ -38,7 +38,7 @@ tmpnam (char *s)
 			0))
     return NULL;
 
-  if (__builtin_expect (__gen_tempname (tmpbuf, 0, 0, __GT_NOCREATE), 0))
+  if (__glibc_unlikely (__gen_tempname (tmpbuf, 0, 0, __GT_NOCREATE)))
     return NULL;
 
   if (s == NULL)
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 2e1e91af78..e0d224530c 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -269,7 +269,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 #define ADDW(Ch)							    \
   do									    \
     {									    \
-      if (__builtin_expect (wpsize == wpmax, 0))			    \
+      if (__glibc_unlikely (wpsize == wpmax))				      \
 	{								    \
 	  CHAR_T *old = wp;						    \
 	  size_t newsize = (UCHAR_MAX + 1 > 2 * wpmax			    \
@@ -392,7 +392,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	      do
 		{
 		  c = inchar ();
-		  if (__builtin_expect (c == EOF, 0))
+		  if (__glibc_unlikely (c == EOF))
 		    input_error ();
 		  else if (c != (unsigned char) *f++)
 		    {
@@ -420,7 +420,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	  c = inchar ();
 
 	  /* Characters other than format specs must just match.  */
-	  if (__builtin_expect (c == EOF, 0))
+	  if (__glibc_unlikely (c == EOF))
 	    input_error ();
 
 	  /* We saw white space char as the last character in the format
@@ -428,12 +428,12 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	  if (skip_space)
 	    {
 	      while (ISSPACE (c))
-		if (__builtin_expect (inchar () == EOF, 0))
+		if (__glibc_unlikely (inchar () == EOF))
 		  input_error ();
 	      skip_space = 0;
 	    }
 
-	  if (__builtin_expect (c != fc, 0))
+	  if (__glibc_unlikely (c != fc))
 	    {
 	      ungetc (c, s);
 	      conv_error ();
@@ -581,7 +581,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	}
 
       /* End of the format string?  */
-      if (__builtin_expect (*f == L_('\0'), 0))
+      if (__glibc_unlikely (*f == L_('\0')))
 	conv_error ();
 
       /* Find the conversion specifier.  */
@@ -610,9 +610,9 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	{
 	case L_('%'):	/* Must match a literal '%'.  */
 	  c = inchar ();
-	  if (__builtin_expect (c == EOF, 0))
+	  if (__glibc_unlikely (c == EOF))
 	    input_error ();
-	  if (__builtin_expect (c != fc, 0))
+	  if (__glibc_unlikely (c != fc))
 	    {
 	      ungetc_not_eof (c, s);
 	      conv_error ();
@@ -710,7 +710,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 #endif
 
 	      c = inchar ();
-	      if (__builtin_expect (c == EOF, 0))
+	      if (__glibc_unlikely (c == EOF))
 		input_error ();
 
 #ifdef COMPILE_WSCANF
@@ -758,7 +758,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		    }
 
 		  n = __wcrtomb (!(flags & SUPPRESS) ? str : NULL, c, &state);
-		  if (__builtin_expect (n == (size_t) -1, 0))
+		  if (__glibc_unlikely (n == (size_t) -1))
 		    /* No valid wide character.  */
 		    input_error ();
 
@@ -836,7 +836,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	  STRING_ARG (wstr, wchar_t, (width > 1024 ? 1024 : width));
 
 	  c = inchar ();
-	  if (__builtin_expect (c == EOF, 0))
+	  if (__glibc_unlikely (c == EOF))
 	    input_error ();
 
 #ifdef COMPILE_WSCANF
@@ -946,14 +946,14 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		      {
 			/* Possibly correct character, just not enough
 			   input.  */
-			if (__builtin_expect (inchar () == EOF, 0))
+			if (__glibc_unlikely (inchar () == EOF))
 			  encode_error ();
 
 			buf[0] = c;
 			continue;
 		      }
 
-		    if (__builtin_expect (n != 1, 0))
+		    if (__glibc_unlikely (n != 1))
 		      encode_error ();
 
 		    /* We have a match.  */
@@ -991,7 +991,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	      STRING_ARG (str, char, 100);
 
 	      c = inchar ();
-	      if (__builtin_expect (c == EOF, 0))
+	      if (__glibc_unlikely (c == EOF))
 		input_error ();
 
 #ifdef COMPILE_WSCANF
@@ -1060,7 +1060,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 
 		    n = __wcrtomb (!(flags & SUPPRESS) ? str : NULL, c,
 				   &state);
-		    if (__builtin_expect (n == (size_t) -1, 0))
+		    if (__glibc_unlikely (n == (size_t) -1))
 		      encode_error ();
 
 		    assert (n <= MB_CUR_MAX);
@@ -1262,14 +1262,14 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 			{
 			  /* Possibly correct character, just not enough
 			     input.  */
-			  if (__builtin_expect (inchar () == EOF, 0))
+			  if (__glibc_unlikely (inchar () == EOF))
 			    encode_error ();
 
 			  buf[0] = c;
 			  continue;
 			}
 
-		      if (__builtin_expect (n != 1, 0))
+		      if (__glibc_unlikely (n != 1))
 			encode_error ();
 
 		      /* We have a match.  */
@@ -1368,7 +1368,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 
 	number:
 	  c = inchar ();
-	  if (__builtin_expect (c == EOF, 0))
+	  if (__glibc_unlikely (c == EOF))
 	    input_error ();
 
 	  /* Check for a sign.  */
@@ -1434,7 +1434,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 #endif
 
 	      /* Get the alternative digit forms if there are any.  */
-	      if (__builtin_expect (map != NULL, 0))
+	      if (__glibc_unlikely (map != NULL))
 		{
 		  /*  Adding new level for extra digits set in locale file.  */
 		  ++to_level;
@@ -1502,7 +1502,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		    {
 		      /* Get the string for the digits with value N.  */
 #ifdef COMPILE_WSCANF
-		      if (__builtin_expect (map != NULL, 0))
+		      if (__glibc_unlikely (map != NULL))
 			wcdigits[n] = wcdigits_extended[n];
 		      else
 			wcdigits[n] = (const wchar_t *)
@@ -1521,7 +1521,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		      const char *cmpp;
 		      int avail = width > 0 ? width : INT_MAX;
 
-		      if (__builtin_expect (map != NULL, 0))
+		      if (__glibc_unlikely (map != NULL))
 			mbdigits[n] = mbdigits_extended[n];
 		      else
 			mbdigits[n]
@@ -1795,7 +1795,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	      else
 		num.ul = __strtoul_internal (wp, &tw, base, flags & GROUP);
 	    }
-	  if (__builtin_expect (wp == tw, 0))
+	  if (__glibc_unlikely (wp == tw))
 	    conv_error ();
 
 	  if (!(flags & SUPPRESS))
@@ -1842,7 +1842,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	  c = inchar ();
 	  if (width > 0)
 	    --width;
-	  if (__builtin_expect (c == EOF, 0))
+	  if (__glibc_unlikely (c == EOF))
 	    input_error ();
 
 	  got_digit = got_dot = got_e = 0;
@@ -1851,7 +1851,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	  if (c == L_('-') || c == L_('+'))
 	    {
 	      negative = c == L_('-');
-	      if (__builtin_expect (width == 0 || inchar () == EOF, 0))
+	      if (__glibc_unlikely (width == 0 || inchar () == EOF))
 		/* EOF is only an input error before we read any chars.  */
 		conv_error ();
 	      if (width > 0)
@@ -2334,7 +2334,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		*ARG (float *) = negative ? -d : d;
 	    }
 
-	  if (__builtin_expect (tw == wp, 0))
+	  if (__glibc_unlikely (tw == wp))
 	    conv_error ();
 
 	  if (!(flags & SUPPRESS))
@@ -2374,7 +2374,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 
 	  while ((fc = *f++) != L'\0' && fc != L']');
 
-	  if (__builtin_expect (fc == L'\0', 0))
+	  if (__glibc_unlikely (fc == L'\0'))
 	    conv_error ();
 	  wchar_t *twend = (wchar_t *) f - 1;
 #else
@@ -2410,7 +2410,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	      /* Add the character to the flag map.  */
 	      wp[fc] = 1;
 
-	  if (__builtin_expect (fc == '\0', 0))
+	  if (__glibc_unlikely (fc == '\0'))
 	    conv_error();
 #endif
 
@@ -2418,7 +2418,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	    {
 	      size_t now = read_in;
 #ifdef COMPILE_WSCANF
-	      if (__builtin_expect (inchar () == WEOF, 0))
+	      if (__glibc_unlikely (inchar () == WEOF))
 		input_error ();
 
 	      do
@@ -2530,7 +2530,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	      size_t cnt = 0;
 	      mbstate_t cstate;
 
-	      if (__builtin_expect (inchar () == EOF, 0))
+	      if (__glibc_unlikely (inchar () == EOF))
 		input_error ();
 
 	      memset (&cstate, '\0', sizeof (cstate));
@@ -2613,13 +2613,13 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		}
 	      while (inchar () != EOF);
 
-	      if (__builtin_expect (cnt != 0, 0))
+	      if (__glibc_unlikely (cnt != 0))
 		/* We stopped in the middle of recognizing another
 		   character.  That's a problem.  */
 		encode_error ();
 #endif
 
-	      if (__builtin_expect (now == read_in, 0))
+	      if (__glibc_unlikely (now == read_in))
 		/* We haven't succesfully read any character.  */
 		conv_error ();
 
@@ -2645,7 +2645,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	    {
 	      size_t now = read_in;
 
-	      if (__builtin_expect (inchar () == EOF, 0))
+	      if (__glibc_unlikely (inchar () == EOF))
 		input_error ();
 
 #ifdef COMPILE_WSCANF
@@ -2754,7 +2754,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 		    }
 
 		  n = __wcrtomb (!(flags & SUPPRESS) ? str : NULL, c, &state);
-		  if (__builtin_expect (n == (size_t) -1, 0))
+		  if (__glibc_unlikely (n == (size_t) -1))
 		    encode_error ();
 
 		  assert (n <= MB_CUR_MAX);
@@ -2817,7 +2817,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	      while (--width > 0 && inchar () != EOF);
 #endif
 
-	      if (__builtin_expect (now == read_in, 0))
+	      if (__glibc_unlikely (now == read_in))
 		/* We haven't succesfully read any character.  */
 		conv_error ();
 
@@ -2911,9 +2911,9 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
   if (errp != NULL)
     *errp |= errval;
 
-  if (__builtin_expect (done == EOF, 0))
+  if (__glibc_unlikely (done == EOF))
     {
-      if (__builtin_expect (ptrs_to_free != NULL, 0))
+      if (__glibc_unlikely (ptrs_to_free != NULL))
 	{
 	  struct ptrs_to_free *p = ptrs_to_free;
 	  while (p != NULL)
@@ -2928,7 +2928,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 	    }
 	}
     }
-  else if (__builtin_expect (strptr != NULL, 0))
+  else if (__glibc_unlikely (strptr != NULL))
     {
       free (*strptr);
       *strptr = NULL;