Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/3rdparty/masm/wtf/PageBlock.h |
Source code | Switch to Preprocessed file |
Line | Source | Count |
---|---|---|
1 | /* | - |
2 | * Copyright (C) 2010 Apple Inc. All rights reserved. | - |
3 | * | - |
4 | * Redistribution and use in source and binary forms, with or without | - |
5 | * modification, are permitted provided that the following conditions | - |
6 | * are met: | - |
7 | * 1. Redistributions of source code must retain the above copyright | - |
8 | * notice, this list of conditions and the following disclaimer. | - |
9 | * 2. Redistributions in binary form must reproduce the above copyright | - |
10 | * notice, this list of conditions and the following disclaimer in the | - |
11 | * documentation and/or other materials provided with the distribution. | - |
12 | * | - |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | - |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | - |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | - |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | - |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | - |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | - |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | - |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | - |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | - |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | - |
23 | * THE POSSIBILITY OF SUCH DAMAGE. | - |
24 | */ | - |
25 | - | |
26 | #ifndef PageBlock_h | - |
27 | #define PageBlock_h | - |
28 | - | |
29 | namespace WTF { | - |
30 | - | |
31 | WTF_EXPORT_PRIVATE size_t pageSize(); | - |
32 | WTF_EXPORT_PRIVATE size_t pageMask(); | - |
33 | inline bool isPageAligned(void* address) { return !(reinterpret_cast<intptr_t>(address) & (pageSize() - 1)); } executed 997042 times by 153 tests: return !(reinterpret_cast<intptr_t>(address) & (pageSize() - 1)); Executed by:
| 997042 |
34 | inline bool isPageAligned(size_t size) { return !(size & (pageSize() - 1)); } executed 1602856 times by 153 tests: return !(size & (pageSize() - 1)); Executed by:
| 1602856 |
35 | inline bool isPowerOfTwo(size_t size) { return !(size & (size - 1)); } executed 14493198 times by 178 tests: return !(size & (size - 1)); Executed by:
| 14493198 |
36 | - | |
37 | class PageBlock { | - |
38 | public: | - |
39 | PageBlock(); | - |
40 | PageBlock(const PageBlock&); | - |
41 | PageBlock(void*, size_t, bool hasGuardPages); | - |
42 | - | |
43 | void* realBase() const { return m_realBase; } executed 604600 times by 153 tests: return m_realBase; Executed by:
| 604600 |
44 | void* base() const { return m_base; } executed 743473 times by 153 tests: return m_base; Executed by:
| 743473 |
45 | size_t size() const | - |
46 | { | - |
47 | return m_size - 2 * (static_cast<char *>(m_base) - static_cast<char *>(m_realBase)); executed 296 times by 1 test: return m_size - 2 * (static_cast<char *>(m_base) - static_cast<char *>(m_realBase)); Executed by:
| 296 |
48 | } | - |
49 | size_t realSize() const { return m_size; } executed 604501 times by 153 tests: return m_size; Executed by:
| 604501 |
50 | - | |
51 | operator bool() const { return !!m_realBase; } executed 2204771 times by 153 tests: return !!m_realBase; Executed by:
| 2204771 |
52 | - | |
53 | bool contains(void* containedBase, size_t containedSize) | - |
54 | { | - |
55 | return containedBase >= m_base executed 997766 times by 153 tests: return containedBase >= m_base && (static_cast<char*>(containedBase) + containedSize) <= (static_cast<char*>(m_base) + m_size); Executed by:
| 997766 |
56 | && (static_cast<char*>(containedBase) + containedSize) <= (static_cast<char*>(m_base) + m_size); executed 997766 times by 153 tests: return containedBase >= m_base && (static_cast<char*>(containedBase) + containedSize) <= (static_cast<char*>(m_base) + m_size); Executed by:
| 997766 |
57 | } | - |
58 | - | |
59 | private: | - |
60 | void* m_realBase; | - |
61 | void* m_base; | - |
62 | size_t m_size; | - |
63 | }; | - |
64 | - | |
65 | inline PageBlock::PageBlock() | - |
66 | : m_realBase(0) | - |
67 | , m_base(0) | - |
68 | , m_size(0) | - |
69 | { | - |
70 | } executed 1000846 times by 153 tests: end of block Executed by:
| 1000846 |
71 | - | |
72 | inline PageBlock::PageBlock(const PageBlock& other) | - |
73 | : m_realBase(other.m_realBase) | - |
74 | , m_base(other.m_base) | - |
75 | , m_size(other.m_size) | - |
76 | { | - |
77 | } executed 703644 times by 153 tests: end of block Executed by:
| 703644 |
78 | - | |
79 | inline PageBlock::PageBlock(void* base, size_t size, bool hasGuardPages) | - |
80 | : m_realBase(base) | - |
81 | , m_base(static_cast<char*>(base) + ((base && hasGuardPages) ? pageSize() : 0)) | - |
82 | , m_size(size) | - |
83 | { | - |
84 | } executed 605627 times by 153 tests: end of block Executed by:
| 605627 |
85 | - | |
86 | } // namespace WTF | - |
87 | - | |
88 | using WTF::pageSize; | - |
89 | using WTF::isPageAligned; | - |
90 | using WTF::isPageAligned; | - |
91 | using WTF::isPowerOfTwo; | - |
92 | - | |
93 | #endif // PageBlock_h | - |
Source code | Switch to Preprocessed file |