source: rtems/c/src/exec/posix/src/mutexdestroy.c @ aaf6063

4.104.114.84.95
Last change on this file since aaf6063 was f42b726, checked in by Joel Sherrill <joel.sherrill@…>, on 01/24/01 at 14:17:28

2001-01-24 Ralf Corsepius <corsepiu@…>

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