i recently got a new macbook and found that i couldn't build ciao from the current source in SVN. i kept getting a bus error from the ciao engine built for the configuration process. i tracked it down to the "engine/timing.c" file. that defines a different version of "cpuspeed()" if the machine has an intel processor, but that version uses "/proc/cpuinfo" and unfortunately, Darwin doesn't have a procfs.
i added a new version of "cpuspeed()" (for darwin) that uses sysctl instead. it seems to work, though i'm not sure if the scales match up properly. it seems to work, though i haven't tested it much. this seems to be used more for GUI functions, which i don't use in what i'm working on currently.
anyway, i've attached a patch for what i did. hopefully it will be of use.
juan chanco
--- ciao/engine/timing.c.orig 2007-06-12 13:45:46.000000000 +0200 +++ ciao/engine/timing.c 2007-06-16 17:00:06.000000000 +0200 @@ -12,6 +12,9 @@ #include "timing_defs.h"
/* local declarations */ +#if defined(DARWIN) +#include <sys/sysctl.h> +#endif
#if (defined(Solaris) || defined(SunOS4) || defined(LINUX) || defined(DARWIN) \ || defined(IRIX) || defined(Win32)) && !defined(crossWin32i86) @@ -111,6 +114,25 @@ is equal to 1 cpu - cycle. */
+#if defined(DARWIN) +/* darwin doesn't have a procfs. this should (hopefully) + * do the same thing, though i'm not sure if the scales match + * on my 2.16 ghz macbook, the value returned is 2160000000 */ +static ENG_LINT cpuspeed (void) +{ + int speed ; + size_t size=sizeof(speed) ; + + if (sysctlbyname("hw.cpufrequency",&speed,&size,NULL,0)) + { + return 0; + } + else + { + return speed; + } +} +#else /* Returns the clock speed of the system's CPU in Hz, as reported by /proc/cpuinfo. On a multiprocessor machine, returns the speed of the first CPU. On error returns zero. @@ -146,6 +168,7 @@ sscanf (match, "cpu MHz : %lf", &clock_speed); return (ENG_LINT)(clock_speed * 1000000); } +#endif
/* Note that "cpuid" could be necessary to force the processor not do the */ /* "speculative execution". */
============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------