Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
cb625e13
Commit
cb625e13
authored
Jan 29, 2011
by
Michael Beck
Browse files
Simplyfied firm arrays by deleting useless macro and union.
[r28280]
parent
f4054b69
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/libfirm/adt/array.h
View file @
cb625e13
...
...
@@ -104,7 +104,7 @@
#define NEW_ARR_D(type, obstack, nelts) \
( nelts \
? (type *)ir_new_arr_d((obstack), (nelts), sizeof(type) * (nelts)) \
: (type *)arr_mt_descr.
v.
elts)
: (type *)arr_mt_descr.elts)
/**
* Creates a new dynamic array with the same number of elements as a
...
...
@@ -228,28 +228,20 @@ typedef union {
long
l
;
}
aligned_type
;
/**
* Construct an array header.
*/
#define ARR_STRUCT(type, rnelts) \
struct { \
int magic; \
size_t eltsize; \
union { \
struct obstack *obstack;
/* dynamic: allocated on this obstack */
\
size_t allocated;
/* flexible: #slots allocated */
\
} u; \
size_t nelts; \
union { \
type elts[(rnelts)]; \
aligned_type align[1]; \
} v; \
}
/**
* The array descriptor header type.
*/
typedef
ARR_STRUCT
(
aligned_type
,
1
)
ir_arr_descr
;
typedef
struct
{
int
magic
;
/**< array magic. */
size_t
eltsize
;
/**< size of array elements. */
union
{
struct
obstack
*
obstack
;
/**< for obstack array: the obstack. */
size_t
allocated
;
/**< number of allocated elements. */
}
u
;
size_t
nelts
;
/**< current length of the array. */
aligned_type
elts
[
1
];
/**< start of the array data. */
}
ir_arr_descr
;
extern
ir_arr_descr
arr_mt_descr
;
...
...
@@ -260,7 +252,7 @@ FIRM_API void *ir_arr_resize(void *elts, size_t nelts, size_t elts_size);
FIRM_API
void
*
ir_arr_setlen
(
void
*
elts
,
size_t
nelts
,
size_t
elts_size
);
FIRM_API
void
ir_verify_arr
(
const
void
*
elts
);
#define ARR_ELTS_OFFS offsetof(ir_arr_descr,
v.
elts)
#define ARR_ELTS_OFFS offsetof(ir_arr_descr, elts)
#define ARR_DESCR(elts) ((ir_arr_descr *)(void *)((char *)(elts) - ARR_ELTS_OFFS))
#include
"../end.h"
...
...
ir/adt/array.c
View file @
cb625e13
...
...
@@ -86,7 +86,7 @@ void *ir_new_arr_d(struct obstack *obstack, size_t nelts, size_t elts_size)
ARR_SET_DBGINF
(
dp
,
ARR_D_MAGIC
,
elts_size
/
nelts
);
dp
->
u
.
obstack
=
obstack
;
dp
->
nelts
=
nelts
;
return
dp
->
v
.
elts
;
return
dp
->
elts
;
}
/**
...
...
@@ -107,7 +107,7 @@ void *ir_new_arr_f(size_t nelts, size_t elts_size)
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
;
return
newa
->
elts
;
}
/**
...
...
@@ -153,7 +153,7 @@ void *ir_arr_setlen (void *elts, size_t nelts, size_t elts_size)
dp
=
(
ir_arr_descr
*
)
xrealloc
(
dp
,
ARR_ELTS_OFFS
+
elts_size
);
dp
->
u
.
allocated
=
dp
->
nelts
=
nelts
;
return
dp
->
v
.
elts
;
return
dp
->
elts
;
}
/**
...
...
@@ -190,7 +190,7 @@ void *ir_arr_resize(void *elts, size_t nelts, size_t eltsize)
}
dp
->
nelts
=
nelts
;
return
dp
->
v
.
elts
;
return
dp
->
elts
;
}
#ifdef DEBUG_libfirm
...
...
ir/adt/array_t.h
View file @
cb625e13
...
...
@@ -52,7 +52,7 @@
#define NEW_ARR_A(type, var, n) \
do { \
size_t nelts = (n); \
(var) = (type *)((ir_arr_descr *)alloca(ARR_ELTS_OFFS + sizeof(type) * nelts))->
v.
elts; \
(var) = (type *)((ir_arr_descr *)alloca(ARR_ELTS_OFFS + sizeof(type) * nelts))->elts; \
ARR_SET_DBGINF(ARR_DESCR ((var)), ARR_A_MAGIC, sizeof (type)); \
(void)(ARR_DESCR((var))->nelts = nelts); \
} while (0)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment