[llvm-commits] [PATCH] work around a nasty g++/glibc incompatiblity
Dan Gohman
gohman at apple.com
Sun Jun 14 16:50:46 PDT 2009
On Jun 14, 2009, at 3:55 AM, Benjamin Kramer wrote:
> Török Edwin wrote:
>> The GNU version always returns a pointer to the error message, it
>> may or
>> may not use the buffer supplied.
>> (I think it doesn't use the buffer if it can return a pointer to the
>> error message table).
>> Accessing the returned pointer is thread safe in either case, so you
>> could check if the returned value == buffer, and if not copy it to
>> buffer. It would still be thread safe.
Instead of copying the string into the buffer for the GLIBC case, could
you add a new char* variable at the top of the function and assign to
it the
address of the buffer, and make the std::string construction at the
bottom
use that variable instead of the buffer? Then, the glibc case could
just
reassign the char* variable.
Also, please make the test be
defined(__GLIBC__) && defined(_GNU_SOURCE)
because _GNU_SOURCE sometimes ends up defined on non-GLIBC
systems.
Thanks,
Dan
More information about the llvm-commits
mailing list