diff options
author | Thomas Jansen <mithi@mithi.net> | 2008-12-02 02:22:43 +0100 |
---|---|---|
committer | Thomas Jansen <mithi@mithi.net> | 2008-12-02 02:22:43 +0100 |
commit | 2720585731eb6a39fece86fb675a644b8ea803ae (patch) | |
tree | 43c66f17c1266e484b6f8fa9951cdd98920a0f2b /src | |
parent | 4ca24f22f191033e5dbb88f34e4088bc2814ed0f (diff) | |
download | mpd-2720585731eb6a39fece86fb675a644b8ea803ae.tar.gz mpd-2720585731eb6a39fece86fb675a644b8ea803ae.tar.xz mpd-2720585731eb6a39fece86fb675a644b8ea803ae.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/path.c | 2 | ||||
-rw-r--r-- | src/pcm_utils.c | 5 | ||||
-rw-r--r-- | src/state_file.c | 6 | ||||
-rw-r--r-- | src/tag_id3.c | 4 | ||||
-rw-r--r-- | src/utils.c | 15 | ||||
-rw-r--r-- | src/volume.c | 2 |
6 files changed, 18 insertions, 16 deletions
diff --git a/src/path.c b/src/path.c index ff7f6ffe5..3baa96bb2 100644 --- a/src/path.c +++ b/src/path.c @@ -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); diff --git a/src/pcm_utils.c b/src/pcm_utils.c index bc9516a8f..4759c20ac 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -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; } diff --git a/src/state_file.c b/src/state_file.c index 1130d62c0..618d9b2f7 100644 --- a/src/state_file.c +++ b/src/state_file.c @@ -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)); } diff --git a/src/tag_id3.c b/src/tag_id3.c index 8f10fedb2..83e7bac14 100644 --- a/src/tag_id3.c +++ b/src/tag_id3.c @@ -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; } } diff --git a/src/utils.c b/src/utils.c index bb5107bb6..892f6f39f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -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; } diff --git a/src/volume.c b/src/volume.c index 9fd33f010..fedccfd7e 100644 --- a/src/volume.c +++ b/src/volume.c @@ -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); |