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

Sebastian Huber sebh at rtems.org
Fri Jul 6 05:27:05 UTC 2018


Module:    rtems
Branch:    master
Commit:    77fbbd620f3eb4aa54cccd3491a2feff955f7822
Changeset: http://git.rtems.org/rtems/commit/?id=77fbbd620f3eb4aa54cccd3491a2feff955f7822

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jul  3 11:50:53 2018 +0200

posix: Check for new <pthread.h> prototypes

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 2352416..0361128 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 3e2351e..e6ed1b8 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 544c8fb..3ac90d8 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 86d8ff0..0b4ce28 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 b6854a0..7c5b6f1 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;



More information about the vc mailing list