OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [pthreadequal.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: pthreadequal.c,v 1.2 2001-09-27 11:59:17 chris Exp $
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
 
23
int 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
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.