[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

call conventions and linkage (was: svn commit: rev 2196 - trunk/subversion/svnadmin)

From: Greg Stein <gstein_at_lyra.org>
Date: 2002-06-14 01:43:35 CEST

On Fri, Jun 14, 2002 at 12:03:28AM +0200, Branko Cibej wrote:
> Greg Stein wrote:
> >On Thu, Jun 13, 2002 at 04:34:47PM -0500, brane@tigris.org wrote:
>...
> >>* svnadmin/main.c (create_stdio_stream): APR_DECLARE the open-file
> >>callback. This macro is not a no-op on Windows, and without this change,
> >>the compiler compains about different function attributes (probably has
> >>to do with the calling convention).
> >
> >Yep -- calling conventions. The exported APR functions are __stdcall (which,
> >I believe, means Pascal-style conventions). And I'm guessing that our .dsp
> >files set cdecl as the default convention.
>
> Our .dsp files set nothing, we just use whatever is the compiler default.
> I don't think we need something like APR_DECLARE for Subversion, do we?

Hmm... The stdcall convention is a bit more optimal, as I recall. But even
if you just leave it as cdecl interfaces, we may want to consider something
like APR_DECLARE.

IIRC, those macros also arrange to get the right dllimport / dllexport
declspec into the compilation. As a result, the compiler/linker can generate
much more efficient calls to the functions. Without them, then the runtime
goes through a symbolic lookup. The workaround there is to use ordinals on
your entry points, but then you have to manually maintain the table.

Net result: the macros make intra-DLL calls much more efficient.

Now if we were to do it... hoo. The problem then becomes that we need a
different set of macros for *each* library/DLL. When you're compiling, say,
libsvn_client, you will be exporting its symbols, but importing symbols from
libsvn_ra. So you end up with SVN_CLIENT_DECLARE() and SVN_RA_DECLARE().

Fun, huh?

(and the macros flip between import/export based on a flag specified in the
 .dsp file; the macro turns on export; most users never set a flag so they
 get "import")

Note that APR has variations for static builds, and (since the default is
'stdcall' convention) macros for cdecl functions. I would recommend that we
avoid stdcall and not worry about static builds [on Windows]. APR also has
macros for data items (which we don't have in our APIs, thankfully).

Back to your original point... thinking about it... I might tend to say,
"yes, we need SVN_*_DECLARE() macros, too." We only need the _DECLARE form,
but we need one for every library(!).

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jun 14 01:42:20 2002

This is an archived mail posted to the Subversion Dev mailing list.