[Top][All Lists]

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

Re: Can we go GTK-only?

From: Paul Eggert
Subject: Re: Can we go GTK-only?
Date: Tue, 1 Nov 2016 09:28:34 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

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. 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.

> 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.

> ralloc is not thread-safe at all.

Yes, and ralloc as it stands should not be used on modern platforms. We clearly need to move in that direction anyway.

> xmalloc calls memory_full, which manipulates global state and calls xsignal, so that is not thread-safe, either.

That's fine, so long as xmalloc is called only in the Emacs Lisp thread. xmalloc is like xsignal, Fcons, and lots of other functions that should be called only in the Emacs Lisp thread.

reply via email to

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