Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Feb 2024 12:02:39 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        Warner Losh <imp@freebsd.org>, src-committers <src-committers@freebsd.org>,  "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>,  "<dev-commits-src-main@freebsd.org>" <dev-commits-src-main@freebsd.org>
Subject:   Re: git: c27a89971805 - main - stdlib.h: add __noexcept to prototypes
Message-ID:  <CANCZdfoTV_Zn4NfvB%2BaPhB_uAj5qjuOersD8WJkZNskqz5A_sQ@mail.gmail.com>
In-Reply-To: <Zb07fS0uA8C_0AaL@kib.kiev.ua>
References:  <202402021816.412IGxAl070009@gitrepo.freebsd.org> <Zb00WYdB01tU9sWq@kib.kiev.ua> <CANCZdfq-uRbMmHuW8EHj5BzFrZwrju4Wh46kOQnrG-mvMDQS2Q@mail.gmail.com> <Zb07fS0uA8C_0AaL@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Fri, Feb 2, 2024 at 11:59 AM Konstantin Belousov <kostikbel@gmail.com>
wrote:

> On Fri, Feb 02, 2024 at 11:36:35AM -0700, Warner Losh wrote:
> > On Fri, Feb 2, 2024, 11:28 AM Konstantin Belousov <kostikbel@gmail.com>
> > wrote:
> >
> > > On Fri, Feb 02, 2024 at 06:16:59PM +0000, Warner Losh wrote:
> > > > The branch main has been updated by imp:
> > > >
> > > > URL:
> > >
> https://cgit.FreeBSD.org/src/commit/?id=c27a89971805b176dcfa5a234f2ea6f6109d0a70
> > > >
> > > > commit c27a89971805b176dcfa5a234f2ea6f6109d0a70
> > > > Author:     Lexi Winter <lexi@le-Fay.ORG>
> > > > AuthorDate: 2024-02-02 16:41:40 +0000
> > > > Commit:     Warner Losh <imp@FreeBSD.org>
> > > > CommitDate: 2024-02-02 18:11:17 +0000
> > > >
> > > >     stdlib.h: add __noexcept to prototypes
> > > >
> > > >     The noexcept specifier is required on these functions in C++:
> > > >     _Exit(), atexit(), quick_exit(), at_quick_exit(), abort().
> > > >
> > > >     MFC after:      2 weeks
> > > >
> > > >     Reviewed by: imp
> > > >     Pull Request: https://github.com/freebsd/freebsd-src/pull/1085
> > > > ---
> > > >  include/stdlib.h | 10 +++++-----
> > > >  1 file changed, 5 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/include/stdlib.h b/include/stdlib.h
> > > > index ff8991d1fa94..f0687f01e6c7 100644
> > > > --- a/include/stdlib.h
> > > > +++ b/include/stdlib.h
> > > > @@ -84,9 +84,9 @@ extern int __mb_cur_max;
> > > >  extern int ___mb_cur_max(void);
> > > >  #define      MB_CUR_MAX      ((size_t)___mb_cur_max())
> > > >
> > > > -_Noreturn void        abort(void);
> > > > +_Noreturn void        abort(void) __noexcept;
> > > >  int   abs(int) __pure2;
> > > > -int   atexit(void (* _Nonnull)(void));
> > > > +int   atexit(void (* _Nonnull)(void)) __noexcept;
> > > >  double        atof(const char *);
> > > >  int   atoi(const char *);
> > > >  long  atol(const char *);
> > > > @@ -154,7 +154,7 @@ unsigned long long
> > > >        strtoull(const char * __restrict, char ** __restrict, int);
> > > >  #endif /* __LONG_LONG_SUPPORTED */
> > > >
> > > > -_Noreturn void        _Exit(int);
> > > > +_Noreturn void        _Exit(int) __noexcept;
> > > >  #endif /* __ISO_C_VISIBLE >= 1999 */
> > > >
> > > >  /*
> > > > @@ -163,9 +163,9 @@ _Noreturn void     _Exit(int);
> > > >  #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
> > > >  void *       aligned_alloc(size_t, size_t) __malloc_like
> > > __alloc_align(1)
> > > >           __alloc_size(2);
> > > > -int  at_quick_exit(void (*)(void));
> > > > +int  at_quick_exit(void (*)(void)) __noexcept;
> > > >  _Noreturn void
> > > > -     quick_exit(int);
> > > > +     quick_exit(int) __noexcept;
> > > This is wrong, libc quick_exit() does not provide such guarantees as
> > > implemented. More, being part of libc it cannot ever guarantee that
> ever
> > > (and call std::terminate if the requirement is violated).
> > >
> > > Making it such would require bringing some C++ ABI into libc which I
> > > object strongly.
> > >
> >
> > So is this just for quick_exit, or all the functions marked?
> Other functions are abort()/_Exit()/atexit(). No functions in this list
> call a user-provided functions, so they cannot raise exceptions.
>
> My objection is only against our quick_exit().
>

OK. I'll back that one out.

Warner

[-- Attachment #2 --]
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 2, 2024 at 11:59 AM Konstantin Belousov &lt;<a href="mailto:kostikbel@gmail.com">kostikbel@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Feb 02, 2024 at 11:36:35AM -0700, Warner Losh wrote:<br>
&gt; On Fri, Feb 2, 2024, 11:28 AM Konstantin Belousov &lt;<a href="mailto:kostikbel@gmail.com" target="_blank">kostikbel@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt; <br>
&gt; &gt; On Fri, Feb 02, 2024 at 06:16:59PM +0000, Warner Losh wrote:<br>
&gt; &gt; &gt; The branch main has been updated by imp:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; URL:<br>
&gt; &gt; <a href="https://cgit.FreeBSD.org/src/commit/?id=c27a89971805b176dcfa5a234f2ea6f6109d0a70" rel="noreferrer" target="_blank">https://cgit.FreeBSD.org/src/commit/?id=c27a89971805b176dcfa5a234f2ea6f6109d0a70</a><br>;
&gt; &gt; &gt;<br>
&gt; &gt; &gt; commit c27a89971805b176dcfa5a234f2ea6f6109d0a70<br>
&gt; &gt; &gt; Author:     Lexi Winter &lt;lexi@le-Fay.ORG&gt;<br>
&gt; &gt; &gt; AuthorDate: 2024-02-02 16:41:40 +0000<br>
&gt; &gt; &gt; Commit:     Warner Losh &lt;imp@FreeBSD.org&gt;<br>
&gt; &gt; &gt; CommitDate: 2024-02-02 18:11:17 +0000<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     stdlib.h: add __noexcept to prototypes<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     The noexcept specifier is required on these functions in C++:<br>
&gt; &gt; &gt;     _Exit(), atexit(), quick_exit(), at_quick_exit(), abort().<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     MFC after:      2 weeks<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     Reviewed by: imp<br>
&gt; &gt; &gt;     Pull Request: <a href="https://github.com/freebsd/freebsd-src/pull/1085" rel="noreferrer" target="_blank">https://github.com/freebsd/freebsd-src/pull/1085</a><br>;
&gt; &gt; &gt; ---<br>
&gt; &gt; &gt;  include/stdlib.h | 10 +++++-----<br>
&gt; &gt; &gt;  1 file changed, 5 insertions(+), 5 deletions(-)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; diff --git a/include/stdlib.h b/include/stdlib.h<br>
&gt; &gt; &gt; index ff8991d1fa94..f0687f01e6c7 100644<br>
&gt; &gt; &gt; --- a/include/stdlib.h<br>
&gt; &gt; &gt; +++ b/include/stdlib.h<br>
&gt; &gt; &gt; @@ -84,9 +84,9 @@ extern int __mb_cur_max;<br>
&gt; &gt; &gt;  extern int ___mb_cur_max(void);<br>
&gt; &gt; &gt;  #define      MB_CUR_MAX      ((size_t)___mb_cur_max())<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; -_Noreturn void        abort(void);<br>
&gt; &gt; &gt; +_Noreturn void        abort(void) __noexcept;<br>
&gt; &gt; &gt;  int   abs(int) __pure2;<br>
&gt; &gt; &gt; -int   atexit(void (* _Nonnull)(void));<br>
&gt; &gt; &gt; +int   atexit(void (* _Nonnull)(void)) __noexcept;<br>
&gt; &gt; &gt;  double        atof(const char *);<br>
&gt; &gt; &gt;  int   atoi(const char *);<br>
&gt; &gt; &gt;  long  atol(const char *);<br>
&gt; &gt; &gt; @@ -154,7 +154,7 @@ unsigned long long<br>
&gt; &gt; &gt;        strtoull(const char * __restrict, char ** __restrict, int);<br>
&gt; &gt; &gt;  #endif /* __LONG_LONG_SUPPORTED */<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; -_Noreturn void        _Exit(int);<br>
&gt; &gt; &gt; +_Noreturn void        _Exit(int) __noexcept;<br>
&gt; &gt; &gt;  #endif /* __ISO_C_VISIBLE &gt;= 1999 */<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;  /*<br>
&gt; &gt; &gt; @@ -163,9 +163,9 @@ _Noreturn void     _Exit(int);<br>
&gt; &gt; &gt;  #if __ISO_C_VISIBLE &gt;= 2011 || __cplusplus &gt;= 201103L<br>
&gt; &gt; &gt;  void *       aligned_alloc(size_t, size_t) __malloc_like<br>
&gt; &gt; __alloc_align(1)<br>
&gt; &gt; &gt;           __alloc_size(2);<br>
&gt; &gt; &gt; -int  at_quick_exit(void (*)(void));<br>
&gt; &gt; &gt; +int  at_quick_exit(void (*)(void)) __noexcept;<br>
&gt; &gt; &gt;  _Noreturn void<br>
&gt; &gt; &gt; -     quick_exit(int);<br>
&gt; &gt; &gt; +     quick_exit(int) __noexcept;<br>
&gt; &gt; This is wrong, libc quick_exit() does not provide such guarantees as<br>
&gt; &gt; implemented. More, being part of libc it cannot ever guarantee that ever<br>
&gt; &gt; (and call std::terminate if the requirement is violated).<br>
&gt; &gt;<br>
&gt; &gt; Making it such would require bringing some C++ ABI into libc which I<br>
&gt; &gt; object strongly.<br>
&gt; &gt;<br>
&gt; <br>
&gt; So is this just for quick_exit, or all the functions marked?<br>
Other functions are abort()/_Exit()/atexit(). No functions in this list<br>
call a user-provided functions, so they cannot raise exceptions.<br>
<br>
My objection is only against our quick_exit().<br></blockquote><div><br></div><div>OK. I&#39;ll back that one out.</div><div><br></div><div>Warner </div></div></div>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfoTV_Zn4NfvB%2BaPhB_uAj5qjuOersD8WJkZNskqz5A_sQ>