[Top][All Lists]

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

Re: __attribute__ ((cleanup)) and emacs-module.c

From: Philipp Stephani
Subject: Re: __attribute__ ((cleanup)) and emacs-module.c
Date: Thu, 9 Mar 2023 13:56:28 +0100

On Thu, 9 Mar 2023 at 11:20, Po Lu <luangruo@yahoo.com> wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
> >> From: Po Lu <luangruo@yahoo.com>
> >> Cc: eggert@cs.ucla.edu,  arsen@aarsen.me,  emacs-devel@gnu.org
> >> Date: Thu, 09 Mar 2023 16:07:04 +0800
> >>
> >> Eli Zaretskii <eliz@gnu.org> writes:
> >>
> >> > I disagree with your conclusion, and I still think we should complain
> >> > noisily if modules cannot be supported.
> >>
> >> OK, but I still think this is a very bad idea.  Do you object to
> >> rewriting emacs-module.c to not utilize __attribute__ ((cleanup))?
> >>
> >> What was said earlier by some people is wrong: as-is, in Emacs, it makes
> >> no difference whether or not we write:
> >>
> >>    foo __attribute__ ((cleanup (module_reset_handlerlist)))...
> >>
> >> or:
> >>
> >>    foo...
> >>    module_reset_handlerlist (foo);
> >
> > If you want to discuss this, please start a new thread and CC Daniel
> > Colascione and Philipp Stephani, who I believe wrote that part of
> > emacs-module.c.  I don't think we should change that without a
> > thorough discussion, as that code is quite old and I don't think it
> > caused any trouble whatsoever.
> Ok.
> Phillip, Daniel, I'd like to replace the use of the `cleanup' attribute
> in emacs-module.c with portable C code.  The reason is that it is
> implemented unsatisfactorily or not at all in certain compilers I want
> to use.  This includes Sun C 5.10, and various versions of the Android
> NDK GCC that crash generating debuginfo.
> Since Emacs is not built with C++ exception handling, there should be no
> reason to use that attribute.  Any objections?

This attribute is necessary at the moment because otherwise the
handlerlist wouldn't get reset when returning from the module
implementation functions. Without it, you'd need to audit every
occurrence of "return" in the code (including the code generated by
the helper macros) and reset the handlerlist manually. This is
unrelated to C++ exception handling. It's not impossible to do this
manually (it's not so different from the unbind_to calls in the Emacs
codebase), but rather error-prone.

reply via email to

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