Rename Jerry's libc functions: __function_name -> function_name.

This commit is contained in:
Ruben Ayrapetyan 2015-02-12 20:15:56 +03:00
parent af77eac8e4
commit 7e4c16e4e6
36 changed files with 484 additions and 532 deletions

View File

@ -75,7 +75,7 @@ static void
libc_printf_putchar (_FILE *stream, /**< stream pointer */
char character) /**< character */
{
__fwrite (&character, 1, sizeof (character), stream);
fwrite (&character, 1, sizeof (character), stream);
} /* libc_printf_putchar */
/**
@ -88,7 +88,7 @@ libc_printf_justified_string_output (_FILE *stream, /**< stream pointer */
bool is_left_justify, /**< justify to left (true) or right (false) */
bool is_zero_padding) /**< left-pad with zeroes (true) or spaces (false) */
{
const size_t str_length = __strlen (string_p);
const size_t str_length = strlen (string_p);
size_t outputted_length = 0;
@ -103,7 +103,7 @@ libc_printf_justified_string_output (_FILE *stream, /**< stream pointer */
}
}
__fwrite (string_p, 1, str_length * sizeof (*string_p), stream);
fwrite (string_p, 1, str_length * sizeof (*string_p), stream);
outputted_length += str_length;
if (is_left_justify)
@ -476,7 +476,7 @@ libc_printf_write_u_o_x_X(_FILE *stream, /**< stream pointer */
* @return number of characters printed
*/
static int
__vfprintf (_FILE *stream, /**< stream pointer */
vfprintf (_FILE *stream, /**< stream pointer */
const char *format, /**< format string */
va_list args) /**< arguments */
{
@ -696,7 +696,7 @@ __vfprintf (_FILE *stream, /**< stream pointer */
if (value == NULL)
{
__printf ("(nil)");
printf ("(nil)");
}
else
{
@ -725,7 +725,7 @@ __vfprintf (_FILE *stream, /**< stream pointer */
va_end (args_copy);
return 0;
} /* __vfprintf */
} /* vfprintf */
/**
* fprintf
@ -733,7 +733,7 @@ __vfprintf (_FILE *stream, /**< stream pointer */
* @return number of characters printed
*/
int
__fprintf (_FILE *stream, /**< stream pointer */
fprintf (_FILE *stream, /**< stream pointer */
const char *format, /**< format string */
...) /**< parameters' values */
{
@ -741,12 +741,12 @@ __fprintf (_FILE *stream, /**< stream pointer */
va_start (args, format);
int ret = __vfprintf (stream, format, args);
int ret = vfprintf (stream, format, args);
va_end (args);
return ret;
} /* __fprintf */
} /* fprintf */
/**
* printf
@ -754,17 +754,17 @@ __fprintf (_FILE *stream, /**< stream pointer */
* @return number of characters printed
*/
int
__printf (const char *format, /**< format string */
printf (const char *format, /**< format string */
...) /**< parameters' values */
{
va_list args;
va_start (args, format);
int ret = __vfprintf (LIBC_STDOUT, format, args);
int ret = vfprintf (LIBC_STDOUT, format, args);
va_end (args);
return ret;
} /* __printf */
} /* printf */

View File

@ -20,26 +20,27 @@
#include "jerry-libc.h"
/**
* memcpy alias to __memcpy (for compiler usage)
* Unreachable stubs for routines that are never called,
* but referenced from third-party libraries.
*/
extern "C" void *memcpy (void *s1, const void*s2, size_t n);
#define JRT_UNREACHABLE_STUB_FOR(...) \
extern "C" __VA_ARGS__; \
__used __VA_ARGS__ \
{ \
JERRY_UNREACHABLE (); \
}
/**
* memset alias to __memset (for compiler usage)
*/
extern "C" void *memset (void *s, int c, size_t n);
JRT_UNREACHABLE_STUB_FOR(void abort (void))
JRT_UNREACHABLE_STUB_FOR(int raise (int sig_no __unused))
/**
* memmove alias to __memmove (for compiler usage)
*/
extern "C" void *memmove (void *s1, const void*s2, size_t n);
#undef JRT_UNREACHABLE_STUB_FOR
#ifdef __GNUC__
/*
* Making GCC not to replace:
* - __memcpy -> call to memcpy;
* - __memset -> call to memset;
* - __memmove -> call to memmove.
* - memcpy -> call to memcpy;
* - memset -> call to memset;
* - memmove -> call to memmove.
*/
CALL_PRAGMA(GCC diagnostic push)
CALL_PRAGMA(GCC diagnostic ignored "-Wpragmas")
@ -47,69 +48,15 @@ CALL_PRAGMA(GCC push_options)
CALL_PRAGMA(GCC optimize ("-fno-tree-loop-distribute-patterns"))
#endif /* __GNUC__ */
/**
* memcpy alias to __memcpy (for compiler usage)
*/
void* __used
memcpy (void *s1, /**< destination */
const void* s2, /**< source */
size_t n) /**< bytes number */
{
return __memcpy (s1, s2, n);
} /* memcpy */
/**
* memset alias to __memset (for compiler usage)
*/
void* __used
memset (void *s, /**< area to set values in */
int c, /**< value to set */
size_t n) /**< area size */
{
return __memset (s, c, n);
} /* memset */
/**
* memmove alias to __memmove (for compiler usage)
*/
void* __used
memmove (void *s1, /**< destination*/
const void*s2, /**< source */
size_t n) /**< area size */
{
return __memmove (s1, s2, n);
} /* memmove */
#ifdef __GNUC__
CALL_PRAGMA(GCC pop_options)
CALL_PRAGMA(GCC diagnostic pop)
#endif /* __GNUC__ */
/**
* Unreachable stubs for routines that are never called,
* but referenced from third-party libraries.
*/
#define JRT_UNREACHABLE_STUB_FOR(...) \
extern "C" __VA_ARGS__; \
__used __VA_ARGS__ \
{ \
JERRY_UNREACHABLE (); \
}
JRT_UNREACHABLE_STUB_FOR(void abort (void))
JRT_UNREACHABLE_STUB_FOR(int raise (int sig_no __unused))
#undef JRT_UNREACHABLE_STUB_FOR
/**
* memset
*
* @return @s
*/
void*
__memset (void *s, /**< area to set values in */
int c, /**< value to set */
size_t n) /**< area size */
memset (void *s, /**< area to set values in */
int c, /**< value to set */
size_t n) /**< area size */
{
uint8_t *area_p = (uint8_t *) s;
for (size_t index = 0; index < n; index++)
@ -118,7 +65,7 @@ __memset (void *s, /**< area to set values in */
}
return s;
} /* __memset */
} /* memset */
/**
* memcmp
@ -128,9 +75,9 @@ __memset (void *s, /**< area to set values in */
* 1, otherwise
*/
int
__memcmp (const void *s1, /**< first area */
const void *s2, /**< second area */
size_t n) /**< area size */
memcmp (const void *s1, /**< first area */
const void *s2, /**< second area */
size_t n) /**< area size */
{
const uint8_t *area1_p = (uint8_t *) s1, *area2_p = (uint8_t *) s2;
for (size_t index = 0; index < n; index++)
@ -146,15 +93,15 @@ __memcmp (const void *s1, /**< first area */
}
return 0;
} /* __memcmp */
} /* memcmp */
/**
* memcpy
*/
void *
__memcpy (void *s1, /**< destination */
const void *s2, /**< source */
size_t n) /**< bytes number */
memcpy (void *s1, /**< destination */
const void *s2, /**< source */
size_t n) /**< bytes number */
{
uint8_t *area1_p = (uint8_t *) s1;
const uint8_t *area2_p = (const uint8_t *) s2;
@ -165,7 +112,7 @@ __memcpy (void *s1, /**< destination */
}
return s1;
} /* __memcpy */
} /* memcpy */
/**
* memmove
@ -173,9 +120,9 @@ __memcpy (void *s1, /**< destination */
* @return the dest pointer's value
*/
void *
__memmove (void *s1, /**< destination */
const void *s2, /**< source */
size_t n) /**< bytes number */
memmove (void *s1, /**< destination */
const void *s2, /**< source */
size_t n) /**< bytes number */
{
uint8_t *dest_p = (uint8_t *) s1;
const uint8_t *src_p = (const uint8_t *) s2;
@ -196,12 +143,17 @@ __memmove (void *s1, /**< destination */
}
return s1;
} /* __memmove */
} /* memmove */
#ifdef __GNUC__
CALL_PRAGMA(GCC pop_options)
CALL_PRAGMA(GCC diagnostic pop)
#endif /* __GNUC__ */
/** Compare two strings. return an integer less than, equal to, or greater than zero
if s1 is found, respectively, to be less than, to match, or be greater than s2. */
int
__strcmp (const char *s1, const char *s2)
strcmp (const char *s1, const char *s2)
{
size_t i;
if (s1 == NULL)
@ -244,7 +196,7 @@ __strcmp (const char *s1, const char *s2)
if the first n character of s1 is found, respectively, to be less than, to match,
or be greater than the first n character of s2. */
int
__strncmp (const char *s1, const char *s2, size_t n)
strncmp (const char *s1, const char *s2, size_t n)
{
size_t i;
if (s1 == NULL)
@ -282,7 +234,7 @@ __strncmp (const char *s1, const char *s2, size_t n)
null byte among the first n bytes of src, the string placed in dest will not be null-terminated.
@return a pointer to the destination string dest. */
char *
__strncpy (char *dest, const char *src, size_t n)
strncpy (char *dest, const char *src, size_t n)
{
size_t i;
@ -300,7 +252,7 @@ __strncpy (char *dest, const char *src, size_t n)
/** Calculate the length of a string. */
size_t
__strlen (const char *s)
strlen (const char *s)
{
size_t i;
for (i = 0; s[i]; i++)
@ -314,7 +266,7 @@ __strlen (const char *s)
/** Checks for white-space characters. In the "C" and "POSIX" locales, these are: space,
form-feed ('\f'), newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). */
int
__isspace (int c)
isspace (int c)
{
switch (c)
{
@ -336,14 +288,14 @@ __isspace (int c)
/** Checks for an uppercase letter. */
int
__isupper (int c)
isupper (int c)
{
return c >= 'A' && c <= 'Z';
}
/** Checks for an lowercase letter. */
int
__islower (int c)
islower (int c)
{
return c >= 'a' && c <= 'z';
}
@ -351,14 +303,14 @@ __islower (int c)
/** Checks for an alphabetic character.
In the standard "C" locale, it is equivalent to (isupper (c) || islower (c)). */
int
__isalpha (int c)
isalpha (int c)
{
return __isupper (c) || __islower (c);
return isupper (c) || islower (c);
}
/** Checks for a digit (0 through 9). */
int
__isdigit (int c)
isdigit (int c)
{
return c >= '0' && c <= '9';
}
@ -366,7 +318,7 @@ __isdigit (int c)
/** checks for a hexadecimal digits, that is, one of
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F. */
int
__isxdigit (int c)
isxdigit (int c)
{
return __isdigit (c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
return isdigit (c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}

View File

@ -38,29 +38,29 @@ typedef void _FILE;
*/
#define LIBC_STDERR (_FILE*)2
extern void* __memset (void *s, int c, size_t n);
extern int __memcmp (const void *s1, const void *s2, size_t n);
extern void* __memcpy (void *s1, const void *s2, size_t n);
extern void* __memmove (void *dest, const void *src, size_t n);
extern int __printf (const char *format, ...);
extern int __putchar (int);
extern "C" void __noreturn __exit (int);
extern void* memset (void *s, int c, size_t n);
extern int memcmp (const void *s1, const void *s2, size_t n);
extern void* memcpy (void *s1, const void *s2, size_t n);
extern void* memmove (void *dest, const void *src, size_t n);
extern int printf (const char *format, ...);
extern int putchar (int);
extern "C" void __noreturn exit (int);
extern int __strcmp (const char *, const char *);
extern int __strncmp (const char *, const char *, size_t);
extern char* __strncpy (char *, const char *, size_t);
extern int strcmp (const char *, const char *);
extern int strncmp (const char *, const char *, size_t);
extern char* strncpy (char *, const char *, size_t);
extern float __strtof (const char *, char **);
extern size_t __strlen (const char *);
extern size_t strlen (const char *);
extern int __isspace (int);
extern int __isupper (int);
extern int __islower (int);
extern int __isalpha (int);
extern int __isdigit (int);
extern int __isxdigit (int);
extern int isspace (int);
extern int isupper (int);
extern int islower (int);
extern int isalpha (int);
extern int isdigit (int);
extern int isxdigit (int);
/**
* 'whence' argument of __fseek that identifies position
* 'whence' argument of fseek that identifies position
* the 'offset' argument is added to.
*/
typedef enum
@ -70,14 +70,14 @@ typedef enum
__SEEK_END /**< relative to end of file */
} _whence_t;
extern _FILE* __fopen (const char *, const char *);
extern int __fclose (_FILE *);
extern int __fseek (_FILE *, long offset, _whence_t);
extern long __ftell (_FILE *);
extern void __rewind (_FILE *);
extern size_t __fread (void *, size_t, size_t, _FILE *);
extern size_t __fwrite (const void *, size_t, size_t, _FILE *);
extern int __fprintf (_FILE *, const char *, ...);
extern _FILE* fopen (const char *, const char *);
extern int fclose (_FILE *);
extern int fseek (_FILE *, long offset, _whence_t);
extern long ftell (_FILE *);
extern void rewind (_FILE *);
extern size_t fread (void *, size_t, size_t, _FILE *);
extern size_t fwrite (const void *, size_t, size_t, _FILE *);
extern int fprintf (_FILE *, const char *, ...);
extern void jrt_set_mem_limits (size_t data_size, size_t stack_size);

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -72,7 +72,7 @@
add r1, sp, #4; \
bl main; \
\
bl __exit; \
bl exit; \
1: \
b 1b

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -62,7 +62,7 @@
callq main; \
\
mov %rax, %rdi; \
callq __exit; \
callq exit; \
1: \
jmp 1b

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -65,7 +65,7 @@ FIXME(Implement x86 ABI);
callq main; \
\
mov %rax, %rdi; \
callq __exit; \
callq exit; \
1: \
jmp 1b

View File

@ -120,18 +120,18 @@ syscall_3 (long int syscall_no, /**< syscall number */
/** Output of character. Writes the character c, cast to an unsigned char, to stdout. */
int
__putchar (int c)
putchar (int c)
{
__fwrite (&c, 1, sizeof (char), LIBC_STDOUT);
fwrite (&c, 1, sizeof (char), LIBC_STDOUT);
return c;
} /* __putchar */
} /* putchar */
/**
* Exit - cause normal process termination with specified status code
*/
void __noreturn
__exit (int status) /**< status code */
void __noreturn __used
exit (int status) /**< status code */
{
syscall_1 (__NR_close, (long int)LIBC_STDIN);
syscall_1 (__NR_close, (long int)LIBC_STDOUT);
@ -143,7 +143,7 @@ __exit (int status) /**< status code */
{
/* unreachable */
}
} /* __exit */
} /* exit */
/**
* fopen
@ -152,7 +152,7 @@ __exit (int status) /**< status code */
* NULL - otherwise
*/
_FILE*
__fopen (const char *path, /**< file path */
fopen (const char *path, /**< file path */
const char *mode) /**< file open mode */
{
bool may_read = false;
@ -233,17 +233,17 @@ __fopen (const char *path, /**< file path */
long int ret = syscall_3 (__NR_open, (long int) path, flags, access);
return (void*) (uintptr_t) (ret);
} /* __fopen */
} /* fopen */
/**
* The rewind () function sets the file position indicator
* for the stream pointed to by STREAM to the beginning of the file.
*/
void
__rewind (_FILE *stream) /**< stream pointer */
rewind (_FILE *stream) /**< stream pointer */
{
syscall_3 (__NR_lseek, (long int) stream, 0, SEEK_SET);
} /* __rewind */
} /* rewind */
/**
* fclose
@ -252,18 +252,18 @@ __rewind (_FILE *stream) /**< stream pointer */
* non-zero value - otherwise.
*/
int
__fclose (_FILE *fp) /**< stream pointer */
fclose (_FILE *fp) /**< stream pointer */
{
syscall_2 (__NR_close, (long int)fp, 0);
return 0;
} /* __fclose */
} /* fclose */
/**
* fseek
*/
int
__fseek (_FILE * fp, /**< stream pointer */
fseek (_FILE * fp, /**< stream pointer */
long offset, /**< offset */
_whence_t whence) /**< specifies position type
to add offset to */
@ -291,18 +291,18 @@ __fseek (_FILE * fp, /**< stream pointer */
syscall_3 (__NR_lseek, (long int)fp, offset, whence_real);
return 0;
} /* __fseek */
} /* fseek */
/**
* ftell
*/
long
__ftell (_FILE * fp) /**< stream pointer */
ftell (_FILE * fp) /**< stream pointer */
{
long int ret = syscall_3 (__NR_lseek, (long int)fp, 0, SEEK_CUR);
return ret;
} /* __ftell */
} /* ftell */
/**
* fread
@ -310,7 +310,7 @@ __ftell (_FILE * fp) /**< stream pointer */
* @return number of bytes read
*/
size_t
__fread (void *ptr, /**< address of buffer to read to */
fread (void *ptr, /**< address of buffer to read to */
size_t size, /**< size of elements to read */
size_t nmemb, /**< number of elements to read */
_FILE *stream) /**< stream pointer */
@ -330,7 +330,7 @@ __fread (void *ptr, /**< address of buffer to read to */
while (bytes_read != size * nmemb && ret != 0);
return bytes_read;
} /* __fread */
} /* fread */
/**
* fwrite
@ -338,7 +338,7 @@ __fread (void *ptr, /**< address of buffer to read to */
* @return number of bytes written
*/
size_t
__fwrite (const void *ptr, /**< data to write */
fwrite (const void *ptr, /**< data to write */
size_t size, /**< size of elements to write */
size_t nmemb, /**< number of elements */
_FILE *stream) /**< stream pointer */
@ -357,7 +357,7 @@ __fwrite (const void *ptr, /**< data to write */
while (bytes_written != size * nmemb);
return bytes_written;
} /* __fwrite */
} /* fwrite */
/**
* Setup new memory limits

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,14 +25,14 @@ extern void __noreturn exit (int status);
/** Output of character. Writes the character c, cast to an unsigned char, to stdout. */
int
__putchar (int c)
putchar (int c)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS("putchar is not implemented for STM32F3.", c);
} /* __putchar */
} /* putchar */
/** exit - cause normal process termination */
void __noreturn
__exit (int status __unused)
void __noreturn __used
exit (int status __unused)
{
/**
* TODO: Blink LEDs? status -> binary -> LEDs?
@ -41,7 +41,7 @@ __exit (int status __unused)
while (true)
{
}
} /* __exit */
} /* exit */
/**
* fwrite
@ -49,11 +49,11 @@ __exit (int status __unused)
* @return number of bytes written
*/
size_t
__fwrite (const void *ptr, /**< data to write */
fwrite (const void *ptr, /**< data to write */
size_t size, /**< size of elements to write */
size_t nmemb, /**< number of elements */
_FILE *stream) /**< stream pointer */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS("fwrite is not implemented for STM32F3.", ptr, size, nmemb, stream);
} /* __fwrite */
} /* fwrite */

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,14 +25,14 @@ extern void __noreturn exit (int status);
/** Output of character. Writes the character c, cast to an unsigned char, to stdout. */
int
__putchar (int c)
putchar (int c)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS("putchar is not implemented for STM32F4.", c);
} /* __putchar */
} /* putchar */
/** exit - cause normal process termination */
void __noreturn
__exit (int status __unused)
void __noreturn __used
exit (int status __unused)
{
/**
* TODO: Blink LEDs? status -> binary -> LEDs?
@ -41,7 +41,7 @@ __exit (int status __unused)
while (true)
{
}
} /* __exit */
} /* exit */
/**
* fwrite
@ -49,11 +49,11 @@ __exit (int status __unused)
* @return number of bytes written
*/
size_t
__fwrite (const void *ptr, /**< data to write */
fwrite (const void *ptr, /**< data to write */
size_t size, /**< size of elements to write */
size_t nmemb, /**< number of elements */
_FILE *stream) /**< stream pointer */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS("fwrite is not implemented for STM32F4.", ptr, size, nmemb, stream);
} /* __fwrite */
} /* fwrite */

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@
void
led_toggle (uint32_t led_id) /**< index of LED */
{
__printf ("led_toggle: %d\n", led_id);
printf ("led_toggle: %d\n", led_id);
}
/**
@ -35,7 +35,7 @@ led_toggle (uint32_t led_id) /**< index of LED */
void
led_on (uint32_t led_id) /**< index of LED */
{
__printf ("led_on: %d\n", led_id);
printf ("led_on: %d\n", led_id);
}
/**
@ -44,7 +44,7 @@ led_on (uint32_t led_id) /**< index of LED */
void
led_off (uint32_t led_id) /**< index of LED */
{
__printf ("led_off: %d\n", led_id);
printf ("led_off: %d\n", led_id);
}
/**
@ -53,7 +53,7 @@ led_off (uint32_t led_id) /**< index of LED */
void
led_blink_once (uint32_t led_id) /**< index of LED */
{
__printf ("led_blink_once: %d\n", led_id);
printf ("led_blink_once: %d\n", led_id);
}
#else /* !__TARGET_HOST */
#ifndef __TARGET_MCU

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ analog_write (uint32_t arg1 __unused, uint32_t arg2 __unused)
void
wait_ms (uint32_t time_ms)
{
__printf ("wait_ms: %d\n", time_ms);
printf ("wait_ms: %d\n", time_ms);
}
#else /* !__TARGET_HOST */

View File

@ -274,7 +274,7 @@ ecma_gc_update_may_ref_younger_object_flag_by_object (ecma_object_t *obj_p, /**<
void
ecma_gc_init (void)
{
__memset (ecma_gc_objects_lists, 0, sizeof (ecma_gc_objects_lists));
memset (ecma_gc_objects_lists, 0, sizeof (ecma_gc_objects_lists));
} /* ecma_gc_init */
/**
@ -614,7 +614,7 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
JERRY_ASSERT (max_gen_to_collect <= ECMA_GC_GEN_COUNT);
ecma_object_t *gen_last_obj_p[ ECMA_GC_GEN_COUNT ];
#ifndef JERRY_NDEBUG
__memset (gen_last_obj_p, 0, sizeof (gen_last_obj_p));
memset (gen_last_obj_p, 0, sizeof (gen_last_obj_p));
#endif /* !JERRY_NDEBUG */
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; gen_id <= max_gen_to_collect; gen_id = (ecma_gc_gen_t) (gen_id + 1))

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -790,7 +790,7 @@ ecma_uint32_to_string (uint32_t value, /**< value to convert */
if (likely (p != out_buffer_p))
{
ssize_t bytes_to_move = ((uint8_t*) out_buffer_p + buffer_size) - (uint8_t*) p;
__memmove (out_buffer_p, p, (size_t) bytes_to_move);
memmove (out_buffer_p, p, (size_t) bytes_to_move);
}
return (ssize_t) bytes_copied;

View File

@ -967,7 +967,7 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d
size_t bytes_to_copy = (length + 1) * sizeof (ecma_char_t);
__memcpy (buffer_p, ecma_get_magic_string_zt (id), bytes_to_copy);
memcpy (buffer_p, ecma_get_magic_string_zt (id), bytes_to_copy);
JERRY_ASSERT (required_buffer_size == (ssize_t) bytes_to_copy);
@ -1101,7 +1101,7 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri
req_size = ecma_string_to_zt_string (string2_p, string2_buf, (ssize_t) string_buf_size);
JERRY_ASSERT (req_size > 0);
bool is_equal = (__memcmp (string1_buf, string2_buf, string_buf_size) == 0);
bool is_equal = (memcmp (string1_buf, string2_buf, string_buf_size) == 0);
mem_heap_free_block (string1_buf);
mem_heap_free_block (string2_buf);

View File

@ -72,7 +72,7 @@ static ecma_lcache_hash_entry_t ecma_lcache_hash_table[ ECMA_LCACHE_HASH_ROWS_CO
void
ecma_lcache_init (void)
{
__memset (ecma_lcache_hash_table, 0, sizeof (ecma_lcache_hash_table));
memset (ecma_lcache_hash_table, 0, sizeof (ecma_lcache_hash_table));
} /* ecma_lcache_init */
/**

View File

@ -30,13 +30,13 @@ void __noreturn
jerry_fatal (jerry_fatal_code_t code) /**< status code */
{
#ifndef JERRY_NDEBUG
__printf ("Error: ");
printf ("Error: ");
switch (code)
{
case ERR_OUT_OF_MEMORY:
{
__printf ("ERR_OUT_OF_MEMORY\n");
printf ("ERR_OUT_OF_MEMORY\n");
break;
}
case ERR_SYSCALL:
@ -46,23 +46,23 @@ jerry_fatal (jerry_fatal_code_t code) /**< status code */
}
case ERR_PARSER:
{
__printf ("ERR_PARSER\n");
printf ("ERR_PARSER\n");
break;
}
case ERR_UNIMPLEMENTED_CASE:
{
__printf ("ERR_UNIMPLEMENTED_CASE\n");
printf ("ERR_UNIMPLEMENTED_CASE\n");
break;
}
case ERR_FAILED_INTERNAL_ASSERTION:
{
__printf ("ERR_FAILED_INTERNAL_ASSERTION\n");
printf ("ERR_FAILED_INTERNAL_ASSERTION\n");
break;
}
}
#endif /* !JERRY_NDEBUG */
__exit (code);
exit (code);
} /* jerry_fatal */
/**
@ -75,8 +75,8 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
const uint32_t line) /** line */
{
#ifndef JERRY_NDEBUG
__printf ("ICE: Assertion '%s' failed at %s(%s):%u.\n",
assertion, file, function, line);
printf ("ICE: Assertion '%s' failed at %s(%s):%u.\n",
assertion, file, function, line);
#else /* !JERRY_NDEBUG */
(void) assertion;
(void) file;
@ -98,7 +98,7 @@ jerry_unreachable (const char *comment, /**< comment to unreachable mark if exis
const uint32_t line) /**< line */
{
#ifndef JERRY_NDEBUG
__printf ("ICE: Unreachable control path at %s(%s):%u was executed", file, function, line);
printf ("ICE: Unreachable control path at %s(%s):%u was executed", file, function, line);
#else /* !JERRY_NDEBUG */
(void) file;
(void) function;
@ -107,9 +107,9 @@ jerry_unreachable (const char *comment, /**< comment to unreachable mark if exis
if (comment != NULL)
{
__printf ("(%s)", comment);
printf ("(%s)", comment);
}
__printf (".\n");
printf (".\n");
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
} /* jerry_unreachable */
@ -125,7 +125,7 @@ jerry_unimplemented (const char *comment, /**< comment to unimplemented mark if
const uint32_t line) /**< line */
{
#ifndef JERRY_NDEBUG
__printf ("SORRY: Unimplemented case at %s(%s):%u was executed", file, function, line);
printf ("SORRY: Unimplemented case at %s(%s):%u was executed", file, function, line);
#else /* !JERRY_NDEBUG */
(void) file;
(void) function;
@ -134,9 +134,9 @@ jerry_unimplemented (const char *comment, /**< comment to unimplemented mark if
if (comment != NULL)
{
__printf ("(%s)", comment);
printf ("(%s)", comment);
}
__printf (".\n");
printf (".\n");
jerry_fatal (ERR_UNIMPLEMENTED_CASE);
} /* jerry_unimplemented */

View File

@ -37,28 +37,28 @@ read_sources (const char *script_file_names[],
{
const char *script_file_name = script_file_names[i];
_FILE *file = __fopen (script_file_name, "r");
_FILE *file = fopen (script_file_name, "r");
if (file == NULL)
{
break;
}
int fseek_status = __fseek (file, 0, __SEEK_END);
int fseek_status = fseek (file, 0, __SEEK_END);
if (fseek_status != 0)
{
break;
}
long script_len = __ftell (file);
long script_len = ftell (file);
if (script_len < 0)
{
break;
}
__rewind (file);
rewind (file);
const size_t current_source_size = (size_t)script_len;
@ -67,20 +67,20 @@ read_sources (const char *script_file_names[],
break;
}
size_t bytes_read = __fread (source_buffer_tail, 1, current_source_size, file);
size_t bytes_read = fread (source_buffer_tail, 1, current_source_size, file);
if (bytes_read < current_source_size)
{
break;
}
__fclose (file);
fclose (file);
source_buffer_tail += current_source_size;
}
if (i < files_count)
{
__printf ("Failed to read script N%d\n", i + 1);
printf ("Failed to read script N%d\n", i + 1);
return NULL;
}
@ -101,7 +101,7 @@ main (int argc __unused,
{
if (argc >= JERRY_MAX_COMMAND_LINE_ARGS)
{
__printf ("Too many command line arguments. Current maximum is %d (JERRY_MAX_COMMAND_LINE_ARGS)\n", argc);
printf ("Too many command line arguments. Current maximum is %d (JERRY_MAX_COMMAND_LINE_ARGS)\n", argc);
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
@ -119,26 +119,26 @@ main (int argc __unused,
for (i = 1; i < argc; i++)
{
if (!__strcmp ("-v", argv[i]))
if (!strcmp ("-v", argv[i]))
{
__printf ("Build date: \t%s\n", jerry_build_date);
__printf ("Commit hash:\t%s\n", jerry_commit_hash);
__printf ("Branch name:\t%s\n", jerry_branch_name);
__printf ("\n");
printf ("Build date: \t%s\n", jerry_build_date);
printf ("Commit hash:\t%s\n", jerry_commit_hash);
printf ("Branch name:\t%s\n", jerry_branch_name);
printf ("\n");
}
if (!__strcmp ("--mem-stats", argv[i]))
if (!strcmp ("--mem-stats", argv[i]))
{
#ifdef MEM_STATS
flags |= JERRY_FLAG_MEM_STATS;
#else /* MEM_STATS */
__printf ("Ignoring --mem-stats because of '!MEM_STATS' build configuration.\n");
printf ("Ignoring --mem-stats because of '!MEM_STATS' build configuration.\n");
#endif /* !MEM_STATS */
}
else if (!__strcmp ("--parse-only", argv[i]))
else if (!strcmp ("--parse-only", argv[i]))
{
flags |= JERRY_FLAG_PARSE_ONLY;
}
else if (!__strcmp ("--show-opcodes", argv[i]))
else if (!strcmp ("--show-opcodes", argv[i]))
{
flags |= JERRY_FLAG_SHOW_OPCODES;
}

View File

@ -69,19 +69,19 @@ mem_finalize (bool is_show_mem_stats) /**< show heap memory stats
mem_pools_stats_t 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 */
}

View File

@ -364,7 +364,7 @@ mem_heap_finalize (void)
VALGRIND_NOACCESS_SPACE(mem_heap.heap_start, mem_heap.heap_size);
__memset (&mem_heap, 0, sizeof (mem_heap));
memset (&mem_heap, 0, sizeof (mem_heap));
} /* mem_heap_finalize */
/**
@ -883,11 +883,11 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
if (dump_block_headers)
{
__printf ("Heap: start=%p size=%lu, first block->%p, last block->%p\n",
mem_heap.heap_start,
mem_heap.heap_size,
(void*) mem_heap.first_block_p,
(void*) mem_heap.last_block_p);
printf ("Heap: start=%p size=%lu, first block->%p, last block->%p\n",
mem_heap.heap_start,
mem_heap.heap_size,
(void*) mem_heap.first_block_p,
(void*) mem_heap.last_block_p);
for (mem_block_header_t *block_p = mem_heap.first_block_p, *next_block_p;
block_p != NULL;
@ -895,12 +895,12 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
{
VALGRIND_DEFINED_STRUCT(block_p);
__printf ("Block (%p): magic num=0x%08x, size in chunks=%lu, previous block->%p next block->%p\n",
(void*) block_p,
block_p->magic_num,
mem_get_block_chunks_count (block_p),
(void*) mem_get_next_block_by_direction (block_p, MEM_DIRECTION_PREV),
(void*) mem_get_next_block_by_direction (block_p, MEM_DIRECTION_NEXT));
printf ("Block (%p): magic num=0x%08x, size in chunks=%lu, previous block->%p next block->%p\n",
(void*) block_p,
block_p->magic_num,
mem_get_block_chunks_count (block_p),
(void*) mem_get_next_block_by_direction (block_p, MEM_DIRECTION_PREV),
(void*) mem_get_next_block_by_direction (block_p, MEM_DIRECTION_NEXT));
if (dump_block_data)
{
@ -909,9 +909,9 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
offset < mem_get_block_data_space_size (block_p);
offset++)
{
__printf ("%02x ", block_data_p[ offset ]);
printf ("%02x ", block_data_p[ offset ]);
}
__printf ("\n");
printf ("\n");
}
next_block_p = mem_get_next_block_by_direction (block_p, MEM_DIRECTION_NEXT);
@ -923,35 +923,35 @@ mem_heap_print (bool dump_block_headers, /**< print block headers */
#ifdef MEM_STATS
if (dump_stats)
{
__printf ("Heap stats:\n");
__printf (" Heap size = %lu bytes\n"
" Chunk size = %lu bytes\n"
" Blocks count = %lu\n"
" Allocated blocks count = %lu\n"
" Allocated chunks count = %lu\n"
" Allocated = %lu bytes\n"
" Waste = %lu bytes\n"
" Peak allocated blocks count = %lu\n"
" Peak allocated chunks count = %lu\n"
" Peak allocated= %lu bytes\n"
" Peak waste = %lu bytes\n",
mem_heap_stats.size,
MEM_HEAP_CHUNK_SIZE,
mem_heap_stats.blocks,
mem_heap_stats.allocated_blocks,
mem_heap_stats.allocated_chunks,
mem_heap_stats.allocated_bytes,
mem_heap_stats.waste_bytes,
mem_heap_stats.peak_allocated_blocks,
mem_heap_stats.peak_allocated_chunks,
mem_heap_stats.peak_allocated_bytes,
mem_heap_stats.peak_waste_bytes);
printf ("Heap stats:\n");
printf (" Heap size = %lu bytes\n"
" Chunk size = %lu bytes\n"
" Blocks count = %lu\n"
" Allocated blocks count = %lu\n"
" Allocated chunks count = %lu\n"
" Allocated = %lu bytes\n"
" Waste = %lu bytes\n"
" Peak allocated blocks count = %lu\n"
" Peak allocated chunks count = %lu\n"
" Peak allocated= %lu bytes\n"
" Peak waste = %lu bytes\n",
mem_heap_stats.size,
MEM_HEAP_CHUNK_SIZE,
mem_heap_stats.blocks,
mem_heap_stats.allocated_blocks,
mem_heap_stats.allocated_chunks,
mem_heap_stats.allocated_bytes,
mem_heap_stats.waste_bytes,
mem_heap_stats.peak_allocated_blocks,
mem_heap_stats.peak_allocated_chunks,
mem_heap_stats.peak_allocated_bytes,
mem_heap_stats.peak_waste_bytes);
}
#else /* MEM_STATS */
(void) dump_stats;
#endif /* !MEM_STATS */
__printf ("\n");
printf ("\n");
} /* mem_heap_print */
/**
@ -1058,7 +1058,7 @@ mem_heap_stats_reset_peak (void)
static void
mem_heap_stat_init ()
{
__memset (&mem_heap_stats, 0, sizeof (mem_heap_stats));
memset (&mem_heap_stats, 0, sizeof (mem_heap_stats));
mem_heap_stats.size = mem_heap.heap_size;
mem_heap_stats.blocks = 1;

View File

@ -273,7 +273,7 @@ mem_pools_stats_reset_peak (void)
static void
mem_pools_stat_init (void)
{
__memset (&mem_pools_stats, 0, sizeof (mem_pools_stats));
memset (&mem_pools_stats, 0, sizeof (mem_pools_stats));
} /* mem_pools_stat_init */
/**

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -51,14 +51,14 @@ array_list_append (array_list al, void *element)
{
size_t size = mem_heap_recommend_allocation_size (h->size + h->element_size);
array_list_header *temp = (array_list_header *) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_SHORT_TERM);
__memset (temp, 0, size);
__memcpy (temp, h, h->size);
memset (temp, 0, size);
memcpy (temp, h, h->size);
temp->size = size;
mem_heap_free_block ((uint8_t *) h);
h = temp;
al = (array_list) h;
}
__memcpy (data (al) + (h->len * h->element_size), element, h->element_size);
memcpy (data (al) + (h->len * h->element_size), element, h->element_size);
h->len++;
return al;
}
@ -87,7 +87,7 @@ array_list_set_element (array_list al, size_t index, void *elem)
{
array_list_header *h = extract_header (al);
JERRY_ASSERT (index < h->len);
__memcpy (data (al) + (index * h->element_size), elem, h->element_size);
memcpy (data (al) + (index * h->element_size), elem, h->element_size);
}
void *
@ -114,7 +114,7 @@ array_list_init (uint8_t element_size)
{
size_t size = mem_heap_recommend_allocation_size (sizeof (array_list_header));
array_list_header *header = (array_list_header *) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_SHORT_TERM);
__memset (header, 0, size);
memset (header, 0, size);
header->magic = ARRAY_LIST_MAGIC;
header->element_size = element_size;
header->len = 0;

View File

@ -71,8 +71,8 @@ hash_table_insert (hash_table ht, void *key, void *value)
list = array_list_init (bucket_size (hti));
}
uint8_t *bucket = (uint8_t*) mem_heap_alloc_block (bucket_size (hti), hti->alloc_term);
__memcpy (bucket, key, hti->key_size);
__memcpy (bucket + hti->key_size, value, hti->value_size);
memcpy (bucket, key, hti->key_size);
memcpy (bucket + hti->key_size, value, hti->value_size);
list = array_list_append (list, bucket);
hti->data[index] = list;
mem_heap_free_block (bucket);
@ -93,7 +93,7 @@ hash_table_lookup (hash_table ht, void *key)
{
uint8_t *bucket = (uint8_t*) array_list_element (al, i);
JERRY_ASSERT (bucket != NULL);
if (!__memcmp (bucket, key, h->key_size))
if (!memcmp (bucket, key, h->key_size))
{
return bucket + h->key_size;
}
@ -106,14 +106,14 @@ hash_table_init (uint8_t key_size, uint8_t value_size, uint16_t size,
uint16_t (*hash) (void *), mem_heap_alloc_term_t alloc_term)
{
hash_table_int *res = (hash_table_int *) mem_heap_alloc_block (sizeof (hash_table_int), alloc_term);
__memset (res, 0, sizeof (hash_table_int));
memset (res, 0, sizeof (hash_table_int));
res->magic = HASH_MAP_MAGIC;
res->key_size = key_size;
res->value_size = value_size;
res->size = size;
res->alloc_term = alloc_term;
res->data = (array_list *) mem_heap_alloc_block (size * sizeof (array_list), alloc_term);
__memset (res->data, 0, size * sizeof (array_list));
memset (res->data, 0, size * sizeof (array_list));
res->hash = hash;
return res;
}

View File

@ -45,10 +45,10 @@ linked_list_init (uint16_t element_size)
linked_list list = (linked_list) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_SHORT_TERM);
if (list == null_list)
{
__printf ("Out of memory");
printf ("Out of memory");
JERRY_UNREACHABLE ();
}
__memset (list, 0, size);
memset (list, 0, size);
linked_list_header* header = (linked_list_header *) list;
header->magic = LINKED_LIST_MAGIC;
header->prev = header->next = null_list;
@ -113,5 +113,5 @@ linked_list_set_element (linked_list list, uint16_t element_num, void *element)
{
return;
}
__memcpy (raw + element_num * header->element_size, element, header->element_size);
memcpy (raw + element_num * header->element_size, element, header->element_size);
}

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,13 +23,13 @@ lit_id_hash_table_init (size_t buckets_count, size_t blocks_count)
{
size_t size = mem_heap_recommend_allocation_size (sizeof (lit_id_hash_table));
lit_id_hash_table *table = (lit_id_hash_table *) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_LONG_TERM);
__memset (table, 0, size);
memset (table, 0, size);
size = mem_heap_recommend_allocation_size (sizeof (literal_index_t) * buckets_count);
table->raw_buckets = (literal_index_t *) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_LONG_TERM);
__memset (table->raw_buckets, 0, size);
memset (table->raw_buckets, 0, size);
size = mem_heap_recommend_allocation_size (sizeof (literal_index_t *) * blocks_count);
table->buckets = (literal_index_t **) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_LONG_TERM);
__memset (table->buckets, 0, size);
memset (table->buckets, 0, size);
table->current_bucket_pos = 0;
return table;
}

View File

@ -1,4 +1,4 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -129,10 +129,10 @@ static TYPE *convert_##NAME##_to_raw_data (void) { \
TYPE *DATA = (TYPE *) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_LONG_TERM); \
if (DATA == NULL) \
{ \
__printf ("Out of memory\n"); \
printf ("Out of memory\n"); \
JERRY_UNREACHABLE (); \
} \
__memcpy (DATA, array_list_element (NAME.data, 0), array_list_len (NAME.data) * sizeof (NAME##_stack_value_type)); \
memcpy (DATA, array_list_element (NAME.data, 0), array_list_len (NAME.data) * sizeof (NAME##_stack_value_type)); \
return DATA; \
}

View File

@ -83,13 +83,13 @@ dump_current_line (void)
return;
}
__printf ("// ");
printf ("// ");
for (i = buffer; *i != '\n' && *i != 0; i++)
{
__putchar (*i);
putchar (*i);
}
__putchar ('\n');
putchar ('\n');
}
static token
@ -107,11 +107,11 @@ create_token (token_type type, literal_index_t uid)
static bool
current_token_equals_to (const char *str)
{
if (__strlen (str) != (size_t) (buffer - token_start))
if (strlen (str) != (size_t) (buffer - token_start))
{
return false;
}
if (!__strncmp (str, token_start, (size_t) (buffer - token_start)))
if (!strncmp (str, token_start, (size_t) (buffer - token_start)))
{
return true;
}
@ -127,7 +127,7 @@ current_token_equals_to_literal (literal lit)
{
return false;
}
if (!__strncmp ((const char *) lit.data.lp.str, token_start, lit.data.lp.length))
if (!strncmp ((const char *) lit.data.lp.str, token_start, lit.data.lp.length))
{
return true;
}
@ -135,11 +135,11 @@ current_token_equals_to_literal (literal lit)
else if (lit.type == LIT_MAGIC_STR)
{
const char *str = (const char *) ecma_get_magic_string_zt (lit.data.magic_str_id);
if (__strlen (str) != (size_t) (buffer - token_start))
if (strlen (str) != (size_t) (buffer - token_start))
{
return false;
}
if (!__strncmp (str, token_start, __strlen (str)))
if (!strncmp (str, token_start, strlen (str)))
{
return true;
}
@ -175,7 +175,7 @@ add_current_token_to_string_cache (void)
+ ((size_t) length + 1) * sizeof (ecma_char_t));
ecma_char_t *temp = (ecma_char_t *) mem_heap_alloc_block (strings_cache_size,
MEM_HEAP_ALLOC_SHORT_TERM);
__memcpy (temp, strings_cache, strings_cache_used_size);
memcpy (temp, strings_cache, strings_cache_used_size);
STACK_ITERATE_VARG_SET (literals, adjust_string_ptrs, 0, (size_t) (temp - strings_cache));
if (strings_cache)
{
@ -183,7 +183,7 @@ add_current_token_to_string_cache (void)
}
strings_cache = temp;
}
__strncpy ((char *) (strings_cache + strings_cache_used_size), token_start, length);
strncpy ((char *) (strings_cache + strings_cache_used_size), token_start, length);
(strings_cache + strings_cache_used_size)[length] = '\0';
const literal res = create_literal_from_zt (strings_cache + strings_cache_used_size, length);
strings_cache_used_size = (size_t) (((size_t) length + 1) * sizeof (ecma_char_t) + strings_cache_used_size);
@ -611,10 +611,10 @@ static token
parse_name (void)
{
char c = LA (0);
bool every_char_islower = __islower (c);
bool every_char_islower = islower (c);
token known_token = empty_token;
JERRY_ASSERT (__isalpha (c) || c == '$' || c == '_');
JERRY_ASSERT (isalpha (c) || c == '$' || c == '_');
new_token ();
consume_char ();
@ -625,11 +625,11 @@ parse_name (void)
{
break;
}
if (!__isalpha (c) && !__isdigit (c) && c != '$' && c != '_')
if (!isalpha (c) && !isdigit (c) && c != '$' && c != '_')
{
break;
}
if (every_char_islower && (!__islower (c)))
if (every_char_islower && (!islower (c)))
{
every_char_islower = false;
}
@ -698,7 +698,7 @@ parse_number (void)
uint32_t res = 0;
token known_token;
JERRY_ASSERT (__isdigit (c) || c == '.');
JERRY_ASSERT (isdigit (c) || c == '.');
if (c == '0')
{
@ -710,7 +710,7 @@ parse_number (void)
if (c == '.')
{
JERRY_ASSERT (!__isalpha (LA (1)));
JERRY_ASSERT (!isalpha (LA (1)));
is_fp = true;
}
@ -723,14 +723,14 @@ parse_number (void)
while (true)
{
c = LA (0);
if (!__isxdigit (c))
if (!isxdigit (c))
{
break;
}
consume_char ();
}
if (__isalpha (c) || c == '_' || c == '$')
if (isalpha (c) || c == '_' || c == '$')
{
PARSE_ERROR ("Integer literal shall not contain non-digit characters", buffer - buffer_start);
}
@ -796,7 +796,7 @@ parse_number (void)
if (c == '.')
{
if (__isalpha (LA (1)) || LA (1) == '_' || LA (1) == '$')
if (isalpha (LA (1)) || LA (1) == '_' || LA (1) == '$')
{
PARSE_ERROR ("Integer literal shall not contain non-digit character after got character",
buffer - buffer_start);
@ -812,7 +812,7 @@ parse_number (void)
{
consume_char ();
}
if (!__isdigit (LA (1)))
if (!isdigit (LA (1)))
{
PARSE_ERROR ("Integer literal shall not contain non-digit character after exponential marker ('e' or 'E')",
buffer - buffer_start);
@ -822,12 +822,12 @@ parse_number (void)
continue;
}
if (__isalpha (c) || c == '_' || c == '$')
if (isalpha (c) || c == '_' || c == '$')
{
PARSE_ERROR ("Integer literal shall not contain non-digit characters", buffer - buffer_start);
}
if (!__isdigit (c))
if (!isdigit (c))
{
break;
}
@ -840,7 +840,7 @@ parse_number (void)
{
ecma_char_t *temp = (ecma_char_t*) mem_heap_alloc_block ((size_t) (tok_length + 1),
MEM_HEAP_ALLOC_SHORT_TERM);
__strncpy ((char *) temp, token_start, (size_t) (tok_length));
strncpy ((char *) temp, token_start, (size_t) (tok_length));
temp[tok_length] = '\0';
ecma_number_t res = ecma_zt_string_to_number (temp);
JERRY_ASSERT (!ecma_number_is_nan (res));
@ -938,7 +938,7 @@ parse_string (void)
if (c == '\\')
{
/* Only single escape character is allowed. */
if (LA (1) == 'x' || LA (1) == 'u' || __isdigit (LA (1)))
if (LA (1) == 'x' || LA (1) == 'u' || isdigit (LA (1)))
{
// PARSE_WARN ("Escape sequences are ignored yet", token_start - buffer_start);
consume_char ();
@ -977,7 +977,7 @@ grobble_whitespaces (void)
{
char c = LA (0);
while ((__isspace (c) && c != '\n'))
while ((isspace (c) && c != '\n'))
{
consume_char ();
c = LA (0);
@ -1046,12 +1046,12 @@ lexer_next_token_private (void)
JERRY_ASSERT (token_start == NULL);
if (__isalpha (c) || c == '$' || c == '_')
if (isalpha (c) || c == '$' || c == '_')
{
return parse_name ();
}
if (__isdigit (c) || (c == '.' && __isdigit (LA (1))))
if (isdigit (c) || (c == '.' && isdigit (LA (1))))
{
return parse_number ();
}
@ -1072,7 +1072,7 @@ lexer_next_token_private (void)
return parse_string ();
}
if (__isspace (c))
if (isspace (c))
{
grobble_whitespaces ();
return lexer_next_token_private ();
@ -1271,7 +1271,7 @@ lexer_dump_line (size_t line)
{
for (; *buf != '\n' && *buf != '\0'; buf++)
{
__putchar (*buf);
putchar (*buf);
}
return;
}

View File

@ -48,7 +48,7 @@ create_literal_from_str (const char *s, ecma_length_t len)
literal
create_literal_from_str_compute_len (const char *s)
{
return create_literal_from_zt ((const ecma_char_t *) s, (ecma_length_t) __strlen (s));
return create_literal_from_zt ((const ecma_char_t *) s, (ecma_length_t) strlen (s));
}
literal
@ -62,7 +62,7 @@ create_literal_from_zt (const ecma_char_t *s, ecma_length_t len)
{
continue;
}
if (!__strncmp ((const char *) s, (const char *) ecma_get_magic_string_zt (msi), len))
if (!strncmp ((const char *) s, (const char *) ecma_get_magic_string_zt (msi), len))
{
literal ret;

View File

@ -619,7 +619,7 @@ scopes_tree_raw_data (scopes_tree tree, lit_id_hash_table *lit_ids)
/* Dump bytecode and fill literal indexes 'hash' table. */
size_t size = ((size_t) (scopes_tree_count_opcodes (tree) + 1) * sizeof (opcode_t)); // +1 for valgrind
opcode_t *opcodes = (opcode_t *) mem_heap_alloc_block (size, MEM_HEAP_ALLOC_LONG_TERM);
__memset (opcodes, 0, size);
memset (opcodes, 0, size);
merge_subscopes (tree, opcodes, lit_ids);
if (lit_id_to_uid != null_hash)
{
@ -647,7 +647,7 @@ scopes_tree
scopes_tree_init (scopes_tree parent)
{
scopes_tree tree = (scopes_tree) mem_heap_alloc_block (sizeof (scopes_tree_int), MEM_HEAP_ALLOC_SHORT_TERM);
__memset (tree, 0, sizeof (scopes_tree_int));
memset (tree, 0, sizeof (scopes_tree_int));
tree->t.magic = TREE_MAGIC;
tree->t.parent = (tree_header *) parent;
tree->t.children = null_list;

View File

@ -113,7 +113,7 @@ serializer_print_opcodes (void)
return;
}
__printf ("AFTER OPTIMIZER:\n");
printf ("AFTER OPTIMIZER:\n");
for (loc = 0; loc < bytecode_data.opcodes_count; loc++)
{

View File

@ -25,43 +25,43 @@
size_t line, column; \
lexer_locus_to_line_and_column ((locus) (LOCUS), &line, &column); \
lexer_dump_line (line); \
__printf ("\n"); \
printf ("\n"); \
for (size_t i = 0; i < column; i++) { \
__putchar (' '); \
putchar (' '); \
} \
__printf ("^\n"); \
__printf ("ERROR: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \
printf ("^\n"); \
printf ("ERROR: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \
jerry_fatal (ERR_PARSER); \
} while (0)
#define PARSE_WARN(MESSAGE, LOCUS) do { \
size_t line, column; \
lexer_locus_to_line_and_column ((locus) (LOCUS), &line, &column); \
__printf ("WARNING: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \
printf ("WARNING: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \
} while (0)
#define PARSE_ERROR_VARG(MESSAGE, LOCUS, ...) do { \
size_t line, column; \
lexer_locus_to_line_and_column ((locus) (LOCUS), &line, &column); \
lexer_dump_line (line); \
__printf ("\n"); \
printf ("\n"); \
for (size_t i = 0; i < column; i++) { \
__putchar (' '); \
putchar (' '); \
} \
__printf ("^\n"); \
__printf ("ERROR: Ln %d, Col %d: ", line + 1, column + 1); \
__printf (MESSAGE, __VA_ARGS__); \
__printf ("\n"); \
printf ("^\n"); \
printf ("ERROR: Ln %d, Col %d: ", line + 1, column + 1); \
printf (MESSAGE, __VA_ARGS__); \
printf ("\n"); \
jerry_fatal (ERR_PARSER); \
} while (0)
#define PARSE_SORRY(MESSAGE, LOCUS) do { \
size_t line, column; \
lexer_locus_to_line_and_column ((locus) (LOCUS), &line, &column); \
lexer_dump_line (line); \
__printf ("\n"); \
printf ("\n"); \
for (size_t i = 0; i < column; i++) { \
__putchar (' '); \
putchar (' '); \
} \
__printf ("^\n"); \
__printf ("SORRY, Unimplemented: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \
printf ("^\n"); \
printf ("SORRY, Unimplemented: Ln %d, Col %d: %s\n", line + 1, column + 1, MESSAGE); \
JERRY_UNIMPLEMENTED ("Unimplemented parser feature."); \
} while (0)
#else /* JERRY_NDEBUG */

View File

@ -134,7 +134,7 @@ opfunc_native_call (opcode_t opdata, /**< operation data */
ecma_string_to_zt_string (str_p, zt_str_p, zt_str_size);
#if CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII
__printf ("%s\n", (char*) zt_str_p);
printf ("%s\n", (char*) zt_str_p);
#elif CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_UTF16
JERRY_UNIMPLEMENTED ("UTF-16 support is not implemented.");
#endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_UTF16 */

View File

@ -53,22 +53,22 @@ dump_literal (literal lit)
{
if (ecma_number_is_nan (lit.data.num))
{
__printf ("%s : NUMBER", "NaN");
printf ("%s : NUMBER", "NaN");
}
else
{
__printf ("%d : NUMBER", lit.data.num);
printf ("%d : NUMBER", lit.data.num);
}
break;
}
case LIT_MAGIC_STR:
{
__printf ("%s : MAGIC STRING", (const char *) ecma_get_magic_string_zt (lit.data.magic_str_id));
printf ("%s : MAGIC STRING", (const char *) ecma_get_magic_string_zt (lit.data.magic_str_id));
break;
}
case LIT_STR:
{
__printf ("%s : STRING", (const char *) (lit.data.lp.str));
printf ("%s : STRING", (const char *) (lit.data.lp.str));
break;
}
default:
@ -81,12 +81,12 @@ dump_literal (literal lit)
void
pp_literals (const literal lits[], literal_index_t size)
{
__printf ("LITERALS %d:\n", size);
printf ("LITERALS %d:\n", size);
for (literal_index_t i = 0; i < size; i++)
{
__printf ("%3d ", i);
printf ("%3d ", i);
dump_literal (lits[i]);
__putchar ('\n');
putchar ('\n');
}
}
@ -95,7 +95,7 @@ static char buff[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER];
static void
clear_temp_buffer (void)
{
__memset (buff, 0, ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER);
memset (buff, 0, ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER);
}
static const char *
@ -121,7 +121,7 @@ tmp_id_to_str (idx_t id)
JERRY_ASSERT (id != LITERAL_TO_REWRITE);
JERRY_ASSERT (id >= 128);
clear_temp_buffer ();
__strncpy (buff, "tmp", 3);
strncpy (buff, "tmp", 3);
if (id / 100 != 0)
{
buff[3] = (char) (id / 100 + '0');
@ -172,7 +172,7 @@ pp_printf (const char *format, opcode_t opcode, literal_index_t lit_ids[], opcod
{
if (*format != '%')
{
__putchar (*format);
putchar (*format);
format++;
continue;
}
@ -183,17 +183,17 @@ pp_printf (const char *format, opcode_t opcode, literal_index_t lit_ids[], opcod
case 'd':
{
raw_opcode raw = *(raw_opcode*) &opcode;
__printf ("%d", raw.uids[current_arg]);
printf ("%d", raw.uids[current_arg]);
break;
}
case 's':
{
__printf ("%s", var_to_str (opcode, lit_ids, oc, current_arg));
printf ("%s", var_to_str (opcode, lit_ids, oc, current_arg));
break;
}
default:
{
__putchar ('%');
putchar ('%');
continue;
}
}
@ -216,18 +216,18 @@ dump_asm (opcode_counter_t oc, opcode_t opcode)
{
uint8_t i = 0;
uint8_t opcode_id = opcode.op_idx;
__printf ("%3d: %20s ", oc, opcode_names[opcode_id]);
printf ("%3d: %20s ", oc, opcode_names[opcode_id]);
if (opcode_id != NAME_TO_ID (nop) && opcode_id != NAME_TO_ID (ret))
{
for (i = 1; i < opcode_sizes[opcode_id]; i++)
{
__printf ("%4d ", ((raw_opcode *) &opcode)->uids[i]);
printf ("%4d ", ((raw_opcode *) &opcode)->uids[i]);
}
}
for (; i < 4; i++)
{
__printf (" ");
printf (" ");
}
}
@ -235,7 +235,7 @@ void
pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
dump_asm (oc, opm.op);
__printf (" // ");
printf (" // ");
switch (opm.op.op_idx)
{
@ -282,35 +282,35 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
PP_OP (delete_prop, "%s = delete %s.%s;");
PP_OP (typeof, "%s = typeof %s;");
PP_OP (with, "with (%s);");
case NAME_TO_ID (is_true_jmp_up): __printf ("if (%s) goto %d;", VAR (1), oc - OC (2, 3)); break;
case NAME_TO_ID (is_false_jmp_up): __printf ("if (%s == false) goto %d;", VAR (1), oc - OC (2, 3)); break;
case NAME_TO_ID (is_true_jmp_down): __printf ("if (%s) goto %d;", VAR (1), oc + OC (2, 3)); break;
case NAME_TO_ID (is_false_jmp_down): __printf ("if (%s == false) goto %d;", VAR (1), oc + OC (2, 3)); break;
case NAME_TO_ID (jmp_up): __printf ("goto %d;", oc - OC (1, 2)); break;
case NAME_TO_ID (jmp_down): __printf ("goto %d;", oc + OC (1, 2)); break;
case NAME_TO_ID (try_block): __printf ("try (end: %d);", oc + OC (1, 2)); break;
case NAME_TO_ID (is_true_jmp_up): printf ("if (%s) goto %d;", VAR (1), oc - OC (2, 3)); break;
case NAME_TO_ID (is_false_jmp_up): printf ("if (%s == false) goto %d;", VAR (1), oc - OC (2, 3)); break;
case NAME_TO_ID (is_true_jmp_down): printf ("if (%s) goto %d;", VAR (1), oc + OC (2, 3)); break;
case NAME_TO_ID (is_false_jmp_down): printf ("if (%s == false) goto %d;", VAR (1), oc + OC (2, 3)); break;
case NAME_TO_ID (jmp_up): printf ("goto %d;", oc - OC (1, 2)); break;
case NAME_TO_ID (jmp_down): printf ("goto %d;", oc + OC (1, 2)); break;
case NAME_TO_ID (try_block): printf ("try (end: %d);", oc + OC (1, 2)); break;
case NAME_TO_ID (assignment):
{
__printf ("%s = ", VAR (1));
printf ("%s = ", VAR (1));
switch (opm.op.data.assignment.type_value_right)
{
case OPCODE_ARG_TYPE_STRING: __printf ("'%s': STRING;", VAR (3)); break;
case OPCODE_ARG_TYPE_NUMBER: __printf ("%s: NUMBER;", VAR (3)); break;
case OPCODE_ARG_TYPE_NUMBER_NEGATE: __printf ("-%s: NUMBER;", VAR (3)); break;
case OPCODE_ARG_TYPE_SMALLINT: __printf ("%d: SMALLINT;", opm.op.data.assignment.value_right); break;
case OPCODE_ARG_TYPE_SMALLINT_NEGATE: __printf ("-%d: SMALLINT;", opm.op.data.assignment.value_right); break;
case OPCODE_ARG_TYPE_VARIABLE: __printf ("%s : TYPEOF(%s);", VAR (3), VAR (3)); break;
case OPCODE_ARG_TYPE_STRING: printf ("'%s': STRING;", VAR (3)); break;
case OPCODE_ARG_TYPE_NUMBER: printf ("%s: NUMBER;", VAR (3)); break;
case OPCODE_ARG_TYPE_NUMBER_NEGATE: printf ("-%s: NUMBER;", VAR (3)); break;
case OPCODE_ARG_TYPE_SMALLINT: printf ("%d: SMALLINT;", opm.op.data.assignment.value_right); break;
case OPCODE_ARG_TYPE_SMALLINT_NEGATE: printf ("-%d: SMALLINT;", opm.op.data.assignment.value_right); break;
case OPCODE_ARG_TYPE_VARIABLE: printf ("%s : TYPEOF(%s);", VAR (3), VAR (3)); break;
case OPCODE_ARG_TYPE_SIMPLE:
{
switch (opm.op.data.assignment.value_right)
{
case ECMA_SIMPLE_VALUE_NULL: __printf ("null"); break;
case ECMA_SIMPLE_VALUE_FALSE: __printf ("false"); break;
case ECMA_SIMPLE_VALUE_TRUE: __printf ("true"); break;
case ECMA_SIMPLE_VALUE_UNDEFINED: __printf ("undefined"); break;
case ECMA_SIMPLE_VALUE_NULL: printf ("null"); break;
case ECMA_SIMPLE_VALUE_FALSE: printf ("false"); break;
case ECMA_SIMPLE_VALUE_TRUE: printf ("true"); break;
case ECMA_SIMPLE_VALUE_UNDEFINED: printf ("undefined"); break;
default: JERRY_UNREACHABLE ();
}
__printf (": SIMPLE;");
printf (": SIMPLE;");
break;
}
}
@ -320,7 +320,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
if (opm.op.data.call_n.arg_list == 0)
{
__printf ("%s = %s ();", VAR (1), VAR (2));
printf ("%s = %s ();", VAR (1), VAR (2));
}
else
{
@ -333,15 +333,15 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
if (opm.op.data.native_call.arg_list == 0)
{
__printf ("%s = ", VAR (1));
printf ("%s = ", VAR (1));
switch (opm.op.data.native_call.name)
{
case OPCODE_NATIVE_CALL_LED_TOGGLE: __printf ("LEDToggle ();"); break;
case OPCODE_NATIVE_CALL_LED_ON: __printf ("LEDOn ();"); break;
case OPCODE_NATIVE_CALL_LED_OFF: __printf ("LEDOff ();"); break;
case OPCODE_NATIVE_CALL_LED_ONCE: __printf ("LEDOnce ();"); break;
case OPCODE_NATIVE_CALL_WAIT: __printf ("wait ();"); break;
case OPCODE_NATIVE_CALL_PRINT: __printf ("print ();"); break;
case OPCODE_NATIVE_CALL_LED_TOGGLE: printf ("LEDToggle ();"); break;
case OPCODE_NATIVE_CALL_LED_ON: printf ("LEDOn ();"); break;
case OPCODE_NATIVE_CALL_LED_OFF: printf ("LEDOff ();"); break;
case OPCODE_NATIVE_CALL_LED_ONCE: printf ("LEDOnce ();"); break;
case OPCODE_NATIVE_CALL_WAIT: printf ("wait ();"); break;
case OPCODE_NATIVE_CALL_PRINT: printf ("print ();"); break;
default: JERRY_UNREACHABLE ();
}
}
@ -356,7 +356,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
if (opm.op.data.construct_n.arg_list == 0)
{
__printf ("%s = new %s;", VAR (1), VAR (2));
printf ("%s = new %s;", VAR (1), VAR (2));
}
else
{
@ -369,7 +369,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
if (opm.op.data.func_decl_n.arg_list == 0)
{
__printf ("function %s ();", VAR (1));
printf ("function %s ();", VAR (1));
}
else
{
@ -384,11 +384,11 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
if (opm.op.data.func_expr_n.name_lit_idx == INVALID_VALUE)
{
__printf ("%s = function ();", VAR (1));
printf ("%s = function ();", VAR (1));
}
else
{
__printf ("%s = function %s ();", VAR (1), VAR (2));
printf ("%s = function %s ();", VAR (1), VAR (2));
}
}
else
@ -402,7 +402,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
if (opm.op.data.array_decl.list == 0)
{
__printf ("%s = [];", VAR (1));
printf ("%s = [];", VAR (1));
}
else
{
@ -415,7 +415,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
if (opm.op.data.obj_decl.list == 0)
{
__printf ("%s = {};", VAR (1));
printf ("%s = {};", VAR (1));
}
else
{
@ -430,7 +430,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
case OPCODE_META_TYPE_UNDEFINED:
{
__printf ("unknown meta;");
printf ("unknown meta;");
break;
}
case OPCODE_META_TYPE_THIS_ARG:
@ -467,57 +467,57 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
case NAME_TO_ID (call_n):
{
__printf ("%s = %s (", var_to_str (start_op, NULL, start, 1),
var_to_str (start_op, NULL, start, 2));
printf ("%s = %s (", var_to_str (start_op, NULL, start, 1),
var_to_str (start_op, NULL, start, 2));
break;
}
case NAME_TO_ID (native_call):
{
__printf ("%s = ", var_to_str (start_op, NULL, start, 1));
printf ("%s = ", var_to_str (start_op, NULL, start, 1));
switch (start_op.data.native_call.name)
{
case OPCODE_NATIVE_CALL_LED_TOGGLE: __printf ("LEDToggle ("); break;
case OPCODE_NATIVE_CALL_LED_ON: __printf ("LEDOn ("); break;
case OPCODE_NATIVE_CALL_LED_OFF: __printf ("LEDOff ("); break;
case OPCODE_NATIVE_CALL_LED_ONCE: __printf ("LEDOnce ("); break;
case OPCODE_NATIVE_CALL_WAIT: __printf ("wait ("); break;
case OPCODE_NATIVE_CALL_PRINT: __printf ("print ("); break;
case OPCODE_NATIVE_CALL_LED_TOGGLE: printf ("LEDToggle ("); break;
case OPCODE_NATIVE_CALL_LED_ON: printf ("LEDOn ("); break;
case OPCODE_NATIVE_CALL_LED_OFF: printf ("LEDOff ("); break;
case OPCODE_NATIVE_CALL_LED_ONCE: printf ("LEDOnce ("); break;
case OPCODE_NATIVE_CALL_WAIT: printf ("wait ("); break;
case OPCODE_NATIVE_CALL_PRINT: printf ("print ("); break;
default: JERRY_UNREACHABLE ();
}
break;
}
case NAME_TO_ID (construct_n):
{
__printf ("%s = new %s (", var_to_str (start_op, NULL, start, 1),
var_to_str (start_op, NULL, start, 2));
printf ("%s = new %s (", var_to_str (start_op, NULL, start, 1),
var_to_str (start_op, NULL, start, 2));
break;
}
case NAME_TO_ID (func_decl_n):
{
__printf ("function %s (", var_to_str (start_op, NULL, start, 1));
printf ("function %s (", var_to_str (start_op, NULL, start, 1));
break;
}
case NAME_TO_ID (func_expr_n):
{
if (start_op.data.func_expr_n.name_lit_idx == INVALID_VALUE)
{
__printf ("%s = function (", var_to_str (start_op, NULL, start, 1));
printf ("%s = function (", var_to_str (start_op, NULL, start, 1));
}
else
{
__printf ("%s = function %s (", var_to_str (start_op, NULL, start, 1),
var_to_str (start_op, NULL, start, 2));
printf ("%s = function %s (", var_to_str (start_op, NULL, start, 1),
var_to_str (start_op, NULL, start, 2));
}
break;
}
case NAME_TO_ID (array_decl):
{
__printf ("%s = [", var_to_str (start_op, NULL, start, 1));
printf ("%s = [", var_to_str (start_op, NULL, start, 1));
break;
}
case NAME_TO_ID (obj_decl):
{
__printf ("%s = {", var_to_str (start_op, NULL, start, 1));
printf ("%s = {", var_to_str (start_op, NULL, start, 1));
break;
}
default:
@ -536,30 +536,30 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
case OPCODE_META_TYPE_THIS_ARG:
{
__printf ("this_arg = %s", var_to_str (meta_op, NULL, counter, 2));
printf ("this_arg = %s", var_to_str (meta_op, NULL, counter, 2));
break;
}
case OPCODE_META_TYPE_VARG:
{
__printf ("%s", var_to_str (meta_op, NULL, counter, 2));
printf ("%s", var_to_str (meta_op, NULL, counter, 2));
break;
}
case OPCODE_META_TYPE_VARG_PROP_DATA:
{
__printf ("%s:%s", var_to_str (meta_op, NULL, counter, 2),
var_to_str (meta_op, NULL, counter, 3));
printf ("%s:%s", var_to_str (meta_op, NULL, counter, 2),
var_to_str (meta_op, NULL, counter, 3));
break;
}
case OPCODE_META_TYPE_VARG_PROP_GETTER:
{
__printf ("%s = get %s ();", var_to_str (meta_op, NULL, counter, 2),
var_to_str (meta_op, NULL, counter, 3));
printf ("%s = get %s ();", var_to_str (meta_op, NULL, counter, 2),
var_to_str (meta_op, NULL, counter, 3));
break;
}
case OPCODE_META_TYPE_VARG_PROP_SETTER:
{
__printf ("%s = set (%s);", var_to_str (meta_op, NULL, counter, 2),
var_to_str (meta_op, NULL, counter, 3));
printf ("%s = set (%s);", var_to_str (meta_op, NULL, counter, 2),
var_to_str (meta_op, NULL, counter, 3));
break;
}
default:
@ -569,7 +569,7 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
}
if (counter != oc)
{
__printf (", ");
printf (", ");
}
break;
}
@ -579,17 +579,17 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
{
case NAME_TO_ID (array_decl):
{
__printf ("];");
printf ("];");
break;
}
case NAME_TO_ID (obj_decl):
{
__printf ("};");
printf ("};");
break;
}
default:
{
__printf (");");
printf (");");
}
}
}
@ -597,37 +597,37 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
}
case OPCODE_META_TYPE_END_WITH:
{
__printf ("end with;");
printf ("end with;");
break;
}
case OPCODE_META_TYPE_FUNCTION_END:
{
__printf ("function end: %d;", oc + OC (2, 3));
printf ("function end: %d;", oc + OC (2, 3));
break;
}
case OPCODE_META_TYPE_CATCH:
{
__printf ("catch end: %d;", oc + OC (2, 3));
printf ("catch end: %d;", oc + OC (2, 3));
break;
}
case OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER:
{
__printf ("catch (%s);", VAR (2));
printf ("catch (%s);", VAR (2));
break;
}
case OPCODE_META_TYPE_FINALLY:
{
__printf ("finally end: %d;", oc + OC (2, 3));
printf ("finally end: %d;", oc + OC (2, 3));
break;
}
case OPCODE_META_TYPE_END_TRY_CATCH_FINALLY:
{
__printf ("end try");
printf ("end try");
break;
}
case OPCODE_META_TYPE_STRICT_CODE:
{
__printf ("use strict;");
printf ("use strict;");
break;
}
default:
@ -645,9 +645,9 @@ pp_op_meta (opcode_counter_t oc, op_meta opm, bool rewrite)
if (rewrite)
{
__printf (" // REWRITE");
printf (" // REWRITE");
}
__printf ("\n");
printf ("\n");
}
#endif /* JERRY_ENABLE_PRETTY_PRINTER */

View File

@ -58,17 +58,17 @@ interp_mem_stats_print_legend (void)
return;
}
__printf ("----- Legend of memory usage trace during interpretation -----\n\n"
"\tEntering block = beginning execution of initial (global) scope or function.\n\n"
"\tInformation on each value is formatted as following: (p -> n ( [+-]c, local l, peak g), where:\n"
"\t p - value just before starting of item's execution;\n"
"\t n - value just after end of item's execution;\n"
"\t [+-c] - difference between n and p;\n"
"\t l - temporary usage of memory during item's execution;\n"
"\t g - global peak of the value during program's execution.\n\n"
"\tChunks are items allocated in a pool."
" If there is no pool with a free chunk upon chunk allocation request,\n"
"\tthen new pool is allocated on the heap (that causes increase of number of allocated heap bytes).\n\n");
printf ("----- Legend of memory usage trace during interpretation -----\n\n"
"\tEntering block = beginning execution of initial (global) scope or function.\n\n"
"\tInformation on each value is formatted as following: (p -> n ( [+-]c, local l, peak g), where:\n"
"\t p - value just before starting of item's execution;\n"
"\t n - value just after end of item's execution;\n"
"\t [+-c] - difference between n and p;\n"
"\t l - temporary usage of memory during item's execution;\n"
"\t g - global peak of the value during program's execution.\n\n"
"\tChunks are items allocated in a pool."
" If there is no pool with a free chunk upon chunk allocation request,\n"
"\tthen new pool is allocated on the heap (that causes increase of number of allocated heap bytes).\n\n");
}
static void
@ -114,7 +114,7 @@ interp_mem_stats_context_enter (int_data_t *int_data_p,
INTERP_MEM_PRINT_INDENTATION_MAX);
char indent_prefix[INTERP_MEM_PRINT_INDENTATION_MAX + 2];
__memset (indent_prefix, ' ', sizeof (indent_prefix));
memset (indent_prefix, ' ', sizeof (indent_prefix));
indent_prefix [indentation] = '|';
indent_prefix [indentation + 1] = '\0';
@ -127,16 +127,16 @@ interp_mem_stats_context_enter (int_data_t *int_data_p,
&int_data_p->pools_stats_context_enter,
false, false);
__printf ("\n%s--- Beginning interpretation of a block at position %u ---\n"
"%s Allocated heap bytes: %5u\n"
"%s Waste heap bytes: %5u\n"
"%s Pools: %5u\n"
"%s Allocated pool chunks: %5u\n\n",
indent_prefix, (uint32_t) block_position,
indent_prefix, int_data_p->heap_stats_context_enter.allocated_bytes,
indent_prefix, int_data_p->heap_stats_context_enter.waste_bytes,
indent_prefix, int_data_p->pools_stats_context_enter.pools_count,
indent_prefix, int_data_p->pools_stats_context_enter.allocated_chunks);
printf ("\n%s--- Beginning interpretation of a block at position %u ---\n"
"%s Allocated heap bytes: %5u\n"
"%s Waste heap bytes: %5u\n"
"%s Pools: %5u\n"
"%s Allocated pool chunks: %5u\n\n",
indent_prefix, (uint32_t) block_position,
indent_prefix, int_data_p->heap_stats_context_enter.allocated_bytes,
indent_prefix, int_data_p->heap_stats_context_enter.waste_bytes,
indent_prefix, int_data_p->pools_stats_context_enter.pools_count,
indent_prefix, int_data_p->pools_stats_context_enter.allocated_chunks);
}
static void
@ -152,7 +152,7 @@ interp_mem_stats_context_exit (int_data_t *int_data_p,
INTERP_MEM_PRINT_INDENTATION_MAX);
char indent_prefix[INTERP_MEM_PRINT_INDENTATION_MAX + 2];
__memset (indent_prefix, ' ', sizeof (indent_prefix));
memset (indent_prefix, ' ', sizeof (indent_prefix));
indent_prefix [indentation] = '|';
indent_prefix [indentation + 1] = '\0';
@ -172,40 +172,40 @@ interp_mem_stats_context_exit (int_data_t *int_data_p,
int_data_p->context_peak_allocated_pool_chunks -= JERRY_MAX (int_data_p->pools_stats_context_enter.allocated_chunks,
pools_stats_context_exit.allocated_chunks);
__printf ("%sAllocated heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
int_data_p->heap_stats_context_enter.allocated_bytes,
heap_stats_context_exit.allocated_bytes,
heap_stats_context_exit.allocated_bytes - int_data_p->heap_stats_context_enter.allocated_bytes,
int_data_p->context_peak_allocated_heap_bytes,
heap_stats_context_exit.global_peak_allocated_bytes);
printf ("%sAllocated heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
int_data_p->heap_stats_context_enter.allocated_bytes,
heap_stats_context_exit.allocated_bytes,
heap_stats_context_exit.allocated_bytes - int_data_p->heap_stats_context_enter.allocated_bytes,
int_data_p->context_peak_allocated_heap_bytes,
heap_stats_context_exit.global_peak_allocated_bytes);
__printf ("%sWaste heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
int_data_p->heap_stats_context_enter.waste_bytes,
heap_stats_context_exit.waste_bytes,
heap_stats_context_exit.waste_bytes - int_data_p->heap_stats_context_enter.waste_bytes,
int_data_p->context_peak_waste_heap_bytes,
heap_stats_context_exit.global_peak_waste_bytes);
printf ("%sWaste heap bytes in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
int_data_p->heap_stats_context_enter.waste_bytes,
heap_stats_context_exit.waste_bytes,
heap_stats_context_exit.waste_bytes - int_data_p->heap_stats_context_enter.waste_bytes,
int_data_p->context_peak_waste_heap_bytes,
heap_stats_context_exit.global_peak_waste_bytes);
__printf ("%sPools count in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
int_data_p->pools_stats_context_enter.pools_count,
pools_stats_context_exit.pools_count,
pools_stats_context_exit.pools_count - int_data_p->pools_stats_context_enter.pools_count,
int_data_p->context_peak_pools_count,
pools_stats_context_exit.global_peak_pools_count);
printf ("%sPools count in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
int_data_p->pools_stats_context_enter.pools_count,
pools_stats_context_exit.pools_count,
pools_stats_context_exit.pools_count - int_data_p->pools_stats_context_enter.pools_count,
int_data_p->context_peak_pools_count,
pools_stats_context_exit.global_peak_pools_count);
__printf ("%sAllocated pool chunks in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
int_data_p->pools_stats_context_enter.allocated_chunks,
pools_stats_context_exit.allocated_chunks,
pools_stats_context_exit.allocated_chunks - int_data_p->pools_stats_context_enter.allocated_chunks,
int_data_p->context_peak_allocated_pool_chunks,
pools_stats_context_exit.global_peak_allocated_chunks);
printf ("%sAllocated pool chunks in the context: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
int_data_p->pools_stats_context_enter.allocated_chunks,
pools_stats_context_exit.allocated_chunks,
pools_stats_context_exit.allocated_chunks - int_data_p->pools_stats_context_enter.allocated_chunks,
int_data_p->context_peak_allocated_pool_chunks,
pools_stats_context_exit.global_peak_allocated_chunks);
__printf ("\n%s--- End of interpretation of a block at position %u ---\n\n",
indent_prefix, (uint32_t) block_position);
printf ("\n%s--- End of interpretation of a block at position %u ---\n\n",
indent_prefix, (uint32_t) block_position);
}
static void
@ -222,7 +222,7 @@ interp_mem_stats_opcode_enter (opcode_counter_t opcode_position,
INTERP_MEM_PRINT_INDENTATION_MAX);
char indent_prefix[INTERP_MEM_PRINT_INDENTATION_MAX + 2];
__memset (indent_prefix, ' ', sizeof (indent_prefix));
memset (indent_prefix, ' ', sizeof (indent_prefix));
indent_prefix [indentation] = '|';
indent_prefix [indentation + 1] = '\0';
@ -232,8 +232,8 @@ interp_mem_stats_opcode_enter (opcode_counter_t opcode_position,
opcode_t opcode = read_opcode (opcode_position);
__printf ("%s-- Opcode: %s (position %u) --\n",
indent_prefix, __op_names [opcode.op_idx], (uint32_t) opcode_position);
printf ("%s-- Opcode: %s (position %u) --\n",
indent_prefix, __op_names [opcode.op_idx], (uint32_t) opcode_position);
interp_mem_stats_print_indentation += INTERP_MEM_PRINT_INDENTATION_STEP;
}
@ -255,7 +255,7 @@ interp_mem_stats_opcode_exit (int_data_t *int_data_p,
INTERP_MEM_PRINT_INDENTATION_MAX);
char indent_prefix[INTERP_MEM_PRINT_INDENTATION_MAX + 2];
__memset (indent_prefix, ' ', sizeof (indent_prefix));
memset (indent_prefix, ' ', sizeof (indent_prefix));
indent_prefix [indentation] = '|';
indent_prefix [indentation + 1] = '\0';
@ -277,53 +277,53 @@ interp_mem_stats_opcode_exit (int_data_t *int_data_p,
opcode_t opcode = read_opcode (opcode_position);
__printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
heap_stats_before_p->allocated_bytes,
heap_stats_after.allocated_bytes,
heap_stats_after.allocated_bytes - heap_stats_before_p->allocated_bytes,
heap_stats_after.peak_allocated_bytes - JERRY_MAX (heap_stats_before_p->allocated_bytes,
heap_stats_after.allocated_bytes),
heap_stats_after.global_peak_allocated_bytes);
printf ("%s Allocated heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
heap_stats_before_p->allocated_bytes,
heap_stats_after.allocated_bytes,
heap_stats_after.allocated_bytes - heap_stats_before_p->allocated_bytes,
heap_stats_after.peak_allocated_bytes - JERRY_MAX (heap_stats_before_p->allocated_bytes,
heap_stats_after.allocated_bytes),
heap_stats_after.global_peak_allocated_bytes);
if (heap_stats_before_p->waste_bytes != heap_stats_after.waste_bytes)
{
__printf ("%s Waste heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
heap_stats_before_p->waste_bytes,
heap_stats_after.waste_bytes,
heap_stats_after.waste_bytes - heap_stats_before_p->waste_bytes,
heap_stats_after.peak_waste_bytes - JERRY_MAX (heap_stats_before_p->waste_bytes,
heap_stats_after.waste_bytes),
heap_stats_after.global_peak_waste_bytes);
printf ("%s Waste heap bytes: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
heap_stats_before_p->waste_bytes,
heap_stats_after.waste_bytes,
heap_stats_after.waste_bytes - heap_stats_before_p->waste_bytes,
heap_stats_after.peak_waste_bytes - JERRY_MAX (heap_stats_before_p->waste_bytes,
heap_stats_after.waste_bytes),
heap_stats_after.global_peak_waste_bytes);
}
if (pools_stats_before_p->pools_count != pools_stats_after.pools_count)
{
__printf ("%s Pools: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
pools_stats_before_p->pools_count,
pools_stats_after.pools_count,
pools_stats_after.pools_count - pools_stats_before_p->pools_count,
pools_stats_after.peak_pools_count - JERRY_MAX (pools_stats_before_p->pools_count,
pools_stats_after.pools_count),
pools_stats_after.global_peak_pools_count);
printf ("%s Pools: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
pools_stats_before_p->pools_count,
pools_stats_after.pools_count,
pools_stats_after.pools_count - pools_stats_before_p->pools_count,
pools_stats_after.peak_pools_count - JERRY_MAX (pools_stats_before_p->pools_count,
pools_stats_after.pools_count),
pools_stats_after.global_peak_pools_count);
}
if (pools_stats_before_p->allocated_chunks != pools_stats_after.allocated_chunks)
{
__printf ("%s Allocated pool chunks: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
pools_stats_before_p->allocated_chunks,
pools_stats_after.allocated_chunks,
pools_stats_after.allocated_chunks - pools_stats_before_p->allocated_chunks,
pools_stats_after.peak_allocated_chunks - JERRY_MAX (pools_stats_before_p->allocated_chunks,
pools_stats_after.allocated_chunks),
pools_stats_after.global_peak_allocated_chunks);
printf ("%s Allocated pool chunks: %5u -> %5u (%+5d, local %5u, peak %5u)\n",
indent_prefix,
pools_stats_before_p->allocated_chunks,
pools_stats_after.allocated_chunks,
pools_stats_after.allocated_chunks - pools_stats_before_p->allocated_chunks,
pools_stats_after.peak_allocated_chunks - JERRY_MAX (pools_stats_before_p->allocated_chunks,
pools_stats_after.allocated_chunks),
pools_stats_after.global_peak_allocated_chunks);
}
__printf ("%s-- End of execution of opcode %s (position %u) --\n\n",
indent_prefix, __op_names [opcode.op_idx], opcode_position);
printf ("%s-- End of execution of opcode %s (position %u) --\n\n",
indent_prefix, __op_names [opcode.op_idx], opcode_position);
}
#endif /* MEM_STATS */
@ -414,8 +414,8 @@ run_int_loop (int_data_t *int_data)
mem_heap_stats_t heap_stats_before;
mem_pools_stats_t pools_stats_before;
__memset (&heap_stats_before, 0, sizeof (heap_stats_before));
__memset (&pools_stats_before, 0, sizeof (pools_stats_before));
memset (&heap_stats_before, 0, sizeof (heap_stats_before));
memset (&pools_stats_before, 0, sizeof (pools_stats_before));
#endif /* MEM_STATS */
while (true)

View File

@ -65,7 +65,7 @@ main( int __unused argc,
ecma_number_to_zt_string (nums[i], zt_str, sizeof (zt_str));
if (__strcmp ((char*)zt_str, (char*)zt_strings [i]) != 0)
if (strcmp ((char*)zt_str, (char*)zt_strings [i]) != 0)
{
return 1;
}

View File

@ -48,7 +48,7 @@ main( int __unused argc,
srand((unsigned int) time(NULL));
unsigned int seed = (unsigned int)rand();
__printf("seed=%u\n", seed);
printf("seed=%u\n", seed);
srand(seed);
for ( uint32_t i = 0; i < test_iters; i++ )
@ -62,7 +62,7 @@ main( int __unused argc,
if ( ptrs[j] != NULL )
{
__memset(ptrs[j], 0, MEM_POOL_CHUNK_SIZE);
memset(ptrs[j], 0, MEM_POOL_CHUNK_SIZE);
}
}
@ -86,8 +86,8 @@ main( int __unused argc,
mem_pools_stats_t stats;
mem_pools_get_stats( &stats);
__printf("Pools stats:\n");
__printf(" Chunk size: %u\n"
printf("Pools stats:\n");
printf(" Chunk size: %u\n"
" Pools: %lu\n"
" Allocated chunks: %lu\n"
" Free chunks: %lu\n"

View File

@ -33,7 +33,7 @@ main( int __unused argc,
mem_init ();
deserializer_init ();
parser_init (program, __strlen (program), true);
parser_init (program, strlen (program), true);
parser_parse_program ();
parser_free ();