aboutsummaryrefslogtreecommitdiff
path: root/include/libtio/cdefs.h
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-08-30 11:52:30 +0200
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-08-30 11:52:30 +0200
commit54e75699b06aa9d2e4f276239bf062ba46142055 (patch)
tree255385c664d97a61d12a4b4da8b6a70506a67041 /include/libtio/cdefs.h
Compiles now.
Diffstat (limited to 'include/libtio/cdefs.h')
-rw-r--r--include/libtio/cdefs.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/include/libtio/cdefs.h b/include/libtio/cdefs.h
new file mode 100644
index 0000000..c63e99a
--- /dev/null
+++ b/include/libtio/cdefs.h
@@ -0,0 +1,102 @@
+/* Pre-ANSI C compilers don't support arguments (and argument types) in
+ * function declarations. This macro is inspired from zlib.
+ *
+ * It is defined outside of the include guard because it is not in
+ * the libtio defined namespace, so we want it to be redefined, in case. */
+
+#if defined(OF)
+#elif defined(__STDC__) && __STDC__
+# define OF(TIO__ARGS) TIO__ARGS
+#else
+# define OF(TIO__ARGS) ()
+#endif
+
+/* "Normal start" of the file is here. */
+
+#ifndef LIBTIO_CDEFS_H
+# define LIBTIO_CDEFS_H 20180710
+# include "config.h"
+# include <stddef.h>
+# include <time.h>
+
+/* Check the library version. */
+
+# define TIO_PREREQ(TIO__MAJ, TIO__MIN) \
+ ((TIO__MAJ) > (LIBTIO_MAJOR) || \
+ ((TIO__MAJ) == (LIBTIO_MAJOR) && (TIO__MIN) >= (LIBTIO_MINOR)))
+
+/* ---
+ * Check for compilers.
+ * --- */
+
+/* First, GCC. */
+
+# if defined(TIO_GNUC_PREREQ)
+# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
+# define TIO_GNUC_PREREQ(TIO__MAJ, TIO__MIN) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((TIO__MAJ) << 16) + (TIO__MIN))
+# else
+# define TIO_GNUC_PREREQ(TIO__MAJ, TIO__MIN) 0
+# endif
+
+/* Then, Microsoft's Compiler. */
+
+# if defined(TIO_MSC_PREREQ) || defined(_MSC_VER)
+# define TIO_MSC_PREREQ(TIO__MAJ, TIO__MIN) \
+ (_MSC_VER >= (TIO__MAJ) * 1000 + (TIO__MIN))
+# else
+# define TIO_MSC_PREREQ(TIO__MAJ, TIO__MIN) 0
+# endif
+
+/* ---
+ * Others.
+ * --- */
+
+/* Warn if the function is deprecated. */
+
+# if TIO_GNUC_PREREQ(3, 0)
+# define TIO_DEPRECATED __attribute__((deprecated))
+# else
+# define TIO_DEPRECATED
+# endif
+
+/* Some platforms require more than simply 'extern'.
+ * Here are macros to control this. */
+
+# define TIO_EXTERN extern
+# define TIO_EXPORT
+# define TIO_LOCAL static
+
+/* Also, libtio is made in C, so we might as well define what we want
+ * for C++. */
+
+# ifdef __cplusplus
+# define TIO_BEGIN_NAMESPACE namespace "libtio" {
+# define TIO_BEGIN_DECLS extern "C" {
+# define TIO_END_DECLS }
+# define TIO_END_NAMESPACE }
+# else
+# define TIO_BEGIN_NAMESPACE
+# define TIO_BEGIN_DECLS
+# define TIO_END_DECLS
+# define TIO_END_NAMESPACE
+# endif
+
+/* ---
+ * Utilities.
+ * --- */
+
+TIO_BEGIN_NAMESPACE
+TIO_BEGIN_DECLS
+
+/* Memory allocation utilities. */
+
+TIO_EXTERN void *TIO_EXPORT tio_alloc
+ OF((size_t tio__count, size_t tio__size));
+TIO_EXTERN void TIO_EXPORT tio_free
+ OF((void *tio__mem));
+
+TIO_END_DECLS
+TIO_END_NAMESPACE
+
+#endif /* LIBTIO_CDEFS_H */