Don't cancel loop tree in parloops
[official-gcc.git] / libcc1 / marshall.hh
blob3f936e7a7543c9cbbd0bc23423b6da68daaac36c
1 /* Marshalling and unmarshalling.
2 Copyright (C) 2014 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_HH
21 #define CC1_PLUGIN_MARSHALL_HH
23 #include "status.hh"
24 #include "gcc-c-interface.h"
26 namespace cc1_plugin
28 class connection;
30 // Only a single kind of integer is ever sent over the wire, and
31 // this is it.
32 typedef unsigned long long protocol_int;
34 // Read an integer from the connection and verify that it has the
35 // value V.
36 status unmarshall_check (connection *, protocol_int v);
38 // Write an integer, prefixed with the integer type marker, to the
39 // connection.
40 status marshall_intlike (connection *, protocol_int);
42 // Read a type marker from the connection and verify that it is an
43 // integer type marker. If not, return FAIL. If so, read an
44 // integer store it in the out argument.
45 status unmarshall_intlike (connection *, protocol_int *);
47 // A template function that can handle marshalling various integer
48 // objects to the connection.
49 template<typename T>
50 status marshall (connection *conn, T scalar)
52 return marshall_intlike (conn, scalar);
55 // A template function that can handle unmarshalling various integer
56 // objects from the connection. Note that this can't be
57 // instantiated for enum types. Note also that there's no way at
58 // the protocol level to distinguish different int types.
59 template<typename T>
60 status unmarshall (connection *conn, T *scalar)
62 protocol_int result;
64 if (!unmarshall_intlike (conn, &result))
65 return FAIL;
66 *scalar = result;
67 return OK;
70 // Unmarshallers for some specific enum types. With C++11 we
71 // wouldn't need these, as we could add type traits to the scalar
72 // unmarshaller.
73 status unmarshall (connection *, enum gcc_c_symbol_kind *);
74 status unmarshall (connection *, enum gcc_qualifiers *);
75 status unmarshall (connection *, enum gcc_c_oracle_request *);
77 // Send a string type marker followed by a string.
78 status marshall (connection *, const char *);
80 // Read a string type marker followed by a string. The caller is
81 // responsible for freeing the resulting string using 'delete[]'.
82 status unmarshall (connection *, char **);
84 // Send a gcc_type_array marker followed by the array.
85 status marshall (connection *, const gcc_type_array *);
87 // Read a gcc_type_array marker, followed by a gcc_type_array. The
88 // resulting array must be freed by the caller, using 'delete[]' on
89 // the elements, and 'delete' on the array object itself.
90 status unmarshall (connection *, struct gcc_type_array **);
93 #endif // CC1_PLUGIN_MARSHALL_HH