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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c6acbb9f2027b8c9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 06 Oct 2005 18:48:43 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1128525722.605730.281980@g43g2000cwa.googlegroups.com> <87mzlnomca.fsf@ludovic-brenta.org> <1128606036.713575.3990@z14g2000cwz.googlegroups.com> Subject: Re: volatile vs aliased Date: Thu, 6 Oct 2005 18:52:28 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4952.2800 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4952.2800 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-Zi6TUYqa4tAfMcX1VlxPVJ87hHu17Oh4Qtry1PhMiAT41RwpLQZG8PFObo2PaLI3/TyE1w1pRfPdwOB!HxNZyLYQd226rv9049OkMqNekIxRXIwWH0o85vK6dVwCOX6MPJcOnfCD8PI93bV4KFL6GLYpQkv4!99qDxPImVzVQPQ== X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:5470 Date: 2005-10-06T18:52:28-05:00 List-Id: "REH" wrote in message news:1128606036.713575.3990@z14g2000cwz.googlegroups.com... ... > That's good stuff. Will it still apply when the address is to a > subprogram? Can Address_to_Access_Conversions be instantiated with a > subprogram? No. > That's what I've been trying to do, but I don't know how > to make a generic that takes an access to an arbitrary subprogram type. > So, I think I am "stuck" using the for X'address specification. For that, I generally use an appropriate access-to-subprogram type (with the correct profile), and a dummy "void" access-to-subprogram, and an Unchecked_Conversion. For instance, "void" is cast as a parameterless procedure with the correct convention. Say we want a access-to-function: type Void_Subprogram is access procedure; pragma Convention (C, Void_Subprogram); -- Use this in the "generic" interfacing routines. type A_Func is access function (A : Integer) return Integer; pragma Convention (C, A_Func); function Convert is new Unchecked_Conversion (Source => Void_Subprogram, Target => A_Func); You do have to know that the C compiler uses the same representation for all access-to-subprogram types (which is likely, more likely than it is for Ada), but that's the only assumption that you need to make. You can also use System.Address in place of Void_Subprogram (using the same Unchecked_Conversion), but it may not have the appropriate representation on some targets. (One example was the U2200 compiler we worked on -- access-to-subprogram values included an extra link word along with the address, so an Unchecked_Conversion from Address wouldn't work. That was required by the underlying system; I don't think there was a way around it.) Randy.