[v2] resolv, rt: Change some extern inline functions to static inline __always_inline

Message ID 20260504175054.2401724-1-pcc@google.com (mailing list archive)
State New
Headers
Series [v2] resolv, rt: Change some extern inline functions to static inline __always_inline |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
redhat-pt-bot/TryBot-still_applies warning Patch no longer applies to master

Commit Message

Peter Collingbourne May 4, 2026, 5:50 p.m. UTC
  The following functions:

__aio_create_helper_thread
__aio_start_notify_thread
__gai_create_helper_thread
__gai_start_notify_thread

are declared as extern inline, but no translation unit provides their
real definitions. This can lead to a link failure if the functions are
not inlined. Fix it by declaring them as static inline __always_inline
instead.
---
v2:
- Add __always_inline

 resolv/gai_misc.c                  | 2 +-
 rt/aio_misc.c                      | 2 +-
 sysdeps/mach/hurd/gai_misc.h       | 4 ++--
 sysdeps/nptl/gai_misc.h            | 4 ++--
 sysdeps/unix/sysv/linux/aio_misc.h | 4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)
  

Comments

Florian Weimer May 4, 2026, 6:12 p.m. UTC | #1
* Peter Collingbourne:

> The following functions:
>
> __aio_create_helper_thread
> __aio_start_notify_thread
> __gai_create_helper_thread
> __gai_start_notify_thread
>
> are declared as extern inline, but no translation unit provides their
> real definitions. This can lead to a link failure if the functions are
> not inlined. Fix it by declaring them as static inline __always_inline
> instead.

Well, that still results in build failures if the functions are not
inlined (though under different circumstances).  The first patch was
better in that regard.  Maybe we should go with that one for now, after
all.

Thanks,
Florian
  
Peter Collingbourne May 4, 2026, 6:31 p.m. UTC | #2
On Mon, May 4, 2026 at 11:12 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Peter Collingbourne:
>
> > The following functions:
> >
> > __aio_create_helper_thread
> > __aio_start_notify_thread
> > __gai_create_helper_thread
> > __gai_start_notify_thread
> >
> > are declared as extern inline, but no translation unit provides their
> > real definitions. This can lead to a link failure if the functions are
> > not inlined. Fix it by declaring them as static inline __always_inline
> > instead.
>
> Well, that still results in build failures if the functions are not
> inlined (though under different circumstances).

I suppose, although I've always understood that the always_inline
inlining failure error should only happen if inlining is "impossible",
which is in principle something that's within the control of the
source code.

>  The first patch was
> better in that regard.  Maybe we should go with that one for now, after
> all.

I think that would be my preference. As I noted in my reply there, it
doesn't seem important whether this function is inlined.

Peter
  

Patch

diff --git a/resolv/gai_misc.c b/resolv/gai_misc.c
index 5cf6d7c149..df6e5f7617 100644
--- a/resolv/gai_misc.c
+++ b/resolv/gai_misc.c
@@ -28,7 +28,7 @@ 
 #ifndef gai_create_helper_thread
 # define gai_create_helper_thread __gai_create_helper_thread
 
-extern inline int
+static inline __always_inline int
 __gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
diff --git a/rt/aio_misc.c b/rt/aio_misc.c
index 724486e66f..747b7edc61 100644
--- a/rt/aio_misc.c
+++ b/rt/aio_misc.c
@@ -33,7 +33,7 @@ 
 #ifndef aio_create_helper_thread
 # define aio_create_helper_thread __aio_create_helper_thread
 
-extern inline int
+static inline __always_inline int
 __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), void *arg)
 {
   pthread_attr_t attr;
diff --git a/sysdeps/mach/hurd/gai_misc.h b/sysdeps/mach/hurd/gai_misc.h
index 0237e59bf6..e57ff0e82a 100644
--- a/sysdeps/mach/hurd/gai_misc.h
+++ b/sysdeps/mach/hurd/gai_misc.h
@@ -22,7 +22,7 @@ 
 #define gai_start_notify_thread __gai_start_notify_thread
 #define gai_create_helper_thread __gai_create_helper_thread
 
-extern inline void
+static inline __always_inline void
 __gai_start_notify_thread (void)
 {
   sigset_t ss;
@@ -32,7 +32,7 @@  __gai_start_notify_thread (void)
   assert_perror (sigerr);
 }
 
-extern inline int
+static inline __always_inline int
 __gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
diff --git a/sysdeps/nptl/gai_misc.h b/sysdeps/nptl/gai_misc.h
index 0416e271f4..998921da92 100644
--- a/sysdeps/nptl/gai_misc.h
+++ b/sysdeps/nptl/gai_misc.h
@@ -76,7 +76,7 @@ 
 #define gai_start_notify_thread __gai_start_notify_thread
 #define gai_create_helper_thread __gai_create_helper_thread
 
-extern inline void
+static inline __always_inline void
 __gai_start_notify_thread (void)
 {
   sigset_t ss;
@@ -84,7 +84,7 @@  __gai_start_notify_thread (void)
   (void) __pthread_sigmask (SIG_SETMASK, &ss, NULL);
 }
 
-extern inline int
+static inline __always_inline int
 __gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {
diff --git a/sysdeps/unix/sysv/linux/aio_misc.h b/sysdeps/unix/sysv/linux/aio_misc.h
index 578ff1cf27..d7add3c720 100644
--- a/sysdeps/unix/sysv/linux/aio_misc.h
+++ b/sysdeps/unix/sysv/linux/aio_misc.h
@@ -25,7 +25,7 @@ 
 # define aio_start_notify_thread __aio_start_notify_thread
 # define aio_create_helper_thread __aio_create_helper_thread
 
-extern inline void
+static inline __always_inline void
 __aio_start_notify_thread (void)
 {
   sigset_t ss;
@@ -34,7 +34,7 @@  __aio_start_notify_thread (void)
 			 __NSIG_BYTES);
 }
 
-extern inline int
+static inline __always_inline int
 __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
 			    void *arg)
 {