🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.mac.programmer.codewarrior
5 messages
5 total messages Started by ccorbell Tue, 05 Feb 2002 18:40
mach/mach.h and IOKit functions
#1062
Author: ccorbell
Date: Tue, 05 Feb 2002 18:40
27 lines
1930 bytes
This is a slightly reworded re-post since I still
don't know where MW stands on this....

Does CW7 support directly calling functions from mach/mach.h?
Does CW7 support directly calling functions from IOKit?

I'm getting link errors, working with the mach-o stationery.
The project includes System, IOKit, and CoreFoundation frameworks.

When I #define DARWIN in a prefix file, most errors go away
but a few remain - link errors for any mach.h function,
and also link errors I don't understand like:
   ___mod2u is undefined
   ___div2u is undefined

The functions I'm calling are all lifted from Apple's Simple USB
Example main.c file which works under ProjectBuilder.

Has anyone out there directly called mach.h functions with CW7?
If so, any clue as to what I'm missing?

If it isn't supported I can use CFPlugin utilites to get
the function pointers I need, I'd just rather not have to go
that route, esp. since the app isn't CFM.

TIA,
Chris Corbell
Re: mach/mach.h and IOKit functions
#1063
Author: Isaac Wankerl
Date: Wed, 06 Feb 2002 20:21
49 lines
2486 bytes
In article <3C602717.27F3AA60@vernier.com>,
 ccorbell <ccorbell@vernier.com> wrote:

> This is a slightly reworded re-post since I still
> don't know where MW stands on this....
> 
> Does CW7 support directly calling functions from mach/mach.h?

Could this be because mach/mach.h doesn't wrap itself with the 
_BEGIN_DECLS and _END_DECLS macros?  If I use

_BEGIN_DECLS
#include <mach/mach.h>
_END_DECLS

then I can link an app using panic().

> Does CW7 support directly calling functions from IOKit?

No, Pro 7 doesn't support this.

> I'm getting link errors, working with the mach-o stationery.
> The project includes System, IOKit, and CoreFoundation frameworks.
> 
> When I #define DARWIN in a prefix file, most errors go away
> but a few remain - link errors for any mach.h function,
> and also link errors I don't understand like:
>    ___mod2u is undefined
>    ___div2u is undefined

Move the MSL Runtime and crt1.o files to the end of the link order and 
it might fix this.

> The functions I'm calling are all lifted from Apple's Simple USB
> Example main.c file which works under ProjectBuilder.
> 
> Has anyone out there directly called mach.h functions with CW7?
> If so, any clue as to what I'm missing?
> 
> If it isn't supported I can use CFPlugin utilites to get
> the function pointers I need, I'd just rather not have to go
> that route, esp. since the app isn't CFM.
> 
> TIA,
> Chris Corbell

-- 
Isaac Wankerl
Metrowerks Mac Software Team
Re: mach/mach.h and IOKit functions
#1065
Author: petrock99
Date: Fri, 08 Feb 2002 12:27
42 lines
3636 bytes
>> Does CW7 support directly calling functions from IOKit?
> 
> No, Pro 7 doesn't support this.
    You definitely can call IOKit functions from a CW project, you just have
to have the right frameworks/headers/libraries linked in.  I recently added
code to one of my projects that would gather a bunch of info on the
processor(s) that my app was running on (i.e. Bus speed, CPU speed, , cache
size/tupe, CPU version etc etc).  The only way to do that in a Mach-O app is
through IOKit...  You can use a command line tool called ioreg to help you
figure out what keys to use etc...  There is also the IORegistryExplorer in
/Developer/Applications that does pretty much the same thing as ioreg, but
with a GUI.
    The project is currently at work, I'll post up any funky settings I had
tomorrow...

>> I'm getting link errors, working with the mach-o stationery.
>> The project includes System, IOKit, and CoreFoundation frameworks.
    There are a couple bugs in the CW7 Mach-O project stationary.  One I
remember was the crt1.o file wasn't being recognized (you could tell cause
it had n/a next to its name in the project list, not a number).  This was a
file mapping issue.  Just add .o to the file mapping (set it to Mach-O
Linker, IMS).

>> When I #define DARWIN in a prefix file, most errors go away
>> but a few remain - link errors for any mach.h function,
>> and also link errors I don't understand like:
>>    ___mod2u is undefined
>>    ___div2u is undefined
> 
> Move the MSL Runtime and crt1.o files to the end of the link order and
> it might fix this.
    This might help, but those are functions defined in runtime.c (inside
CW).  It should have been exported in the Runtime projects (bug?)...  The
way I got around it was just by adding runtime.c to my project...

>> Has anyone out there directly called mach.h functions with CW7?
>> If so, any clue as to what I'm missing?
    yes...  Its most likely an include path issue...  Do you have
/usr/include in your access paths?  I'll take a look at my project
tomorrow.....  Good luck...

--Rob
Re: mach/mach.h and IOKit functions
#1066
Author: Josef W. Wankerl
Date: Fri, 08 Feb 2002 14:50
7 lines
1292 bytes
In article <B889043E.1AB3%petrock99-NOSPAM@hotmail.com>,
 petrock99 <petrock99-NOSPAM@hotmail.com> wrote:

>     There are a couple bugs in the CW7 Mach-O project stationary.  One I
> remember was the crt1.o file wasn't being recognized

This was fixed in the 7.1 update.
Re: mach/mach.h and IOKit functions
#1067
Author: petrock99
Date: Fri, 08 Feb 2002 19:36
65 lines
3691 bytes
On 2/8/02 4:27 AM, in article B889043E.1AB3%petrock99-NOSPAM@hotmail.com,
"petrock99" <petrock99-NOSPAM@hotmail.com> wrote:

>>> Does CW7 support directly calling functions from IOKit?
>> 
>> No, Pro 7 doesn't support this.
>   You definitely can call IOKit functions from a CW project, you just have
> to have the right frameworks/headers/libraries linked in.  I recently added
> code to one of my projects that would gather a bunch of info on the
> processor(s) that my app was running on (i.e. Bus speed, CPU speed, , cache
> size/tupe, CPU version etc etc).  The only way to do that in a Mach-O app is
> through IOKit...  You can use a command line tool called ioreg to help you
> figure out what keys to use etc...  There is also the IORegistryExplorer in
> /Developer/Applications that does pretty much the same thing as ioreg, but
> with a GUI.
>   The project is currently at work, I'll post up any funky settings I had
> tomorrow...
    I took a look at my project, I didn't have any funky access paths, or
frameworks.  I had the default Mach-O stationary access paths, and System,
IOKit and CoreFoundation frameworks...

The insludes I had in my source were

#include <stdio.h>  // it was a console app...
#include <stdlib.h>

    // these are the only other includes I had...
#include <mach/port.h>
#include <mach/kern_return.h>
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CFNumber.h>
#include <CoreFoundation/CFSet.h>



Here's a snippit of my code...  This snippit will get the master port, then
get a "reference" to the cpus in the registry (not that cpus will point to
one or more cpu's...  You need to setup an iterator to get to the underlying
cpu data)

    mach_port_t         masterport  = MACH_PORT_NULL;    // (don't release)
    io_registry_entry_t cpus        = MACH_PORT_NULL;    // (needs release)
    io_iterator_t       iter        = NULL;              // (needs release)
    kern_return_t       status        = KERN_SUCCESS;
    
        // get master port
    status = IOMasterPort(bootstrap_port, &masterPort);
    if( status == KERN_SUCCESS )
        cpus = IORegistryEntryFromPath( masterPort, kIODeviceTreePlane
":/cpus" );
    if( cpus != MACH_PORT_NULL )
        status = IORegistryEntryGetChildIterator( cpus, kIODeviceTreePlane,
&iter );

                // clean up
    if( cpus != MACH_PORT_NULL )    {
        IOObjectRelease( cpus );
        cpus = MACH_PORT_NULL;
    }
    


Good luck...

--Rob
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads