[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can we go GTK-only?

From: Perry E. Metzger
Subject: Re: Can we go GTK-only?
Date: Tue, 1 Nov 2016 12:41:12 -0400

On Tue, 01 Nov 2016 17:11:57 +0200 Eli Zaretskii <address@hidden> wrote:
> > Of course you can call malloc from multiple threads. Otherwise,
> > projects like jemalloc would be pointless. You can freely
> > allocate and deallocate from different threads on both POSIX and
> > Windows systems, and there is no need to free an object on the
> > thread that allocated it.  
> IMO, this is not a safe assumption, even though in practice more and
> more systems out there provide thread-safe native malloc.  Only C11
> mandates that malloc/realloc/free shall be thread-safe, and we don't
> yet require C11.

I was under the impression the requirement that malloc be thread safe
was before now a POSIX/pthreads thing, not a C standard thing, and
that this had been the case for a very long time.

SUS says this explicitly here: 

   2.9.1 Thread-Safety

   All functions defined by this volume of POSIX.1-2008 shall be
   thread-safe, except that the following functions need not be

It then goes on to not mention malloc, so malloc is required to be
thread safe.

I can look up old versions of the standard but I believe it was the
case as long as pthreads has been around.

Perry E. Metzger                address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]