1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Inlined Routines from the POSIX Spinlock Manager |
---|
5 | * |
---|
6 | * This file contains the static inlin implementation of the inlined |
---|
7 | * routines from the POSIX Spinlock Manager. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 1989-2011. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * Copyright (c) 2016 embedded brains GmbH |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.org/license/LICENSE. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _RTEMS_POSIX_SPINLOCKIMPL_H |
---|
22 | #define _RTEMS_POSIX_SPINLOCKIMPL_H |
---|
23 | |
---|
24 | #include <pthread.h> |
---|
25 | |
---|
26 | #include <rtems/score/isrlevel.h> |
---|
27 | |
---|
28 | #if defined(RTEMS_SMP) |
---|
29 | #include <rtems/score/percpu.h> |
---|
30 | #include <rtems/score/smplockticket.h> |
---|
31 | #endif |
---|
32 | |
---|
33 | #ifdef __cplusplus |
---|
34 | extern "C" { |
---|
35 | #endif |
---|
36 | |
---|
37 | #if SIZEOF_PTHREAD_SPINLOCK_T > 4 |
---|
38 | #define POSIX_SPINLOCKS_ARE_SELF_CONTAINED |
---|
39 | #endif |
---|
40 | |
---|
41 | typedef struct { |
---|
42 | #if defined(RTEMS_SMP) |
---|
43 | SMP_ticket_lock_Control Lock; |
---|
44 | #else |
---|
45 | unsigned int reserved[ 2 ]; |
---|
46 | #endif |
---|
47 | ISR_Level interrupt_state; |
---|
48 | } POSIX_Spinlock_Control; |
---|
49 | |
---|
50 | #if !defined(POSIX_SPINLOCKS_ARE_SELF_CONTAINED) |
---|
51 | extern POSIX_Spinlock_Control _POSIX_Spinlock_Global; |
---|
52 | |
---|
53 | extern int _POSIX_Spinlock_Nest_level; |
---|
54 | |
---|
55 | #if defined(RTEMS_SMP) |
---|
56 | extern uint32_t _POSIX_Spinlock_Owner; |
---|
57 | #endif |
---|
58 | #endif |
---|
59 | |
---|
60 | RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get( |
---|
61 | pthread_spinlock_t *lock |
---|
62 | ) |
---|
63 | { |
---|
64 | #if defined(POSIX_SPINLOCKS_ARE_SELF_CONTAINED) |
---|
65 | return (POSIX_Spinlock_Control *) lock; |
---|
66 | #else |
---|
67 | (void) lock; |
---|
68 | return &_POSIX_Spinlock_Global; |
---|
69 | #endif |
---|
70 | } |
---|
71 | |
---|
72 | #ifdef __cplusplus |
---|
73 | } |
---|
74 | #endif |
---|
75 | |
---|
76 | #endif |
---|
77 | /* end of include file */ |
---|