mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-11-14 10:10:12 +01:00
Common: reformat (#4720)
* common: format AlignedMalloc.cpp * common: format AppTrait.h * common: format Assertions.h * common: format CheckedStaticBox * common: format Console * common: format Dependencies.h * common: format EmbeddedImage * common: format EventSource * common: format Exceptions * common: format FastFormatString.cpp * common: format General.h * common: format InitInterface * common: format MathUtils.h * common: format MemsetFast/MemcpyFast * common: format Mutex.cpp * common: format PageFaultSource.h * common: format Path.h * common: format PathUtils.cpp * common: format Pcsx2Types.h * common: format Perf * common: format PersistentThread.h * common: format RwMutex * common: format SafeArray * common: format ScopedAlloc.h * common: format ScopedPtrMT.h * common: format Semaphore.cpp * common: format StringHelpers * common: format ThreadTools.cpp * common: format Threading.h * common: format ThreadingDialogs * common: format ThreadingInternal.h * common: format TraceLog.h * common: format VirtualMemory.cpp * common: format pxCheckBox * common: format pxEvents.h * common: format pxForwardDefs.h * common: format pxRadioPanel * common: format pxStaticText * common: format pxStreams * common: format pxTranslate.cpp * common: format pxWindowTextWriter.cpp * common: format wxAppWithHelpers * common: format wxBaseTools.h * common: format wxGuiTools * common: format wxHelpers.cpp * common: format Darwin directory * common: format Linux directory * common: format Windows directory * common: format LnxCpuDetect.cpp * common: format WinCpuDetect.cpp * common: format bmi.cpp * common: format cpudetect.cpp * common: format cpu_detect_internal.h * common: format fpu.cpp * common: format groups.cpp * common: format instructions.h * common: format internal.h * common: format jmp.cpp * common: format legacy.cpp * common: format legacy_instructions.h * common: format legacy_internal.h * common: format movs.cpp * common: format simd.cpp * common: format tools.h * common: format x86emitter.cpp * common: format x86types.h * common: format bmi.h * common: format dwshift.h * common: format group1.h group2.h group3.h * common: format incdec.h * common: format jmpcall.h * common: format movs.h * common: format simd_arithmetic.h * common: format simd_comparisons.h * common: format simd_helpers.h * common: format simd_moremovs.h * common: format simd_shufflepack.h * common: format simd_templated_helpers.h * common: format test.h
This commit is contained in:
1 parent
f9bf87f50d
commit
13dfceff48
102 files changed
+13189
-12692
No files matched your search
@@ -29,27 +29,27 @@
|
||||
|
||||
__forceinline void Threading::Sleep(int ms)
|
||||
{
|
||||
usleep(1000 * ms);
|
||||
usleep(1000 * ms);
|
||||
}
|
||||
|
||||
// For use in spin/wait loops, acts as a hint to Intel CPUs and should, in theory
|
||||
// improve performance and reduce cpu power consumption.
|
||||
__forceinline void Threading::SpinWait()
|
||||
{
|
||||
// If this doesn't compile you can just comment it out (it only serves as a
|
||||
// performance hint and isn't required).
|
||||
__asm__("pause");
|
||||
// If this doesn't compile you can just comment it out (it only serves as a
|
||||
// performance hint and isn't required).
|
||||
__asm__("pause");
|
||||
}
|
||||
|
||||
__forceinline void Threading::EnableHiresScheduler()
|
||||
{
|
||||
// Darwin has customizable schedulers, see xnu/osfmk/man. Not
|
||||
// implemented yet though (and not sure if useful for pcsx2).
|
||||
// Darwin has customizable schedulers, see xnu/osfmk/man. Not
|
||||
// implemented yet though (and not sure if useful for pcsx2).
|
||||
}
|
||||
|
||||
__forceinline void Threading::DisableHiresScheduler()
|
||||
{
|
||||
// see EnableHiresScheduler()
|
||||
// see EnableHiresScheduler()
|
||||
}
|
||||
|
||||
// Just like on Windows, this is not really the number of ticks per second,
|
||||
@@ -58,27 +58,28 @@ __forceinline void Threading::DisableHiresScheduler()
|
||||
// doing this will of course yield precision loss.
|
||||
u64 Threading::GetThreadTicksPerSecond()
|
||||
{
|
||||
return 1000000; // the *CpuTime() functions return values in microseconds
|
||||
return 1000000; // the *CpuTime() functions return values in microseconds
|
||||
}
|
||||
|
||||
// gets the CPU time used by the current thread (both system and user), in
|
||||
// microseconds, returns 0 on failure
|
||||
static u64 getthreadtime(thread_port_t thread)
|
||||
{
|
||||
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
|
||||
thread_basic_info_data_t info;
|
||||
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
|
||||
thread_basic_info_data_t info;
|
||||
|
||||
kern_return_t kr = thread_info(thread, THREAD_BASIC_INFO,
|
||||
(thread_info_t)&info, &count);
|
||||
if (kr != KERN_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
kern_return_t kr = thread_info(thread, THREAD_BASIC_INFO,
|
||||
(thread_info_t)&info, &count);
|
||||
if (kr != KERN_SUCCESS)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// add system and user time
|
||||
return (u64)info.user_time.seconds * (u64)1e6 +
|
||||
(u64)info.user_time.microseconds +
|
||||
(u64)info.system_time.seconds * (u64)1e6 +
|
||||
(u64)info.system_time.microseconds;
|
||||
// add system and user time
|
||||
return (u64)info.user_time.seconds * (u64)1e6 +
|
||||
(u64)info.user_time.microseconds +
|
||||
(u64)info.system_time.seconds * (u64)1e6 +
|
||||
(u64)info.system_time.microseconds;
|
||||
}
|
||||
|
||||
// Returns the current timestamp (not relative to a real world clock) in
|
||||
@@ -88,44 +89,45 @@ static u64 getthreadtime(thread_port_t thread)
|
||||
// not very good.
|
||||
u64 Threading::GetThreadCpuTime()
|
||||
{
|
||||
// we could also use mach_thread_self() and mach_port_deallocate(), but
|
||||
// that calls upon mach traps (kinda like system calls). Unless I missed
|
||||
// something in the COMMPAGE (like Linux vDSO) which makes overrides it
|
||||
// to be user-space instead. In contract,
|
||||
// pthread_mach_thread_np(pthread_self()) is entirely in user-space.
|
||||
u64 us = getthreadtime(pthread_mach_thread_np(pthread_self()));
|
||||
return us * 10ULL;
|
||||
// we could also use mach_thread_self() and mach_port_deallocate(), but
|
||||
// that calls upon mach traps (kinda like system calls). Unless I missed
|
||||
// something in the COMMPAGE (like Linux vDSO) which makes overrides it
|
||||
// to be user-space instead. In contract,
|
||||
// pthread_mach_thread_np(pthread_self()) is entirely in user-space.
|
||||
u64 us = getthreadtime(pthread_mach_thread_np(pthread_self()));
|
||||
return us * 10ULL;
|
||||
}
|
||||
|
||||
u64 Threading::pxThread::GetCpuTime() const
|
||||
{
|
||||
// Get the cpu time for the thread belonging to this object. Use m_native_id and/or
|
||||
// m_native_handle to implement it. Return value should be a measure of total time the
|
||||
// thread has used on the CPU (scaled by the value returned by GetThreadTicksPerSecond(),
|
||||
// which typically would be an OS-provided scalar or some sort).
|
||||
if (!m_native_id) {
|
||||
return 0;
|
||||
}
|
||||
// Get the cpu time for the thread belonging to this object. Use m_native_id and/or
|
||||
// m_native_handle to implement it. Return value should be a measure of total time the
|
||||
// thread has used on the CPU (scaled by the value returned by GetThreadTicksPerSecond(),
|
||||
// which typically would be an OS-provided scalar or some sort).
|
||||
if (!m_native_id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return getthreadtime((thread_port_t)m_native_id) * 10ULL;
|
||||
return getthreadtime((thread_port_t)m_native_id) * 10ULL;
|
||||
}
|
||||
|
||||
void Threading::pxThread::_platform_specific_OnStartInThread()
|
||||
{
|
||||
m_native_id = (uptr)mach_thread_self();
|
||||
m_native_id = (uptr)mach_thread_self();
|
||||
}
|
||||
|
||||
void Threading::pxThread::_platform_specific_OnCleanupInThread()
|
||||
{
|
||||
// cleanup of handles that were upened in
|
||||
// _platform_specific_OnStartInThread
|
||||
mach_port_deallocate(mach_task_self(), (thread_port_t)m_native_id);
|
||||
// cleanup of handles that were upened in
|
||||
// _platform_specific_OnStartInThread
|
||||
mach_port_deallocate(mach_task_self(), (thread_port_t)m_native_id);
|
||||
}
|
||||
|
||||
// name can be up to 16 bytes
|
||||
void Threading::SetNameOfCurrentThread(const char *name)
|
||||
void Threading::SetNameOfCurrentThread(const char* name)
|
||||
{
|
||||
pthread_setname_np(name);
|
||||
pthread_setname_np(name);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user