source: rtems/cpukit/posix/src/pthreadequal.c @ 860c34e

4.104.114.95
Last change on this file since 860c34e was 860c34e, checked in by Glenn Humphrey <glenn.humphrey@…>, on 11/30/07 at 20:34:13

2007-11-30 Glenn Humphrey <glenn.humphrey@…>

  • posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/semaphore.h, posix/src/cancel.c, posix/src/conddestroy.c, posix/src/condsignalsupp.c, posix/src/condwaitsupp.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keysetspecific.c, posix/src/mqueueclose.c, posix/src/mqueuegetattr.c, posix/src/mqueuenotify.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mqueuetranslatereturncode.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexinit.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, posix/src/pbarrierdestroy.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlockdestroy.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspindestroy.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/pthreaddetach.c, posix/src/pthreadequal.c, posix/src/pthreadgetschedparam.c, posix/src/pthreadjoin.c, posix/src/pthreadkill.c, posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/sempost.c, posix/src/types.c, rtems/src/msgqtranslatereturncode.c, rtems/src/semobtain.c, rtems/src/timerfireafter.c, score/include/rtems/system.h, score/include/rtems/score/corebarrier.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h: Restructed to move the OBJECTS_LOCAL case to the top of the switch statement and eliminate the fall-through return of POSIX_BOTTOM_REACHED. These changes produced simplier assembly code and allowed for complete test coverage. Also applied some consistency to the functions that translate the core status codes to POSIX status codes.
  • posix/src/mutextranslatereturncode.c, posix/src/semaphoretranslatereturncode.c: New files.
  • posix/src/mutexfromcorestatus.c: Removed.
  • Property mode set to 100644
File size: 1.9 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-2007.
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.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <pthread.h>
21#include <errno.h>
22
23#include <rtems/system.h>
24#include <rtems/posix/pthread.h>
25#include <rtems/score/thread.h>
26
27int pthread_equal(
28  pthread_t  t1,
29  pthread_t  t2
30)
31{
32  /*
33   *  If the system is configured for debug, then we will do everything we
34   *  can to insure that both ids are valid.  Otherwise, we will do the
35   *  cheapest possible thing to determine if they are equal.
36   */
37
38#ifndef RTEMS_DEBUG
39  return _Objects_Are_ids_equal( t1, t2 );
40#else
41  int               status;
42  Objects_Locations location;
43
44  /*
45   *  By default this is not a match.
46   */
47
48  status = 0;
49
50  /*
51   *  Validate the first id and return 0 if it is not valid
52   */
53
54  (void) _POSIX_Threads_Get( t1, &location );
55  switch ( location ) {
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
66        case OBJECTS_LOCAL:
67          status = _Objects_Are_ids_equal( t1, t2 );
68          _Thread_Unnest_dispatch();
69          _Thread_Enable_dispatch();
70          break;
71
72        case OBJECTS_ERROR:
73        case OBJECTS_REMOTE:
74          /* t1 must have been valid so exit the critical section */
75          _Thread_Enable_dispatch();
76          /* return status == 0 */
77          break;
78      }
79      break;
80
81#if defined(RTEMS_MULTIPROCESSING)
82    case OBJECTS_REMOTE:
83#endif
84    case OBJECTS_ERROR:
85      /* return status == 0 */
86      break;
87  }
88
89  return status;
90#endif
91}
Note: See TracBrowser for help on using the repository browser.