replaced mpd_likely/mpd_unlikely by G_LIKELY/G_UNLIKELY

We want to remove gcc.h eventually. This takes care of all the
G_LIKELY/G_UNLIKELY macros.
This commit is contained in:
Thomas Jansen 2008-12-02 02:22:43 +01:00
parent 4ca24f22f1
commit 2720585731
6 changed files with 18 additions and 16 deletions

View File

@ -110,7 +110,7 @@ char *pfx_dir(char *dst,
const char *path, const size_t path_len,
const char *pfx, const size_t pfx_len)
{
if (mpd_unlikely((pfx_len + path_len + 1) >= MPD_PATH_MAX))
if (G_UNLIKELY((pfx_len + path_len + 1) >= MPD_PATH_MAX))
FATAL("Cannot prefix '%s' to '%s', PATH_MAX: %d\n",
pfx, path, MPD_PATH_MAX);

View File

@ -26,6 +26,7 @@
#include <assert.h>
#include <string.h>
#include <math.h>
#include <glib.h>
static inline int
pcm_dither(void)
@ -40,9 +41,9 @@ pcm_dither(void)
static int32_t
pcm_range(int32_t sample, unsigned bits)
{
if (mpd_unlikely(sample < (-1 << (bits - 1))))
if (G_UNLIKELY(sample < (-1 << (bits - 1))))
return -1 << (bits - 1);
if (mpd_unlikely(sample >= (1 << (bits - 1))))
if (G_UNLIKELY(sample >= (1 << (bits - 1))))
return (1 << (bits - 1)) - 1;
return sample;
}

View File

@ -19,13 +19,13 @@
#include "../config.h"
#include "state_file.h"
#include "conf.h"
#include "gcc.h"
#include "log.h"
#include "audio.h"
#include "playlist.h"
#include "utils.h"
#include "volume.h"
#include <glib.h>
#include <string.h>
#include <sys/stat.h>
@ -58,7 +58,7 @@ void write_state_file(void)
if (!sfpath)
return;
fp = fopen(sfpath, "w");
if (mpd_unlikely(!fp)) {
if (G_UNLIKELY(!fp)) {
ERROR("problems opening state file \"%s\" for writing: %s\n",
sfpath, strerror(errno));
return;
@ -87,7 +87,7 @@ void read_state_file(void)
FATAL("state file \"%s\" is not a regular file\n", sfpath);
while (!(fp = fopen(sfpath, "r")) && errno == EINTR);
if (mpd_unlikely(!fp)) {
if (G_UNLIKELY(!fp)) {
FATAL("problems opening state file \"%s\" for reading: %s\n",
sfpath, strerror(errno));
}

View File

@ -52,7 +52,7 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
GError *error = NULL;
isostr = id3_ucs4_latin1duplicate(ucs4);
if (mpd_unlikely(!isostr)) {
if (G_UNLIKELY(!isostr)) {
return NULL;
}
@ -70,7 +70,7 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
free(isostr);
} else {
utf8 = id3_ucs4_utf8duplicate(ucs4);
if (mpd_unlikely(!utf8)) {
if (G_UNLIKELY(!utf8)) {
return NULL;
}
}

View File

@ -27,6 +27,7 @@
#include <sys/types.h>
#include <pwd.h>
#include <fcntl.h>
#include <glib.h>
#ifdef HAVE_IPV6
#include <sys/socket.h>
@ -78,7 +79,7 @@ int ipv6Supported(void)
mpd_malloc char *xstrdup(const char *s)
{
char *ret = strdup(s);
if (mpd_unlikely(!ret))
if (G_UNLIKELY(!ret))
FATAL("OOM: strdup\n");
return ret;
}
@ -89,10 +90,10 @@ mpd_malloc void *xmalloc(size_t size)
{
void *ret;
assert(mpd_likely(size));
assert(G_LIKELY(size));
ret = malloc(size);
if (mpd_unlikely(!ret))
if (G_UNLIKELY(!ret))
FATAL("OOM: malloc\n");
return ret;
}
@ -104,10 +105,10 @@ mpd_malloc void *xrealloc(void *ptr, size_t size)
/* some C libraries return NULL when size == 0,
* make sure we get a free()-able pointer (free(NULL)
* doesn't work with all C libraries, either) */
if (mpd_unlikely(!ret && !size))
if (G_UNLIKELY(!ret && !size))
ret = realloc(ptr, 1);
if (mpd_unlikely(!ret))
if (G_UNLIKELY(!ret))
FATAL("OOM: realloc\n");
return ret;
}
@ -116,10 +117,10 @@ mpd_malloc void *xcalloc(size_t nmemb, size_t size)
{
void *ret;
assert(mpd_likely(nmemb && size));
assert(G_LIKELY(nmemb && size));
ret = calloc(nmemb, size);
if (mpd_unlikely(!ret))
if (G_UNLIKELY(!ret))
FATAL("OOM: calloc\n");
return ret;
}

View File

@ -526,7 +526,7 @@ void read_sw_volume_state(FILE *fp)
if (!g_str_has_prefix(buf, SW_VOLUME_STATE))
continue;
sv = strtol(buf + strlen(SW_VOLUME_STATE), &end, 10);
if (mpd_likely(!*end))
if (G_LIKELY(!*end))
changeSoftwareVolume(sv, 0);
else
ERROR("Can't parse software volume: %s\n", buf);