|
|
ce426f |
From 6806b6f3b4870204737e5d465bab2fdbc1c15de0 Mon Sep 17 00:00:00 2001
|
|
|
ce426f |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
ce426f |
Date: Mon, 7 Nov 2016 16:03:46 +0100
|
|
|
ce426f |
Subject: [PATCH 06/17] Use glibc_likely instead __builtin_expect.
|
|
|
ce426f |
|
|
|
ce426f |
Upstream commit a1ffb40e32741f992c743e7b16c061fefa3747ac
|
|
|
ce426f |
|
|
|
ce426f |
This part is a prerequirement for the s390 iconv patches.
|
|
|
ce426f |
---
|
|
|
ce426f |
sysdeps/s390/s390-64/utf16-utf32-z9.c | 10 +++++-----
|
|
|
ce426f |
sysdeps/s390/s390-64/utf8-utf16-z9.c | 26 +++++++++++++-------------
|
|
|
ce426f |
sysdeps/s390/s390-64/utf8-utf32-z9.c | 32 ++++++++++++++++----------------
|
|
|
ce426f |
3 files changed, 34 insertions(+), 34 deletions(-)
|
|
|
ce426f |
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-64/utf16-utf32-z9.c b/sysdeps/s390/s390-64/utf16-utf32-z9.c
|
|
|
ce426f |
index 9eaa1a5..94a1a33 100644
|
|
|
ce426f |
--- a/sysdeps/s390/s390-64/utf16-utf32-z9.c
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-64/utf16-utf32-z9.c
|
|
|
ce426f |
@@ -54,7 +54,7 @@
|
|
|
ce426f |
if (dir == to_utf16) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Emit the UTF-16 Byte Order Mark. */ \
|
|
|
ce426f |
- if (__builtin_expect (outbuf + 2 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outbuf + 2 > outend)) \
|
|
|
ce426f |
return __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
\
|
|
|
ce426f |
put16u (outbuf, BOM_UTF16); \
|
|
|
ce426f |
@@ -63,7 +63,7 @@
|
|
|
ce426f |
else \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Emit the UTF-32 Byte Order Mark. */ \
|
|
|
ce426f |
- if (__builtin_expect (outbuf + 4 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outbuf + 4 > outend)) \
|
|
|
ce426f |
return __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
\
|
|
|
ce426f |
put32u (outbuf, BOM_UTF32); \
|
|
|
ce426f |
@@ -236,13 +236,13 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* An isolated low-surrogate was found. This has to be \
|
|
|
ce426f |
considered ill-formed. */ \
|
|
|
ce426f |
- if (__builtin_expect (u1 >= 0xdc00, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (u1 >= 0xdc00)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
STANDARD_FROM_LOOP_ERR_HANDLER (2); \
|
|
|
ce426f |
} \
|
|
|
ce426f |
/* It's a surrogate character. At least the first word says \
|
|
|
ce426f |
it is. */ \
|
|
|
ce426f |
- if (__builtin_expect (inptr + 4 > inend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (inptr + 4 > inend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We don't have enough input for another complete input \
|
|
|
ce426f |
character. */ \
|
|
|
ce426f |
@@ -306,7 +306,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
uint16_t out; \
|
|
|
ce426f |
\
|
|
|
ce426f |
/* Generate a surrogate character. */ \
|
|
|
ce426f |
- if (__builtin_expect (outptr + 4 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outptr + 4 > outend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Overflow in the output buffer. */ \
|
|
|
ce426f |
result = __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-64/utf8-utf16-z9.c b/sysdeps/s390/s390-64/utf8-utf16-z9.c
|
|
|
ce426f |
index 9f59177..8e0515c 100644
|
|
|
ce426f |
--- a/sysdeps/s390/s390-64/utf8-utf16-z9.c
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-64/utf8-utf16-z9.c
|
|
|
ce426f |
@@ -50,7 +50,7 @@
|
|
|
ce426f |
&& data->__invocation_counter == 0) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Emit the UTF-16 Byte Order Mark. */ \
|
|
|
ce426f |
- if (__builtin_expect (outbuf + 2 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outbuf + 2 > outend)) \
|
|
|
ce426f |
return __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
\
|
|
|
ce426f |
put16u (outbuf, BOM_UTF16); \
|
|
|
ce426f |
@@ -197,7 +197,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
if ((inptr[i] & 0xc0) != 0x80) \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (inptr + i == inend, 1)) \
|
|
|
ce426f |
+ if (__glibc_likely (inptr + i == inend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
result = __GCONV_INCOMPLETE_INPUT; \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
@@ -210,7 +210,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
/* Next input byte. */ \
|
|
|
ce426f |
uint16_t ch = *inptr; \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (ch < 0x80, 1)) \
|
|
|
ce426f |
+ if (__glibc_likely (ch < 0x80)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* One byte sequence. */ \
|
|
|
ce426f |
++inptr; \
|
|
|
ce426f |
@@ -228,13 +228,13 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
cnt = 2; \
|
|
|
ce426f |
ch &= 0x1f; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect three bytes. */ \
|
|
|
ce426f |
cnt = 3; \
|
|
|
ce426f |
ch &= 0x0f; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect four bytes. */ \
|
|
|
ce426f |
cnt = 4; \
|
|
|
ce426f |
@@ -255,7 +255,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
STANDARD_FROM_LOOP_ERR_HANDLER (i); \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (inptr + cnt > inend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (inptr + cnt > inend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We don't have enough input. But before we report \
|
|
|
ce426f |
that check that all the bytes are correct. */ \
|
|
|
ce426f |
@@ -263,7 +263,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
if ((inptr[i] & 0xc0) != 0x80) \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (inptr + i == inend, 1)) \
|
|
|
ce426f |
+ if (__glibc_likely (inptr + i == inend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
result = __GCONV_INCOMPLETE_INPUT; \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
@@ -278,7 +278,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
low) are needed. */ \
|
|
|
ce426f |
uint16_t zabcd, high, low; \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (outptr + 4 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outptr + 4 > outend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Overflow in the output buffer. */ \
|
|
|
ce426f |
result = __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
@@ -368,7 +368,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
\
|
|
|
ce426f |
uint16_t c = get16 (inptr); \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (c <= 0x007f, 1)) \
|
|
|
ce426f |
+ if (__glibc_likely (c <= 0x007f)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Single byte UTF-8 char. */ \
|
|
|
ce426f |
*outptr = c & 0xff; \
|
|
|
ce426f |
@@ -378,7 +378,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Two byte UTF-8 char. */ \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (outptr + 2 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outptr + 2 > outend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Overflow in the output buffer. */ \
|
|
|
ce426f |
result = __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
@@ -397,7 +397,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Three byte UTF-8 char. */ \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (outptr + 3 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outptr + 3 > outend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Overflow in the output buffer. */ \
|
|
|
ce426f |
result = __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
@@ -419,14 +419,14 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
/* Four byte UTF-8 char. */ \
|
|
|
ce426f |
uint16_t low, uvwxy; \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (outptr + 4 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outptr + 4 > outend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Overflow in the output buffer. */ \
|
|
|
ce426f |
result = __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
inptr += 2; \
|
|
|
ce426f |
- if (__builtin_expect (inptr + 2 > inend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (inptr + 2 > inend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
result = __GCONV_INCOMPLETE_INPUT; \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
diff --git a/sysdeps/s390/s390-64/utf8-utf32-z9.c b/sysdeps/s390/s390-64/utf8-utf32-z9.c
|
|
|
ce426f |
index a807980..c657a38 100644
|
|
|
ce426f |
--- a/sysdeps/s390/s390-64/utf8-utf32-z9.c
|
|
|
ce426f |
+++ b/sysdeps/s390/s390-64/utf8-utf32-z9.c
|
|
|
ce426f |
@@ -52,7 +52,7 @@
|
|
|
ce426f |
&& data->__invocation_counter == 0) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Emit the Byte Order Mark. */ \
|
|
|
ce426f |
- if (__builtin_expect (outbuf + 4 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outbuf + 4 > outend)) \
|
|
|
ce426f |
return __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
\
|
|
|
ce426f |
put32u (outbuf, BOM); \
|
|
|
ce426f |
@@ -201,7 +201,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
if ((inptr[i] & 0xc0) != 0x80) \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (inptr + i == inend, 1)) \
|
|
|
ce426f |
+ if (__glibc_likely (inptr + i == inend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
result = __GCONV_INCOMPLETE_INPUT; \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
@@ -214,7 +214,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
/* Next input byte. */ \
|
|
|
ce426f |
uint32_t ch = *inptr; \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (ch < 0x80, 1)) \
|
|
|
ce426f |
+ if (__glibc_likely (ch < 0x80)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* One byte sequence. */ \
|
|
|
ce426f |
++inptr; \
|
|
|
ce426f |
@@ -232,25 +232,25 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
cnt = 2; \
|
|
|
ce426f |
ch &= 0x1f; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect three bytes. */ \
|
|
|
ce426f |
cnt = 3; \
|
|
|
ce426f |
ch &= 0x0f; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect four bytes. */ \
|
|
|
ce426f |
cnt = 4; \
|
|
|
ce426f |
ch &= 0x07; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xfc) == 0xf8, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xfc) == 0xf8)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect five bytes. */ \
|
|
|
ce426f |
cnt = 5; \
|
|
|
ce426f |
ch &= 0x03; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xfe) == 0xfc, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xfe) == 0xfc)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect six bytes. */ \
|
|
|
ce426f |
cnt = 6; \
|
|
|
ce426f |
@@ -271,7 +271,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
STANDARD_FROM_LOOP_ERR_HANDLER (i); \
|
|
|
ce426f |
} \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (inptr + cnt > inend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (inptr + cnt > inend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We don't have enough input. But before we report \
|
|
|
ce426f |
that check that all the bytes are correct. */ \
|
|
|
ce426f |
@@ -279,7 +279,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
if ((inptr[i] & 0xc0) != 0x80) \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (inptr + i == inend, 1)) \
|
|
|
ce426f |
+ if (__glibc_likely (inptr + i == inend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
result = __GCONV_INCOMPLETE_INPUT; \
|
|
|
ce426f |
break; \
|
|
|
ce426f |
@@ -338,19 +338,19 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
cnt = 2; \
|
|
|
ce426f |
ch &= 0x1f; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xf0) == 0xe0)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect three bytes. */ \
|
|
|
ce426f |
cnt = 3; \
|
|
|
ce426f |
ch &= 0x0f; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xf8) == 0xf0)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect four bytes. */ \
|
|
|
ce426f |
cnt = 4; \
|
|
|
ce426f |
ch &= 0x07; \
|
|
|
ce426f |
} \
|
|
|
ce426f |
- else if (__builtin_expect ((ch & 0xfc) == 0xf8, 1)) \
|
|
|
ce426f |
+ else if (__glibc_likely ((ch & 0xfc) == 0xf8)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* We expect five bytes. */ \
|
|
|
ce426f |
cnt = 5; \
|
|
|
ce426f |
@@ -431,7 +431,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
\
|
|
|
ce426f |
uint32_t wc = *((const uint32_t *) inptr); \
|
|
|
ce426f |
\
|
|
|
ce426f |
- if (__builtin_expect (wc <= 0x7f, 1)) \
|
|
|
ce426f |
+ if (__glibc_likely (wc <= 0x7f)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Single UTF-8 char. */ \
|
|
|
ce426f |
*outptr = (uint8_t)wc; \
|
|
|
ce426f |
@@ -440,7 +440,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
else if (wc <= 0x7ff) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Two UTF-8 chars. */ \
|
|
|
ce426f |
- if (__builtin_expect (outptr + 2 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outptr + 2 > outend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Overflow in the output buffer. */ \
|
|
|
ce426f |
result = __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
@@ -458,7 +458,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
else if (wc <= 0xffff) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Three UTF-8 chars. */ \
|
|
|
ce426f |
- if (__builtin_expect (outptr + 3 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outptr + 3 > outend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Overflow in the output buffer. */ \
|
|
|
ce426f |
result = __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
@@ -478,7 +478,7 @@ gconv_end (struct __gconv_step *data)
|
|
|
ce426f |
else if (wc <= 0x10ffff) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Four UTF-8 chars. */ \
|
|
|
ce426f |
- if (__builtin_expect (outptr + 4 > outend, 0)) \
|
|
|
ce426f |
+ if (__glibc_unlikely (outptr + 4 > outend)) \
|
|
|
ce426f |
{ \
|
|
|
ce426f |
/* Overflow in the output buffer. */ \
|
|
|
ce426f |
result = __GCONV_FULL_OUTPUT; \
|
|
|
ce426f |
--
|
|
|
ce426f |
1.8.3.1
|
|
|
ce426f |
|