1 | /** |
---|
2 | * @file rtems/posix/spinlock.inl |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * This file contains the static inlin implementation of the inlined |
---|
7 | * routines from the POSIX Spinlock Manager. |
---|
8 | * |
---|
9 | * COPYRIGHT (c) 1989-2006. |
---|
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_POSIX_SPINLOCK_H |
---|
20 | # error "Never use <rtems/posix/spinlock.inl> directly; include <rtems/posix/spinlock.h> instead." |
---|
21 | #endif |
---|
22 | |
---|
23 | #ifndef _RTEMS_POSIX_SPINLOCK_INL |
---|
24 | #define _RTEMS_POSIX_SPINLOCK_INL |
---|
25 | |
---|
26 | #include <pthread.h> |
---|
27 | |
---|
28 | /** |
---|
29 | * @brief _POSIX_Spinlock_Allocate |
---|
30 | * |
---|
31 | * This function allocates a spinlock control block from |
---|
32 | * the inactive chain of free spinlock control blocks. |
---|
33 | */ |
---|
34 | RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Allocate( void ) |
---|
35 | { |
---|
36 | return (POSIX_Spinlock_Control *) |
---|
37 | _Objects_Allocate( &_POSIX_Spinlock_Information ); |
---|
38 | } |
---|
39 | |
---|
40 | /** |
---|
41 | * @brief _POSIX_Spinlock_Free |
---|
42 | * |
---|
43 | * This routine frees a spinlock control block to the |
---|
44 | * inactive chain of free spinlock control blocks. |
---|
45 | */ |
---|
46 | RTEMS_INLINE_ROUTINE void _POSIX_Spinlock_Free ( |
---|
47 | POSIX_Spinlock_Control *the_spinlock |
---|
48 | ) |
---|
49 | { |
---|
50 | _Objects_Free( &_POSIX_Spinlock_Information, &the_spinlock->Object ); |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * @brief _POSIX_Spinlock_Get |
---|
55 | * |
---|
56 | * This function maps spinlock IDs to spinlock control blocks. |
---|
57 | * If ID corresponds to a local spinlock, then it returns |
---|
58 | * the_spinlock control pointer which maps to ID and location |
---|
59 | * is set to OBJECTS_LOCAL. if the spinlock ID is global and |
---|
60 | * resides on a remote node, then location is set to OBJECTS_REMOTE, |
---|
61 | * and the_spinlock is undefined. Otherwise, location is set |
---|
62 | * to OBJECTS_ERROR and the_spinlock is undefined. |
---|
63 | */ |
---|
64 | RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get ( |
---|
65 | pthread_spinlock_t *spinlock, |
---|
66 | Objects_Locations *location |
---|
67 | ) |
---|
68 | { |
---|
69 | return (POSIX_Spinlock_Control *) _Objects_Get( |
---|
70 | &_POSIX_Spinlock_Information, |
---|
71 | *((Objects_Id *)spinlock), |
---|
72 | location |
---|
73 | ); |
---|
74 | } |
---|
75 | |
---|
76 | /** |
---|
77 | * @brief _POSIX_Spinlock_Is_null |
---|
78 | * |
---|
79 | * This function returns TRUE if the_spinlock is NULL and FALSE otherwise. |
---|
80 | */ |
---|
81 | RTEMS_INLINE_ROUTINE bool _POSIX_Spinlock_Is_null ( |
---|
82 | POSIX_Spinlock_Control *the_spinlock |
---|
83 | ) |
---|
84 | { |
---|
85 | return ( the_spinlock == NULL ); |
---|
86 | } |
---|
87 | |
---|
88 | #endif |
---|
89 | /* end of include file */ |
---|