1 | /* |
---|
2 | * 16.1.7 Compare Thread IDs, p1003.1c/Draft 10, p. 153 |
---|
3 | * |
---|
4 | * NOTE: POSIX does not define the behavior when either thread id is invalid. |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989-1998. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * Copyright assigned to U.S. Government, 1994. |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.OARcorp.com/rtems/license.html. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #include <pthread.h> |
---|
18 | #include <errno.h> |
---|
19 | |
---|
20 | #include <rtems/system.h> |
---|
21 | #include <rtems/posix/pthread.h> |
---|
22 | #include <rtems/score/thread.h> |
---|
23 | |
---|
24 | int pthread_equal( |
---|
25 | pthread_t t1, |
---|
26 | pthread_t t2 |
---|
27 | ) |
---|
28 | { |
---|
29 | /* |
---|
30 | * If the system is configured for debug, then we will do everything we |
---|
31 | * can to insure that both ids are valid. Otherwise, we will do the |
---|
32 | * cheapest possible thing to determine if they are equal. |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef RTEMS_DEBUG |
---|
36 | return _Objects_Are_ids_equal( t1, t2 ); |
---|
37 | #else |
---|
38 | int status; |
---|
39 | Objects_Locations location; |
---|
40 | |
---|
41 | /* |
---|
42 | * By default this is not a match. |
---|
43 | */ |
---|
44 | |
---|
45 | status = 0; |
---|
46 | |
---|
47 | /* |
---|
48 | * Validate the first id and return 0 if it is not valid |
---|
49 | */ |
---|
50 | |
---|
51 | (void) _POSIX_Threads_Get( t1, &location ); |
---|
52 | switch ( location ) { |
---|
53 | case OBJECTS_ERROR: |
---|
54 | case OBJECTS_REMOTE: |
---|
55 | break; |
---|
56 | |
---|
57 | case OBJECTS_LOCAL: |
---|
58 | |
---|
59 | /* |
---|
60 | * Validate the second id and return 0 if it is not valid |
---|
61 | */ |
---|
62 | |
---|
63 | (void) _POSIX_Threads_Get( t2, &location ); |
---|
64 | switch ( location ) { |
---|
65 | case OBJECTS_ERROR: |
---|
66 | case OBJECTS_REMOTE: |
---|
67 | break; |
---|
68 | case OBJECTS_LOCAL: |
---|
69 | status = _Objects_Are_ids_equal( t1, t2 ); |
---|
70 | break; |
---|
71 | } |
---|
72 | _Thread_Unnest_dispatch(); |
---|
73 | break; |
---|
74 | } |
---|
75 | |
---|
76 | _Thread_Enable_dispatch(); |
---|
77 | return status; |
---|
78 | #endif |
---|
79 | } |
---|
80 | |
---|