--- Gnu-Mach/kern/mach_clock.c 2020/09/02 04:36:57 1.1.1.1 +++ Gnu-Mach/kern/mach_clock.c 2020/09/02 04:45:20 1.1.1.4 @@ -33,9 +33,8 @@ * * Clock primitives. */ -#include -#include -#include + +#include #include #include @@ -44,25 +43,27 @@ #include #include #include "cpu_number.h" +#include #include #include -#include +#include #include +#include #include #include #include -#include #include +#include #include #include #include /* HZ */ #include +#include #if MACH_PCSAMPLE #include #endif - void softclock(); /* forward */ int hz = HZ; /* number of ticks per second */ @@ -89,7 +90,7 @@ int bigadj = 1000000; /* adjust 10*tick * } while (secs != mtime->check_seconds); * to read the time correctly. (On a multiprocessor this assumes * that processors see each other's writes in the correct order. - * We may have to insert fence operations.) + * We have to insert write fence operations.) FIXME */ mapped_time_value_t *mtime = 0; @@ -98,7 +99,9 @@ mapped_time_value_t *mtime = 0; MACRO_BEGIN \ if (mtime != 0) { \ mtime->check_seconds = (time)->seconds; \ + asm volatile("":::"memory"); \ mtime->microseconds = (time)->microseconds; \ + asm volatile("":::"memory"); \ mtime->seconds = (time)->seconds; \ } \ MACRO_END @@ -141,7 +144,7 @@ void clock_interrupt(usec, usermode, bas else { timer_bump(&thread->system_timer, usec); } -#endif STAT_TIME +#endif /* STAT_TIME */ /* * Increment the CPU time statistics. @@ -167,7 +170,7 @@ void clock_interrupt(usec, usermode, bas thread_quantum_update(my_cpu, thread, 1, state); } -#if MACH_SAMPLE +#if MACH_PCSAMPLE /* * Take a sample of pc for the user if required. * This had better be MP safe. It might be interesting @@ -193,7 +196,7 @@ void clock_interrupt(usec, usermode, bas * Increment the tick count for the timestamping routine. */ ts_tick_count++; -#endif TS_FORMAT == 1 +#endif /* TS_FORMAT == 1 */ /* * Update the tick count since bootup, and handle @@ -276,8 +279,8 @@ void softclock() */ spl_t s; register timer_elt_t telt; - register int (*fcn)(); - register char *param; + register void (*fcn)( void * param ); + register void *param; while (TRUE) { s = splsched(); @@ -369,6 +372,19 @@ void init_timeout() } /* + * Record a timestamp in STAMP. + */ +void +record_time_stamp (time_value_t *stamp) +{ + do { + stamp->seconds = mtime->seconds; + stamp->microseconds = mtime->microseconds; + } while (stamp->seconds != mtime->check_seconds); +} + + +/* * Read the time. */ kern_return_t @@ -407,7 +423,7 @@ host_set_time(host, new_time) thread_bind(current_thread(), master_processor); if (current_processor() != master_processor) thread_block((void (*)) 0); -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ s = splhigh(); time = new_time; @@ -420,7 +436,7 @@ host_set_time(host, new_time) * Switch off the master CPU. */ thread_bind(current_thread(), PROCESSOR_NULL); -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ return (KERN_SUCCESS); } @@ -448,7 +464,7 @@ host_adjust_time(host, new_adjustment, o thread_bind(current_thread(), master_processor); if (current_processor() != master_processor) thread_block((void (*)) 0); -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ s = splclock(); @@ -469,7 +485,7 @@ host_adjust_time(host, new_adjustment, o splx(s); #if NCPUS > 1 thread_bind(current_thread(), PROCESSOR_NULL); -#endif NCPUS > 1 +#endif /* NCPUS > 1 */ *old_adjustment = oadj; @@ -481,7 +497,7 @@ void mapable_time_init() if (kmem_alloc_wired(kernel_map, (vm_offset_t *) &mtime, PAGE_SIZE) != KERN_SUCCESS) panic("mapable_time_init"); - bzero((char *)mtime, PAGE_SIZE); + memset(mtime, 0, PAGE_SIZE); update_mapped_time(&time); } @@ -497,7 +513,7 @@ int timeclose() /* * Compatibility for device drivers. * New code should use set_timeout/reset_timeout and private timers. - * These code can't use a zone to allocate timers, because + * These code can't use a cache to allocate timers, because * it can be called from interrupt handlers. */ @@ -513,8 +529,8 @@ timer_elt_data_t timeout_timers[NTIMERS] * interval: timeout interval, in hz. */ void timeout(fcn, param, interval) - int (*fcn)(/* char * param */); - char * param; + void (*fcn)( void * param ); + void * param; int interval; { spl_t s; @@ -541,8 +557,8 @@ void timeout(fcn, param, interval) * and removed. */ boolean_t untimeout(fcn, param) - register int (*fcn)(); - register char * param; + register void (*fcn)( void * param ); + register void * param; { spl_t s; register timer_elt_t elt;