/src/serenity/AK/StackInfo.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2020, the SerenityOS developers. |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/Types.h> |
10 | | |
11 | | namespace AK { |
12 | | |
13 | | class StackInfo { |
14 | | public: |
15 | | StackInfo(); |
16 | | |
17 | 0 | FlatPtr base() const { return m_base; } |
18 | 0 | FlatPtr top() const { return m_top; } |
19 | 0 | size_t size() const { return m_size; } |
20 | | size_t size_free() const |
21 | 0 | { |
22 | 0 | auto p = reinterpret_cast<FlatPtr>(__builtin_frame_address(0)); |
23 | 0 | return p - m_base; |
24 | 0 | } |
25 | | |
26 | | private: |
27 | | FlatPtr m_base; |
28 | | FlatPtr m_top; |
29 | | size_t m_size; |
30 | | }; |
31 | | |
32 | | } |
33 | | |
34 | | #if USING_AK_GLOBALLY |
35 | | using AK::StackInfo; |
36 | | #endif |