Commit ce6161a7 authored by Matthias Braun's avatar Matthias Braun
Browse files

make firm compilable with a c++ compiler

[r28127]
parent fd269bc5
......@@ -79,7 +79,7 @@
* first element of this array).
*/
#define DUP_ARR_F(type, arr) \
memcpy(CLONE_ARR_F(type, (arr)), (arr), sizeof(type) * ARR_LEN((arr)))
((type*) memcpy(CLONE_ARR_F(type, (arr)), (arr), sizeof(type) * ARR_LEN((arr))))
/**
* Delete a flexible array.
......@@ -137,7 +137,7 @@
* first element of this array).
*/
#define DUP_ARR_D(type, obstack, arr) \
memcpy(CLONE_ARR_D(type, (obstack), (arr)), (arr), sizeof(type) * ARR_LEN ((arr)))
((type*)memcpy(CLONE_ARR_D(type, (obstack), (arr)), (arr), sizeof(type) * ARR_LEN ((arr))))
/**
* Returns the length of an array
......@@ -157,7 +157,7 @@
* @remark This macro may change arr, so update all references!
*/
#define ARR_RESIZE(type, arr, n) \
((arr) = ir_arr_resize((void *)(arr), (n), sizeof(type)))
((arr) = (type*) ir_arr_resize((void *)(arr), (n), sizeof(type)))
/**
* Resize a flexible array, always reallocate data.
......@@ -169,7 +169,7 @@
* @remark This macro may change arr, so update all references!
*/
#define ARR_SETLEN(type, arr, n) \
((arr) = ir_arr_setlen((void *)(arr), (n), sizeof(type) * (n)))
((arr) = (type*) ir_arr_setlen((void *)(arr), (n), sizeof(type) * (n)))
/** Set a length smaller than the current length of the array. Do not
* resize. len must be <= ARR_LEN(arr). */
......
......@@ -76,6 +76,9 @@ FIRM_API void *eset_next(eset *s);
/** Inserts all elements of source into target (union). Does NOT work if NULL is contained in source. */
FIRM_API void eset_insert_all(eset *target, eset *source);
#define eset_foreach(eset, type, iter) \
for ((iter) = (type)eset_first((eset)); (iter) != NULL; (iter) = (type)eset_next((eset)))
#include "../end.h"
#endif
......@@ -501,12 +501,19 @@ __extension__ \
#endif /* not __GNUC__ or not __STDC__ */
#ifdef __cplusplus
# define FIRM_NOTHROW throw ()
#else
# define FIRM_NOTHROW
#endif
/** prints formated string (printf-style format) to an obstack.
* This is done by "growing" the obstack with the obstack_*grow*
* functions. Note: Does NOT append a null-byte. */
int obstack_printf(struct obstack *obst, const char *fmt, ...);
int obstack_vprintf(struct obstack *obst, const char *fmt, va_list ap);
int obstack_printf(struct obstack *obst, const char *fmt, ...)
FIRM_NOTHROW __attribute__ ((__format__ (__printf__, 2, 3)));
int obstack_vprintf(struct obstack *obst, const char *fmt, va_list ap)
FIRM_NOTHROW __attribute__ ((__format__ (__printf__, 2, 0)));
#include "../end.h"
......
......@@ -207,7 +207,7 @@ FIRM_API void pset_break(pset *pset);
* @param pset the pset
* @param entry the iterator
*/
#define foreach_pset(pset, entry) for (entry = pset_first(pset); entry; entry = pset_next(pset))
#define foreach_pset(pset, type, entry) for (entry = (type)pset_first(pset); entry; entry = (type)pset_next(pset))
/**
* Inserts all elements of the pointer set src into
......
......@@ -136,10 +136,10 @@ FIRM_API void pset_new_remove_iterator(pset_new_t *pset_new, const pset_new_iter
/**
* Convenience macro for iterating over a pset_new.
*/
#define foreach_pset_new(pset_new, ptr, iter) \
#define foreach_pset_new(pset_new, type, ptr, iter) \
for(pset_new_iterator_init(&iter, pset_new), \
ptr = pset_new_iterator_next(&iter); \
ptr != NULL; ptr = pset_new_iterator_next(&iter))
ptr = (type) pset_new_iterator_next(&iter); \
ptr != NULL; ptr = (type) pset_new_iterator_next(&iter))
#include "../end.h"
......
......@@ -189,7 +189,7 @@ FIRM_API void set_break(set *set);
* @param set the set
* @param entry the iterator
*/
#define foreach_set(set, entry) for (entry = set_first(set); entry; entry = set_next(set))
#define foreach_set(set, type, entry) for (entry = (type) set_first(set); entry; entry = (type) set_next(set))
/* implementation specific */
#define new_set(cmp, slots) (SET_TRACE (new_set) ((cmp), (slots)))
......
......@@ -33,18 +33,20 @@
#include "begin.h"
typedef enum {
ASM_CONSTRAINT_FLAG_SUPPORTS_REGISTER = 0x0001,
ASM_CONSTRAINT_FLAG_SUPPORTS_MEMOP = 0x0002,
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE = 0x0004,
ASM_CONSTRAINT_FLAG_NO_SUPPORT = 0x0008,
ASM_CONSTRAINT_FLAG_MODIFIER_WRITE = 0x0010,
ASM_CONSTRAINT_FLAG_MODIFIER_NO_WRITE = 0x0020,
ASM_CONSTRAINT_FLAG_MODIFIER_READ = 0x0040,
ASM_CONSTRAINT_FLAG_MODIFIER_NO_READ = 0x0080,
ASM_CONSTRAINT_FLAG_MODIFIER_EARLYCLOBBER = 0x0100,
ASM_CONSTRAINT_FLAG_MODIFIER_COMMUTATIVE = 0x0200,
ASM_CONSTRAINT_FLAG_INVALID = 0x8000
ASM_CONSTRAINT_FLAG_NONE = 0,
ASM_CONSTRAINT_FLAG_SUPPORTS_REGISTER = 1u << 0,
ASM_CONSTRAINT_FLAG_SUPPORTS_MEMOP = 1u << 1,
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE = 1u << 2,
ASM_CONSTRAINT_FLAG_NO_SUPPORT = 1u << 3,
ASM_CONSTRAINT_FLAG_MODIFIER_WRITE = 1u << 4,
ASM_CONSTRAINT_FLAG_MODIFIER_NO_WRITE = 1u << 5,
ASM_CONSTRAINT_FLAG_MODIFIER_READ = 1u << 6,
ASM_CONSTRAINT_FLAG_MODIFIER_NO_READ = 1u << 7,
ASM_CONSTRAINT_FLAG_MODIFIER_EARLYCLOBBER = 1u << 8,
ASM_CONSTRAINT_FLAG_MODIFIER_COMMUTATIVE = 1u << 9,
ASM_CONSTRAINT_FLAG_INVALID = 1u << 10
} asm_constraint_flags_t;
ENUM_BITSET(asm_constraint_flags_t)
/**
* Build a Trampoline for the closure.
......
......@@ -42,16 +42,17 @@
#ifdef _WIN32
#define FIRM_API extern __declspec(dllimport)
#else
#define FIRM_API
#define FIRM_API extern
#endif
#endif
#else
#define FIRM_API
#define FIRM_API extern
#endif
/* mark declarations as C function */
#ifdef __cplusplus
extern "C" {
#endif
/* mark declarations as C function (note that we always need this,
* so don't put it in the include guard) */
#ifdef __cplusplus
extern "C" {
#endif
......@@ -23,16 +23,9 @@
* @author Matthias Braun
* @version $Id$
*/
#ifndef FIRM_END_H
#define FIRM_END_H
#ifndef FIRM_BEGIN_H
#error "end.h included without begin.h?"
#endif
/* close extern "C" block from begin.h */
/* close extern "C" block from begin.h,
* we need this without include guard (see begin.h) */
#ifdef __cplusplus
}
#endif
#endif
......@@ -34,7 +34,7 @@ typedef unsigned long ir_label_t;
typedef struct dbg_info dbg_info, *dbg_info_ptr;
typedef struct type_dbg_info type_dbg_info, *type_dbg_info_ptr;
typedef const struct ident ident, *ir_ident_ptr;
typedef struct ident ident, *ir_ident_ptr;
typedef struct ir_node ir_node, *ir_node_ptr;
typedef struct ir_op ir_op, *ir_op_ptr;
typedef struct ir_mode ir_mode, *ir_mode_ptr;
......@@ -92,8 +92,35 @@ typedef const ir_node *ir_node_cnst_ptr;
*/
typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
#ifdef __cplusplus
# define ENUM_BITSET(type) \
extern "C++" { \
static inline type operator ~ (type a) { return (type)~(int)a; } \
static inline type operator & (type a, type b) { return (type)((int)a & (int)b); } \
static inline type operator &= (type& a, type b) { return a = (type)((int)a & (int)b); } \
static inline type operator ^ (type a, type b) { return (type)((int)a ^ (int)b); } \
static inline type operator ^= (type& a, type b) { return a = (type)((int)a ^ (int)b); } \
static inline type operator | (type a, type b) { return (type)((int)a | (int)b); } \
static inline type operator |= (type& a, type b) { return a = (type)((int)a | (int)b); } \
}
#else
# define ENUM_BITSET(type)
#endif
#ifdef __cplusplus
# define ENUM_COUNTABLE(type) \
extern "C++" { \
static inline type operator ++(type& a) { return a = (type)((int)a + 1); } \
static inline type operator --(type& a) { return a = (type)((int)a - 1); } \
}
#else
# define ENUM_COUNTABLE(type)
#endif
/** op_pin_state_pinned states. */
typedef enum {
typedef enum op_pin_state {
op_pin_state_floats = 0, /**< Nodes of this opcode can be placed in any basic block. */
op_pin_state_pinned = 1, /**< Nodes must remain in this basic block. */
op_pin_state_exc_pinned, /**< Node must be remain in this basic block if it can throw an
......@@ -105,7 +132,7 @@ typedef enum {
/**
* A type to express conditional jump predictions.
*/
typedef enum {
typedef enum cond_jmp_predicate {
COND_JMP_PRED_NONE, /**< No jump prediction. Default. */
COND_JMP_PRED_TRUE, /**< The True case is predicted. */
COND_JMP_PRED_FALSE /**< The False case is predicted. */
......@@ -116,7 +143,7 @@ typedef enum {
* Tell about special properties of a method type. Some
* of these may be discovered by analyses.
*/
typedef enum {
typedef enum mtp_additional_properties {
mtp_no_property = 0x00000000, /**< no additional properties, default */
mtp_property_const = 0x00000001, /**< This method did not access memory and calculates
its return values solely from its parameters.
......@@ -144,7 +171,8 @@ typedef enum {
mtp_property_has_loop = 0x00000400, /**< Set, if this method contains one possible endless loop. */
mtp_property_inherited = (1<<31) /**< Internal. Used only in irg's, means property is
inherited from type. */
} mtp_additional_property;
} mtp_additional_properties;
ENUM_BITSET(mtp_additional_properties)
/** This enum names the different kinds of symbolic Constants represented by
* SymConst. The content of the attribute symconst_symbol depends on this tag.
......@@ -176,20 +204,20 @@ typedef union symconst_symbol {
} symconst_symbol;
/** The allocation place. */
typedef enum {
typedef enum ir_where_alloc {
stack_alloc, /**< Alloc allocates the object on the stack. */
heap_alloc /**< Alloc allocates the object on the heap. */
} ir_where_alloc;
/** A input/output constraint attribute. */
typedef struct {
typedef struct ir_asm_constraint {
unsigned pos; /**< The inputs/output position for this constraint. */
ident *constraint; /**< The constraint for this input/output. */
ir_mode *mode; /**< The mode of the constraint. */
} ir_asm_constraint;
/** Supported libFirm builtins. */
typedef enum {
typedef enum ir_builtin_kind {
ir_bk_trap, /**< GCC __builtin_trap(): insert trap */
ir_bk_debugbreak, /**< MS __debugbreak(): insert debug break */
ir_bk_return_address, /**< GCC __builtin_return_address() */
......@@ -219,7 +247,7 @@ enum pn_generic {
/**
* Possible return values of value_classify().
*/
typedef enum {
typedef enum ir_value_classify_sign {
value_classified_unknown = 0, /**< could not classify */
value_classified_positive = 1, /**< value is positive, i.e. >= 0 */
value_classified_negative = -1 /**< value is negative, i.e. <= 0 if
......
......@@ -89,6 +89,7 @@ typedef enum {
arch_dep_div_by_const = 2, /**< optimize Div into Shift/Add/Mulh */
arch_dep_mod_by_const = 4 /**< optimize Mod into Shift/Add/Mulh */
} arch_dep_opts_t;
ENUM_BITSET(arch_dep_opts_t)
/**
* Set the optimizations that shall be applied.
......
......@@ -1127,6 +1127,7 @@ typedef enum ir_cons_flags {
cons_unaligned = 1U << 1, /**< Memory operation is unaligned. */
cons_floats = 1U << 2 /**< Memory operation can float. */
} ir_cons_flags;
ENUM_BITSET(ir_cons_flags)
/*-------------------------------------------------------------------------*/
/* The raw interface */
......
......@@ -284,6 +284,7 @@ typedef enum {
dump_verbosity_max = 0x4FF00FBE /**< Turn everything on */
} ir_dump_verbosity_t;
ENUM_BITSET(ir_dump_verbosity_t)
/** override currently set text dump flags with new ones */
FIRM_API void ir_set_dump_verbosity(ir_dump_verbosity_t verbosity);
......@@ -343,6 +344,7 @@ typedef enum {
/** dump entities in class hierarchies */
ir_dump_flag_entities_in_hierarchy = 1U << 22,
} ir_dump_flags_t;
ENUM_BITSET(ir_dump_flags_t)
/** override currently set dump flags with new ones */
FIRM_API void ir_set_dump_flags(ir_dump_flags_t flags);
......
......@@ -29,14 +29,14 @@
#include "begin.h"
/** Supported Edge kinds. */
enum ir_edge_kind_t {
EDGE_KIND_NORMAL, /**< Normal data flow edges. */
EDGE_KIND_BLOCK, /**< Block to Block control flow edges. */
EDGE_KIND_DEP, /**< Dependency edges. */
typedef enum ir_edge_kind_t {
EDGE_KIND_FIRST,
EDGE_KIND_NORMAL = EDGE_KIND_FIRST, /**< Normal data flow edges. */
EDGE_KIND_BLOCK, /**< Block to Block control flow edges. */
EDGE_KIND_DEP, /**< Dependency edges. */
EDGE_KIND_LAST
};
typedef enum ir_edge_kind_t ir_edge_kind_t;
} ir_edge_kind_t;
ENUM_COUNTABLE(ir_edge_kind_t)
#include "end.h"
......
......@@ -447,19 +447,19 @@ FIRM_API void set_irg_inline_property(ir_graph *irg, irg_inline_property s);
* Returns the mask of the additional graph properties.
* The properties are automatically inherited from the method type
* if they were not set using set_irg_additional_properties() or
* set_irg_additional_property().
* set_irg_additional_properties().
*
* @return a bitset of mtp_additional_property values
* @return a bitset of mtp_additional_properties values
*/
FIRM_API unsigned get_irg_additional_properties(const ir_graph *irg);
FIRM_API mtp_additional_properties get_irg_additional_properties(const ir_graph *irg);
/** Sets the mask of the additional graph properties. */
FIRM_API void set_irg_additional_properties(ir_graph *irg,
unsigned property_mask);
mtp_additional_properties property_mask);
/** Sets one additional graph property. */
FIRM_API void set_irg_additional_property(ir_graph *irg,
mtp_additional_property flag);
FIRM_API void add_irg_additional_properties(ir_graph *irg,
mtp_additional_properties flag);
/** A void * field to link arbitrary information to the node. */
FIRM_API void set_irg_link(ir_graph *irg, void *thing);
......@@ -487,8 +487,9 @@ FIRM_API void set_irg_block_visited(ir_graph *irg, ir_visited_t i);
* block_visited flags. If NDEBUG is not defined, then the compiler will abort
* if 2 parties try to use the flags.
*/
enum ir_resources_enum_t {
typedef enum ir_resources_t {
/* local (irg) resources */
IR_RESOURCE_NONE = 0,
IR_RESOURCE_BLOCK_VISITED = 1 << 0, /**< Block visited flags are used. */
IR_RESOURCE_BLOCK_MARK = 1 << 1, /**< Block mark bits are used. */
IR_RESOURCE_IRN_VISITED = 1 << 2, /**< IR-node visited flags are used. */
......@@ -504,8 +505,8 @@ enum ir_resources_enum_t {
/* masks */
IR_RESOURCE_LOCAL_MASK = 0x00FF, /**< Mask for all local resources. */
IR_RESOURCE_GLOBAL_MASK = 0xFF00 /**< Mask for all global resources. */
};
typedef unsigned ir_resources_t;
} ir_resources_t;
ENUM_BITSET(ir_resources_t)
#ifndef NDEBUG
FIRM_API void ir_reserve_resources(ir_graph *irg, ir_resources_t resources);
......@@ -525,6 +526,7 @@ typedef enum {
IR_GRAPH_STATE_ARCH_DEP = 1U << 1, /**< should not construct more nodes which irarch potentially breaks down */
IR_GRAPH_STATE_BCONV_ALLOWED = 1U << 2, /**< Conv(mode_b) to Iu is allowed as set command */
} ir_graph_state_t;
ENUM_BITSET(ir_graph_state_t)
/** set some state flags on the graph (this does not clear the other flags) */
FIRM_API void set_irg_state(ir_graph *irg, ir_graph_state_t state);
......
......@@ -31,20 +31,20 @@
#include "begin.h"
/** The alias relation of two memory addresses. */
typedef enum {
typedef enum ir_alias_relation {
ir_no_alias, /**< No alias. */
ir_may_alias, /**< Unknown state, may alias. */
ir_sure_alias /**< Sure alias. */
} ir_alias_relation;
/** The state of the entity usage flags. */
typedef enum {
typedef enum ir_entity_usage_computed_state {
ir_entity_usage_not_computed,
ir_entity_usage_computed
} ir_entity_usage_computed_state;
/** Possible options for the memory disambiguator. */
typedef enum {
typedef enum ir_disambuigator_options {
aa_opt_no_opt = 0, /**< no options: most conservative */
aa_opt_type_based = 1, /**< use type based alias analysis: strict typed source language */
aa_opt_byte_type_may_alias = 2, /**< if type based analysis is enabled: bytes types may alias other types */
......@@ -53,6 +53,7 @@ typedef enum {
aa_opt_no_alias = 16, /**< two addresses NEVER alias, use with CAUTION (gcc -fno-alias) */
aa_opt_inherited = 128 /**< only for implementation: options from a graph are inherited from global */
} ir_disambuigator_options;
ENUM_BITSET(ir_disambuigator_options)
/**
* Classify storage locations.
......@@ -60,7 +61,7 @@ typedef enum {
* ir_sc_pointer potentially aliases all classes which don't have a
* NOTTAKEN modifier.
*/
typedef enum {
typedef enum ir_storage_class_class_t {
ir_sc_pointer = 0x0, /**< generic pointer, may be anything */
ir_sc_globalvar = 0x1, /**< an address of a global variable */
ir_sc_localvar = 0x2, /**< an address of a local variable or method argument */
......@@ -72,9 +73,13 @@ typedef enum {
ir_sc_modifier_argument = 0x40, /**< if set pointer was a function argument */
ir_sc_modifiers = ir_sc_modifier_nottaken | ir_sc_modifier_argument
} ir_storage_class_class_t;
ENUM_BITSET(ir_storage_class_class_t)
/** Get the base storage class (ignore modifier) */
#define GET_BASE_SC(x) ((x) & ~ir_sc_modifiers)
static inline ir_storage_class_class_t get_base_sc(ir_storage_class_class_t x)
{
return x & ~ir_sc_modifiers;
}
/**
* A source language specific memory disambiguator function.
......
......@@ -35,6 +35,8 @@
#include "begin.h"
#include "nodeops.h"
ENUM_BITSET(pn_Cmp)
/**
* @defgroup ir_node Declarations of an ir node.
*
......@@ -571,6 +573,7 @@ FIRM_API void add_Sync_pred(ir_node *node, ir_node *pred);
/** Return the projection number of a Proj node. */
FIRM_API long get_Proj_proj(const ir_node *node);
FIRM_API void set_Proj_proj(ir_node *node, long proj);
FIRM_API pn_Cmp get_Proj_pn_cmp(const ir_node*);
/**
* Returns non-zero if a node is a routine parameter.
......
......@@ -62,6 +62,7 @@ typedef enum ir_segment_t {
IR_SEGMENT_LAST = IR_SEGMENT_DESTRUCTORS
} ir_segment_t;
ENUM_COUNTABLE(ir_segment_t)
/**
* A variable pointing to the current irp (program or module).
......
......@@ -149,6 +149,7 @@ typedef enum {
*/
IR_LINKAGE_HIDDEN_USER = 1 << 4
} ir_linkage;
ENUM_BITSET(ir_linkage)
/**
* Return the visibility class of an entity
......@@ -575,15 +576,15 @@ FIRM_API int entity_not_visited(const ir_entity *ent);
* set_entity_additional_properties() or
* set_entity_additional_property().
*/
FIRM_API unsigned get_entity_additional_properties(const ir_entity *ent);
FIRM_API mtp_additional_properties get_entity_additional_properties(const ir_entity *ent);
/** Sets the mask of the additional graph properties. */
FIRM_API void set_entity_additional_properties(ir_entity *ent,
unsigned property_mask);
mtp_additional_properties prop);
/** Sets one additional graph property. */
FIRM_API void set_entity_additional_property(ir_entity *ent,
mtp_additional_property flag);
/** Sets additional graph properties. */
FIRM_API void add_entity_additional_properties(ir_entity *ent,
mtp_additional_properties flag);
/** Returns the class type that this type info entity represents or NULL
if ent is no type info entity. */
......@@ -629,7 +630,7 @@ FIRM_API ir_entity *unknown_entity;
FIRM_API ir_entity *get_unknown_entity(void);
/** Encodes how a pointer parameter is accessed. */
typedef enum acc_bits {
typedef enum ptr_access_kind {
ptr_access_none = 0, /**< no access */
ptr_access_read = 1, /**< read access */
ptr_access_write = 2, /**< write access */
......@@ -637,6 +638,7 @@ typedef enum acc_bits {
ptr_access_store = 4, /**< the pointer is stored */
ptr_access_all = ptr_access_rw|ptr_access_store /**< all possible access */
} ptr_access_kind;
ENUM_BITSET(ptr_access_kind)
#define IS_READ(a) ((a) & ptr_access_read)
#define IS_WRITTEN(a) ((a) & ptr_access_write)
......@@ -1678,15 +1680,15 @@ FIRM_API int get_method_first_variadic_param_index(const ir_type *method);
FIRM_API void set_method_first_variadic_param_index(ir_type *method, int index);
/** Returns the mask of the additional graph properties. */
FIRM_API unsigned get_method_additional_properties(const ir_type *method);
FIRM_API mtp_additional_properties get_method_additional_properties(const ir_type *method);
/** Sets the mask of the additional graph properties. */
FIRM_API void set_method_additional_properties(ir_type *method,
unsigned property_mask);
mtp_additional_properties property_mask);
/** Sets one additional graph property. */
FIRM_API void set_method_additional_property(ir_type *method,
mtp_additional_property flag);
FIRM_API void add_method_additional_properties(ir_type *method,
mtp_additional_properties flag);
/**
* Calling conventions: lower 24 bits are the number of register parameters,
......
......@@ -82,7 +82,7 @@ void *ir_new_arr_d(struct obstack *obstack, int nelts, size_t elts_size)
assert(obstack && (nelts >= 0));
dp = obstack_alloc(obstack, ARR_ELTS_OFFS + elts_size);
dp = (ir_arr_descr*) obstack_alloc(obstack, ARR_ELTS_OFFS + elts_size);
ARR_SET_DBGINF(dp, ARR_D_MAGIC, elts_size/nelts);
dp->u.obstack = obstack;
dp->nelts = nelts;
......@@ -102,13 +102,13 @@ void *ir_new_arr_d(struct obstack *obstack, int nelts, size_t elts_size)
*/
void *ir_new_arr_f(int nelts, size_t elts_size)
{
ir_arr_descr *new;
ir_arr_descr *newa;
assert (nelts >= 0);
new = xmalloc (ARR_ELTS_OFFS+elts_size);
ARR_SET_DBGINF (new, ARR_F_MAGIC, nelts ? elts_size/nelts : 0);
new->u.allocated = new->nelts = nelts;
return new->v.elts;
newa = (ir_arr_descr*) xmalloc (ARR_ELTS_OFFS+elts_size);
ARR_SET_DBGINF (newa, ARR_F_MAGIC, nelts ? elts_size/nelts : 0);
newa->u.allocated = newa->nelts = nelts;
return newa->v.elts;
}
/**
......@@ -154,7 +154,7 @@ void *ir_arr_setlen (void *elts, int nelts, size_t elts_size)
ARR_VRFY (elts);
assert (!dp->eltsize || !nelts || (dp->eltsize == elts_size/nelts));
dp = xrealloc (dp, ARR_ELTS_OFFS+elts_size);
dp = (ir_arr_descr*) xrealloc (dp, ARR_ELTS_OFFS+elts_size);
dp->u.allocated = dp->nelts = nelts;
return dp->v.elts;
......@@ -189,7 +189,7 @@ void *ir_arr_resize(void *elts, int nelts, size_t eltsize)
assert(n >= nelts);
if (n != dp->u.allocated) {
dp = xrealloc(dp, ARR_ELTS_OFFS+eltsize*n);
dp = (ir_arr_descr*) xrealloc(dp, ARR_ELTS_OFFS+eltsize*n);
dp->u.allocated = n;
#if defined(DEBUG) && defined(HAVE_GNU_MALLOC)
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment