* src/mm/gc.hpp: Code reordered.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 4 Sep 2008 10:59:49 +0000 (12:59 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Thu, 4 Sep 2008 10:59:49 +0000 (12:59 +0200)
src/mm/gc.hpp

index 7e130458e34bde9d2070e54e55e33c0aa54e369e..4443c93c324562ad0b27db72dd4da0b5137e9229 100644 (file)
 #include <assert.h>
 #include <stdint.h>
 
-#if defined(ENABLE_GC_CACAO)
-# include "threads/thread.hpp"
-#endif
-
-#include "vm/global.h"
-#include "vm/method.h"
-
 
 #ifdef __cplusplus
 
@@ -48,7 +41,47 @@ public:
        static void critical_leave(void);
 };
 
-extern "C" {
+
+// Includes.
+#if defined(ENABLE_GC_CACAO)
+# include "threads/thread.hpp"
+#endif
+
+
+/**
+ * Enters a LLNI critical section which prevents the GC from moving
+ * objects around on the collected heap.
+ *
+ * There are no race conditions possible while entering such a critical
+ * section, because each thread only modifies its own thread local flag
+ * and the GC reads the flags while the world is stopped.
+ */
+inline void GC::critical_enter()
+{
+#if defined(ENABLE_GC_CACAO)
+       threadobject *t;
+
+       t = THREADOBJECT;
+       assert(!t->gc_critical);
+       t->gc_critical = true;
+#endif
+}
+
+/**
+ * Leaves a LLNI critical section and allows the GC to move objects
+ * around on the collected heap again.
+ */
+inline void GC::critical_leave()
+{
+#if defined(ENABLE_GC_CACAO)
+       threadobject *t;
+
+       t = THREADOBJECT;
+       assert(t->gc_critical);
+       t->gc_critical = false;
+#endif
+}
+
 #endif
 
 
@@ -66,8 +99,17 @@ enum {
 };
 
 
+// Includes.
+#include "vm/global.h"
+#include "vm/method.h"
+
+
 /* function prototypes ********************************************************/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void    gc_init(size_t heapmaxsize, size_t heapstartsize);
 
 void*   heap_alloc_uncollectable(size_t size);
@@ -97,7 +139,7 @@ void*   gc_out_of_memory(size_t bytes_requested);
 
 /* inlined functions **********************************************************/
 
-static inline int32_t heap_hashcode(java_object_t *obj)
+static inline int32_t heap_hashcode(java_object_tobj)
 {
 #if defined(ENABLE_GC_CACAO)
        return heap_get_hashcode(obj);
@@ -107,45 +149,10 @@ static inline int32_t heap_hashcode(java_object_t *obj)
 }
 
 #ifdef __cplusplus
-}
-
-/**
- * Enters a LLNI critical section which prevents the GC from moving
- * objects around on the collected heap.
- *
- * There are no race conditions possible while entering such a critical
- * section, because each thread only modifies its own thread local flag
- * and the GC reads the flags while the world is stopped.
- */
-inline void GC::critical_enter()
-{
-#if defined(ENABLE_GC_CACAO)
-       threadobject *t;
-
-       t = THREADOBJECT;
-       assert(!t->gc_critical);
-       t->gc_critical = true;
-#endif
-}
-
-/**
- * Leaves a LLNI critical section and allows the GC to move objects
- * around on the collected heap again.
- */
-inline void GC::critical_leave()
-{
-#if defined(ENABLE_GC_CACAO)
-       threadobject *t;
-
-       t = THREADOBJECT;
-       assert(t->gc_critical);
-       t->gc_critical = false;
-#endif
-}
-
+} // extern "C"
 #endif
 
-#endif /* _GC_HPP */
+#endif // _GC_HPP
 
 
 /*
@@ -154,9 +161,10 @@ inline void GC::critical_leave()
  * Emacs will automagically detect them.
  * ---------------------------------------------------------------------
  * Local variables:
- * mode: c
+ * mode: c++
  * indent-tabs-mode: t
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */