source: rtems/cpukit/rtems/src/semflush.c

Last change on this file was 80cf60e, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 15, 2020 at 7:48:32 AM

Canonicalize config.h include

Use the following variant which was already used by most source files:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Semaphore Flush
5 *  @ingroup ClassicSem
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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.org/license/LICENSE.
15 */
16
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/semimpl.h>
22
23rtems_status_code rtems_semaphore_flush( rtems_id id )
24{
25  Semaphore_Control    *the_semaphore;
26  Thread_queue_Context  queue_context;
27  uintptr_t             flags;
28  Semaphore_Variant     variant;
29
30  the_semaphore = _Semaphore_Get( id, &queue_context );
31
32  if ( the_semaphore == NULL ) {
33#if defined(RTEMS_MULTIPROCESSING)
34    if ( _Semaphore_MP_Is_remote( id ) ) {
35      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
36    }
37#endif
38
39    return RTEMS_INVALID_ID;
40  }
41
42  _Thread_queue_Acquire_critical(
43    &the_semaphore->Core_control.Wait_queue,
44    &queue_context
45  );
46  _Thread_queue_Context_set_MP_callout(
47    &queue_context,
48    _Semaphore_MP_Send_object_was_deleted
49  );
50  flags = _Semaphore_Get_flags( the_semaphore );
51  variant = _Semaphore_Get_variant( flags );
52
53  switch ( variant ) {
54#if defined(RTEMS_SMP)
55    case SEMAPHORE_VARIANT_MRSP:
56      _Thread_queue_Release(
57        &the_semaphore->Core_control.Wait_queue,
58        &queue_context
59      );
60      return RTEMS_NOT_DEFINED;
61#endif
62    default:
63      _Assert(
64        variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY
65          || variant == SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING
66          || variant == SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL
67          || variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
68          || variant == SEMAPHORE_VARIANT_COUNTING
69      );
70      _Thread_queue_Flush_critical(
71        &the_semaphore->Core_control.Wait_queue.Queue,
72        _Semaphore_Get_operations( flags ),
73        _Thread_queue_Flush_status_unavailable,
74        &queue_context
75      );
76      break;
77  }
78
79  return RTEMS_SUCCESSFUL;
80}
Note: See TracBrowser for help on using the repository browser.