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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,39ade949adb6bf4 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news-transit.tcx.org.uk!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: StdCall and pragma Import_Function Date: Fri, 19 Aug 2011 22:37:15 +0200 Organization: cbb software GmbH Message-ID: <1wy52h1ibxvgr$.1uzxk4brvx3i5.dlg@40tude.net> References: <332032a4-0acf-459d-a743-e90e823ca5af@glegroupsg2000goo.googlegroups.com> <118ybwhr53151$.fjqabmpo2k23$.dlg@40tude.net> <3feb634f-ca38-4f08-a6da-5299233f295e@glegroupsg2000goo.googlegroups.com> <11f8n1nxhs0hg$.16p4wm0m6u4nt.dlg@40tude.net> <1je5iuczb7anp.1vt48byg9dio7$.dlg@40tude.net> <51f8a92b-41b2-4d57-914e-a326163adc9f@glegroupsg2000goo.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: k4I7B8KOb++aONcKk8Z+SQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news1.google.com comp.lang.ada:20691 Date: 2011-08-19T22:37:15+02:00 List-Id: On Fri, 19 Aug 2011 13:07:16 -0700 (PDT), Felix Krause wrote: > typedef signed __int32 cl_int; > > typedef struct _cl_platform_id * cl_platform_id; > > typedef unsigned __int64 cl_ulong; > typedef cl_ulong cl_bitfield; > typedef cl_bitfield cl_device_type; > > typedef struct _cl_device_id * cl_device_id; > > typedef unsigned __int32 cl_uint; > > (For further details, the headers are available at http://www.khronos.org/registry/cl/ as cl.h and cl_platform.h) > > As this problem definitely is fixable (by substituting the bit vector > types with ULong in the function definitions), I'm confident I'll get my > bindings working cross-platform. Unlike Glib, OpenCL is an open standard > and there was much effort to make the API as clear and portable as > possible. There also exist cross-platform bindings for the related OpenGL > API in Ada, so it definitely is possible. with Interfaces; use Interfaces; type cl_int is new Integer_32; type cl_uint is new Unsigned_32; type cl_device_type is new Unsigned_64; function clGetDeviceIDs ( platform : System.Address; -- access cl_platform_id device_type : cl_device_type; num_entries : cl_uint; devices : System.Address; -- access cl_device_id num_devices : access cl_uint ) return cl_int; pragma Import (Stdcall, clGetDeviceIDs, "_clGetDeviceIDs@24"); Note: 1. I used System.Address twice, because you hadn't provided the corresponding structures. 2. You have to use explicit external names everywhere. First you check that the generated name has the correct @n suffix. It must be "clGetDeviceIDs@24" in the above case. Then you add "_" prefix to it, and specify the result as an external name. 3. It is not GNAT bug, it is crippled library interface. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de