-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix FreeBSD build failures. Update tests for FreeBSD #92
Changes from 2 commits
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,10 @@ | |
#include <sys/syscall.h> | ||
#include <pthread.h> | ||
|
||
#if __FreeBSD__ | ||
#include <pthread_np.h> | ||
#endif | ||
|
||
pid_t GetCurrentThreadId() | ||
{ | ||
pid_t tid = 0; | ||
|
@@ -17,6 +21,9 @@ pid_t GetCurrentThreadId() | |
uint64_t tid64; | ||
pthread_threadid_np(NULL, &tid64); | ||
tid = (pid_t)tid64; | ||
#elif defined(__FreeBSD__) | ||
tid = pthread_getthreadid_np(); | ||
return (int)tid; | ||
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. This cast is superfluous - this function returns 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. This one...I tried my best here to follow what is done under dotNET for |
||
#endif | ||
return tid; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,11 @@ | |
#include <sys/sysctl.h> | ||
#endif | ||
|
||
#if __FreeBSD__ | ||
#include <sys/types.h> | ||
#include <sys/sysctl.h> | ||
#endif | ||
|
||
//! @brief GetPPid returns the parent process id for a process | ||
//! | ||
//! GetPPid | ||
|
@@ -26,20 +31,20 @@ | |
//! | ||
pid_t GetPPid(pid_t pid) | ||
{ | ||
|
||
#if defined(__APPLE__) && defined(__MACH__) | ||
|
||
#if defined (__APPLE__) && defined(__MACH__) || defined(__FreeBSD__) | ||
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. roll this commit into previous? |
||
const pid_t PIDUnknown = UINT_MAX; | ||
struct kinfo_proc info; | ||
size_t length = sizeof(struct kinfo_proc); | ||
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}; | ||
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid }; | ||
if (sysctl(mib, 4, &info, &length, NULL, 0) < 0) | ||
return PIDUnknown; | ||
if (length == 0) | ||
return PIDUnknown; | ||
|
||
#if defined (__APPLE__) && defined(__MACH__) | ||
return info.kp_eproc.e_ppid; | ||
|
||
#elif defined(__FreeBSD__) | ||
return info.ki_ppid; | ||
#endif | ||
#else | ||
|
||
return UINT_MAX; | ||
|
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.
It seems strange to pass
-Wl
with no arg. Of course the oddity was just duplicated from the Darwin case (where it exists in the first public version of this file).It seems to me we ought to just mimic the Linux behaviour here, e.g. make the existing case above
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
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.
I found it unusual too, but opted to include it as I assumed if it was important enough for
"Darwin"
to have it then so should"FreeBSD"
. I will go ahead and add"FreeBSD"
to the"Linux"
case as suggested. Thanks!