1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS specific pthread attribute comparison |
---|
5 | * @ingroup POSIX_PTHREADS Private Threads |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2014. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | #include <stdio.h> |
---|
21 | |
---|
22 | #include <errno.h> |
---|
23 | #include <pthread.h> |
---|
24 | #include <string.h> |
---|
25 | #include <rtems/posix/pthreadimpl.h> |
---|
26 | |
---|
27 | int rtems_pthread_attribute_compare( |
---|
28 | const pthread_attr_t *attr1, |
---|
29 | const pthread_attr_t *attr2 |
---|
30 | ) |
---|
31 | { |
---|
32 | if ( attr1->is_initialized != attr2->is_initialized ) |
---|
33 | return 1; |
---|
34 | |
---|
35 | if ( attr1->stackaddr != attr2->stackaddr ) |
---|
36 | return 1; |
---|
37 | |
---|
38 | if ( attr1->stacksize != attr2->stacksize ) |
---|
39 | return 1; |
---|
40 | |
---|
41 | if ( attr1->contentionscope != attr2->contentionscope ) |
---|
42 | return 1; |
---|
43 | |
---|
44 | if ( attr1->inheritsched != attr2->inheritsched ) |
---|
45 | return 1; |
---|
46 | |
---|
47 | if ( attr1->schedpolicy != attr2->schedpolicy ) |
---|
48 | return 1; |
---|
49 | |
---|
50 | if (memcmp( |
---|
51 | &attr1->schedparam, |
---|
52 | &attr2->schedparam, |
---|
53 | sizeof(struct sched_param) |
---|
54 | )) |
---|
55 | return 1; |
---|
56 | |
---|
57 | #if HAVE_DECL_PTHREAD_ATTR_SETGUARDSIZE |
---|
58 | if ( attr1->guardsize != attr2->guardsize ) |
---|
59 | return 1; |
---|
60 | #endif |
---|
61 | |
---|
62 | #if defined(_POSIX_THREAD_CPUTIME) |
---|
63 | if ( attr1->cputime_clock_allowed != attr2->cputime_clock_allowed ) |
---|
64 | return 1; |
---|
65 | #endif |
---|
66 | |
---|
67 | if ( attr1->detachstate != attr2->detachstate ) |
---|
68 | return 1; |
---|
69 | |
---|
70 | #if defined(__RTEMS_HAVE_SYS_CPUSET_H__) |
---|
71 | if ( attr1->affinitysetsize != attr2->affinitysetsize ) |
---|
72 | return 1; |
---|
73 | |
---|
74 | if (!CPU_EQUAL_S( |
---|
75 | attr1->affinitysetsize, |
---|
76 | attr1->affinityset, |
---|
77 | attr2->affinityset |
---|
78 | )) |
---|
79 | return 1; |
---|
80 | |
---|
81 | if (!CPU_EQUAL_S( |
---|
82 | attr1->affinitysetsize, |
---|
83 | &attr1->affinitysetpreallocated, |
---|
84 | &attr2->affinitysetpreallocated |
---|
85 | )) |
---|
86 | return 1; |
---|
87 | #endif |
---|
88 | |
---|
89 | return 0; |
---|
90 | } |
---|
91 | |
---|
92 | |
---|