Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libcc1 / marshall-cp.hh
blob40c9791152fcfc35ec654d0215a3028e65363ba1
1 /* Marshalling and unmarshalling of C++-specific types.
2 Copyright (C) 2014-2024 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
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/>. */
20 #ifndef CC1_PLUGIN_MARSHALL_CXX_HH
21 #define CC1_PLUGIN_MARSHALL_CXX_HH
23 #include "marshall.hh"
24 #include "gcc-cp-interface.h"
25 #include "deleter.hh"
27 namespace cc1_plugin
29 template<>
30 struct deleter<gcc_vbase_array>
32 void operator() (gcc_vbase_array *p)
34 delete[] p->flags;
35 delete[] p->elements;
36 delete p;
40 template<>
41 struct deleter<gcc_cp_template_args>
43 void operator() (gcc_cp_template_args *p)
45 delete[] p->elements;
46 delete[] p->kinds;
47 delete p;
51 template<>
52 struct deleter<gcc_cp_function_args>
54 void operator() (gcc_cp_function_args *p)
56 delete[] p->elements;
57 delete p;
61 // Send a gcc_vbase_array marker followed by the array.
62 status
63 marshall (connection *conn, const gcc_vbase_array *a)
65 size_t len;
67 if (a)
68 len = a->n_elements;
69 else
70 len = (size_t)-1;
72 if (!marshall_array_start (conn, 'v', len))
73 return FAIL;
75 if (!a)
76 return OK;
78 if (!marshall_array_elmts (conn, len * sizeof (a->elements[0]),
79 a->elements))
80 return FAIL;
82 return marshall_array_elmts (conn, len * sizeof (a->flags[0]),
83 a->flags);
86 // Read a gcc_vbase_array marker, followed by a gcc_vbase_array. The
87 // resulting array must be freed by the caller, using 'delete[]' on
88 // elements and virtualp, and 'delete' on the array object itself.
89 status
90 unmarshall (connection *conn, struct gcc_vbase_array **result)
92 size_t len;
94 if (!unmarshall_array_start (conn, 'v', &len))
95 return FAIL;
97 if (len == (size_t)-1)
99 *result = NULL;
100 return OK;
103 cc1_plugin::unique_ptr<gcc_vbase_array> gva (new gcc_vbase_array {});
105 gva->n_elements = len;
106 gva->elements = new gcc_type[len];
108 if (!unmarshall_array_elmts (conn,
109 len * sizeof (gva->elements[0]),
110 gva->elements))
111 return FAIL;
113 gva->flags = new enum gcc_cp_symbol_kind[len];
115 if (!unmarshall_array_elmts (conn,
116 len * sizeof (gva->flags[0]),
117 gva->flags))
118 return FAIL;
120 *result = gva.release ();
121 return OK;
124 // Send a gcc_cp_template_args marker followed by the array.
125 status
126 marshall (connection *conn, const gcc_cp_template_args *a)
128 size_t len;
130 if (a)
131 len = a->n_elements;
132 else
133 len = (size_t)-1;
135 if (!marshall_array_start (conn, 't', len))
136 return FAIL;
138 if (!a)
139 return OK;
141 if (!marshall_array_elmts (conn, len * sizeof (a->kinds[0]),
142 a->kinds))
143 return FAIL;
145 return marshall_array_elmts (conn, len * sizeof (a->elements[0]),
146 a->elements);
149 // Read a gcc_vbase_array marker, followed by a gcc_vbase_array. The
150 // resulting array must be freed by the caller, using 'delete[]' on
151 // elements and virtualp, and 'delete' on the array object itself.
152 status
153 unmarshall (connection *conn, struct gcc_cp_template_args **result)
155 size_t len;
157 if (!unmarshall_array_start (conn, 't', &len))
158 return FAIL;
160 if (len == (size_t)-1)
162 *result = NULL;
163 return OK;
166 cc1_plugin::unique_ptr<gcc_cp_template_args> gva
167 (new gcc_cp_template_args {});
169 gva->n_elements = len;
170 gva->kinds = new char[len];
172 if (!unmarshall_array_elmts (conn,
173 len * sizeof (gva->kinds[0]),
174 gva->kinds))
175 return FAIL;
177 gva->elements = new gcc_cp_template_arg[len];
179 if (!unmarshall_array_elmts (conn,
180 len * sizeof (gva->elements[0]),
181 gva->elements))
182 return FAIL;
184 *result = gva.release ();
185 return OK;
188 // Send a gcc_cp_function_args marker followed by the array.
189 status
190 marshall (connection *conn, const gcc_cp_function_args *a)
192 size_t len;
194 if (a)
195 len = a->n_elements;
196 else
197 len = (size_t)-1;
199 if (!marshall_array_start (conn, 'd', len))
200 return FAIL;
202 if (!a)
203 return OK;
205 return marshall_array_elmts (conn, len * sizeof (a->elements[0]),
206 a->elements);
209 // Read a gcc_cp_function_args marker, followed by a
210 // gcc_cp_function_args. The resulting array must be freed
211 // by the caller, using 'delete[]' on elements and virtualp, and
212 // 'delete' on the array object itself.
213 status
214 unmarshall (connection *conn, struct gcc_cp_function_args **result)
216 size_t len;
218 if (!unmarshall_array_start (conn, 'd', &len))
219 return FAIL;
221 if (len == (size_t)-1)
223 *result = NULL;
224 return OK;
227 cc1_plugin::unique_ptr<gcc_cp_function_args> gva
228 (new gcc_cp_function_args {});
230 gva->n_elements = len;
231 gva->elements = new gcc_expr[len];
233 if (!unmarshall_array_elmts (conn,
234 len * sizeof (gva->elements[0]),
235 gva->elements))
236 return FAIL;
238 *result = gva.release ();
240 return OK;
244 #endif // CC1_PLUGIN_MARSHALL_CP_HH