OSDN Git Service

Switch to <stdbool.h> in the VM.
authorAndy McFadden <fadden@android.com>
Wed, 5 Aug 2009 22:20:27 +0000 (15:20 -0700)
committerAndy McFadden <fadden@android.com>
Wed, 5 Aug 2009 22:26:34 +0000 (15:26 -0700)
We were using an enum that made the compiler unhappy on MacOS X.  This
switches us to using <stdbool.h> when it's available.

The size of a "bool" is either sizeof(_Bool) or sizeof(enum bool), and
the assembly sources dislike ambiguity, so this also changes
gDvm.debuggerActive to always be a single byte.  The ARM and x86 code
was already assuming that -- held over from when enums were
variable-width, and never fixed because we get the right answer on
little-endian platforms -- so it doesn't look like we need to change
anything in mterp.

vm/Common.h
vm/Globals.h
vm/mterp/common/asm-constants.h

index 4b357e2..d0c021d 100644 (file)
@@ -97,11 +97,15 @@ typedef union JValue {
 } JValue;
 
 /*
- * Some systems might have this in <stdbool.h>.
+ * The <stdbool.h> definition uses _Bool, a type known to the compiler.
  */
-#ifndef __bool_true_false_are_defined
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>   /* C99 */
+#else
+# ifndef __bool_true_false_are_defined
 typedef enum { false=0, true=!false } bool;
-#define __bool_true_false_are_defined 1
+# define __bool_true_false_are_defined 1
+# endif
 #endif
 
 #define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
index 5b69f02..2ac1187 100644 (file)
@@ -498,9 +498,12 @@ struct DvmGlobals {
 
     /*
      * JDWP debugger support.
+     *
+     * Note "debuggerActive" is accessed from mterp, so its storage size and
+     * meaning must not be changed without updating the assembly sources.
      */
     bool        debuggerConnected;      /* debugger or DDMS is connected */
-    bool        debuggerActive;         /* debugger is making requests */
+    u1          debuggerActive;         /* debugger is making requests */
     JdwpState*  jdwpState;
 
     /*
index 5c37af6..716df3d 100644 (file)
@@ -82,7 +82,7 @@
  */
 
 /* globals (sanity check for LDR vs LDRB) */
-MTERP_SIZEOF(sizeofGlobal_debuggerActive, gDvm.debuggerActive, MTERP_SMALL_ENUM)
+MTERP_SIZEOF(sizeofGlobal_debuggerActive, gDvm.debuggerActive, 1)
 #if defined(WITH_PROFILER)
 MTERP_SIZEOF(sizeofGlobal_activeProfilers, gDvm.activeProfilers, 4)
 #endif