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.
This commit is contained in:
Samuel Thibault 2022-01-15 17:35:51 +01:00
parent c1105e34ac
commit 1bd7a06a95
6 changed files with 11 additions and 79 deletions

View File

@ -19,8 +19,6 @@
#ifndef _BITS_TYPES_STRUCT___PTHREAD_ATTR #ifndef _BITS_TYPES_STRUCT___PTHREAD_ATTR
#define _BITS_TYPES_STRUCT___PTHREAD_ATTR 1 #define _BITS_TYPES_STRUCT___PTHREAD_ATTR 1
#include <bits/types/struct_sched_param.h>
#define __need_size_t #define __need_size_t
#include <stddef.h> #include <stddef.h>
@ -28,11 +26,15 @@ enum __pthread_detachstate;
enum __pthread_inheritsched; enum __pthread_inheritsched;
enum __pthread_contentionscope; enum __pthread_contentionscope;
struct __sched_param {
int __sched_priority;
};
/* This structure describes the attributes of a POSIX thread. Note /* This structure describes the attributes of a POSIX thread. Note
that not all of them are supported on all systems. */ that not all of them are supported on all systems. */
struct __pthread_attr struct __pthread_attr
{ {
struct sched_param __schedparam; struct __sched_param __schedparam;
void *__stackaddr; void *__stackaddr;
size_t __stacksize; size_t __stacksize;
size_t __guardsize; size_t __guardsize;

View File

@ -26,7 +26,7 @@ int
__pthread_attr_getschedparam (const pthread_attr_t *attr, __pthread_attr_getschedparam (const pthread_attr_t *attr,
struct sched_param *param) struct sched_param *param)
{ {
memcpy (param, &attr->__schedparam, sizeof *param); param->sched_priority = attr->__schedparam.__sched_priority;
return 0; return 0;
} }

View File

@ -26,9 +26,9 @@ int
__pthread_attr_setschedparam (pthread_attr_t *attr, __pthread_attr_setschedparam (pthread_attr_t *attr,
const struct sched_param *param) 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; return 0;
} }

View File

@ -24,7 +24,7 @@
#include <pt-internal.h> #include <pt-internal.h>
struct __pthread_attr __pthread_default_attr = { struct __pthread_attr __pthread_default_attr = {
__schedparam: { sched_priority: 0 }, __schedparam: { __sched_priority: 0 },
__stacksize: 0, __stacksize: 0,
__stackaddr: NULL, __stackaddr: NULL,
#ifdef PAGESIZE #ifdef PAGESIZE

View File

@ -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 *ileft = (struct __pthread_attr *) left;
struct __pthread_attr *iright = (struct __pthread_attr *) right; struct __pthread_attr *iright = (struct __pthread_attr *) right;
return ileft->__schedparam.sched_priority return ileft->__schedparam.__sched_priority
== iright->__schedparam.sched_priority == iright->__schedparam.__sched_priority
&& ileft->__stackaddr == iright->__stackaddr && ileft->__stackaddr == iright->__stackaddr
&& ileft->__stacksize == iright->__stacksize && ileft->__stacksize == iright->__stacksize
&& ileft->__guardsize == iright->__guardsize && ileft->__guardsize == iright->__guardsize

View File

@ -23,76 +23,6 @@ ifeq ($(subdir),conform)
# For bugs 23081, 23082, 23083, 23084, 23085, 23086. # For bugs 23081, 23082, 23083, 23084, 23085, 23086.
# (type conformance) # (type conformance)
conformtest-xfail-conds += i386-gnu conformtest-xfail-conds += i386-gnu
# For bug 23088
# (sched_* visibility)
test-xfail-POSIX/fcntl.h/conform = yes
test-xfail-POSIX/signal.h/conform = yes
test-xfail-POSIX/semaphore.h/conform = yes
test-xfail-POSIX/regex.h/conform = yes
test-xfail-POSIX/aio.h/conform = yes
test-xfail-POSIX/mqueue.h/conform = yes
test-xfail-POSIX/sys/types.h/conform = yes
test-xfail-UNIX98/fcntl.h/conform = yes
test-xfail-UNIX98/netdb.h/conform = yes
test-xfail-UNIX98/signal.h/conform = yes
test-xfail-UNIX98/semaphore.h/conform = yes
test-xfail-UNIX98/regex.h/conform = yes
test-xfail-UNIX98/aio.h/conform = yes
test-xfail-UNIX98/ftw.h/conform = yes
test-xfail-UNIX98/mqueue.h/conform = yes
test-xfail-UNIX98/netinet/in.h/conform = yes
test-xfail-UNIX98/sys/wait.h/conform = yes
test-xfail-UNIX98/sys/sem.h/conform = yes
test-xfail-UNIX98/sys/uio.h/conform = yes
test-xfail-UNIX98/sys/socket.h/conform = yes
test-xfail-UNIX98/sys/types.h/conform = yes
test-xfail-UNIX98/stdlib.h/conform = yes
test-xfail-UNIX98/arpa/inet.h/conform = yes
test-xfail-POSIX2008/fcntl.h/conform = yes
test-xfail-POSIX2008/netdb.h/conform = yes
test-xfail-POSIX2008/signal.h/conform = yes
test-xfail-POSIX2008/semaphore.h/conform = yes
test-xfail-POSIX2008/regex.h/conform = yes
test-xfail-POSIX2008/aio.h/conform = yes
test-xfail-POSIX2008/mqueue.h/conform = yes
test-xfail-POSIX2008/netinet/in.h/conform = yes
test-xfail-POSIX2008/sys/wait.h/conform = yes
test-xfail-POSIX2008/sys/socket.h/conform = yes
test-xfail-POSIX2008/sys/types.h/conform = yes
test-xfail-POSIX2008/arpa/inet.h/conform = yes
test-xfail-XOPEN2K/fcntl.h/conform = yes
test-xfail-XOPEN2K/netdb.h/conform = yes
test-xfail-XOPEN2K/signal.h/conform = yes
test-xfail-XOPEN2K/semaphore.h/conform = yes
test-xfail-XOPEN2K/regex.h/conform = yes
test-xfail-XOPEN2K/aio.h/conform = yes
test-xfail-XOPEN2K/ftw.h/conform = yes
test-xfail-XOPEN2K/mqueue.h/conform = yes
test-xfail-XOPEN2K/netinet/in.h/conform = yes
test-xfail-XOPEN2K/sys/wait.h/conform = yes
test-xfail-XOPEN2K/sys/sem.h/conform = yes
test-xfail-XOPEN2K/sys/uio.h/conform = yes
test-xfail-XOPEN2K/sys/socket.h/conform = yes
test-xfail-XOPEN2K/sys/types.h/conform = yes
test-xfail-XOPEN2K/stdlib.h/conform = yes
test-xfail-XOPEN2K/arpa/inet.h/conform = yes
test-xfail-XOPEN2K8/fcntl.h/conform = yes
test-xfail-XOPEN2K8/netdb.h/conform = yes
test-xfail-XOPEN2K8/signal.h/conform = yes
test-xfail-XOPEN2K8/semaphore.h/conform = yes
test-xfail-XOPEN2K8/regex.h/conform = yes
test-xfail-XOPEN2K8/aio.h/conform = yes
test-xfail-XOPEN2K8/ftw.h/conform = yes
test-xfail-XOPEN2K8/mqueue.h/conform = yes
test-xfail-XOPEN2K8/netinet/in.h/conform = yes
test-xfail-XOPEN2K8/sys/wait.h/conform = yes
test-xfail-XOPEN2K8/sys/sem.h/conform = yes
test-xfail-XOPEN2K8/sys/uio.h/conform = yes
test-xfail-XOPEN2K8/sys/socket.h/conform = yes
test-xfail-XOPEN2K8/sys/types.h/conform = yes
test-xfail-XOPEN2K8/stdlib.h/conform = yes
test-xfail-XOPEN2K8/arpa/inet.h/conform = yes
endif endif
# For bug 23286 # For bug 23286