Re: idiom for cleanup + abort

From: Elizabeth D Rather <erather_at_forth.com>
Date: Fri, 30 Jan 2009 16:27:55 -1000

Joel Reymont wrote:
> I'm trying to port C code that looks like this
>
> // This consumes a reference on dictRef.
> kr = IOServiceGetMatchingServices(kIOMasterPortDefault, dictRef,
> &iter);
> if (KERN_SUCCESS != kr) {
> fprintf(stderr, "IOServiceGetMatchingServices returned
> 0x%08x.\n", kr);
> CFRelease(dictRef);
> return -1;
> }
>
> This is for the Forth side of the Mac driver code for the IntellaSys
> FORTHdrive [1] that I'm testing at the moment.
>
> My current Forth code looks like this:
>
> : LOOKUP-BLOCK-STORAGE-NUB ( -- svc | )
> \ IOBlockStorageServices is our child in the I/O registry
> ZSTR "IOBlockStorageServices" IOServiceMatching ( dictRef *)
> ?DUP 0= ABORT" IOServiceMatching did not return a dictionary"
> \ create an iterator over all matching IOService nubs
> kIOMasterPortDefault OVER ITERATOR IOServiceGetMatchingServices
> ABORT" IOServiceGetMatchingServices failed"
> ...
>
> Obviously, this won't work since it will leave the dictRef hanging!
> I'd like to create a wrapper around ABORT" but would appreciate advice
> (or code!) since the implementation of ABORT" in SwiftForth is a bit
> over my head :).
>
"Hanging" where? If ABORT" fires, it'll clear the stack.

Cheers,
Elizabeth

-- 
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310.999.6784
5959 West Century Blvd. Suite 700  
Los Angeles, CA 90045
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
================================================== 
----------------------------------------------------------------------
sftalk_at_forth.com      The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users.  For product support and
bug reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Fri Jan 30 2009 - 18:28:24 PST

Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 08-Feb-2012. Archive updated nightly.