freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] Use of qsort


From: David Turner
Subject: Re: [Devel] Use of qsort
Date: Tue, 26 Jun 2001 20:04:58 +0200

Salut Antoine,

> 
> OK, now you've understand the point (?), what do we do?
> - either we modify every DOS/Windows Makefile and like to discard the 
> __fastcall
>   optimization (it looks like this is what VC++ 6 do by default)
>   Doable, but this raises some potential pitfalls (if some did build its 
> Makefile
>   alone; or we destroy backward compatibility; pure performance is badly 
> affected;
>   etc.)
> - or we introduce another config parameter, similar to FT_EXPORT, FT_LOCALDEF
>   and the like, to tag those functions that are expected to be used as 
> callbacks;
>   by default the config parameters will do nothing, but it may be overridden
>   if needed for the compilers that may need it. I favor this later.
>

The easy thing is to provide our own implementation of quick sort
(or heap sort, shell sort, whatever seems simpler and not too quadratic),
since this completely avoids the problem. Actually, there already is
so rather "reusable" quick sort algorithm in the smooth rasterizer
(using a custom algorithm is critical for performance here)

Other than that, I think that the only viable alternative is to use
yet another configuration macro to declare/define callback functions.
Actually, I just modified the definition of FT_CALLBACK_DEF (which is
used to tag C callback functions when compiling the library in C++
mode, thanks to Werner), as follows in "include/freetype/config/ftconfig.h":

#ifndef FT_CALLBACK_DEF
#  ifdef __cplusplus
#    define FT_CALLBACK_DEF  extern "C"
#  else
#    define FT_CALLBACK_DEF  static
#  endif
#endif

#ifndef FT_CALLBACK_TABLE
#  ifdef __cplusplus
#    define FT_CALLBACK_TABLE      extern "C"
#    define FT_CALLBACK_TABLE_DEF  extern "C"
#  else
#    define FT_CALLBACK_TABLE      extern
#    define FT_CALLBACK_TABLE_DEF
#  endif
#endif

thus, we should be able to define the comparison function with
something along the lines of:

  FT_CALLBACK_DEF  int  comparison( const void* a, const void* b );
 
And let the Makefiles define FT_CALLBACK_DEF to "__stdcall", or whatever
is required for 16-bit compilers.

I just hope that the special keyword doesn't need to be within the
return type and the function name in the definition. Otherwise, we'll
need to define FT_CALLBACK_DEF(), and replace all uses in the source
code..

What do you think about it ??


> Also, a thing worth checking is whether any other part of our libraries, being
> 1.x or 2.x, use any callback back to a standard library (qsort is just an 
> example,
> although it is probably the one which is the most probable).
>
I believe that I didn't use any standard library function when writing
the library. The "qsort" was introduced later, and I should have checked
the issue at that time !!


Regards,

- David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]