[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trap return result wierdness



>I'm new to MCL and somewhat new to Macintosh programming, so bear with me.
>
>I was surprised by this result:
>? (%stack-block ((response 4)) (#_gestalt #$gestaltEasyAccessAttr
> 				          response))
>59985
>
>I was expecting a negative error number. Do I need to somehow coerce
>the result of the trap into a negative word?

This is a bug in the DEFTRAP for _Gestalt. Below is the fixed definition.
It used to say %get-word instead of %get-signed-word:

(deftrap _gestalt ((selector :ostype) (response (:pointer :signed-long)))
   (:no-trap :signed-integer)
   (:no-trap (ccl::%stack-block ((ret 8))
               (ccl::%gen-trap #xA1AD
                              :return-block ret
                              :d0 selector
                              :a0 response
                              '(:d0 :a0))
               (%put-ptr response (%get-ptr ret 4))
               (%get-signed-word ret 2))))

The definition for _replacegestalt needs to be changed in the same way.
If you make this change to the file "ccl:interfaces;gestaltequ.lisp",
remember to (reindex-interfaces).

Probably, noone ever noticed this because all of our code just
says (eql 0 (#_Gestalt ...)).

>
>Also, is there higher level construct than %stack-block for allocating
>a word or longword of storage?

It's usually done with RLET, which macroexpands into %stack-block:

(rlet ((response :long))
  (#_gestalt #$gestaltEasyAccessAttr response))