Mesa (master): c11/threads: don' t include assert.h if the assert macro is already defined
Brian Paul
brianp at kemper.freedesktop.org
Wed Mar 19 23:15:02 UTC 2014
Module: Mesa
Branch: master
Commit: eaf9affa5ec9c5fd919e4207ab80b4677650ac67
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=eaf9affa5ec9c5fd919e4207ab80b4677650ac67
Author: Brian Paul <brianp at vmware.com>
Date: Tue Mar 18 17:25:07 2014 -0600
c11/threads: don't include assert.h if the assert macro is already defined
In the gallium code, the assert() macro could come from either the
system's assert.h file (via c11/threads.h) or from gallium's u_debug.h.
It looks like all known assert.h files unconditionally #undef assert
before defining their own version. So the assert you get depends on
whether threads.h or u_debug.h was included last.
In the gallium code we really want to use the assert() from u_debug.h
(it behaves better on Windows). In gallium, c11/threads.h is only
included after u_debug.h in the os_thread.h wrapper. So Adding
an #ifndef assert test in the threads*.h files avoids using the system's
assert().
Cc: "10.1" <mesa-stable at lists.freedesktop.org>
Reviewed-by: José Fonseca <jfonseca at vmware.com>
---
include/c11/threads_posix.h | 2 ++
include/c11/threads_win32.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h
index 7e96715..f9c165d 100644
--- a/include/c11/threads_posix.h
+++ b/include/c11/threads_posix.h
@@ -27,7 +27,9 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
+#ifndef assert
#include <assert.h>
+#endif
#include <limits.h>
#include <errno.h>
#include <unistd.h>
diff --git a/include/c11/threads_win32.h b/include/c11/threads_win32.h
index d4c2a72..5298a84 100644
--- a/include/c11/threads_win32.h
+++ b/include/c11/threads_win32.h
@@ -26,7 +26,9 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
+#ifndef assert
#include <assert.h>
+#endif
#include <limits.h>
#include <errno.h>
#include <process.h> // MSVCRT
More information about the mesa-commit
mailing list