This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] libstdc++/67747 Allocate space for dirent::d_name

On 10/02/2015 11:43 AM, Florian Weimer wrote:
On 10/02/2015 07:37 PM, Martin Sebor wrote:

I'm not sure what you are basing this assertion on. In the man
pages I have looked at, memcpy is documented as MT-Safe. readdir
is documented as MT-Unsafe. The Unsafe definition is clear:
contains global and static data that is not protected.

I think the Solaris thread-safety attributes are a bit too simplistic to
capture the whole scope of thread safety issues for functions operating
on mutable data.

For example, Solaris 11.2:

“It is safe to use readdir() in a threaded application, so long as only
one thread reads from the directory stream at any given time. The
readdir() function is generally preferred over the readdir_r() function.”

Ah, I see the discrepancy. I had a few pages open, one for Solaris
9 and one for 11.2. The newer one has the quote, the older one does

Here's the older page:

With that, I agree that using readdir is thread-safe on Solaris 11.2.
It is not safe on Solaris 9, and it would not be safe on other systems
that don't document it as such.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]