-
-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move get_stack_ptr to source #6594
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -8,6 +8,7 @@ | |||
|
||||
#pragma once | ||||
|
||||
#include <hpx/config.hpp> | ||||
#include <hpx/config/compiler_specific.hpp> | ||||
#include <hpx/config/defines.hpp> | ||||
|
||||
|
@@ -28,28 +29,6 @@ | |||
#include <limits> | ||||
|
||||
namespace hpx::threads::coroutines::detail { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the function is defined only for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what you are describing already happens since
|
||||
|
||||
inline std::size_t get_stack_ptr() noexcept | ||||
{ | ||||
#if defined(HPX_HAVE_BUILTIN_FRAME_ADDRESS) | ||||
return std::size_t(__builtin_frame_address(0)); | ||||
#else | ||||
std::size_t stack_ptr = (std::numeric_limits<std::size_t>::max)(); | ||||
#if defined(__x86_64__) || defined(__amd64) | ||||
asm("movq %%rsp, %0" : "=r"(stack_ptr)); | ||||
#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \ | ||||
defined(__i686__) | ||||
asm("movl %%esp, %0" : "=r"(stack_ptr)); | ||||
#elif defined(__powerpc__) | ||||
void* stack_ptr_p = &stack_ptr; | ||||
asm("stw %%r1, 0(%0)" : "=&r"(stack_ptr_p)); | ||||
#elif defined(__arm__) | ||||
asm("mov %0, sp" : "=r"(stack_ptr)); | ||||
#elif defined(__riscv) | ||||
__asm__ __volatile__("add %0, x0, sp" : "=r"(stack_ptr)); | ||||
#endif | ||||
return stack_ptr; | ||||
#endif | ||||
} | ||||
HPX_CORE_EXPORT std::size_t get_stack_ptr() noexcept; | ||||
} // namespace hpx::threads::coroutines::detail | ||||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2013-2016 Thomas Heller | ||
// Copyright (c) 2022 Christopher Taylor | ||
// | ||
// SPDX-License-Identifier: BSL-1.0 | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <hpx/coroutines/detail/get_stack_pointer.hpp> | ||
|
||
#if !defined(HPX_WINDOWS) | ||
|
||
#include <cstddef> | ||
#include <limits> | ||
|
||
namespace hpx::threads::coroutines::detail { | ||
|
||
std::size_t get_stack_ptr() noexcept | ||
{ | ||
#if defined(HPX_HAVE_BUILTIN_FRAME_ADDRESS) | ||
return std::size_t(__builtin_frame_address(0)); | ||
#else | ||
std::size_t stack_ptr = (std::numeric_limits<std::size_t>::max)(); | ||
#if defined(__x86_64__) || defined(__amd64) | ||
asm("movq %%rsp, %0" : "=r"(stack_ptr)); | ||
#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || \ | ||
defined(__i686__) | ||
asm("movl %%esp, %0" : "=r"(stack_ptr)); | ||
#elif defined(__powerpc__) | ||
void* stack_ptr_p = &stack_ptr; | ||
asm("stw %%r1, 0(%0)" : "=&r"(stack_ptr_p)); | ||
#elif defined(__arm__) | ||
asm("mov %0, sp" : "=r"(stack_ptr)); | ||
#elif defined(__riscv) | ||
__asm__ __volatile__("add %0, x0, sp" : "=r"(stack_ptr)); | ||
#endif | ||
return stack_ptr; | ||
#endif | ||
} | ||
} // namespace hpx::threads::coroutines::detail | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you include <hpx/config.hpp>, then the other two #includes are not needed anymore (those are pulled in by it).