Style fixes in libruntime.
This commit is contained in:
+43
-17
@@ -27,61 +27,87 @@
|
||||
* and call assertion fail handler.
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_exit( jerry_status_t code) /**< status code */
|
||||
jerry_exit (jerry_status_t code) /**< status code */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
if ( code != ERR_OK )
|
||||
if (code != ERR_OK)
|
||||
{
|
||||
__printf("Error: ");
|
||||
__printf ("Error: ");
|
||||
|
||||
switch ( code )
|
||||
switch (code)
|
||||
{
|
||||
case ERR_OK:
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
case ERR_IO:
|
||||
__printf("ERR_IO\n");
|
||||
{
|
||||
__printf ("ERR_IO\n");
|
||||
break;
|
||||
}
|
||||
case ERR_BUFFER_SIZE:
|
||||
__printf("ERR_BUFFER_SIZE\n");
|
||||
{
|
||||
__printf ("ERR_BUFFER_SIZE\n");
|
||||
break;
|
||||
}
|
||||
case ERR_SEVERAL_FILES:
|
||||
__printf("ERR_SEVERAL_FILES\n");
|
||||
{
|
||||
__printf ("ERR_SEVERAL_FILES\n");
|
||||
break;
|
||||
}
|
||||
case ERR_NO_FILES:
|
||||
__printf("ERR_NO_FILES\n");
|
||||
{
|
||||
__printf ("ERR_NO_FILES\n");
|
||||
break;
|
||||
}
|
||||
case ERR_NON_CHAR:
|
||||
__printf("ERR_NON_CHAR\n");
|
||||
{
|
||||
__printf ("ERR_NON_CHAR\n");
|
||||
break;
|
||||
}
|
||||
case ERR_UNCLOSED:
|
||||
__printf("ERR_UNCLOSED\n");
|
||||
{
|
||||
__printf ("ERR_UNCLOSED\n");
|
||||
break;
|
||||
}
|
||||
case ERR_INT_LITERAL:
|
||||
__printf("ERR_INT_LITERAL\n");
|
||||
{
|
||||
__printf ("ERR_INT_LITERAL\n");
|
||||
break;
|
||||
}
|
||||
case ERR_STRING:
|
||||
__printf("ERR_STRING\n");
|
||||
{
|
||||
__printf ("ERR_STRING\n");
|
||||
break;
|
||||
}
|
||||
case ERR_PARSER:
|
||||
__printf("ERR_PARSER\n");
|
||||
{
|
||||
__printf ("ERR_PARSER\n");
|
||||
break;
|
||||
}
|
||||
case ERR_MEMORY:
|
||||
__printf("ERR_MEMORY\n");
|
||||
{
|
||||
__printf ("ERR_MEMORY\n");
|
||||
break;
|
||||
}
|
||||
case ERR_SYSCALL:
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
case ERR_GENERAL:
|
||||
__printf("ERR_GENERAL\n");
|
||||
{
|
||||
__printf ("ERR_GENERAL\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* The failed assertion is 'Return code is zero' */
|
||||
jerry_assert_fail( "Return code is zero", __FILE__, __LINE__);
|
||||
jerry_assert_fail ("Return code is zero", __FILE__, __LINE__);
|
||||
}
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
__exit( -code );
|
||||
__exit (-code);
|
||||
} /* jerry_exit */
|
||||
|
||||
|
||||
+228
-158
@@ -46,71 +46,71 @@ typedef uint8_t libc_printf_arg_flags_mask_t;
|
||||
/**
|
||||
* Left justification of field's contents
|
||||
*/
|
||||
#define LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY ( 1 << 0 )
|
||||
#define LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY (1 << 0)
|
||||
|
||||
/**
|
||||
* Force print of number's sign
|
||||
*/
|
||||
#define LIBC_PRINTF_ARG_FLAG_PRINT_SIGN ( 1 << 1 )
|
||||
#define LIBC_PRINTF_ARG_FLAG_PRINT_SIGN (1 << 1)
|
||||
|
||||
/**
|
||||
* If no sign is printed, print space before value
|
||||
*/
|
||||
#define LIBC_PRINTF_ARG_FLAG_SPACE ( 1 << 2 )
|
||||
#define LIBC_PRINTF_ARG_FLAG_SPACE (1 << 2)
|
||||
|
||||
/**
|
||||
* For o, x, X preceed value with 0, 0x or 0X for non-zero values.
|
||||
*/
|
||||
#define LIBC_PRINTF_ARG_FLAG_SHARP ( 1 << 3 )
|
||||
#define LIBC_PRINTF_ARG_FLAG_SHARP (1 << 3)
|
||||
|
||||
/**
|
||||
* Left-pad field with zeroes instead of spaces
|
||||
*/
|
||||
#define LIBC_PRINTF_ARG_FLAG_ZERO_PADDING ( 1 << 4 )
|
||||
#define LIBC_PRINTF_ARG_FLAG_ZERO_PADDING (1 << 4)
|
||||
|
||||
/**
|
||||
* printf helper function that outputs a char
|
||||
*/
|
||||
static void
|
||||
libc_printf_putchar( _FILE *stream, /**< stream pointer */
|
||||
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 */
|
||||
|
||||
/**
|
||||
* printf helper function that outputs justified string
|
||||
*/
|
||||
static void
|
||||
libc_printf_justified_string_output( _FILE *stream, /**< stream pointer */
|
||||
libc_printf_justified_string_output (_FILE *stream, /**< stream pointer */
|
||||
const char *string_p, /**< string */
|
||||
size_t width, /**< minimum field width */
|
||||
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;
|
||||
|
||||
if ( !is_left_justify )
|
||||
if (!is_left_justify)
|
||||
{
|
||||
char padding_char = is_zero_padding ? '0' : ' ';
|
||||
|
||||
while ( outputted_length + str_length < width )
|
||||
while (outputted_length + str_length < width)
|
||||
{
|
||||
libc_printf_putchar( stream, padding_char);
|
||||
libc_printf_putchar (stream, padding_char);
|
||||
outputted_length++;
|
||||
}
|
||||
}
|
||||
|
||||
__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 )
|
||||
if (is_left_justify)
|
||||
{
|
||||
while( outputted_length < width )
|
||||
while (outputted_length < width)
|
||||
{
|
||||
libc_printf_putchar( stream, ' ');
|
||||
libc_printf_putchar (stream, ' ');
|
||||
outputted_length++;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ libc_printf_justified_string_output( _FILE *stream, /**< stream pointer */
|
||||
* printf helper function that converts unsigned integer to string
|
||||
*/
|
||||
static char*
|
||||
libc_printf_uint_to_string( uintmax_t value, /**< integer value */
|
||||
libc_printf_uint_to_string (uintmax_t value, /**< integer value */
|
||||
char *buffer_p, /**< buffer for output string */
|
||||
size_t buffer_size, /**< buffer size */
|
||||
const char *alphabet, /**< alphabet used for digits */
|
||||
@@ -130,20 +130,20 @@ libc_printf_uint_to_string( uintmax_t value, /**< integer value */
|
||||
char *str_p = str_buffer_end;
|
||||
*--str_p = '\0';
|
||||
|
||||
JERRY_ASSERT( radix >= 2 );
|
||||
JERRY_ASSERT(radix >= 2);
|
||||
|
||||
if ( ( radix & ( radix - 1 ) ) != 0 )
|
||||
if ((radix & (radix - 1)) != 0)
|
||||
{
|
||||
/*
|
||||
* Radix is not power of 2. Only 32-bit numbers are supported in this mode.
|
||||
*/
|
||||
JERRY_ASSERT( ( value >> 32 ) == 0 );
|
||||
JERRY_ASSERT((value >> 32) == 0);
|
||||
|
||||
uint32_t value_lo = (uint32_t) value;
|
||||
|
||||
while ( value_lo != 0 )
|
||||
while (value_lo != 0)
|
||||
{
|
||||
JERRY_ASSERT ( str_p != buffer_p );
|
||||
JERRY_ASSERT (str_p != buffer_p);
|
||||
|
||||
*--str_p = alphabet[ value_lo % radix ];
|
||||
value_lo /= radix;
|
||||
@@ -152,34 +152,34 @@ libc_printf_uint_to_string( uintmax_t value, /**< integer value */
|
||||
else
|
||||
{
|
||||
uint32_t shift = 0;
|
||||
while ( !( radix & ( 1u << shift ) ) )
|
||||
while (!(radix & (1u << shift)))
|
||||
{
|
||||
shift++;
|
||||
|
||||
JERRY_ASSERT( shift <= 32 );
|
||||
JERRY_ASSERT(shift <= 32);
|
||||
}
|
||||
|
||||
uint32_t value_lo = (uint32_t) value;
|
||||
uint32_t value_hi = (uint32_t) ( value >> 32 );
|
||||
uint32_t value_hi = (uint32_t) (value >> 32);
|
||||
|
||||
while ( value_lo != 0
|
||||
|| value_hi != 0 )
|
||||
while (value_lo != 0
|
||||
|| value_hi != 0)
|
||||
{
|
||||
JERRY_ASSERT ( str_p != buffer_p );
|
||||
JERRY_ASSERT (str_p != buffer_p);
|
||||
|
||||
*--str_p = alphabet[ value_lo & ( radix - 1 ) ];
|
||||
*--str_p = alphabet[ value_lo & (radix - 1) ];
|
||||
value_lo >>= shift;
|
||||
value_lo += ( value_hi & ( radix - 1 ) ) << ( 32 - shift );
|
||||
value_lo += (value_hi & (radix - 1)) << (32 - shift);
|
||||
value_hi >>= shift;
|
||||
}
|
||||
}
|
||||
|
||||
if ( *str_p == '\0' )
|
||||
if (*str_p == '\0')
|
||||
{
|
||||
*--str_p = '0';
|
||||
}
|
||||
|
||||
JERRY_ASSERT( str_p >= buffer_p && str_p < str_buffer_end );
|
||||
JERRY_ASSERT(str_p >= buffer_p && str_p < str_buffer_end);
|
||||
|
||||
return str_p;
|
||||
} /* libc_printf_uint_to_string */
|
||||
@@ -190,101 +190,119 @@ libc_printf_uint_to_string( uintmax_t value, /**< integer value */
|
||||
* @return updated va_list
|
||||
*/
|
||||
static void
|
||||
libc_printf_write_d_i( _FILE *stream, /**< stream pointer */
|
||||
libc_printf_write_d_i (_FILE *stream, /**< stream pointer */
|
||||
va_list* args_list_p, /**< args' list */
|
||||
libc_printf_arg_flags_mask_t flags, /**< field's flags */
|
||||
libc_printf_arg_length_type_t length, /**< field's length type */
|
||||
uint32_t width) /**< minimum field width to output */
|
||||
{
|
||||
JERRY_ASSERT( ( flags & LIBC_PRINTF_ARG_FLAG_SHARP ) == 0 );
|
||||
JERRY_ASSERT((flags & LIBC_PRINTF_ARG_FLAG_SHARP) == 0);
|
||||
|
||||
bool is_signed = true;
|
||||
uintmax_t value = 0;
|
||||
|
||||
/* true - positive, false - negative */
|
||||
bool sign = true;
|
||||
const uintmax_t value_sign_mask = ((uintmax_t)1) << ( sizeof(value) * JERRY_BITSINBYTE - 1 );
|
||||
const uintmax_t value_sign_mask = ((uintmax_t)1) << (sizeof (value) * JERRY_BITSINBYTE - 1);
|
||||
|
||||
switch ( length )
|
||||
switch (length)
|
||||
{
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_NONE:
|
||||
value = (uintmax_t)va_arg( *args_list_p, int);
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, int);
|
||||
break;
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_HH:
|
||||
value = (uintmax_t)va_arg( *args_list_p, int); /* char is promoted to int */
|
||||
break;
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_H:
|
||||
value = (uintmax_t)va_arg( *args_list_p, int); /* short int is promoted to int */
|
||||
break;
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_L:
|
||||
value = (uintmax_t)va_arg( *args_list_p, long int);
|
||||
break;
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_LL:
|
||||
value = (uintmax_t)va_arg( *args_list_p, long long int);
|
||||
break;
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_J:
|
||||
value = (uintmax_t)va_arg( *args_list_p, intmax_t);
|
||||
break;
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_Z:
|
||||
is_signed = false;
|
||||
value = (uintmax_t)va_arg( *args_list_p, size_t);
|
||||
break;
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_T:
|
||||
is_signed = false;
|
||||
value = (uintmax_t)va_arg( *args_list_p, ptrdiff_t);
|
||||
break;
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_HIGHL:
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
|
||||
if ( is_signed )
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_HH:
|
||||
{
|
||||
sign = ( ( value & value_sign_mask ) == 0 );
|
||||
value = (uintmax_t)va_arg (*args_list_p, int); /* char is promoted to int */
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !sign )
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_H:
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, int); /* short int is promoted to int */
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_L:
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, long int);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_LL:
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, long long int);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_J:
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, intmax_t);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_Z:
|
||||
{
|
||||
is_signed = false;
|
||||
value = (uintmax_t)va_arg (*args_list_p, size_t);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_T:
|
||||
{
|
||||
is_signed = false;
|
||||
value = (uintmax_t)va_arg (*args_list_p, ptrdiff_t);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_HIGHL:
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
if (is_signed)
|
||||
{
|
||||
sign = ((value & value_sign_mask) == 0);
|
||||
|
||||
if (!sign)
|
||||
{
|
||||
value = (uintmax_t) (-value);
|
||||
}
|
||||
}
|
||||
|
||||
char str_buffer[ 32 ];
|
||||
const char *string_p = libc_printf_uint_to_string( value,
|
||||
const char *string_p = libc_printf_uint_to_string (value,
|
||||
str_buffer,
|
||||
sizeof(str_buffer),
|
||||
sizeof (str_buffer),
|
||||
"0123456789",
|
||||
10);
|
||||
|
||||
if ( !sign
|
||||
|| ( flags & LIBC_PRINTF_ARG_FLAG_PRINT_SIGN ) )
|
||||
if (!sign
|
||||
|| (flags & LIBC_PRINTF_ARG_FLAG_PRINT_SIGN))
|
||||
{
|
||||
/* printing sign */
|
||||
|
||||
libc_printf_putchar( stream, sign ? '+' : '-' );
|
||||
if ( width > 0 )
|
||||
libc_printf_putchar (stream, sign ? '+' : '-');
|
||||
if (width > 0)
|
||||
{
|
||||
width--;
|
||||
}
|
||||
}
|
||||
else if ( flags & LIBC_PRINTF_ARG_FLAG_SPACE )
|
||||
else if (flags & LIBC_PRINTF_ARG_FLAG_SPACE)
|
||||
{
|
||||
/* no sign and space flag, printing one space */
|
||||
|
||||
libc_printf_putchar( stream, ' ');
|
||||
if ( width > 0 )
|
||||
libc_printf_putchar (stream, ' ');
|
||||
if (width > 0)
|
||||
{
|
||||
width--;
|
||||
}
|
||||
}
|
||||
|
||||
libc_printf_justified_string_output( stream,
|
||||
libc_printf_justified_string_output (stream,
|
||||
string_p,
|
||||
width,
|
||||
flags & LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY,
|
||||
@@ -297,7 +315,7 @@ libc_printf_write_d_i( _FILE *stream, /**< stream pointer */
|
||||
* @return updated va_list
|
||||
*/
|
||||
static void
|
||||
libc_printf_write_u_o_x_X( _FILE *stream, /**< stream pointer */
|
||||
libc_printf_write_u_o_x_X(_FILE *stream, /**< stream pointer */
|
||||
char specifier, /**< specifier (u, o, x, X) */
|
||||
va_list* args_list_p, /**< args' list */
|
||||
libc_printf_arg_flags_mask_t flags, /**< field's flags */
|
||||
@@ -306,61 +324,79 @@ libc_printf_write_u_o_x_X( _FILE *stream, /**< stream pointer */
|
||||
{
|
||||
uintmax_t value = 0;
|
||||
|
||||
switch ( length )
|
||||
switch (length)
|
||||
{
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_NONE:
|
||||
value = (uintmax_t)va_arg( *args_list_p, unsigned int);
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, unsigned int);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_HH:
|
||||
value = (uintmax_t)va_arg( *args_list_p, unsigned int); /* char is promoted to int */
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, unsigned int); /* char is promoted to int */
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_H:
|
||||
value = (uintmax_t)va_arg( *args_list_p, unsigned int); /* short int is promoted to int */
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, unsigned int); /* short int is promoted to int */
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_L:
|
||||
value = (uintmax_t)va_arg( *args_list_p, unsigned long int);
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, unsigned long int);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_LL:
|
||||
value = (uintmax_t)va_arg( *args_list_p, unsigned long long int);
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, unsigned long long int);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_J:
|
||||
value = (uintmax_t)va_arg( *args_list_p, uintmax_t);
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, uintmax_t);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_Z:
|
||||
value = (uintmax_t)va_arg( *args_list_p, size_t);
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, size_t);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_T:
|
||||
value = (uintmax_t)va_arg( *args_list_p, ptrdiff_t);
|
||||
{
|
||||
value = (uintmax_t)va_arg (*args_list_p, ptrdiff_t);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIBC_PRINTF_ARG_LENGTH_TYPE_HIGHL:
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
|
||||
if ( flags & LIBC_PRINTF_ARG_FLAG_SHARP )
|
||||
{
|
||||
if ( value != 0 && specifier != 'u' )
|
||||
{
|
||||
libc_printf_putchar( stream, '0');
|
||||
|
||||
if ( specifier == 'x' )
|
||||
{
|
||||
libc_printf_putchar( stream, 'x');
|
||||
}
|
||||
else if ( specifier == 'X' )
|
||||
|
||||
if (flags & LIBC_PRINTF_ARG_FLAG_SHARP)
|
||||
{
|
||||
libc_printf_putchar( stream, 'X');
|
||||
if (value != 0 && specifier != 'u')
|
||||
{
|
||||
libc_printf_putchar (stream, '0');
|
||||
|
||||
if (specifier == 'x')
|
||||
{
|
||||
libc_printf_putchar (stream, 'x');
|
||||
}
|
||||
else if (specifier == 'X')
|
||||
{
|
||||
libc_printf_putchar (stream, 'X');
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT( specifier == 'o' );
|
||||
JERRY_ASSERT(specifier == 'o');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -368,61 +404,71 @@ libc_printf_write_u_o_x_X( _FILE *stream, /**< stream pointer */
|
||||
uint32_t radix = 10;
|
||||
const char *alphabet;
|
||||
|
||||
switch ( specifier )
|
||||
switch (specifier)
|
||||
{
|
||||
case 'u':
|
||||
{
|
||||
alphabet = "0123456789";
|
||||
radix = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'o':
|
||||
{
|
||||
alphabet = "01234567";
|
||||
radix = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'x':
|
||||
{
|
||||
alphabet = "0123456789abcdef";
|
||||
radix = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'X':
|
||||
{
|
||||
alphabet = "0123456789ABCDEF";
|
||||
radix = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
char str_buffer[ 32 ];
|
||||
const char *string_p = libc_printf_uint_to_string( value,
|
||||
const char *string_p = libc_printf_uint_to_string (value,
|
||||
str_buffer,
|
||||
sizeof(str_buffer),
|
||||
sizeof (str_buffer),
|
||||
alphabet,
|
||||
radix);
|
||||
|
||||
if ( flags & LIBC_PRINTF_ARG_FLAG_PRINT_SIGN )
|
||||
if (flags & LIBC_PRINTF_ARG_FLAG_PRINT_SIGN)
|
||||
{
|
||||
/* printing sign */
|
||||
|
||||
libc_printf_putchar( stream, '+');
|
||||
if ( width > 0 )
|
||||
libc_printf_putchar (stream, '+');
|
||||
if (width > 0)
|
||||
{
|
||||
width--;
|
||||
}
|
||||
}
|
||||
else if ( flags & LIBC_PRINTF_ARG_FLAG_SPACE )
|
||||
else if (flags & LIBC_PRINTF_ARG_FLAG_SPACE)
|
||||
{
|
||||
/* no sign and space flag, printing one space */
|
||||
|
||||
libc_printf_putchar( stream, ' ');
|
||||
if ( width > 0 )
|
||||
libc_printf_putchar (stream, ' ');
|
||||
if (width > 0)
|
||||
{
|
||||
width--;
|
||||
}
|
||||
}
|
||||
|
||||
libc_printf_justified_string_output( stream,
|
||||
libc_printf_justified_string_output (stream,
|
||||
string_p,
|
||||
width,
|
||||
flags & LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY,
|
||||
@@ -435,21 +481,21 @@ 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 */
|
||||
{
|
||||
va_list args_copy;
|
||||
|
||||
va_copy( args_copy, args);
|
||||
va_copy (args_copy, args);
|
||||
|
||||
const char *format_iter_p = format;
|
||||
|
||||
while ( *format_iter_p )
|
||||
while (*format_iter_p)
|
||||
{
|
||||
if ( *format_iter_p != '%' )
|
||||
if (*format_iter_p != '%')
|
||||
{
|
||||
libc_printf_putchar( stream, *format_iter_p);
|
||||
libc_printf_putchar (stream, *format_iter_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -457,27 +503,27 @@ __vfprintf( _FILE *stream, /**< stream pointer */
|
||||
uint32_t width = 0;
|
||||
libc_printf_arg_length_type_t length = LIBC_PRINTF_ARG_LENGTH_TYPE_NONE;
|
||||
|
||||
while ( true )
|
||||
while (true)
|
||||
{
|
||||
format_iter_p++;
|
||||
|
||||
if ( *format_iter_p == '-' )
|
||||
if (*format_iter_p == '-')
|
||||
{
|
||||
flags |= LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY;
|
||||
}
|
||||
else if ( *format_iter_p == '+' )
|
||||
else if (*format_iter_p == '+')
|
||||
{
|
||||
flags |= LIBC_PRINTF_ARG_FLAG_PRINT_SIGN;
|
||||
}
|
||||
else if ( *format_iter_p == ' ' )
|
||||
else if (*format_iter_p == ' ')
|
||||
{
|
||||
flags |= LIBC_PRINTF_ARG_FLAG_SPACE;
|
||||
}
|
||||
else if ( *format_iter_p == '#' )
|
||||
else if (*format_iter_p == '#')
|
||||
{
|
||||
flags |= LIBC_PRINTF_ARG_FLAG_SHARP;
|
||||
}
|
||||
else if ( *format_iter_p == '0' )
|
||||
else if (*format_iter_p == '0')
|
||||
{
|
||||
flags |= LIBC_PRINTF_ARG_FLAG_ZERO_PADDING;
|
||||
}
|
||||
@@ -487,29 +533,30 @@ __vfprintf( _FILE *stream, /**< stream pointer */
|
||||
}
|
||||
}
|
||||
|
||||
if ( *format_iter_p == '*' )
|
||||
if (*format_iter_p == '*')
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
// If there is a number, recognize it as field width
|
||||
while ( *format_iter_p >= '0' && *format_iter_p <= '9' )
|
||||
while (*format_iter_p >= '0' && *format_iter_p <= '9')
|
||||
{
|
||||
width = width * 10u + (uint32_t) (*format_iter_p - '0');
|
||||
|
||||
format_iter_p++;
|
||||
}
|
||||
|
||||
if ( *format_iter_p == '.' )
|
||||
if (*format_iter_p == '.')
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
switch ( *format_iter_p )
|
||||
switch (*format_iter_p)
|
||||
{
|
||||
case 'h':
|
||||
{
|
||||
format_iter_p++;
|
||||
if ( *format_iter_p == 'h' )
|
||||
if (*format_iter_p == 'h')
|
||||
{
|
||||
format_iter_p++;
|
||||
|
||||
@@ -520,10 +567,12 @@ __vfprintf( _FILE *stream, /**< stream pointer */
|
||||
length = LIBC_PRINTF_ARG_LENGTH_TYPE_H;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'l':
|
||||
{
|
||||
format_iter_p++;
|
||||
if ( *format_iter_p == 'l' )
|
||||
if (*format_iter_p == 'l')
|
||||
{
|
||||
format_iter_p++;
|
||||
|
||||
@@ -534,41 +583,54 @@ __vfprintf( _FILE *stream, /**< stream pointer */
|
||||
length = LIBC_PRINTF_ARG_LENGTH_TYPE_L;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'j':
|
||||
{
|
||||
format_iter_p++;
|
||||
length = LIBC_PRINTF_ARG_LENGTH_TYPE_J;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'z':
|
||||
{
|
||||
format_iter_p++;
|
||||
length = LIBC_PRINTF_ARG_LENGTH_TYPE_Z;
|
||||
break;
|
||||
}
|
||||
|
||||
case 't':
|
||||
{
|
||||
format_iter_p++;
|
||||
length = LIBC_PRINTF_ARG_LENGTH_TYPE_T;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'L':
|
||||
{
|
||||
format_iter_p++;
|
||||
length = LIBC_PRINTF_ARG_LENGTH_TYPE_HIGHL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch ( *format_iter_p )
|
||||
switch (*format_iter_p)
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
libc_printf_write_d_i( stream, &args_copy, flags, length, width);
|
||||
{
|
||||
libc_printf_write_d_i (stream, &args_copy, flags, length, width);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'u':
|
||||
case 'o':
|
||||
case 'x':
|
||||
case 'X':
|
||||
libc_printf_write_u_o_x_X( stream, *format_iter_p, &args_copy, flags, length, width);
|
||||
{
|
||||
libc_printf_write_u_o_x_X(stream, *format_iter_p, &args_copy, flags, length, width);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'f':
|
||||
case 'F':
|
||||
@@ -578,11 +640,14 @@ __vfprintf( _FILE *stream, /**< stream pointer */
|
||||
case 'G':
|
||||
case 'a':
|
||||
case 'A':
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c':
|
||||
if ( length & LIBC_PRINTF_ARG_LENGTH_TYPE_L )
|
||||
{
|
||||
if (length & LIBC_PRINTF_ARG_LENGTH_TYPE_L)
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
@@ -590,68 +655,73 @@ __vfprintf( _FILE *stream, /**< stream pointer */
|
||||
{
|
||||
char str[2] =
|
||||
{
|
||||
(char)va_arg( args_copy, int), /* char is promoted to int */
|
||||
(char)va_arg (args_copy, int), /* char is promoted to int */
|
||||
'\0'
|
||||
};
|
||||
|
||||
libc_printf_justified_string_output( stream,
|
||||
libc_printf_justified_string_output (stream,
|
||||
str,
|
||||
width,
|
||||
flags & LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY,
|
||||
flags & LIBC_PRINTF_ARG_FLAG_ZERO_PADDING);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 's':
|
||||
if ( length & LIBC_PRINTF_ARG_LENGTH_TYPE_L )
|
||||
{
|
||||
if (length & LIBC_PRINTF_ARG_LENGTH_TYPE_L)
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
else
|
||||
{
|
||||
char *str_p = va_arg( args_copy, char*);
|
||||
char *str_p = va_arg (args_copy, char*);
|
||||
|
||||
libc_printf_justified_string_output( stream,
|
||||
libc_printf_justified_string_output (stream,
|
||||
str_p,
|
||||
width,
|
||||
flags & LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY,
|
||||
flags & LIBC_PRINTF_ARG_FLAG_ZERO_PADDING);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'p':
|
||||
{
|
||||
va_list args_copy2;
|
||||
va_copy( args_copy2, args_copy);
|
||||
void *value = va_arg( args_copy2, void*);
|
||||
va_end( args_copy2);
|
||||
va_copy (args_copy2, args_copy);
|
||||
void *value = va_arg (args_copy2, void*);
|
||||
va_end (args_copy2);
|
||||
|
||||
if ( value == NULL )
|
||||
if (value == NULL)
|
||||
{
|
||||
__printf( "(nil)");
|
||||
__printf ("(nil)");
|
||||
}
|
||||
else
|
||||
{
|
||||
libc_printf_write_u_o_x_X( stream,
|
||||
libc_printf_write_u_o_x_X(stream,
|
||||
'x',
|
||||
&args_copy,
|
||||
flags | LIBC_PRINTF_ARG_FLAG_SHARP,
|
||||
LIBC_PRINTF_ARG_LENGTH_TYPE_Z,
|
||||
width);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'n':
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
format_iter_p++;
|
||||
}
|
||||
|
||||
va_end( args_copy);
|
||||
va_end (args_copy);
|
||||
|
||||
return 0;
|
||||
} /* __vfprintf */
|
||||
@@ -662,17 +732,17 @@ __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 */
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, format);
|
||||
va_start (args, format);
|
||||
|
||||
int ret = __vfprintf( stream, format, args);
|
||||
int ret = __vfprintf (stream, format, args);
|
||||
|
||||
va_end( args);
|
||||
va_end (args);
|
||||
|
||||
return ret;
|
||||
} /* __fprintf */
|
||||
@@ -683,16 +753,16 @@ __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);
|
||||
va_start (args, format);
|
||||
|
||||
int ret = __vfprintf( LIBC_STDOUT, format, args);
|
||||
int ret = __vfprintf (LIBC_STDOUT, format, args);
|
||||
|
||||
va_end( args);
|
||||
va_end (args);
|
||||
|
||||
return ret;
|
||||
} /* __printf */
|
||||
|
||||
+58
-25
@@ -19,23 +19,23 @@
|
||||
|
||||
#include "jerry-libc.h"
|
||||
|
||||
FIXME( #ifndef LIBC_MUSL should be removed from here when own libc will be implemented )
|
||||
FIXME(#ifndef LIBC_MUSL should be removed from here when own libc will be implemented)
|
||||
|
||||
#ifndef LIBC_MUSL
|
||||
/**
|
||||
* memcpy alias to __memcpy (for compiler usage)
|
||||
*/
|
||||
extern void *memcpy(void *s1, const void*s2, size_t n);
|
||||
extern void *memcpy (void *s1, const void*s2, size_t n);
|
||||
|
||||
/**
|
||||
* memset alias to __memset (for compiler usage)
|
||||
*/
|
||||
extern void *memset(void *s, int c, size_t n);
|
||||
extern void *memset (void *s, int c, size_t n);
|
||||
|
||||
/**
|
||||
* memmove alias to __memmove (for compiler usage)
|
||||
*/
|
||||
extern void *memmove(void *s1, const void*s2, size_t n);
|
||||
extern void *memmove (void *s1, const void*s2, size_t n);
|
||||
|
||||
#ifdef __GNUC__
|
||||
/*
|
||||
@@ -53,31 +53,31 @@ CALL_PRAGMA(GCC optimize ("-fno-tree-loop-distribute-patterns"))
|
||||
/**
|
||||
* memcpy alias to __memcpy (for compiler usage)
|
||||
*/
|
||||
void* memcpy(void *s1, /**< destination */
|
||||
void* memcpy (void *s1, /**< destination */
|
||||
const void* s2, /**< source */
|
||||
size_t n) /**< bytes number */
|
||||
{
|
||||
return __memcpy(s1, s2, n);
|
||||
return __memcpy (s1, s2, n);
|
||||
} /* memcpy */
|
||||
|
||||
/**
|
||||
* memset alias to __memset (for compiler usage)
|
||||
*/
|
||||
void* memset(void *s, /**< area to set values in */
|
||||
void* memset (void *s, /**< area to set values in */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
return __memset(s, c, n);
|
||||
return __memset (s, c, n);
|
||||
} /* memset */
|
||||
|
||||
/**
|
||||
* memmove alias to __memmove (for compiler usage)
|
||||
*/
|
||||
void* memmove(void *s1, /**< destination*/
|
||||
void* memmove (void *s1, /**< destination*/
|
||||
const void*s2, /**< source */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
return __memmove(s1, s2, n);
|
||||
return __memmove (s1, s2, n);
|
||||
} /* memmove */
|
||||
|
||||
#ifdef __GNUC__
|
||||
@@ -93,12 +93,12 @@ CALL_PRAGMA(GCC diagnostic pop)
|
||||
* @return @s
|
||||
*/
|
||||
void*
|
||||
__memset(void *s, /**< area to set values in */
|
||||
__memset (void *s, /**< area to set values in */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
uint8_t *area_p = s;
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
for (size_t index = 0; index < n; index++)
|
||||
{
|
||||
area_p[ index ] = (uint8_t)c;
|
||||
}
|
||||
@@ -114,17 +114,18 @@ __memset(void *s, /**< area to set values in */
|
||||
* 1, otherwise
|
||||
*/
|
||||
int
|
||||
__memcmp(const void *s1, /**< first area */
|
||||
__memcmp (const void *s1, /**< first area */
|
||||
const void *s2, /**< second area */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
const uint8_t *area1_p = s1, *area2_p = s2;
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
for (size_t index = 0; index < n; index++)
|
||||
{
|
||||
if ( area1_p[ index ] < area2_p[ index ] )
|
||||
if (area1_p[ index ] < area2_p[ index ])
|
||||
{
|
||||
return -1;
|
||||
} else if ( area1_p[ index ] > area2_p[ index ] )
|
||||
}
|
||||
else if (area1_p[ index ] > area2_p[ index ])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -137,14 +138,14 @@ __memcmp(const void *s1, /**< first area */
|
||||
* memcpy
|
||||
*/
|
||||
void *
|
||||
__memcpy(void *s1, /**< destination */
|
||||
__memcpy (void *s1, /**< destination */
|
||||
const void *s2, /**< source */
|
||||
size_t n) /**< bytes number */
|
||||
{
|
||||
uint8_t *area1_p = s1;
|
||||
const uint8_t *area2_p = s2;
|
||||
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
for (size_t index = 0; index < n; index++)
|
||||
{
|
||||
area1_p[ index ] = area2_p[ index ];
|
||||
}
|
||||
@@ -158,22 +159,23 @@ __memcpy(void *s1, /**< destination */
|
||||
* @return the dest pointer's value
|
||||
*/
|
||||
void *
|
||||
__memmove(void *s1, /**< destination */
|
||||
__memmove (void *s1, /**< destination */
|
||||
const void *s2, /**< source */
|
||||
size_t n) /**< bytes number */
|
||||
{
|
||||
uint8_t *dest_p = s1;
|
||||
const uint8_t *src_p = s2;
|
||||
|
||||
if ( dest_p < src_p )
|
||||
if (dest_p < src_p)
|
||||
{ /* from begin to end */
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
for (size_t index = 0; index < n; index++)
|
||||
{
|
||||
dest_p[ index ] = src_p[ index ];
|
||||
}
|
||||
} else if ( dest_p > src_p )
|
||||
}
|
||||
else if (dest_p > src_p)
|
||||
{ /* from end to begin */
|
||||
for ( size_t index = 1; index <= n; index++ )
|
||||
for (size_t index = 1; index <= n; index++)
|
||||
{
|
||||
dest_p[ n - index ] = src_p[ n - index ];
|
||||
}
|
||||
@@ -191,23 +193,35 @@ __strcmp (const char *s1, const char *s2)
|
||||
if (s1 == NULL)
|
||||
{
|
||||
if (s2 != NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (s2 == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; s1[i]; i++)
|
||||
{
|
||||
if (s1[i] > s2[i])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (s1[i] < s2[i])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (s2[i])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -222,20 +236,30 @@ __strncmp (const char *s1, const char *s2, size_t n)
|
||||
if (s1 == NULL)
|
||||
{
|
||||
if (s2 != NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (s2 == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (s1[i] > s2[i])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (s1[i] < s2[i])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -244,7 +268,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;
|
||||
|
||||
@@ -252,8 +276,10 @@ __strncpy(char *dest, const char *src, size_t n)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
if (src[i] == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
@@ -274,7 +300,10 @@ __strlen (const char *s)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; s[i]; i++)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -291,10 +320,14 @@ __isspace (int c)
|
||||
case '\r':
|
||||
case '\t':
|
||||
case '\v':
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks for an uppercase letter. */
|
||||
@@ -312,7 +345,7 @@ __islower (int c)
|
||||
}
|
||||
|
||||
/** Checks for an alphabetic character.
|
||||
In the standard "C" locale, it is equivalent to (isupper(c) || islower(c)). */
|
||||
In the standard "C" locale, it is equivalent to (isupper (c) || islower (c)). */
|
||||
int
|
||||
__isalpha (int c)
|
||||
{
|
||||
|
||||
+11
-11
@@ -91,19 +91,19 @@ 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 *, ...);
|
||||
|
||||
#define DBL_MANT_DIG ( 52)
|
||||
#define DBL_DIG ( 10)
|
||||
#define DBL_MANT_DIG (52)
|
||||
#define DBL_DIG (10)
|
||||
#define DBL_MIN_EXP (-324)
|
||||
#define DBL_MAX_EXP ( 308)
|
||||
#define DBL_MAX_EXP (308)
|
||||
#define HUGE_VAL (1e37f)
|
||||
|
||||
#endif /* JERRY_LIBC_H */
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
* syscall
|
||||
* mov %rax -> ret
|
||||
*/
|
||||
#define SYSCALL_1( syscall_no, arg1, ret) \
|
||||
__asm volatile ( "syscall" \
|
||||
: "=a" ( ret ) \
|
||||
#define SYSCALL_1(syscall_no, arg1, ret) \
|
||||
__asm volatile ("syscall" \
|
||||
: "=a" (ret) \
|
||||
: "a" (syscall_no), "D" (arg1) \
|
||||
: "rcx", "r11" );
|
||||
: "rcx", "r11");
|
||||
|
||||
/*
|
||||
* mov syscall_no -> %rax
|
||||
@@ -35,11 +35,11 @@
|
||||
* syscall
|
||||
* mov %rax -> ret
|
||||
*/
|
||||
#define SYSCALL_2( syscall_no, arg1, arg2, ret) \
|
||||
__asm volatile ( "syscall" \
|
||||
: "=a" ( ret ) \
|
||||
#define SYSCALL_2(syscall_no, arg1, arg2, ret) \
|
||||
__asm volatile ("syscall" \
|
||||
: "=a" (ret) \
|
||||
: "a" (syscall_no), "D" (arg1), "S" (arg2) \
|
||||
: "rcx", "r11" );
|
||||
: "rcx", "r11");
|
||||
|
||||
/*
|
||||
* mov syscall_no -> %rax
|
||||
@@ -49,11 +49,11 @@
|
||||
* syscall
|
||||
* mov %rax -> ret
|
||||
*/
|
||||
#define SYSCALL_3( syscall_no, arg1, arg2, arg3, ret) \
|
||||
__asm volatile ( "syscall" \
|
||||
: "=a" ( ret ) \
|
||||
#define SYSCALL_3(syscall_no, arg1, arg2, arg3, ret) \
|
||||
__asm volatile ("syscall" \
|
||||
: "=a" (ret) \
|
||||
: "a" (syscall_no), "D" (arg1), "S" (arg2), "d" (arg3) \
|
||||
: "rcx", "r11" );
|
||||
: "rcx", "r11");
|
||||
|
||||
#define _START \
|
||||
mov (%rsp), %rdi; \
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#ifndef LINUX_X86_ASM_H
|
||||
#define LINUX_X86_ASM_H
|
||||
|
||||
FIXME( Implement x86 ABI );
|
||||
FIXME(Implement x86 ABI);
|
||||
#error "Not implemented"
|
||||
|
||||
/*
|
||||
@@ -25,11 +25,11 @@ FIXME( Implement x86 ABI );
|
||||
* syscall
|
||||
* mov %rax -> ret
|
||||
*/
|
||||
#define SYSCALL_1( syscall_no, arg1, ret) \
|
||||
__asm ( "syscall" \
|
||||
: "=a" ( ret ) \
|
||||
#define SYSCALL_1 (syscall_no, arg1, ret) \
|
||||
__asm ("syscall" \
|
||||
: "=a" (ret) \
|
||||
: "a" (syscall_no), "D" (arg1) \
|
||||
: "rcx", "r11" );
|
||||
: "rcx", "r11");
|
||||
|
||||
/*
|
||||
* mov syscall_no -> %rax
|
||||
@@ -38,11 +38,11 @@ FIXME( Implement x86 ABI );
|
||||
* syscall
|
||||
* mov %rax -> ret
|
||||
*/
|
||||
#define SYSCALL_2( syscall_no, arg1, arg2, ret) \
|
||||
__asm ( "syscall" \
|
||||
: "=a" ( ret ) \
|
||||
#define SYSCALL_2 (syscall_no, arg1, arg2, ret) \
|
||||
__asm ("syscall" \
|
||||
: "=a" (ret) \
|
||||
: "a" (syscall_no), "D" (arg1), "S" (arg2) \
|
||||
: "rcx", "r11" );
|
||||
: "rcx", "r11");
|
||||
|
||||
/*
|
||||
* mov syscall_no -> %rax
|
||||
@@ -52,11 +52,11 @@ FIXME( Implement x86 ABI );
|
||||
* syscall
|
||||
* mov %rax -> ret
|
||||
*/
|
||||
#define SYSCALL_3( syscall_no, arg1, arg2, arg3, ret) \
|
||||
__asm ( "syscall" \
|
||||
: "=a" ( ret ) \
|
||||
#define SYSCALL_3 (syscall_no, arg1, arg2, arg3, ret) \
|
||||
__asm ("syscall" \
|
||||
: "=a" (ret) \
|
||||
: "a" (syscall_no), "D" (arg1), "S" (arg2), "d" (arg3) \
|
||||
: "rcx", "r11" );
|
||||
: "rcx", "r11");
|
||||
|
||||
#define _START \
|
||||
mov (%rsp), %rdi; \
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
* Handle failed assertion
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_assert_fail(const char *assertion, /**< assertion condition string */
|
||||
jerry_assert_fail (const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /** line */
|
||||
{
|
||||
__printf("Assertion '%s' failed at %s:%u\n",
|
||||
__printf ("Assertion '%s' failed at %s:%u\n",
|
||||
assertion, file, line);
|
||||
|
||||
__exit( -ERR_GENERAL);
|
||||
__exit (-ERR_GENERAL);
|
||||
} /* jerry_assert_fail */
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
|
||||
#ifdef __TARGET_HOST_x64
|
||||
# include "asm_x64.h"
|
||||
#elif defined(__TARGET_HOST_x86)
|
||||
#elif defined (__TARGET_HOST_x86)
|
||||
# include "asm_x86.h"
|
||||
#endif /* !__TARGET_HOST_x64 && TARGET_HOST_x86 */
|
||||
|
||||
FIXME( Rename __unused )
|
||||
FIXME(Rename __unused)
|
||||
#undef __unused
|
||||
|
||||
#include <unistd.h>
|
||||
@@ -42,15 +42,15 @@ FIXME( Rename __unused )
|
||||
/**
|
||||
* Exit program with ERR_SYSCALL if syscall_ret_val is negative
|
||||
*/
|
||||
#define LIBC_EXIT_ON_ERROR( syscall_ret_val) \
|
||||
if ( unlikely( ( syscall_ret_val ) < 0 ) ) \
|
||||
{ \
|
||||
__exit( -ERR_SYSCALL); \
|
||||
}
|
||||
#define LIBC_EXIT_ON_ERROR(syscall_ret_val) \
|
||||
if (unlikely ((syscall_ret_val) < 0)) \
|
||||
{ \
|
||||
__exit (-ERR_SYSCALL); \
|
||||
}
|
||||
|
||||
static long int syscall_1( long int syscall_no, long int arg1);
|
||||
static long int syscall_2( long int syscall_no, long int arg1, long int arg2);
|
||||
static long int syscall_3( long int syscall_no, long int arg1, long int arg2, long int arg3);
|
||||
static long int syscall_1 (long int syscall_no, long int arg1);
|
||||
static long int syscall_2 (long int syscall_no, long int arg1, long int arg2);
|
||||
static long int syscall_3 (long int syscall_no, long int arg1, long int arg2, long int arg3);
|
||||
|
||||
/**
|
||||
* System call with one argument.
|
||||
@@ -58,14 +58,14 @@ static long int syscall_3( long int syscall_no, long int arg1, long int arg2, lo
|
||||
* @return syscall's return value
|
||||
*/
|
||||
static long int
|
||||
syscall_1( long int syscall_no, /**< syscall number */
|
||||
syscall_1 (long int syscall_no, /**< syscall number */
|
||||
long int arg1) /**< argument */
|
||||
{
|
||||
long int ret;
|
||||
|
||||
SYSCALL_1( syscall_no, arg1, ret);
|
||||
SYSCALL_1 (syscall_no, arg1, ret);
|
||||
|
||||
LIBC_EXIT_ON_ERROR( ret );
|
||||
LIBC_EXIT_ON_ERROR(ret);
|
||||
|
||||
return ret;
|
||||
} /* syscall_1 */
|
||||
@@ -76,15 +76,15 @@ syscall_1( long int syscall_no, /**< syscall number */
|
||||
* @return syscall's return value
|
||||
*/
|
||||
static long int
|
||||
syscall_2( long int syscall_no, /**< syscall number */
|
||||
syscall_2 (long int syscall_no, /**< syscall number */
|
||||
long int arg1, /**< first argument */
|
||||
long int arg2) /**< second argument */
|
||||
{
|
||||
long int ret;
|
||||
|
||||
SYSCALL_2( syscall_no, arg1, arg2, ret);
|
||||
SYSCALL_2 (syscall_no, arg1, arg2, ret);
|
||||
|
||||
LIBC_EXIT_ON_ERROR( ret );
|
||||
LIBC_EXIT_ON_ERROR(ret);
|
||||
|
||||
return ret;
|
||||
} /* syscall_2 */
|
||||
@@ -95,16 +95,16 @@ syscall_2( long int syscall_no, /**< syscall number */
|
||||
* @return syscall's return value
|
||||
*/
|
||||
static long int
|
||||
syscall_3( long int syscall_no, /**< syscall number */
|
||||
syscall_3 (long int syscall_no, /**< syscall number */
|
||||
long int arg1, /**< first argument */
|
||||
long int arg2, /**< second argument */
|
||||
long int arg3) /**< third argument */
|
||||
{
|
||||
long int ret;
|
||||
|
||||
SYSCALL_3( syscall_no, arg1, arg2, arg3, ret);
|
||||
SYSCALL_3 (syscall_no, arg1, arg2, arg3, ret);
|
||||
|
||||
LIBC_EXIT_ON_ERROR( ret );
|
||||
LIBC_EXIT_ON_ERROR(ret);
|
||||
|
||||
return ret;
|
||||
} /* syscall_3 */
|
||||
@@ -113,7 +113,7 @@ syscall_3( long int syscall_no, /**< syscall number */
|
||||
int
|
||||
__putchar (int c)
|
||||
{
|
||||
__fwrite( &c, 1, sizeof(char), LIBC_STDOUT);
|
||||
__fwrite (&c, 1, sizeof (char), LIBC_STDOUT);
|
||||
|
||||
return c;
|
||||
} /* __putchar */
|
||||
@@ -124,13 +124,13 @@ __putchar (int c)
|
||||
void __noreturn
|
||||
__exit (int status) /**< status code */
|
||||
{
|
||||
syscall_1( __NR_close, (long int)LIBC_STDIN);
|
||||
syscall_1( __NR_close, (long int)LIBC_STDOUT);
|
||||
syscall_1( __NR_close, (long int)LIBC_STDERR);
|
||||
syscall_1 (__NR_close, (long int)LIBC_STDIN);
|
||||
syscall_1 (__NR_close, (long int)LIBC_STDOUT);
|
||||
syscall_1 (__NR_close, (long int)LIBC_STDERR);
|
||||
|
||||
syscall_1( __NR_exit_group, status);
|
||||
syscall_1 (__NR_exit_group, status);
|
||||
|
||||
while ( true )
|
||||
while (true)
|
||||
{
|
||||
/* unreachable */
|
||||
}
|
||||
@@ -143,88 +143,96 @@ __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,
|
||||
may_write = false,
|
||||
truncate = false,
|
||||
create_if_not_exist = false,
|
||||
position_at_end = false;
|
||||
bool may_read = false;
|
||||
bool may_write = false;
|
||||
bool truncate = false;
|
||||
bool create_if_not_exist = false;
|
||||
bool position_at_end = false;
|
||||
|
||||
JERRY_ASSERT( path != NULL && mode != NULL );
|
||||
JERRY_ASSERT( mode[1] == '+' || mode[1] == '\0' );
|
||||
JERRY_ASSERT(path != NULL && mode != NULL);
|
||||
JERRY_ASSERT(mode[1] == '+' || mode[1] == '\0');
|
||||
|
||||
switch( mode[0] )
|
||||
switch (mode[0])
|
||||
{
|
||||
case 'r':
|
||||
{
|
||||
may_read = true;
|
||||
may_write = (mode[1] == '+');
|
||||
break;
|
||||
}
|
||||
case 'w':
|
||||
{
|
||||
may_write = true;
|
||||
truncate = true;
|
||||
create_if_not_exist = true;
|
||||
may_read = (mode[1] == '+');
|
||||
break;
|
||||
}
|
||||
case 'a':
|
||||
{
|
||||
may_write = true;
|
||||
position_at_end = true;
|
||||
create_if_not_exist = true;
|
||||
if ( mode[1] == '+' )
|
||||
if (mode[1] == '+')
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
int access = S_IRUSR | S_IWUSR;
|
||||
if ( may_read && !may_write )
|
||||
if (may_read && !may_write)
|
||||
{
|
||||
flags = O_RDONLY;
|
||||
}
|
||||
else if ( !may_read && may_write )
|
||||
else if (!may_read && may_write)
|
||||
{
|
||||
flags = O_WRONLY;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT( may_read && may_write );
|
||||
JERRY_ASSERT(may_read && may_write);
|
||||
|
||||
flags = O_RDWR;
|
||||
}
|
||||
|
||||
if ( truncate )
|
||||
if (truncate)
|
||||
{
|
||||
flags |= O_TRUNC;
|
||||
}
|
||||
|
||||
if ( create_if_not_exist )
|
||||
if (create_if_not_exist)
|
||||
{
|
||||
flags |= O_CREAT;
|
||||
}
|
||||
|
||||
if ( position_at_end )
|
||||
if (position_at_end)
|
||||
{
|
||||
flags |= O_APPEND;
|
||||
}
|
||||
|
||||
long int ret = syscall_3( __NR_open, (long int)path, flags, access);
|
||||
long int ret = syscall_3 (__NR_open, (long int) path, flags, access);
|
||||
|
||||
return (void*)(uintptr_t)(ret);
|
||||
return (void*) (uintptr_t) (ret);
|
||||
} /* __fopen */
|
||||
|
||||
/**
|
||||
* The rewind() function sets the file position indicator
|
||||
* 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 */
|
||||
{
|
||||
syscall_3( __NR_lseek, (long int)stream, 0, SEEK_SET);
|
||||
syscall_3 (__NR_lseek, (long int) stream, 0, SEEK_SET);
|
||||
} /* __rewind */
|
||||
|
||||
/**
|
||||
@@ -234,9 +242,9 @@ __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);
|
||||
syscall_2 (__NR_close, (long int)fp, 0);
|
||||
|
||||
return 0;
|
||||
} /* __fclose */
|
||||
@@ -245,26 +253,32 @@ __fclose(_FILE *fp) /**< stream pointer */
|
||||
* 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 */
|
||||
{
|
||||
int whence_real = SEEK_CUR;
|
||||
switch ( whence )
|
||||
switch (whence)
|
||||
{
|
||||
case __SEEK_SET:
|
||||
{
|
||||
whence_real = SEEK_SET;
|
||||
break;
|
||||
}
|
||||
case __SEEK_CUR:
|
||||
{
|
||||
whence_real = SEEK_CUR;
|
||||
break;
|
||||
}
|
||||
case __SEEK_END:
|
||||
{
|
||||
whence_real = SEEK_END;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
syscall_3( __NR_lseek, (long int)fp, offset, whence_real);
|
||||
syscall_3 (__NR_lseek, (long int)fp, offset, whence_real);
|
||||
|
||||
return 0;
|
||||
} /* __fseek */
|
||||
@@ -273,9 +287,9 @@ __fseek(_FILE * fp, /**< stream pointer */
|
||||
* 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);
|
||||
long int ret = syscall_3 (__NR_lseek, (long int)fp, 0, SEEK_CUR);
|
||||
|
||||
return ret;
|
||||
} /* __ftell */
|
||||
@@ -286,7 +300,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 */
|
||||
@@ -296,10 +310,14 @@ __fread(void *ptr, /**< address of buffer to read to */
|
||||
|
||||
do
|
||||
{
|
||||
ret = syscall_3( __NR_read, (long int)stream, (long int) ((uint8_t*)ptr + bytes_read), (long int) (size * nmemb - bytes_read));
|
||||
ret = syscall_3 (__NR_read,
|
||||
(long int) stream,
|
||||
(long int) ((uint8_t*) ptr + bytes_read),
|
||||
(long int) (size * nmemb - bytes_read));
|
||||
|
||||
bytes_read += (size_t)ret;
|
||||
} while (bytes_read != size * nmemb && ret != 0);
|
||||
}
|
||||
while (bytes_read != size * nmemb && ret != 0);
|
||||
|
||||
return bytes_read;
|
||||
} /* __fread */
|
||||
@@ -310,7 +328,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 */
|
||||
@@ -319,15 +337,19 @@ __fwrite(const void *ptr, /**< data to write */
|
||||
|
||||
do
|
||||
{
|
||||
long int ret = syscall_3( __NR_write, (long int)stream, (long int) ((uint8_t*)ptr + bytes_written), (long int) (size * nmemb - bytes_written));
|
||||
long int ret = syscall_3 (__NR_write,
|
||||
(long int) stream,
|
||||
(long int) ((uint8_t*) ptr + bytes_written),
|
||||
(long int) (size * nmemb - bytes_written));
|
||||
|
||||
bytes_written += (size_t)ret;
|
||||
} while (bytes_written != size * nmemb);
|
||||
}
|
||||
while (bytes_written != size * nmemb);
|
||||
|
||||
return bytes_written;
|
||||
} /* __fwrite */
|
||||
|
||||
#elif defined(LIBC_MUSL)
|
||||
#elif defined (LIBC_MUSL)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -340,14 +362,14 @@ const _FILE **libc_stderr = (void*)&stderr;
|
||||
int
|
||||
__putchar (int c)
|
||||
{
|
||||
return putchar( c);
|
||||
return putchar (c);
|
||||
} /* __putchar */
|
||||
|
||||
/** exit - cause normal process termination */
|
||||
void __noreturn
|
||||
__exit (int status)
|
||||
{
|
||||
exit( status);
|
||||
exit (status);
|
||||
} /* __exit */
|
||||
|
||||
/**
|
||||
@@ -357,13 +379,13 @@ __exit (int status)
|
||||
* NULL - otherwise
|
||||
*/
|
||||
_FILE*
|
||||
__fopen(const char *path, /**< file path */
|
||||
__fopen (const char *path, /**< file path */
|
||||
const char *mode) /**< file open mode */
|
||||
{
|
||||
return fopen( path, mode);
|
||||
return fopen (path, mode);
|
||||
} /* __fopen */
|
||||
|
||||
/** The rewind() function sets the file position
|
||||
/** 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)
|
||||
@@ -378,44 +400,50 @@ __rewind (_FILE *stream)
|
||||
* non-zero value - otherwise.
|
||||
*/
|
||||
int
|
||||
__fclose(_FILE *fp) /**< stream pointer */
|
||||
__fclose (_FILE *fp) /**< stream pointer */
|
||||
{
|
||||
return fclose( fp);
|
||||
return fclose (fp);
|
||||
} /* __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 */
|
||||
{
|
||||
int whence_real = SEEK_CUR;
|
||||
switch ( whence )
|
||||
switch (whence)
|
||||
{
|
||||
case __SEEK_SET:
|
||||
{
|
||||
whence_real = SEEK_SET;
|
||||
break;
|
||||
}
|
||||
case __SEEK_CUR:
|
||||
{
|
||||
whence_real = SEEK_CUR;
|
||||
break;
|
||||
}
|
||||
case __SEEK_END:
|
||||
{
|
||||
whence_real = SEEK_END;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return fseek( fp, offset, whence_real);
|
||||
return fseek (fp, offset, whence_real);
|
||||
} /* __fseek */
|
||||
|
||||
/**
|
||||
* ftell
|
||||
*/
|
||||
long
|
||||
__ftell(_FILE * fp) /**< stream pointer */
|
||||
__ftell (_FILE * fp) /**< stream pointer */
|
||||
{
|
||||
return ftell( fp);
|
||||
return ftell (fp);
|
||||
} /* __ftell */
|
||||
|
||||
/**
|
||||
@@ -424,12 +452,12 @@ __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 */
|
||||
{
|
||||
return fread(ptr, size, nmemb, stream);
|
||||
return fread (ptr, size, nmemb, stream);
|
||||
} /* __fread */
|
||||
|
||||
/**
|
||||
@@ -438,12 +466,12 @@ __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 */
|
||||
{
|
||||
return fwrite(ptr, size, nmemb, stream);
|
||||
return fwrite (ptr, size, nmemb, stream);
|
||||
} /* __fwrite */
|
||||
|
||||
#else /* !LIBC_RAW && !LIBC_MUSL */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifdef __TARGET_HOST_x64
|
||||
# include "asm_x64.h"
|
||||
#elif defined(__TARGET_HOST_x86)
|
||||
#elif defined (__TARGET_HOST_x86)
|
||||
# include "asm_x86.h"
|
||||
#else /* !__HOST && !__TARGET_HOST_x86 */
|
||||
# error "!__HOST && !__TARGET_HOST_x86"
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
* Handle failed assertion
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_assert_fail(const char *assertion __unused, /**< assertion condition string */
|
||||
jerry_assert_fail (const char *assertion __unused, /**< assertion condition string */
|
||||
const char *file __unused, /**< file name */
|
||||
const uint32_t line __unused) /** line */
|
||||
{
|
||||
__exit( -ERR_GENERAL);
|
||||
__exit (-ERR_GENERAL);
|
||||
} /* jerry_assert_fail */
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
extern void __noreturn exit(int status);
|
||||
extern void __noreturn exit (int status);
|
||||
|
||||
/** Output of character. Writes the character c, cast to an unsigned char, to stdout. */
|
||||
int
|
||||
@@ -38,7 +38,7 @@ __exit (int status __unused)
|
||||
* TODO: Blink LEDs? status -> binary -> LEDs?
|
||||
*/
|
||||
|
||||
while(true);
|
||||
while (true);
|
||||
} /* __exit */
|
||||
|
||||
/**
|
||||
@@ -47,11 +47,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( ptr, size, nmemb, stream);
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(ptr, size, nmemb, stream);
|
||||
} /* __fwrite */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user