aboutsummaryrefslogtreecommitdiff
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
parentb38b6a670c359e497926d799cea4d9c80d561eab (diff)
Added the 'attributes.h' header
-rw-r--r--CMakeLists.txt1
-rw-r--r--Makefile1
-rw-r--r--include/tinyalsa/attributes.h39
-rw-r--r--include/tinyalsa/pcm.h28
4 files changed, 51 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c78dbf..cb31c58 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.0.2)
project("TinyALSA" C)
set (HDRS
+ "include/tinyalsa/attributes.h"
"include/tinyalsa/version.h"
"include/tinyalsa/asoundlib.h"
"include/tinyalsa/pcm.h"
diff --git a/Makefile b/Makefile
index 7042a3c..e3ed0ef 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ clean:
.PHONY: install
install:
install -d $(DESTDIR)$(INCDIR)/
+ install include/tinyalsa/attributes.h $(DESTDIR)$(INCDIR)/
install include/tinyalsa/pcm.h $(DESTDIR)$(INCDIR)/
install include/tinyalsa/mixer.h $(DESTDIR)$(INCDIR)/
install include/tinyalsa/asoundlib.h $(DESTDIR)$(INCDIR)/
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);