From 1d2a686532a9774c3a13df9b3626e91d105d5882 Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Fri, 10 Nov 2017 13:12:44 +0100 Subject: [PATCH] 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 --- jerry-libc/jerry-libc-init.c | 4 +- jerry-libc/jerry-libc-printf.c | 10 ++-- jerry-libc/jerry-libc.c | 54 +++++++++++++++------ jerry-libc/target/posix/jerry-libc-target.c | 50 ++----------------- 4 files changed, 52 insertions(+), 66 deletions(-) diff --git a/jerry-libc/jerry-libc-init.c b/jerry-libc/jerry-libc-init.c index 712359b59..3d346662f 100644 --- a/jerry-libc/jerry-libc-init.c +++ b/jerry-libc/jerry-libc-init.c @@ -46,7 +46,7 @@ extern void _fini (void); /** * No-op default _init. */ -void __attr_weak___ +void __attr_weak___ _init (void) { } /* _init */ @@ -54,7 +54,7 @@ _init (void) /** * No-op default _fini. */ -void __attr_weak___ +void __attr_weak___ _fini (void) { } /* _fini */ diff --git a/jerry-libc/jerry-libc-printf.c b/jerry-libc/jerry-libc-printf.c index cc9366c78..7c29978ec 100644 --- a/jerry-libc/jerry-libc-printf.c +++ b/jerry-libc/jerry-libc-printf.c @@ -120,6 +120,9 @@ libc_printf_justified_string_output (FILE *stream, /**< stream pointer */ /** * 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 * libc_printf_uint_to_string (uintmax_t value, /**< integer value */ @@ -717,9 +720,9 @@ 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 */ + ...) /**< parameters' values */ { va_list args; @@ -739,7 +742,7 @@ fprintf (FILE *stream, /**< stream pointer */ */ int printf (const char *format, /**< format string */ - ...) /**< parameters' values */ + ...) /**< parameters' values */ { va_list args; @@ -751,4 +754,3 @@ printf (const char *format, /**< format string */ return ret; } /* printf */ - diff --git a/jerry-libc/jerry-libc.c b/jerry-libc/jerry-libc.c index 54002d0ad..cde857892 100644 --- a/jerry-libc/jerry-libc.c +++ b/jerry-libc/jerry-libc.c @@ -57,8 +57,8 @@ CALL_PRAGMA (GCC optimize ("-fno-tree-loop-distribute-patterns")) * @return @a s */ void * __attr_used___ -memset (void *s, /**< area to set values in */ - int c, /**< value to set */ +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; @@ -97,6 +97,8 @@ memcmp (const void *s1, /**< first area */ /** * memcpy + * + * @return the dest pointer's value */ void * __attr_used___ memcpy (void *s1, /**< destination */ @@ -174,10 +176,15 @@ 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. */ +/** + * 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, /**< first string */ + const char *s2) /**< second string */ { while (1) { @@ -192,11 +199,16 @@ strcmp (const char *s1, const char *s2) } } /* 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, - or be greater than the first n character of s2. */ +/** + * 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, 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, /**< first string */ + const char *s2, /**< second string */ + size_t n) /**< maximum number of characters to compare */ { while (n--) { @@ -213,11 +225,19 @@ strncmp (const char *s1, const char *s2, size_t n) return 0; } /* 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. - @return a pointer to the destination string dest. */ +/** + * Copy a string. At most n bytes of src are copied. + * + * 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___ -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--) { @@ -233,9 +253,13 @@ strncpy (char *dest, const char *src, size_t n) return dest; } /* strncpy */ -/** Calculate the length of a string. */ +/** + * Calculate the length of a string. + * + * @return the length. + */ size_t -strlen (const char *s) +strlen (const char *s) /**< string */ { size_t i = 0; while (s[i]) diff --git a/jerry-libc/target/posix/jerry-libc-target.c b/jerry-libc/target/posix/jerry-libc-target.c index c1cdc7597..019c31b82 100644 --- a/jerry-libc/target/posix/jerry-libc-target.c +++ b/jerry-libc/target/posix/jerry-libc-target.c @@ -88,9 +88,12 @@ abort (void) /** * Send a signal to the current process. + * + * @return 0 - upon successful completion, + * non-zero value - otherwise. */ int __attr_used___ -raise (int sig) +raise (int sig) /**< signal number */ { return (int) syscall_2 (SYSCALL_NO (kill), syscall_0 (SYSCALL_NO (getpid)), sig); } /* raise */ @@ -99,7 +102,7 @@ raise (int sig) * fopen * * @return FILE pointer - upon successful completion, - * NULL - otherwise + * NULL - otherwise. */ FILE * 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); } /* 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 */