From 0aa9f3c0f2f2ff675c3c12ae5ac6ceb475d6a16f Mon Sep 17 00:00:00 2001 From: Alexei Fedorov Date: Tue, 14 Jul 2020 12:26:19 +0100 Subject: TF-A: Redefine true/false definitions This patch redefines 'true' and 'false' definitions in 'include/lib/libc/stdbool.h' to fix defect reported by MISRA C-2012 Rule 10.1 "The expression \"0\" of non-boolean essential type is being interpreted as a boolean value for the operator \"? :\"." Change-Id: Ie1b16e5826e5427cc272bd753e15d4d283e1ee4c Signed-off-by: Alexei Fedorov --- include/lib/libc/stdbool.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/lib/libc') diff --git a/include/lib/libc/stdbool.h b/include/lib/libc/stdbool.h index e39aef7d3..b58334cd0 100644 --- a/include/lib/libc/stdbool.h +++ b/include/lib/libc/stdbool.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -9,8 +9,8 @@ #define bool _Bool -#define true 1 -#define false 0 +#define true (0 < 1) +#define false (0 > 1) #define __bool_true_false_are_defined 1 -- cgit v1.2.3 From 1123a5e2f973dc9f0223467f4782f6b2df542620 Mon Sep 17 00:00:00 2001 From: Madhukar Pappireddy Date: Fri, 4 Sep 2020 14:04:23 -0500 Subject: libc: Import strlcat from FreeBSD project From commit: 21571b1d140ae7bb44e94c0afba2ec61456b275b Made small changes to fit into TF-A project Change-Id: I07fd7fe1037857f6b299c35367c104fb51fa5cfa Signed-off-by: Madhukar Pappireddy --- include/lib/libc/string.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/lib/libc') diff --git a/include/lib/libc/string.h b/include/lib/libc/string.h index 71774b0c8..91cbafbb7 100644 --- a/include/lib/libc/string.h +++ b/include/lib/libc/string.h @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ /* - * Portions copyright (c) 2018-2019, ARM Limited and Contributors. + * Portions copyright (c) 2018-2020, ARM Limited and Contributors. * All rights reserved. */ @@ -26,5 +26,6 @@ size_t strlen(const char *s); size_t strnlen(const char *s, size_t maxlen); char *strrchr(const char *p, int ch); size_t strlcpy(char * dst, const char * src, size_t dsize); +size_t strlcat(char * dst, const char * src, size_t dsize); #endif /* STRING_H */ -- cgit v1.2.3 From 77648689ad2627911a3aa6fd69463e8043889532 Mon Sep 17 00:00:00 2001 From: Madhukar Pappireddy Date: Tue, 8 Sep 2020 19:00:00 -0500 Subject: libc: Add support for vsnprintf() It uses the existing implementation of snprintf() function Change-Id: Ie59418564c2e415222e819cf322c34e9a4d1f336 Signed-off-by: Madhukar Pappireddy --- include/lib/libc/stdio.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/lib/libc') diff --git a/include/lib/libc/stdio.h b/include/lib/libc/stdio.h index 2d9e6557b..ba13683e6 100644 --- a/include/lib/libc/stdio.h +++ b/include/lib/libc/stdio.h @@ -22,6 +22,7 @@ int snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4); #ifdef STDARG_H int vprintf(const char *fmt, va_list args); +int vsnprintf(char *s, size_t n, const char *fmt, va_list args); #endif int putchar(int c); -- cgit v1.2.3 From 374eef025f4d4d407fb84dd83b1fef5d5477e991 Mon Sep 17 00:00:00 2001 From: Madhukar Pappireddy Date: Wed, 16 Sep 2020 18:58:49 -0500 Subject: libc: Import strtok_r from FreeBSD project From commit: 21571b1d140ae7bb44e94c0afba2ec61456b275b Made small changes to fit into TF-A project Change-Id: I991f653a7ace04f9c84bcda78ad8d7114ea18e93 Signed-off-by: Madhukar Pappireddy --- include/lib/libc/string.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/lib/libc') diff --git a/include/lib/libc/string.h b/include/lib/libc/string.h index 91cbafbb7..989448318 100644 --- a/include/lib/libc/string.h +++ b/include/lib/libc/string.h @@ -27,5 +27,6 @@ size_t strnlen(const char *s, size_t maxlen); char *strrchr(const char *p, int ch); size_t strlcpy(char * dst, const char * src, size_t dsize); size_t strlcat(char * dst, const char * src, size_t dsize); +char *strtok_r(char *s, const char *delim, char **last); #endif /* STRING_H */ -- cgit v1.2.3 From 015240d9d35c88d4f5c2845e8b8bfceb6d25dd9d Mon Sep 17 00:00:00 2001 From: Madhukar Pappireddy Date: Tue, 26 Jan 2021 21:36:18 -0600 Subject: libc: Import strtol from FreeBSD project From commit: 21571b1d140ae7bb44e94c0afba2ec61456b275b The coding guidelines[1] in TF-A forbid the use of ato*() functions in favour of strto*(). However, the TF-A libc does not provide an implementation of strto*(), making this rule impossible to satisfy. Also made small changes to fit into TF-A project. Added the source files to the libc makefile [1] https://trustedfirmware-a.readthedocs.io/en/latest/process/coding-guidelines.html#libc-functions-that-are-banned-or-to-be-used-with-caution Change-Id: Ica95bf5da722913834fe90bf3fe743aa34e01e80 Signed-off-by: Madhukar Pappireddy --- include/lib/libc/stdlib.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/lib/libc') diff --git a/include/lib/libc/stdlib.h b/include/lib/libc/stdlib.h index 24e7bae2f..b4a14e87f 100644 --- a/include/lib/libc/stdlib.h +++ b/include/lib/libc/stdlib.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017 Roberto E. Vargas Caballero + * Copyright (c) 2012-2021 Roberto E. Vargas Caballero * * SPDX-License-Identifier: BSD-3-Clause */ @@ -18,8 +18,12 @@ #define _ATEXIT_MAX 1 +#define isspace(x) (((x) == ' ') || ((x) == '\r') || ((x) == '\n') || \ + ((x) == '\t') || ((x) == '\b')) + extern void abort(void); extern int atexit(void (*func)(void)); extern void exit(int status); +long strtol(const char *nptr, char **endptr, int base); #endif /* STDLIB_H */ -- cgit v1.2.3 From 15c1c14735c28b03c540fdb00aa44b208e3b01eb Mon Sep 17 00:00:00 2001 From: Madhukar Pappireddy Date: Wed, 27 Jan 2021 15:44:52 -0600 Subject: libc: Import strtoul from FreeBSD project From commit: 21571b1d140ae7bb44e94c0afba2ec61456b275b The coding guidelines[1] in TF-A forbid the use of ato*() functions in favour of strto*(). However, the TF-A libc does not provide an implementation of strto*(), making this rule impossible to satisfy. Also made small changes to fit into TF-A project. Added the source files to the libc makefile [1] https://trustedfirmware-a.readthedocs.io/en/latest/process/coding-guidelines.html#libc-functions-that-are-banned-or-to-be-used-with-caution Change-Id: I8c3b92751d1ce226c966f7c81fedd83f0846865e Signed-off-by: Madhukar Pappireddy --- include/lib/libc/stdlib.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/lib/libc') diff --git a/include/lib/libc/stdlib.h b/include/lib/libc/stdlib.h index b4a14e87f..3b5e9157e 100644 --- a/include/lib/libc/stdlib.h +++ b/include/lib/libc/stdlib.h @@ -26,4 +26,5 @@ extern int atexit(void (*func)(void)); extern void exit(int status); long strtol(const char *nptr, char **endptr, int base); +unsigned long strtoul(const char *nptr, char **endptr, int base); #endif /* STDLIB_H */ -- cgit v1.2.3 From 587c15565f543878aeeff80bf224e24616d68462 Mon Sep 17 00:00:00 2001 From: Madhukar Pappireddy Date: Wed, 27 Jan 2021 18:32:17 -0600 Subject: libc: Import strtoll from FreeBSD project From commit: 21571b1d140ae7bb44e94c0afba2ec61456b275b The coding guidelines[1] in TF-A forbid the use of ato*() functions in favour of strto*(). However, the TF-A libc does not provide an implementation of strto*(), making this rule impossible to satisfy. Also made small changes to fit into TF-A project. Added the source files to the libc makefile [1] https://trustedfirmware-a.readthedocs.io/en/latest/process/coding-guidelines.html#libc-functions-that-are-banned-or-to-be-used-with-caution Change-Id: I9cb581574d46de73c3d6917ebf78935fc5ac075a Signed-off-by: Madhukar Pappireddy --- include/lib/libc/stdlib.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/lib/libc') diff --git a/include/lib/libc/stdlib.h b/include/lib/libc/stdlib.h index 3b5e9157e..a0354fabc 100644 --- a/include/lib/libc/stdlib.h +++ b/include/lib/libc/stdlib.h @@ -27,4 +27,5 @@ extern void exit(int status); long strtol(const char *nptr, char **endptr, int base); unsigned long strtoul(const char *nptr, char **endptr, int base); +long long strtoll(const char *nptr, char **endptr, int base); #endif /* STDLIB_H */ -- cgit v1.2.3 From d56b957c2104f624994d5f20fdaa989079c06a6f Mon Sep 17 00:00:00 2001 From: Madhukar Pappireddy Date: Wed, 27 Jan 2021 19:12:33 -0600 Subject: libc: Import strtoull from FreeBSD project From commit: 21571b1d140ae7bb44e94c0afba2ec61456b275b The coding guidelines[1] in TF-A forbid the use of ato*() functions in favour of strto*(). However, the TF-A libc does not provide an implementation of strto*(), making this rule impossible to satisfy. Also made small changes to fit into TF-A project. Added the source files to the libc makefile [1] https://trustedfirmware-a.readthedocs.io/en/latest/process/coding-guidelines.html#libc-functions-that-are-banned-or-to-be-used-with-caution Change-Id: I2e94a0b227ec39f6f4530dc50bb477999d27730f Signed-off-by: Madhukar Pappireddy --- include/lib/libc/stdlib.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/lib/libc') diff --git a/include/lib/libc/stdlib.h b/include/lib/libc/stdlib.h index a0354fabc..4641e566e 100644 --- a/include/lib/libc/stdlib.h +++ b/include/lib/libc/stdlib.h @@ -28,4 +28,5 @@ extern void exit(int status); long strtol(const char *nptr, char **endptr, int base); unsigned long strtoul(const char *nptr, char **endptr, int base); long long strtoll(const char *nptr, char **endptr, int base); +unsigned long long strtoull(const char *nptr, char **endptr, int base); #endif /* STDLIB_H */ -- cgit v1.2.3