* Removed all Id tags.
[cacao.git] / src / toolbox / logging.c
index 0d21c1a8e74300d205fcfbbcab22a570178eca0b..de04b1e573aee75d7623e6fe8254701a5b1c4cb8 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: logging.c 7246 2007-01-29 18:49:05Z twisti $
-
 */
 
 
 # include "vmcore/statistics.h"
 #endif
 
-#if 0
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
-#endif
-
 
 /***************************************************************************
                         LOG FILE HANDLING 
@@ -75,18 +67,41 @@ void log_init(const char *fname)
 
 *******************************************************************************/
 
+/* ATTENTION: Don't include threads-common.h, because we can't
+   bootstrap this file in that case (missing java_lang_Thread.h).
+   Instead we declare threads_get_current_threadobject differently: */
+
+/* #if defined(ENABLE_THREADS) */
+/* # include "threads/threads-common.h" */
+/* #endif */
+
+extern ptrint threads_get_current_tid(void);
+
+
 void log_start(void)
 {
-       if (logfile) {
 #if defined(ENABLE_THREADS)
-#warning FIX ME!
-/*             fprintf(logfile, "[%p] ", (void *) threads_get_current_threadobject()); */
+       ptrint tid;
+
+       tid = threads_get_current_tid();
 #endif
 
-       } else {
+       if (logfile) {
 #if defined(ENABLE_THREADS)
-#warning FIX ME!
-/*             fprintf(stdout, "LOG: [%p] ", (void *) threads_get_current_threadobject()); */
+# if SIZEOF_VOID_P == 8
+               fprintf(logfile, "[0x%016lx] ", tid );
+# else
+               fprintf(logfile, "[0x%08x] ", tid);
+# endif
+#endif
+       }
+       else {
+#if defined(ENABLE_THREADS)
+# if SIZEOF_VOID_P == 8
+               fprintf(stdout, "LOG: [0x%016lx] ", tid);
+# else
+               fprintf(stdout, "LOG: [0x%08x] ", tid);
+# endif
 #else
                fputs("LOG: ", stdout);
 #endif
@@ -155,11 +170,11 @@ void log_println(const char *text, ...)
 void log_finish(void)
 {
        if (logfile) {
+               fputs("\n", logfile);
                fflush(logfile);
-
-       else {
+       }
+       else {
                fputs("\n", stdout);
-
                fflush(stdout);
        }
 }