[pulseaudio-commits] r1835 - in /branches/lennart/src: pulse/cdecl.h pulse/channelmap.h pulse/sample.h pulse/timeval.h pulse/utf8.h pulse/volume.h pulsecore/core-util.h pulsecore/gccmacro.h pulsecore/sample-util.h pulsecore/sconv.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Sep 16 15:42:03 PDT 2007


Author: lennart
Date: Mon Sep 17 00:42:03 2007
New Revision: 1835

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1835&root=pulseaudio&view=rev
Log:
use gcc const and pure function attributes wherever applicable

Modified:
    branches/lennart/src/pulse/cdecl.h
    branches/lennart/src/pulse/channelmap.h
    branches/lennart/src/pulse/sample.h
    branches/lennart/src/pulse/timeval.h
    branches/lennart/src/pulse/utf8.h
    branches/lennart/src/pulse/volume.h
    branches/lennart/src/pulsecore/core-util.h
    branches/lennart/src/pulsecore/gccmacro.h
    branches/lennart/src/pulsecore/sample-util.h
    branches/lennart/src/pulsecore/sconv.h

Modified: branches/lennart/src/pulse/cdecl.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/cdecl.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulse/cdecl.h (original)
+++ branches/lennart/src/pulse/cdecl.h Mon Sep 17 00:42:03 2007
@@ -41,4 +41,22 @@
 
 #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

Modified: branches/lennart/src/pulse/channelmap.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/channelmap.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulse/channelmap.h (original)
+++ branches/lennart/src/pulse/channelmap.h Mon Sep 17 00:42:03 2007
@@ -172,7 +172,7 @@
 pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def);
 
 /** Return a text label for the specified channel position */
-const char* pa_channel_position_to_string(pa_channel_position_t pos);
+const char* pa_channel_position_to_string(pa_channel_position_t pos) PA_GCC_PURE;
 
 /** Return a human readable text label for the specified channel position. \since 0.9.7 */
 const char* pa_channel_position_to_pretty_string(pa_channel_position_t pos);
@@ -187,10 +187,10 @@
 pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s);
 
 /** Compare two channel maps. Return 1 if both match. */
-int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b);
+int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) PA_GCC_PURE;
 
 /** Return non-zero of the specified channel map is considered valid */
-int pa_channel_map_valid(const pa_channel_map *map);
+int pa_channel_map_valid(const pa_channel_map *map) PA_GCC_PURE;
 
 PA_C_DECL_END
 

Modified: branches/lennart/src/pulse/sample.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/sample.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulse/sample.h (original)
+++ branches/lennart/src/pulse/sample.h Mon Sep 17 00:42:03 2007
@@ -155,31 +155,31 @@
 typedef uint64_t pa_usec_t;
 
 /** Return the amount of bytes playback of a second of audio with the specified sample type takes */
-size_t pa_bytes_per_second(const pa_sample_spec *spec);
+size_t pa_bytes_per_second(const pa_sample_spec *spec) PA_GCC_PURE;
 
 /** Return the size of a frame with the specific sample type */
-size_t pa_frame_size(const pa_sample_spec *spec);
+size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE;
 
 /** Return the size of a sample with the specific sample type */
-size_t pa_sample_size(const pa_sample_spec *spec);
+size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE;
 
 /** Calculate the time the specified bytes take to play with the specified sample type */
-pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec);
+pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE;
 
 /** Calculates the number of bytes that are required for the specified time. \since 0.9 */
-size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec);
+size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE;
 
 /** Return non-zero when the sample type specification is valid */
-int pa_sample_spec_valid(const pa_sample_spec *spec);
+int pa_sample_spec_valid(const pa_sample_spec *spec) PA_GCC_PURE;
 
 /** Return non-zero when the two sample type specifications match */
-int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b);
+int pa_sample_spec_equal(const pa_sample_spec*a, const pa_sample_spec*b) PA_GCC_PURE;
 
 /** Return a descriptive string for the specified sample format. \since 0.8 */
-const char *pa_sample_format_to_string(pa_sample_format_t f);
+const char *pa_sample_format_to_string(pa_sample_format_t f) PA_GCC_PURE;
 
 /** Parse a sample format text. Inverse of pa_sample_format_to_string() */
-pa_sample_format_t pa_parse_sample_format(const char *format);
+pa_sample_format_t pa_parse_sample_format(const char *format) PA_GCC_PURE;
 
 /** Maximum required string length for pa_sample_spec_snprint() */
 #define PA_SAMPLE_SPEC_SNPRINT_MAX 32

Modified: branches/lennart/src/pulse/timeval.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/timeval.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulse/timeval.h (original)
+++ branches/lennart/src/pulse/timeval.h Mon Sep 17 00:42:03 2007
@@ -44,16 +44,16 @@
 
 /** Calculate the difference between the two specified timeval
  * structs. */
-pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b);
+pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) PA_GCC_PURE;
 
 /** Compare the two timeval structs and return 0 when equal, negative when a < b, positive otherwse */
-int pa_timeval_cmp(const struct timeval *a, const struct timeval *b);
+int pa_timeval_cmp(const struct timeval *a, const struct timeval *b) PA_GCC_PURE;
 
 /** Return the time difference between now and the specified timestamp */
 pa_usec_t pa_timeval_age(const struct timeval *tv);
 
 /** Add the specified time inmicroseconds to the specified timeval structure */
-struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v);
+struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) PA_GCC_PURE;
 
 PA_C_DECL_END
 

Modified: branches/lennart/src/pulse/utf8.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/utf8.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulse/utf8.h (original)
+++ branches/lennart/src/pulse/utf8.h Mon Sep 17 00:42:03 2007
@@ -34,7 +34,7 @@
 PA_C_DECL_BEGIN
 
 /** Test if the specified strings qualifies as valid UTF8. Return the string if so, otherwise NULL */
-char *pa_utf8_valid(const char *str);
+char *pa_utf8_valid(const char *str) PA_GCC_PURE;
 
 /** Filter all invalid UTF8 characters from the specified string, returning a new fully UTF8 valid string. Don't forget to free the returned string with pa_xfree() */
 char *pa_utf8_filter(const char *str);

Modified: branches/lennart/src/pulse/volume.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/volume.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulse/volume.h (original)
+++ branches/lennart/src/pulse/volume.h Mon Sep 17 00:42:03 2007
@@ -113,7 +113,7 @@
 } pa_cvolume;
 
 /** Return non-zero when *a == *b */
-int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b);
+int pa_cvolume_equal(const pa_cvolume *a, const pa_cvolume *b) PA_GCC_PURE;
 
 /** Set the volume of all channels to PA_VOLUME_NORM */
 #define pa_cvolume_reset(a, n) pa_cvolume_set((a), (n), PA_VOLUME_NORM)
@@ -131,13 +131,13 @@
 char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c);
 
 /** Return the average volume of all channels */
-pa_volume_t pa_cvolume_avg(const pa_cvolume *a);
+pa_volume_t pa_cvolume_avg(const pa_cvolume *a) PA_GCC_PURE;
 
 /** Return TRUE when the passed cvolume structure is valid, FALSE otherwise */
-int pa_cvolume_valid(const pa_cvolume *v);
+int pa_cvolume_valid(const pa_cvolume *v) PA_GCC_PURE;
 
 /** Return non-zero if the volume of all channels is equal to the specified value */
-int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v);
+int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) PA_GCC_PURE;
 
 /** Return 1 if the specified volume has all channels muted */
 #define pa_cvolume_is_muted(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_MUTED)
@@ -146,22 +146,22 @@
 #define pa_cvolume_is_norm(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_NORM)
 
 /** Multiply two volumes specifications, return the result. This uses PA_VOLUME_NORM as neutral element of multiplication. This is only valid for software volumes! */
-pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b);
+pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b) PA_GCC_CONST;
 
 /** Multiply to per-channel volumes and return the result in *dest. This is only valid for software volumes! */
-pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
+pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b) PA_GCC_PURE;
 
 /** Convert a decibel value to a volume. This is only valid for software volumes! \since 0.4 */
-pa_volume_t pa_sw_volume_from_dB(double f);
+pa_volume_t pa_sw_volume_from_dB(double f) PA_GCC_CONST;
 
 /** Convert a volume to a decibel value. This is only valid for software volumes! \since 0.4 */
-double pa_sw_volume_to_dB(pa_volume_t v);
+double pa_sw_volume_to_dB(pa_volume_t v) PA_GCC_CONST;
 
 /** Convert a linear factor to a volume. This is only valid for software volumes! \since 0.8 */
-pa_volume_t pa_sw_volume_from_linear(double v);
+pa_volume_t pa_sw_volume_from_linear(double v) PA_GCC_CONST;
 
 /** Convert a volume to a linear factor. This is only valid for software volumes! \since 0.8 */
-double pa_sw_volume_to_linear(pa_volume_t v);
+double pa_sw_volume_to_linear(pa_volume_t v) PA_GCC_CONST;
 
 #ifdef INFINITY
 #define PA_DECIBEL_MININFTY (-INFINITY)

Modified: branches/lennart/src/pulsecore/core-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/core-util.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/core-util.h (original)
+++ branches/lennart/src/pulsecore/core-util.h Mon Sep 17 00:42:03 2007
@@ -61,14 +61,14 @@
 
 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 @@
 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);
 

Modified: branches/lennart/src/pulsecore/gccmacro.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/gccmacro.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/gccmacro.h (original)
+++ branches/lennart/src/pulsecore/gccmacro.h Mon Sep 17 00:42:03 2007
@@ -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

Modified: branches/lennart/src/pulsecore/sample-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/sample-util.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/sample-util.h (original)
+++ branches/lennart/src/pulsecore/sample-util.h Mon Sep 17 00:42:03 2007
@@ -56,8 +56,8 @@
     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

Modified: branches/lennart/src/pulsecore/sconv.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/sconv.h?rev=1835&root=pulseaudio&r1=1834&r2=1835&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/sconv.h (original)
+++ branches/lennart/src/pulsecore/sconv.h Mon Sep 17 00:42:03 2007
@@ -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




More information about the pulseaudio-commits mailing list