Getting CPU Speed Using the Gestalt Manager

Phipli

68040
Well, I'm confused.

I've been trying to get the CPU speed from the Gestalt Manager, as it says in the title. I'm using CodeWarrior Pro 4 on an emulated Quadra 800 running Mac OS 8.1.

I have code similar to the following :

Code:
#include <stdio.h>
#include <Gestalt.h>
#include <Errors.h>

int main(void) {
    long    procSpd;
    OSErr    err;
    
    err = Gestalt('Frq2', &procSpd);
    if (err != noErr){
        printf("Gestalt Error %d\n", err);
    }else{
        printf("Gestalt returned %d\n", procSpd);
    }
    
    return 0;
}

I get a gestalt error -5551, but it has to be available! This is from the same (emulated) machine :

1767488342222.png

If I replace 'Frq2' with something like 'proc', everything works as expected.

Note that 'Frq2' doesn't have an entry in the gestalt.h file that comes with CodeWarrior - does this mean that it is also missing from a library and that is causing my issue? Because I'm on an 040, I don't seem to have access to 'Freq', 'pclk' or anything else that might be helpful, but obviously Gestalt.Appl is managing it somehow :(
 
I think the 'More information' tab (lower right of your screenshot) explains that it is redirecting this call from pclk.

No pclk for me on an 040 either; it seems to make a wild guess based on some magic involving the contents of the kFrq resource. Too tired to take it to bits to work out exactly what.
 
Look at the text box at the bottom: it says it's a pseudo-selector, which means it's synthesising it from other Gestalt data.
OK, so it is something implemented in this program specifically?

I assume the application must also come with libraries or something. I thought it was for reference. I'll have to do some digging in the morning. It's been bugging me that loads of software clearly gets a value from somewhere in the OS which is set during boot, because if you, cough, dynamically change the clock, they all still report the boot speed, unless you restart at the new speed.
 
Back
Top