diff options
author | Ondřej Bílka <neleai@seznam.cz> | 2014-02-10 14:45:42 +0100 |
---|---|---|
committer | Ondřej Bílka <neleai@seznam.cz> | 2014-02-10 15:07:12 +0100 |
commit | a1ffb40e32741f992c743e7b16c061fefa3747ac (patch) | |
tree | 246a29a87b26cfd5d07b17070f85eb3785018de9 /time | |
parent | 1448f3244714a9dabb5240ec18b094f100887d5c (diff) | |
download | glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.zip glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.gz glibc-a1ffb40e32741f992c743e7b16c061fefa3747ac.tar.bz2 |
Use glibc_likely instead __builtin_expect.
Diffstat (limited to 'time')
-rw-r--r-- | time/asctime.c | 2 | ||||
-rw-r--r-- | time/tzfile.c | 36 | ||||
-rw-r--r-- | time/tzset.c | 12 |
3 files changed, 25 insertions, 25 deletions
diff --git a/time/asctime.c b/time/asctime.c index dfbafbf..073cf84 100644 --- a/time/asctime.c +++ b/time/asctime.c @@ -46,7 +46,7 @@ asctime_internal (const struct tm *tp, char *buf, size_t buflen) this would mean the output needs more space. This would not be a problem if the 'asctime_r' interface would be defined sanely and a buffer size would be passed. */ - if (__builtin_expect (tp->tm_year > INT_MAX - 1900, 0)) + if (__glibc_unlikely (tp->tm_year > INT_MAX - 1900)) { eoverflow: __set_errno (EOVERFLOW); diff --git a/time/tzfile.c b/time/tzfile.c index deef58e..52f0994 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -232,7 +232,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) > (SIZE_MAX - total_size) / sizeof (struct ttinfo), 0)) goto lose; total_size += num_types * sizeof (struct ttinfo); - if (__builtin_expect (chars > SIZE_MAX - total_size, 0)) + if (__glibc_unlikely (chars > SIZE_MAX - total_size)) goto lose; total_size += chars; if (__builtin_expect (__alignof__ (struct leap) - 1 @@ -261,16 +261,16 @@ __tzfile_read (const char *file, size_t extra, char **extrap) || tzspec_len < num_leaps * 12, 0)) goto lose; tzspec_len -= num_leaps * 12; - if (__builtin_expect (tzspec_len < num_isstd, 0)) + if (__glibc_unlikely (tzspec_len < num_isstd)) goto lose; tzspec_len -= num_isstd; - if (__builtin_expect (tzspec_len == 0 || tzspec_len - 1 < num_isgmt, 0)) + if (__glibc_unlikely (tzspec_len == 0 || tzspec_len - 1 < num_isgmt)) goto lose; tzspec_len -= num_isgmt + 1; - if (__builtin_expect (SIZE_MAX - total_size < tzspec_len, 0)) + if (__glibc_unlikely (SIZE_MAX - total_size < tzspec_len)) goto lose; } - if (__builtin_expect (SIZE_MAX - total_size - tzspec_len < extra, 0)) + if (__glibc_unlikely (SIZE_MAX - total_size - tzspec_len < extra)) goto lose; /* Allocate enough memory including the extra block requested by the @@ -310,7 +310,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) /* Check for bogus indices in the data file, so we can hereafter safely use type_idxs[T] as indices into `types' and never crash. */ for (i = 0; i < num_transitions; ++i) - if (__builtin_expect (type_idxs[i] >= num_types, 0)) + if (__glibc_unlikely (type_idxs[i] >= num_types)) goto lose; if ((BYTE_ORDER != BIG_ENDIAN && (sizeof (time_t) == 4 || trans_width == 4)) @@ -341,18 +341,18 @@ __tzfile_read (const char *file, size_t extra, char **extrap) 0)) goto lose; c = getc_unlocked (f); - if (__builtin_expect ((unsigned int) c > 1u, 0)) + if (__glibc_unlikely ((unsigned int) c > 1u)) goto lose; types[i].isdst = c; c = getc_unlocked (f); - if (__builtin_expect ((size_t) c > chars, 0)) + if (__glibc_unlikely ((size_t) c > chars)) /* Bogus index in data file. */ goto lose; types[i].idx = c; types[i].offset = (long int) decode (x); } - if (__builtin_expect (fread_unlocked (zone_names, 1, chars, f) != chars, 0)) + if (__glibc_unlikely (fread_unlocked (zone_names, 1, chars, f) != chars)) goto lose; for (i = 0; i < num_leaps; ++i) @@ -366,7 +366,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) else leaps[i].transition = (time_t) decode64 (x); - if (__builtin_expect (fread_unlocked (x, 1, 4, f) != 4, 0)) + if (__glibc_unlikely (fread_unlocked (x, 1, 4, f) != 4)) goto lose; leaps[i].change = (long int) decode (x); } @@ -374,7 +374,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) for (i = 0; i < num_isstd; ++i) { int c = getc_unlocked (f); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) goto lose; types[i].isstd = c != 0; } @@ -384,7 +384,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) for (i = 0; i < num_isgmt; ++i) { int c = getc_unlocked (f); - if (__builtin_expect (c == EOF, 0)) + if (__glibc_unlikely (c == EOF)) goto lose; types[i].isgmt = c != 0; } @@ -627,7 +627,7 @@ __tzfile_compute (time_t timer, int use_localtime, __tzname[0] = NULL; __tzname[1] = NULL; - if (__builtin_expect (num_transitions == 0 || timer < transitions[0], 0)) + if (__glibc_unlikely (num_transitions == 0 || timer < transitions[0])) { /* TIMER is before any transition (or there are no transitions). Choose the first non-DST type @@ -657,9 +657,9 @@ __tzfile_compute (time_t timer, int use_localtime, ++j; } } - else if (__builtin_expect (timer >= transitions[num_transitions - 1], 0)) + else if (__glibc_unlikely (timer >= transitions[num_transitions - 1])) { - if (__builtin_expect (tzspec == NULL, 0)) + if (__glibc_unlikely (tzspec == NULL)) { use_last: i = num_transitions; @@ -671,7 +671,7 @@ __tzfile_compute (time_t timer, int use_localtime, /* Convert to broken down structure. If this fails do not use the string. */ - if (__builtin_expect (! __offtime (&timer, 0, tp), 0)) + if (__glibc_unlikely (! __offtime (&timer, 0, tp))) goto use_last; /* Use the rules from the TZ string to compute the change. */ @@ -680,7 +680,7 @@ __tzfile_compute (time_t timer, int use_localtime, /* If tzspec comes from posixrules loaded by __tzfile_default, override the STD and DST zone names with the ones user requested in TZ envvar. */ - if (__builtin_expect (zone_names == (char *) &leaps[num_leaps], 0)) + if (__glibc_unlikely (zone_names == (char *) &leaps[num_leaps])) { assert (num_types == 2); __tzname[0] = __tzstring (zone_names); @@ -762,7 +762,7 @@ __tzfile_compute (time_t timer, int use_localtime, ++j; } - if (__builtin_expect (__tzname[0] == NULL, 0)) + if (__glibc_unlikely (__tzname[0] == NULL)) __tzname[0] = __tzname[1]; i = type_idxs[i - 1]; diff --git a/time/tzset.c b/time/tzset.c index bfcd943..77bfde9 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -184,16 +184,16 @@ __tzset_parse_tz (tz) { /* Check for the quoted version. */ char *wp = tzbuf; - if (__builtin_expect (*tz++ != '<', 0)) + if (__glibc_unlikely (*tz++ != '<')) goto out; while (isalnum (*tz) || *tz == '+' || *tz == '-') *wp++ = *tz++; - if (__builtin_expect (*tz++ != '>' || wp - tzbuf < 3, 0)) + if (__glibc_unlikely (*tz++ != '>' || wp - tzbuf < 3)) goto out; *wp = '\0'; } - else if (__builtin_expect (consumed < 3, 0)) + else if (__glibc_unlikely (consumed < 3)) goto out; else tz += consumed; @@ -232,19 +232,19 @@ __tzset_parse_tz (tz) /* Check for the quoted version. */ char *wp = tzbuf; const char *rp = tz; - if (__builtin_expect (*rp++ != '<', 0)) + if (__glibc_unlikely (*rp++ != '<')) /* Punt on name, set up the offsets. */ goto done_names; while (isalnum (*rp) || *rp == '+' || *rp == '-') *wp++ = *rp++; - if (__builtin_expect (*rp++ != '>' || wp - tzbuf < 3, 0)) + if (__glibc_unlikely (*rp++ != '>' || wp - tzbuf < 3)) /* Punt on name, set up the offsets. */ goto done_names; *wp = '\0'; tz = rp; } - else if (__builtin_expect (consumed < 3, 0)) + else if (__glibc_unlikely (consumed < 3)) /* Punt on name, set up the offsets. */ goto done_names; else |