1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Inlined Routines from the POSIX Barrier Manager |
---|
5 | * |
---|
6 | * This file contains the static inlin implementation of the inlined |
---|
7 | * routines from the POSIX Barrier Manager. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2011. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_POSIX_BARRIERIMPL_H |
---|
20 | #define _RTEMS_POSIX_BARRIERIMPL_H |
---|
21 | |
---|
22 | #include <rtems/posix/barrier.h> |
---|
23 | #include <rtems/score/corebarrierimpl.h> |
---|
24 | #include <rtems/score/objectimpl.h> |
---|
25 | |
---|
26 | #include <errno.h> |
---|
27 | #include <pthread.h> |
---|
28 | |
---|
29 | #ifdef __cplusplus |
---|
30 | extern "C" { |
---|
31 | #endif |
---|
32 | |
---|
33 | /** |
---|
34 | * The following defines the information control block used to manage |
---|
35 | * this class of objects. |
---|
36 | */ |
---|
37 | |
---|
38 | extern Objects_Information _POSIX_Barrier_Information; |
---|
39 | |
---|
40 | /** |
---|
41 | * @brief Allocate a barrier control block. |
---|
42 | * |
---|
43 | * This function allocates a barrier control block from |
---|
44 | * the inactive chain of free barrier control blocks. |
---|
45 | */ |
---|
46 | RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Allocate( void ) |
---|
47 | { |
---|
48 | return (POSIX_Barrier_Control *) |
---|
49 | _Objects_Allocate( &_POSIX_Barrier_Information ); |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * @brief Free a barrier control block. |
---|
54 | * |
---|
55 | * This routine frees a barrier control block to the |
---|
56 | * inactive chain of free barrier control blocks. |
---|
57 | */ |
---|
58 | RTEMS_INLINE_ROUTINE void _POSIX_Barrier_Free ( |
---|
59 | POSIX_Barrier_Control *the_barrier |
---|
60 | ) |
---|
61 | { |
---|
62 | _CORE_barrier_Destroy( &the_barrier->Barrier ); |
---|
63 | _Objects_Free( &_POSIX_Barrier_Information, &the_barrier->Object ); |
---|
64 | } |
---|
65 | |
---|
66 | RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Get( |
---|
67 | const pthread_barrier_t *barrier, |
---|
68 | Thread_queue_Context *queue_context |
---|
69 | ) |
---|
70 | { |
---|
71 | _Thread_queue_Context_initialize( queue_context, NULL ); |
---|
72 | return (POSIX_Barrier_Control *) _Objects_Get( |
---|
73 | (Objects_Id) *barrier, |
---|
74 | &queue_context->Lock_context, |
---|
75 | &_POSIX_Barrier_Information |
---|
76 | ); |
---|
77 | } |
---|
78 | |
---|
79 | #ifdef __cplusplus |
---|
80 | } |
---|
81 | #endif |
---|
82 | |
---|
83 | #endif |
---|
84 | /* end of include file */ |
---|