aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iconvdata/iso646.c6
-rw-r--r--iconvdata/iso8859-1.c2
-rw-r--r--iconvdata/iso_6937-2.c24
-rw-r--r--iconvdata/iso_6937.c24
-rw-r--r--iconvdata/johab.c52
5 files changed, 53 insertions, 55 deletions
diff --git a/iconvdata/iso646.c b/iconvdata/iso646.c
index ba0addc..ea36ebc 100644
--- a/iconvdata/iso646.c
+++ b/iconvdata/iso646.c
@@ -145,7 +145,7 @@ gconv_init (struct __gconv_step *step)
}
result = __GCONV_NOCONV;
- if (dir != illegal_dir)
+ if (__builtin_expect (dir, from_iso646) != illegal_dir)
{
new_data = (struct iso646_data *) malloc (sizeof (struct iso646_data));
@@ -404,7 +404,7 @@ gconv_end (struct __gconv_step *data)
\
/* Hopefully gcc can recognize that the following `if' is only true \
when we reach the default case in the `switch' statement. */ \
- if (failure == __GCONV_ILLEGAL_INPUT) \
+ if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
{ \
if (! ignore_errors_p ()) \
{ \
@@ -881,7 +881,7 @@ gconv_end (struct __gconv_step *data)
break; \
} \
\
- if (failure == __GCONV_ILLEGAL_INPUT) \
+ if (__builtin_expect (failure, __GCONV_OK) == __GCONV_ILLEGAL_INPUT) \
{ \
if (! ignore_errors_p ()) \
{ \
diff --git a/iconvdata/iso8859-1.c b/iconvdata/iso8859-1.c
index 4949991..f40da07 100644
--- a/iconvdata/iso8859-1.c
+++ b/iconvdata/iso8859-1.c
@@ -45,7 +45,7 @@
#define BODY \
{ \
uint32_t ch = *((uint32_t *) inptr); \
- if (ch > 0xff) \
+ if (__builtin_expect (ch, 0) > 0xff) \
{ \
/* We have an illegal character. */ \
if (! ignore_errors_p ()) \
diff --git a/iconvdata/iso_6937-2.c b/iconvdata/iso_6937-2.c
index f58ebe4..a3c8be6 100644
--- a/iconvdata/iso_6937-2.c
+++ b/iconvdata/iso_6937-2.c
@@ -385,8 +385,8 @@ static const char from_ucs4[][2] =
#define TO_LOOP to_iso6937_2
#define DEFINE_INIT 1
#define DEFINE_FINI 1
-#define MIN_NEEDED_FROM 1
-#define MAX_NEEDED_FROM 2
+#define MIN_NEEDED_FROM 1
+#define MAX_NEEDED_FROM 2
#define MIN_NEEDED_TO 4
@@ -399,13 +399,13 @@ static const char from_ucs4[][2] =
{ \
uint32_t ch = *inptr; \
\
- if (ch >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch, 0) >= 0xc1 && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
int ch2; \
\
- if (inptr + 1 >= inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 1 >= inend, 0)) \
{ \
/* The second character is not available. Store the \
intermediate result. */ \
@@ -415,7 +415,8 @@ static const char from_ucs4[][2] =
\
ch2 = inptr[1]; \
\
- if (ch2 < 0x20 || ch2 >= 0x80) \
+ if (__builtin_expect (ch2, 0) < 0x20 \
+ || __builtin_expect (ch2, 0) >= 0x80) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -432,7 +433,7 @@ static const char from_ucs4[][2] =
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\
- if (ch == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
/* Illegal character. */ \
if (! ignore_errors_p ()) \
@@ -453,7 +454,7 @@ static const char from_ucs4[][2] =
{ \
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 ()) \
@@ -487,7 +488,8 @@ static const char from_ucs4[][2] =
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])) \
{ \
int fail = 0; \
switch (ch) \
@@ -564,7 +566,7 @@ static const char from_ucs4[][2] =
fail = 1; \
} \
\
- if (fail) \
+ if (__builtin_expect (fail, 0)) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
@@ -579,7 +581,7 @@ static const char from_ucs4[][2] =
continue; \
} \
} \
- else if (from_ucs4[ch][0] == '\0' && ch != 0) \
+ else if (__builtin_expect (from_ucs4[ch][0], '\1') == '\0' && ch != 0) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
@@ -599,7 +601,7 @@ static const char from_ucs4[][2] =
/* 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; \
diff --git a/iconvdata/iso_6937.c b/iconvdata/iso_6937.c
index f6581cf..391adf9 100644
--- a/iconvdata/iso_6937.c
+++ b/iconvdata/iso_6937.c
@@ -377,8 +377,8 @@ static const char from_ucs4[][2] =
#define TO_LOOP to_iso6937
#define DEFINE_INIT 1
#define DEFINE_FINI 1
-#define MIN_NEEDED_FROM 1
-#define MAX_NEEDED_FROM 2
+#define MIN_NEEDED_FROM 1
+#define MAX_NEEDED_FROM 2
#define MIN_NEEDED_TO 4
@@ -391,13 +391,13 @@ static const char from_ucs4[][2] =
{ \
uint32_t ch = *inptr; \
\
- if (ch >= 0xc1 && ch <= 0xcf) \
+ if (__builtin_expect (ch, 0) >= 0xc1 && ch <= 0xcf) \
{ \
/* Composed character. First test whether the next character \
is also available. */ \
int ch2; \
\
- if (inptr + 1 >= inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + 1 >= inend, 0)) \
{ \
/* The second character is not available. Store the \
intermediate result. */ \
@@ -407,7 +407,8 @@ static const char from_ucs4[][2] =
\
ch2 = inptr[1]; \
\
- if (ch2 < 0x20 || ch2 >= 0x80) \
+ if (__builtin_expect (ch2, 0) < 0x20 \
+ || __builtin_expect (ch2, 0) >= 0x80) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -424,7 +425,7 @@ static const char from_ucs4[][2] =
\
ch = to_ucs4_comb[ch - 0xc1][ch2 - 0x20]; \
\
- if (ch == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
/* Illegal character. */ \
if (! ignore_errors_p ()) \
@@ -445,7 +446,7 @@ static const char from_ucs4[][2] =
{ \
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 ()) \
@@ -479,7 +480,8 @@ static const char from_ucs4[][2] =
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])) \
{ \
int fail = 0; \
switch (ch) \
@@ -535,7 +537,7 @@ static const char from_ucs4[][2] =
fail = 1; \
} \
\
- if (fail) \
+ if (__builtin_expect (fail, 0)) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
@@ -550,7 +552,7 @@ static const char from_ucs4[][2] =
continue; \
} \
} \
- else if (from_ucs4[ch][0] == '\0' && ch != 0) \
+ else if (__builtin_expect (from_ucs4[ch][0], '\1') == '\0' && ch != 0) \
{ \
/* Illegal characters. */ \
if (! ignore_errors_p ()) \
@@ -570,7 +572,7 @@ static const char from_ucs4[][2] =
/* 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; \
diff --git a/iconvdata/johab.c b/iconvdata/johab.c
index ca4d053..fccfbab 100644
--- a/iconvdata/johab.c
+++ b/iconvdata/johab.c
@@ -179,8 +179,10 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
0xd831-0xd87e and 0xd891-0xd8fe are user-defined area */ \
else \
{ \
- if (ch > 0xf9 || ch == 0xdf || (ch > 0x7e && ch < 0x84) \
- || (ch > 0xd3 && ch < 0xd9)) \
+ if (__builtin_expect (ch, 0) > 0xf9 \
+ || __builtin_expect (ch, 0) == 0xdf \
+ || (__builtin_expect (ch, 0) > 0x7e && ch < 0x84) \
+ || (__builtin_expect (ch, 0) > 0xd3 && ch < 0xd9)) \
{ \
/* These are illegal. */ \
if (! ignore_errors_p ()) \
@@ -201,7 +203,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
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. */ \
@@ -211,7 +213,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
\
ch2 = inptr[1]; \
idx = ch * 256 + ch2; \
- if (ch <= 0xd3) \
+ if (__builtin_expect (ch, 0) <= 0xd3) \
{ \
/* Hangul */ \
uint_fast32_t i, m, f; \
@@ -220,7 +222,9 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
m = mid[(idx & 0x03e0) >> 5]; \
f = final[idx & 0x001f]; \
\
- if (i == -1 || m == -1 || f == -1) \
+ if (__builtin_expect (i, 0) == -1 \
+ || __builtin_expect (m, 0) == -1 \
+ || __builtin_expect (f, 0) == -1) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -240,7 +244,8 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
ch = init_to_ucs[i - 1]; \
else if (i == 0 && m > 0 && f == 0) \
ch = 0x314e + m; /* 0x314f + m - 1 */ \
- else if (i == 0 && m == 0 && f > 0) \
+ else if (__builtin_expect (i | m, 0) == 0 \
+ && __builtin_expect (f, 1) > 0) \
ch = final_to_ucs[f - 1]; /* round trip?? */ \
else \
{ \
@@ -259,7 +264,11 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
} \
else \
{ \
- if (ch2 < 0x31 || (ch2 > 0x7e && ch2 < 0x91) || ch2 == 0xff) \
+ if (__builtin_expect (ch2, 0x31) < 0x31 \
+ || (__builtin_expect (ch2, 0x7e) > 0x7e && ch2 < 0x91) \
+ || __builtin_expect (ch2, 0) == 0xff \
+ || (__builtin_expect (ch, 0) == 0xda \
+ && ch2 > 0xa0 && ch2 < 0xd4)) \
{ \
/* This is illegal. */ \
if (! ignore_errors_p ()) \
@@ -273,21 +282,6 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
++*converted; \
continue; \
} \
- else if (ch == 0xda && ch2 > 0xa0 && ch2 < 0xd4) \
- { \
- /* This is illegal. Modern Hangul Jaso is defined \
- elsewhere in Johab */ \
- if (! ignore_errors_p ()) \
- { \
- /* This is an illegal character. */ \
- result = __GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- ++inptr; \
- ++*converted; \
- continue; \
- } \
else \
{ \
ch = johab_sym_hanja_to_ucs (idx, ch, ch2); \
@@ -304,7 +298,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
} \
} \
\
- if (ch == 0) \
+ if (__builtin_expect (ch, 1) == 0) \
{ \
/* This is an illegal character. */ \
if (! ignore_errors_p ()) \
@@ -356,7 +350,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
{ \
if (ch >= 0xac00 && ch <= 0xd7a3) \
{ \
- if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr + 2 > outend, 0))\
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -377,7 +371,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
{ \
ch = jamo_from_ucs_table[ch - 0x3131]; \
\
- if (NEED_LENGTH_TEST && outptr + 2 > outend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (outptr + 2 > outend, 0))\
{ \
result = __GCONV_FULL_OUTPUT; \
break; \
@@ -395,12 +389,12 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
written = ucs4_to_ksc5601_hanja (ch, outptr, \
(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 ()) \
{ \
@@ -432,12 +426,12 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
written = ucs4_to_ksc5601_sym (ch, outptr, \
(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, 1) == __UNKNOWN_10646_CHAR) \
{ \
if (! ignore_errors_p ()) \
{ \