You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

320 lines
12 KiB

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