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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,5edee74b13d8e50a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!feedme.ziplink.net!news.swapon.de!newsfeed.straub-nv.de!weretis.net!feeder3.news.weretis.net!news.szaf.org!news.gnuher.de!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail From: michael bode Newsgroups: comp.lang.ada Subject: Re: The "black magic" of ioctl Date: Fri, 22 Oct 2010 22:16:00 +0200 Organization: Evangelisches Atomkraftwerk =?ISO-8859-1?Q?M=FClheim-K=E4rl?= =?ISO-8859-1?Q?ich?= Message-ID: References: <74b46743-fb81-48cc-a478-ffd069db2fc6@k22g2000yqh.googlegroups.com> NNTP-Posting-Host: p5b2489cb.dip0.t-ipconnect.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: online.de 1287778561 2109 91.36.137.203 (22 Oct 2010 20:16:01 GMT) X-Complaints-To: abuse@einsundeins.com NNTP-Posting-Date: Fri, 22 Oct 2010 20:16:01 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 In-Reply-To: Xref: g2news1.google.com comp.lang.ada:14687 Date: 2010-10-22T22:16:00+02:00 List-Id: Am 21.10.2010 13:31, schrieb Francesco Piraneo Giuliano: > But my application still need to be written and has to run under linux > so to collect some data about linux' framebuffer I have to use ioctl; > the only solution is to write all low level interfacing (open the > device, get informations about, map it into memory) in C then write > the upper level in Ada? Look here http://www.pegasoft.ca/resources/boblap/book.html for information on how to program for Linux in Ada. You can call ioctl from an Ada program, you only have to arrange the parameters. For example this is part of a thin binding to Vide4Linux2 API: with Posix.Io; with Interfaces.C; with Interfaces.C.Strings; private package Video_4_Linux_2.Ioctls is package C renames Interfaces.C; VIDIOC_QUERYCAP : constant := -2140645888; ... type C_V4l2_Capability is record Driver : C.Char_Array(0 .. 15); Card : C.Char_Array(0 .. 31); Bus_Info : C.Char_Array(0 .. 31); Version : Unsigned32; Capabilities : Bits32; Reserved : U32_Array(0 .. 3); end record; pragma Convention (C, C_V4l2_Capability); function Ioctl (Fd : POSIX.IO.File_Descriptor; Cmd : C.int; Arg : access C_V4l2_Capability) return C.int; pragma Import (C, Ioctl, "ioctl"); And you use this ioctl like this: type Capability_array is array(Capability_Index) of boolean; type V4l2_Capability is record Driver : String(1 .. 16); Card : String(1 .. 32); Bus_Info : String(1 .. 32); Version : Natural; Capabilities : Capability_Array; end record; procedure Get_Capability (Device : Video_Device; Cap : out V4l2_Capability) is C_Cap : aliased C_V4l2_Capability; begin if 0 = Ioctl (Device.Fd, VIDIOC_QUERYCAP, C_Cap'access) then Cap.Driver(1..C.To_Ada (C_Cap.Driver)'Length) := C.To_Ada (C_Cap.Driver); Cap.Driver(C.To_Ada (C_Cap.Driver)'Length+1..16) := (others => ' '); ...