source: rtems/cpukit/libcsupport/src/malloc_deferred.c @ 02733495

4.115
Last change on this file since 02733495 was 02733495, checked in by Sebastian Huber <sebastian.huber@…>, on 11/24/14 at 14:20:25

libcsupport: malloc_is_system_state_OK()

Move system state check to malloc_is_system_state_OK().

  • Property mode set to 100644
File size: 1.2 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.org/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
30#include <rtems/score/sysstate.h>
31#include <rtems/score/threaddispatch.h>
32
33RTEMS_CHAIN_DEFINE_EMPTY(RTEMS_Malloc_GC_list);
34
35bool malloc_is_system_state_OK(void)
36{
37  return !_System_state_Is_up( _System_state_Get() )
38    || _Thread_Dispatch_is_enabled();
39}
40
41void malloc_deferred_frees_process(void)
42{
43  rtems_chain_node  *to_be_freed;
44
45  /*
46   *  If some free's have been deferred, then do them now.
47   */
48  while ((to_be_freed = rtems_chain_get(&RTEMS_Malloc_GC_list)) != NULL)
49    free(to_be_freed);
50}
51
52void malloc_deferred_free(
53  void *pointer
54)
55{
56  rtems_chain_append(&RTEMS_Malloc_GC_list, (rtems_chain_node *)pointer);
57}
58#endif
Note: See TracBrowser for help on using the repository browser.