| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "platform/utils.h" | 6 #include "platform/utils.h" |
| 7 #include "vm/globals.h" | 7 #include "vm/globals.h" |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 UNIT_TEST_CASE(OsFuncs) { | 49 UNIT_TEST_CASE(OsFuncs) { |
| 50 EXPECT(Utils::IsPowerOfTwo(OS::ActivationFrameAlignment())); | 50 EXPECT(Utils::IsPowerOfTwo(OS::ActivationFrameAlignment())); |
| 51 EXPECT(Utils::IsPowerOfTwo(OS::PreferredCodeAlignment())); | 51 EXPECT(Utils::IsPowerOfTwo(OS::PreferredCodeAlignment())); |
| 52 int procs = OS::NumberOfAvailableProcessors(); | 52 int procs = OS::NumberOfAvailableProcessors(); |
| 53 EXPECT_LE(1, procs); | 53 EXPECT_LE(1, procs); |
| 54 } | 54 } |
| 55 | 55 |
| 56 | |
| 57 UNIT_TEST_CASE(OSAlignedAllocate) { | |
| 58 // TODO(johnmccutchan): Test other alignments, once we support | |
| 59 // alignments != 16 on Mac. | |
| 60 void* p1 = OS::AlignedAllocate(1023, 16); | |
| 61 void* p2 = OS::AlignedAllocate(1025, 16); | |
| 62 void* p3 = OS::AlignedAllocate(1025, 16); | |
| 63 void* p4 = OS::AlignedAllocate(1, 16); | |
| 64 void* p5 = OS::AlignedAllocate(2, 16); | |
| 65 void* p6 = OS::AlignedAllocate(4, 16); | |
| 66 EXPECT((reinterpret_cast<intptr_t>(p1) & 15) == 0); | |
| 67 EXPECT((reinterpret_cast<intptr_t>(p2) & 15) == 0); | |
| 68 EXPECT((reinterpret_cast<intptr_t>(p3) & 15) == 0); | |
| 69 EXPECT((reinterpret_cast<intptr_t>(p4) & 15) == 0); | |
| 70 EXPECT((reinterpret_cast<intptr_t>(p5) & 15) == 0); | |
| 71 EXPECT((reinterpret_cast<intptr_t>(p6) & 15) == 0); | |
| 72 OS::AlignedFree(p1); | |
| 73 OS::AlignedFree(p2); | |
| 74 OS::AlignedFree(p3); | |
| 75 OS::AlignedFree(p4); | |
| 76 OS::AlignedFree(p5); | |
| 77 OS::AlignedFree(p6); | |
| 78 } | |
| 79 | |
| 80 } // namespace dart | 56 } // namespace dart |
| OLD | NEW |