mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 05:51:06 +00:00
Replaced get_tick_per_sec() by NANOSECONDS_PER_SECOND
This patch replaces get_ticks_per_sec() calls with the macro NANOSECONDS_PER_SECOND. Also, as there are no callers, get_ticks_per_sec() is then removed. This replacement improves the readability and understandability of code. For example, timer_mod(fdctrl->result_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (get_ticks_per_sec() / 50)); NANOSECONDS_PER_SECOND makes it obvious that qemu_clock_get_ns matches the unit of the expression on the right side of the plus. Backports commit 73bcb24d932912f8e75e1d88da0fc0ac6d4bce78 from qemu
This commit is contained in:
parent
c024ca9f49
commit
d9fdc180d7
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_aarch64
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_aarch64
|
||||
#define get_system_memory get_system_memory_aarch64
|
||||
#define get_ticks_per_sec get_ticks_per_sec_aarch64
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_aarch64
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__aarch64
|
||||
#define gt_cntfrq_access gt_cntfrq_access_aarch64
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_aarch64eb
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_aarch64eb
|
||||
#define get_system_memory get_system_memory_aarch64eb
|
||||
#define get_ticks_per_sec get_ticks_per_sec_aarch64eb
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_aarch64eb
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__aarch64eb
|
||||
#define gt_cntfrq_access gt_cntfrq_access_aarch64eb
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_arm
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_arm
|
||||
#define get_system_memory get_system_memory_arm
|
||||
#define get_ticks_per_sec get_ticks_per_sec_arm
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_arm
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__arm
|
||||
#define gt_cntfrq_access gt_cntfrq_access_arm
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_armeb
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_armeb
|
||||
#define get_system_memory get_system_memory_armeb
|
||||
#define get_ticks_per_sec get_ticks_per_sec_armeb
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_armeb
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__armeb
|
||||
#define gt_cntfrq_access gt_cntfrq_access_armeb
|
||||
|
|
|
@ -1363,7 +1363,6 @@ symbols = (
|
|||
'get_phys_addr_v5',
|
||||
'get_phys_addr_v6',
|
||||
'get_system_memory',
|
||||
'get_ticks_per_sec',
|
||||
'g_list_insert_sorted_merged',
|
||||
'_GLOBAL_OFFSET_TABLE_',
|
||||
'gt_cntfrq_access',
|
||||
|
|
|
@ -50,8 +50,8 @@ static void cpu_mips_timer_update(CPUMIPSState *env)
|
|||
|
||||
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
wait = env->CP0_Compare - env->CP0_Count -
|
||||
(uint32_t)muldiv64(now, TIMER_FREQ, get_ticks_per_sec());
|
||||
next = now + muldiv64(wait, get_ticks_per_sec(), TIMER_FREQ);
|
||||
(uint32_t)muldiv64(now, TIMER_FREQ, NANOSECONDS_PER_SECOND);
|
||||
next = now + muldiv64(wait, NANOSECONDS_PER_SECOND, TIMER_FREQ);
|
||||
timer_mod(env->timer, next);
|
||||
#endif
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ uint32_t cpu_mips_get_count (CPUMIPSState *env)
|
|||
//}
|
||||
|
||||
return env->CP0_Count +
|
||||
(uint32_t)muldiv64(now, TIMER_FREQ, get_ticks_per_sec());
|
||||
(uint32_t)muldiv64(now, TIMER_FREQ, NANOSECONDS_PER_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ void cpu_mips_store_count (CPUMIPSState *env, uint32_t count)
|
|||
/* Store new count register */
|
||||
env->CP0_Count =
|
||||
count - (uint32_t)muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
||||
TIMER_FREQ, get_ticks_per_sec());
|
||||
TIMER_FREQ, NANOSECONDS_PER_SECOND);
|
||||
/* Update timer timer */
|
||||
cpu_mips_timer_update(env);
|
||||
}
|
||||
|
@ -127,5 +127,5 @@ void cpu_mips_stop_count(CPUMIPSState *env)
|
|||
{
|
||||
/* Store the current value */
|
||||
env->CP0_Count += (uint32_t)muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
||||
TIMER_FREQ, get_ticks_per_sec());
|
||||
TIMER_FREQ, NANOSECONDS_PER_SECOND);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "qemu-common.h"
|
||||
#include "qemu/host-utils.h"
|
||||
|
||||
#define NANOSECONDS_PER_SECOND 1000000000LL
|
||||
|
||||
/* timers */
|
||||
|
||||
#define SCALE_MS 1000000
|
||||
|
@ -149,11 +151,6 @@ void cpu_enable_ticks(void);
|
|||
/* Caller must hold BQL */
|
||||
void cpu_disable_ticks(void);
|
||||
|
||||
static inline int64_t get_ticks_per_sec(void)
|
||||
{
|
||||
return 1000000000LL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Low level clock functions
|
||||
*/
|
||||
|
@ -177,7 +174,7 @@ static inline int64_t get_clock(void)
|
|||
{
|
||||
LARGE_INTEGER ti;
|
||||
QueryPerformanceCounter(&ti);
|
||||
return muldiv64(ti.QuadPart, (uint32_t)get_ticks_per_sec(), (uint32_t)clock_freq);
|
||||
return muldiv64(ti.QuadPart, (uint32_t)NANOSECONDS_PER_SECOND, (uint32_t)clock_freq);
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_m68k
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_m68k
|
||||
#define get_system_memory get_system_memory_m68k
|
||||
#define get_ticks_per_sec get_ticks_per_sec_m68k
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_m68k
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__m68k
|
||||
#define gt_cntfrq_access gt_cntfrq_access_m68k
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_mips
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_mips
|
||||
#define get_system_memory get_system_memory_mips
|
||||
#define get_ticks_per_sec get_ticks_per_sec_mips
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_mips
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__mips
|
||||
#define gt_cntfrq_access gt_cntfrq_access_mips
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_mips64
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_mips64
|
||||
#define get_system_memory get_system_memory_mips64
|
||||
#define get_ticks_per_sec get_ticks_per_sec_mips64
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_mips64
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__mips64
|
||||
#define gt_cntfrq_access gt_cntfrq_access_mips64
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_mips64el
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_mips64el
|
||||
#define get_system_memory get_system_memory_mips64el
|
||||
#define get_ticks_per_sec get_ticks_per_sec_mips64el
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_mips64el
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__mips64el
|
||||
#define gt_cntfrq_access gt_cntfrq_access_mips64el
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_mipsel
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_mipsel
|
||||
#define get_system_memory get_system_memory_mipsel
|
||||
#define get_ticks_per_sec get_ticks_per_sec_mipsel
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_mipsel
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__mipsel
|
||||
#define gt_cntfrq_access gt_cntfrq_access_mipsel
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_powerpc
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_powerpc
|
||||
#define get_system_memory get_system_memory_powerpc
|
||||
#define get_ticks_per_sec get_ticks_per_sec_powerpc
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_powerpc
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__powerpc
|
||||
#define gt_cntfrq_access gt_cntfrq_access_powerpc
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_sparc
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_sparc
|
||||
#define get_system_memory get_system_memory_sparc
|
||||
#define get_ticks_per_sec get_ticks_per_sec_sparc
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_sparc
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__sparc
|
||||
#define gt_cntfrq_access gt_cntfrq_access_sparc
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_sparc64
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_sparc64
|
||||
#define get_system_memory get_system_memory_sparc64
|
||||
#define get_ticks_per_sec get_ticks_per_sec_sparc64
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_sparc64
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__sparc64
|
||||
#define gt_cntfrq_access gt_cntfrq_access_sparc64
|
||||
|
|
|
@ -714,7 +714,7 @@ void pmccntr_sync(CPUARMState *env)
|
|||
uint64_t temp_ticks;
|
||||
|
||||
temp_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
|
||||
get_ticks_per_sec(), 1000000);
|
||||
NANOSECONDS_PER_SECOND, 1000000);
|
||||
|
||||
if (env->cp15.c9_pmcr & PMCRD) {
|
||||
/* Increment once every 64 processor clock cycles */
|
||||
|
@ -753,7 +753,7 @@ static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri)
|
|||
}
|
||||
|
||||
total_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
|
||||
get_ticks_per_sec(), 1000000);
|
||||
NANOSECONDS_PER_SECOND, 1000000);
|
||||
|
||||
if (env->cp15.c9_pmcr & PMCRD) {
|
||||
/* Increment once every 64 processor clock cycles */
|
||||
|
@ -774,7 +774,7 @@ static void pmccntr_write(CPUARMState *env, const ARMCPRegInfo *ri,
|
|||
}
|
||||
|
||||
total_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
|
||||
get_ticks_per_sec(), 1000000);
|
||||
NANOSECONDS_PER_SECOND, 1000000);
|
||||
|
||||
if (env->cp15.c9_pmcr & PMCRD) {
|
||||
/* Increment once every 64 processor clock cycles */
|
||||
|
|
|
@ -1357,7 +1357,6 @@
|
|||
#define get_phys_addr_v5 get_phys_addr_v5_x86_64
|
||||
#define get_phys_addr_v6 get_phys_addr_v6_x86_64
|
||||
#define get_system_memory get_system_memory_x86_64
|
||||
#define get_ticks_per_sec get_ticks_per_sec_x86_64
|
||||
#define g_list_insert_sorted_merged g_list_insert_sorted_merged_x86_64
|
||||
#define _GLOBAL_OFFSET_TABLE_ _GLOBAL_OFFSET_TABLE__x86_64
|
||||
#define gt_cntfrq_access gt_cntfrq_access_x86_64
|
||||
|
|
Loading…
Reference in a new issue