comp.lang.ada
 help / color / mirror / Atom feed
From: Andi Kleen <ak@muc.de>
Subject: Re: 2nd help about handling HW interrupt and apologizes.
Date: 1998/04/11
Date: 1998-04-11T00:00:00+00:00	[thread overview]
Message-ID: <m3sonkr1js.fsf@fred.muc.de> (raw)
In-Reply-To: 6glg1a$8og$1@gonzo.sun3.iaf.nl


Geert Bosch <geert@gonzo.sun3.iaf.nl> writes:

> Andi Kleen <ak@muc.de> 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




  reply	other threads:[~1998-04-11  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-08  0:00 2nd help about handling HW interrupt and apologizes jtapasai
1998-04-08  0:00 ` Markus Kuhn
1998-04-10  0:00   ` Andi Kleen
1998-04-10  0:00     ` Using GNAT for Linux kernel hacking Markus Kuhn
1998-04-10  0:00     ` 2nd help about handling HW interrupt and apologizes Geert Bosch
1998-04-11  0:00       ` Andi Kleen [this message]
1998-04-10  0:00     ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox