about summary refs log tree commit diff
path: root/sysdeps/htl
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-01-15 17:35:51 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-01-15 21:31:08 +0100
commit1bd7a06a958e93dbd10d99d30ee9ad82fca13f48 (patch)
tree07a368ec2acde2179d376eebd0a871f737a69144 /sysdeps/htl
parentc1105e34aced53b26f02176b973079eb30fc54b1 (diff)
downloadglibc-1bd7a06a958e93dbd10d99d30ee9ad82fca13f48.tar.gz
glibc-1bd7a06a958e93dbd10d99d30ee9ad82fca13f48.tar.xz
glibc-1bd7a06a958e93dbd10d99d30ee9ad82fca13f48.zip
htl: Hide __pthread_attr's __schedparam type [BZ #23088]
The content of the structure is only used internally, so we can make
__pthread_attr_getschedparam and __pthread_attr_setschedparam convert
between the public sched_param type and an internal __sched_param.

This allows to avoid to spuriously expose the sched_param type.

This fixes BZ #23088.
Diffstat (limited to 'sysdeps/htl')
-rw-r--r--sysdeps/htl/bits/types/struct___pthread_attr.h8
-rw-r--r--sysdeps/htl/pt-attr-getschedparam.c2
-rw-r--r--sysdeps/htl/pt-attr-setschedparam.c4
-rw-r--r--sysdeps/htl/pt-attr.c2
-rw-r--r--sysdeps/htl/timer_routines.h4
5 files changed, 11 insertions, 9 deletions
diff --git a/sysdeps/htl/bits/types/struct___pthread_attr.h b/sysdeps/htl/bits/types/struct___pthread_attr.h
index ec4d6485c8..9ec7ccc5b6 100644
--- a/sysdeps/htl/bits/types/struct___pthread_attr.h
+++ b/sysdeps/htl/bits/types/struct___pthread_attr.h
@@ -19,8 +19,6 @@
 #ifndef _BITS_TYPES_STRUCT___PTHREAD_ATTR
 #define _BITS_TYPES_STRUCT___PTHREAD_ATTR	1
 
-#include <bits/types/struct_sched_param.h>
-
 #define __need_size_t
 #include <stddef.h>
 
@@ -28,11 +26,15 @@ enum __pthread_detachstate;
 enum __pthread_inheritsched;
 enum __pthread_contentionscope;
 
+struct __sched_param {
+  int __sched_priority;
+};
+
 /* This structure describes the attributes of a POSIX thread.  Note
    that not all of them are supported on all systems.  */
 struct __pthread_attr
 {
-  struct sched_param __schedparam;
+  struct __sched_param __schedparam;
   void *__stackaddr;
   size_t __stacksize;
   size_t __guardsize;
diff --git a/sysdeps/htl/pt-attr-getschedparam.c b/sysdeps/htl/pt-attr-getschedparam.c
index 714998abbc..59e7c6d538 100644
--- a/sysdeps/htl/pt-attr-getschedparam.c
+++ b/sysdeps/htl/pt-attr-getschedparam.c
@@ -26,7 +26,7 @@ int
 __pthread_attr_getschedparam (const pthread_attr_t *attr,
 			      struct sched_param *param)
 {
-  memcpy (param, &attr->__schedparam, sizeof *param);
+  param->sched_priority = attr->__schedparam.__sched_priority;
   return 0;
 }
 
diff --git a/sysdeps/htl/pt-attr-setschedparam.c b/sysdeps/htl/pt-attr-setschedparam.c
index 52d39126f4..d9b4731fed 100644
--- a/sysdeps/htl/pt-attr-setschedparam.c
+++ b/sysdeps/htl/pt-attr-setschedparam.c
@@ -26,9 +26,9 @@ int
 __pthread_attr_setschedparam (pthread_attr_t *attr,
 			      const struct sched_param *param)
 {
-  if (memcmp (param, &__pthread_default_attr.__schedparam, sizeof *param) == 0)
+  if (param->sched_priority == __pthread_default_attr.__schedparam.__sched_priority)
     {
-      memcpy (&attr->__schedparam, param, sizeof *param);
+      attr->__schedparam.__sched_priority = param->sched_priority;
       return 0;
     }
 
diff --git a/sysdeps/htl/pt-attr.c b/sysdeps/htl/pt-attr.c
index 385347ccb2..c460be2156 100644
--- a/sysdeps/htl/pt-attr.c
+++ b/sysdeps/htl/pt-attr.c
@@ -24,7 +24,7 @@
 #include <pt-internal.h>
 
 struct __pthread_attr __pthread_default_attr = {
-  __schedparam: { sched_priority: 0 },
+  __schedparam: { __sched_priority: 0 },
   __stacksize: 0,
   __stackaddr: NULL,
 #ifdef PAGESIZE
diff --git a/sysdeps/htl/timer_routines.h b/sysdeps/htl/timer_routines.h
index 8d0bec84a9..fa69d9e963 100644
--- a/sysdeps/htl/timer_routines.h
+++ b/sysdeps/htl/timer_routines.h
@@ -32,8 +32,8 @@ thread_attr_compare (const pthread_attr_t * left, const pthread_attr_t * right)
   struct __pthread_attr *ileft = (struct __pthread_attr *) left;
   struct __pthread_attr *iright = (struct __pthread_attr *) right;
 
-  return ileft->__schedparam.sched_priority
-	   == iright->__schedparam.sched_priority
+  return ileft->__schedparam.__sched_priority
+	   == iright->__schedparam.__sched_priority
 	 && ileft->__stackaddr == iright->__stackaddr
 	 && ileft->__stacksize == iright->__stacksize
 	 && ileft->__guardsize == iright->__guardsize