source: rtems/c/src/exec/posix/src/pthreadequal.c @ 03598b1

4.104.114.84.95
Last change on this file since 03598b1 was 03598b1, checked in by Joel Sherrill <joel.sherrill@…>, on 01/25/99 at 23:20:52

Split most of POSIX Threads Manager into multiple files.

  • 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-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/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.