summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJennifer Averett <jennifer.averett@oarcorp.com>2014-02-06 12:56:34 -0600
committerJennifer Averett <jennifer.averett@oarcorp.com>2014-03-07 09:11:28 -0600
commitbaa426a074924b2e1766e2a07a6cce40fdc313cb (patch)
treee5778a2bce71e8c478a10cbd61cfbbcab3680089 /cpukit/posix
parentposix: Add POSIX thread affinity attribute support. (diff)
downloadrtems-baa426a074924b2e1766e2a07a6cce40fdc313cb.tar.bz2
posix: Add support method to compare two pthread attribute structures.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/Makefile.am3
-rw-r--r--cpukit/posix/src/pthreadattrcompare.c92
2 files changed, 95 insertions, 0 deletions
diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am
index ea6d3d983d..45562daedc 100644
--- a/cpukit/posix/Makefile.am
+++ b/cpukit/posix/Makefile.am
@@ -139,6 +139,9 @@ libposix_a_SOURCES += src/pthreadatfork.c src/pthreadattrdestroy.c \
src/pthreadsetschedparam.c src/pthreadsigmask.c \
src/psxpriorityisvalid.c src/psxtransschedparam.c
+## RTEMS specific support methods
+libposix_a_SOURCES += src/pthreadattrcompare.c
+
## PSIGNAL_C_FILES
libposix_a_SOURCES += src/psignal.c src/alarm.c src/kill.c src/killinfo.c \
src/kill_r.c src/pause.c src/psignalclearprocesssignals.c \
diff --git a/cpukit/posix/src/pthreadattrcompare.c b/cpukit/posix/src/pthreadattrcompare.c
new file mode 100644
index 0000000000..8ec6fec33f
--- /dev/null
+++ b/cpukit/posix/src/pthreadattrcompare.c
@@ -0,0 +1,92 @@
+/**
+ * @file
+ *
+ * @brief RTEMS specific pthread attribute comparison
+ * @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.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <stdio.h>
+
+#include <errno.h>
+#include <pthread.h>
+#include <string.h>
+#include <rtems/posix/pthreadimpl.h>
+
+int rtems_pthread_attribute_compare(
+ const pthread_attr_t *attr1,
+ const pthread_attr_t *attr2
+)
+{
+ if ( attr1->is_initialized != attr2->is_initialized )
+ return 1;
+
+ if ( attr1->stackaddr != attr2->stackaddr )
+ return 1;
+
+ if ( attr1->stacksize != attr2->stacksize )
+ return 1;
+
+ if ( attr1->contentionscope != attr2->contentionscope )
+ return 1;
+
+ if ( attr1->inheritsched != attr2->inheritsched )
+ return 1;
+
+ if ( attr1->schedpolicy != attr2->schedpolicy )
+ return 1;
+
+ if (memcmp(
+ &attr1->schedparam,
+ &attr2->schedparam,
+ sizeof(struct sched_param)
+ ))
+ return 1;
+
+ #if HAVE_DECL_PTHREAD_ATTR_SETGUARDSIZE
+ if ( attr1->guardsize != attr2->guardsize )
+ return 1;
+ #endif
+
+ #if defined(_POSIX_THREAD_CPUTIME)
+ if ( attr1->cputime_clock_allowed != attr2->cputime_clock_allowed )
+ return 1;
+ #endif
+
+ if ( attr1->detachstate != attr2->detachstate )
+ return 1;
+
+ #if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
+ if ( attr1->affinitysetsize != attr2->affinitysetsize )
+ return 1;
+
+ if (!CPU_EQUAL_S(
+ attr1->affinitysetsize,
+ attr1->affinityset,
+ attr2->affinityset
+ ))
+ return 1;
+
+ if (!CPU_EQUAL_S(
+ attr1->affinitysetsize,
+ &attr1->affinitysetpreallocated,
+ &attr2->affinitysetpreallocated
+ ))
+ return 1;
+ #endif
+
+ return 0;
+}
+
+