<br><br><div class="gmail_quote">On Tue, Mar 12, 2013 at 3:39 PM, <span dir="ltr"><<a href="mailto:jfonseca@vmware.com" target="_blank">jfonseca@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: José Fonseca <<a href="mailto:jfonseca@vmware.com">jfonseca@vmware.com</a>><br>
<br>
We were in four already...<br>
---<br>
include/c99_compat.h | 105 +++++++++++++++++++++++++++++++++<br>
src/egl/main/eglcompiler.h | 44 ++------------<br>
src/gallium/include/pipe/p_compiler.h | 74 ++---------------------<br>
src/mapi/mapi/u_compiler.h | 26 ++------<br>
src/mesa/main/compiler.h | 56 ++----------------<br>
5 files changed, 125 insertions(+), 180 deletions(-)<br>
create mode 100644 include/c99_compat.h<br>
<br>
diff --git a/include/c99_compat.h b/include/c99_compat.h<br>
new file mode 100644<br>
index 0000000..39f958f<br>
--- /dev/null<br>
+++ b/include/c99_compat.h<br>
@@ -0,0 +1,105 @@<br>
+/**************************************************************************<br>
+ *<br>
+ * Copyright 2007-2013 VMware, Inc.<br>
+ * All Rights Reserved.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the<br>
+ * "Software"), to deal in the Software without restriction, including<br>
+ * without limitation the rights to use, copy, modify, merge, publish,<br>
+ * distribute, sub license, and/or sell copies of the Software, and to<br>
+ * permit persons to whom the Software is furnished to do so, subject to<br>
+ * the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the<br>
+ * next paragraph) shall be included in all copies or substantial portions<br>
+ * of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS<br>
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.<br>
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR<br>
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br>
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE<br>
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+ *<br>
+ **************************************************************************/<br>
+<br>
+#ifndef _C99_COMPAT_H_<br>
+#define _C99_COMPAT_H_<br>
+<br>
+<br>
+/*<br>
+ * C99 inline keyword<br>
+ */<br>
+#ifndef inline<br>
+# ifdef __cplusplus<br>
+ /* C++ supports inline keyword */<br>
+# elif defined(__GNUC__)<br>
+# define inline __inline__<br>
+# elif defined(_MSC_VER)<br>
+# define inline __inline<br>
+# elif defined(__ICL)<br>
+# define inline __inline<br>
+# elif defined(__INTEL_COMPILER)<br>
+ /* Intel compiler supports inline keyword */<br>
+# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)<br>
+# define inline __inline<br>
+# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)<br></blockquote><div><br></div><div>Solaris Studio supports __inline and __inline__ </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ /* C99 supports inline keyword */<br>
+# elif (__STDC_VERSION__ >= 199901L)<br>
+ /* C99 supports inline keyword */<br>
+# else<br>
+# define inline<br>
+# endif<br>
+#endif<br>
</blockquote><div><br></div><div><br></div><div>The order of the checks will not work as expected. Intel's compiler will define __GNUC__, and so will clang. The check for __GNUC__ has to be the last one.</div><div><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+<br>
+<br>
+/*<br>
+ * C99 restrict keyword<br>
+ *<br>
+ * See also:<br>
+ * - <a href="http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html" target="_blank">http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html</a><br>
+ */<br>
+#ifndef restrict<br>
+# if (__STDC_VERSION__ >= 199901L)<br>
+ /* C99 */<br>
+# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)<br>
+ /* C99 */<br></blockquote><div><br></div><div>Solaris Studio supports "_Restrict" when not in C99 mode as well. </div><div><br></div><div>#define restrict _Restrict</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+# elif defined(__GNUC__)<br>
+# define restrict __restrict__<br>
+# elif defined(_MSC_VER)<br>
+# define restrict __restrict<br>
+# else<br>
+# define restrict /* */<br>
+# endif<br>
+#endif<br>
+<br>
+<br>
+/*<br>
+ * C99 __func__ macro<br>
+ */<br>
+#ifndef __func__<br>
+# if (__STDC_VERSION__ >= 199901L)<br>
+ /* C99 */<br>
+# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)<br>
+ /* C99 */<br></blockquote><div><br></div><div>Solaris Studio supports __FUNCTION__ when not in C99 mode.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+# elif defined(__GNUC__)<br>
+# if __GNUC__ >= 2<br>
+# define __func__ __FUNCTION__<br>
+# else<br>
+# define __func__ "<unknown>"<br>
+# endif<br>
+# elif defined(_MSC_VER)<br>
+# if _MSC_VER >= 1300<br>
+# define __func__ __FUNCTION__<br>
+# else<br>
+# define __func__ "<unknown>"<br>
+# endif<br>
+# else<br>
+# define __func__ "<unknown>"<br>
+# endif<br>
+#endif<br>
+<br>
+<br>
+#endif /* _C99_COMPAT_H_ */<br>
diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h<br>
index 9823693..2499172 100644<br>
--- a/src/egl/main/eglcompiler.h<br>
+++ b/src/egl/main/eglcompiler.h<br>
@@ -31,6 +31,9 @@<br>
#define EGLCOMPILER_INCLUDED<br>
<br>
<br>
+#include "c99_compat.h" /* inline, __func__, etc. */<br>
+<br>
+<br>
/**<br>
* Get standard integer types<br>
*/<br>
@@ -62,30 +65,7 @@<br>
#endif<br>
<br>
<br>
-/**<br>
- * Function inlining<br>
- */<br>
-#ifndef inline<br>
-# ifdef __cplusplus<br>
- /* C++ supports inline keyword */<br>
-# elif defined(__GNUC__)<br>
-# define inline __inline__<br>
-# elif defined(_MSC_VER)<br>
-# define inline __inline<br>
-# elif defined(__ICL)<br>
-# define inline __inline<br>
-# elif defined(__INTEL_COMPILER)<br>
- /* Intel compiler supports inline keyword */<br>
-# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)<br>
-# define inline __inline<br>
-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)<br>
- /* C99 supports inline keyword */<br>
-# elif (__STDC_VERSION__ >= 199901L)<br>
- /* C99 supports inline keyword */<br>
-# else<br>
-# define inline<br>
-# endif<br>
-#endif<br>
+/* XXX: Use standard `inline` keyword instead */<br>
#ifndef INLINE<br>
# define INLINE inline<br>
#endif<br>
@@ -104,21 +84,9 @@<br>
# endif<br>
#endif<br>
<br>
-/**<br>
- * The __FUNCTION__ gcc variable is generally only used for debugging.<br>
- * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.<br>
- * Don't define it if using a newer Windows compiler.<br>
- */<br>
+/* XXX: Use standard `__func__` instead */<br>
#ifndef __FUNCTION__<br>
-# if (!defined __GNUC__) && (!defined __xlC__) && \<br>
- (!defined(_MSC_VER) || _MSC_VER < 1300)<br>
-# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \<br>
- (defined(__SUNPRO_C) && defined(__C99FEATURES__))<br>
-# define __FUNCTION__ __func__<br>
-# else<br>
-# define __FUNCTION__ "<unknown>"<br>
-# endif<br>
-# endif<br>
+# define __FUNCTION__ __func__<br>
#endif<br>
<br>
#endif /* EGLCOMPILER_INCLUDED */<br>
diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h<br>
index 5958333..a131969 100644<br>
--- a/src/gallium/include/pipe/p_compiler.h<br>
+++ b/src/gallium/include/pipe/p_compiler.h<br>
@@ -29,6 +29,8 @@<br>
#define P_COMPILER_H<br>
<br>
<br>
+#include "c99_compat.h" /* inline, __func__, etc. */<br>
+<br>
#include "p_config.h"<br>
<br>
#include <stdlib.h><br>
@@ -90,28 +92,7 @@ typedef unsigned char boolean;<br>
#endif<br>
#endif<br>
<br>
-/* Function inlining */<br>
-#ifndef inline<br>
-# ifdef __cplusplus<br>
- /* C++ supports inline keyword */<br>
-# elif defined(__GNUC__)<br>
-# define inline __inline__<br>
-# elif defined(_MSC_VER)<br>
-# define inline __inline<br>
-# elif defined(__ICL)<br>
-# define inline __inline<br>
-# elif defined(__INTEL_COMPILER)<br>
- /* Intel compiler supports inline keyword */<br>
-# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)<br>
-# define inline __inline<br>
-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)<br>
- /* C99 supports inline keyword */<br>
-# elif (__STDC_VERSION__ >= 199901L)<br>
- /* C99 supports inline keyword */<br>
-# else<br>
-# define inline<br>
-# endif<br>
-#endif<br>
+/* XXX: Use standard `inline` keyword instead */<br>
#ifndef INLINE<br>
# define INLINE inline<br>
#endif<br>
@@ -127,26 +108,6 @@ typedef unsigned char boolean;<br>
# endif<br>
#endif<br>
<br>
-/*<br>
- * Define the C99 restrict keyword.<br>
- *<br>
- * See also:<br>
- * - <a href="http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html" target="_blank">http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html</a><br>
- */<br>
-#ifndef restrict<br>
-# if (__STDC_VERSION__ >= 199901L)<br>
- /* C99 */<br>
-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)<br>
- /* C99 */<br>
-# elif defined(__GNUC__)<br>
-# define restrict __restrict__<br>
-# elif defined(_MSC_VER)<br>
-# define restrict __restrict<br>
-# else<br>
-# define restrict /* */<br>
-# endif<br>
-#endif<br>
-<br>
<br>
/* Function visibility */<br>
#ifndef PUBLIC<br>
@@ -160,35 +121,10 @@ typedef unsigned char boolean;<br>
#endif<br>
<br>
<br>
-/* The __FUNCTION__ gcc variable is generally only used for debugging.<br>
- * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.<br>
- */<br>
+/* XXX: Use standard `__func__` instead */<br>
#ifndef __FUNCTION__<br>
-# if !defined(__GNUC__)<br>
-# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \<br>
- (defined(__SUNPRO_C) && defined(__C99FEATURES__))<br>
-# define __FUNCTION__ __func__<br>
-# else<br>
-# define __FUNCTION__ "<unknown>"<br>
-# endif<br>
-# endif<br>
-# if defined(_MSC_VER) && _MSC_VER < 1300<br>
-# define __FUNCTION__ "<unknown>"<br>
-# endif<br>
+# define __FUNCTION__ __func__<br>
#endif<br>
-#ifndef __func__<br>
-# if (__STDC_VERSION__ >= 199901L) || \<br>
- (defined(__SUNPRO_C) && defined(__C99FEATURES__))<br>
- /* __func__ is part of C99 */<br>
-# elif defined(_MSC_VER)<br>
-# if _MSC_VER >= 1300<br>
-# define __func__ __FUNCTION__<br>
-# else<br>
-# define __func__ "<unknown>"<br>
-# endif<br>
-# endif<br>
-#endif<br>
-<br>
<br>
<br>
/* This should match linux gcc cdecl semantics everywhere, so that we<br>
diff --git a/src/mapi/mapi/u_compiler.h b/src/mapi/mapi/u_compiler.h<br>
index 2b019ed..f376e97 100644<br>
--- a/src/mapi/mapi/u_compiler.h<br>
+++ b/src/mapi/mapi/u_compiler.h<br>
@@ -1,28 +1,10 @@<br>
#ifndef _U_COMPILER_H_<br>
#define _U_COMPILER_H_<br>
<br>
-/* Function inlining */<br>
-#ifndef inline<br>
-# ifdef __cplusplus<br>
- /* C++ supports inline keyword */<br>
-# elif defined(__GNUC__)<br>
-# define inline __inline__<br>
-# elif defined(_MSC_VER)<br>
-# define inline __inline<br>
-# elif defined(__ICL)<br>
-# define inline __inline<br>
-# elif defined(__INTEL_COMPILER)<br>
- /* Intel compiler supports inline keyword */<br>
-# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)<br>
-# define inline __inline<br>
-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)<br>
- /* C99 supports inline keyword */<br>
-# elif (__STDC_VERSION__ >= 199901L)<br>
- /* C99 supports inline keyword */<br>
-# else<br>
-# define inline<br>
-# endif<br>
-#endif<br>
+#include "c99_compat.h" /* inline, __func__, etc. */<br>
+<br>
+<br>
+/* XXX: Use standard `inline` keyword instead */<br>
#ifndef INLINE<br>
# define INLINE inline<br>
#endif<br>
diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h<br>
index b22b994..4871248 100644<br>
--- a/src/mesa/main/compiler.h<br>
+++ b/src/mesa/main/compiler.h<br>
@@ -48,6 +48,8 @@<br>
#include <float.h><br>
#include <stdarg.h><br>
<br>
+#include "c99_compat.h" /* inline, __func__, etc. */<br>
+<br>
<br>
#ifdef __cplusplus<br>
extern "C" {<br>
@@ -111,30 +113,7 @@ extern "C" {<br>
<br>
<br>
<br>
-/**<br>
- * Function inlining<br>
- */<br>
-#ifndef inline<br>
-# ifdef __cplusplus<br>
- /* C++ supports inline keyword */<br>
-# elif defined(__GNUC__)<br>
-# define inline __inline__<br>
-# elif defined(_MSC_VER)<br>
-# define inline __inline<br>
-# elif defined(__ICL)<br>
-# define inline __inline<br>
-# elif defined(__INTEL_COMPILER)<br>
- /* Intel compiler supports inline keyword */<br>
-# elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)<br>
-# define inline __inline<br>
-# elif defined(__SUNPRO_C) && defined(__C99FEATURES__)<br>
- /* C99 supports inline keyword */<br>
-# elif (__STDC_VERSION__ >= 199901L)<br>
- /* C99 supports inline keyword */<br>
-# else<br>
-# define inline<br>
-# endif<br>
-#endif<br>
+/* XXX: Use standard `inline` keyword instead */<br>
#ifndef INLINE<br>
# define INLINE inline<br>
#endif<br>
@@ -177,35 +156,10 @@ extern "C" {<br>
# endif<br>
#endif<br>
<br>
-/**<br>
- * The __FUNCTION__ gcc variable is generally only used for debugging.<br>
- * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.<br>
- * Don't define it if using a newer Windows compiler.<br>
- */<br>
+/* XXX: Use standard `__func__` instead */<br>
#ifndef __FUNCTION__<br>
-# if !defined(__GNUC__) && !defined(__xlC__) && \<br>
- (!defined(_MSC_VER) || _MSC_VER < 1300)<br>
-# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \<br>
- (defined(__SUNPRO_C) && defined(__C99FEATURES__))<br>
-# define __FUNCTION__ __func__<br>
-# else<br>
-# define __FUNCTION__ "<unknown>"<br>
-# endif<br>
-# endif<br>
+# define __FUNCTION__ __func__<br>
#endif<br>
-#ifndef __func__<br>
-# if (__STDC_VERSION__ >= 199901L) || \<br>
- (defined(__SUNPRO_C) && defined(__C99FEATURES__))<br>
- /* __func__ is part of C99 */<br>
-# elif defined(_MSC_VER)<br>
-# if _MSC_VER >= 1300<br>
-# define __func__ __FUNCTION__<br>
-# else<br>
-# define __func__ "<unknown>"<br>
-# endif<br>
-# endif<br>
-#endif<br>
-<br>
<br>
/**<br>
* Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32.<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.9.5<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>