- maybe we should always use `const char *' in function declarations
[cacao.git] / builtin.c
index d513bf346910e0ae510237e55d06d8cd69459d68..38c4344831f848453ad13ef3493478f3cecc8fe1 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 1356 2004-07-28 10:05:07Z twisti $
+   $Id: builtin.c 1542 2004-11-18 12:19:49Z twisti $
 
 */
 
@@ -265,7 +265,7 @@ s4 builtin_arrayinstanceof(java_objectheader *obj, vftbl_t *target)
 
 java_objectheader *builtin_throw_exception(java_objectheader *xptr)
 {
-       if (verbose) {
+       if (opt_verbose) {
                char logtext[MAXLOGTEXT];
                sprintf(logtext, "Builtin exception thrown: ");
                if (xptr) {
@@ -276,7 +276,7 @@ java_objectheader *builtin_throw_exception(java_objectheader *xptr)
 
                        if (t->detailMessage) {
                                sprintf(logtext + strlen(logtext), ": %s",
-                                               javastring_tochar(t->detailMessage));
+                                               javastring_tochar((java_objectheader *) t->detailMessage));
                        }
 
                } else {
@@ -478,10 +478,13 @@ java_objectheader *builtin_new(classinfo *c)
 
        if (!o)
                return NULL;
-       
+
        memset(o, 0, c->instancesize);
 
        o->vftbl = c->vftbl;
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+       initObjectLock(o);
+#endif
 
        return o;
 }
@@ -538,6 +541,9 @@ java_arrayheader *builtin_newarray(s4 size, vftbl_t *arrayvftbl)
        memset(a, 0, actualsize);
 
        a->objheader.vftbl = arrayvftbl;
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+       initObjectLock(&a->objheader);
+#endif
        a->size = size;
 #ifdef SIZE_FROM_CLASSINFO
        a->alignedsize = actualsize;
@@ -771,7 +777,7 @@ java_objectheader *builtin_trace_exception(java_objectheader *xptr,
                else
                        log_text("WARNING: unmatched methodindent--");
        }
-       if (verbose || runverbose || verboseexception) {
+       if (opt_verbose || runverbose || verboseexception) {
                if (xptr) {
                        printf("Exception ");
                        utf_display_classname(xptr->vftbl->class->name);
@@ -785,25 +791,39 @@ java_objectheader *builtin_trace_exception(java_objectheader *xptr,
                        utf_display_classname(m->class->name);
                        printf(".");
                        utf_display(m->name);
-                       if (m->flags & ACC_SYNCHRONIZED)
+                       if (m->flags & ACC_SYNCHRONIZED) {
                                printf("(SYNC");
-                       else
+
+                       } else{
                                printf("(NOSYNC");
+                       }
+
                        if (m->flags & ACC_NATIVE) {
                                printf(",NATIVE");
-                               printf(")(%p) at position %p\n", m->entrypoint, pos);
+#if POINTERSIZE == 8
+                               printf(")(0x%016lx) at position %p\n", (s8) m->entrypoint, pos);
+#else
+                               printf(")(0x%08lx) at position %p\n", (s4) m->entrypoint, pos);
+#endif
+
                        } else {
-                               printf(")(%p) at position %p (", m->entrypoint, pos);
-                               if (m->class->sourcefile==NULL)
+#if POINTERSIZE == 8
+                               printf(")(0x%016lx) at position %p (", (s8) m->entrypoint, pos);
+#else
+                               printf(")(0x%08lx) at position %p (", (s4) m->entrypoint, pos);
+#endif
+                               if (m->class->sourcefile == NULL) {
                                        printf("<NO CLASSFILE INFORMATION>");
-                               else
+
+                               } else {
                                        utf_display(m->class->sourcefile);
+                               }
                                printf(":%d)\n", line);
                        }
 
                } else
                        printf("call_java_method\n");
-               fflush (stdout);
+               fflush(stdout);
        }
 
        return xptr;
@@ -1142,6 +1162,7 @@ void builtin_monitorenter(java_objectheader *o)
        monitorEnter((threadobject *) THREADOBJECT, o);
 #endif
 #endif
+
 }
 
 /*
@@ -1157,7 +1178,7 @@ void builtin_staticmonitorenter(classinfo *c)
 }
 
 
-void builtin_monitorexit(java_objectheader *o)
+void *builtin_monitorexit(java_objectheader *o)
 {
 #if defined(USE_THREADS)
 #if !defined(NATIVE_THREADS)
@@ -1177,8 +1198,10 @@ void builtin_monitorexit(java_objectheader *o)
                internal_unlock_mutex_for_object(o);
 
        --blockInts;
+       return o;
 #else
        monitorExit((threadobject *) THREADOBJECT, o);
+       return o;
 #endif
 #endif
 }
@@ -1776,7 +1799,8 @@ inline float longBitsToDouble(s8 l)
 
 java_arrayheader *builtin_clone_array(void *env, java_arrayheader *o)
 {
-       return (java_arrayheader *) Java_java_lang_VMObject_clone(0, 0, (java_lang_Cloneable *) o);
+       return (java_arrayheader *)
+               Java_java_lang_VMObject_clone(0, 0, (java_lang_Cloneable *) o);
 }