In this context I interpret it as "without having been designed to achieve it, it still is thread-safe".
There is no direct link to the concept of inheritance, although of course the words are related. This is not an example of inheritance in the object-oriented programming sense, of course. This is just a function, that from its core nature gets the property of being thread-safe.
Of course there's nothing magic about memcpy()
being inherently thread-safe, either. Any function without internal state or "shared" side-effects will be so, which is why functional programming, where all functions are supposed to be "pure" and lack side-effects, lends itself so well to parallel programming.
In practice it's hard on typical computers to get "real work" done without side-effects, particularly I/O is very much defined by its side-effects. So even pure functional languages often have some non-functional corners.
Update: Of course, memcpy()
is not free from side-effects, it's core purpose is to manipulate memory which, if shared between threads, certainly isn't safe. The assumption has to be that as long as the destination areas are distinct, it doesn't matter if one or more threads run memcpy()
in parallel.
Contrast this with e.g. printf()
, which generates characters on a single (for the process) output stream. It has to be explicitly implemented (as required by POSIX) to be thread-safe, whereas memcpy()
does not.
memcpy
of course doesn't need to touch shared state (and thus is naively thread-safe), it modifies arbitrary memory regions in an unsynchronized manner, which is very obviously not thread-safe at all.memcpy
is required by Posix to be thread-safe under that definition. The quote from Wikipedia is not necessarily consistent with this definition, although it could be if we were very careful what we mean by "shared data structures". So, it is only absurd to you because you miss the context in which "thread-safe" is defined. The tags are unfortunate since the usual meaning of "thread-safe" in Java is different from the usual meaning in C.