mirror of https://github.com/PCSX2/pcsx2.git
utilities: Add FreeBSD thread name implementation
This commit is contained in:
parent
e23b6e3484
commit
280ca1dd85
|
@ -16,16 +16,20 @@
|
||||||
|
|
||||||
#include "../PrecompiledHeader.h"
|
#include "../PrecompiledHeader.h"
|
||||||
#include "PersistentThread.h"
|
#include "PersistentThread.h"
|
||||||
#include <sys/prctl.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#if defined(__linux__)
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#elif defined(__unix__)
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// We wont need this until we actually have this more then just stubbed out, so I'm commenting this out
|
// We wont need this until we actually have this more then just stubbed out, so I'm commenting this out
|
||||||
// to remove an unneeded dependency.
|
// to remove an unneeded dependency.
|
||||||
//#include "x86emitter/tools.h"
|
//#include "x86emitter/tools.h"
|
||||||
|
|
||||||
#if !defined(__linux__) && !defined(__WXMAC__)
|
#if !defined(__unix__)
|
||||||
|
|
||||||
# pragma message( "LnxThreads.cpp should only be compiled by projects or makefiles targeted at Linux/Mac distros.")
|
# pragma message( "LnxThreads.cpp should only be compiled by projects or makefiles targeted at Linux/BSD distros.")
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -68,7 +72,7 @@ static u64 get_thread_time(uptr id = 0)
|
||||||
{
|
{
|
||||||
clockid_t cid;
|
clockid_t cid;
|
||||||
if (id) {
|
if (id) {
|
||||||
int err = pthread_getcpuclockid(id, &cid);
|
int err = pthread_getcpuclockid((pthread_t)id, &cid);
|
||||||
if (err) return 0;
|
if (err) return 0;
|
||||||
} else {
|
} else {
|
||||||
cid = CLOCK_THREAD_CPUTIME_ID;
|
cid = CLOCK_THREAD_CPUTIME_ID;
|
||||||
|
@ -113,9 +117,13 @@ void Threading::pxThread::_platform_specific_OnCleanupInThread()
|
||||||
|
|
||||||
void Threading::pxThread::_DoSetThreadName( const char* name )
|
void Threading::pxThread::_DoSetThreadName( const char* name )
|
||||||
{
|
{
|
||||||
|
#if defined(__linux__)
|
||||||
// Extract of manpage: "The name can be up to 16 bytes long, and should be
|
// Extract of manpage: "The name can be up to 16 bytes long, and should be
|
||||||
// null-terminated if it contains fewer bytes."
|
// null-terminated if it contains fewer bytes."
|
||||||
prctl(PR_SET_NAME, name, 0, 0, 0);
|
prctl(PR_SET_NAME, name, 0, 0, 0);
|
||||||
|
#elif defined(__unix__)
|
||||||
|
pthread_set_name_np(pthread_self(), name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue