diff mbox

[API-NEXT,1/2] drv: adding compiler.h

Message ID 1455698659-26695-1-git-send-email-christophe.milard@linaro.org
State Superseded
Headers show

Commit Message

Christophe Milard Feb. 17, 2016, 8:44 a.m. UTC
The file is, of course, largely inspired from its equivalent on the
application interface.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>
---
 include/odp/drv/spec/compiler.h | 51 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 include/odp/drv/spec/compiler.h
diff mbox

Patch

diff --git a/include/odp/drv/spec/compiler.h b/include/odp/drv/spec/compiler.h
new file mode 100644
index 0000000..3198d21
--- /dev/null
+++ b/include/odp/drv/spec/compiler.h
@@ -0,0 +1,51 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * Compiler related for ODP driver interface
+ */
+
+#ifndef ODPDRV_COMPILER_H_
+#define ODPDRV_COMPILER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @addtogroup odpdrv_compiler_optim ODPDRV COMPILER / OPTIMIZATION
+ *  Macro for old compilers
+ *  @{
+ */
+
+/** @internal GNU compiler version */
+#define GCC_VERSION (__GNUC__ * 10000 \
+			+ __GNUC_MINOR__ * 100 \
+			+ __GNUC_PATCHLEVEL__)
+
+/**
+ * @internal
+ * Compiler __builtin_bswap16() is not available on all platforms
+ * until GCC 4.8.0 - work around this by offering __odpdrv_builtin_bswap16()
+ * Don't use this function directly, instead see odpdrv byteorder.h
+ */
+#if GCC_VERSION < 40800
+#define __odpdrv_builtin_bswap16(u16) \
+				((((u16)&0x00ff) << 8) | (((u16)&0xff00) >> 8))
+#else
+#define __odpdrv_builtin_bswap16(u16) __builtin_bswap16(u16)
+#endif
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif