missing extern and ;
[cacao.git] / builtin.h
index ae49650a1c718d11884f907c4f7a3d172892dd48..34cbf55b514e395fa5721d88d4b146ff818d7086 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -28,7 +28,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: builtin.h 821 2003-12-31 14:14:01Z twisti $
+   $Id: builtin.h 930 2004-03-02 21:18:23Z jowenn $
 
 */
 
@@ -37,6 +37,7 @@
 #define _BUILTIN_H
 
 #include "config.h"
+#include "toolbox/loging.h"
 
 
 /* define infinity for floating point numbers */
 #define DBL_NEGINF  0xfff0000000000000LL
 
 
-/* some platforms do not have float versions of these functions */
+/* float versions are not defined in gnu classpath's fdlibm */
 
-#ifndef HAVE_COPYSIGNF
-#define copysignf copysign
-#endif
-
-#ifndef HAVE_FINITEF
-#define finitef finite
-#endif
-
-#ifndef HAVE_FMODF
-#define fmodf fmod
-#endif
-
-#ifndef HAVE_ISNANF
-#define isnanf isnan
-#endif
+#define copysignf    copysign
+#define finitef      finite
+#define fmodf        fmod
+#define isnanf       isnan
 
 
 /**********************************************************************/
  * must be an entry in the builtin_desc table in jit/jit.c.
  */
  
-/* XXX delete */
-#if 0
-typedef struct builtin_descriptor {
-       functionptr bptr;
-       char        *name;
-       } builtin_descriptor;
-#endif
-
 typedef struct builtin_descriptor builtin_descriptor;
 
 /* There is a builtin_descriptor in builtin_desc for every builtin
@@ -115,7 +97,28 @@ extern builtin_descriptor builtin_desc[];
 /* GLOBAL VARIABLES                                                   */
 /**********************************************************************/
 
-extern java_objectheader* exceptionptr;
+#define THREADSPECIFIC
+#define exceptionptr (&_exceptionptr)
+#define threadrootmethod (&_threadrootmethod)
+
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#ifdef HAVE___THREAD
+
+#undef THREADSPECIFIC
+#define THREADSPECIFIC __thread
+
+#else
+
+#undef exceptionptr
+#undef threadrootmethod
+#define exceptionptr builtin_get_exceptionptrptr()
+#define threadrootmethod  builtin_get_threadrootmethod()
+#endif
+#endif
+
+extern THREADSPECIFIC java_objectheader* _exceptionptr;
+extern THREADSPECIFIC methodinfo* _threadrootmethod;
+extern THREADSPECIFIC native_stackframeinfo* _threadnativestackframeinfo;
 
 
 /**********************************************************************/
@@ -167,11 +170,17 @@ s4 asm_builtin_checkarraycast(java_objectheader *obj, vftbl *target);
 
 java_objectheader *builtin_throw_exception(java_objectheader *exception);
 /* NOT AN OP */
-java_objectheader *builtin_trace_exception(java_objectheader *exceptionptr,
+java_objectheader *builtin_trace_exception(java_objectheader *_exceptionptr,
                                                                                   methodinfo *method, 
                                                                                   int *pos, int noindent);
 /* NOT AN OP */
 
+static inline java_objectheader **builtin_get_exceptionptrptr();
+static inline methodinfo **builtin_get_threadrootmethod();
+/* NOT AN OP */
+void builtin_reset_exceptionptr();
+/* NOT AN OP */
+
 java_objectheader *builtin_new(classinfo *c);
 #define BUILTIN_new (functionptr) builtin_new
 
@@ -220,12 +229,12 @@ void builtin_trace_args(s8 a0, s8 a1, s8 a2, s8 a3, s8 a4, s8 a5, s8 a6, s8 a7,
 /* NOT AN OP */
 #endif
 #endif
-void builtin_displaymethodstart(methodinfo *method); /* XXX? */
+void builtin_displaymethodstart(methodinfo *method);
 /* NOT AN OP */
 void builtin_displaymethodstop(methodinfo *method, s8 l, double d, float f);
 /* NOT AN OP */
-/* void builtin_displaymethodstop(methodinfo *method); */ /* XXX? */
-void builtin_displaymethodexception(methodinfo *method); /* XXX? */
+/* void builtin_displaymethodstop(methodinfo *method); */
+void builtin_displaymethodexception(methodinfo *method);
 /* NOT AN OP */
 
 void builtin_monitorenter(java_objectheader *o);
@@ -277,36 +286,36 @@ s8 builtin_lneg(s8 a);
 s4 builtin_lcmp(s8 a, s8 b);
 #define BUILTIN_lcmp (functionptr) builtin_lcmp
 
-float builtin_fadd(float a, float b); /* XXX? */
+float builtin_fadd(float a, float b);
 /* NOT AN OP */
-float builtin_fsub(float a, float b); /* XXX? */
+float builtin_fsub(float a, float b);
 /* NOT AN OP */
-float builtin_fmul(float a, float b); /* XXX? */
+float builtin_fmul(float a, float b);
 /* NOT AN OP */
-float builtin_fdiv(float a, float b); /* XXX? */
+float builtin_fdiv(float a, float b);
 /* NOT AN OP */
-float builtin_fneg(float a);          /* XXX? */
+float builtin_fneg(float a);         
 /* NOT AN OP */
-s4 builtin_fcmpl(float a, float b);   /* XXX? */
+s4 builtin_fcmpl(float a, float b);  
 /* NOT AN OP */
-s4 builtin_fcmpg(float a, float b);   /* XXX? */
+s4 builtin_fcmpg(float a, float b);  
 /* NOT AN OP */
 float builtin_frem(float a, float b);
 #define BUILTIN_frem (functionptr) builtin_frem
 
-double builtin_dadd(double a, double b); /* XXX? */
+double builtin_dadd(double a, double b);
 /* NOT AN OP */
-double builtin_dsub(double a, double b); /* XXX? */
+double builtin_dsub(double a, double b);
 /* NOT AN OP */
-double builtin_dmul(double a, double b); /* XXX? */
+double builtin_dmul(double a, double b);
 /* NOT AN OP */
-double builtin_ddiv(double a, double b); /* XXX? */
+double builtin_ddiv(double a, double b);
 /* NOT AN OP */
-double builtin_dneg(double a);           /* XXX? */ 
+double builtin_dneg(double a);          
 /* NOT AN OP */
-s4 builtin_dcmpl(double a, double b);    /* XXX? */
+s4 builtin_dcmpl(double a, double b);   
 /* NOT AN OP */
-s4 builtin_dcmpg(double a, double b);    /* XXX? */
+s4 builtin_dcmpg(double a, double b);   
 /* NOT AN OP */
 double builtin_drem(double a, double b);
 #define BUILTIN_drem (functionptr) builtin_drem
@@ -333,7 +342,7 @@ s8       builtin_f2l(float a);
 s8       asm_builtin_f2l(float a);
 /* NOT AN OP */
 
-double   builtin_f2d(float a);     /* XXX? */
+double   builtin_f2d(float a);
 /* NOT AN OP */
 
 s4       builtin_d2i(double a);
@@ -345,17 +354,60 @@ s8       builtin_d2l(double a);
 s8       asm_builtin_d2l(double a);
 /* NOT AN OP */
 
-float    builtin_d2f(double a);    /* XXX? */
+float    builtin_d2f(double a);
 /* NOT AN OP */
 
 java_arrayheader *builtin_clone_array(void *env, java_arrayheader *o);
 /* NOT AN OP */
 
+/* builtin_dummy just panics if it is executed. */
+s4 builtin_dummy();
+/* NOT AN OP */
+
 /* conversion helper functions */
 
 inline float intBitsToFloat(s4 i);
 inline float longBitsToDouble(s8 l);
 
+
+static inline java_objectheader **builtin_get_exceptionptrptr()
+{
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#ifdef HAVE___THREAD
+    return &_exceptionptr;
+#else
+    return &((nativethread*) pthread_getspecific(tkey_exceptionptr))->_exceptionptr;
+#endif
+#else
+    panic("builtin_get_exceptionptrptr should not be used in this configuration");
+    return NULL;
+#endif
+}
+
+static inline methodinfo **builtin_get_threadrootmethod()
+{
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#ifdef HAVE___THREAD
+    return &_threadrootmethod;
+#else
+    return &((nativethread*) pthread_getspecific(tkey_threadrootmethod))->_threadrootmethod;
+#endif
+#else
+    panic("builting_get_threadrootmethod should not be used in this configuration");
+    return NULL;
+#endif
+}
+
+/* returns the root method of a thread. this is used in asmpart.S and delivers the abort condition
+   for the stack unwinding for getClassContext and getClassLoader. For the main thread this is the main function.
+   Otherwhise it is the thread's run method (at least that's how I see it) (jowenn) */
+methodinfo *builtin_asm_get_threadrootmethod();
+
+/* adds an element to the stack frame info list (needed for unwinding across native functions) */
+native_stackframeinfo **builtin_asm_new_stackframeinfo();
+
+/* returns the current top element of the stack frame info list (needed for unwinding across native functions) */
+native_stackframeinfo *builtin_asm_get_stackframeinfo();
 #endif /* _BUILTIN_H */