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,641105de50ec2788 X-Google-Attributes: gid103376,public From: Andi Kleen Subject: Re: 2nd help about handling HW interrupt and apologizes. Date: 1998/04/11 Message-ID: #1/1 X-Deja-AN: 343055053 Distribution: world Sender: andi@fred.muc.de References: <6gft3m$rib$1@nnrp1.dejanews.com> <352BB2AE.1DC7325E@cl.cam.ac.uk> <6glg1a$8og$1@gonzo.sun3.iaf.nl> Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany) Newsgroups: comp.lang.ada Date: 1998-04-11T00:00:00+00:00 List-Id: Geert Bosch writes: > Andi Kleen wrote: > To just get the job done it is probably easier to just write a small > stub kernel driver in C that communicates with the Ada program running > in userspace over a device or a netlink socket. > > Of course you'll have exactly the same problems when you write these > drivers in C as when you write them in Ada! As you mentioned it is > not safe to use the C run-time library as well. So, yes, you should > write your code using a very limited subset of the language and you'll > have to know what kind of code your compiler generates. Because the complete kernel is written in C linux has already most required runtime library support for C. Of course the in-kernel environment is not full ISO-C compliant. The user callable library is very different, and there are even a few language differences: - Initialisation of local arrays does not work as expected, because gcc calls bzero() for that and the kernel runtime library only has memset. - Unitialised global or static variables are not guranteed to be zero at kernel start, because the kernel doesn't clear the BSS segment. - More complex long long arithmetic [which is not ISO C anyways] like the diviosn probably won't work on 32bit machines because the kernel doesn't include the necessary code from libgcc. Overall I would say it is safer to write kernel code in C than in Ada, simply because it is a much better understood topic. Also the kernel includes rely heavily on include functions, C macros and inline assembler so you might have a hard time to write a ada binding for that. > For example when using GNAT it is possible to get almost identical > code as when using the GNU C compiler if you just limit yourself to > what would be possible in C. It is easy to do this experiment yourself > and look at the generated code; this is something you should do in > any case when writing code like system kernel modules. This is true, you'll probably need to invest much more exploration work for a Ada module - I think it is not worth it when a small stub is sufficient. -Andi