diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-12-28 22:47:59 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-12-28 22:47:59 +0000 |
commit | 63b8eae47a28005453f64ad31b34596a1d419017 (patch) | |
tree | 2d46fadf66ecea0af92270178028d276d2675fa4 /libio/libio.h | |
parent | (yn_test): Expect invalid exception for negative arguments. (y0_test): Likewi... (diff) | |
download | glibc-63b8eae47a28005453f64ad31b34596a1d419017.tar.gz glibc-63b8eae47a28005453f64ad31b34596a1d419017.tar.bz2 glibc-63b8eae47a28005453f64ad31b34596a1d419017.zip |
Use __builtin_expect in _IO_getc_unlocked, _IO_peekc_unlocked, _IO_ptc_unlcoked, _IO_getwc_unlocked, and _IO_putwc_unlocked.
Diffstat (limited to 'libio/libio.h')
-rw-r--r-- | libio/libio.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libio/libio.h b/libio/libio.h index c70a86ae90..e7d7bae2b5 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -407,23 +407,31 @@ extern _IO_wint_t __wunderflow (_IO_FILE *) __THROW; extern _IO_wint_t __wuflow (_IO_FILE *) __THROW; extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t) __THROW; +#if __GNUC__ >= 3 +# define _IO_BE(expr, res) __builtin_expect (expr, res) +#else +# define _IO_BE(expr, res) (expr) +#endif + #define _IO_getc_unlocked(_fp) \ - ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow (_fp) \ - : *(unsigned char *) (_fp)->_IO_read_ptr++) + (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \ + ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++) #define _IO_peekc_unlocked(_fp) \ - ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \ + (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \ && __underflow (_fp) == EOF ? EOF \ : *(unsigned char *) (_fp)->_IO_read_ptr) #define _IO_putc_unlocked(_ch, _fp) \ - (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \ + (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \ ? __overflow (_fp, (unsigned char) (_ch)) \ : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch))) #define _IO_getwc_unlocked(_fp) \ - ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end \ + (_IO_BE ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end,\ + 0) \ ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++) #define _IO_putwc_unlocked(_wch, _fp) \ - ((_fp)->_wide_data->_IO_write_ptr >= (_fp)->_wide_data->_IO_write_end \ + (_IO_BE ((_fp)->_wide_data->_IO_write_ptr \ + >= (_fp)->_wide_data->_IO_write_end, 0) \ ? __woverflow (_fp, _wch) \ : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch))) |