Commit 8e331cfc authored by Max Kellermann's avatar Max Kellermann

gcc.h: re-add gcc_const and gcc_pure

Remove GLib dependency from some headers.
parent edf811fa
...@@ -27,10 +27,7 @@ ...@@ -27,10 +27,7 @@
#define MPD_DATABASE_PLUGIN_HXX #define MPD_DATABASE_PLUGIN_HXX
#include "DatabaseVisitor.hxx" #include "DatabaseVisitor.hxx"
#include "gcc.h"
#include <glib.h>
#include <assert.h>
#include <stdbool.h>
struct config_param; struct config_param;
struct db_selection; struct db_selection;
...@@ -46,7 +43,7 @@ public: ...@@ -46,7 +43,7 @@ public:
/** /**
* Open the database. Read it into memory if applicable. * Open the database. Read it into memory if applicable.
*/ */
virtual bool Open(G_GNUC_UNUSED GError **error_r) { virtual bool Open(gcc_unused GError **error_r) {
return true; return true;
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
/** /**
* The GLib quark used for errors reported by this library. * The GLib quark used for errors reported by this library.
*/ */
G_GNUC_CONST gcc_const
static inline GQuark static inline GQuark
audio_format_quark(void) audio_format_quark(void)
{ {
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#ifndef MPD_AUDIO_FORMAT_H #ifndef MPD_AUDIO_FORMAT_H
#define MPD_AUDIO_FORMAT_H #define MPD_AUDIO_FORMAT_H
#include <glib.h> #include "gcc.h"
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <assert.h> #include <assert.h>
...@@ -189,7 +190,7 @@ audio_valid_channel_count(unsigned channels) ...@@ -189,7 +190,7 @@ audio_valid_channel_count(unsigned channels)
* Returns false if the format is not valid for playback with MPD. * Returns false if the format is not valid for playback with MPD.
* This function performs some basic validity checks. * This function performs some basic validity checks.
*/ */
G_GNUC_PURE gcc_pure
static inline bool audio_format_valid(const struct audio_format *af) static inline bool audio_format_valid(const struct audio_format *af)
{ {
return audio_valid_sample_rate(af->sample_rate) && return audio_valid_sample_rate(af->sample_rate) &&
...@@ -201,7 +202,7 @@ static inline bool audio_format_valid(const struct audio_format *af) ...@@ -201,7 +202,7 @@ static inline bool audio_format_valid(const struct audio_format *af)
* Returns false if the format mask is not valid for playback with * Returns false if the format mask is not valid for playback with
* MPD. This function performs some basic validity checks. * MPD. This function performs some basic validity checks.
*/ */
G_GNUC_PURE gcc_pure
static inline bool audio_format_mask_valid(const struct audio_format *af) static inline bool audio_format_mask_valid(const struct audio_format *af)
{ {
return (af->sample_rate == 0 || return (af->sample_rate == 0 ||
...@@ -223,7 +224,7 @@ void ...@@ -223,7 +224,7 @@ void
audio_format_mask_apply(struct audio_format *af, audio_format_mask_apply(struct audio_format *af,
const struct audio_format *mask); const struct audio_format *mask);
G_GNUC_CONST gcc_const
static inline unsigned static inline unsigned
sample_format_size(enum sample_format format) sample_format_size(enum sample_format format)
{ {
...@@ -254,7 +255,7 @@ sample_format_size(enum sample_format format) ...@@ -254,7 +255,7 @@ sample_format_size(enum sample_format format)
/** /**
* Returns the size of each (mono) sample in bytes. * Returns the size of each (mono) sample in bytes.
*/ */
G_GNUC_PURE gcc_pure
static inline unsigned audio_format_sample_size(const struct audio_format *af) static inline unsigned audio_format_sample_size(const struct audio_format *af)
{ {
return sample_format_size((enum sample_format)af->format); return sample_format_size((enum sample_format)af->format);
...@@ -263,7 +264,7 @@ static inline unsigned audio_format_sample_size(const struct audio_format *af) ...@@ -263,7 +264,7 @@ static inline unsigned audio_format_sample_size(const struct audio_format *af)
/** /**
* Returns the size of each full frame in bytes. * Returns the size of each full frame in bytes.
*/ */
G_GNUC_PURE gcc_pure
static inline unsigned static inline unsigned
audio_format_frame_size(const struct audio_format *af) audio_format_frame_size(const struct audio_format *af)
{ {
...@@ -274,7 +275,7 @@ audio_format_frame_size(const struct audio_format *af) ...@@ -274,7 +275,7 @@ audio_format_frame_size(const struct audio_format *af)
* Returns the floating point factor which converts a time span to a * Returns the floating point factor which converts a time span to a
* storage size in bytes. * storage size in bytes.
*/ */
G_GNUC_PURE gcc_pure
static inline double audio_format_time_to_size(const struct audio_format *af) static inline double audio_format_time_to_size(const struct audio_format *af)
{ {
return af->sample_rate * audio_format_frame_size(af); return af->sample_rate * audio_format_frame_size(af);
...@@ -287,7 +288,7 @@ static inline double audio_format_time_to_size(const struct audio_format *af) ...@@ -287,7 +288,7 @@ static inline double audio_format_time_to_size(const struct audio_format *af)
* @param format a #sample_format enum value * @param format a #sample_format enum value
* @return the string * @return the string
*/ */
G_GNUC_PURE G_GNUC_MALLOC gcc_pure gcc_malloc
const char * const char *
sample_format_to_string(enum sample_format format); sample_format_to_string(enum sample_format format);
...@@ -299,7 +300,7 @@ sample_format_to_string(enum sample_format format); ...@@ -299,7 +300,7 @@ sample_format_to_string(enum sample_format format);
* @param s a buffer to print into * @param s a buffer to print into
* @return the string, or NULL if the #audio_format object is invalid * @return the string, or NULL if the #audio_format object is invalid
*/ */
G_GNUC_PURE G_GNUC_MALLOC gcc_pure gcc_malloc
const char * const char *
audio_format_to_string(const struct audio_format *af, audio_format_to_string(const struct audio_format *af,
struct audio_format_string *s); struct audio_format_string *s);
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#ifndef MPD_CLIENT_H #ifndef MPD_CLIENT_H
#define MPD_CLIENT_H #define MPD_CLIENT_H
#include <glib.h> #include "gcc.h"
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -35,28 +36,28 @@ void client_manager_deinit(void); ...@@ -35,28 +36,28 @@ void client_manager_deinit(void);
void client_new(struct player_control *player_control, void client_new(struct player_control *player_control,
int fd, const struct sockaddr *sa, size_t sa_length, int uid); int fd, const struct sockaddr *sa, size_t sa_length, int uid);
G_GNUC_PURE gcc_pure
bool client_is_expired(const struct client *client); bool client_is_expired(const struct client *client);
/** /**
* returns the uid of the client process, or a negative value if the * returns the uid of the client process, or a negative value if the
* uid is unknown * uid is unknown
*/ */
G_GNUC_PURE gcc_pure
int client_get_uid(const struct client *client); int client_get_uid(const struct client *client);
/** /**
* Is this client running on the same machine, connected with a local * Is this client running on the same machine, connected with a local
* (UNIX domain) socket? * (UNIX domain) socket?
*/ */
G_GNUC_PURE gcc_pure
static inline bool static inline bool
client_is_local(const struct client *client) client_is_local(const struct client *client)
{ {
return client_get_uid(client) > 0; return client_get_uid(client) > 0;
} }
G_GNUC_PURE gcc_pure
unsigned client_get_permission(const struct client *client); unsigned client_get_permission(const struct client *client);
void client_set_permission(struct client *client, unsigned permission); void client_set_permission(struct client *client, unsigned permission);
...@@ -74,6 +75,8 @@ void client_vprintf(struct client *client, const char *fmt, va_list args); ...@@ -74,6 +75,8 @@ void client_vprintf(struct client *client, const char *fmt, va_list args);
/** /**
* Write a printf-like formatted string to the client. * Write a printf-like formatted string to the client.
*/ */
G_GNUC_PRINTF(2, 3) void client_printf(struct client *client, const char *fmt, ...); gcc_fprintf
void
client_printf(struct client *client, const char *fmt, ...);
#endif #endif
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#ifndef MPD_CLIENT_FILE_H #ifndef MPD_CLIENT_FILE_H
#define MPD_CLIENT_FILE_H #define MPD_CLIENT_FILE_H
#include <glib.h> #include "gcc.h"
#include "gerror.h"
#include <stdbool.h> #include <stdbool.h>
struct client; struct client;
...@@ -35,7 +37,7 @@ struct client; ...@@ -35,7 +37,7 @@ struct client;
* @param path_fs the absolute path name in filesystem encoding * @param path_fs the absolute path name in filesystem encoding
* @return true if access is allowed * @return true if access is allowed
*/ */
G_GNUC_PURE gcc_pure
bool bool
client_allow_file(const struct client *client, const char *path_fs, client_allow_file(const struct client *client, const char *path_fs,
GError **error_r); GError **error_r);
......
...@@ -20,10 +20,11 @@ ...@@ -20,10 +20,11 @@
#ifndef MPD_CLIENT_MESSAGE_H #ifndef MPD_CLIENT_MESSAGE_H
#define MPD_CLIENT_MESSAGE_H #define MPD_CLIENT_MESSAGE_H
#include "gcc.h"
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <glib.h>
/** /**
* A client-to-client message. * A client-to-client message.
...@@ -34,11 +35,11 @@ struct client_message { ...@@ -34,11 +35,11 @@ struct client_message {
char *message; char *message;
}; };
G_GNUC_PURE gcc_pure
bool bool
client_message_valid_channel_name(const char *name); client_message_valid_channel_name(const char *name);
G_GNUC_PURE gcc_pure
static inline bool static inline bool
client_message_defined(const struct client_message *msg) client_message_defined(const struct client_message *msg)
{ {
...@@ -59,7 +60,7 @@ void ...@@ -59,7 +60,7 @@ void
client_message_copy(struct client_message *dest, client_message_copy(struct client_message *dest,
const struct client_message *src); const struct client_message *src);
G_GNUC_MALLOC gcc_malloc
struct client_message * struct client_message *
client_message_dup(const struct client_message *src); client_message_dup(const struct client_message *src);
......
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
#ifndef MPD_CLIENT_SUBSCRIBE_H #ifndef MPD_CLIENT_SUBSCRIBE_H
#define MPD_CLIENT_SUBSCRIBE_H #define MPD_CLIENT_SUBSCRIBE_H
#include "gcc.h"
#include <stdbool.h> #include <stdbool.h>
#include <glib.h>
typedef struct _GSList GSList;
struct client; struct client;
struct client_message; struct client_message;
...@@ -52,7 +54,7 @@ client_unsubscribe_all(struct client *client); ...@@ -52,7 +54,7 @@ client_unsubscribe_all(struct client *client);
bool bool
client_push_message(struct client *client, const struct client_message *msg); client_push_message(struct client *client, const struct client_message *msg);
G_GNUC_MALLOC gcc_malloc
GSList * GSList *
client_read_messages(struct client *client); client_read_messages(struct client *client);
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "ack.h" #include "ack.h"
#include <glib.h>
#include <stdbool.h> #include <stdbool.h>
enum command_return { enum command_return {
......
...@@ -47,7 +47,7 @@ db_finish(void); ...@@ -47,7 +47,7 @@ db_finish(void);
* Returns the root directory object. Returns NULL if there is no * Returns the root directory object. Returns NULL if there is no
* configured music directory. * configured music directory.
*/ */
G_GNUC_PURE gcc_pure
struct directory * struct directory *
db_get_root(void); db_get_root(void);
...@@ -55,12 +55,12 @@ db_get_root(void); ...@@ -55,12 +55,12 @@ db_get_root(void);
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
gcc_nonnull(1) gcc_nonnull(1)
G_GNUC_PURE gcc_pure
struct directory * struct directory *
db_get_directory(const char *name); db_get_directory(const char *name);
gcc_nonnull(1) gcc_nonnull(1)
G_GNUC_PURE gcc_pure
struct song * struct song *
db_get_song(const char *file); db_get_song(const char *file);
...@@ -82,14 +82,14 @@ db_save(GError **error_r); ...@@ -82,14 +82,14 @@ db_save(GError **error_r);
bool bool
db_load(GError **error); db_load(GError **error);
G_GNUC_PURE gcc_pure
time_t time_t
db_get_mtime(void); db_get_mtime(void);
/** /**
* Returns true if there is a valid database file on the disk. * Returns true if there is a valid database file on the disk.
*/ */
G_GNUC_PURE gcc_pure
static inline bool static inline bool
db_exists(void) db_exists(void)
{ {
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <cassert> #include <cassert>
#include <string> #include <string>
#include <glib.h>
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
...@@ -40,7 +39,7 @@ class SimpleDatabase : public Database { ...@@ -40,7 +39,7 @@ class SimpleDatabase : public Database {
time_t mtime; time_t mtime;
public: public:
G_GNUC_PURE gcc_pure
struct directory *GetRoot() { struct directory *GetRoot() {
assert(root != NULL); assert(root != NULL);
...@@ -49,7 +48,7 @@ public: ...@@ -49,7 +48,7 @@ public:
bool Save(GError **error_r); bool Save(GError **error_r);
G_GNUC_PURE gcc_pure
time_t GetLastModified() const { time_t GetLastModified() const {
return mtime; return mtime;
} }
...@@ -70,12 +69,12 @@ public: ...@@ -70,12 +69,12 @@ public:
protected: protected:
bool Configure(const struct config_param *param, GError **error_r); bool Configure(const struct config_param *param, GError **error_r);
G_GNUC_PURE gcc_pure
bool Check(GError **error_r) const; bool Check(GError **error_r) const;
bool Load(GError **error_r); bool Load(GError **error_r);
G_GNUC_PURE gcc_pure
const struct directory *LookupDirectory(const char *uri) const; const struct directory *LookupDirectory(const char *uri) const;
}; };
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "decoder_api.h" #include "decoder_api.h"
#include "pcm_buffer.h" #include "pcm_buffer.h"
#include <glib.h>
#include <FLAC/stream_decoder.h> #include <FLAC/stream_decoder.h>
#include <FLAC/metadata.h> #include <FLAC/metadata.h>
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
*/ */
#if GCC_CHECK_VERSION(3,0) #if GCC_CHECK_VERSION(3,0)
# define gcc_const __attribute__((const))
# define gcc_pure __attribute__((pure))
# define gcc_malloc __attribute__((malloc))
# define gcc_must_check __attribute__ ((warn_unused_result)) # define gcc_must_check __attribute__ ((warn_unused_result))
# define gcc_packed __attribute__ ((packed)) # define gcc_packed __attribute__ ((packed))
/* these are very useful for type checking */ /* these are very useful for type checking */
...@@ -41,11 +44,21 @@ ...@@ -41,11 +44,21 @@
# define gcc_fprintf__ __attribute__ ((format(printf,4,5))) # define gcc_fprintf__ __attribute__ ((format(printf,4,5)))
# define gcc_scanf __attribute__ ((format(scanf,1,2))) # define gcc_scanf __attribute__ ((format(scanf,1,2)))
# define gcc_used __attribute__ ((used)) # define gcc_used __attribute__ ((used))
# define gcc_unused __attribute__((unused))
# define gcc_warn_unused_result __attribute__((warn_unused_result))
/* # define inline inline __attribute__ ((always_inline)) */ /* # define inline inline __attribute__ ((always_inline)) */
# define gcc_noinline __attribute__ ((noinline)) # define gcc_noinline __attribute__ ((noinline))
# define gcc_nonnull(...) __attribute__((nonnull(__VA_ARGS__))) # define gcc_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
# define gcc_nonnull_all __attribute__((nonnull)) # define gcc_nonnull_all __attribute__((nonnull))
# define gcc_likely(x) __builtin_expect (!!(x), 1)
# define gcc_unlikely(x) __builtin_expect (!!(x), 0)
#else #else
# define gcc_unused
# define gcc_const
# define gcc_pure
# define gcc_malloc
# define gcc_must_check # define gcc_must_check
# define gcc_packed # define gcc_packed
# define gcc_printf # define gcc_printf
...@@ -54,10 +67,16 @@ ...@@ -54,10 +67,16 @@
# define gcc_fprintf__ # define gcc_fprintf__
# define gcc_scanf # define gcc_scanf
# define gcc_used # define gcc_used
# define gcc_unused
# define gcc_warn_unused_result
/* # define inline */ /* # define inline */
# define gcc_noinline # define gcc_noinline
# define gcc_nonnull(...) # define gcc_nonnull(...)
# define gcc_nonnull_all # define gcc_nonnull_all
# define gcc_likely(x) (x)
# define gcc_unlikely(x) (x)
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "uri.h" #include "uri.h"
#include "client.h" #include "client.h"
#include <glib.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
......
...@@ -24,10 +24,11 @@ ...@@ -24,10 +24,11 @@
#ifndef MPD_MAPPER_H #ifndef MPD_MAPPER_H
#define MPD_MAPPER_H #define MPD_MAPPER_H
#include "gcc.h"
#include "gerror.h" #include "gerror.h"
#include <glib.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
#define PLAYLIST_FILE_SUFFIX ".m3u" #define PLAYLIST_FILE_SUFFIX ".m3u"
...@@ -38,14 +39,14 @@ void mapper_init(const char *_music_dir, const char *_playlist_dir); ...@@ -38,14 +39,14 @@ void mapper_init(const char *_music_dir, const char *_playlist_dir);
void mapper_finish(void); void mapper_finish(void);
G_GNUC_CONST gcc_const
const char * const char *
mapper_get_music_directory(void); mapper_get_music_directory(void);
/** /**
* Returns true if a music directory was configured. * Returns true if a music directory was configured.
*/ */
G_GNUC_CONST gcc_const
static inline bool static inline bool
mapper_has_music_directory(void) mapper_has_music_directory(void)
{ {
...@@ -57,7 +58,7 @@ mapper_has_music_directory(void) ...@@ -57,7 +58,7 @@ mapper_has_music_directory(void)
* this function converts it to a relative path. If not, it returns * this function converts it to a relative path. If not, it returns
* the unmodified string pointer. * the unmodified string pointer.
*/ */
G_GNUC_PURE gcc_pure
const char * const char *
map_to_relative_path(const char *path_utf8); map_to_relative_path(const char *path_utf8);
...@@ -66,7 +67,7 @@ map_to_relative_path(const char *path_utf8); ...@@ -66,7 +67,7 @@ map_to_relative_path(const char *path_utf8);
* is basically done by converting the URI to the file system charset * is basically done by converting the URI to the file system charset
* and prepending the music directory. * and prepending the music directory.
*/ */
G_GNUC_MALLOC gcc_malloc
char * char *
map_uri_fs(const char *uri); map_uri_fs(const char *uri);
...@@ -76,7 +77,7 @@ map_uri_fs(const char *uri); ...@@ -76,7 +77,7 @@ map_uri_fs(const char *uri);
* @param directory the directory object * @param directory the directory object
* @return the path in file system encoding, or NULL if mapping failed * @return the path in file system encoding, or NULL if mapping failed
*/ */
G_GNUC_MALLOC gcc_malloc
char * char *
map_directory_fs(const struct directory *directory); map_directory_fs(const struct directory *directory);
...@@ -88,7 +89,7 @@ map_directory_fs(const struct directory *directory); ...@@ -88,7 +89,7 @@ map_directory_fs(const struct directory *directory);
* @param name the child's name in UTF-8 * @param name the child's name in UTF-8
* @return the path in file system encoding, or NULL if mapping failed * @return the path in file system encoding, or NULL if mapping failed
*/ */
G_GNUC_MALLOC gcc_malloc
char * char *
map_directory_child_fs(const struct directory *directory, const char *name); map_directory_child_fs(const struct directory *directory, const char *name);
...@@ -99,7 +100,7 @@ map_directory_child_fs(const struct directory *directory, const char *name); ...@@ -99,7 +100,7 @@ map_directory_child_fs(const struct directory *directory, const char *name);
* @param song the song object * @param song the song object
* @return the path in file system encoding, or NULL if mapping failed * @return the path in file system encoding, or NULL if mapping failed
*/ */
G_GNUC_MALLOC gcc_malloc
char * char *
map_song_fs(const struct song *song); map_song_fs(const struct song *song);
...@@ -110,14 +111,14 @@ map_song_fs(const struct song *song); ...@@ -110,14 +111,14 @@ map_song_fs(const struct song *song);
* @param path_fs a path in file system encoding * @param path_fs a path in file system encoding
* @return the relative path in UTF-8, or NULL if mapping failed * @return the relative path in UTF-8, or NULL if mapping failed
*/ */
G_GNUC_MALLOC gcc_malloc
char * char *
map_fs_to_utf8(const char *path_fs); map_fs_to_utf8(const char *path_fs);
/** /**
* Returns the playlist directory. * Returns the playlist directory.
*/ */
G_GNUC_CONST gcc_const
const char * const char *
map_spl_path(void); map_spl_path(void);
...@@ -128,7 +129,7 @@ map_spl_path(void); ...@@ -128,7 +129,7 @@ map_spl_path(void);
* *
* @return the path in file system encoding, or NULL if mapping failed * @return the path in file system encoding, or NULL if mapping failed
*/ */
G_GNUC_PURE gcc_pure
char * char *
map_spl_utf8_to_fs(const char *name); map_spl_utf8_to_fs(const char *name);
......
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
#ifndef MPD_OUTPUT_HTTPD_CLIENT_H #ifndef MPD_OUTPUT_HTTPD_CLIENT_H
#define MPD_OUTPUT_HTTPD_CLIENT_H #define MPD_OUTPUT_HTTPD_CLIENT_H
#include <glib.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
struct httpd_client; struct httpd_client;
struct httpd_output; struct httpd_output;
......
...@@ -20,10 +20,9 @@ ...@@ -20,10 +20,9 @@
#ifndef MPD_OUTPUT_PLUGIN_H #ifndef MPD_OUTPUT_PLUGIN_H
#define MPD_OUTPUT_PLUGIN_H #define MPD_OUTPUT_PLUGIN_H
#include "gcc.h"
#include "gerror.h" #include "gerror.h"
#include <glib.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
...@@ -167,7 +166,7 @@ ao_plugin_test_default_device(const struct audio_output_plugin *plugin) ...@@ -167,7 +166,7 @@ ao_plugin_test_default_device(const struct audio_output_plugin *plugin)
: false; : false;
} }
G_GNUC_MALLOC gcc_malloc
struct audio_output * struct audio_output *
ao_plugin_init(const struct audio_output_plugin *plugin, ao_plugin_init(const struct audio_output_plugin *plugin,
const struct config_param *param, const struct config_param *param,
...@@ -189,7 +188,7 @@ ao_plugin_open(struct audio_output *ao, struct audio_format *audio_format, ...@@ -189,7 +188,7 @@ ao_plugin_open(struct audio_output *ao, struct audio_format *audio_format,
void void
ao_plugin_close(struct audio_output *ao); ao_plugin_close(struct audio_output *ao);
G_GNUC_PURE gcc_pure
unsigned unsigned
ao_plugin_delay(struct audio_output *ao); ao_plugin_delay(struct audio_output *ao);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define PCM_MIX_H #define PCM_MIX_H
#include "audio_format.h" #include "audio_format.h"
#include "gcc.h"
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
* *
* @return true on success, false if the format is not supported * @return true on success, false if the format is not supported
*/ */
G_GNUC_WARN_UNUSED_RESULT gcc_warn_unused_result
bool bool
pcm_mix(void *buffer1, const void *buffer2, size_t size, pcm_mix(void *buffer1, const void *buffer2, size_t size,
enum sample_format format, float portion1); enum sample_format format, float portion1);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
enum { enum {
/** this value means "100% volume" */ /** this value means "100% volume" */
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#ifndef MPD_PIPE_H #ifndef MPD_PIPE_H
#define MPD_PIPE_H #define MPD_PIPE_H
#include <glib.h> #include "gcc.h"
#include <stdbool.h> #include <stdbool.h>
#ifndef NDEBUG #ifndef NDEBUG
...@@ -39,7 +40,7 @@ struct music_pipe; ...@@ -39,7 +40,7 @@ struct music_pipe;
/** /**
* Creates a new #music_pipe object. It is empty. * Creates a new #music_pipe object. It is empty.
*/ */
G_GNUC_MALLOC gcc_malloc
struct music_pipe * struct music_pipe *
music_pipe_new(void); music_pipe_new(void);
...@@ -72,7 +73,7 @@ music_pipe_contains(const struct music_pipe *mp, ...@@ -72,7 +73,7 @@ music_pipe_contains(const struct music_pipe *mp,
* Returns the first #music_chunk from the pipe. Returns NULL if the * Returns the first #music_chunk from the pipe. Returns NULL if the
* pipe is empty. * pipe is empty.
*/ */
G_GNUC_PURE gcc_pure
const struct music_chunk * const struct music_chunk *
music_pipe_peek(const struct music_pipe *mp); music_pipe_peek(const struct music_pipe *mp);
...@@ -99,11 +100,11 @@ music_pipe_push(struct music_pipe *mp, struct music_chunk *chunk); ...@@ -99,11 +100,11 @@ music_pipe_push(struct music_pipe *mp, struct music_chunk *chunk);
/** /**
* Returns the number of chunks currently in this pipe. * Returns the number of chunks currently in this pipe.
*/ */
G_GNUC_PURE gcc_pure
unsigned unsigned
music_pipe_size(const struct music_pipe *mp); music_pipe_size(const struct music_pipe *mp);
G_GNUC_PURE gcc_pure
static inline bool static inline bool
music_pipe_empty(const struct music_pipe *mp) music_pipe_empty(const struct music_pipe *mp)
{ {
......
...@@ -21,10 +21,9 @@ ...@@ -21,10 +21,9 @@
#define MPD_PROTOCOL_RESULT_H #define MPD_PROTOCOL_RESULT_H
#include "check.h" #include "check.h"
#include "gcc.h"
#include "ack.h" #include "ack.h"
#include <glib.h>
struct client; struct client;
extern const char *current_command; extern const char *current_command;
...@@ -37,7 +36,7 @@ void ...@@ -37,7 +36,7 @@ void
command_error_v(struct client *client, enum ack error, command_error_v(struct client *client, enum ack error,
const char *fmt, va_list args); const char *fmt, va_list args);
G_GNUC_PRINTF(3, 4) gcc_fprintf_
void void
command_error(struct client *client, enum ack error, const char *fmt, ...); command_error(struct client *client, enum ack error, const char *fmt, ...);
......
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
#ifndef MPD_RESOLVER_H #ifndef MPD_RESOLVER_H
#define MPD_RESOLVER_H #define MPD_RESOLVER_H
#include "gcc.h"
#include <glib.h> #include <glib.h>
struct sockaddr; struct sockaddr;
struct addrinfo; struct addrinfo;
G_GNUC_CONST gcc_const
static inline GQuark static inline GQuark
resolver_quark(void) resolver_quark(void)
{ {
...@@ -42,7 +44,7 @@ resolver_quark(void) ...@@ -42,7 +44,7 @@ resolver_quark(void)
* @param error location to store the error occurring, or NULL to * @param error location to store the error occurring, or NULL to
* ignore errors * ignore errors
*/ */
G_GNUC_MALLOC gcc_malloc
char * char *
sockaddr_to_string(const struct sockaddr *sa, size_t length, GError **error); sockaddr_to_string(const struct sockaddr *sa, size_t length, GError **error);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifndef MPD_STRING_UTIL_H #ifndef MPD_STRING_UTIL_H
#define MPD_STRING_UTIL_H #define MPD_STRING_UTIL_H
#include <glib.h> #include "gcc.h"
#include <stdbool.h> #include <stdbool.h>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* Remove the "const" attribute from a string pointer. This is a * Remove the "const" attribute from a string pointer. This is a
* dirty hack, don't use it unless you know what you're doing! * dirty hack, don't use it unless you know what you're doing!
*/ */
G_GNUC_CONST gcc_const
static inline char * static inline char *
deconst_string(const char *p) deconst_string(const char *p)
{ {
...@@ -49,14 +49,14 @@ deconst_string(const char *p) ...@@ -49,14 +49,14 @@ deconst_string(const char *p)
* This is a faster version of g_strchug(), because it does not move * This is a faster version of g_strchug(), because it does not move
* data. * data.
*/ */
G_GNUC_PURE gcc_pure
const char * const char *
strchug_fast_c(const char *p); strchug_fast_c(const char *p);
/** /**
* Same as strchug_fast_c(), but works with a writable pointer. * Same as strchug_fast_c(), but works with a writable pointer.
*/ */
G_GNUC_PURE gcc_pure
static inline char * static inline char *
strchug_fast(char *p) strchug_fast(char *p)
{ {
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "config.h" #include "config.h"
#include "strset.h" #include "strset.h"
#include <glib.h>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
......
...@@ -29,11 +29,13 @@ ...@@ -29,11 +29,13 @@
#ifndef MPD_STRSET_H #ifndef MPD_STRSET_H
#define MPD_STRSET_H #define MPD_STRSET_H
#include <glib.h> #include "gcc.h"
struct strset; struct strset;
G_GNUC_MALLOC struct strset *strset_new(void); gcc_malloc
struct strset *
strset_new(void);
void strset_free(struct strset *set); void strset_free(struct strset *set);
......
...@@ -21,10 +21,9 @@ ...@@ -21,10 +21,9 @@
#define MPD_TAG_ID3_H #define MPD_TAG_ID3_H
#include "check.h" #include "check.h"
#include "gcc.h"
#include "gerror.h" #include "gerror.h"
#include <glib.h>
#include <stdbool.h> #include <stdbool.h>
struct tag_handler; struct tag_handler;
...@@ -52,9 +51,9 @@ tag_id3_load(const char *path_fs, GError **error_r); ...@@ -52,9 +51,9 @@ tag_id3_load(const char *path_fs, GError **error_r);
#else #else
static inline bool static inline bool
tag_id3_scan(G_GNUC_UNUSED const char *path_fs, tag_id3_scan(gcc_unused const char *path_fs,
G_GNUC_UNUSED const struct tag_handler *handler, gcc_unused const struct tag_handler *handler,
G_GNUC_UNUSED void *handler_ctx) gcc_unused void *handler_ctx)
{ {
return false; return false;
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define MPD_UPDATE_ARCHIVE_H #define MPD_UPDATE_ARCHIVE_H
#include "check.h" #include "check.h"
#include "gcc.h"
#include <stdbool.h> #include <stdbool.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -40,10 +41,10 @@ update_archive_file(struct directory *directory, ...@@ -40,10 +41,10 @@ update_archive_file(struct directory *directory,
#include <glib.h> #include <glib.h>
static inline bool static inline bool
update_archive_file(G_GNUC_UNUSED struct directory *directory, update_archive_file(gcc_unused struct directory *directory,
G_GNUC_UNUSED const char *name, gcc_unused const char *name,
G_GNUC_UNUSED const char *suffix, gcc_unused const char *suffix,
G_GNUC_UNUSED const struct stat *st) gcc_unused const struct stat *st)
{ {
return false; return false;
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifndef MPD_URI_H #ifndef MPD_URI_H
#define MPD_URI_H #define MPD_URI_H
#include <glib.h> #include "gcc.h"
#include <stdbool.h> #include <stdbool.h>
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
* Checks whether the specified URI has a scheme in the form * Checks whether the specified URI has a scheme in the form
* "scheme://". * "scheme://".
*/ */
G_GNUC_PURE gcc_pure
bool uri_has_scheme(const char *uri); bool uri_has_scheme(const char *uri);
G_GNUC_PURE gcc_pure
const char * const char *
uri_get_suffix(const char *uri); uri_get_suffix(const char *uri);
...@@ -43,7 +43,7 @@ uri_get_suffix(const char *uri); ...@@ -43,7 +43,7 @@ uri_get_suffix(const char *uri);
* - no double slashes * - no double slashes
* - no path component begins with a dot * - no path component begins with a dot
*/ */
G_GNUC_PURE gcc_pure
bool bool
uri_safe_local(const char *uri); uri_safe_local(const char *uri);
...@@ -53,7 +53,7 @@ uri_safe_local(const char *uri); ...@@ -53,7 +53,7 @@ uri_safe_local(const char *uri);
* NULL if nothing needs to be removed, or if the URI is not * NULL if nothing needs to be removed, or if the URI is not
* recognized. * recognized.
*/ */
G_GNUC_MALLOC gcc_malloc
char * char *
uri_remove_auth(const char *uri); uri_remove_auth(const char *uri);
......
...@@ -20,12 +20,13 @@ ...@@ -20,12 +20,13 @@
#ifndef MPD_BIT_REVERSE_H #ifndef MPD_BIT_REVERSE_H
#define MPD_BIT_REVERSE_H #define MPD_BIT_REVERSE_H
#include <glib.h> #include "gcc.h"
#include <stdint.h> #include <stdint.h>
extern const uint8_t bit_reverse_table[256]; extern const uint8_t bit_reverse_table[256];
G_GNUC_CONST gcc_const
static inline uint8_t static inline uint8_t
bit_reverse(uint8_t x) bit_reverse(uint8_t x)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment