std:string thread-safety

Boris Goldberg boris.goldberg@msdw.com
Thu Mar 22 14:34:00 GMT 2001


Hi all,
 
  I have a question:

here is what I see in bastring.h which comes with g++/gcc 2.95.2.1:



#elif defined __sparcv9__
    void release ()
      {
	size_t __newval, __oldval = ref;
	do
	  {
	    __newval = __oldval - 1;
	    __asm__ ("cas	[%4], %2, %0"
		     : "=r" (__oldval), "=m" (ref)
		     : "r" (__oldval), "m" (ref), "r"(&(ref)), "0" (__newval));
	  }
	while (__newval != __oldval);

	if (__oldval == 0)
	  delete this;
      }


As I understand, this assembly code makes std::string thread-safe.
The problem is, __sparcv9__ is not defined on our UltraSparc systems
and the string ends up being thread-unsafe and it crashes.
 
Can you shed some light on this?

						Thanks,

						Boris Goldberg



More information about the Libstdc++ mailing list