Skip to content

Commit

Permalink
Implement memory queries on iOS/tvOS
Browse files Browse the repository at this point in the history
  • Loading branch information
warmenhoven authored and LibretroAdmin committed Jul 1, 2023
1 parent 9320122 commit 9d7ce37
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions frontend/drivers/platform_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <sys/utsname.h>

#include <mach/mach_host.h>
#include <mach/mach.h>

#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFArray.h>
Expand Down Expand Up @@ -764,7 +764,6 @@ static int frontend_darwin_parse_drive_list(void *data, bool load_content)
return ret;
}

/* TODO/FIXME - is adding iOS/tvOS support possible here? */
static uint64_t frontend_darwin_get_total_mem(void)
{
#if defined(OSX)
Expand All @@ -774,11 +773,15 @@ static uint64_t frontend_darwin_get_total_mem(void)
size_t len = sizeof(size);
if (sysctl(mib, namelen, &size, &len, NULL, 0) >= 0)
return size;
#elif defined(IOS)
task_vm_info_data_t vmInfo;
mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
if (task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count) == KERN_SUCCESS)
return vmInfo.resident_size_peak;
#endif
return 0;
}

/* TODO/FIXME - is adding iOS/tvOS support possible here? */
static uint64_t frontend_darwin_get_free_mem(void)
{
#if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200))
Expand All @@ -797,6 +800,11 @@ static uint64_t frontend_darwin_get_free_mem(void)
(int64_t)vm_stats.wire_count) * (int64_t)page_size;
return used_memory;
}
#elif defined(IOS)
task_vm_info_data_t vmInfo;
mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
if (task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count) == KERN_SUCCESS)
return vmInfo.resident_size_peak - vmInfo.resident_size;
#endif
return 0;
}
Expand Down

0 comments on commit 9d7ce37

Please sign in to comment.