Re: globals.c->globals.cc

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Sun, 15 Dec 2002 14:56:42 +0100

And the real problem is what should be addressed there.

The problem is MemPool which was moved into lib without beeing
properly separated from Squid, still relying on the currently Squid
internal "squid_curtime".

As a quick fix squid_curtime can be made 'extern "C"', but the proper
fix would involve a moving the time functions to lib.

Hmm.. there is the same problem for several other variables defined in
include/util.h in certain configurations..

Attached is a small patch which moves the cached time functions to
lib/util.h (but large in bytes due to global search/replace), and
converts them to inlines rather than direct variable access. It also
attemtps to fix a few other SQUIDCEXTERN issues in other include/
headers, mostly code which is not compiled by default.

Summary:

   time_t squid_curtime -> inline currentTimeC()
   double current_dtime -> inline currentTimeD()
   struct timevar current_time -> inline currentTimeVal()
   time_t getCurrentTime() moved to lib/util.c

the current*() functions uses cached time, updated by
getCurrentTime().

Unless someone has an objection like compiler issues with the method
of inline etc I'll commit this to HEAD in a few days.

Regards
Henrik

On Sunday 15 December 2002 10.33, Guido Serassio wrote:
> Hi Robert,
>
> Il 10.07 15/12/2002 Robert Collins ha scritto:
> >I've changed the generation of globals.c to create globals.cc.
> > This allows for C++ syntax in headers such as structs.h.
> >
> >You may find that you need to do the following in your build
> > trees:
> >
> >rm src/globals.o
> >rm src/.deps/globals.Po
> >touch src/.deps/globals.Po
> >
> >before you can build successfully.
> >
> >Cheers
> >Rob
>
> There is only a problem:
>
> Microsoft Visual Studio apply "name decoration" or "name mangling"
> to C++ object files, so, if all global variables defined in
> globals.c are referenced from other C++ object files, Squid links
> fine. But at line 95 in MemPool.c:
>
> /*
> * XXX This is a boundary violation between lib and src.. would be
> good * if it could be solved otherwise, but left for now.
> */
> extern time_t squid_curtime;
>
> The result is an "squid_curtime unresolved external" error in
> MemPool.obj when linking.
>
> Previously I have resolved the issue compiling globals.c as a C
> source and declaring globals.h as extern "C", but now the
> squid_curtime problem must be fixed.
>
> Regards
>
> Guido
>
>
>
> -
> =======================================================
> Serassio Guido
> Via Albenga, 11/4 10134 -
> Torino - ITALY E-mail: guido.serassio@serassio.it
> WWW: http://www.serassio.it

Received on Sun Dec 15 2002 - 06:56:26 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:19:01 MST