Author: jkeenan
Date: Fri Jan 2 19:47:29 2009
New Revision: 34846
Modified:
branches/assert_args/compilers/imcc/sets.c
branches/assert_args/src/charset.c
branches/assert_args/src/embed.c
branches/assert_args/src/inter_run.c
branches/assert_args/src/pbc_merge.c
branches/assert_args/src/pic.c
Log:
Fix positioning of ASSERT_ARGS() to be below last variable declaration in a
given subroutine; avoid C90 warnings.
Modified: branches/assert_args/compilers/imcc/sets.c
==============================================================================
--- branches/assert_args/compilers/imcc/sets.c (original)
+++ branches/assert_args/compilers/imcc/sets.c Fri Jan 2 19:47:29 2009
@@ -51,8 +51,8 @@
Set*
set_make(unsigned int length)
{
- ASSERT_ARGS(set_make);
Set * const s = mem_allocate_zeroed_typed(Set);
+ ASSERT_ARGS(set_make);
s->length = length;
s->bmp = mem_allocate_n_zeroed_typed(NUM_BYTES(length),
unsigned char);
@@ -76,9 +76,9 @@
Set*
set_make_full(unsigned int length)
{
- ASSERT_ARGS(set_make_full);
Set * const s = set_make(length);
const size_t bytes = NUM_BYTES(length);
+ ASSERT_ARGS(set_make_full);
if (bytes)
memset(s->bmp, 0xff, bytes);
@@ -141,8 +141,8 @@
Set*
set_copy(ARGIN(const Set *s))
{
- ASSERT_ARGS(set_copy);
Set * const d = set_make(s->length);
+ ASSERT_ARGS(set_copy);
memcpy(d->bmp, s->bmp, NUM_BYTES(d->length));
return d;
@@ -166,8 +166,8 @@
set_equal(ARGIN(const Set *s1), ARGIN(const Set *s2))
{
int mask;
- ASSERT_ARGS(set_equal);
const size_t bytes = s1->length / 8;
+ ASSERT_ARGS(set_equal);
if (s1->length != s2->length)
fatal(1, "set_equal", "Sets don't have the same length\n");
@@ -201,9 +201,9 @@
void
set_add(ARGMOD(Set *s), unsigned int element)
{
- ASSERT_ARGS(set_add);
const int elem_byte_in_set = BYTE_IN_SET(element);
const int bytes_in_set = BYTE_IN_SET(s->length);
+ ASSERT_ARGS(set_add);
if (bytes_in_set < elem_byte_in_set) {
s->bmp = (unsigned char *)mem_sys_realloc_zeroed(s->bmp,
@@ -302,8 +302,8 @@
set_union(ARGIN(const Set *s1), ARGIN(const Set *s2))
{
unsigned int i;
- ASSERT_ARGS(set_union);
Set * const s = set_make(s1->length);
+ ASSERT_ARGS(set_union);
if (s1->length != s2->length)
fatal(1, "set_union", "Sets don't have the same length\n");
@@ -335,8 +335,8 @@
set_intersec(ARGIN(const Set *s1), ARGIN(const Set *s2))
{
unsigned int i;
- ASSERT_ARGS(set_intersec);
Set * const s = set_make(s1->length);
+ ASSERT_ARGS(set_intersec);
if (s1->length != s2->length)
fatal(1, "set_intersec", "Sets don't have the same length\n");
Modified: branches/assert_args/src/charset.c
==============================================================================
--- branches/assert_args/src/charset.c (original)
+++ branches/assert_args/src/charset.c Fri Jan 2 19:47:29 2009
@@ -116,8 +116,8 @@
Parrot_charsets_encodings_deinit(SHIM_INTERP)
{
int i;
- ASSERT_ARGS(Parrot_charsets_encodings_deinit);
const int n = all_charsets->n_charsets;
+ ASSERT_ARGS(Parrot_charsets_encodings_deinit);
for (i = 0; i < n; ++i) {
if (all_charsets->set[i].n_converters)
@@ -148,8 +148,8 @@
Parrot_find_charset(SHIM_INTERP, ARGIN(const char *charsetname))
{
int i;
- ASSERT_ARGS(Parrot_find_charset);
const int n = all_charsets->n_charsets;
+ ASSERT_ARGS(Parrot_find_charset);
for (i = 0; i < n; ++i) {
if (STREQ(all_charsets->set[i].charset->name, charsetname)) {
@@ -198,8 +198,8 @@
Parrot_charset_number(PARROT_INTERP, ARGIN(const STRING *charsetname))
{
int i;
- ASSERT_ARGS(Parrot_charset_number);
const int n = all_charsets->n_charsets;
+ ASSERT_ARGS(Parrot_charset_number);
for (i = 0; i < n; ++i) {
if (!string_equal(interp, all_charsets->set[i].name, charsetname))
@@ -224,8 +224,8 @@
Parrot_charset_number_of_str(SHIM_INTERP, ARGIN(const STRING *src))
{
int i;
- ASSERT_ARGS(Parrot_charset_number_of_str);
const int n = all_charsets->n_charsets;
+ ASSERT_ARGS(Parrot_charset_number_of_str);
for (i = 0; i < n; ++i) {
if (src->charset == all_charsets->set[i].charset)
@@ -319,8 +319,8 @@
ARGIN(CHARSET *charset))
{
int i;
- ASSERT_ARGS(register_charset);
const int n = all_charsets->n_charsets;
+ ASSERT_ARGS(register_charset);
for (i = 0; i < n; ++i) {
if (STREQ(all_charsets->set[i].charset->name, charsetname))
@@ -528,8 +528,8 @@
ARGIN(const CHARSET *lhs), ARGIN(const CHARSET *rhs))
{
int i;
- ASSERT_ARGS(Parrot_find_charset_converter);
const int n = all_charsets->n_charsets;
+ ASSERT_ARGS(Parrot_find_charset_converter);
for (i = 0; i < n; ++i) {
if (lhs == all_charsets->set[i].charset) {
@@ -563,8 +563,8 @@
ARGIN(charset_converter_t func))
{
int i;
- ASSERT_ARGS(Parrot_register_charset_converter);
const int n = all_charsets->n_charsets;
+ ASSERT_ARGS(Parrot_register_charset_converter);
for (i = 0; i < n; ++i) {
if (lhs == all_charsets->set[i].charset) {
Modified: branches/assert_args/src/embed.c
==============================================================================
--- branches/assert_args/src/embed.c (original)
+++ branches/assert_args/src/embed.c Fri Jan 2 19:47:29 2009
@@ -836,11 +836,11 @@
{
opcode_t i;
PMC *sub_pmc;
- ASSERT_ARGS(set_current_sub);
PackFile_ByteCode * const cur_cs = interp->code;
PackFile_FixupTable * const ft = cur_cs->fixups;
PackFile_ConstTable * const ct = cur_cs->const_table;
+ ASSERT_ARGS(set_current_sub);
/*
* Walk the fixup table. The first Sub-like entry should be our
Modified: branches/assert_args/src/inter_run.c
==============================================================================
--- branches/assert_args/src/inter_run.c (original)
+++ branches/assert_args/src/inter_run.c Fri Jan 2 19:47:29 2009
@@ -64,11 +64,11 @@
void
runops(PARROT_INTERP, size_t offs)
{
- ASSERT_ARGS(runops);
volatile size_t offset = offs;
const int old_runloop_id = interp->current_runloop_id;
const int our_runloop_level = ++interp->current_runloop_level;
const int our_runloop_id = ++runloop_id_counter;
+ ASSERT_ARGS(runops);
/* It is OK if the runloop ID overflows; we only ever test it for equality,
so the chance of collision is slight. */
@@ -139,10 +139,10 @@
{
opcode_t offset, *dest;
Parrot_Context *ctx;
- ASSERT_ARGS(Parrot_runops_fromc);
/* we need one return continuation with a NULL offset */
PMC * const ret_c = new_ret_continuation_pmc(interp, NULL);
+ ASSERT_ARGS(Parrot_runops_fromc);
interp->current_cont = ret_c;
#if defined GC_VERBOSE && GC_VERBOSE
PObj_report_SET(ret_c); /* s. also dod.c */
@@ -197,8 +197,8 @@
char new_sig[10];
const char *sig_p;
- ASSERT_ARGS(runops_args);
Parrot_Context * const old_ctx = CONTEXT(interp);
+ ASSERT_ARGS(runops_args);
interp->current_cont = new_ret_continuation_pmc(interp, NULL);
interp->current_object = obj;
@@ -340,7 +340,6 @@
va_list args;
Parrot_Context *ctx;
void *retval;
- ASSERT_ARGS(Parrot_runops_fromc_args_event);
/*
* running code from event handlers isn't fully reentrant due to
* these interpreter variables - mainly related to calls
@@ -350,6 +349,7 @@
opcode_t * const returns = interp->current_returns;
PMC * const cont = interp->current_cont;
/* what else ? */
+ ASSERT_ARGS(Parrot_runops_fromc_args_event);
va_start(args, sig);
ctx = runops_args(interp, sub, PMCNULL, NULL, sig, args);
@@ -540,8 +540,8 @@
ARGIN(const char *sig), va_list args)
{
void* retval;
- ASSERT_ARGS(Parrot_runops_fromc_arglist);
Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig,
args);
+ ASSERT_ARGS(Parrot_runops_fromc_arglist);
retval = set_retval(interp, *sig, ctx);
Parrot_free_context(interp, ctx, 1);
@@ -567,8 +567,8 @@
ARGIN(const char *sig), va_list args)
{
INTVAL retval;
- ASSERT_ARGS(Parrot_runops_fromc_arglist_reti);
Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig,
args);
+ ASSERT_ARGS(Parrot_runops_fromc_arglist_reti);
retval = set_retval_i(interp, *sig, ctx);
Parrot_free_context(interp, ctx, 1);
@@ -594,8 +594,8 @@
ARGIN(const char *sig), va_list args)
{
FLOATVAL retval;
- ASSERT_ARGS(Parrot_runops_fromc_arglist_retf);
Parrot_Context * const ctx = runops_args(interp, sub, PMCNULL, NULL, sig,
args);
+ ASSERT_ARGS(Parrot_runops_fromc_arglist_retf);
retval = set_retval_f(interp, *sig, ctx);
Parrot_free_context(interp, ctx, 1);
@@ -652,8 +652,8 @@
ARGIN(STRING *meth), ARGIN(const char *sig), va_list args)
{
INTVAL retval;
- ASSERT_ARGS(Parrot_run_meth_fromc_arglist_reti);
Parrot_Context * const ctx = runops_args(interp, sub, obj, meth, sig,
args);
+ ASSERT_ARGS(Parrot_run_meth_fromc_arglist_reti);
retval = set_retval_i(interp, *sig, ctx);
Parrot_free_context(interp, ctx, 1);
@@ -680,8 +680,8 @@
ARGIN(STRING *meth), ARGIN(const char *sig), va_list args)
{
FLOATVAL retval;
- ASSERT_ARGS(Parrot_run_meth_fromc_arglist_retf);
Parrot_Context * const ctx = runops_args(interp, sub, obj, meth, sig,
args);
+ ASSERT_ARGS(Parrot_run_meth_fromc_arglist_retf);
retval = set_retval_f(interp, *sig, ctx);
Parrot_free_context(interp, ctx, 1);
@@ -737,8 +737,8 @@
void
free_runloop_jump_point(PARROT_INTERP)
{
- ASSERT_ARGS(free_runloop_jump_point);
Parrot_runloop * const jump_point = interp->current_runloop;
+ ASSERT_ARGS(free_runloop_jump_point);
interp->current_runloop = jump_point->prev;
jump_point->prev = interp->runloop_jmp_free_list;
interp->runloop_jmp_free_list = jump_point;
Modified: branches/assert_args/src/pbc_merge.c
==============================================================================
--- branches/assert_args/src/pbc_merge.c (original)
+++ branches/assert_args/src/pbc_merge.c Fri Jan 2 19:47:29 2009
@@ -233,7 +233,6 @@
INTVAL program_size, wanted;
char *program_code;
PackFile *pf;
- ASSERT_ARGS(pbc_merge_loadpbc);
FILE * io = NULL;
INTVAL is_mapped = 0;
size_t chunk_size;
@@ -243,6 +242,7 @@
/* Check the file exists. */
STRING * const fs = string_make(interp, fullname,
strlen(fullname), NULL, 0);
+ ASSERT_ARGS(pbc_merge_loadpbc);
if (!Parrot_stat_info_intval(interp, fs, STAT_EXISTS)) {
Parrot_io_eprintf(interp, "PBC Merge: Can't stat %s, code %i.\n",
fullname, errno);
@@ -323,7 +323,6 @@
int num_inputs, ARGMOD(PackFile *pf))
{
int i;
- ASSERT_ARGS(pbc_merge_bytecode);
opcode_t *bc = mem_allocate_typed(opcode_t);
opcode_t cursor = 0;
@@ -331,6 +330,7 @@
PackFile_ByteCode * const bc_seg =
(PackFile_ByteCode *)PackFile_Segment_new_seg(interp,
&pf->directory, PF_BYTEC_SEG, BYTE_CODE_SEGMENT_NAME, 1);
+ ASSERT_ARGS(pbc_merge_bytecode);
if (bc_seg == NULL) {
Parrot_io_eprintf(interp, "PBC Merge: Error creating bytecode
segment.");
Parrot_exit(interp, 1);
@@ -388,13 +388,13 @@
int num_inputs, ARGMOD(PackFile *pf),
ARGMOD(PackFile_ByteCode *bc))
{
int i, j;
- ASSERT_ARGS(pbc_merge_constants);
PackFile_Constant **constants = mem_allocate_typed(PackFile_Constant *);
opcode_t cursor = 0;
/* Add a constant table segment. */
PackFile_ConstTable * const const_seg =
(PackFile_ConstTable*)PackFile_Segment_new_seg(
interp, &pf->directory, PF_CONST_SEG, CONSTANT_SEGMENT_NAME, 1);
+ ASSERT_ARGS(pbc_merge_constants);
if (const_seg == NULL) {
Parrot_io_eprintf(interp,
"PBC Merge: Error creating constant table segment.");
@@ -484,10 +484,10 @@
int num_inputs, ARGMOD(PackFile *pf),
ARGMOD(PackFile_ByteCode *bc))
{
int i, j;
- ASSERT_ARGS(pbc_merge_fixups);
PackFile_FixupTable *fixup_seg;
PackFile_FixupEntry **fixups = mem_allocate_typed(PackFile_FixupEntry *);
opcode_t cursor = 0;
+ ASSERT_ARGS(pbc_merge_fixups);
/* Add a fixup table segment. */
fixup_seg = (PackFile_FixupTable*)PackFile_Segment_new_seg(
@@ -580,13 +580,13 @@
int num_inputs, ARGMOD(PackFile *pf),
ARGMOD(PackFile_ByteCode *bc))
{
int i, j;
- ASSERT_ARGS(pbc_merge_debugs);
PackFile_Debug *debug_seg;
opcode_t *lines = mem_allocate_typed(opcode_t);
PackFile_DebugMapping **mappings =
mem_allocate_typed(PackFile_DebugMapping *);
opcode_t num_mappings = 0;
opcode_t num_lines = 0;
+ ASSERT_ARGS(pbc_merge_debugs);
/* We need to merge both the mappings and the list of line numbers.
The line numbers can just be concatenated. The mappings must have
@@ -653,10 +653,10 @@
int i;
PackFile_Segment *pic_index;
size_t size;
- ASSERT_ARGS(pbc_merge_pic_index);
opcode_t cursor = 0;
opcode_t start = 0;
opcode_t last = 0;
+ ASSERT_ARGS(pbc_merge_pic_index);
/* calc needed size */
for (i = 0, size = 0; i < num_inputs; i++) {
@@ -705,10 +705,10 @@
{
int cur_arg;
opcode_t *op_ptr;
- ASSERT_ARGS(pbc_merge_ctpointers);
opcode_t *ops = bc->base.data;
opcode_t cur_op = 0;
int cur_input = 0;
+ ASSERT_ARGS(pbc_merge_ctpointers);
/* Loop over the ops in the merged bytecode. */
while (cur_op < (opcode_t)bc->base.size) {
@@ -788,10 +788,10 @@
{
PackFile_ByteCode *bc;
PackFile_ConstTable *ct;
- ASSERT_ARGS(pbc_merge_begin);
/* Create a new empty packfile. */
PackFile * const merged = PackFile_new(interp, 0);
+ ASSERT_ARGS(pbc_merge_begin);
if (merged == NULL) {
Parrot_io_eprintf(interp, "PBC Merge: Error creating new packfile.\n");
Parrot_exit(interp, 1);
@@ -827,7 +827,6 @@
static void
pbc_merge_write(PARROT_INTERP, ARGMOD(PackFile *pf), ARGIN(const char
*filename))
{
- ASSERT_ARGS(pbc_merge_write);
FILE *fp;
/* Get size of packfile we'll write. */
@@ -835,6 +834,7 @@
/* Allocate memory. */
opcode_t * const pack = (opcode_t*) mem_sys_allocate(size);
+ ASSERT_ARGS(pbc_merge_write);
if (pack == NULL) {
Parrot_io_eprintf(interp, "PBC Merge: Out of memory");
Parrot_exit(interp, 1);
Modified: branches/assert_args/src/pic.c
==============================================================================
--- branches/assert_args/src/pic.c (original)
+++ branches/assert_args/src/pic.c Fri Jan 2 19:47:29 2009
@@ -251,7 +251,6 @@
{
Parrot_PIC_store *store;
size_t size;
- ASSERT_ARGS(parrot_PIC_alloc_store);
/*
* estimated 95% of calls are monomorphic, 5% are polymorphic
@@ -259,6 +258,7 @@
*/
#define POLYMORPHIC 0.05
size_t poly = (size_t)(n * POLYMORPHIC) * sizeof (Parrot_PIC);
+ ASSERT_ARGS(parrot_PIC_alloc_store);
if (!poly)
poly = 2 * sizeof (Parrot_PIC);
@@ -287,8 +287,8 @@
void
parrot_PIC_destroy(ARGMOD(PackFile_ByteCode *cs))
{
- ASSERT_ARGS(parrot_PIC_destroy);
Parrot_PIC_store *store = cs->pic_store;
+ ASSERT_ARGS(parrot_PIC_destroy);
while (store) {
Parrot_PIC_store * const prev = store->prev;
@@ -340,8 +340,8 @@
Parrot_MIC*
parrot_PIC_alloc_mic(const PARROT_INTERP, size_t n)
{
- ASSERT_ARGS(parrot_PIC_alloc_mic);
Parrot_PIC_store * const store = interp->code->pic_store;
+ ASSERT_ARGS(parrot_PIC_alloc_mic);
PARROT_ASSERT(n < store->n_mics);
return store->mic + n;
}
@@ -362,9 +362,9 @@
Parrot_PIC*
parrot_PIC_alloc_pic(PARROT_INTERP)
{
- ASSERT_ARGS(parrot_PIC_alloc_pic);
Parrot_PIC_store *store = interp->code->pic_store;
Parrot_PIC_store *new_store;
+ ASSERT_ARGS(parrot_PIC_alloc_pic);
if (store->usable < sizeof (Parrot_PIC)) {
size_t size =
@@ -407,11 +407,11 @@
void *
parrot_pic_opcode(PARROT_INTERP, INTVAL op)
{
- ASSERT_ARGS(parrot_pic_opcode);
#ifdef HAVE_COMPUTED_GOTO
op_lib_t *cg_lib;
#endif
const int core = interp->run_core;
+ ASSERT_ARGS(parrot_pic_opcode);
if (core == PARROT_SWITCH_CORE || core == PARROT_SWITCH_JIT_CORE)
return (void *)op;
@@ -438,8 +438,8 @@
ARGIN(const void **src), ARGOUT(char *dest_base), ARGIN(void * const
*dest))
{
int i;
- ASSERT_ARGS(pass_int);
int n = SIG_ELEMS(sig);
+ ASSERT_ARGS(pass_int);
for (i = 2; n; ++i, --n) {
const INTVAL arg = *(const INTVAL *)(src_base + ((const
opcode_t*)src)[i]);
@@ -463,8 +463,8 @@
ARGIN(const void **src), ARGOUT(char *dest_base), ARGIN(void * const
*dest))
{
int i;
- ASSERT_ARGS(pass_num);
int n = SIG_ELEMS(sig);
+ ASSERT_ARGS(pass_num);
for (i = 2; n; ++i, --n) {
const FLOATVAL arg = *(const FLOATVAL *)(src_base + ((const
opcode_t*)src)[i]);
@@ -488,8 +488,8 @@
ARGIN(const void **src), ARGOUT(char *dest_base), ARGIN(void * const
*dest))
{
int i;
- ASSERT_ARGS(pass_str);
int n = SIG_ELEMS(sig);
+ ASSERT_ARGS(pass_str);
for (i = 2; n; ++i, --n) {
STRING * const arg = *(STRING* const *)(src_base + ((const
opcode_t*)src)[i]);
@@ -514,8 +514,8 @@
ARGIN(const void **src), ARGOUT(char *dest_base), ARGIN(void * const
*dest))
{
int i;
- ASSERT_ARGS(pass_pmc);
int n = SIG_ELEMS(sig);
+ ASSERT_ARGS(pass_pmc);
for (i = 2; n; ++i, --n) {
PMC * const arg = *(PMC* const *)(src_base + ((const
opcode_t*)src)[i]);
@@ -540,8 +540,8 @@
{
int i;
INTVAL *bitp;
- ASSERT_ARGS(pass_mixed);
int n = SIG_ELEMS(sig);
+ ASSERT_ARGS(pass_mixed);
ASSERT_SIG_PMC(sig);
bitp = SIG_ARRAY(sig);
@@ -692,13 +692,13 @@
static int
is_pic_param(PARROT_INTERP, ARGIN(void **pc), ARGOUT(Parrot_MIC *mic),
opcode_t op)
{
- ASSERT_ARGS(is_pic_param);
PMC *sig2;
Parrot_Context *caller_ctx;
opcode_t *args;
PMC * const sig1 = (PMC *)(pc[1]);
const Parrot_Context * const ctx = CONTEXT(interp);
int type = 0;
+ ASSERT_ARGS(is_pic_param);
/* check params */
@@ -794,13 +794,13 @@
* pc is at set_args
*/
- ASSERT_ARGS(is_pic_func);
PMC *sub, *sig_results;
opcode_t *op, n;
int flags;
Parrot_Context * const ctx = CONTEXT(interp);
PMC * const sig_args = (PMC *)(pc[1]);
+ ASSERT_ARGS(is_pic_func);
ASSERT_SIG_PMC(sig_args);
n = SIG_ELEMS(sig_args);
@@ -853,10 +853,10 @@
void
parrot_PIC_prederef(PARROT_INTERP, opcode_t op, ARGOUT(void **pc_pred), int
core)
{
- ASSERT_ARGS(parrot_PIC_prederef);
op_func_t * const prederef_op_func = interp->op_lib->op_func_table;
opcode_t * const cur_opcode = (opcode_t *)pc_pred;
Parrot_MIC *mic = NULL;
+ ASSERT_ARGS(parrot_PIC_prederef);
if (parrot_PIC_op_is_cached(op)) {
const PackFile_ByteCode * const cs = interp->code;