Whitespace gardening in jerry-libc (#2082)
Also includes the addition and styling of some doc comments (but those are whitespace too). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -46,7 +46,7 @@ extern void _fini (void);
|
|||||||
/**
|
/**
|
||||||
* No-op default _init.
|
* No-op default _init.
|
||||||
*/
|
*/
|
||||||
void __attr_weak___
|
void __attr_weak___
|
||||||
_init (void)
|
_init (void)
|
||||||
{
|
{
|
||||||
} /* _init */
|
} /* _init */
|
||||||
@@ -54,7 +54,7 @@ _init (void)
|
|||||||
/**
|
/**
|
||||||
* No-op default _fini.
|
* No-op default _fini.
|
||||||
*/
|
*/
|
||||||
void __attr_weak___
|
void __attr_weak___
|
||||||
_fini (void)
|
_fini (void)
|
||||||
{
|
{
|
||||||
} /* _fini */
|
} /* _fini */
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ libc_printf_justified_string_output (FILE *stream, /**< stream pointer */
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* printf helper function that converts unsigned integer to string
|
* printf helper function that converts unsigned integer to string
|
||||||
|
*
|
||||||
|
* @return start of the string representation (within the output string buffer
|
||||||
|
* but not necessarily at its start)
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
libc_printf_uint_to_string (uintmax_t value, /**< integer value */
|
libc_printf_uint_to_string (uintmax_t value, /**< integer value */
|
||||||
@@ -717,9 +720,9 @@ vfprintf (FILE *stream, /**< stream pointer */
|
|||||||
* @return number of characters printed
|
* @return number of characters printed
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
fprintf (FILE *stream, /**< stream pointer */
|
fprintf (FILE *stream, /**< stream pointer */
|
||||||
const char *format, /**< format string */
|
const char *format, /**< format string */
|
||||||
...) /**< parameters' values */
|
...) /**< parameters' values */
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@@ -739,7 +742,7 @@ fprintf (FILE *stream, /**< stream pointer */
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
printf (const char *format, /**< format string */
|
printf (const char *format, /**< format string */
|
||||||
...) /**< parameters' values */
|
...) /**< parameters' values */
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@@ -751,4 +754,3 @@ printf (const char *format, /**< format string */
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
} /* printf */
|
} /* printf */
|
||||||
|
|
||||||
|
|||||||
+39
-15
@@ -57,8 +57,8 @@ CALL_PRAGMA (GCC optimize ("-fno-tree-loop-distribute-patterns"))
|
|||||||
* @return @a s
|
* @return @a s
|
||||||
*/
|
*/
|
||||||
void * __attr_used___
|
void * __attr_used___
|
||||||
memset (void *s, /**< area to set values in */
|
memset (void *s, /**< area to set values in */
|
||||||
int c, /**< value to set */
|
int c, /**< value to set */
|
||||||
size_t n) /**< area size */
|
size_t n) /**< area size */
|
||||||
{
|
{
|
||||||
uint8_t *area_p = (uint8_t *) s;
|
uint8_t *area_p = (uint8_t *) s;
|
||||||
@@ -97,6 +97,8 @@ memcmp (const void *s1, /**< first area */
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* memcpy
|
* memcpy
|
||||||
|
*
|
||||||
|
* @return the dest pointer's value
|
||||||
*/
|
*/
|
||||||
void * __attr_used___
|
void * __attr_used___
|
||||||
memcpy (void *s1, /**< destination */
|
memcpy (void *s1, /**< destination */
|
||||||
@@ -174,10 +176,15 @@ CALL_PRAGMA (GCC pop_options)
|
|||||||
CALL_PRAGMA (GCC diagnostic pop)
|
CALL_PRAGMA (GCC diagnostic pop)
|
||||||
#endif /* __GNUC__ */
|
#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. */
|
* 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
|
int
|
||||||
strcmp (const char *s1, const char *s2)
|
strcmp (const char *s1, /**< first string */
|
||||||
|
const char *s2) /**< second string */
|
||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -192,11 +199,16 @@ strcmp (const char *s1, const char *s2)
|
|||||||
}
|
}
|
||||||
} /* strcmp */
|
} /* strcmp */
|
||||||
|
|
||||||
/** Compare two strings. return an integer less than, equal to, or greater than zero
|
/**
|
||||||
if the first n character of s1 is found, respectively, to be less than, to match,
|
* Compare two strings.
|
||||||
or be greater than the first n character of s2. */
|
*
|
||||||
|
* @return an integer less than, equal to, or greater than zero 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
|
int
|
||||||
strncmp (const char *s1, const char *s2, size_t n)
|
strncmp (const char *s1, /**< first string */
|
||||||
|
const char *s2, /**< second string */
|
||||||
|
size_t n) /**< maximum number of characters to compare */
|
||||||
{
|
{
|
||||||
while (n--)
|
while (n--)
|
||||||
{
|
{
|
||||||
@@ -213,11 +225,19 @@ strncmp (const char *s1, const char *s2, size_t n)
|
|||||||
return 0;
|
return 0;
|
||||||
} /* strncmp */
|
} /* strncmp */
|
||||||
|
|
||||||
/** Copy a string. At most n bytes of src are copied. Warning: If there is no
|
/**
|
||||||
null byte among the first n bytes of src, the string placed in dest will not be null-terminated.
|
* Copy a string. At most n bytes of src are copied.
|
||||||
@return a pointer to the destination string dest. */
|
*
|
||||||
|
* Note:
|
||||||
|
* If there is no 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 * __attr_used___
|
char * __attr_used___
|
||||||
strncpy (char *dest, const char *src, size_t n)
|
strncpy (char *dest, /**< destination string */
|
||||||
|
const char *src, /**< source string */
|
||||||
|
size_t n) /**< maximum number of characters to copy */
|
||||||
{
|
{
|
||||||
while (n--)
|
while (n--)
|
||||||
{
|
{
|
||||||
@@ -233,9 +253,13 @@ strncpy (char *dest, const char *src, size_t n)
|
|||||||
return dest;
|
return dest;
|
||||||
} /* strncpy */
|
} /* strncpy */
|
||||||
|
|
||||||
/** Calculate the length of a string. */
|
/**
|
||||||
|
* Calculate the length of a string.
|
||||||
|
*
|
||||||
|
* @return the length.
|
||||||
|
*/
|
||||||
size_t
|
size_t
|
||||||
strlen (const char *s)
|
strlen (const char *s) /**< string */
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (s[i])
|
while (s[i])
|
||||||
|
|||||||
@@ -88,9 +88,12 @@ abort (void)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a signal to the current process.
|
* Send a signal to the current process.
|
||||||
|
*
|
||||||
|
* @return 0 - upon successful completion,
|
||||||
|
* non-zero value - otherwise.
|
||||||
*/
|
*/
|
||||||
int __attr_used___
|
int __attr_used___
|
||||||
raise (int sig)
|
raise (int sig) /**< signal number */
|
||||||
{
|
{
|
||||||
return (int) syscall_2 (SYSCALL_NO (kill), syscall_0 (SYSCALL_NO (getpid)), sig);
|
return (int) syscall_2 (SYSCALL_NO (kill), syscall_0 (SYSCALL_NO (getpid)), sig);
|
||||||
} /* raise */
|
} /* raise */
|
||||||
@@ -99,7 +102,7 @@ raise (int sig)
|
|||||||
* fopen
|
* fopen
|
||||||
*
|
*
|
||||||
* @return FILE pointer - upon successful completion,
|
* @return FILE pointer - upon successful completion,
|
||||||
* NULL - otherwise
|
* NULL - otherwise.
|
||||||
*/
|
*/
|
||||||
FILE *
|
FILE *
|
||||||
fopen (const char *path, /**< file path */
|
fopen (const char *path, /**< file path */
|
||||||
@@ -274,46 +277,3 @@ gettimeofday (void *tp, /**< struct timeval */
|
|||||||
{
|
{
|
||||||
return (int) syscall_2 (SYSCALL_NO (gettimeofday), (long int) tp, (long int) tzp);
|
return (int) syscall_2 (SYSCALL_NO (gettimeofday), (long int) tp, (long int) tzp);
|
||||||
} /* gettimeofday */
|
} /* gettimeofday */
|
||||||
|
|
||||||
/* FIXME */
|
|
||||||
#if 0
|
|
||||||
/**
|
|
||||||
* Setup new memory limits
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
jrt_set_mem_limits (size_t data_size, /**< limit for data + bss + brk heap */
|
|
||||||
size_t stack_size) /**< limit for stack */
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned long long rlim_cur;
|
|
||||||
unsigned long long rlim_max;
|
|
||||||
} data_limit = { data_size, data_size };
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned long long rlim_cur;
|
|
||||||
unsigned long long rlim_max;
|
|
||||||
} stack_limit = { stack_size, stack_size };
|
|
||||||
|
|
||||||
long int ret;
|
|
||||||
|
|
||||||
#if defined (__TARGET_HOST_x64)
|
|
||||||
ret = syscall_2 (SYSCALL_NO (setrlimit), RLIMIT_DATA, (intptr_t) &data_limit);
|
|
||||||
assert (ret == 0);
|
|
||||||
|
|
||||||
ret = syscall_2 (SYSCALL_NO (setrlimit), RLIMIT_STACK, (intptr_t) &stack_limit);
|
|
||||||
assert (ret == 0);
|
|
||||||
#elif defined (__TARGET_HOST_ARMv7)
|
|
||||||
ret = syscall_3 (SYSCALL_NO (prlimit64), 0, RLIMIT_DATA, (intptr_t) &data_limit);
|
|
||||||
assert (ret == 0);
|
|
||||||
|
|
||||||
ret = syscall_3 (SYSCALL_NO (prlimit64), 0, RLIMIT_STACK, (intptr_t) &stack_limit);
|
|
||||||
assert (ret == 0);
|
|
||||||
#elif defined (__TARGET_HOST_x86)
|
|
||||||
# error "__TARGET_HOST_x86 case is not implemented"
|
|
||||||
#else /* !__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86 */
|
|
||||||
# error "!__TARGET_HOST_x64 && !__TARGET_HOST_ARMv7 && !__TARGET_HOST_x86"
|
|
||||||
#endif /* __TARGET_HOST_x64 */
|
|
||||||
} /* jrt_set_mem_limits */
|
|
||||||
#endif /* 0 */
|
|
||||||
|
|||||||
Reference in New Issue
Block a user