GNU header update.
[cacao.git] / src / mm / memory.c
index 2a6673189726a69d71d83cd42cf665c7ec8212ed..134ecdb5fd64bfa920f4f8861c2bdacd2f8e0ce2 100644 (file)
@@ -1,9 +1,9 @@
 /* toolbox/memory.c - 
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
-   M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
-   P. Tomsich, J. Wenninger
+   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+   Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
@@ -26,7 +26,7 @@
 
    Authors: Reinhard Grafl
 
-   $Id: memory.c 1568 2004-11-23 16:02:31Z twisti $
+   $Id: memory.c 1735 2004-12-07 14:33:27Z twisti $
 
 */
 
 #include <unistd.h>
 
 #include "config.h"
-#include "exceptions.h"
-#include "global.h"
-#include "native.h"
-#include "options.h"
-#include "statistics.h"
-#include "threads/nativethread.h"
+#include "mm/memory.h"
+#include "vm/exceptions.h"
+#include "vm/global.h"
+#include "vm/options.h"
+#include "vm/statistics.h"
+#include "native/native.h"
+
+#if defined(USE_THREADS)
+# if defined(NATIVE_THREADS)
+#  include "threads/native/threads.h"
+# else
+#  include "threads/green/threads.h"
+# endif
+#endif
+
 #include "toolbox/logging.h"
-#include "toolbox/memory.h"
 
 
 /********* general types, variables and auxiliary functions *********/
@@ -68,7 +76,7 @@ static void *mmapcodeptr = NULL;
 
 *******************************************************************************/
 
-#if !defined(USE_THREADS)
+#if !defined(USE_THREADS) || (defined(USE_THREADS) && !defined(NATIVE_THREADS))
 static dumpinfo nothreads_dumpinfo;
 #endif
 
@@ -186,7 +194,7 @@ void *dump_alloc(s4 size)
 
        /* If no threads are used, the dumpinfo structure is a static structure   */
        /* defined at the top of this file.                                       */
-#if defined(USE_THREADS)
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
        di = &((threadobject *) THREADOBJECT)->dumpinfo;
 #else
        di = &nothreads_dumpinfo;
@@ -268,7 +276,7 @@ void dump_release(s4 size)
 
        /* If no threads are used, the dumpinfo structure is a static structure   */
        /* defined at the top of this file.                                       */
-#if defined(USE_THREADS)
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
        di = &((threadobject *) THREADOBJECT)->dumpinfo;
 #else
        di = &nothreads_dumpinfo;
@@ -315,12 +323,15 @@ s4 dump_size()
 
        /* If no threads are used, the dumpinfo structure is a static structure   */
        /* defined at the top of this file.                                       */
-#if defined(USE_THREADS)
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
        di = &((threadobject *) THREADOBJECT)->dumpinfo;
 #else
        di = &nothreads_dumpinfo;
 #endif
 
+       if (!di)
+               return 0;
+
        return di->useddumpsize;
 }