Mesa (master): util: Don't use x86 asm on x86_64.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Mar 25 21:02:00 UTC 2009


Module: Mesa
Branch: master
Commit: 8c4bd92b68cf79ff94dc431f78a970bbab7e0d00
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c4bd92b68cf79ff94dc431f78a970bbab7e0d00

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Mar 25 20:58:38 2009 +0000

util: Don't use x86 asm on x86_64.

---

 src/gallium/auxiliary/util/u_debug.c       |   10 +++++-----
 src/gallium/auxiliary/util/u_debug.h       |    9 +++------
 src/gallium/auxiliary/util/u_debug_stack.c |    2 +-
 src/gallium/auxiliary/util/u_math.h        |   16 ++++++++++++----
 4 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 0af69d8..1b98442 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -169,18 +169,18 @@ void debug_print_blob( const char *name,
 #endif
 
 
-void _debug_break(void) 
+#ifndef debug_break
+void debug_break(void) 
 {
-#if defined(PIPE_ARCH_X86) && defined(PIPE_CC_GCC)
-   __asm("int3");
-#elif defined(PIPE_ARCH_X86) && defined(PIPE_CC_MSVC)
-   _asm {int 3};
+#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+   DebugBreak();
 #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
    EngDebugBreak();
 #else
    abort();
 #endif
 }
+#endif
 
 
 #ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index 33e7cb3..5e88f3e 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -125,19 +125,16 @@ void debug_print_format(const char *msg, unsigned fmt );
 #endif
 
 
-void _debug_break(void);
-
-
 /**
  * Hard-coded breakpoint.
  */
 #ifdef DEBUG
 #if defined(PIPE_ARCH_X86) && defined(PIPE_CC_GCC)
 #define debug_break() __asm("int3")
-#elif defined(PIPE_ARCH_X86) && defined(PIPE_CC_MSVC)
-#define debug_break()  do { _asm {int 3} } while(0)
+#elif defined(PIPE_CC_MSVC)
+#define debug_break()  __debugbreak()
 #else
-#define debug_break() _debug_break()
+void debug_break(void);
 #endif
 #else /* !DEBUG */
 #define debug_break() ((void)0)
diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c
index 76068a6..e5d6190 100644
--- a/src/gallium/auxiliary/util/u_debug_stack.c
+++ b/src/gallium/auxiliary/util/u_debug_stack.c
@@ -49,7 +49,7 @@ debug_backtrace_capture(struct debug_stack_frame *backtrace,
 
 #if defined(PIPE_CC_GCC)
    frame_pointer = ((const void **)__builtin_frame_address(1));
-#elif defined(PIPE_CC_MSVC)
+#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
    __asm {
       mov frame_pointer, ebp
    }
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index 1ecde7a..9268a9b 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -319,11 +319,21 @@ util_iround(float f)
 
 
 
-#if defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
 /**
  * Find first bit set in word.  Least significant bit is 1.
  * Return 0 if no bits set.
  */
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+static INLINE
+unsigned long ffs( unsigned long u )
+{
+   unsigned long i;
+   if(_BitScanForward(&i, u))
+      return i + 1;
+   else
+      return 0;
+}
+#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
 static INLINE
 unsigned ffs( unsigned u )
 {
@@ -339,9 +349,7 @@ unsigned ffs( unsigned u )
 
    return i;
 }
-#endif
-
-#ifdef __MINGW32__
+#elif defined(__MINGW32__)
 #define ffs __builtin_ffs
 #endif
 




More information about the mesa-commit mailing list