1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSScoreThread |
---|
7 | * |
---|
8 | * @brief This source file contains the implementation of |
---|
9 | * _Thread_Wait_get_id(). |
---|
10 | */ |
---|
11 | |
---|
12 | /* |
---|
13 | * Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved. |
---|
14 | * |
---|
15 | * embedded brains GmbH |
---|
16 | * Dornierstr. 4 |
---|
17 | * 82178 Puchheim |
---|
18 | * Germany |
---|
19 | * <rtems@embedded-brains.de> |
---|
20 | * |
---|
21 | * Redistribution and use in source and binary forms, with or without |
---|
22 | * modification, are permitted provided that the following conditions |
---|
23 | * are met: |
---|
24 | * 1. Redistributions of source code must retain the above copyright |
---|
25 | * notice, this list of conditions and the following disclaimer. |
---|
26 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
27 | * notice, this list of conditions and the following disclaimer in the |
---|
28 | * documentation and/or other materials provided with the distribution. |
---|
29 | * |
---|
30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
31 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
32 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
34 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
36 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
37 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
38 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
39 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
40 | * POSSIBILITY OF SUCH DAMAGE. |
---|
41 | */ |
---|
42 | |
---|
43 | #ifdef HAVE_CONFIG_H |
---|
44 | #include "config.h" |
---|
45 | #endif |
---|
46 | |
---|
47 | #include <rtems/score/threadimpl.h> |
---|
48 | |
---|
49 | Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread ) |
---|
50 | { |
---|
51 | const Thread_queue_Queue *queue; |
---|
52 | |
---|
53 | #if defined(RTEMS_MULTIPROCESSING) |
---|
54 | if ( _States_Is_waiting_for_rpc_reply( the_thread->current_state ) ) { |
---|
55 | return the_thread->Wait.remote_id; |
---|
56 | } |
---|
57 | #endif |
---|
58 | |
---|
59 | queue = the_thread->Wait.queue; |
---|
60 | |
---|
61 | if ( queue != NULL && queue->name == _Thread_queue_Object_name ) { |
---|
62 | const Thread_queue_Object *queue_object; |
---|
63 | |
---|
64 | queue_object = THREAD_QUEUE_QUEUE_TO_OBJECT( queue ); |
---|
65 | return queue_object->Object.id; |
---|
66 | } |
---|
67 | |
---|
68 | return 0; |
---|
69 | } |
---|