aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-06-06 05:02:18 +0000
committerUlrich Drepper <drepper@redhat.com>2000-06-06 05:02:18 +0000
commit365afefc6b7054d9ca7585f6f17bdd1fe03b8cfd (patch)
treeca5117da5f6e954d45892b85ccde3889f542db58
parent85830c4c4688b30d3d76111aa9a26745c7b141d6 (diff)
downloadglibc-365afefc6b7054d9ca7585f6f17bdd1fe03b8cfd.tar
glibc-365afefc6b7054d9ca7585f6f17bdd1fe03b8cfd.tar.gz
glibc-365afefc6b7054d9ca7585f6f17bdd1fe03b8cfd.tar.bz2
glibc-365afefc6b7054d9ca7585f6f17bdd1fe03b8cfd.zip
Update.
* iconv/gconv_dl.c: Add __builtin_expect in many places. * iconv/skeleton.c: Add more __builtin_expect. * iconv/gconv_simple.c: Add __builtin_expect in many places.
-rw-r--r--ChangeLog4
-rw-r--r--iconv/gconv_dl.c3
-rw-r--r--iconv/gconv_simple.c56
-rw-r--r--iconv/skeleton.c15
4 files changed, 43 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index 764c9acdd6..99a3aab176 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2000-06-05 Ulrich Drepper <drepper@redhat.com>
+ * iconv/gconv_dl.c: Add __builtin_expect in many places.
+ * iconv/skeleton.c: Add more __builtin_expect.
+ * iconv/gconv_simple.c: Add __builtin_expect in many places.
+
* iconv/gconv.h (__GCONV_IS_LAST, __GCONV_IGNORE_ERRORS): Define.
(struct __gconv_step_data): Rename __is_last to __flags.
* iconv/gconv_close.c: Change all uses of __is_last.
diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c
index 710b440c58..d07f84e31b 100644
--- a/iconv/gconv_dl.c
+++ b/iconv/gconv_dl.c
@@ -91,7 +91,8 @@ __gconv_find_shlib (const char *name)
found->counter = -TRIES_BEFORE_UNLOAD - 1;
found->handle = NULL;
- if (__tsearch (found, &loaded, known_compare) == NULL)
+ if (__builtin_expect (__tsearch (found, &loaded, known_compare)
+ == NULL, 0))
{
/* Something went wrong while inserting the entry. */
free (found);
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c
index 7189ad3787..c2d873e21d 100644
--- a/iconv/gconv_simple.c
+++ b/iconv/gconv_simple.c
@@ -159,7 +159,7 @@ internal_ucs4_loop_single (const unsigned char **inptrp,
while (*inptrp < inend && cnt < 4)
state->__value.__wchb[cnt++] = *(*inptrp)++;
- if (cnt < 4)
+ if (__builtin_expect (cnt, 4) < 4)
{
/* Still not enough bytes. Store the ones in the input buffer. */
state->__count &= ~7;
@@ -224,7 +224,7 @@ ucs4_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
inval = *(uint32_t *) inptr;
#endif
- if (inval > 0x7fffffff)
+ if (__builtin_expect (inval, 0) > 0x7fffffff)
{
if (flags & __GCONV_IGNORE_ERRORS)
{
@@ -271,7 +271,7 @@ ucs4_internal_loop_unaligned (const unsigned char **inptrp,
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4, outptr += 4)
{
- if (inptr[0] > 0x80)
+ if (__builtin_expect (inptr[0], 0) > 0x80)
{
/* The value is too large. */
if (flags & __GCONV_IGNORE_ERRORS)
@@ -339,7 +339,7 @@ ucs4_internal_loop_single (const unsigned char **inptrp,
while (*inptrp < inend && cnt < 4)
state->__value.__wchb[cnt++] = *(*inptrp)++;
- if (cnt < 4)
+ if (__builtin_expect (cnt, 4) < 4)
{
/* Still not enough bytes. Store the ones in the input buffer. */
state->__count &= ~7;
@@ -348,7 +348,8 @@ ucs4_internal_loop_single (const unsigned char **inptrp,
return __GCONV_INCOMPLETE_INPUT;
}
- if (((unsigned char *) state->__value.__wchb)[0] > 0x80)
+ if (__builtin_expect (((unsigned char *) state->__value.__wchb)[0], 0)
+ > 0x80)
{
/* The value is too large. */
if (!(flags & __GCONV_IGNORE_ERRORS))
@@ -490,7 +491,7 @@ internal_ucs4le_loop_single (const unsigned char **inptrp,
while (*inptrp < inend && cnt < 4)
state->__value.__wchb[cnt++] = *(*inptrp)++;
- if (cnt < 4)
+ if (__builtin_expect (cnt, 4) < 4)
{
/* Still not enough bytes. Store the ones in the input buffer. */
state->__count &= ~7;
@@ -553,7 +554,7 @@ ucs4le_internal_loop (const unsigned char **inptrp, const unsigned char *inend,
inval = *(uint32_t *) inptr;
#endif
- if (inval > 0x7fffffff)
+ if (__builtin_expect (inval, 0) > 0x7fffffff)
{
if (flags & __GCONV_IGNORE_ERRORS)
{
@@ -598,7 +599,7 @@ ucs4le_internal_loop_unaligned (const unsigned char **inptrp,
for (cnt = 0; cnt < n_convert; ++cnt, inptr += 4)
{
- if (inptr[3] > 0x80)
+ if (__builtin_expect (inptr[3], 0) > 0x80)
{
/* The value is too large. */
if (flags & __GCONV_IGNORE_ERRORS)
@@ -656,7 +657,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
while (*inptrp < inend && cnt < 4)
state->__value.__wchb[cnt++] = *(*inptrp)++;
- if (cnt < 4)
+ if (__builtin_expect (cnt, 4) < 4)
{
/* Still not enough bytes. Store the ones in the input buffer. */
state->__count &= ~7;
@@ -665,7 +666,8 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
return __GCONV_INCOMPLETE_INPUT;
}
- if (((unsigned char *) state->__value.__wchb)[3] > 0x80)
+ if (__builtin_expect (((unsigned char *) state->__value.__wchb)[3], 0)
+ > 0x80)
{
/* The value is too large. */
if (!(flags & __GCONV_IGNORE_ERRORS))
@@ -713,7 +715,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- if (*inptr > '\x7f') \
+ if (__builtin_expect (*inptr, 0) > '\x7f') \
{ \
if (! ignore_errors_p ()) \
{ \
@@ -750,7 +752,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- if (*((uint32_t *) inptr) > 0x7f) \
+ if (__builtin_expect (*((uint32_t *) inptr), 0) > 0x7f) \
{ \
if (! ignore_errors_p ()) \
{ \
@@ -806,7 +808,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
if ((wc & encoding_mask[step - 2]) == 0) \
break; \
\
- if (outptr + step > outend) \
+ if (__builtin_expect (outptr + step > outend, 0)) \
{ \
/* Too long. */ \
result = __GCONV_FULL_OUTPUT; \
@@ -873,25 +875,25 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
cnt = 2; \
ch &= 0x1f; \
} \
- else if ((ch & 0xf0) == 0xe0) \
+ else if (__builtin_expect (ch & 0xf0, 0xf0) == 0xe0) \
{ \
/* We expect three bytes. */ \
cnt = 3; \
ch &= 0x0f; \
} \
- else if ((ch & 0xf8) == 0xf0) \
+ else if (__builtin_expect (ch & 0xf8, 0xf8) == 0xf0) \
{ \
/* We expect four bytes. */ \
cnt = 4; \
ch &= 0x07; \
} \
- else if ((ch & 0xfc) == 0xf8) \
+ else if (__builtin_expect (ch & 0xfc, 0xf8) == 0xf8) \
{ \
/* We expect five bytes. */ \
cnt = 5; \
ch &= 0x03; \
} \
- else if ((ch & 0xfe) == 0xfc) \
+ else if (__builtin_expect (ch & 0xfe, 0xfc) == 0xfc) \
{ \
/* We expect six bytes. */ \
cnt = 6; \
@@ -921,7 +923,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
continue; \
} \
\
- if (NEED_LENGTH_TEST && inptr + cnt > inend) \
+ if (NEED_LENGTH_TEST && __builtin_expect (inptr + cnt > inend, 0)) \
{ \
/* We don't have enough input. But before we report that check \
that all the bytes are correct. */ \
@@ -929,7 +931,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
if ((inptr[i] & 0xc0) != 0x80) \
break; \
\
- if (inptr + i == inend) \
+ if (__builtin_expect (inptr + i == inend, 1)) \
{ \
result = __GCONV_INCOMPLETE_INPUT; \
break; \
@@ -1004,19 +1006,19 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
cnt = 2; \
ch &= 0x1f; \
} \
- else if ((ch & 0xf0) == 0xe0) \
+ else if (__builtin_expect (ch & 0xf0, 0xe0) == 0xe0) \
{ \
/* We expect three bytes. */ \
cnt = 3; \
ch &= 0x0f; \
} \
- else if ((ch & 0xf8) == 0xf0) \
+ else if (__builtin_expect (ch & 0xf8, 0xf8) == 0xf0) \
{ \
/* We expect four bytes. */ \
cnt = 4; \
ch &= 0x07; \
} \
- else if ((ch & 0xfc) == 0xf8) \
+ else if (__builtin_expect (ch & 0xfc, 0xfc) == 0xf8) \
{ \
/* We expect five bytes. */ \
cnt = 5; \
@@ -1056,17 +1058,17 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
bytebuf[0] = 0xc0; \
ntotal = 2; \
} \
- else if (state->__value.__wch <= 0xffff) \
+ else if (__builtin_expect (state->__value.__wch, 0) <= 0xffff) \
{ \
bytebuf[0] = 0xe0; \
ntotal = 3; \
} \
- else if (state->__value.__wch <= 0x1fffff) \
+ else if (__builtin_expect (state->__value.__wch, 0) <= 0x1fffff) \
{ \
bytebuf[0] = 0xf0; \
ntotal = 4; \
} \
- else if (state->__value.__wch <= 0x3ffffff) \
+ else if (__builtin_expect (state->__value.__wch, 0) <= 0x3ffffff) \
{ \
bytebuf[0] = 0xf8; \
ntotal = 5; \
@@ -1128,7 +1130,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- if (*((uint32_t *) inptr) >= 0x10000) \
+ if (__builtin_expect (*((uint32_t *) inptr), 0) >= 0x10000) \
{ \
if (! ignore_errors_p ()) \
{ \
@@ -1184,7 +1186,7 @@ ucs4le_internal_loop_single (const unsigned char **inptrp,
#define BODY \
{ \
uint32_t val = *((uint32_t *) inptr); \
- if (val >= 0x10000) \
+ if (__builtin_expect (val, 0) >= 0x10000) \
{ \
if (! ignore_errors_p ()) \
{ \
diff --git a/iconv/skeleton.c b/iconv/skeleton.c
index 6069104f52..bf4e11f37a 100644
--- a/iconv/skeleton.c
+++ b/iconv/skeleton.c
@@ -221,7 +221,7 @@ gconv_init (struct __gconv_step *step)
step->__min_needed_to = MIN_NEEDED_TO;
step->__max_needed_to = MAX_NEEDED_TO;
}
- else if (strcmp (step->__to_name, CHARSET_NAME) == 0)
+ else if (__builtin_expect (strcmp (step->__to_name, CHARSET_NAME), 0) == 0)
{
step->__data = &to_object;
@@ -348,7 +348,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
EXTRA_LOOP_ARGS);
# endif
- if (status != __GCONV_OK)
+ if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK)
return status;
}
#endif
@@ -382,7 +382,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
SAVE_RESET_STATE (1);
#endif
- if (!unaligned)
+ if (__builtin_expect (!unaligned, 1))
{
if (FROM_DIRECTION)
/* Run the conversion loop. */
@@ -422,7 +422,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
/* If this is the last step leave the loop, there is nothing
we can do. */
- if (data->__flags & __GCONV_IS_LAST)
+ if (__builtin_expect (data->__flags & __GCONV_IS_LAST, 0))
{
/* Store information about how many bytes are available. */
data->__outbuf = outbuf;
@@ -434,7 +434,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
}
/* Write out all output which was produced. */
- if (outbuf > outstart)
+ if (__builtin_expect (outbuf > outstart, 1))
{
const unsigned char *outerr = data->__outbuf;
int result;
@@ -490,7 +490,7 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
/* If we haven't consumed a single byte decrement
the invocation counter. */
- if (outbuf == outstart)
+ if (__builtin_expect (outbuf == outstart, 0))
--data->__invocation_counter;
#endif /* reset input buffer */
}
@@ -516,7 +516,8 @@ FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
#if MAX_NEEDED_FROM > 1 || MAX_NEEDED_TO > 1
if (((MAX_NEEDED_FROM > 1 && FROM_DIRECTION)
|| (MAX_NEEDED_TO > 1 && !FROM_DIRECTION))
- && consume_incomplete && status == __GCONV_INCOMPLETE_INPUT)
+ && __builtin_expect (consume_incomplete, 0)
+ && status == __GCONV_INCOMPLETE_INPUT)
{
# ifdef STORE_REST
mbstate_t *state = data->__statep;