+/* Ensure it is in .rodata (if available) by workarounding GCC PR 44690. */
+const struct cplus_struct_type cplus_struct_default = { };
+
+void
+allocate_cplus_struct_type (struct type *type)
+{
+ if (HAVE_CPLUS_STRUCT (type))
+ /* Structure was already allocated. Nothing more to do. */
+ return;
+
+ TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF;
+ TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
+ TYPE_ALLOC (type, sizeof (struct cplus_struct_type));
+ *(TYPE_RAW_CPLUS_SPECIFIC (type)) = cplus_struct_default;
+ set_type_vptr_fieldno (type, -1);
+}
+
+const struct gnat_aux_type gnat_aux_default =
+ { NULL };
+
+/* Set the TYPE's type-specific kind to TYPE_SPECIFIC_GNAT_STUFF,
+ and allocate the associated gnat-specific data. The gnat-specific
+ data is also initialized to gnat_aux_default. */
+
+void
+allocate_gnat_aux_type (struct type *type)
+{
+ TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF;
+ TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *)
+ TYPE_ALLOC (type, sizeof (struct gnat_aux_type));
+ *(TYPE_GNAT_SPECIFIC (type)) = gnat_aux_default;
+}
+
+/* Helper function to initialize a newly allocated type. Set type code
+ to CODE and initialize the type-specific fields accordingly. */
+
+static void
+set_type_code (struct type *type, enum type_code code)
+{
+ TYPE_CODE (type) = code;
+
+ switch (code)
+ {
+ case TYPE_CODE_STRUCT:
+ case TYPE_CODE_UNION:
+ case TYPE_CODE_NAMESPACE:
+ INIT_CPLUS_SPECIFIC (type);
+ break;
+ case TYPE_CODE_FLT:
+ TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FLOATFORMAT;
+ break;
+ case TYPE_CODE_FUNC:
+ INIT_FUNC_SPECIFIC (type);
+ break;
+ }
+}
+
+/* Helper function to verify floating-point format and size.
+ BIT is the type size in bits; if BIT equals -1, the size is
+ determined by the floatformat. Returns size to be used. */
+
+static int
+verify_floatformat (int bit, const struct floatformat *floatformat)
+{
+ gdb_assert (floatformat != NULL);
+
+ if (bit == -1)
+ bit = floatformat->totalsize;
+
+ gdb_assert (bit >= 0);
+ gdb_assert (bit >= floatformat->totalsize);
+
+ return bit;
+}
+
+/* Return the floating-point format for a floating-point variable of
+ type TYPE. */
+
+const struct floatformat *
+floatformat_from_type (const struct type *type)
+{
+ gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
+ gdb_assert (TYPE_FLOATFORMAT (type));
+ return TYPE_FLOATFORMAT (type);
+}
+
+/* Helper function to initialize the standard scalar types.
+
+ If NAME is non-NULL, then it is used to initialize the type name.
+ Note that NAME is not copied; it is required to have a lifetime at
+ least as long as OBJFILE. */
+
+struct type *
+init_type (struct objfile *objfile, enum type_code code, int bit,
+ const char *name)
+{
+ struct type *type;
+
+ type = alloc_type (objfile);
+ set_type_code (type, code);
+ gdb_assert ((bit % TARGET_CHAR_BIT) == 0);
+ TYPE_LENGTH (type) = bit / TARGET_CHAR_BIT;
+ TYPE_NAME (type) = name;
+
+ return type;
+}
+
+/* Allocate a TYPE_CODE_ERROR type structure associated with OBJFILE,
+ to use with variables that have no debug info. NAME is the type
+ name. */
+
+static struct type *
+init_nodebug_var_type (struct objfile *objfile, const char *name)
+{
+ return init_type (objfile, TYPE_CODE_ERROR, 0, name);
+}
+
+/* Allocate a TYPE_CODE_INT type structure associated with OBJFILE.
+ BIT is the type size in bits. If UNSIGNED_P is non-zero, set
+ the type's TYPE_UNSIGNED flag. NAME is the type name. */
+
+struct type *
+init_integer_type (struct objfile *objfile,
+ int bit, int unsigned_p, const char *name)
+{
+ struct type *t;
+
+ t = init_type (objfile, TYPE_CODE_INT, bit, name);
+ if (unsigned_p)
+ TYPE_UNSIGNED (t) = 1;
+
+ return t;
+}
+
+/* Allocate a TYPE_CODE_CHAR type structure associated with OBJFILE.
+ BIT is the type size in bits. If UNSIGNED_P is non-zero, set
+ the type's TYPE_UNSIGNED flag. NAME is the type name. */
+
+struct type *
+init_character_type (struct objfile *objfile,
+ int bit, int unsigned_p, const char *name)
+{
+ struct type *t;
+
+ t = init_type (objfile, TYPE_CODE_CHAR, bit, name);
+ if (unsigned_p)
+ TYPE_UNSIGNED (t) = 1;
+
+ return t;
+}
+
+/* Allocate a TYPE_CODE_BOOL type structure associated with OBJFILE.
+ BIT is the type size in bits. If UNSIGNED_P is non-zero, set
+ the type's TYPE_UNSIGNED flag. NAME is the type name. */