1 | /** |
---|
2 | * @file rtems/rtems/sem.inl |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * This file contains the static inlin implementation of the inlined |
---|
7 | * routines from the Semaphore Manager. |
---|
8 | * |
---|
9 | * COPYRIGHT (c) 1989-1999. |
---|
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.com/license/LICENSE. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_RTEMS_SEM_INL |
---|
20 | #define _RTEMS_RTEMS_SEM_INL |
---|
21 | |
---|
22 | /*PAGE |
---|
23 | * |
---|
24 | * _Semaphore_Allocate |
---|
25 | * |
---|
26 | * DESCRIPTION: |
---|
27 | * |
---|
28 | * This function allocates a semaphore control block from |
---|
29 | * the inactive chain of free semaphore control blocks. |
---|
30 | */ |
---|
31 | |
---|
32 | RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void ) |
---|
33 | { |
---|
34 | return (Semaphore_Control *) _Objects_Allocate( &_Semaphore_Information ); |
---|
35 | } |
---|
36 | |
---|
37 | /*PAGE |
---|
38 | * |
---|
39 | * _Semaphore_Free |
---|
40 | * |
---|
41 | * DESCRIPTION: |
---|
42 | * |
---|
43 | * This routine frees a semaphore control block to the |
---|
44 | * inactive chain of free semaphore control blocks. |
---|
45 | */ |
---|
46 | |
---|
47 | RTEMS_INLINE_ROUTINE void _Semaphore_Free ( |
---|
48 | Semaphore_Control *the_semaphore |
---|
49 | ) |
---|
50 | { |
---|
51 | _Objects_Free( &_Semaphore_Information, &the_semaphore->Object ); |
---|
52 | } |
---|
53 | |
---|
54 | /*PAGE |
---|
55 | * |
---|
56 | * _Semaphore_Get |
---|
57 | * |
---|
58 | * DESCRIPTION: |
---|
59 | * |
---|
60 | * This function maps semaphore IDs to semaphore control blocks. |
---|
61 | * If ID corresponds to a local semaphore, then it returns |
---|
62 | * the_semaphore control pointer which maps to ID and location |
---|
63 | * is set to OBJECTS_LOCAL. if the semaphore ID is global and |
---|
64 | * resides on a remote node, then location is set to OBJECTS_REMOTE, |
---|
65 | * and the_semaphore is undefined. Otherwise, location is set |
---|
66 | * to OBJECTS_ERROR and the_semaphore is undefined. |
---|
67 | */ |
---|
68 | |
---|
69 | RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get ( |
---|
70 | Objects_Id id, |
---|
71 | Objects_Locations *location |
---|
72 | ) |
---|
73 | { |
---|
74 | return (Semaphore_Control *) |
---|
75 | _Objects_Get( &_Semaphore_Information, id, location ); |
---|
76 | } |
---|
77 | |
---|
78 | RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get_interrupt_disable ( |
---|
79 | Objects_Id id, |
---|
80 | Objects_Locations *location, |
---|
81 | ISR_Level *level |
---|
82 | ) |
---|
83 | { |
---|
84 | return (Semaphore_Control *) |
---|
85 | _Objects_Get_isr_disable( &_Semaphore_Information, id, location, level ); |
---|
86 | } |
---|
87 | |
---|
88 | /*PAGE |
---|
89 | * |
---|
90 | * _Semaphore_Is_null |
---|
91 | * |
---|
92 | * DESCRIPTION: |
---|
93 | * |
---|
94 | * This function returns TRUE if the_semaphore is NULL and FALSE otherwise. |
---|
95 | */ |
---|
96 | |
---|
97 | RTEMS_INLINE_ROUTINE boolean _Semaphore_Is_null ( |
---|
98 | Semaphore_Control *the_semaphore |
---|
99 | ) |
---|
100 | { |
---|
101 | return ( the_semaphore == NULL ); |
---|
102 | } |
---|
103 | |
---|
104 | #endif |
---|
105 | /* end of include file */ |
---|