From 44f76f487687b11c6e0c5cee98b2108b3dd02a8d Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 15 Nov 2009 04:48:56 +0100 Subject: [PATCH] drop leftover freq_dynamic code in freebsd.c and openbsd.c As the comment states, those functions were originally copied from linux.c; in fact just the code which has been removed due to licensing issues. --- src/common.h | 1 - src/freebsd.c | 43 ------------------------------------------- src/openbsd.c | 43 ------------------------------------------- 3 files changed, 87 deletions(-) diff --git a/src/common.h b/src/common.h index 53bee4fb..de9d6694 100644 --- a/src/common.h +++ b/src/common.h @@ -30,7 +30,6 @@ void update_running_processes(void); void update_i8k(void); void update_stuff(void); char get_freq(char *, size_t, const char *, int, unsigned int); -void get_freq_dynamic(char *, size_t, const char *, int); char get_voltage(char *, size_t, const char *, int, unsigned int); /* ptarjan */ void update_load_average(void); void update_top(void); diff --git a/src/freebsd.c b/src/freebsd.c index b819a496..e536b96b 100644 --- a/src/freebsd.c +++ b/src/freebsd.c @@ -508,49 +508,6 @@ void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size) } } -/* rdtsc() and get_freq_dynamic() copied from linux.c */ - -#if defined(__i386) || defined(__x86_64) -__attribute__((gnu_inline)) inline unsigned long long int rdtsc(void) -{ - unsigned long long int x; - - __asm__ volatile(".byte 0x0f, 0x31":"=A" (x)); - return x; -} -#endif - -/* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */ -void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size, - const char *p_format, int divisor) -{ -#if defined(__i386) || defined(__x86_64) - struct timezone tz; - struct timeval tvstart, tvstop; - unsigned long long cycles[2]; /* gotta be 64 bit */ - unsigned int microseconds; /* total time taken */ - - memset(&tz, 0, sizeof(tz)); - - /* get this function in cached memory */ - gettimeofday(&tvstart, &tz); - cycles[0] = rdtsc(); - gettimeofday(&tvstart, &tz); - - /* we don't trust that this is any specific length of time */ - usleep(100); - cycles[1] = rdtsc(); - gettimeofday(&tvstop, &tz); - microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) + - (tvstop.tv_usec - tvstart.tv_usec); - - snprintf(p_client_buffer, client_buffer_size, p_format, - (float) ((cycles[1] - cycles[0]) / microseconds) / divisor); -#else - get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1); -#endif -} - /* void */ char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_format, int divisor, unsigned int cpu) diff --git a/src/openbsd.c b/src/openbsd.c index 6ca84535..2d7dde41 100644 --- a/src/openbsd.c +++ b/src/openbsd.c @@ -582,49 +582,6 @@ void get_obsd_product(char *buf, size_t client_buffer_size) } } -/* rdtsc() and get_freq_dynamic() copied from linux.c */ - -#if defined(__i386) || defined(__x86_64) -__inline__ unsigned long long int rdtsc() -{ - unsigned long long int x; - - __asm__ volatile(".byte 0x0f, 0x31":"=A" (x)); - return x; -} -#endif - -/* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */ -void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size, - const char *p_format, int divisor) -{ -#if defined(__i386) || defined(__x86_64) - struct timezone tz; - struct timeval tvstart, tvstop; - unsigned long long cycles[2]; /* gotta be 64 bit */ - unsigned int microseconds; /* total time taken */ - - memset(&tz, 0, sizeof(tz)); - - /* get this function in cached memory */ - gettimeofday(&tvstart, &tz); - cycles[0] = rdtsc(); - gettimeofday(&tvstart, &tz); - - /* we don't trust that this is any specific length of time */ - usleep(100); - cycles[1] = rdtsc(); - gettimeofday(&tvstop, &tz); - microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) + - (tvstop.tv_usec - tvstart.tv_usec); - - snprintf(p_client_buffer, client_buffer_size, p_format, - (float) ((cycles[1] - cycles[0]) / microseconds) / divisor); -#else - get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1); -#endif -} - /* void */ char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_format, int divisor, unsigned int cpu)