emacs-devel
[Top][All Lists]
Advanced

[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 13:15:54 -0400

On Tue, 1 Nov 2016 09:28:34 -0700 Paul Eggert <address@hidden>
wrote:
> On 11/01/2016 08:11 AM, Eli Zaretskii wrote:
>  > Only C11 mandates that malloc/realloc/free shall be thread-safe,
>  > and   
> we don't yet require C11.
> 
> This is too pessimistic. C11 was the first C standard to talk about 
> threads, which is why it's the first C standard to specify whether 
> malloc is thread-safe.

Precisely. Before then, the thread safety of malloc was discussed in
standards that talked about threads, like the pthreads standards in
POSIX.

> In practice it should be safe to assume that 
> malloc is thread-safe on multithreaded platforms, as C programmers
> would have revolted en masse otherwise.

Again, the Single Unix Specification and its predecessors always
said, very explicitly, that malloc was thread safe, as does Windows.
I am unaware of the existence of a platform that supports both C and
threads in which malloc is not documented to be thread safe.
Certainly if such a platform once existed, it is long gone and does
not support a modern Emacs.

>  > gmalloc is only thread-safe if Emacs is built with pthreads.  
> 
> Yes, and that's what one would expect. If you build Emacs in 
> single-threaded mode, malloc won't be thread-safe. But in the
> normal case nowadays, malloc should be thread-safe.

Precisely. Generally, the library calls are only thread safe if you
link with the pthreads library or the like, but we're presuming that
is what would happen here.

Perry
-- 
Perry E. Metzger                address@hidden



reply via email to

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