HP3000-L Archives

November 2000, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Stan Sieler <[log in to unmask]>
Reply To:
Stan Sieler <[log in to unmask]>
Date:
Tue, 21 Nov 2000 18:35:03 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (118 lines)
Re:
> I'm encountering a strange problem calling the system intrinsic HPCIGETVAR
> from within a "C" program compiled with the gnu gcc compiler [2.95.2]  The

Although you have the answer now, I thought I'd point out several
things (some about "CSEQ", some about "extensible")...

cseq -gcc hpcigetvar

CSEQ [2.11] - LPS Toolbox [A.07b]           (c) 1995 Lund Performance Solutions

This product is licensed to: Allegro Consultants, Inc.
#include "/usr/contrib/intrinsics/types.h"

extern void HPCIGETVAR (
   int32     num_actual_parms,            /* R26 */
   void     *varname,                     /* R25 */
   void     *status,                      /* R24, @32 -> 32 = NIL */
   int32     keyword1,                    /* R23 = 0 */
   void     *keyvalue1,                   /* SP-$0034 = NIL */
   int32     keyword2,                    /* SP-$0038 = 0 */
   void     *keyvalue2,                   /* SP-$003c = NIL */
   int32     keyword3,                    /* SP-$0040 = 0 */
   void     *keyvalue3,                   /* SP-$0044 = NIL */
   int32     keyword4,                    /* SP-$0048 = 0 */
   void     *keyvalue4,                   /* SP-$004c = NIL */
   int32     keyword5,                    /* SP-$0050 = 0 */
   void     *keyvalue5,                   /* SP-$0054 = NIL */
   int32     keyword6,                    /* SP-$0058 = 0 */
   void     *keyvalue6);                  /* SP-$005c = NIL */
   /*  varname: up to 255 chars, terminate with blank/null.                */
   /*  keyword/value pairs:                                                */
   /*     0, n.a.: ignore pair                                             */
   /*     1, I32 : variable value if number, else 0.                       */
   /*     2, CA255: variable value if string (else null).                  */
   /*     3, I32 : variable value if boolean, else 0.                      */
   /*              (true --> 1, false --> 0)                               */
   /*    10, I32 : input: #bytes in keyword=2 (string)                     */
   /*              (must accompany a keyword=2)                            */
   /*    11, I32 : output: #bytes put into string.                         */
   /*    12, I32 : input: max recursion value (0=don't)                    */
   /*                Recursion would be done to handle                     */
   /*                "!variable" within strings.                           */
   /*    13, I32 : output: type of variable found (if any):                */
   /*                 1=integer, 2=string, 3=boolean                       */
   /*  varname: up to 255 chars, terminate with blank/null.                */
      /* extensible 14 */


Note that CSEQ has a "-gcc" parameter, which tells it you want the output
in a gcc-friendly manner (as opposed to C/iX).  This mostly affects
64-bit pointers, which HPCIGETVAR doesn't use.

The "extensible 14" (and this is where Bill should get interested)
says: there are at least 14 parameters.  Thus, you *always* have to
pass at least a value of 14 there.  If you want to logically omit
pairs 2 through 6, pass 0 for the keyword numbers, and NULL (0) for the
keyword value addresses.

Now, as to "why should it be extensible 14 if you have to specify
all 14 parameters"...that's actually two questions:

   1) why extensible at all?

      What happens if it weren't extensible, and someone wanted to add a
      parmeter later?  Oops...can't do it!

   2) Why "extensible 14" instead of, say, "extensible 4"?

      Lack of code review :)

      I'd have written it as "extensible 4" (i.e., at least the first
      keyword number/value pair would be required).

      But, perhaps the author thought it was easier to do:

         if keyword2 <> 0 then
            if haveoptvarparm (keyvalue2) then
               handle keyword_pair (keyword2, keyvalue2)
            else
               error ("keyword supplied, but keyvalue omitted")
         else
            if haveoptvarparm (keyvalue2) then
               error ("keyvalue supplied, but keyword is 0")
            else
               ;  {neither keyword nor keyvalue are non-0}

and then clone it for pairs 3, 4, 5, 6.

If "extensible 4" had been used, the code would be further
complicated (although more efficient in 99% of the calls):

    if not haveextension (keyword2) then
       goto end_keyword_handling;

    if not haveextension (keyvalue2) then
       error ("keyword2 passed in, is non-0, but keyvalue2 omitted");
           {I assume "error" won't return}

    if keyword2 <> 0 then
       if haveoptvarparm (keyvalue2) then
          handle keyword_pair (keyword2, keyvalue2)
       else
          error ("keyword supplied, but keyvalue omitted")
    else
       if haveoptvarparm (keyvalue2) then
          error ("keyvalue supplied, but keyword is 0")
       else
          ;  {neither keyword nor keyvalue are non-0}

and clone it for pairs 3, 4, 5, 6.
     ...
   end_keyword_handling:


Stan Sieler                                           [log in to unmask]
www.allegro.com/sieler/wanted/index.html          www.allegro.com/sieler

ATOM RSS1 RSS2