use gcc const and pure function attributes wherever applicable

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1835 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-09-16 22:42:03 +00:00
parent 35483eeab7
commit 116ddaaae9
10 changed files with 73 additions and 36 deletions

View file

@ -61,14 +61,14 @@ void pa_reset_priority(void);
int pa_fd_set_cloexec(int fd, int b);
int pa_parse_boolean(const char *s);
int pa_parse_boolean(const char *s) PA_GCC_PURE;
char *pa_split(const char *c, const char*delimiters, const char **state);
char *pa_split_spaces(const char *c, const char **state);
char *pa_strip_nl(char *s);
const char *pa_strsignal(int sig);
const char *pa_strsignal(int sig) PA_GCC_PURE;
int pa_own_uid_in_group(const char *name, gid_t *gid);
int pa_uid_in_group(uid_t uid, const char *name);
@ -85,8 +85,8 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env
char *pa_hexstr(const uint8_t* d, size_t dlength, char *s, size_t slength);
size_t pa_parsehex(const char *p, uint8_t *d, size_t dlength);
int pa_startswith(const char *s, const char *pfx);
int pa_endswith(const char *s, const char *sfx);
int pa_startswith(const char *s, const char *pfx) PA_GCC_PURE;
int pa_endswith(const char *s, const char *sfx) PA_GCC_PURE;
char *pa_runtime_path(const char *fn, char *s, size_t l);

View file

@ -55,7 +55,26 @@
#ifdef __GNUC__
#define PA_GCC_DESTRUCTOR __attribute__ ((destructor))
#else
/** Call this function when process terminates */
#define PA_GCC_DESTRUCTOR
#endif
#ifndef PA_GCC_PURE
#ifdef __GNUCC__
#define PA_GCC_PURE __attribute__ ((pure))
#else
/** This function's return value depends only the arguments list and global state **/
#define PA_GCC_PURE
#endif
#endif
#ifndef PA_GCC_CONST
#ifdef __GNUCC__
#define PA_GCC_CONST __attribute__ ((pure))
#else
/** This function's return value depends only the arguments list (stricter version of PA_GCC_CONST) **/
#define PA_GCC_CONST
#endif
#endif
#endif

View file

@ -56,8 +56,8 @@ void pa_volume_memchunk(
const pa_sample_spec *spec,
const pa_cvolume *volume);
size_t pa_frame_align(size_t l, const pa_sample_spec *ss);
size_t pa_frame_align(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
int pa_frame_aligned(size_t l, const pa_sample_spec *ss);
int pa_frame_aligned(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
#endif

View file

@ -29,10 +29,10 @@
typedef void (*pa_convert_func_t)(unsigned n, const void *a, void *b);
pa_convert_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f);
pa_convert_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f);
pa_convert_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) PA_GCC_PURE;
pa_convert_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) PA_GCC_PURE;
pa_convert_func_t pa_get_convert_to_s16ne_function(pa_sample_format_t f);
pa_convert_func_t pa_get_convert_from_s16ne_function(pa_sample_format_t f);
pa_convert_func_t pa_get_convert_to_s16ne_function(pa_sample_format_t f) PA_GCC_PURE;
pa_convert_func_t pa_get_convert_from_s16ne_function(pa_sample_format_t f) PA_GCC_PURE;
#endif