[comp.sys.apollo] Discrepancy in sio.h file?

lau@kings.wharton.upenn.edu (Yan K. Lau) (06/27/89)

This is a technical question about the C compiler and the Apollo sio
include file.  There seems to be a discrepancy between parameter lists.

In /usr/apollo/include/sio.h, the sio_$control call is defined as follows:

    extern void sio_$control(
            stream_$id_t          &stream_id,
            sio_$opt_t            &option,
            void                  &value,
            status_$t             *status
            );

BTW, In /sys/ins/sio.ins.c, the call is defined simply as:

    std_$call void sio_$control();

In comparison, in /sys/ins/sio.ins.pas, the call is defined as:

    PROCEDURE sio_$control(IN strid: stream_$id_t;
                           IN option: sio_$opt_t;
                           IN value: UNIV sio_$value_t;
                           OUT status: status_$t); EXTERN;

The _Domain/OS Call Reference_, defines the call as follows:

    extern void sio_$control(
            stream_$id_t          &stream_id,
            sio_$opt_t            &option,
            sio_$value_t          &value,
            status_$t             *status
            );

The definition of sio_$value_t is:

    typedef union {
            char c;
            pinteger i;
            char b;        /* boolean */
            sio_$err_enables_t es;
    } sio_$value_t;


It appears that the third parameter in /usr/apollo/include/sio.h is wrong.
Is this true?  If so, what other "gotchas" are out there?  This gives me
an uneasy feeling.  Has anyone else encounter similar problems?



Yan.
---
      Yan K. Lau                    + the last message of a newgroup will be:
   )~                               +   a) longer than one screen &
 ~/~  lau@scrolls.wharton.upenn.edu +   b) something you're not interested in.
 /\   University of Pennsylvania    + your decision, 'n' key or space bar?

beierl_c@apollo.COM (Christopher Beierl) (07/01/89)

In article <12447@netnews.upenn.edu> lau@kings.wharton.upenn.edu (Yan K. Lau) writes:
>This is a technical question about the C compiler and the Apollo sio
>include file.  There seems to be a discrepancy between parameter lists.
>
>In /usr/apollo/include/sio.h, the sio_$control call is defined as follows:
>    extern void sio_$control(
>            stream_$id_t          &stream_id,
>            sio_$opt_t            &option,
>            void                  &value,
>            status_$t             *status
>            );

This is a bug (APR #dcb69) and is fixed in SR10.2.  The correct prototype
matches the documentation and is shown below.

    extern void sio_$control(
            stream_$id_t          &stream_id,
            sio_$opt_t            &option,
            sio_$value_t          &value,
            status_$t             *status
            );

Note that an actual object of type sio_$value_t must be used in the call,
rather than just a cast because you can't cast a constant to a union.  An
example follows:

#include <apollo/sio.h>
    stream_$id_t    stream_id;
    sio_$value_t    sio_value;
    status_$t       status;

    sio_value.i = sio_$9600;
    sio_$control(stream_id, sio_$speed, sio_value, &status);
    sio_value.b = true;
    sio_$control(stream_id, sio_$raw,   sio_value, &status);

>BTW, In /sys/ins/sio.ins.c, the call is defined simply as:
>    std_$call void sio_$control();

For a C programmer it is much preferable to use the .h header files.  If
the ins.c header files are used instead then the std_$call mechanism is
used for interlanguage calls rather than prototypes.  An example follows:

#include "/sys/ins/sio.ins.c" 

    stream_$id_t    stream_id;
    status_$t       status;

    sio_$control(stream_id, sio_$speed, (pinteger)sio_$9600, status);
    sio_$control(stream_id, sio_$raw,   true,                status);


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Christopher T. Beierl                         Internet: beierl_c@apollo.com
 Apollo Computer, Inc.      UUCP: {mit-eddie,yale,uw-beaver}!apollo!beierl_c
 A Subsidiary of Hewlett-Packard                       Phone: (508) 256-6600