mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +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
Notes:
sideshowbarker
2024-07-17 08:46:23 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/ae4d871183 Pull-request: https://github.com/SerenityOS/serenity/pull/14539 Reviewed-by: https://github.com/ADKaster
1 changed files with 15 additions and 2 deletions
|
@ -14,6 +14,9 @@
|
|||
# include <serenity.h>
|
||||
#elif defined(__linux__) or defined(AK_OS_MACOS)
|
||||
# include <pthread.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
# include <pthread.h>
|
||||
# include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
namespace AK {
|
||||
|
@ -25,13 +28,23 @@ StackInfo::StackInfo()
|
|||
perror("get_stack_bounds");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
#elif defined(__linux__) or defined(__FreeBSD__)
|
||||
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) {
|
||||
fprintf(stderr, "pthread_getattr_np: %s\n", strerror(rc));
|
||||
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) {
|
||||
fprintf(stderr, "pthread_attr_getstack: %s\n", strerror(rc));
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
Loading…
Reference in a new issue