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 21:43:18 +0200
Date: 2011-08-19T21:43:18+02:00	[thread overview]
Message-ID: <1je5iuczb7anp.1vt48byg9dio7$.dlg@40tude.net> (raw)
In-Reply-To: a9c2e23c-4d92-4104-936f-40dd559125e0@glegroupsg2000goo.googlegroups.com

On Fri, 19 Aug 2011 12:23:49 -0700 (PDT), Felix Krause wrote:

> From the header file:
> 
> extern CL_API_ENTRY cl_int CL_API_CALL
> clGetDeviceIDs(cl_platform_id   /* platform */,
>                cl_device_type   /* device_type */,
>                cl_uint          /* num_entries */,
>                cl_device_id *   /* devices */,
>                cl_uint *        /* num_devices */) CL_API_SUFFIX__VERSION_1_0;
> 
> Those macros are defined as:
> 
> #if defined(_WIN32) || defined(__CYGWIN__)
> #define CL_API_ENTRY
> #define CL_API_CALL __stdcall
>     #define CL_CALLBACK     __stdcall
> #else
> #define CL_API_ENTRY
> #define CL_API_CALL
>     #define CL_CALLBACK
> #endif
> 
> So it indeed uses StdCall convention. The corresponding output of dumpbin is:
> 
>   Version      : 0
>   Machine      : 14C (x86)
>   TimeDateStamp: 4E03B987 Fri Jun 24 00:09:11 2011
>   SizeOfData   : 0000001E
>   DLL name     : OpenCL.dll
>   Symbol name  : _clGetDeviceIDs@24
>   Type         : code
>   Name type    : undecorate
>   Hint         : 44
>   Name         : clGetDeviceIDs
> 
> (I don't have a def file, but this shows the fully qualified name too.)
> 
> cl_device_type is the bitvector from my example, and GNAT searches for "clGetDeviceIDs@20".

How are the types of the arguments declared?

cl_int
cl_platform_id
cl_device_type
cl_device_id
cl_uint

BTW, you will have problems with making bindings to this mess portable. I
had similar issues with poorly designed Glib. They too have the linkage
names varying from platform to platform. I solved that by using GNU linker
weak references and wrappers. Not nice, but they refused to fix the
problem.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2011-08-19 19:43 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 [this message]
2011-08-19 20:07           ` Felix Krause
2011-08-19 20:37             ` Dmitry A. Kazakov
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