[Mesa-dev] [PATCH 1/2] util: Make unreachable at least be an assert

2014-12-05 Thread Carl Worth
Previously, if __builtin_unreachable() was unavailable, the
unreachable macro was defined to do nothing. We do better here, by at
least still making it an assert.
---
 src/util/macros.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/macros.h b/src/util/macros.h
index 5fc6729..eec8b93 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -82,7 +82,7 @@ do {\
 #endif
 
 #ifndef unreachable
-#define unreachable(str)
+#define unreachable(str) assert(!str)
 #endif
 
 /**
-- 
2.1.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] util: Make unreachable at least be an assert

2014-12-05 Thread Ian Romanick
On 12/05/2014 01:17 PM, Carl Worth wrote:
 Previously, if __builtin_unreachable() was unavailable, the
 unreachable macro was defined to do nothing. We do better here, by at
 least still making it an assert.
 ---
  src/util/macros.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/util/macros.h b/src/util/macros.h
 index 5fc6729..eec8b93 100644
 --- a/src/util/macros.h
 +++ b/src/util/macros.h
 @@ -82,7 +82,7 @@ do {\
  #endif
  
  #ifndef unreachable
 -#define unreachable(str)
 +#define unreachable(str) assert(!str)

I'd make this ASSERT.  In Mesa, ASSERT only exists if DEBUG is defined.
 It seems that many distros build without -DDEBUG and without -DNDEBUG.
 I'd rather have no code for these cases in all release builds.

With that changed, this patch is

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

  #endif
  
  /**
 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] util: Make unreachable at least be an assert

2014-12-05 Thread Matt Turner
On Fri, Dec 5, 2014 at 1:25 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/05/2014 01:17 PM, Carl Worth wrote:
 Previously, if __builtin_unreachable() was unavailable, the
 unreachable macro was defined to do nothing. We do better here, by at
 least still making it an assert.
 ---
  src/util/macros.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/util/macros.h b/src/util/macros.h
 index 5fc6729..eec8b93 100644
 --- a/src/util/macros.h
 +++ b/src/util/macros.h
 @@ -82,7 +82,7 @@ do {\
  #endif

  #ifndef unreachable
 -#define unreachable(str)
 +#define unreachable(str) assert(!str)

 I'd make this ASSERT.  In Mesa, ASSERT only exists if DEBUG is defined.
  It seems that many distros build without -DDEBUG and without -DNDEBUG.
  I'd rather have no code for these cases in all release builds.

I'm surprised by that.

I see that we add -DDEBUG with --enable-debug, but from experience
assert() does nothing in my regular release build (without
--enable-debug). Where is NDEBUG coming from in that case? I don't see
it in the macros gcc automatically defines (gcc -g -dM -E - 
/dev/null).
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] util: Make unreachable at least be an assert

2014-12-05 Thread Ian Romanick
On 12/05/2014 01:42 PM, Matt Turner wrote:
 On Fri, Dec 5, 2014 at 1:25 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/05/2014 01:17 PM, Carl Worth wrote:
 Previously, if __builtin_unreachable() was unavailable, the
 unreachable macro was defined to do nothing. We do better here, by at
 least still making it an assert.
 ---
  src/util/macros.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/util/macros.h b/src/util/macros.h
 index 5fc6729..eec8b93 100644
 --- a/src/util/macros.h
 +++ b/src/util/macros.h
 @@ -82,7 +82,7 @@ do {\
  #endif

  #ifndef unreachable
 -#define unreachable(str)
 +#define unreachable(str) assert(!str)

 I'd make this ASSERT.  In Mesa, ASSERT only exists if DEBUG is defined.
  It seems that many distros build without -DDEBUG and without -DNDEBUG.
  I'd rather have no code for these cases in all release builds.
 
 I'm surprised by that.
 
 I see that we add -DDEBUG with --enable-debug, but from experience
 assert() does nothing in my regular release build (without
 --enable-debug). Where is NDEBUG coming from in that case? I don't see
 it in the macros gcc automatically defines (gcc -g -dM -E - 
 /dev/null).

Right... and you need NDEBUG to no-op assert.  It has to be added by
hand, and it seems that the distros don't.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] util: Make unreachable at least be an assert

2014-12-05 Thread Matt Turner
On Fri, Dec 5, 2014 at 1:48 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/05/2014 01:42 PM, Matt Turner wrote:
 On Fri, Dec 5, 2014 at 1:25 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/05/2014 01:17 PM, Carl Worth wrote:
 Previously, if __builtin_unreachable() was unavailable, the
 unreachable macro was defined to do nothing. We do better here, by at
 least still making it an assert.
 ---
  src/util/macros.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/util/macros.h b/src/util/macros.h
 index 5fc6729..eec8b93 100644
 --- a/src/util/macros.h
 +++ b/src/util/macros.h
 @@ -82,7 +82,7 @@ do {\
  #endif

  #ifndef unreachable
 -#define unreachable(str)
 +#define unreachable(str) assert(!str)

 I'd make this ASSERT.  In Mesa, ASSERT only exists if DEBUG is defined.
  It seems that many distros build without -DDEBUG and without -DNDEBUG.
  I'd rather have no code for these cases in all release builds.

 I'm surprised by that.

 I see that we add -DDEBUG with --enable-debug, but from experience
 assert() does nothing in my regular release build (without
 --enable-debug). Where is NDEBUG coming from in that case? I don't see
 it in the macros gcc automatically defines (gcc -g -dM -E - 
 /dev/null).

 Right... and you need NDEBUG to no-op assert.  It has to be added by
 hand, and it seems that the distros don't.

But I don't get assert()s in release builds, and I'm not adding NDEBUG anywhere.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] util: Make unreachable at least be an assert

2014-12-05 Thread Ian Romanick
On 12/05/2014 01:50 PM, Matt Turner wrote:
 On Fri, Dec 5, 2014 at 1:48 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/05/2014 01:42 PM, Matt Turner wrote:
 On Fri, Dec 5, 2014 at 1:25 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/05/2014 01:17 PM, Carl Worth wrote:
 Previously, if __builtin_unreachable() was unavailable, the
 unreachable macro was defined to do nothing. We do better here, by at
 least still making it an assert.
 ---
  src/util/macros.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/util/macros.h b/src/util/macros.h
 index 5fc6729..eec8b93 100644
 --- a/src/util/macros.h
 +++ b/src/util/macros.h
 @@ -82,7 +82,7 @@ do {\
  #endif

  #ifndef unreachable
 -#define unreachable(str)
 +#define unreachable(str) assert(!str)

 I'd make this ASSERT.  In Mesa, ASSERT only exists if DEBUG is defined.
  It seems that many distros build without -DDEBUG and without -DNDEBUG.
  I'd rather have no code for these cases in all release builds.

 I'm surprised by that.

 I see that we add -DDEBUG with --enable-debug, but from experience
 assert() does nothing in my regular release build (without
 --enable-debug). Where is NDEBUG coming from in that case? I don't see
 it in the macros gcc automatically defines (gcc -g -dM -E - 
 /dev/null).

 Right... and you need NDEBUG to no-op assert.  It has to be added by
 hand, and it seems that the distros don't.
 
 But I don't get assert()s in release builds, and I'm not adding NDEBUG 
 anywhere.

That's weird... I just (today) had a case where an assert() was in a
release build, but the same ASSERT() was not.  Maybe something weird is
just happening on my end... let me double check my stuff.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] util: Make unreachable at least be an assert

2014-12-05 Thread Ian Romanick
On 12/05/2014 01:54 PM, Ian Romanick wrote:
 On 12/05/2014 01:50 PM, Matt Turner wrote:
 On Fri, Dec 5, 2014 at 1:48 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/05/2014 01:42 PM, Matt Turner wrote:
 On Fri, Dec 5, 2014 at 1:25 PM, Ian Romanick i...@freedesktop.org wrote:
 On 12/05/2014 01:17 PM, Carl Worth wrote:
 Previously, if __builtin_unreachable() was unavailable, the
 unreachable macro was defined to do nothing. We do better here, by at
 least still making it an assert.
 ---
  src/util/macros.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/util/macros.h b/src/util/macros.h
 index 5fc6729..eec8b93 100644
 --- a/src/util/macros.h
 +++ b/src/util/macros.h
 @@ -82,7 +82,7 @@ do {\
  #endif

  #ifndef unreachable
 -#define unreachable(str)
 +#define unreachable(str) assert(!str)

 I'd make this ASSERT.  In Mesa, ASSERT only exists if DEBUG is defined.
  It seems that many distros build without -DDEBUG and without -DNDEBUG.
  I'd rather have no code for these cases in all release builds.

 I'm surprised by that.

 I see that we add -DDEBUG with --enable-debug, but from experience
 assert() does nothing in my regular release build (without
 --enable-debug). Where is NDEBUG coming from in that case? I don't see
 it in the macros gcc automatically defines (gcc -g -dM -E - 
 /dev/null).

 Right... and you need NDEBUG to no-op assert.  It has to be added by
 hand, and it seems that the distros don't.

 But I don't get assert()s in release builds, and I'm not adding NDEBUG 
 anywhere.
 
 That's weird... I just (today) had a case where an assert() was in a
 release build, but the same ASSERT() was not.  Maybe something weird is
 just happening on my end... let me double check my stuff.

Never mind.  PEBKAC.

Patch, as is, is

Reviewed-by: Ian Romanick ian.d.roman...@intel.com

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev