HP3000-L Archives

September 2002, Week 2

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:
Thu, 12 Sep 2002 16:19:34 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (99 lines)
Re:
> I have found my problem.  I forgot the #pragma intrinsic directive for
> FCONTROL.
>
> Strange error though !  I would expect a "routine not found" message.
> >  FCONTROL(msg_infileno,fcontrol_num,&wait_enabled);
> >   FCHECK(msg_infileno,&errnum);

Several comments...

1. CSEQ would have told you that the third parameter is passed by
a long address:

   :cseq fcontrol
   Procedure FCONTROL (
      filenum      :        int16   ;        {R26}
      controlcode  :        int16   ;        {R25}
      param        : anyvar uint16  )        {R23, R24}
                                             {Address type = LongAddr}
      {controlcodes                                                    }
      {  0  general -> param                                           }
      ...

Your implied declaration of it told the C compiler that the third
parameter was a 32-bit address, not a 64-bit address.
Had you said:
  FCONTROL (msg_infileno, fcontrol_num, (uint16 ^) &wait_enabled);
it would probably have worked correctly.  (Note: requires -Ae)
The "^" is HP C's way of saying "I want a 64-bit pointer".


2. Since you said "FCONTROL", and not "Fcontrol" or "fcontrol" or some
other variation, the external name was "FCONTROL" ... which happens
to be exactly the name of the FCONTROL intrinsic in NL.PUB.SYS.
Thus, I wouldn't have expected a "routine not found".  Note that
many implementations of C aren't kind enough to say "hey, you
forgot to declare this routine".  The C standard basically tells the
compiler to "declare" it using the parameter types it sees you
passing into it.


3. You also really want to say: #pragma intrinsic FCHECK
because FCHECK actually has 5 parameters.  Without that, you
run the risk of corrupting data in various places (depending upon
what's in registers R24, R23, and memory at [sp-$34]):

:cseq FCHECK
Procedure FCHECK (
   filenum      :        int16   ;        {R26} := 0
   fserrorcode  : var    int16   ;        {R25} := nil
   translog     : var    int16   ;        {R24} := nil
   blocknum     : var    int32   ;        {R23} := nil
   numrecs      : var    int16   )        {SP-$0034} := nil
      { CCE: ok                                                  }
      { CCL: error: filenum not valid, or internal error         }
   {translog: <0 for bytes; >0 for halfwords                           }
   {blocknum: # blocks transferred since FOPEN                         }
   {  (documented as zeroed upon rewind for                            }
   {  variable record files...doesn't seem to be)                      }
   {numrecs: # records per block (empirical)                           }
   {popular errors:                                                    }
   {  0 = EOF                                                          }
   {  20 = invalid operation                                           }
   {  21 = Data parity error                                           }
   {  22 = Read timeout (see FCONTROL #4)                              }
   {  23 = End of tape                                                 }
   {  24 = device not ready                                            }
   {  25 = no write ring                                               }
   {  26 = transmission error                                          }
   {  32 = ABORTIO                                                     }
   {  38 = tape parity error                                           }
   {  39 = recovered tape error (FSETMODE bit 12)                      }
   {  43 = write exceeds record size                                   }
   {  50 = nonexistent account                                         }
   {  51 = nonexistent group                                           }
   {  52 = nonexistent perm file                                       }
   {  53 = nonexistent temp file                                       }
   {  54 = invalid file reference                                      }

The use of "#pragma intrinsic FCHECK" "declares" FCHECK properly,
and the HP C compiler allows you to omit some parameters.  In this
case, FCHECK(msg_infileno,&errnum) will be treated like:
   FCHECK (msg_infileno, &errnum, NULL, NULL, NULL);

(note that blank space after a comma and before a "(" improve
code readability)

Good luck!

Stan (CSEQ: don't code without it :) Sieler

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

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2