source: rtems/c/src/exec/posix/src/pthreadequal.c @ 64f55e7

4.104.114.84.95
Last change on this file since 64f55e7 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 1.7 KB
Line 
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-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <pthread.h>
17#include <errno.h>
18
19#include <rtems/system.h>
20#include <rtems/posix/pthread.h>
21#include <rtems/score/thread.h>
22
23int pthread_equal(
24  pthread_t  t1,
25  pthread_t  t2
26)
27{
28  /*
29   *  If the system is configured for debug, then we will do everything we
30   *  can to insure that both ids are valid.  Otherwise, we will do the
31   *  cheapest possible thing to determine if they are equal.
32   */
33
34#ifndef RTEMS_DEBUG
35  return _Objects_Are_ids_equal( t1, t2 );
36#else
37  int               status;
38  Objects_Locations location;
39
40  /*
41   *  By default this is not a match.
42   */
43
44  status = 0;
45
46  /*
47   *  Validate the first id and return 0 if it is not valid
48   */
49
50  (void) _POSIX_Threads_Get( t1, &location );
51  switch ( location ) {
52    case OBJECTS_ERROR:
53    case OBJECTS_REMOTE:
54      break;
55
56    case OBJECTS_LOCAL:
57
58      /*
59       *  Validate the second id and return 0 if it is not valid
60       */
61
62      (void) _POSIX_Threads_Get( t2, &location );
63      switch ( location ) {
64        case OBJECTS_ERROR:
65        case OBJECTS_REMOTE:
66          break;
67        case OBJECTS_LOCAL:
68          status = _Objects_Are_ids_equal( t1, t2 );
69          break;
70      }
71      _Thread_Unnest_dispatch();
72      break;
73  }
74
75  _Thread_Enable_dispatch();
76  return status;
77#endif
78}
79
Note: See TracBrowser for help on using the repository browser.