class PageRoundedSize

Defined at line 62 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

This wraps size_t to ensure that a size is always rounded to whole pages.

To support safe chaining of operations with overflow detection, this class

provides overloaded operators that work with std::optional

<PageRoundedSize

>.

Normal arithmetic operators which could overflow return std::optional

<PageRoundedSize

>

which will have a valid result when no overflow is detected.

Examples:

1. Adding two PageRoundedSize objects:

PageRoundedSize a = ...;

PageRoundedSize b = ...;

std::optional

<PageRoundedSize

> sum = a + b;

if (!sum) { /* handle overflow */ }

2. Chaining multiple additions:

PageRoundedSize a = ...;

PageRoundedSize b = ...;

PageRoundedSize c = ...;

std::optional

<PageRoundedSize

> total = a + b + c;

if (!total) { /* handle overflow */ }

3. Adding a raw size (auto-rounded):

PageRoundedSize a = ...;

size_t raw_size = ...;

std::optional

<PageRoundedSize

> total = a + raw_size;

4. Construction from raw size with check:

std::optional

<PageRoundedSize

> size = PageRoundedSize::From(raw_size);

5. Construction from page count:

std::optional

<PageRoundedSize

> size = PageRoundedSize::Pages(num_pages);

Public Methods

void PageRoundedSize ()

Defined at line 64 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

void PageRoundedSize (const PageRoundedSize & )

Defined at line 65 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

PageRoundedSize & operator= (const PageRoundedSize & )

Defined at line 66 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

std::optional<PageRoundedSize> From (size_t raw_size)

Defined at line 68 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

std::strong_ordering operator<=> (const PageRoundedSize & )

Defined at line 81 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

size_t get ()

Defined at line 83 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

bool operator bool ()

Defined at line 85 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

PageRoundedSize Page ()

Defined at line 87 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

std::optional<PageRoundedSize> Pages (size_t num)

Defined at line 91 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

PageRoundedSize operator/ (size_t other)

Defined at line 93 of file ../../sdk/lib/c/pthread/../threads/../startup/../zircon/vmar.h

Friends

class ThreadStorage
class GuardedPageBlock
optional PageRoundedSize (PageRoundedSize a, size_t b)
optional PageRoundedSize (std::optional<PageRoundedSize> a, std::optional<PageRoundedSize> b)
optional PageRoundedSize (std::optional<PageRoundedSize> a, std::optional<PageRoundedSize> b)
optional PageRoundedSize (std::optional<PageRoundedSize> a, size_t b)
optional PageRoundedSize (PageRoundedSize a, std::optional<PageRoundedSize> b)
optional PageRoundedSize (std::optional<PageRoundedSize> a, PageRoundedSize b)
optional PageRoundedSize (std::optional<PageRoundedSize> a, std::optional<PageRoundedSize> b)
optional PageRoundedSize (PageRoundedSize aPageRoundedSize b)