Fixing style according to rules defined in vera++ scripts.

This commit is contained in:
Ruben Ayrapetyan 2015-02-17 19:47:00 +03:00
parent 88353e93cf
commit f42faabe89
12 changed files with 185 additions and 173 deletions

View File

@ -143,7 +143,7 @@ jerry_run (jerry_ctx_t* ctx_p) /**< run context */
/* FIXME: Remove after implementation of run contexts */
(void) ctx_p;
return run_int();
return run_int ();
} /* jerry_run */
/**

View File

@ -61,7 +61,8 @@
putchar (' '); \
} \
printf ("^\n"); \
printf ("SORRY, Unimplemented: Ln %lu, Col %lu: %s\n", (unsigned long) (line + 1), (unsigned long) (column + 1), MESSAGE); \
printf ("SORRY, Unimplemented: Ln %lu, Col %lu: %s\n", \
(unsigned long) (line + 1), (unsigned long) (column + 1), MESSAGE); \
JERRY_UNIMPLEMENTED ("Unimplemented parser feature."); \
} while (0)
#else /* JERRY_NDEBUG */

View File

@ -52,7 +52,7 @@ libc_fatal (const char *msg,
libc_fatal ("Code is unreachable", __FILE__, __FUNCTION__, __LINE__); \
} while (0)
#else /* !LIBC_NDEBUG */
# define LIBC_ASSERT(x) do { if (false) { (void)(x); } } while (0)
# define LIBC_ASSERT(x) do { if (false) { (void) (x); } } while (0)
# define LIBC_UNREACHABLE() \
do \
{ \

View File

@ -36,8 +36,8 @@ libc_fatal (const char *msg, /**< fatal error description */
&& file_name != NULL
&& function_name != NULL)
{
printf("Assertion '%s' failed at %s (%s:%u).\n",
msg, function_name, file_name, line_number);
printf ("Assertion '%s' failed at %s (%s:%u).\n",
msg, function_name, file_name, line_number);
}
exit (LIBC_FATAL_ERROR_EXIT_CODE);

View File

@ -123,7 +123,7 @@ putchar (int c)
* Output specified string
*/
int
puts(const char *s) /**< string to print */
puts (const char *s) /**< string to print */
{
while (*s)
{

View File

@ -26,7 +26,8 @@
#define LP(s) create_literal_from_str_compute_len (s)
#define NUM(s) create_literal_from_num (s)
static uint8_t opcode_sizes[] = {
static uint8_t opcode_sizes[] =
{
OP_LIST (OPCODE_SIZE)
0
};
@ -38,21 +39,29 @@ opcodes_equal (const opcode_t *opcodes1, opcode_t *opcodes2, uint16_t size)
{
uint16_t i;
for (i = 0; i < size; i++)
{
uint8_t opcode_num1 = opcodes1[i].op_idx, opcode_num2 = opcodes2[i].op_idx;
uint8_t j;
if (opcode_num1 != opcode_num2)
{
uint8_t opcode_num1 = opcodes1[i].op_idx, opcode_num2 = opcodes2[i].op_idx;
uint8_t j;
if (opcode_num1 != opcode_num2)
return false;
if (opcode_num1 == NAME_TO_ID (nop) || opcode_num1 == NAME_TO_ID (ret))
return true;
for (j = 1; j < opcode_sizes[opcode_num1]; j++)
if (((uint8_t*)&opcodes1[i])[j] != ((uint8_t*)&opcodes2[i])[j])
return false;
return false;
}
if (opcode_num1 == NAME_TO_ID (nop) || opcode_num1 == NAME_TO_ID (ret))
{
return true;
}
for (j = 1; j < opcode_sizes[opcode_num1]; j++)
{
if (((uint8_t*)&opcodes1[i])[j] != ((uint8_t*)&opcodes2[i])[j])
{
return false;
}
}
}
return true;
}

View File

@ -66,13 +66,13 @@ test_heap_give_some_memory_back (mem_try_give_memory_back_severity_t severity)
for (int i = 0; i < test_sub_iters; i++)
{
if (rand() % p == 0)
if (rand () % p == 0)
{
if (ptrs[i] != NULL)
{
for( size_t k = 0; k < sizes[i]; k++ )
for (size_t k = 0; k < sizes[i]; k++)
{
JERRY_ASSERT( ptrs[i][k] == 0 );
JERRY_ASSERT (ptrs[i][k] == 0);
}
mem_heap_free_block (ptrs[i]);
@ -83,72 +83,72 @@ test_heap_give_some_memory_back (mem_try_give_memory_back_severity_t severity)
} /* test_heap_give_some_memory_back */
int
main( int __attr_unused___ argc,
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
uint8_t test_native_heap[test_heap_size];
uint8_t test_native_heap[test_heap_size];
mem_heap_init( test_native_heap, sizeof (test_native_heap));
mem_heap_init (test_native_heap, sizeof (test_native_heap));
srand((unsigned int) time(NULL));
int k = rand();
printf("seed=%d\n", k);
srand((unsigned int) k);
srand ((unsigned int) time (NULL));
int k = rand ();
printf ("seed=%d\n", k);
srand ((unsigned int) k);
mem_register_a_try_give_memory_back_callback (test_heap_give_some_memory_back);
mem_register_a_try_give_memory_back_callback (test_heap_give_some_memory_back);
mem_heap_print (true, false, true);
mem_heap_print (true, false, true);
for ( uint32_t i = 0; i < test_iters; i++ )
for (uint32_t i = 0; i < test_iters; i++)
{
for (uint32_t j = 0; j < test_sub_iters; j++)
{
for ( uint32_t j = 0; j < test_sub_iters; j++ )
size_t size = (size_t) rand () % test_threshold_block_size;
ptrs[j] = (uint8_t*) mem_heap_alloc_block (size,
(rand () % 2) ?
MEM_HEAP_ALLOC_SHORT_TERM : MEM_HEAP_ALLOC_SHORT_TERM);
sizes[j] = size;
JERRY_ASSERT (size == 0 || ptrs[j] != NULL);
memset (ptrs[j], 0, sizes[j]);
}
// mem_heap_print (true);
for (uint32_t j = 0; j < test_sub_iters; j++)
{
if (ptrs[j] != NULL && (rand () % 2) == 0)
{
size_t size = (unsigned int) rand() % ( test_threshold_block_size );
ptrs[j] = (uint8_t*) mem_heap_alloc_block (size,
(rand() % 2) ?
MEM_HEAP_ALLOC_SHORT_TERM : MEM_HEAP_ALLOC_SHORT_TERM);
sizes[j] = size;
JERRY_ASSERT(size == 0 || ptrs[j] != NULL);
memset(ptrs[j], 0, sizes[j]);
}
// mem_heap_print( true);
for ( uint32_t j = 0; j < test_sub_iters; j++ )
{
if ( ptrs[j] != NULL && (rand () % 2) == 0 )
for (size_t k = 0; k < sizes[j]; k++)
{
for( size_t k = 0; k < sizes[j]; k++ )
{
JERRY_ASSERT(ptrs[j][k] == 0);
}
size_t new_size = (unsigned int) rand() % ( test_threshold_block_size );
if (mem_heap_try_resize_block (ptrs[j], new_size))
{
sizes[j] = new_size;
memset (ptrs[j], 0, sizes[j]);
}
JERRY_ASSERT(ptrs[j][k] == 0);
}
}
for ( uint32_t j = 0; j < test_sub_iters; j++ )
{
if ( ptrs[j] != NULL )
size_t new_size = (size_t) rand () % (test_threshold_block_size);
if (mem_heap_try_resize_block (ptrs[j], new_size))
{
for( size_t k = 0; k < sizes[j]; k++ )
{
JERRY_ASSERT( ptrs[j][k] == 0 );
}
mem_heap_free_block (ptrs[j]);
ptrs[j] = NULL;
sizes[j] = new_size;
memset (ptrs[j], 0, sizes[j]);
}
}
}
mem_heap_print( true, false, true);
for (uint32_t j = 0; j < test_sub_iters; j++)
{
if (ptrs[j] != NULL)
{
for (size_t k = 0; k < sizes[j]; k++)
{
JERRY_ASSERT(ptrs[j][k] == 0);
}
mem_heap_free_block (ptrs[j]);
ptrs[j] = NULL;
}
}
}
return 0;
mem_heap_print (true, false, true);
return 0;
} /* main */

View File

@ -24,7 +24,7 @@
* Unit test's main function.
*/
int
main( int __attr_unused___ argc,
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
const ecma_char_t* zt_strings[] =

View File

@ -35,61 +35,62 @@ const uint32_t test_iters = 64;
// Subiterations count
const uint32_t test_max_sub_iters = 1024;
#define TEST_POOL_SPACE_SIZE (sizeof (mem_pool_state_t) + (1ull << MEM_POOL_MAX_CHUNKS_NUMBER_LOG) * MEM_POOL_CHUNK_SIZE)
uint8_t test_pool [TEST_POOL_SPACE_SIZE] __attribute__((aligned(MEM_ALIGNMENT)));
#define TEST_POOL_SPACE_SIZE (sizeof (mem_pool_state_t) + \
(1ull << MEM_POOL_MAX_CHUNKS_NUMBER_LOG) * MEM_POOL_CHUNK_SIZE)
uint8_t test_pool [TEST_POOL_SPACE_SIZE] __attribute__ ((aligned (MEM_ALIGNMENT)));
uint8_t* ptrs[test_max_sub_iters];
int
main( int __attr_unused___ argc,
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
srand((unsigned int) time(NULL));
int k = rand();
printf("seed=%d\n", k);
srand((unsigned int) k);
srand ((unsigned int) time (NULL));
int k = rand ();
printf ("seed=%d\n", k);
srand ((unsigned int) k);
for ( uint32_t i = 0; i < test_iters; i++ )
for (uint32_t i = 0; i < test_iters; i++)
{
mem_pool_state_t* pool_p = (mem_pool_state_t*) test_pool;
JERRY_ASSERT (MEM_POOL_SIZE <= TEST_POOL_SPACE_SIZE);
mem_pool_init (pool_p, MEM_POOL_SIZE);
const size_t subiters = ((size_t) rand () % test_max_sub_iters) + 1;
for (size_t j = 0; j < subiters; j++)
{
mem_pool_state_t* pool_p = (mem_pool_state_t*) test_pool;
if (pool_p->free_chunks_number != 0)
{
ptrs[j] = mem_pool_alloc_chunk (pool_p);
JERRY_ASSERT (MEM_POOL_SIZE <= TEST_POOL_SPACE_SIZE);
memset (ptrs[j], 0, MEM_POOL_CHUNK_SIZE);
}
else
{
JERRY_ASSERT (j >= MEM_POOL_CHUNKS_NUMBER);
mem_pool_init (pool_p, MEM_POOL_SIZE);
const size_t subiters = ( (size_t) rand() % test_max_sub_iters ) + 1;
for ( size_t j = 0; j < subiters; j++ )
{
if (pool_p->free_chunks_number != 0)
{
ptrs[j] = mem_pool_alloc_chunk( pool_p);
memset(ptrs[j], 0, MEM_POOL_CHUNK_SIZE);
}
else
{
JERRY_ASSERT (j >= MEM_POOL_CHUNKS_NUMBER);
ptrs[j] = NULL;
}
}
// mem_heap_print( true);
for ( size_t j = 0; j < subiters; j++ )
{
if ( ptrs[j] != NULL )
{
for ( size_t k = 0; k < MEM_POOL_CHUNK_SIZE; k++ )
{
JERRY_ASSERT( ((uint8_t*)ptrs[j])[k] == 0 );
}
mem_pool_free_chunk( pool_p, ptrs[j]);
}
}
ptrs[j] = NULL;
}
}
return 0;
// mem_heap_print (true);
for (size_t j = 0; j < subiters; j++)
{
if (ptrs[j] != NULL)
{
for (size_t k = 0; k < MEM_POOL_CHUNK_SIZE; k++)
{
JERRY_ASSERT(((uint8_t*)ptrs[j])[k] == 0);
}
mem_pool_free_chunk (pool_p, ptrs[j]);
}
}
}
return 0;
} /* main */

View File

@ -38,64 +38,64 @@ const uint32_t test_max_sub_iters = 32;
uint8_t *ptrs[test_max_sub_iters];
int
main( int __attr_unused___ argc,
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
mem_init();
mem_init ();
srand((unsigned int) time(NULL));
unsigned int seed = (unsigned int)rand();
printf("seed=%u\n", seed);
srand(seed);
srand ((unsigned int) time (NULL));
unsigned int seed = (unsigned int) rand ();
printf ("seed=%u\n", seed);
srand (seed);
for ( uint32_t i = 0; i < test_iters; i++ )
for (uint32_t i = 0; i < test_iters; i++)
{
const size_t subiters = ((size_t) rand () % test_max_sub_iters) + 1;
for (size_t j = 0; j < subiters; j++)
{
const size_t subiters = ( (size_t) rand() % test_max_sub_iters ) + 1;
ptrs[j] = mem_pools_alloc ();
// JERRY_ASSERT(ptrs[j] != NULL);
for ( size_t j = 0; j < subiters; j++ )
{
ptrs[j] = mem_pools_alloc();
// JERRY_ASSERT(ptrs[j] != NULL);
if ( ptrs[j] != NULL )
{
memset(ptrs[j], 0, MEM_POOL_CHUNK_SIZE);
}
}
// mem_heap_print( false);
for ( size_t j = 0; j < subiters; j++ )
{
if ( ptrs[j] != NULL )
{
for ( size_t k = 0; k < MEM_POOL_CHUNK_SIZE; k++ )
{
JERRY_ASSERT( ((uint8_t*) ptrs[j])[k] == 0 );
}
mem_pools_free( ptrs[j]);
}
}
if (ptrs[j] != NULL)
{
memset (ptrs[j], 0, MEM_POOL_CHUNK_SIZE);
}
}
// mem_heap_print (false);
for (size_t j = 0; j < subiters; j++)
{
if (ptrs[j] != NULL)
{
for (size_t k = 0; k < MEM_POOL_CHUNK_SIZE; k++)
{
JERRY_ASSERT(((uint8_t*) ptrs[j])[k] == 0);
}
mem_pools_free (ptrs[j]);
}
}
}
#ifdef MEM_STATS
mem_pools_stats_t stats;
mem_pools_get_stats( &stats);
mem_pools_get_stats (&stats);
printf("Pools stats:\n");
printf(" Chunk size: %u\n"
" Pools: %lu\n"
" Allocated chunks: %lu\n"
" Free chunks: %lu\n"
" Peak pools: %lu\n"
" Peak allocated chunks: %lu\n\n",
MEM_POOL_CHUNK_SIZE,
stats.pools_count,
stats.allocated_chunks,
stats.free_chunks,
stats.peak_pools_count,
stats.peak_allocated_chunks);
printf ("Pools stats:\n");
printf (" Chunk size: %u\n"
" Pools: %lu\n"
" Allocated chunks: %lu\n"
" Free chunks: %lu\n"
" Peak pools: %lu\n"
" Peak allocated chunks: %lu\n\n",
MEM_POOL_CHUNK_SIZE,
stats.pools_count,
stats.allocated_chunks,
stats.free_chunks,
stats.peak_pools_count,
stats.peak_allocated_chunks);
#endif /* MEM_STATS */
return 0;

View File

@ -26,7 +26,7 @@
* Unit test's main function.
*/
int
main( int __attr_unused___ argc,
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
char program[] = "a=1;var a;";
@ -38,15 +38,16 @@ main( int __attr_unused___ argc,
parser_parse_program ();
parser_free ();
opcode_t opcodes[] = {
opcode_t opcodes[] =
{
getop_reg_var_decl (128, 129), // var tmp128 .. tmp129;
getop_var_decl (0), // var a;
getop_assignment (129, 1, 1), // tmp129 = 1: SMALLINT;
getop_assignment (0, 6, 129), // a = tmp129 : TYPEOF(tmp129);
getop_exitval (0) // exit 0;
getop_var_decl (0), // var a;
getop_assignment (129, 1, 1), // tmp129 = 1: SMALLINT;
getop_assignment (0, 6, 129), // a = tmp129 : TYPEOF(tmp129);
getop_exitval (0) // exit 0;
};
if (!opcodes_equal((const opcode_t *) deserialize_bytecode (), opcodes, 5))
if (!opcodes_equal ((const opcode_t *) deserialize_bytecode (), opcodes, 5))
{
is_ok = false;
}

View File

@ -23,7 +23,7 @@
* Unit test's main function.
*/
int
main( int __attr_unused___ argc,
main (int __attr_unused___ argc,
char __attr_unused___ **argv)
{
const ecma_char_t* zt_strings[] =