comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: StdCall and pragma Import_Function
Date: Fri, 19 Aug 2011 22:37:15 +0200
Date: 2011-08-19T22:37:15+02:00	[thread overview]
Message-ID: <1wy52h1ibxvgr$.1uzxk4brvx3i5.dlg@40tude.net> (raw)
In-Reply-To: 51f8a92b-41b2-4d57-914e-a326163adc9f@glegroupsg2000goo.googlegroups.com

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



  reply	other threads:[~2011-08-19 20:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 16:24 StdCall and pragma Import_Function Felix Krause
2011-08-19 16:51 ` Dmitry A. Kazakov
2011-08-19 17:07   ` Felix Krause
2011-08-19 18:58     ` Dmitry A. Kazakov
2011-08-19 19:23       ` Felix Krause
2011-08-19 19:43         ` Dmitry A. Kazakov
2011-08-19 20:07           ` Felix Krause
2011-08-19 20:37             ` Dmitry A. Kazakov [this message]
2011-08-19 20:45             ` Jeffrey Carter
2011-08-21 18:25               ` Felix Krause
2011-08-20  8:04           ` Georg Bauhaus
2011-08-20  9:23             ` Dmitry A. Kazakov
2011-08-19 17:26   ` Adam Beneschan
2011-08-19 17:38     ` Felix Krause
2011-08-19 18:10 ` Jeffrey Carter
2011-08-19 18:37   ` Felix Krause
replies disabled

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