comp.lang.ada
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: Re: Kernel Syscall from Ada?
Date: Sat, 25 Jun 2016 00:23:39 +0200
Date: 2016-06-25T00:23:39+02:00	[thread overview]
Message-ID: <87vb0y5iqc.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: 2048d6d6-04e2-4e2c-9483-e3769da59781@googlegroups.com

* Diogenes:

> Is there a simple way to make a direct (Linux)Kernel syscall from Ada
> without using the system C library? i.e. Make a direct call as in
> Assembler?

glibc implements a lot of system calls as assembler stubs.  Some are
more complicated because emulation of certain features is desirable,
or there is no straight mapping between the application and kernel
parameter lists (e.g., the offset parameter to mmap).

Calling individual system calls in GNAT using machine code insertion
is not that hard (except for 6-argument system calls on i386 with
older GCC versions).  But designing a way to write such system calls
so that you do not have to tweak the sources for each architecture is
quite hard.  The lax C type system allows you to treat all system
calls as taking signed long arguments, returning signed long (*), and
you only have to specialize the number of arguments.  With the C
preprocessor, you can also deal with 64-bit arguments in a portable
manner (so that the source code denoting the system call is identical
across 32-bit and 64-bit architectures).  I doubt something similar is
possible in GNAT.

You also need to replicate all data types used in the userspace API,
which can be rather involved (stat is a bit complicated, and there are
many ioctls).

(*) Some architectures do not use in-band signaling for errno, and the
return convention is different.

  parent reply	other threads:[~2016-06-24 22:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-23  8:36 Kernel Syscall from Ada? Diogenes
2016-06-23 10:58 ` Björn Lundin
2016-06-23 16:28   ` Per Sandberg
2016-06-23 22:18 ` Randy Brukardt
2018-07-12 19:07   ` Dan'l Miller
2018-07-12 20:59     ` Randy Brukardt
2016-06-24  1:13 ` Xavier Petit
2016-06-24 22:23 ` Florian Weimer [this message]
2018-07-11 22:38 ` alexgrantbenedict
2018-07-12  1:32 ` Dan'l Miller
2018-07-12  8:19   ` Lucretia
2018-07-12 15:27     ` Dan'l Miller
2018-07-12 17:27       ` Lucretia
replies disabled

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