Modifications to make the new mm compile using the Digital Unix cc
authorphil <none@none>
Wed, 11 Nov 1998 02:22:30 +0000 (02:22 +0000)
committerphil <none@none>
Wed, 11 Nov 1998 02:22:30 +0000 (02:22 +0000)
mm/allocator.c
mm/bitmap2.c
mm/heap2.c
mm/mm.h

index 975674ccc1a3e418246226c2807d6a655235c21c..5818cc8c50db70d81a06776e7b4dc3d46a2faf5e 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Authors: Philipp Tomsich     EMAIL: cacao@complang.tuwien.ac.at
  *
- * $Id: allocator.c 34 1998-11-03 11:29:37Z phil $
+ * $Id: allocator.c 60 1998-11-11 02:22:30Z phil $
  */
 
 /* 
@@ -264,7 +264,7 @@ void
 allocator_init()
 {
        fprintf(stderr, 
-                       "allocator_init: $Id: allocator.c 34 1998-11-03 11:29:37Z phil $\n\n");
+                       "allocator_init: $Id: allocator.c 60 1998-11-11 02:22:30Z phil $\n\n");
        
        fprintf(stderr, "\t%d bit addresses\n", ADDRESS);
        fprintf(stderr, "\t%d bit alignment\n", ALIGN);
@@ -428,7 +428,7 @@ allocator_alloc(SIZE size)
 
                                /* split */
                                if ((bin << ALIGN) > size)
-                                       allocator_free(result + size, (bin << ALIGN) - size);
+                                       allocator_free((void*)((long)result + size), (bin << ALIGN) - size);
 
                                //                              fprintf(stderr, "found chunk in exact bin %d\n", bin);
 
@@ -456,7 +456,7 @@ allocator_alloc(SIZE size)
 
                                /* split */
                                if (chunk->size > size)
-                                       allocator_free((void*)chunk + size, (chunk->size - size));
+                                       allocator_free((void*)((long)chunk + size), (chunk->size - size));
                                
                                return (void*)chunk;
                        }
@@ -471,7 +471,7 @@ allocator_alloc(SIZE size)
 
                                /* split */
                                if (new_chunk->size > size)
-                                       allocator_free((void*)new_chunk + size, (new_chunk->size - size));
+                                       allocator_free((void*)((long)new_chunk + size), (new_chunk->size - size));
                                
                                return (void*)new_chunk;
                        }
index b0aa8424a43a63a987caefc5a39740467c82755d..e63a722dcf596735deb21255b3f2c9aa2df6eb8b 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Authors: Philipp Tomsich     EMAIL: cacao@complang.tuwien.ac.at
  *
- * $Id: bitmap2.c 56 1998-11-10 17:35:47Z phil $
+ * $Id: bitmap2.c 60 1998-11-11 02:22:30Z phil $
  */
 
 /*
@@ -191,10 +191,10 @@ bitmap_t* bitmap_allocate(void*   zero_addr,
 
        bitmap->bytesize = bytesize;
        bitmap->bitmap_memory = malloc(bytesize);
-       bitmap->bitmap = bitmap->bitmap_memory - CALC_ZERO_OFFSET(zero_addr);   /* offset for fast access */
+       bitmap->bitmap = (void*)((long)bitmap->bitmap_memory - CALC_ZERO_OFFSET(zero_addr));   /* offset for fast access */
 
-       bitmap->bitmap_beyond_addr = zero_addr + size;
-       bitmap->bitmap_top_block = ADDR_TO_BLOCK(bitmap->bitmap_beyond_addr - sizeof(BITBLOCK));
+       bitmap->bitmap_beyond_addr = (void*)((long)zero_addr + size);
+       bitmap->bitmap_top_block = ADDR_TO_BLOCK((long)bitmap->bitmap_beyond_addr - sizeof(BITBLOCK));
 
        if (!bitmap->bitmap_memory) {
                /* handle error -- unable to allocate enough memory */
@@ -309,7 +309,7 @@ bitmap_find_next_setbit(bitmap_t* bitmap,
        /* 1. check the current block, starting from the bit indicated by addr */
        pattern = bitmap->bitmap[block] >> offset;
        if (pattern)
-               return (void*)(addr + offset_for_lowest(pattern));
+               return (void*)((long)addr + offset_for_lowest(pattern));
 
        /* 2. iteratively check block by block until the end of the bitmap */
        while (block < bitmap->bitmap_top_block) {
@@ -339,7 +339,7 @@ bitmap_find_next_combination_set_unset(bitmap_t* bitmap,
        /* 1. check the current block, starting from the bit indicated by addr */
        pattern = (bitmap->bitmap[block] & ~invertedmap->bitmap[block]) >> offset;
        if (pattern)
-               return (void*)(addr + offset_for_lowest(pattern));
+               return (void*)((long)addr + offset_for_lowest(pattern));
 
        /* 2. iteratively check block by block until the end of the bitmap */
        while (block < bitmap->bitmap_top_block) {
index a2296193536e5c8c6b23eefdc89155ba3d729ea0..4e73315ed6e80552dc1a66d1528fe5e5adab73e0 100644 (file)
@@ -110,7 +110,7 @@ heap_init (SIZE size,
        heap_base = malloc(heap_size);
 #endif
 
-       if (heap_base == MAP_FAILED) {
+       if (heap_base == (void*)MAP_FAILED) {
                /* unable to allocate the requested amount of memory */
                fprintf(stderr, "The queen, mylord, is dead!\n");
                exit(-1);
@@ -132,12 +132,12 @@ heap_init (SIZE size,
        stackbottom = in_stackbottom; /* copy the stackbottom */
 
        heap_top = heap_base; /* the current end of the heap (just behind the last allocated object) */
-       heap_limit = heap_base + heap_size; /* points just behind the last accessible block of the heap */
+       heap_limit = (void*)((long)heap_base + heap_size); /* points just behind the last accessible block of the heap */
 
        /* 6. calculate a useful first collection limit */
        /* This is extremly primitive at this point... 
           we should replace it with something more useful -- phil. */
-       heap_next_collection = heap_base + (heap_size / 8);
+       heap_next_collection = (void*)((long)heap_base + (heap_size / 8));
 
        /* 7. Init the global reference lists & finalizer addresses */
        references = NULL;
@@ -171,9 +171,9 @@ heap_close (void)
                munmap(heap_base, heap_size);
 }
 
+__inline__
 static
-inline
-void
+void 
 heap_add_address_to_address_list(address_list_node** list, void* address)
 {
        /* Note: address lists are kept sorted to simplify finalization */
@@ -202,8 +202,9 @@ heap_add_address_to_address_list(address_list_node** list, void* address)
        *list = new_node;
 }
 
+
+__inline__
 static
-inline
 void
 heap_add_finalizer_for_object_at(void* addr)
 {
@@ -238,7 +239,7 @@ heap_allocate (SIZE           in_length,
        if (finalizer)
                fprintf(stderr, "finalizer detected\n");
 
-#if VERBOSITY >= VERBOSITY_LIFESPAN 
+#if VERBOSITY >= VERBOSITY_LIFESPAN
        /* perform garbage collection to collect data for lifespan analysis */
        if (heap_top > heap_base)
                gc_call();
@@ -253,7 +254,7 @@ heap_allocate (SIZE           in_length,
        /* 2. if unsuccessful, try alternative allocation strategies */
        if (!free_chunk) {
                /* 2.a if the collection threshold would be exceeded, collect the heap */
-               if (heap_top + length > heap_next_collection) {
+               if ((long)heap_top + length > (long)heap_next_collection) {
                        /* 2.a.1. collect if the next_collection threshold would be exceeded */
                        gc_call();
 
@@ -264,13 +265,13 @@ heap_allocate (SIZE                 in_length,
 
                        /* 2.a.3. we can't satisfy the request from the freelists, check
                                  against the heap_limit whether growing the heap is possible */
-                       if (heap_top + length > heap_limit)
+                       if ((long)heap_top + length > (long)heap_limit)
                                goto failure;
                }
 
                /* 2.b. grow the heap */
                free_chunk = heap_top;
-               heap_top += length;
+               heap_top = (void*)((long)heap_top + length);
        }
 
  success:
@@ -280,7 +281,7 @@ heap_allocate (SIZE           in_length,
           which already is marked (Note: The first free-block gets marked in heap_init). -- phil. */
        bitmap_setbit(start_bits, free_chunk); /* mark the new object */
 #endif
-       bitmap_setbit(start_bits, free_chunk + length); /* mark the freespace behind the new object */
+       bitmap_setbit(start_bits, (void*)((long)free_chunk + (long)length)); /* mark the freespace behind the new object */
        if (references)
                bitmap_setbit(reference_bits, free_chunk);
        else 
@@ -294,7 +295,7 @@ heap_allocate (SIZE           in_length,
 #   warning "finalizers disabled."
 #endif
 
-#if VERBOSITY >= VERBOSITY_TRACE
+#if VERBOSITY >= VERBOSITY_TRACE && 0
        fprintf(stderr, "heap_allocate: returning free block of 0x%lx bytes at 0x%lx\n", length, free_chunk);
 #endif
 #if VERBOSITY >= VERBOSITY_PARANOIA && 0
@@ -336,7 +337,7 @@ heap_addreference (void **reflocation)
 }
 
 static
-inline
+__inline__
 void gc_finalize (void)
 {
        /* This will have to be slightly rewritten as soon the JIT-marked heap-based lists are used. -- phil. */
@@ -374,8 +375,9 @@ void gc_finalize (void)
 #endif
 }
 
+
+__inline__
 static 
-inline 
 void gc_reclaim (void)
 {
        void* free_start;
@@ -436,12 +438,12 @@ bitmap_find_next_setbit(mark_bitmap, free_start + 8); /* FIXME: constant used */
                        fprintf(stderr, "gc_reclaim: inconsistent bit info for 0x%lx\n", free_start);
 
                if (free_start < heap_top) {
-                       free_end   = bitmap_find_next_setbit(mark_bitmap, free_start + 8); /* FIXME: constant used */
+                       free_end   = bitmap_find_next_setbit(mark_bitmap, (void*)((long)free_start + 8)); /* FIXME: constant used */
 
                        //                      fprintf(stderr, "%lx -- %lx\n", free_start, free_end);
                        
                        if (free_end < heap_top) {
-                               allocator_free(free_start, free_end - free_start);
+                               allocator_free(free_start, (long)free_end - (long)free_start);
 
                                //                              fprintf(stderr, "gc_reclaim: freed 0x%lx bytes at 0x%lx\n", free_end - free_start, free_start);
 
@@ -478,7 +480,7 @@ bitmap_find_next_setbit(mark_bitmap, free_start + 8); /* FIXME: constant used */
                bitmap_setbit(start_bits, heap_top);
 
        /* 4. adjust the collection threshold */
-       heap_next_collection = heap_top + (heap_limit - heap_top) / 8;
+       heap_next_collection = (void*)((long)heap_top + ((long)heap_limit - (long)heap_top) / 8);
        if (heap_next_collection > heap_limit)
                heap_next_collection = heap_limit;
 
@@ -493,8 +495,8 @@ bitmap_find_next_setbit(mark_bitmap, free_start + 8); /* FIXME: constant used */
 #endif
 }
 
+__inline__
 static
-inline 
 void 
 gc_mark_object_at (void** addr)
 {
@@ -565,8 +567,9 @@ gc_mark_object_at (void** addr)
        return;
 }
 
+
+__inline__
 static
-inline 
 void gc_mark_references (void)
 {
        address_list_node* curr = references;
@@ -579,8 +582,8 @@ void gc_mark_references (void)
        }
 }
 
+__inline__
 static
-inline
 void 
 markreferences(void** start, void** end)
 {
@@ -588,8 +591,8 @@ markreferences(void** start, void** end)
                gc_mark_object_at(*(start++));
 }
 
+__inline__
 static
-inline 
 void gc_mark_stack (void)
 {
        void *dummy;
diff --git a/mm/mm.h b/mm/mm.h
index 99c10cc992992f8a03d3c32dfe4a2e0fbb03de9d..d3cb08e1c1ba7657ec05f339717b332f3b0f6653 100644 (file)
--- a/mm/mm.h
+++ b/mm/mm.h
@@ -4,6 +4,19 @@
 #include "../sysdep/types.h"
 #include "../global.h"
 
+#ifndef CACAO_NO_INLINE
+#define __cacao_inline__  inline
+#else
+#define __cacao_inline__
+#endif
+
+#ifdef __GNUC__
+#define __inline__  __cacao_inline__
+#else
+#define __inline__
+#endif
+
+
 #endif