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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e6293bc5c0d52b2b X-Google-Attributes: gid103376,public From: "Samuel T. Harris" Subject: Re: Unix SELECT Ada binding Date: 1999/07/22 Message-ID: <379780B7.51868604@hso.link.com>#1/1 X-Deja-AN: 504142529 Content-Transfer-Encoding: 7bit References: <379638B1.101427E5@res.raytheon.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Raytheon Training Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-07-22T00:00:00+00:00 List-Id: Andy Askey wrote: > > Has anyone created an Ada package with binding into the SELECT C library > function that does I/O multiplexing? The binding is straight forward > but there are several macros (FD_SET, FD_CLR, ...) that have to be > translated into Ada. > > For example, the select.h file has the following macro for FD_SET: > > #define FD_SET(__n, __p) ((__p)->fds_bits[(__n)/FD_NFDBITS] |= \ > ((unsigned)1 << ((__n) % > FD_NFDBITS))) > > If anyone has an example of this they care to share, we will greatly > appreciated it. > > Thanx. > Andy > -- Doing this ages ago in another life, I found the easiest thing to do was write a C helper routine which used the macro instead of trying to duplicate the macro in Ada. Interface to the C helpers and viola. Takes about 5 mins work. While Ada purists may cringe at this, I find that one of my favorite features of Ada are the interface capabilities which allows me to glue stuff together when that is appropriate. I don't like C, but I recognize the need to use it when it gets the job done. -- Samuel T. Harris, Principal Engineer Raytheon, Scientific and Technical Systems "If you can make it, We can fake it!"