From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8b691ded59393771 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-23 03:18:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news-FFM2.ecrc.net!news.iks-jena.de!lutz From: lutz@iks-jena.de (Lutz Donnerhacke) Newsgroups: comp.lang.ada Subject: Re: Wrapping / Interfacing to C macros Date: Fri, 23 Aug 2002 10:18:39 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1030097919 29753 217.17.192.37 (23 Aug 2002 10:18:39 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Fri, 23 Aug 2002 10:18:39 +0000 (UTC) User-Agent: slrn/0.9.6.3 (Linux) Xref: archiver1.google.com comp.lang.ada:28336 Date: 2002-08-23T10:18:39+00:00 List-Id: * Le Snelson wrote: >I'm hoping someone has seen a dialect or pattern for interfacing to C >macros. I need to use the ioctl() mechanisms of VxWorks to control >some low level features of a couple of serial cards. I've never seen >any Ada applications wrapping up linguistic attributes such as the >following from Tornado/target/h/sys/ioctl.h : > >#define _IO(x,y) (IOC_VOID|((x)<<8)|y) >#define _IOR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y) >#define _IOW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y) >/* this should be _IORW, but stdio got there first */ >#define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y) > >#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ >#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ >#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ >#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ >#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ I usually prefer to define the type in Ada without looking at the C code. type io_t (c : ioc_t) is record x : x_t; y : y_t; t : iocparam_t; end record; for io_t use record c at 0 range 24 .. 31; t at 0 range 16 .. 23; x at 0 range 7 .. 15; y at 0 range 0 .. 7; end record; for io_t'Bit_Order use ...; procedure SIOCSHIWAT (level : ...); function SIOCGHIWAT return ...;