source: rtems/cpukit/posix/src/mutexget.c @ 419accf

4.115
Last change on this file since 419accf was 419accf, checked in by Sebastian Huber <sebastian.huber@…>, on 10/08/14 at 08:07:01

posix: Use function instead of macros

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Convert POSIX Mutex ID to local object pointer
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/posix/muteximpl.h>
22
23static bool _POSIX_Mutex_Check_id_and_auto_init(
24  pthread_mutex_t   *mutex,
25  Objects_Locations *location
26)
27{
28  if ( mutex == NULL ) {
29    *location = OBJECTS_ERROR;
30
31    return false;
32  }
33
34  if ( *mutex == PTHREAD_MUTEX_INITIALIZER ) {
35    int eno;
36
37    eno = pthread_mutex_init( mutex, NULL );
38
39    if ( eno != 0 ) {
40      *location = OBJECTS_ERROR;
41
42      return false;
43    }
44  }
45
46  return true;
47}
48
49POSIX_Mutex_Control *_POSIX_Mutex_Get (
50  pthread_mutex_t   *mutex,
51  Objects_Locations *location
52)
53{
54  if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, location ) ) {
55    return NULL;
56  }
57
58  return (POSIX_Mutex_Control *)
59    _Objects_Get( &_POSIX_Mutex_Information, (Objects_Id) *mutex, location );
60}
61
62POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
63  pthread_mutex_t   *mutex,
64  Objects_Locations *location,
65  ISR_Level         *level
66)
67{
68  if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, location ) ) {
69    return NULL;
70  }
71
72  return (POSIX_Mutex_Control *) _Objects_Get_isr_disable(
73    &_POSIX_Mutex_Information,
74    (Objects_Id) *mutex,
75    location,
76    level
77  );
78}
Note: See TracBrowser for help on using the repository browser.