mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
AK: Port StackInfo to FreeBSD
This can almost be identical to the Linux version, except that the `pthread_attr_t` object is populated using a call to `pthread_attr_get_np` instead of `pthread_getattr_np`. FreeBSD also needs `pthread_atttr_t` to be initialized using `pthread_attr_init` instead of zero-initialization, but it's the technically correct thing to do on Linux as well.
This commit is contained in:
parent
cd0fb6dcc8
commit
ae4d871183
1 changed files with 15 additions and 2 deletions
|
@ -14,6 +14,9 @@
|
||||||
# include <serenity.h>
|
# include <serenity.h>
|
||||||
#elif defined(__linux__) or defined(AK_OS_MACOS)
|
#elif defined(__linux__) or defined(AK_OS_MACOS)
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
# include <pthread.h>
|
||||||
|
# include <pthread_np.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
@ -25,13 +28,23 @@ StackInfo::StackInfo()
|
||||||
perror("get_stack_bounds");
|
perror("get_stack_bounds");
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__) or defined(__FreeBSD__)
|
||||||
int rc;
|
int rc;
|
||||||
pthread_attr_t attr = {};
|
pthread_attr_t attr;
|
||||||
|
pthread_attr_init(&attr);
|
||||||
|
|
||||||
|
# ifdef __linux__
|
||||||
if ((rc = pthread_getattr_np(pthread_self(), &attr)) != 0) {
|
if ((rc = pthread_getattr_np(pthread_self(), &attr)) != 0) {
|
||||||
fprintf(stderr, "pthread_getattr_np: %s\n", strerror(rc));
|
fprintf(stderr, "pthread_getattr_np: %s\n", strerror(rc));
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
# else
|
||||||
|
if ((rc = pthread_attr_get_np(pthread_self(), &attr)) != 0) {
|
||||||
|
fprintf(stderr, "pthread_attr_get_np: %s\n", strerror(rc));
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
if ((rc = pthread_attr_getstack(&attr, (void**)&m_base, &m_size)) != 0) {
|
if ((rc = pthread_attr_getstack(&attr, (void**)&m_base, &m_size)) != 0) {
|
||||||
fprintf(stderr, "pthread_attr_getstack: %s\n", strerror(rc));
|
fprintf(stderr, "pthread_attr_getstack: %s\n", strerror(rc));
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue