libobs/util: Add function to get Rosetta translation status
parent
a255b0f742
commit
3b64e74660
|
@ -478,3 +478,12 @@ Other Functions
|
|||
.. function:: uint64_t os_get_proc_virtual_size(void)
|
||||
|
||||
Returns the virtual memory size of the current process.
|
||||
|
||||
---------------------
|
||||
|
||||
.. function:: bool os_get_emulation_status(void)
|
||||
|
||||
Returns true if the current process is a x64 binary and is being emulated or translated
|
||||
by the host operating system. On macOS, it returns true when a x64 binary is
|
||||
being translated by Rosetta and running on Apple Silicon Macs. This function is not yet
|
||||
implemented on Windows and Linux and will always return false on those platforms.
|
||||
|
|
|
@ -319,6 +319,21 @@ static int physical_cores = 0;
|
|||
static int logical_cores = 0;
|
||||
static bool core_count_initialized = false;
|
||||
|
||||
bool os_get_emulation_status(void)
|
||||
{
|
||||
#ifdef __aarch64__
|
||||
return false;
|
||||
#else
|
||||
int rosettaTranslated = 0;
|
||||
size_t size = sizeof(rosettaTranslated);
|
||||
if (sysctlbyname("sysctl.proc_translated", &rosettaTranslated, &size,
|
||||
NULL, 0) == -1)
|
||||
return false;
|
||||
|
||||
return rosettaTranslated == 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void os_get_cores_internal(void)
|
||||
{
|
||||
if (core_count_initialized)
|
||||
|
|
|
@ -401,6 +401,11 @@ char *os_get_executable_path_ptr(const char *name)
|
|||
return path.array;
|
||||
}
|
||||
|
||||
bool os_get_emulation_status(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool os_file_exists(const char *path)
|
||||
|
|
|
@ -992,6 +992,11 @@ bool is_64_bit_windows(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool os_get_emulation_status(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void get_reg_dword(HKEY hkey, LPCWSTR sub_key, LPCWSTR value_name,
|
||||
struct reg_dword *info)
|
||||
{
|
||||
|
|
|
@ -123,6 +123,8 @@ EXPORT char *os_get_abs_path_ptr(const char *path);
|
|||
|
||||
EXPORT const char *os_get_path_extension(const char *path);
|
||||
|
||||
EXPORT bool os_get_emulation_status(void);
|
||||
|
||||
struct os_dir;
|
||||
typedef struct os_dir os_dir_t;
|
||||
|
||||
|
|
Loading…
Reference in New Issue