[PATCH] posix: Check for new <pthread.h> prototypes

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Jul 3 09:53:02 UTC 2018


Update #3342.
Update #3343.
---
 cpukit/configure.ac                      | 23 +++++++++++++++++++++++
 cpukit/include/rtems/posix/pthreadimpl.h |  2 +-
 cpukit/posix/src/mutexgetprioceiling.c   | 10 +++++++---
 cpukit/posix/src/psxtransschedparam.c    |  2 +-
 cpukit/posix/src/pthreadsetschedparam.c  | 12 ++++++++----
 5 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/cpukit/configure.ac b/cpukit/configure.ac
index 235241643e..0361128e1d 100644
--- a/cpukit/configure.ac
+++ b/cpukit/configure.ac
@@ -115,6 +115,29 @@ RTEMS_CHECK_FUNC([pthread_getattr_np],[
   #define _GNU_SOURCE
   #include <pthread.h>])
 
+AC_LANG_PUSH(C)
+AC_MSG_CHECKING([for pthread_mutex_getprioceiling(const pthread_mutex_t *, ...)])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#include <pthread.h>
+int pthread_mutex_getprioceiling(const pthread_mutex_t *__restrict, int *);
+])],[
+AC_MSG_RESULT([yes])
+AC_DEFINE(HAVE_PTHREAD_MUTEX_GETCEILING_CONST, [], [pthread_mutex_getprioceiling(const pthread_mutex_t *, ...)])
+],[
+AC_MSG_RESULT([no])
+])
+AC_MSG_CHECKING([for pthread_setschedparam(..., const struct sched_param *)])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#include <pthread.h>
+int pthread_setschedparam(pthread_t, int, const struct sched_param *);
+])],[
+AC_MSG_RESULT([yes])
+AC_DEFINE(HAVE_PTHREAD_SETSCHEDPARAM_CONST, [], [pthread_setschedparam(..., const struct sched_param *)])
+],[
+AC_MSG_RESULT([no])
+])
+AC_LANG_POP(C)
+
 # Mandated by POSIX, not declared in some versions of newlib.
 AC_CHECK_DECLS([getrusage],,,[#include sys/resource.h])
 
diff --git a/cpukit/include/rtems/posix/pthreadimpl.h b/cpukit/include/rtems/posix/pthreadimpl.h
index 3e2351e57e..e6ed1b8990 100644
--- a/cpukit/include/rtems/posix/pthreadimpl.h
+++ b/cpukit/include/rtems/posix/pthreadimpl.h
@@ -97,7 +97,7 @@ int _POSIX_Thread_Translate_to_sched_policy(
  */
 int _POSIX_Thread_Translate_sched_param(
   int                                  policy,
-  struct sched_param                  *param,
+  const struct sched_param            *param,
   Thread_CPU_budget_algorithms        *budget_algorithm,
   Thread_CPU_budget_algorithm_callout *budget_callout
 );
diff --git a/cpukit/posix/src/mutexgetprioceiling.c b/cpukit/posix/src/mutexgetprioceiling.c
index 544c8fbf33..3ac90d888e 100644
--- a/cpukit/posix/src/mutexgetprioceiling.c
+++ b/cpukit/posix/src/mutexgetprioceiling.c
@@ -26,8 +26,12 @@
  */
 
 int pthread_mutex_getprioceiling(
-  pthread_mutex_t   *mutex,
-  int               *prioceiling
+#ifdef HAVE_PTHREAD_MUTEX_GETCEILING_CONST
+  const pthread_mutex_t *mutex,
+#else
+  pthread_mutex_t       *mutex,
+#endif
+  int                   *prioceiling
 )
 {
   POSIX_Mutex_Control  *the_mutex;
@@ -38,7 +42,7 @@ int pthread_mutex_getprioceiling(
     return EINVAL;
   }
 
-  the_mutex = _POSIX_Mutex_Get( mutex );
+  the_mutex = _POSIX_Mutex_Get( RTEMS_DECONST( pthread_mutex_t *, mutex ) );
   POSIX_MUTEX_VALIDATE_OBJECT( the_mutex, flags );
 
   _POSIX_Mutex_Acquire( the_mutex, &queue_context );
diff --git a/cpukit/posix/src/psxtransschedparam.c b/cpukit/posix/src/psxtransschedparam.c
index 86d8ff0894..0b4ce2823e 100644
--- a/cpukit/posix/src/psxtransschedparam.c
+++ b/cpukit/posix/src/psxtransschedparam.c
@@ -42,7 +42,7 @@ int _POSIX_Thread_Translate_to_sched_policy(
 
 int _POSIX_Thread_Translate_sched_param(
   int                                  policy,
-  struct sched_param                  *param,
+  const struct sched_param            *param,
   Thread_CPU_budget_algorithms        *budget_algorithm,
   Thread_CPU_budget_algorithm_callout *budget_callout
 )
diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c
index b6854a080c..7c5b6f109d 100644
--- a/cpukit/posix/src/pthreadsetschedparam.c
+++ b/cpukit/posix/src/pthreadsetschedparam.c
@@ -33,7 +33,7 @@
 static int _POSIX_Set_sched_param(
   Thread_Control                       *the_thread,
   int                                   policy,
-  struct sched_param                   *param,
+  const struct sched_param             *param,
   Thread_CPU_budget_algorithms          budget_algorithm,
   Thread_CPU_budget_algorithm_callout   budget_callout,
   Thread_queue_Context                 *queue_context
@@ -113,9 +113,13 @@ static int _POSIX_Set_sched_param(
 }
 
 int pthread_setschedparam(
-  pthread_t           thread,
-  int                 policy,
-  struct sched_param *param
+  pthread_t                 thread,
+  int                       policy,
+#ifdef HAVE_PTHREAD_SETSCHEDPARAM_CONST
+  const struct sched_param *param
+#else
+  struct sched_param       *param
+#endif
 )
 {
   Thread_CPU_budget_algorithms         budget_algorithm;
-- 
2.13.7



More information about the devel mailing list