OLD | NEW |
1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <cinttypes> | 6 #include <cinttypes> |
7 | 7 |
8 #define TESTING | 8 #define TESTING |
9 #include "src/shared/assert.h" | 9 #include "src/shared/assert.h" |
10 | 10 |
11 #include "platforms/stm/disco_fletch/src/cmpctmalloc.h" | 11 #include "platforms/stm/disco_dartino/src/cmpctmalloc.h" |
12 #include "platforms/stm/disco_fletch/src/page_allocator.h" | 12 #include "platforms/stm/disco_dartino/src/page_allocator.h" |
13 | 13 |
14 PageAllocator* page_allocator; | 14 PageAllocator* page_allocator; |
15 | 15 |
16 extern "C" void* page_alloc(size_t pages) { | 16 extern "C" void* page_alloc(size_t pages) { |
17 return page_allocator->AllocatePages(pages); | 17 return page_allocator->AllocatePages(pages); |
18 } | 18 } |
19 | 19 |
20 extern "C" void page_free(void* start, size_t pages) { | 20 extern "C" void page_free(void* start, size_t pages) { |
21 return page_allocator->FreePages(start, pages); | 21 return page_allocator->FreePages(start, pages); |
22 } | 22 } |
(...skipping 15 matching lines...) Expand all Loading... |
38 size_t heap_size = 60 * PAGE_SIZE; // TODO(sgjesse): Test with few pages. | 38 size_t heap_size = 60 * PAGE_SIZE; // TODO(sgjesse): Test with few pages. |
39 heap_size = 0x800000; | 39 heap_size = 0x800000; |
40 void* heap_memory; | 40 void* heap_memory; |
41 int result = posix_memalign(&heap_memory, PAGE_SIZE, heap_size); | 41 int result = posix_memalign(&heap_memory, PAGE_SIZE, heap_size); |
42 EXPECT_EQ(0, result); | 42 EXPECT_EQ(0, result); |
43 int arena1_bitmap = page_allocator->AddArena( | 43 int arena1_bitmap = page_allocator->AddArena( |
44 "test", reinterpret_cast<uintptr_t>(heap_memory), heap_size); | 44 "test", reinterpret_cast<uintptr_t>(heap_memory), heap_size); |
45 EXPECT_EQ(1, arena1_bitmap); | 45 EXPECT_EQ(1, arena1_bitmap); |
46 | 46 |
47 cmpct_test_buckets(); | 47 cmpct_test_buckets(); |
48 #ifdef FLETCH_TARGET_OS_LK | 48 #ifdef DARTINO_TARGET_OS_LK |
49 // TODO(sgjesse): This test crashes. | 49 // TODO(sgjesse): This test crashes. |
50 cmpct_test_get_back_newly_freed(); | 50 cmpct_test_get_back_newly_freed(); |
51 #endif | 51 #endif |
52 cmpct_test_return_to_os(); | 52 cmpct_test_return_to_os(); |
53 cmpct_test_trim(); | 53 cmpct_test_trim(); |
54 cmpct_dump(); | 54 cmpct_dump(); |
55 } | 55 } |
OLD | NEW |