time(): Split into architecture dependent functions

This fixes the bug reported as POSTK_ARCH_DEP_13 and POSTK_DEBUG_ARCH_DEP_13.
This commit is contained in:
Masamichi Takagi
2017-12-23 11:36:52 +09:00
parent 0cda763f95
commit 9a5d5feb9c
4 changed files with 24 additions and 24 deletions

View File

@ -13,6 +13,7 @@
#include <hwcap.h>
#include <prctl.h>
#include <limits.h>
#include <syscall.h>
extern void ptrace_report_signal(struct thread *thread, int sig);
extern void clear_single_step(struct thread *thread);
@ -2497,4 +2498,15 @@ out:
return mpsr->phase_ret;
}
time_t time(void) {
struct timespec ats;
if (gettime_local_support) {
calculate_time_from_tsc(&ats);
return ats.tv_sec;
}
return (time_t)0;
}
/*** End of File ***/

View File

@ -30,6 +30,7 @@
#include <ihk/ikc.h>
#include <page.h>
#include <limits.h>
#include <syscall.h>
void terminate(int, int);
extern long do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact);
@ -2540,4 +2541,14 @@ out:
return mpsr->phase_ret;
}
time_t time(void) {
struct syscall_request sreq IHK_DMA_ALIGN;
struct thread *thread = cpu_local_var(current);
time_t ret;
sreq.number = __NR_time;
sreq.args[0] = (uintptr_t)NULL;
ret = (time_t)do_syscall(&sreq, ihk_mc_get_processor_id(), thread->proc->pid);
return ret;
}
/*** End of File ***/

View File

@ -472,6 +472,7 @@ int arch_setup_vdso(void);
int arch_cpu_read_write_register(struct ihk_os_cpu_register *desc,
enum mcctrl_os_cpu_operation op);
struct vm_range_numa_policy *vm_range_policy_search(struct process_vm *vm, uintptr_t addr);
time_t time(void);
#ifndef POSTK_DEBUG_ARCH_DEP_52
#define VDSO_MAXPAGES 2

View File

@ -4689,30 +4689,6 @@ struct shminfo the_shminfo = {
};
struct shm_info the_shm_info = { 0, };
time_t time(void) {
#ifndef POSTK_DEBUG_ARCH_DEP_13 /* arch depend tmp hide */
struct syscall_request sreq IHK_DMA_ALIGN;
struct thread *thread = cpu_local_var(current);
#endif /* POSTK_DEBUG_ARCH_DEP_13 */
#ifdef POSTK_DEBUG_ARCH_DEP_49 /* time() local calculate added. */
struct timespec ats;
if (gettime_local_support) {
calculate_time_from_tsc(&ats);
return ats.tv_sec;
}
#endif /* POSTK_DEBUG_ARCH_DEP_49 */
#ifdef POSTK_DEBUG_ARCH_DEP_13 /* arch depend tmp hide */
return (time_t)0;
#else /* POSTK_DEBUG_ARCH_DEP_13 */
sreq.number = __NR_time;
sreq.args[0] = (uintptr_t)NULL;
return (time_t)do_syscall(&sreq, ihk_mc_get_processor_id(), thread->proc->pid);
#endif /* POSTK_DEBUG_ARCH_DEP_13 */
}
static int make_shmid(struct shmobj *obj)
{
return ((int)obj->index << 16) | obj->ds.shm_perm.seq;