source: rtems/cpukit/posix/src/mutexget.c @ 3507c6df

4.104.115
Last change on this file since 3507c6df was 3507c6df, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 5, 2009 at 8:26:01 PM

2009-01-05 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/gxx_wrappers.c, posix/include/mqueue.h, posix/include/rtems/posix/semaphore.h, posix/inline/rtems/posix/barrier.inl, posix/inline/rtems/posix/key.inl, posix/inline/rtems/posix/mqueue.inl, posix/inline/rtems/posix/rwlock.inl, posix/inline/rtems/posix/semaphore.inl, posix/inline/rtems/posix/spinlock.inl, posix/inline/rtems/posix/timer.inl, posix/src/condget.c, posix/src/mqueuenametoid.c, posix/src/mutexget.c, posix/src/semaphorenametoid.c, posix/src/semopen.c, sapi/src/itronapi.c, sapi/src/posixapi.c: Make changes necessary for all tests to run on SPARC with 16-bit Ids. This required ensuring that all POSIX and compilering binding code makes a distinction between the public Id type (e.g. pthread_t, etc.) and the RTEMS Object_Id type. All POSIX Object Get routines should not take the POSIX Id type as the argument. Sixteen bit RTEMS Ids should be placed into the 32-bits reserved by the POSIX API type in a uniform manner now. This removed all assumptions that the external Id types in POSIX and ITRON are the same as the internal Object Id type.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  Convert POSIX Mutex ID to local object pointer
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <errno.h>
19#include <pthread.h>
20
21#include <rtems/system.h>
22#include <rtems/score/coremutex.h>
23#if defined(RTEMS_MULTIPROCESSING)
24#include <rtems/score/mpci.h>
25#endif
26#include <rtems/posix/mutex.h>
27
28
29/*
30 *  _POSIX_Mutex_Get_support
31 *
32 *  NOTE: The support macro makes it possible for both to use exactly
33 *        the same code to check for NULL id pointer and
34 *        PTHREAD_MUTEX_INITIALIZER without adding overhead.
35 */
36
37#define ___POSIX_Mutex_Get_support( _id, _location ) \
38  do { \
39    int _status; \
40    \
41    if ( !_id ) { \
42      *_location = OBJECTS_ERROR; \
43      return (POSIX_Mutex_Control *) 0; \
44    }  \
45    \
46    if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
47      /* \
48       *  Do an "auto-create" here. \
49       */ \
50    \
51      _status = pthread_mutex_init( (pthread_mutex_t *)_id, 0 ); \
52      if ( _status ) { \
53        *_location = OBJECTS_ERROR;  \
54        return (POSIX_Mutex_Control *) 0; \
55      } \
56    } \
57  } while (0)
58 
59POSIX_Mutex_Control *_POSIX_Mutex_Get (
60  pthread_mutex_t   *mutex,
61  Objects_Locations *location
62)
63{
64  ___POSIX_Mutex_Get_support( mutex, location );
65
66  return (POSIX_Mutex_Control *)
67    _Objects_Get( &_POSIX_Mutex_Information, (Objects_Id) *mutex, location );
68}
69
70POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
71  pthread_mutex_t   *mutex,
72  Objects_Locations *location,
73  ISR_Level         *level
74)
75{
76  ___POSIX_Mutex_Get_support( mutex, location );
77
78  return (POSIX_Mutex_Control *) _Objects_Get_isr_disable(
79    &_POSIX_Mutex_Information,
80    (Objects_Id) *mutex,
81    location,
82    level
83  );
84}
Note: See TracBrowser for help on using the repository browser.