[Mesa-dev] [PATCH] util: port _mesa_strto[df] to C

Matt Turner mattst88 at gmail.com
Mon Mar 16 13:37:47 PDT 2015


On Sun, Mar 15, 2015 at 12:05 PM, Erik Faye-Lund <kusmabite at gmail.com> wrote:
> _mesa_strtod and _mesa_strtof are only used from the GLSL compiler,
> so the locale doesn't need to be initialized before the first context
> gets initialized. So let's use explicit initialization from the
> one-time init code instead of depending on a C++ compiler to initialize
> at image-load time.
>
> Signed-off-by: Erik Faye-Lund <kusmabite at gmail.com>
> ---
>
> Because of the recent discussion on libc++ and Mesa, I thought I'd
> have a look into what parts of mesa depended on libc++, and I spotted
> this file.
>
> In this case, it was rather trivial to port the code to plain C, making
> it dead obvious that it doesn't depend on libc++. I'm not proposing all
> C++ gets this treatment, but in this case it seems like a pretty
> straight-forward way to make it obvious that this code does not depend
> on libc++.

This looks good to me. It'd be nice if idr could take a look as well.

Reviewed-by: Matt Turner <mattst88 at gmail.com>

The one annoyance is that autotools doesn't work across this change.
After applying this patch to a configured and built tree, you'll get

make[4]: *** No rule to make target
'../../../mesa/src/util/strtod.cpp', needed by
'libmesautil_la-strtod.lo'.  Stop.

when running make.

To fix, run

sed -i -e 's/strtod.cpp/strtod.c/' src/util/.deps/libmesautil_la-strtod.Plo

The file will be in your build tree.


More information about the mesa-dev mailing list