[Zlib-devel] Re: The calling convention in zlibCompileFlags()

Cosmin Truta cosmin at cs.toronto.edu
Mon Aug 4 22:00:46 EDT 2003


After a little web search, I found out there exists a whole menagerie of
calling conventions, with a world of peculiar restrictions (for example,
register preservation, which has never been discussed in our lists),
constraints and whatnot. This article is particularly interesting:

http://web.sau.edu/LillisKevinM/csci240/masmdocs/programmersguide/16LMAPGC12.pdf

but even this one doesn't cover everything. For example, it doesn't
cover fastcall.

We should not encourage the use of any other convention besides STDCALL.
I will also rewrite the Delphi port, converting FASTCALL to CDECL.
Another thing that I would like to propose is that instead of using
STDCALL for 32-bit Windows and PASCAL for 16-bit Windows, we should in
fact use WINAPI, which gets translated to STDCALL in 32 bits, and to
PASCAL in 16 bits.

Summary:

- ZLIB_STDCALL gets changed to ZLIB_WINAPI.
- ZLIB_FASTCALL gets removed.
- zlibCompileFlags() should worry only about ZLIB_WINAPI, and spend only
  one bit with this.

If any user will want any other fancy convention, s/he will use it at
her or his own risk.


Unless any of you disagrees, I will prepare the next update to the
DLL_FAQ, and the zlib-1.2.0.f-cos2 release, by considering these
decisions.


Best regards,
Cosmin


On Sat, 2 Aug 2003, Cosmin Truta wrote:

> At Gerard's suggestion, I propose to add the calling convention flags to
> the report given by zlibCompileFlags(). Given the fact that the function
> does not have arguments, it can be safely called from any application,
> using any convention.
>
> Since there are 3 conventions, CDECL (default), ZLIB_STDCALL and
> ZLIB_FASTCALL, we need 2 flags. I chose 28 and 29, but if you think
> these numbers are not the best choice, feel free to change them.
>
> ZLIB_STDCALL and ZLIB_FASTCALL are mutually exclusive, and even though
> both flags can be set in theory, exclusivity will be guaranteed by
> zconf.h. Maybe ((1 << 28) | (1 << 29)) will be used by who knows what
> other convention that may appear and be used in some future.





More information about the Zlib-devel mailing list