2020-04-23 14:05:57 +02:00
|
|
|
// The Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) The Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
2023-01-18 05:21:09 +01:00
|
|
|
namespace boost::context
|
|
|
|
{
|
|
|
|
struct stack_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace boost::coroutines
|
|
|
|
{
|
|
|
|
struct stack_context;
|
|
|
|
}
|
|
|
|
|
2020-04-23 14:05:57 +02:00
|
|
|
namespace ircd::ctx
|
|
|
|
{
|
|
|
|
struct stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ircd::ctx::stack
|
|
|
|
{
|
2020-10-14 10:34:23 +02:00
|
|
|
struct allocator;
|
|
|
|
|
2020-10-14 04:48:55 +02:00
|
|
|
mutable_buffer buf; // complete allocation
|
2020-10-14 10:34:23 +02:00
|
|
|
uintptr_t base {0}; // base frame pointer
|
2020-04-23 14:05:57 +02:00
|
|
|
size_t max {0}; // User given stack size
|
|
|
|
size_t at {0}; // Updated for profiling at sleep
|
2020-04-23 14:09:10 +02:00
|
|
|
size_t peak {0}; // Updated for profiling; maximum
|
2020-04-23 14:05:57 +02:00
|
|
|
|
2020-10-14 10:34:23 +02:00
|
|
|
stack(const mutable_buffer &) noexcept;
|
2020-04-23 14:05:57 +02:00
|
|
|
|
|
|
|
static const stack &get(const ctx &) noexcept;
|
|
|
|
static stack &get(ctx &) noexcept;
|
|
|
|
};
|
2023-01-18 05:21:09 +01:00
|
|
|
|
|
|
|
struct [[gnu::visibility("hidden")]]
|
|
|
|
ircd::ctx::stack::allocator
|
|
|
|
{
|
|
|
|
mutable_buffer &buf;
|
|
|
|
bool owner {false};
|
|
|
|
|
|
|
|
void deallocate(boost::coroutines::stack_context &) noexcept;
|
|
|
|
void allocate(boost::coroutines::stack_context &, size_t size);
|
|
|
|
|
|
|
|
void deallocate(boost::context::stack_context &) noexcept;
|
|
|
|
boost::context::stack_context allocate();
|
|
|
|
};
|