source: rtems/cpukit/posix/src/mutexdestroy.c @ a045c9d

4.104.114.95
Last change on this file since a045c9d 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.8 KB
Line 
1/*
2 *  $Id$
3 */
4
5#if HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <errno.h>
10#include <pthread.h>
11
12#include <rtems/system.h>
13#include <rtems/score/coremutex.h>
14#include <rtems/score/watchdog.h>
15#if defined(RTEMS_MULTIPROCESSING)
16#include <rtems/score/mpci.h>
17#endif
18#include <rtems/posix/mutex.h>
19#include <rtems/posix/priority.h>
20#include <rtems/posix/time.h>
21
22/*PAGE
23 *
24 *  11.3.2 Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87
25 */
26
27int pthread_mutex_destroy(
28  pthread_mutex_t           *mutex
29)
30{
31  register POSIX_Mutex_Control *the_mutex;
32  Objects_Locations             location;
33
34  the_mutex = _POSIX_Mutex_Get( mutex, &location );
35  switch ( location ) {
36
37    case OBJECTS_LOCAL:
38       /*
39        * XXX: There is an error for the mutex being locked
40        *  or being in use by a condition variable.
41        */
42
43      if ( _CORE_mutex_Is_locked( &the_mutex->Mutex ) ) {
44        _Thread_Enable_dispatch();
45        return EBUSY;
46      }
47
48      _Objects_Close( &_POSIX_Mutex_Information, &the_mutex->Object );
49
50      _CORE_mutex_Flush(
51        &the_mutex->Mutex,
52#if defined(RTEMS_MULTIPROCESSING)
53        _POSIX_Mutex_MP_Send_object_was_deleted,
54#else
55        NULL,
56#endif
57        EINVAL
58      );
59
60      _POSIX_Mutex_Free( the_mutex );
61
62#if defined(RTEMS_MULTIPROCESSING)
63      if ( the_mutex->process_shared == PTHREAD_PROCESS_SHARED ) {
64
65        _Objects_MP_Close( &_POSIX_Mutex_Information, the_mutex->Object.id );
66
67        _POSIX_Mutex_MP_Send_process_packet(
68          POSIX_MUTEX_MP_ANNOUNCE_DELETE,
69          the_mutex->Object.id,
70          0,                         /* Not used */
71          0                          /* Not used */
72        );
73      }
74#endif
75      _Thread_Enable_dispatch();
76      return 0;
77
78#if defined(RTEMS_MULTIPROCESSING)
79    case OBJECTS_REMOTE:
80#endif
81    case OBJECTS_ERROR:
82      break;
83  }
84
85  return EINVAL;
86}
Note: See TracBrowser for help on using the repository browser.