{ \
uint32_t ch = *inptr; \
\
- if (ch == 0x5c) \
+ if (__builtin_expect (ch, 0) == 0x5c) \
{ \
ch = 0xa5; \
++inptr; \
} \
- else if (ch == 0x7e) \
+ else if (__builtin_expect (ch, 0) == 0x7e) \
{ \
ch = 0x203e; \
++inptr; \
ch = halfkana_to_ucs4[ch - 0xa1]; \
++inptr; \
} \
- else if (ch > 0xea || ch == 0xa0 || ch <= 0x80) \
+ else if (__builtin_expect (ch, 0) > 0xea \
+ || __builtin_expect (ch, 0) == 0xa0 \
+ || __builtin_expect (ch, 0x81) <= 0x80) \
{ \
/* These are illegal. */ \
if (! ignore_errors_p ()) \
uint32_t ch2; \
uint_fast32_t idx; \
\
- if (NEED_LENGTH_TEST && inptr + 1 >= inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 1 >= inend, 0)) \
{ \
/* The second character is not available. Store \
the intermediate result. */ \
\
ch2 = inptr[1]; \
idx = ch * 256 + ch2; \
- if (idx < 0x8140 || (idx > 0x84be && idx < 0x889f) \
- || (idx > 0x88fc && idx < 0x8940) \
- || (idx > 0x9ffc && idx < 0xe040) || idx > 0xeaa4) \
+ if (__builtin_expect (idx, 0x8140) < 0x8140 \
+ || (__builtin_expect (idx, 0x8140) > 0x84be && idx < 0x889f) \
+ || (__builtin_expect (idx, 0x8140) > 0x88fc && idx < 0x8940) \
+ || (__builtin_expect (idx, 0x8140) > 0x9ffc && idx < 0xe040) \
+ || __builtin_expect (idx, 0x8140) > 0xeaa4) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
inptr += 2; \
} \
\
- if (ch == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
cp = from_ucs4_greek[ch - 0x391]; \
else if (ch >= 0x2010 && ch <= 0x9fa0) \
cp = from_ucs4_cjk[ch - 0x02010]; \
- else if (ch >= 0xff01 && ch <= 0xffef) \
+ else if (__builtin_expect (ch, 0xff01) >= 0xff01 \
+ && __builtin_expect (ch, 0xff01) <= 0xffef) \
cp = from_ucs4_extra[ch - 0xff00]; \
else \
{ \
else \
cp = from_ucs4_lat1[ch]; \
\
- if (cp[0] == '\0' && ch != 0) \
+ if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0) \
{ \
/* Illegal character. */ \
if (! ignore_errors_p ()) \
/* Now test for a possible second byte and write this if possible. */\
if (cp[1] != '\0') \
{ \
- if (NEED_LENGTH_TEST && outptr >= outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr >= outend, 0)) \
{ \
/* The result does not fit into the buffer. */ \
result = __GCONV_FULL_OUTPUT; \
#define BODY \
{ \
uint32_t ch = *inptr; \
+ int increment = 1; \
\
- if (ch >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch, 0x20) >= 0xc1 && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
uint32_t ch2; \
\
- if (NEED_LENGTH_TEST && inptr + 1 >= inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 1 >= inend, 0)) \
{ \
/* The second character is not available. */ \
result = __GCONV_INCOMPLETE_INPUT; \
\
ch2 = inptr[1]; \
\
- if (ch2 < 0x20 || ch2 >= 0x80) \
+ if (__builtin_expect (ch2, 0x20) < 0x20 \
+ || __builtin_expect (ch2, 0x20) >= 0x80) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\
- inptr += 2; \
+ increment = 2; \
} \
else \
- { \
- ch = to_ucs4[ch]; \
- ++inptr; \
- } \
+ ch = to_ucs4[ch]; \
\
- if (ch == 0 && *inptr != '\0') \
+ if (__builtin_expect (ch, 1) == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
{ \
/* This is an illegal character. */ \
- --inptr; \
result = __GCONV_ILLEGAL_INPUT; \
break; \
} \
put32 (outptr, ch); \
outptr += 4; \
} \
+ inptr += increment; \
}
#include <iconv/loop.c>
uint32_t ch = get32 (inptr); \
const char *cp; \
\
- if (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
+ if (__builtin_expect (ch, 0) \
+ >= sizeof (from_ucs4) / sizeof (from_ucs4[0])) \
{ \
- if (ch == 0x2126) \
+ if (__builtin_expect (ch, 0) == 0x2126) \
cp = "\xe0"; \
- else if (ch == 0x2c7) \
+ else if (__builtin_expect (ch, 0) == 0x2c7) \
cp = "\xcf\x20"; \
- else if (ch < 0x2d8 || ch > 0x2dd || ch == 0x02dc) \
+ else if (__builtin_expect (ch, 0x2d8) < 0x2d8 \
+ || __builtin_expect (ch, 0x2d8) > 0x2dd \
+ || __builtin_expect (ch, 0x2d8) == 0x02dc) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
{ \
cp = from_ucs4[ch]; \
\
- if (cp[0] == '\0' && ch != 0) \
+ if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0) \
{ \
/* Illegal. */ \
if (! ignore_errors_p ()) \
/* Now test for a possible second byte and write this if possible. */ \
if (cp[1] != '\0') \
{ \
- if (NEED_LENGTH_TEST && outptr >= outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr >= outend, 0)) \
{ \
/* The result does not fit into the buffer. */ \
--outptr; \
*/ \
if (ch <= 0x7f) \
++inptr; \
- else if (ch <= 0x80 || ch >= 0xfe || ch == 0xc9) \
+ else if (__builtin_expect (ch, 0x81) <= 0x80 \
+ || __builtin_expect (ch, 0x81) >= 0xfe \
+ || __builtin_expect (ch, 0x81) == 0xc9) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
is also available. */ \
uint32_t ch2; \
\
- if (NEED_LENGTH_TEST && inptr + 1 >= inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 1 >= inend, 0)) \
{ \
/* The second character is not available. Store \
the intermediate result. */ \
\
if (ch < 0xa1 || ch2 < 0xa1) \
{ \
- if (ch > 0xc6 || ch2 <0x41 || (ch2 > 0x5a && ch2 < 0x61) \
- || (ch2 > 0x7a && ch2 < 0x81) || (ch == 0xc6 && ch2 > 0x52)) \
+ if (__builtin_expect (ch, 0xc5) > 0xc6 \
+ || __builtin_expect (ch2, 0x41) < 0x41 \
+ || (__builtin_expect (ch2, 0x41) > 0x5a && ch2 < 0x61) \
+ || (__builtin_expect (ch2, 0x41) > 0x7a && ch2 < 0x81) \
+ || (__builtin_expect (ch, 0xc5) == 0xc6 && ch2 > 0x52)) \
{ \
/* This is not legal. */ \
if (! ignore_errors_p ()) \
? (ch - 0x81) * 178 \
: 5696 + (ch - 0xa1) * 84)]; \
\
- if (ch == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
else \
{ \
ch = ksc5601_to_ucs4 (&inptr, 2, 0x80); \
- if (ch == __UNKNOWN_10646_CHAR) \
+ if (__builtin_expect (ch, 0) == __UNKNOWN_10646_CHAR) \
{ \
/* Illegal. */ \
if (! ignore_errors_p ()) \
{ \
const char *s = uhc_hangul_from_ucs[ch - 0xac00]; \
\
- if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr + 2 > outend, 0)) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
(NEED_LENGTH_TEST \
? outend - outptr : 2)); \
\
- if (NEED_LENGTH_TEST && written == 0) \
+ if (NEED_LENGTH_TEST && __builtin_expect (written, 1) == 0) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
} \
- if (written == __UNKNOWN_10646_CHAR) \
+ if (__builtin_expect (written, 0) == __UNKNOWN_10646_CHAR) \
{ \
if (! ignore_errors_p ()) \
{ \
(NEED_LENGTH_TEST \
? outend - outptr : 2)); \
\
- if (NEED_LENGTH_TEST && written == 0) \
+ if (NEED_LENGTH_TEST && __builtin_expect (written, 1) == 0) \
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
} \
- if (written == __UNKNOWN_10646_CHAR) \
+ if (__builtin_expect (written, 0) == __UNKNOWN_10646_CHAR) \
{ \
if (! ignore_errors_p ()) \
{ \
else if (!data->__internal_use && data->__invocation_counter == 0) \
{ \
/* Emit the Byte Order Mark. */ \
- if (outbuf + 2 > outend) \
+ if (__builtin_expect (outbuf + 2 > outend, 0)) \
return __GCONV_FULL_OUTPUT; \
\
put16u (outbuf, BOM); \
{ \
uint32_t c = get32 (inptr); \
\
- if (c >= 0x10000) \
+ if (__builtin_expect (c, 0) >= 0x10000) \
{ \
if (! ignore_errors_p ()) \
{ \
&& data->__invocation_counter == 0) \
{ \
/* Emit the Byte Order Mark. */ \
- if (outbuf + 2 > outend) \
+ if (__builtin_expect (outbuf + 2 > outend, 0)) \
return __GCONV_FULL_OUTPUT; \
\
put16u (outbuf, BOM); \
}
result = __GCONV_NOCONV;
- if (dir != illegal_dir)
+ if (__builtin_expect (dir, to_utf16) != illegal_dir)
{
new_data = (struct utf16_data *) malloc (sizeof (struct utf16_data));
\
if (swap) \
{ \
- if (c >= 0x10000) \
+ if (__builtin_expect (c, 0) >= 0x10000) \
{ \
- if (c >= 0x110000) \
+ if (__builtin_expect (c, 0) >= 0x110000) \
{ \
if (! ignore_errors_p ()) \
{ \
} \
\
/* Generate a surrogate character. */ \
- if (NEED_LENGTH_TEST && outptr + 4 > outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr + 4 > outend, 0))\
{ \
/* Overflow in the output buffer. */ \
result = __GCONV_FULL_OUTPUT; \
} \
else \
{ \
- if (c >= 0x10000) \
+ if (__builtin_expect (c, 0) >= 0x10000) \
{ \
- if (c >= 0x110000) \
+ if (__builtin_expect (c, 0) >= 0x110000) \
{ \
if (! ignore_errors_p ()) \
{ \
} \
\
/* Generate a surrogate character. */ \
- if (NEED_LENGTH_TEST && outptr + 4 > outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr + 4 > outend, 0))\
{ \
/* Overflow in the output buffer. */ \
result = __GCONV_FULL_OUTPUT; \
{ \
u1 = bswap_16 (u1); \
\
- if (u1 < 0xd800 || u1 > 0xdfff) \
+ if (__builtin_expect (u1, 0) < 0xd800 || u1 > 0xdfff) \
{ \
/* No surrogate. */ \
- put32 (outptr, u1); \
+ put32 (outptr, u1); \
inptr += 2; \
} \
else \
\
/* It's a surrogate character. At least the first word says \
it is. */ \
- if (NEED_LENGTH_TEST && inptr + 4 > inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 4 > inend, 0)) \
{ \
/* We don't have enough input for another complete input \
character. */ \
\
inptr += 2; \
u2 = bswap_16 (get16 (inptr)); \
- if (u2 < 0xdc00 || u2 >= 0xdfff) \
+ if (__builtin_expect (u2, 0xdc00) < 0xdc00 \
+ || __builtin_expect (u2, 0xdc00) >= 0xdfff) \
{ \
/* This is no valid second word for a surrogate. */ \
if (! ignore_errors_p ()) \
} \
else \
{ \
- if (u1 < 0xd800 || u1 > 0xdfff) \
+ if (__builtin_expect (u1, 0) < 0xd800 || u1 > 0xdfff) \
{ \
/* No surrogate. */ \
put32 (outptr, u1); \
\
/* It's a surrogate character. At least the first word says \
it is. */ \
- if (NEED_LENGTH_TEST && inptr + 4 > inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 4 > inend, 0)) \
{ \
/* We don't have enough input for another complete input \
character. */ \
\
inptr += 2; \
u2 = get16 (inptr); \
- if (u2 < 0xdc00 || u2 >= 0xdfff) \
+ if (__builtin_expect (u2, 0xdc00) < 0xdc00 \
+ || __builtin_expect (u2, 0xdc00) >= 0xdfff) \
{ \
/* This is no valid second word for a surrogate. */ \
if (! ignore_errors_p ()) \