mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Merge pull request #11162 from NixOS/rename-stack-limit
Rename osStackLow -> osStackLimit
This commit is contained in:
commit
b13ba7490c
1 changed files with 7 additions and 6 deletions
|
@ -86,12 +86,13 @@ void fixupBoehmStackPointer(void ** sp_ptr, void * _pthread_id)
|
||||||
auto pthread_id = reinterpret_cast<pthread_t>(_pthread_id);
|
auto pthread_id = reinterpret_cast<pthread_t>(_pthread_id);
|
||||||
pthread_attr_t pattr;
|
pthread_attr_t pattr;
|
||||||
size_t osStackSize;
|
size_t osStackSize;
|
||||||
void * osStackLow;
|
// The low address of the stack, which grows down.
|
||||||
|
void * osStackLimit;
|
||||||
void * osStackBase;
|
void * osStackBase;
|
||||||
|
|
||||||
# ifdef __APPLE__
|
# ifdef __APPLE__
|
||||||
osStackSize = pthread_get_stacksize_np(pthread_id);
|
osStackSize = pthread_get_stacksize_np(pthread_id);
|
||||||
osStackLow = pthread_get_stackaddr_np(pthread_id);
|
osStackLimit = pthread_get_stackaddr_np(pthread_id);
|
||||||
# else
|
# else
|
||||||
if (pthread_attr_init(&pattr)) {
|
if (pthread_attr_init(&pattr)) {
|
||||||
throw Error("fixupBoehmStackPointer: pthread_attr_init failed");
|
throw Error("fixupBoehmStackPointer: pthread_attr_init failed");
|
||||||
|
@ -110,18 +111,18 @@ void fixupBoehmStackPointer(void ** sp_ptr, void * _pthread_id)
|
||||||
# else
|
# else
|
||||||
# error "Need one of `pthread_attr_get_np` or `pthread_getattr_np`"
|
# error "Need one of `pthread_attr_get_np` or `pthread_getattr_np`"
|
||||||
# endif
|
# endif
|
||||||
if (pthread_attr_getstack(&pattr, &osStackLow, &osStackSize)) {
|
if (pthread_attr_getstack(&pattr, &osStackLimit, &osStackSize)) {
|
||||||
throw Error("fixupBoehmStackPointer: pthread_attr_getstack failed");
|
throw Error("fixupBoehmStackPointer: pthread_attr_getstack failed");
|
||||||
}
|
}
|
||||||
if (pthread_attr_destroy(&pattr)) {
|
if (pthread_attr_destroy(&pattr)) {
|
||||||
throw Error("fixupBoehmStackPointer: pthread_attr_destroy failed");
|
throw Error("fixupBoehmStackPointer: pthread_attr_destroy failed");
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
osStackBase = (char *) osStackLow + osStackSize;
|
osStackBase = (char *) osStackLimit + osStackSize;
|
||||||
// NOTE: We assume the stack grows down, as it does on all architectures we support.
|
// NOTE: We assume the stack grows down, as it does on all architectures we support.
|
||||||
// Architectures that grow the stack up are rare.
|
// Architectures that grow the stack up are rare.
|
||||||
if (sp >= osStackBase || sp < osStackLow) { // lo is outside the os stack
|
if (sp >= osStackBase || sp < osStackLimit) { // sp is outside the os stack
|
||||||
sp = osStackLow;
|
sp = osStackLimit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue