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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Linux kernel module - memory allocation Date: Mon, 18 May 2015 19:02:44 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net zqkwvoUjrGPTweRv57YNgA94vpihs+JebuEcjJPgYWb1NydV4y Cancel-Lock: sha1:2dlgZT9o5cRA55EASbxYShu/FVI= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: Xref: number.nntp.giganews.com comp.lang.ada:193213 Date: 2015-05-18T19:02:44+03:00 List-Id: On 15-05-18 12:19 , q.kontinuum wrote: > Hi, thanks a lot for the fast reply. > > In comp.lang.ada, you wrote: >> On 15-05-18 11:27 , q.kontinuum wrote: >> Do you mean a real "driver", either kernel-linked or a loadable module? > > Yes, I'm aiming for a loadable kernel module. Ok. I don't think many people have tried this with GNAT or Ada -- I don't know of any others. Do you know anyone who has done it? I you haven't already done so, you should find out what "elaboration" means in Ada (= initializations before the main subprogram starts), and either ensure that your driver somehow does it, although it has no main subprogram -- perhaps some part of the driver should call "adainit" explicitly -- or perhaps by ensuring that your Ada code needs no elaboration. Look into the pragmas Preelaborate and No_Elaboration_Code (the latter is GNAT-specific). The Gnat User Guide section http://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/building_executable_programs_with_gnat.html#binding-with-non-ada-main-programs may be useful. >> Which Ada compiler are you using? Do you use some specific compiler >> switches to adapt it to the driver environment? > > I'm using gnat. Command line to compile a > gnatmake -a -s -mcmodel=kernel ... I couldn't find any AdaCore documentation about -mcmodel=kernel with GNAT. Hmm... >> You could try with a constrained string subtype, say String(1 .. 10), > > I assume if I use that within a function, I'd run into the same problem > because the function might be called more often, thus still requiring > dynamic allocation. I don't follow. if you say subtype String10 is String(1 .. 10); then every object of type String10 has a static size. Local variables of that type will be allocated on the (primary, standard) stack, but that does not count as dynamic allocation. Perhaps you are thinking of some part of your real application, not strings at all? -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .