[webkit-dev] Question for people working on ports
Krzysztof Kowalczyk
kkowalczyk at gmail.com
Thu Sep 29 15:11:22 PDT 2005
That's really a compiler thing. On Windows (both for desktop and
pocket pc) Microsoft's compilers support /FI (Name Forced Include
File) option. To quote
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcce/htm/complref_11.asp:
"This option causes the preprocessor to process the specified header
file. This option has the same effect as specifying the file with
double quotes in an #include directive on the first line of every
source file specified on the command line, in the CL environment
variable, or in an command file. If you use multiple /FI options,
files are included in the order they are processed by CL."
So it'll be possible to craft a Makefile that will add "/FIconfig.h"
to every compilation.
On gcc "-include" seems to do the same (according to
http://www.freeos.com/articles/3185/) so the same should be doable on
Linux.
Symbian, as far as I know, uses gcc as well (at least some versions of
the SDK) so as long as the version of gcc that they use supports a
similar option, it should work as well.
Having said that, in general I'm wary of using tricks like this. C++
compilers don't seem to support them uniformly well. Some of the
javascriptcore code depended on gcc-specific behaviour and required
changes for visual c compatiblity.
On Windows, for example, malloc() is thread-safe by default so unless
there is a measurable speed gain in using the replacement, there's
little value in using something else.
-- kjk
On 9/29/05, Maciej Stachowiak <mjs at apple.com> wrote:
>
> Hi everyone,
>
> After recently changing to a threadsafe malloc, I'd like to use it
> for all C++ allocations in WebCore/JavaScriptCore. Darin suggested a
> neat trick for doing this, where we can do a private declaration of
> operator new, so it won't affect outside C++ code:
>
> #if __GNUC__
> #define PRIVATE_INLINE __private_extern__ inline __attribute__
> ((always_inline))
> #else
> #define PRIVATE_INLINE inline
> #endif
>
> PRIVATE_INLINE void* operator new(size_t s) { return fastMalloc(s); }
> PRIVATE_INLINE void operator delete(void* p) { fastFree(p); }
> PRIVATE_INLINE void* operator new[](size_t s) { return fastMalloc(s); }
> PRIVATE_INLINE void operator delete[](void* p) { fastFree(p); }
>
>
> Note that the operator declarations are inline, so the header that
> contains this must be included in every C++ implementation file (or
> you could get new/delete mismatches which would lead to crashes or
> random memory trashing).
>
> On Mac OS X, the easiest way to do this is to make sure these
> definitions are included in the per-project prefix header. The Xcode
> build system will tell gcc to make a precompiled header out of this,
> and then automatically pass it as a prefix header to all gcc
> invocations. I don't know if other build systems have anything
> analogous. Another possible alternative is to make sure these
> declarations go in config.h, and then force every source file to
> include it. But that's a little ugly and furthermore hard to
> maintain, since forgetting a config.h include will not lead to a
> build failure but will cause incorrect code to be generated.
>
>
> So does anyone have any experience here? I'd like the solution to
> work at least on Linux, Windows and Symbian Series 60.
>
> Regards,
> Maciej
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at opendarwin.org
> http://www.opendarwin.org/mailman/listinfo/webkit-dev
>
More information about the webkit-dev
mailing list