aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2019-01-13 13:10:47 -0500
committerTaylor Holberton <taylorcholberton@gmail.com>2019-01-13 13:10:47 -0500
commitbc86b6b288bfaac9fc15392fcc43b8e5789a7f15 (patch)
tree42a45c601ceb1fe074f9d18469361f7e948394b0 /include
parentb38b6a670c359e497926d799cea4d9c80d561eab (diff)
Added the 'attributes.h' header
Diffstat (limited to 'include')
-rw-r--r--include/tinyalsa/attributes.h39
-rw-r--r--include/tinyalsa/pcm.h28
2 files changed, 49 insertions, 18 deletions
diff --git a/include/tinyalsa/attributes.h b/include/tinyalsa/attributes.h
new file mode 100644
index 0000000..e33f46a
--- /dev/null
+++ b/include/tinyalsa/attributes.h
@@ -0,0 +1,39 @@
+#ifndef TINYALSA_ATTRIBUTES_H
+#define TINYALSA_ATTRIBUTES_H
+
+/** @defgroup libtinyalsa-attributes
+ * @brief GCC attributes to issue diagnostics
+ * when the library is being used incorrectly.
+ * */
+
+#ifdef __GNUC__
+
+/** Issues a warning when a function is being
+ * used that is now deprecated.
+ * @ingroup libtinyalsa-attributes
+ * */
+#define TINYALSA_DEPRECATED __attribute__((deprecated))
+
+/** Issues a warning when a return code of
+ * a function is not checked.
+ * @ingroup libtinyalsa-attributes
+ * */
+#define TINYALSA_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+
+#else /* __GNUC__ */
+
+/** This is just a placeholder for compilers
+ * that aren't GCC or Clang.
+ * @ingroup libtinyalsa-attributes
+ * */
+#define TINYALSA_DEPRECATED
+
+/** This is just a placeholder for compilers
+ * that aren't GCC or Clang.
+ * @ingroup libtinyalsa-attributes
+ * */
+#define TINYALSA_WARN_UNUSED_RESULT
+
+#endif /* __GNUC__ */
+
+#endif /* TINYALSA_ATTRIBUTES_H */
diff --git a/include/tinyalsa/pcm.h b/include/tinyalsa/pcm.h
index 46c9b94..36aaf85 100644
--- a/include/tinyalsa/pcm.h
+++ b/include/tinyalsa/pcm.h
@@ -35,13 +35,11 @@
#ifndef TINYALSA_PCM_H
#define TINYALSA_PCM_H
+#include <tinyalsa/attributes.h>
+
#include <sys/time.h>
#include <stddef.h>
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
/** A flag that specifies that the PCM is an output.
* May not be bitwise AND'd with @ref PCM_IN.
* Used in @ref pcm_open.
@@ -128,6 +126,10 @@ extern "C" {
*/
#define PCM_STATE_DISCONNECTED 0x08
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
/** Audio sample format of a PCM.
* The first letter specifiers whether the sample is signed or unsigned.
* The letter 'S' means signed. The letter 'U' means unsigned.
@@ -284,23 +286,13 @@ int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, struct timespec *ts
unsigned int pcm_get_subdevice(const struct pcm *pcm);
-int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count);
-
-int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count);
-
-#ifdef __GNUC__
-
-int pcm_write(struct pcm *pcm, const void *data, unsigned int count) __attribute((deprecated));
+int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) TINYALSA_WARN_UNUSED_RESULT;
-int pcm_read(struct pcm *pcm, void *data, unsigned int count) __attribute((deprecated));
+int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count) TINYALSA_WARN_UNUSED_RESULT;
-#else
+int pcm_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DEPRECATED;
-int pcm_write(struct pcm *pcm, const void *data, unsigned int count);
-
-int pcm_read(struct pcm *pcm, void *data, unsigned int count);
-
-#endif
+int pcm_read(struct pcm *pcm, void *data, unsigned int count) TINYALSA_DEPRECATED;
int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count);