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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 int num = 7; | 44 int num = 7; |
45 OS::SNPrint(NULL, 0, "%*d%*d", width, num, width, num); | 45 OS::SNPrint(NULL, 0, "%*d%*d", width, num, width, num); |
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 EXPECT_LT(0U, OS::GetStackSizeLimit()); | |
55 } | 54 } |
56 | 55 |
57 | 56 |
58 UNIT_TEST_CASE(OSAlignedAllocate) { | 57 UNIT_TEST_CASE(OSAlignedAllocate) { |
59 // TODO(johnmccutchan): Test other alignments, once we support | 58 // TODO(johnmccutchan): Test other alignments, once we support |
60 // alignments != 16 on Mac. | 59 // alignments != 16 on Mac. |
61 void* p1 = OS::AlignedAllocate(1023, 16); | 60 void* p1 = OS::AlignedAllocate(1023, 16); |
62 void* p2 = OS::AlignedAllocate(1025, 16); | 61 void* p2 = OS::AlignedAllocate(1025, 16); |
63 void* p3 = OS::AlignedAllocate(1025, 16); | 62 void* p3 = OS::AlignedAllocate(1025, 16); |
64 void* p4 = OS::AlignedAllocate(1, 16); | 63 void* p4 = OS::AlignedAllocate(1, 16); |
65 void* p5 = OS::AlignedAllocate(2, 16); | 64 void* p5 = OS::AlignedAllocate(2, 16); |
66 void* p6 = OS::AlignedAllocate(4, 16); | 65 void* p6 = OS::AlignedAllocate(4, 16); |
67 EXPECT((reinterpret_cast<intptr_t>(p1) & 15) == 0); | 66 EXPECT((reinterpret_cast<intptr_t>(p1) & 15) == 0); |
68 EXPECT((reinterpret_cast<intptr_t>(p2) & 15) == 0); | 67 EXPECT((reinterpret_cast<intptr_t>(p2) & 15) == 0); |
69 EXPECT((reinterpret_cast<intptr_t>(p3) & 15) == 0); | 68 EXPECT((reinterpret_cast<intptr_t>(p3) & 15) == 0); |
70 EXPECT((reinterpret_cast<intptr_t>(p4) & 15) == 0); | 69 EXPECT((reinterpret_cast<intptr_t>(p4) & 15) == 0); |
71 EXPECT((reinterpret_cast<intptr_t>(p5) & 15) == 0); | 70 EXPECT((reinterpret_cast<intptr_t>(p5) & 15) == 0); |
72 EXPECT((reinterpret_cast<intptr_t>(p6) & 15) == 0); | 71 EXPECT((reinterpret_cast<intptr_t>(p6) & 15) == 0); |
73 OS::AlignedFree(p1); | 72 OS::AlignedFree(p1); |
74 OS::AlignedFree(p2); | 73 OS::AlignedFree(p2); |
75 OS::AlignedFree(p3); | 74 OS::AlignedFree(p3); |
76 OS::AlignedFree(p4); | 75 OS::AlignedFree(p4); |
77 OS::AlignedFree(p5); | 76 OS::AlignedFree(p5); |
78 OS::AlignedFree(p6); | 77 OS::AlignedFree(p6); |
79 } | 78 } |
80 | 79 |
81 } // namespace dart | 80 } // namespace dart |
OLD | NEW |