Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / June 2003



Tip: Looking for answers? Try searching our database.

Porting to MacOSX Questions.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick Girard - 26 Jun 2003 18:45 GMT
1- I need to find the equivalent of the win32
   GetSystemInfo(&systemInfo);
   systemInfo.lpMinimumApplicationAddress and
   systemInfo.lpMaximumApplicationAddress.

2- Is there an equivalent of IsBadReadPtr on OSX?

3- Is there an equivalent to OutputDebugString on OSX?

4- The lib I am porting is OSX only (no MacOS9 and down).
    I used pthreads for threading.
    I used the FileManager API for file operations.
    I used calloc and free for big memory allocations.
   Can you tell me if my choices are ok?
Eric Albert - 27 Jun 2003 08:26 GMT
> 1- I need to find the equivalent of the win32
>     GetSystemInfo(&systemInfo);
>     systemInfo.lpMinimumApplicationAddress and
>     systemInfo.lpMaximumApplicationAddress.

You can set lpMinimumApplicationAddress to 4096 and
lpMaximumApplicationAddress to 0xC0000000, but I'm not sure why you'd
care about either of those.  Not all of that address space is available
to your application.  There are probably better ways to accomplish
whatever you're trying to do.

> 2- Is there an equivalent of IsBadReadPtr on OSX?

int IsBadReadPtr(const void *ptr) {
   kern_return_t result;
   vm_address_t address;
   vm_size_t size;
   struct vm_region_basic_info info;
   mach_msg_type_number_t count;
   mach_port_t objectName = MACH_PORT_NULL;

   address = (vm_address_t) ptr;
   count = VM_REGION_BASIC_INFO_COUNT;
   result = vm_region(mach_task_self(), &address, &size,
                      VM_REGION_BASIC_INFO, (vm_region_info_t) &info,
                      &count, &objectName);
   if (objectName != MACH_PORT_NULL) {
       mach_port_deallocate(mach_task_self(), objectName);
   }
   if (result != KERN_SUCCESS || address > (vm_address_t) ptr ||
       info.protection == VM_PROT_NONE) {
       return 0;
   }
   return 1;
}

> 3- Is there an equivalent to OutputDebugString on OSX?

What are you trying to do with it?  You can write to /dev/console if
you'd like, or to stderr.

> 4- The lib I am porting is OSX only (no MacOS9 and down).
>      I used pthreads for threading.
>      I used the FileManager API for file operations.
>      I used calloc and free for big memory allocations.
>     Can you tell me if my choices are ok?

They're fine, though you might find it easier to use POSIX APIs for file
operations instead of the File Manager.  And you should only use calloc
for blocks that have to be zero'd out before you can use them.  Use
malloc for other allocations.

Hope this helps,
Eric

Signature

Eric Albert         ejalbert@stanford.edu
http://rescomp.stanford.edu/~ejalbert/

Sean McBride - 30 Jun 2003 20:17 GMT
> 1- I need to find the equivalent of the win32

Please read this:
<http://developer.apple.com/macosx/win32porting/>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.