Branch data Line data Source code
1 : : /* Null garbage collection for the GNU compiler.
2 : : Copyright (C) 1998-2025 Free Software Foundation, Inc.
3 : :
4 : : This file is part of GCC.
5 : :
6 : : GCC is free software; you can redistribute it and/or modify it
7 : : under the terms of the GNU General Public License as published by
8 : : the Free Software Foundation; either version 3, or (at your option)
9 : : any later version.
10 : :
11 : : GCC is distributed in the hope that it will be useful, but WITHOUT
12 : : ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 : : or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 : : License for more details.
15 : :
16 : : You should have received a copy of the GNU General Public License
17 : : along with GCC; see the file COPYING3. If not see
18 : : <http://www.gnu.org/licenses/>. */
19 : :
20 : : /* This version is used by the gen* programs and certain language-specific
21 : : targets (such as java), where we don't really need GC at all.
22 : : This prevents problems with pulling in all the tree stuff. */
23 : :
24 : : #ifdef GENERATOR_FILE
25 : : #include "bconfig.h"
26 : : #else
27 : : #include "config.h"
28 : : #endif
29 : :
30 : : #include "system.h"
31 : : #include "coretypes.h"
32 : : #include "hash-table.h"
33 : :
34 : : /* For a given size of memory requested for allocation, return the
35 : : actual size that is going to be allocated. */
36 : :
37 : : size_t
38 : 0 : ggc_round_alloc_size (size_t requested_size)
39 : : {
40 : 0 : return requested_size;
41 : : }
42 : :
43 : : #ifdef HAVE_ATTRIBUTE_ALIAS
44 : : extern "C" void *
45 : 0 : ggc_internal_alloc_ (size_t size, void (*f)(void *), size_t, size_t
46 : : MEM_STAT_DECL)
47 : : {
48 : 0 : gcc_assert (!f); // ggc-none doesn't support finalizers
49 : 0 : return xmalloc (size);
50 : : }
51 : :
52 : : extern "C" void *
53 : 0 : ggc_internal_cleared_alloc_ (size_t size, void (*f)(void *), size_t, size_t
54 : : MEM_STAT_DECL)
55 : : {
56 : 0 : gcc_assert (!f); // ggc-none doesn't support finalizers
57 : 0 : return xcalloc (size, 1);
58 : : }
59 : :
60 : : extern void *
61 : : ggc_internal_alloc (size_t size, void (*f)(void *), size_t s,
62 : : size_t n MEM_STAT_DECL)
63 : : __attribute__((__alias__ ("ggc_internal_alloc_")));
64 : : extern void *
65 : : ggc_internal_alloc_no_dtor (size_t size, void (*f)(void *), size_t s,
66 : : size_t n MEM_STAT_DECL)
67 : : __attribute__((__alias__ ("ggc_internal_alloc_")));
68 : : extern void *
69 : : ggc_internal_cleared_alloc (size_t size, void (*f)(void *),
70 : : size_t s, size_t n MEM_STAT_DECL)
71 : : __attribute__((__alias__ ("ggc_internal_cleared_alloc_")));
72 : : extern void *
73 : : ggc_internal_cleared_alloc_no_dtor (size_t size, void (*f)(void *),
74 : : size_t s, size_t n MEM_STAT_DECL)
75 : : __attribute__((__alias__ ("ggc_internal_cleared_alloc_")));
76 : : #else
77 : : void *
78 : : ggc_internal_alloc (size_t size, void (*f)(void *), size_t, size_t
79 : : MEM_STAT_DECL)
80 : : {
81 : : gcc_assert (!f); // ggc-none doesn't support finalizers
82 : : return xmalloc (size);
83 : : }
84 : :
85 : : void *
86 : : ggc_internal_cleared_alloc (size_t size, void (*f)(void *), size_t, size_t
87 : : MEM_STAT_DECL)
88 : : {
89 : : gcc_assert (!f); // ggc-none doesn't support finalizers
90 : : return xcalloc (size, 1);
91 : : }
92 : :
93 : : void *
94 : : ggc_internal_alloc_no_dtor (size_t size, void (*f)(void *), size_t s,
95 : : size_t n MEM_STAT_DECL)
96 : : {
97 : : return ggc_internal_alloc (size, f, s, n PASS_MEM_STAT);
98 : : }
99 : :
100 : : void *
101 : : ggc_internal_cleared_alloc_no_dtor (size_t size, void (*f)(void *),
102 : : size_t s, size_t n MEM_STAT_DECL)
103 : : {
104 : : return ggc_internal_cleared_alloc (size, f, s, n PASS_MEM_STAT);
105 : : }
106 : : #endif
107 : :
108 : : void *
109 : 0 : ggc_realloc_stat (void *x, size_t size MEM_STAT_DECL)
110 : : {
111 : 0 : return xrealloc (x, size);
112 : : }
113 : :
114 : : void
115 : 0 : ggc_free (void *p)
116 : : {
117 : 0 : free (p);
118 : 0 : }
119 : :
120 : : void
121 : 0 : ggc_grow (void)
122 : : {
123 : 0 : }
124 : :
125 : : void
126 : 0 : ggc_trim (void)
127 : : {
128 : 0 : }
|