Message ID | 20230429131223.2507236-1-bugaevc@gmail.com |
---|---|
State | New |
Headers | show |
Series | [1/3] cdefs.h: Define __COLD | expand |
And of course right after I have sent it, I notice that I forgot the "Not GCC or clang." case. Sergey -- >8 -- From 1b8c6563828399de563846525d0f525001f2d80d Mon Sep 17 00:00:00 2001 From: Sergey Bugaev <bugaevc@gmail.com> Date: Thu, 27 Apr 2023 17:42:11 +0300 Subject: [PATCH] cdefs.h: Define __COLD This expands to __attribute__ ((cold)) when supported. It should be used to mark up functions that are invoked rarely. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> --- misc/sys/cdefs.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 23ec0ebd..9a07e297 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -98,6 +98,12 @@ # endif # endif +# if __GNUC_PREREQ (4, 3) || __glibc_has_attribute (__cold__) +# define __COLD __attribute__ ((__cold__)) +# else +# define __COLD +# endif + #else /* Not GCC or clang. */ # if (defined __cplusplus \ @@ -110,6 +116,7 @@ # define __THROW # define __THROWNL # define __NTH(fct) fct +# define __COLD #endif /* GCC || clang. */
Applied, thanks! Sergey Bugaev, le sam. 29 avril 2023 16:20:53 +0300, a ecrit: > And of course right after I have sent it, I notice that I forgot the > "Not GCC or clang." case. > > Sergey > > -- >8 -- > > From 1b8c6563828399de563846525d0f525001f2d80d Mon Sep 17 00:00:00 2001 > From: Sergey Bugaev <bugaevc@gmail.com> > Date: Thu, 27 Apr 2023 17:42:11 +0300 > Subject: [PATCH] cdefs.h: Define __COLD > > This expands to __attribute__ ((cold)) when supported. It should be > used to mark up functions that are invoked rarely. > > Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> > --- > misc/sys/cdefs.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h > index 23ec0ebd..9a07e297 100644 > --- a/misc/sys/cdefs.h > +++ b/misc/sys/cdefs.h > @@ -98,6 +98,12 @@ > # endif > # endif > > +# if __GNUC_PREREQ (4, 3) || __glibc_has_attribute (__cold__) > +# define __COLD __attribute__ ((__cold__)) > +# else > +# define __COLD > +# endif > + > #else /* Not GCC or clang. */ > > # if (defined __cplusplus \ > @@ -110,6 +116,7 @@ > # define __THROW > # define __THROWNL > # define __NTH(fct) fct > +# define __COLD > > #endif /* GCC || clang. */ > > -- > 2.40.1 >
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 23ec0ebd..8eec4b94 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -98,6 +98,12 @@ # endif # endif +# if __GNUC_PREREQ (4, 3) || __glibc_has_attribute (__cold__) +# define __COLD __attribute__ ((__cold__)) +# else +# define __COLD +# endif + #else /* Not GCC or clang. */ # if (defined __cplusplus \
This expands to __attribute__ ((cold)) when supported. It should be used to mark up functions that are invoked rarely. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> --- I can change __COLD to __attribute_cold__ if that is preferred. misc/sys/cdefs.h | 6 ++++++ 1 file changed, 6 insertions(+)