summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-10 07:18:09 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-10 07:18:09 +0200
commitbd5be58fa6b4f1108fc69c8ff55cf2d20ddde620 (patch)
tree747a03289a5f31df52a69f04a57a916b069d4a78 /cpukit
parentposix: Constify default thread processor affinity (diff)
downloadrtems-bd5be58fa6b4f1108fc69c8ff55cf2d20ddde620.tar.bz2
posix: Unconditional thread attribute support
Update #2514.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/posix/Makefile.am29
-rw-r--r--cpukit/posix/include/rtems/posix/pthreadattrimpl.h71
-rw-r--r--cpukit/posix/include/rtems/posix/pthreadimpl.h29
-rw-r--r--cpukit/posix/preinstall.am4
-rw-r--r--cpukit/posix/src/pthread.c39
-rw-r--r--cpukit/posix/src/pthreadattrdefault.c60
-rw-r--r--cpukit/posix/src/pthreadattrdestroy.c3
-rw-r--r--cpukit/posix/src/pthreadattrinit.c6
-rw-r--r--cpukit/posix/src/pthreadattrsetguardsize.c4
-rw-r--r--cpukit/posix/src/pthreadattrsetinheritsched.c3
-rw-r--r--cpukit/posix/src/pthreadattrsetschedpolicy.c3
-rw-r--r--cpukit/posix/src/pthreadattrsetscope.c3
-rw-r--r--cpukit/posix/src/pthreadcreate.c1
13 files changed, 155 insertions, 100 deletions
diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am
index 7bd6869c3c..cbdd22bd3a 100644
--- a/cpukit/posix/Makefile.am
+++ b/cpukit/posix/Makefile.am
@@ -24,6 +24,7 @@ include_rtems_posix_HEADERS += include/rtems/posix/config.h
include_rtems_posix_HEADERS += include/rtems/posix/muteximpl.h
include_rtems_posix_HEADERS += include/rtems/posix/posixapi.h
include_rtems_posix_HEADERS += include/rtems/posix/priorityimpl.h
+include_rtems_posix_HEADERS += include/rtems/posix/pthreadattrimpl.h
include_rtems_posix_HEADERS += include/rtems/posix/rwlockimpl.h
include_rtems_posix_HEADERS += include/rtems/posix/semaphore.h
include_rtems_posix_HEADERS += include/rtems/posix/semaphoreimpl.h
@@ -89,14 +90,25 @@ libposix_a_SOURCES += src/mutexattrdestroy.c src/mutexattrgetprioceiling.c \
src/mutexlocksupp.c src/mutexsetprioceiling.c src/mutextimedlock.c \
src/mutextrylock.c src/mutexunlock.c
+## PTHREAD_ATTR_C_FILES
+libposix_a_SOURCES += src/pthreadattrdefault.c src/pthreadattrdestroy.c \
+ src/pthreadattrgetdetachstate.c src/pthreadattrgetguardsize.c \
+ src/pthreadattrgetinheritsched.c src/pthreadattrgetschedparam.c \
+ src/pthreadattrgetschedpolicy.c src/pthreadattrgetscope.c \
+ src/pthreadattrgetstackaddr.c src/pthreadattrgetstack.c \
+ src/pthreadattrgetstacksize.c src/pthreadattrinit.c \
+ src/pthreadattrsetdetachstate.c src/pthreadattrsetguardsize.c \
+ src/pthreadattrsetinheritsched.c src/pthreadattrsetschedparam.c \
+ src/pthreadattrsetschedpolicy.c src/pthreadattrsetscope.c \
+ src/pthreadattrsetstackaddr.c src/pthreadattrsetstack.c \
+ src/pthreadattrsetstacksize.c
+
## PTHREAD_AFFINITY_C_FILES
libposix_a_SOURCES += src/pthreadattrsetaffinitynp.c \
src/pthreadattrgetaffinitynp.c src/pthreadgetaffinitynp.c \
src/pthreadsetaffinitynp.c
if HAS_PTHREADS
-libposix_a_SOURCES += src/pthreadatfork.c
-
## CANCEL_C_FILES
libposix_a_SOURCES += src/cancel.c \
src/cleanuppush.c src/setcancelstate.c \
@@ -128,18 +140,9 @@ libposix_a_SOURCES += src/mqueue.c src/mqueueclose.c \
src/mqueueunlink.c
## PTHREAD_C_FILES
-libposix_a_SOURCES += src/pthreadatfork.c src/pthreadattrdestroy.c \
- src/pthreadattrgetdetachstate.c src/pthreadattrgetinheritsched.c \
- src/pthreadattrgetschedparam.c src/pthreadattrgetschedpolicy.c \
- src/pthreadattrgetscope.c src/pthreadattrgetstackaddr.c \
- src/pthreadattrgetstack.c src/pthreadattrgetstacksize.c \
- src/pthreadattrinit.c src/pthreadattrsetdetachstate.c \
- src/pthreadattrsetguardsize.c src/pthreadattrsetinheritsched.c \
- src/pthreadattrsetschedparam.c src/pthreadattrsetschedpolicy.c \
- src/pthreadattrsetscope.c src/pthreadattrsetstackaddr.c \
- src/pthreadattrsetstack.c src/pthreadattrsetstacksize.c \
+libposix_a_SOURCES += src/pthreadatfork.c \
src/pthreadgetattrnp.c \
- src/pthreadattrgetguardsize.c src/pthread.c \
+ src/pthread.c \
src/pthreadconcurrency.c \
src/pthreadcreate.c src/pthreaddetach.c src/pthreadequal.c \
src/pthreadexit.c src/pthreadgetcpuclockid.c \
diff --git a/cpukit/posix/include/rtems/posix/pthreadattrimpl.h b/cpukit/posix/include/rtems/posix/pthreadattrimpl.h
new file mode 100644
index 0000000000..a52be931a1
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/pthreadattrimpl.h
@@ -0,0 +1,71 @@
+/**
+ * @file
+ *
+ * @brief POSIX Threads Private Support
+ *
+ * This include file contains all the private support information for
+ * POSIX threads.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_PTHREADATTRIMPL_H
+#define _RTEMS_POSIX_PTHREADATTRIMPL_H
+
+#include <errno.h>
+#include <pthread.h>
+
+#include <rtems/score/basedefs.h>
+#include <rtems/score/assert.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup POSIX_PTHREAD
+ */
+/**@{**/
+
+/**
+ * This variable contains the default POSIX Thread attributes.
+ */
+extern const pthread_attr_t _POSIX_Threads_Default_attributes;
+
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes(
+ pthread_attr_t *dst_attr,
+ const pthread_attr_t *src_attr
+)
+{
+ *dst_attr = *src_attr;
+ _Assert(
+ dst_attr->affinitysetsize == sizeof(dst_attr->affinitysetpreallocated)
+ );
+ dst_attr->affinityset = &dst_attr->affinitysetpreallocated;
+}
+
+RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes(
+ pthread_attr_t *attr
+)
+{
+ _POSIX_Threads_Copy_attributes(
+ attr,
+ &_POSIX_Threads_Default_attributes
+ );
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/include/rtems/posix/pthreadimpl.h b/cpukit/posix/include/rtems/posix/pthreadimpl.h
index 6b338f9d5c..055043105b 100644
--- a/cpukit/posix/include/rtems/posix/pthreadimpl.h
+++ b/cpukit/posix/include/rtems/posix/pthreadimpl.h
@@ -48,11 +48,6 @@ extern "C" {
*/
extern Thread_Information _POSIX_Threads_Information;
-/**
- * This variable contains the default POSIX Thread attributes.
- */
-extern const pthread_attr_t _POSIX_Threads_Default_attributes;
-
RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert(
Thread_Control *the_thread,
POSIX_API_Control *api
@@ -113,20 +108,6 @@ RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void)
_Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects );
}
-RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes(
- pthread_attr_t *dst_attr,
- const pthread_attr_t *src_attr
-)
-{
- *dst_attr = *src_attr;
-#if defined(RTEMS_SMP)
- _Assert(
- dst_attr->affinitysetsize == sizeof(dst_attr->affinitysetpreallocated)
- );
- dst_attr->affinityset = &dst_attr->affinitysetpreallocated;
-#endif
-}
-
RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free (
Thread_Control *the_pthread
)
@@ -134,16 +115,6 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free (
_Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object );
}
-RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes(
- pthread_attr_t *attr
-)
-{
- _POSIX_Threads_Copy_attributes(
- attr,
- &_POSIX_Threads_Default_attributes
- );
-}
-
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am
index 157be567c2..d96cbf75a7 100644
--- a/cpukit/posix/preinstall.am
+++ b/cpukit/posix/preinstall.am
@@ -59,6 +59,10 @@ $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h: include/rtems/posix/priorityimpl.
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h
+$(PROJECT_INCLUDE)/rtems/posix/pthreadattrimpl.h: include/rtems/posix/pthreadattrimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/pthreadattrimpl.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/pthreadattrimpl.h
+
$(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h: include/rtems/posix/rwlockimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 171d0366df..17f7fe3a82 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -43,45 +43,6 @@
Thread_Information _POSIX_Threads_Information;
-/*
- * The default pthreads attributes structure.
- *
- * NOTE: Be careful .. if the default attribute set changes,
- * _POSIX_Threads_Initialize_user_threads will need to be examined.
- */
-const pthread_attr_t _POSIX_Threads_Default_attributes = {
- .is_initialized = true, /* is_initialized */
- .stackaddr = NULL, /* stackaddr */
- .stacksize = 0, /* stacksize -- will be adjusted to minimum */
- .contentionscope = PTHREAD_SCOPE_PROCESS, /* contentionscope */
- .inheritsched = PTHREAD_INHERIT_SCHED, /* inheritsched */
- .schedpolicy = SCHED_FIFO, /* schedpolicy */
- .schedparam =
- { /* schedparam */
- 2, /* sched_priority */
- #if defined(_POSIX_SPORADIC_SERVER) || \
- defined(_POSIX_THREAD_SPORADIC_SERVER)
- 0, /* sched_ss_low_priority */
- { 0L, 0 }, /* sched_ss_repl_period */
- { 0L, 0 }, /* sched_ss_init_budget */
- 0 /* sched_ss_max_repl */
- #endif
- },
-
- #if HAVE_DECL_PTHREAD_ATTR_SETGUARDSIZE
- .guardsize = 0, /* guardsize */
- #endif
- #if defined(_POSIX_THREAD_CPUTIME)
- .cputime_clock_allowed = 1, /* cputime_clock_allowed */
- #endif
- .detachstate = PTHREAD_CREATE_JOINABLE, /* detachstate */
- .affinitysetsize =
- sizeof( _POSIX_Threads_Default_attributes.affinitysetpreallocated ),
- .affinityset =
- &_POSIX_Threads_Default_attributes.affinitysetpreallocated,
- .affinitysetpreallocated = { { -1L } }
-};
-
void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog )
{
POSIX_API_Control *api;
diff --git a/cpukit/posix/src/pthreadattrdefault.c b/cpukit/posix/src/pthreadattrdefault.c
new file mode 100644
index 0000000000..efd6671fe6
--- /dev/null
+++ b/cpukit/posix/src/pthreadattrdefault.c
@@ -0,0 +1,60 @@
+/**
+ * @file
+ *
+ * @brief Private Support Information for POSIX Threads
+ * @ingroup POSIX_PTHREADS Private Threads
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/posix/pthreadattrimpl.h>
+
+/*
+ * The default pthreads attributes structure.
+ *
+ * NOTE: Be careful .. if the default attribute set changes,
+ * _POSIX_Threads_Initialize_user_threads will need to be examined.
+ */
+const pthread_attr_t _POSIX_Threads_Default_attributes = {
+ .is_initialized = true, /* is_initialized */
+ .stackaddr = NULL, /* stackaddr */
+ .stacksize = 0, /* stacksize -- will be adjusted to minimum */
+ .contentionscope = PTHREAD_SCOPE_PROCESS, /* contentionscope */
+ .inheritsched = PTHREAD_INHERIT_SCHED, /* inheritsched */
+ .schedpolicy = SCHED_FIFO, /* schedpolicy */
+ .schedparam =
+ { /* schedparam */
+ 2, /* sched_priority */
+ #if defined(_POSIX_SPORADIC_SERVER) || \
+ defined(_POSIX_THREAD_SPORADIC_SERVER)
+ 0, /* sched_ss_low_priority */
+ { 0L, 0 }, /* sched_ss_repl_period */
+ { 0L, 0 }, /* sched_ss_init_budget */
+ 0 /* sched_ss_max_repl */
+ #endif
+ },
+
+ #if HAVE_DECL_PTHREAD_ATTR_SETGUARDSIZE
+ .guardsize = 0, /* guardsize */
+ #endif
+ #if defined(_POSIX_THREAD_CPUTIME)
+ .cputime_clock_allowed = 1, /* cputime_clock_allowed */
+ #endif
+ .detachstate = PTHREAD_CREATE_JOINABLE, /* detachstate */
+ .affinitysetsize =
+ sizeof( _POSIX_Threads_Default_attributes.affinitysetpreallocated ),
+ .affinityset =
+ &_POSIX_Threads_Default_attributes.affinitysetpreallocated,
+ .affinitysetpreallocated = { { -1L } }
+};
diff --git a/cpukit/posix/src/pthreadattrdestroy.c b/cpukit/posix/src/pthreadattrdestroy.c
index d36c1d6dfe..7d30be9ed5 100644
--- a/cpukit/posix/src/pthreadattrdestroy.c
+++ b/cpukit/posix/src/pthreadattrdestroy.c
@@ -20,8 +20,7 @@
#include <pthread.h>
#include <errno.h>
-
-#include <rtems/system.h>
+#include <stdbool.h>
int pthread_attr_destroy(
pthread_attr_t *attr
diff --git a/cpukit/posix/src/pthreadattrinit.c b/cpukit/posix/src/pthreadattrinit.c
index 311e42cc7a..d69cac497b 100644
--- a/cpukit/posix/src/pthreadattrinit.c
+++ b/cpukit/posix/src/pthreadattrinit.c
@@ -18,11 +18,7 @@
#include "config.h"
#endif
-#include <pthread.h>
-#include <errno.h>
-
-#include <rtems/system.h>
-#include <rtems/posix/pthreadimpl.h>
+#include <rtems/posix/pthreadattrimpl.h>
/**
* 16.1.1 Thread Creation Attributes, P1003.1c/Draft 10, p, 140
diff --git a/cpukit/posix/src/pthreadattrsetguardsize.c b/cpukit/posix/src/pthreadattrsetguardsize.c
index 829a1b30c6..766066ce24 100644
--- a/cpukit/posix/src/pthreadattrsetguardsize.c
+++ b/cpukit/posix/src/pthreadattrsetguardsize.c
@@ -19,12 +19,10 @@
#endif
#if HAVE_DECL_PTHREAD_ATTR_SETGUARDSIZE
+
#include <pthread.h>
#include <errno.h>
-#include <rtems/system.h>
-#include <rtems/posix/pthreadimpl.h>
-
int pthread_attr_setguardsize(
pthread_attr_t *attr,
size_t guardsize
diff --git a/cpukit/posix/src/pthreadattrsetinheritsched.c b/cpukit/posix/src/pthreadattrsetinheritsched.c
index 8ce3a5db0e..c3b8a53053 100644
--- a/cpukit/posix/src/pthreadattrsetinheritsched.c
+++ b/cpukit/posix/src/pthreadattrsetinheritsched.c
@@ -23,9 +23,6 @@
#include <pthread.h>
#include <errno.h>
-#include <rtems/system.h>
-#include <rtems/posix/pthreadimpl.h>
-
int pthread_attr_setinheritsched(
pthread_attr_t *attr,
int inheritsched
diff --git a/cpukit/posix/src/pthreadattrsetschedpolicy.c b/cpukit/posix/src/pthreadattrsetschedpolicy.c
index 9adec1b8f9..235e7a8ad1 100644
--- a/cpukit/posix/src/pthreadattrsetschedpolicy.c
+++ b/cpukit/posix/src/pthreadattrsetschedpolicy.c
@@ -23,9 +23,6 @@
#include <pthread.h>
#include <errno.h>
-#include <rtems/system.h>
-#include <rtems/posix/pthreadimpl.h>
-
int pthread_attr_setschedpolicy(
pthread_attr_t *attr,
int policy
diff --git a/cpukit/posix/src/pthreadattrsetscope.c b/cpukit/posix/src/pthreadattrsetscope.c
index 78b0fde984..1d8bec0467 100644
--- a/cpukit/posix/src/pthreadattrsetscope.c
+++ b/cpukit/posix/src/pthreadattrsetscope.c
@@ -23,9 +23,6 @@
#include <pthread.h>
#include <errno.h>
-#include <rtems/system.h>
-#include <rtems/posix/pthreadimpl.h>
-
int pthread_attr_setscope(
pthread_attr_t *attr,
int contentionscope
diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c
index ebb96bf8a4..41e2b67122 100644
--- a/cpukit/posix/src/pthreadcreate.c
+++ b/cpukit/posix/src/pthreadcreate.c
@@ -27,6 +27,7 @@
#include <rtems/posix/priorityimpl.h>
#include <rtems/posix/pthreadimpl.h>
+#include <rtems/posix/pthreadattrimpl.h>
#include <rtems/score/assert.h>
#include <rtems/score/cpusetimpl.h>
#include <rtems/score/threadimpl.h>