source: rtems/cpukit/libcsupport/src/malloc_deferred.c @ 49cdf40

4.115
Last change on this file since 49cdf40 was 49cdf40, checked in by Sebastian Huber <sebastian.huber@…>, on 06/12/13 at 07:25:39

score: Add and use _Thread_Dispatch_is_enabled()

Delete _Thread_Dispatch_in_critical_section() and
_Thread_Is_dispatching_enabled().

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Malloc Deferred Support
5 *  @ingroup libcsupport
6 */
7
8/*
9 *  Process free requests deferred because they were from ISR
10 *  or other critical section.
11 *
12 *  COPYRIGHT (c) 1989-2007.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.com/license/LICENSE.
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#ifdef RTEMS_NEWLIB
25#include <stdlib.h>
26#include <errno.h>
27
28#include "malloc_p.h"
29
30RTEMS_CHAIN_DEFINE_EMPTY(RTEMS_Malloc_GC_list);
31
32bool malloc_is_system_state_OK(void)
33{
34  if ( !_Thread_Dispatch_is_enabled() )
35    return false;
36
37  if ( _ISR_Nest_level > 0 )
38    return false;
39
40  return true;
41}
42
43void malloc_deferred_frees_process(void)
44{
45  rtems_chain_node  *to_be_freed;
46
47  /*
48   *  If some free's have been deferred, then do them now.
49   */
50  while ((to_be_freed = rtems_chain_get(&RTEMS_Malloc_GC_list)) != NULL)
51    free(to_be_freed);
52}
53
54void malloc_deferred_free(
55  void *pointer
56)
57{
58  rtems_chain_append(&RTEMS_Malloc_GC_list, (rtems_chain_node *)pointer);
59}
60#endif
Note: See TracBrowser for help on using the repository browser.