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

4.104.114.9
Last change on this file since 860c34e was 860c34e, checked in by Glenn Humphrey <glenn.humphrey@…>, on Nov 30, 2007 at 8:34:13 PM

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.6 KB
Line 
1/*
2 *  $Id$
3 */
4
5#if HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <pthread.h>
10#include <errno.h>
11
12#include <rtems/system.h>
13#include <rtems/score/object.h>
14#include <rtems/score/states.h>
15#include <rtems/score/watchdog.h>
16#include <rtems/posix/cond.h>
17#include <rtems/posix/time.h>
18#include <rtems/posix/mutex.h>
19
20/*PAGE
21 *
22 *  11.4.2 Initializing and Destroying a Condition Variable,
23 *         P1003.1c/Draft 10, p. 87
24 */
25
26int pthread_cond_destroy(
27  pthread_cond_t           *cond
28)
29{
30  POSIX_Condition_variables_Control *the_cond;
31  Objects_Locations                  location;
32
33  the_cond = _POSIX_Condition_variables_Get( cond, &location );
34  switch ( location ) {
35
36    case OBJECTS_LOCAL:
37
38      if ( _Thread_queue_First( &the_cond->Wait_queue ) ) {
39        _Thread_Enable_dispatch();
40        return EBUSY;
41      }
42
43      _Objects_Close(
44        &_POSIX_Condition_variables_Information,
45        &the_cond->Object
46      );
47
48      _POSIX_Condition_variables_Free( the_cond );
49
50#if defined(RTEMS_MULTIPROCESSING)
51      if ( the_cond->process_shared == PTHREAD_PROCESS_SHARED ) {
52
53        _Objects_MP_Close(
54          &_POSIX_Condition_variables_Information,
55          the_cond->Object.id
56        );
57
58        _POSIX_Condition_variables_MP_Send_process_packet(
59          POSIX_CONDITION_VARIABLES_MP_ANNOUNCE_DELETE,
60          the_cond->Object.id,
61          0,                         /* Not used */
62          0                          /* Not used */
63        );
64      }
65#endif
66      _Thread_Enable_dispatch();
67      return 0;
68
69#if defined(RTEMS_MULTIPROCESSING)
70    case OBJECTS_REMOTE:
71#endif
72    case OBJECTS_ERROR:
73      break;
74  }
75
76  return EINVAL;
77}
Note: See TracBrowser for help on using the repository browser.