source: rtems/cpukit/score/src/debugisownerofallocator.c @ faf3ff8f

4.115
Last change on this file since faf3ff8f was faf3ff8f, checked in by Sebastian Huber <sebastian.huber@…>, on 03/19/15 at 07:55:01

score: Fix _Debug_Is_owner_of_allocator()

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/*
2 * Copyright (c) 2014-2015 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/score/assert.h>
20#include <rtems/score/apimutex.h>
21#include <rtems/score/thread.h>
22#include <rtems/score/threaddispatch.h>
23
24#if defined( RTEMS_DEBUG )
25  bool _Debug_Is_owner_of_allocator( void )
26  {
27    API_Mutex_Control *mutex = _RTEMS_Allocator_Mutex;
28    bool owner;
29
30    /*
31     * We have to synchronize with the _CORE_mutex_Surrender() operation,
32     * otherwise we may observe an outdated mutex holder.
33     */
34    _Thread_Disable_dispatch();
35
36    if ( mutex != NULL ) {
37      owner = mutex->Mutex.holder == _Thread_Executing;
38    } else {
39      owner = false;
40    }
41
42    _Thread_Enable_dispatch();
43
44    return owner;
45  }
46#endif
Note: See TracBrowser for help on using the repository browser.