Skip to content
Snippets Groups Projects
Commit e7d07412 authored by rtoy's avatar rtoy
Browse files

Move the Darwin-specific timebase_init stuff from lisp.c to Darwin-os.c,

where it belongs.
parent e96ee310
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* Frobbed for OpenBSD by Pierre R. Mai, 2001. * Frobbed for OpenBSD by Pierre R. Mai, 2001.
* Frobbed for Darwin by Pierre R. Mai, 2003. * Frobbed for Darwin by Pierre R. Mai, 2003.
* *
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Darwin-os.c,v 1.3 2005/06/01 13:30:16 rtoy Exp $ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Darwin-os.c,v 1.4 2005/09/06 13:05:58 rtoy Exp $
* *
*/ */
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
#include <signal.h> #include <signal.h>
/* #include <sys/sysinfo.h> */ /* #include <sys/sysinfo.h> */
/* #include <sys/proc.h> */ /* #include <sys/proc.h> */
/* For timebase info */
#include <sys/param.h>
#include <sys/sysctl.h>
/* Need this to define ppc_saved_state_t (for 10.4) */ /* Need this to define ppc_saved_state_t (for 10.4) */
#include <mach/thread_status.h> #include <mach/thread_status.h>
...@@ -43,10 +47,58 @@ vm_size_t os_vm_page_size; ...@@ -43,10 +47,58 @@ vm_size_t os_vm_page_size;
#define DPRINTF(t,a) {if (t) fprintf a;} #define DPRINTF(t,a) {if (t) fprintf a;}
/*
* This is accessed by Lisp! Make this a static symbol?
*/
int cycles_per_tick = 1;
/*
* Compute the conversion factor from the numbef of time base ticks to
* clock frequency. The timebase counter on PPC is not a cycle
* counter; we have to derive the relationship ourselves.
*/
void timebase_init()
{
int mib[2];
int tbfrequency;
int cpufrequency;
unsigned int miblen;
size_t len;
mib[0] = CTL_HW;
#ifndef HW_TB_FREQ
/*
* Mac OS X 10.2.8 doesn't have this, so we take it from 10.3.8,
* which does.
*/
#define HW_TB_FREQ 23
#endif
mib[1] = HW_TB_FREQ;
miblen = 2;
len = sizeof(tbfrequency);
if (sysctl(mib, miblen, &tbfrequency, &len, NULL, 0) == -1) {
perror("Error getting HW_TB_FREQ from sysctl: ");
}
mib[0] = CTL_HW;
mib[1] = HW_CPU_FREQ;
miblen = 2;
len = sizeof(cpufrequency);
if (sysctl(mib, miblen, &cpufrequency, &len, NULL, 0) == -1) {
perror("Error getting HW_CPU_FREQ from sysctl: ");
}
cycles_per_tick = cpufrequency / tbfrequency;
}
void os_init(void) void os_init(void)
{ {
os_vm_page_size = OS_VM_DEFAULT_PAGESIZE; os_vm_page_size = OS_VM_DEFAULT_PAGESIZE;
timebase_init();
} }
int os_get_errno(void) int os_get_errno(void)
......
/* /*
* main() entry point for a stand alone lisp image. * main() entry point for a stand alone lisp image.
* *
* $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.48 2005/09/06 01:33:29 cshapiro Exp $ * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.49 2005/09/06 13:05:58 rtoy Exp $
* *
*/ */
...@@ -394,53 +394,6 @@ prepend_core_path(char* lib, char* corefile) ...@@ -394,53 +394,6 @@ prepend_core_path(char* lib, char* corefile)
int builtin_image_flag = 0; int builtin_image_flag = 0;
long initial_function_addr = 0; long initial_function_addr = 0;
#ifdef DARWIN
#include <sys/param.h>
#include <sys/sysctl.h>
int cycles_per_tick = 1;
/*
* Compute the conversion factor from the numbef of time base ticks to
* clock frequency. The timebase counter on PPC is not a cycle
* counter; we have to derive the relationship ourselves.
*/
void timebase_init()
{
int mib[2];
int tbfrequency;
int cpufrequency;
unsigned int miblen;
size_t len;
mib[0] = CTL_HW;
#ifndef HW_TB_FREQ
/*
* Mac OS X 10.2.8 doesn't have this, so we take it from 10.3.8,
* which does.
*/
#define HW_TB_FREQ 23
#endif
mib[1] = HW_TB_FREQ;
miblen = 2;
len = sizeof(tbfrequency);
if (sysctl(mib, miblen, &tbfrequency, &len, NULL, 0) == -1) {
perror("Error getting HW_TB_FREQ from sysctl: ");
}
mib[0] = CTL_HW;
mib[1] = HW_CPU_FREQ;
miblen = 2;
len = sizeof(cpufrequency);
if (sysctl(mib, miblen, &cpufrequency, &len, NULL, 0) == -1) {
perror("Error getting HW_CPU_FREQ from sysctl: ");
}
cycles_per_tick = cpufrequency / tbfrequency;
}
#endif
/* And here be main. */ /* And here be main. */
int main(int argc, char *argv[], char *envp[]) int main(int argc, char *argv[], char *envp[])
...@@ -746,9 +699,6 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -746,9 +699,6 @@ int main(int argc, char *argv[], char *envp[])
*/ */
sigint_init(); sigint_init();
#ifdef DARWIN
timebase_init();
#endif
if (monitor) { if (monitor) {
while (1) { while (1) {
ldb_monitor(); ldb_monitor();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment