From: Chip Davis cdavis@codeweavers.com
Signed-off-by: Chip Davis cdavis5x@gmail.com --- dlls/ntdll/unix/system.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 56a31f5e4757..1b92649ba284 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -1911,6 +1911,22 @@ static void get_performance_info( SYSTEM_PERFORMANCE_INFORMATION *info ) info->IdleTime.QuadPart = (ULONGLONG)ptimes[CP_IDLE] * 10000000 / clockrate.stathz; } } +#elif defined(__APPLE__) + { + host_name_port_t host = mach_host_self(); + struct host_cpu_load_info load_info; + mach_msg_type_number_t count; + + count = HOST_CPU_LOAD_INFO_COUNT; + if (host_statistics(host, HOST_CPU_LOAD_INFO, (host_info_t)&load_info, &count) == KERN_SUCCESS) + { + /* Believe it or not, based on my reading of XNU source, this is + * already in the units we want (100 ns). + */ + info->IdleTime.QuadPart = load_info.cpu_ticks[CPU_STATE_IDLE]; + } + mach_port_deallocate(mach_task_self(), host); + } #else { static ULONGLONG idle;
Signed-off-by: Chip Davis cdavis5x@gmail.com --- dlls/ntdll/unix/loader.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 0617fca631c1..2878cb99faa5 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -644,6 +644,20 @@ static void init_paths( char *argv[] ) bin_dir = realpath_dirname( path ); free( path ); } +#elif defined(__APPLE__) + { + uint32_t path_size = PATH_MAX; + char *path = malloc( path_size ); + while (path && _NSGetExecutablePath( path, &path_size ) < 0) + path = realloc( path, path_size ); + if (!path) + bin_dir = realpath_dirname( argv0 ); + else + { + bin_dir = realpath_dirname( path ); + free( path ); + } + } #else bin_dir = realpath_dirname( argv0 ); #endif
Signed-off-by: Chip Davis cdavis5x@gmail.com --- dlls/ntdll/unix/thread.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 451402159d46..3e9e4d740e6a 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -2285,6 +2285,21 @@ ULONG WINAPI NtGetCurrentProcessorNumber(void) if (res != -1) return processor; #endif
+#if defined(__APPLE__) && (defined(__i386__) || defined(__x86_64__)) + /* A little known feature of macOS is that it will stash the CPU number + * in the low 12 bits of the IDTR's limit field. + */ +#include "pshpack1.h" + struct + { + USHORT limit; + ULONG_PTR base; + } idtr; +#include "poppack.h" + asm("sidt %0" : "=m" (idtr)); + return idtr.limit & 0xfff; +#endif + if (peb->NumberOfProcessors > 1) { ULONG_PTR thread_mask, processor_mask;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=112891
Your paranoid android.
=== debian11 (64 bit WoW report) ===
ntdll: env.c:461: Test failed: wrong end ptr 000000000003197C/0000000000031980
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=112889
Your paranoid android.
=== debian11 (64 bit WoW report) ===
ntdll: env.c:461: Test failed: wrong end ptr 000000000003197C/0000000000031980
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=112890
Your paranoid android.
=== debian11 (64 bit WoW report) ===
ntdll: env.c:461: Test failed: wrong end ptr 000000000003197C/0000000000031980