about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-05-15 17:51:57 +0200
committerFlorian Weimer <fweimer@redhat.com>2020-05-20 20:22:59 +0200
commit1979819d680bb5394a878261519f8a3e4a2886a1 (patch)
treecd871a594a5fd9e7aba416a8938f43c36e8c428f /nptl
parent714da1d4eac32400187255254dd40334b48b80f3 (diff)
downloadglibc-1979819d680bb5394a878261519f8a3e4a2886a1.tar.gz
glibc-1979819d680bb5394a878261519f8a3e4a2886a1.tar.xz
glibc-1979819d680bb5394a878261519f8a3e4a2886a1.zip
nptl: Move pthread_attr_setaffinity_np into libc
This is part of the libpthread removal project:

    <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

The symbol did not previously exist in libc, so a new GLIBC_2.32
symbol is needed, to get correct dependency for binaries which
use the symbol but no longer link against libpthread.

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_attr_setaffinity_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py pthread_attr_setaffinity_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'nptl')
-rw-r--r--nptl/Makefile3
-rw-r--r--nptl/Versions12
-rw-r--r--nptl/pthreadP.h2
-rw-r--r--nptl/pthread_attr_setaffinity.c22
4 files changed, 29 insertions, 10 deletions
diff --git a/nptl/Makefile b/nptl/Makefile
index 5fc45b224b..76f7d60584 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -46,6 +46,7 @@ routines = \
   pthread_attr_getschedpolicy \
   pthread_attr_getscope \
   pthread_attr_init \
+  pthread_attr_setaffinity \
   pthread_attr_setdetachstate \
   pthread_attr_setinheritsched \
   pthread_attr_setschedparam \
@@ -149,7 +150,7 @@ libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
 		      herrno res pt-allocrtsig \
 		      pthread_kill_other_threads \
 		      pthread_getaffinity pthread_setaffinity \
-		      pthread_attr_getaffinity pthread_attr_setaffinity \
+		      pthread_attr_getaffinity \
 		      pthread_mutexattr_getrobust pthread_mutexattr_setrobust \
 		      pthread_mutex_consistent \
 		      cleanup_routine unwind-forcedunwind \
diff --git a/nptl/Versions b/nptl/Versions
index f7140277f5..a799e63606 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -29,11 +29,18 @@ libc {
     pthread_cond_wait; pthread_cond_signal;
     pthread_cond_broadcast; pthread_cond_timedwait;
   }
+  GLIBC_2.3.3 {
+    pthread_attr_setaffinity_np;
+  }
+  GLIBC_2.3.4 {
+    pthread_attr_setaffinity_np;
+  }
   # C11 thread symbols.
   GLIBC_2.28 {
     thrd_current; thrd_equal; thrd_sleep; thrd_yield;
   }
   GLIBC_2.32 {
+    pthread_attr_setaffinity_np;
     pthread_sigmask;
   }
   GLIBC_PRIVATE {
@@ -45,6 +52,7 @@ libc {
     __libc_allocate_rtsig_private;
     # Used by the C11 threads implementation.
     __pthread_cond_destroy; __pthread_cond_init;
+    __pthread_attr_setaffinity_np;
   }
 }
 
@@ -219,13 +227,13 @@ libpthread {
 
     # affinity interfaces without size parameter
     pthread_getaffinity_np; pthread_setaffinity_np;
-    pthread_attr_getaffinity_np; pthread_attr_setaffinity_np;
+    pthread_attr_getaffinity_np;
   }
 
   GLIBC_2.3.4 {
     # New affinity interfaces.
     pthread_getaffinity_np; pthread_setaffinity_np;
-    pthread_attr_getaffinity_np; pthread_attr_setaffinity_np;
+    pthread_attr_getaffinity_np;
 
     pthread_setschedprio;
   }
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index c4e72f57a9..42730a46df 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -433,6 +433,8 @@ extern int __pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
 				    size_t *__restrict __stacksize);
 extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
 				    size_t __stacksize);
+int __pthread_attr_setaffinity_np (pthread_attr_t *, size_t, const cpu_set_t *);
+libc_hidden_proto (__pthread_attr_setaffinity_np)
 extern int __pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
 				  const pthread_rwlockattr_t *__restrict
 				  __attr);
diff --git a/nptl/pthread_attr_setaffinity.c b/nptl/pthread_attr_setaffinity.c
index cbdee85343..a42ffd92f4 100644
--- a/nptl/pthread_attr_setaffinity.c
+++ b/nptl/pthread_attr_setaffinity.c
@@ -25,8 +25,8 @@
 
 
 int
-__pthread_attr_setaffinity_new (pthread_attr_t *attr, size_t cpusetsize,
-				const cpu_set_t *cpuset)
+__pthread_attr_setaffinity_np (pthread_attr_t *attr, size_t cpusetsize,
+			       const cpu_set_t *cpuset)
 {
   struct pthread_attr *iattr;
 
@@ -55,17 +55,25 @@ __pthread_attr_setaffinity_new (pthread_attr_t *attr, size_t cpusetsize,
 
   return 0;
 }
-versioned_symbol (libpthread, __pthread_attr_setaffinity_new,
-		  pthread_attr_setaffinity_np, GLIBC_2_3_4);
+libc_hidden_def (__pthread_attr_setaffinity_np)
+versioned_symbol (libc, __pthread_attr_setaffinity_np,
+		  pthread_attr_setaffinity_np, GLIBC_2_32);
 
 
-#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)
+#if SHLIB_COMPAT (libc, GLIBC_2_3_4, GLIBC_2_32)
+/* Compat symbol with the old libc version.  */
+strong_alias (__pthread_attr_setaffinity_np, __pthread_attr_setaffinity_alias)
+compat_symbol (libc, __pthread_attr_setaffinity_alias,
+	       pthread_attr_setaffinity_np, GLIBC_2_3_4);
+#endif
+
+#if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
 int
 __pthread_attr_setaffinity_old (pthread_attr_t *attr, cpu_set_t *cpuset)
 {
   /* The old interface by default assumed a 1024 processor bitmap.  */
-  return __pthread_attr_setaffinity_new (attr, 128, cpuset);
+  return __pthread_attr_setaffinity_np (attr, 128, cpuset);
 }
-compat_symbol (libpthread, __pthread_attr_setaffinity_old,
+compat_symbol (libc, __pthread_attr_setaffinity_old,
 	       pthread_attr_setaffinity_np, GLIBC_2_3_3);
 #endif