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
--0000000000002ca5bf06106ac272
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, Feb 2, 2024 at 11:59=E2=80=AFAM Konstantin Belousov <kostikbel@gmai=
l.com>
wrote:

> On Fri, Feb 02, 2024 at 11:36:35AM -0700, Warner Losh wrote:
> > On Fri, Feb 2, 2024, 11:28=E2=80=AFAM Konstantin Belousov <kostikbel@gm=
ail.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=3Dc27a89971805b176dcfa5a234f2ea6f=
6109d0a70
> > > >
> > > > 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 >=3D 1999 */
> > > >
> > > >  /*
> > > > @@ -163,9 +163,9 @@ _Noreturn void     _Exit(int);
> > > >  #if __ISO_C_VISIBLE >=3D 2011 || __cplusplus >=3D 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

--0000000000002ca5bf06106ac272
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Fri, Feb 2, 2024 at 11:59=E2=80=AF=
AM Konstantin Belousov &lt;<a href=3D"mailto:kostikbel@gmail.com">kostikbel=
@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"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=E2=80=AFAM Konstantin Belousov &lt;<a href=
=3D"mailto:kostikbel@gmail.com" target=3D"_blank">kostikbel@gmail.com</a>&g=
t;<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=3D"https://cgit.FreeBSD.org/src/commit/?id=3Dc27a89971805=
b176dcfa5a234f2ea6f6109d0a70" rel=3D"noreferrer" target=3D"_blank">https://=
cgit.FreeBSD.org/src/commit/?id=3Dc27a89971805b176dcfa5a234f2ea6f6109d0a70<=
/a><br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; commit c27a89971805b176dcfa5a234f2ea6f6109d0a70<br>
&gt; &gt; &gt; Author:=C2=A0 =C2=A0 =C2=A0Lexi Winter &lt;lexi@le-Fay.ORG&g=
t;<br>
&gt; &gt; &gt; AuthorDate: 2024-02-02 16:41:40 +0000<br>
&gt; &gt; &gt; Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh &lt;imp@FreeBSD.org&g=
t;<br>
&gt; &gt; &gt; CommitDate: 2024-02-02 18:11:17 +0000<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0stdlib.h: add __noexcept to prototypes<br=
>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0The noexcept specifier is required on the=
se functions in C++:<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0_Exit(), atexit(), quick_exit(), at_quick=
_exit(), abort().<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0MFC after:=C2=A0 =C2=A0 =C2=A0 2 weeks<br=
>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0Reviewed by: imp<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0Pull Request: <a href=3D"https://github.c=
om/freebsd/freebsd-src/pull/1085" rel=3D"noreferrer" target=3D"_blank">http=
s://github.com/freebsd/freebsd-src/pull/1085</a><br>
&gt; &gt; &gt; ---<br>
&gt; &gt; &gt;=C2=A0 include/stdlib.h | 10 +++++-----<br>
&gt; &gt; &gt;=C2=A0 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;=C2=A0 extern int ___mb_cur_max(void);<br>
&gt; &gt; &gt;=C2=A0 #define=C2=A0 =C2=A0 =C2=A0 MB_CUR_MAX=C2=A0 =C2=A0 =
=C2=A0 ((size_t)___mb_cur_max())<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; -_Noreturn void=C2=A0 =C2=A0 =C2=A0 =C2=A0 abort(void);<br>
&gt; &gt; &gt; +_Noreturn void=C2=A0 =C2=A0 =C2=A0 =C2=A0 abort(void) __noe=
xcept;<br>
&gt; &gt; &gt;=C2=A0 int=C2=A0 =C2=A0abs(int) __pure2;<br>
&gt; &gt; &gt; -int=C2=A0 =C2=A0atexit(void (* _Nonnull)(void));<br>
&gt; &gt; &gt; +int=C2=A0 =C2=A0atexit(void (* _Nonnull)(void)) __noexcept;=
<br>
&gt; &gt; &gt;=C2=A0 double=C2=A0 =C2=A0 =C2=A0 =C2=A0 atof(const char *);<=
br>
&gt; &gt; &gt;=C2=A0 int=C2=A0 =C2=A0atoi(const char *);<br>
&gt; &gt; &gt;=C2=A0 long=C2=A0 atol(const char *);<br>
&gt; &gt; &gt; @@ -154,7 +154,7 @@ unsigned long long<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 strtoull(const char * __restrict,=
 char ** __restrict, int);<br>
&gt; &gt; &gt;=C2=A0 #endif /* __LONG_LONG_SUPPORTED */<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; -_Noreturn void=C2=A0 =C2=A0 =C2=A0 =C2=A0 _Exit(int);<br>
&gt; &gt; &gt; +_Noreturn void=C2=A0 =C2=A0 =C2=A0 =C2=A0 _Exit(int) __noex=
cept;<br>
&gt; &gt; &gt;=C2=A0 #endif /* __ISO_C_VISIBLE &gt;=3D 1999 */<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;=C2=A0 /*<br>
&gt; &gt; &gt; @@ -163,9 +163,9 @@ _Noreturn void=C2=A0 =C2=A0 =C2=A0_Exit(=
int);<br>
&gt; &gt; &gt;=C2=A0 #if __ISO_C_VISIBLE &gt;=3D 2011 || __cplusplus &gt;=
=3D 201103L<br>
&gt; &gt; &gt;=C2=A0 void *=C2=A0 =C2=A0 =C2=A0 =C2=A0aligned_alloc(size_t,=
 size_t) __malloc_like<br>
&gt; &gt; __alloc_align(1)<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0__alloc_size(2);<br>
&gt; &gt; &gt; -int=C2=A0 at_quick_exit(void (*)(void));<br>
&gt; &gt; &gt; +int=C2=A0 at_quick_exit(void (*)(void)) __noexcept;<br>
&gt; &gt; &gt;=C2=A0 _Noreturn void<br>
&gt; &gt; &gt; -=C2=A0 =C2=A0 =C2=A0quick_exit(int);<br>
&gt; &gt; &gt; +=C2=A0 =C2=A0 =C2=A0quick_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 th=
at 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 whic=
h 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></d=
iv><div>OK. I&#39;ll back that one out.</div><div><br></div><div>Warner=C2=
=A0</div></div></div>

--0000000000002ca5bf06106ac272--



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