| 9b0773cb | 11-Sep-2020 |
Jerome Forissier <jerome@forissier.org> |
libutils: fix memset(), memcpy(), memmove() with -O3
When libutils is built with optimization -O3 (make CFG_CC_OPT_LEVEL=3), memset() may cause infinite recursion. This bug was observed with GCC 8.3
libutils: fix memset(), memcpy(), memmove() with -O3
When libutils is built with optimization -O3 (make CFG_CC_OPT_LEVEL=3), memset() may cause infinite recursion. This bug was observed with GCC 8.3 with QEMUv8. The reason is, at this optimization level the compiler may decide to replace loops with calls to memset(), which is obviously not valid when the loop is in the memset function itself. This behavior can be turned off with -fno-tree-loop-distribute-patterns.
Therefore, add the appropriate build flag to memset.c. Note that a similar fix was introduced in upstream newlib [1] but since it depends on the newlib build script to detect compiler support, the patch is not directly applicable. Instead $(call cc-option,...) is used here.
Although I have not observed any issue with memcpy() and memmove(), upstream did apply the compiler flag to these functions too [1], [2], which seems quite reasonable so do the same here.
Link: [1] https://github.com/bminor/newlib/commit/10e4d79a191f07999bc94b21535fba5d7c04f419 Link: [2] https://github.com/bminor/newlib/commit/82dfae9ab0734b9946321590162dc6021057fec1 Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b6d69a43 | 25-Mar-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils: ctype.h: do not define functions as builtins
Our <ctype.h> defines a number of functions as macros that evaluate to the builtin function of the same name, for instance:
#define isalpha(_
libutils: ctype.h: do not define functions as builtins
Our <ctype.h> defines a number of functions as macros that evaluate to the builtin function of the same name, for instance:
#define isalpha(__c) __builtin_isalpha(__c)
There are two problems with this:
1. It gets in the way of the application developer and makes some compiler flags irrelevant (-fno-builtin*, [1]). 2. Different compilers do not support the same set of builtin functions so having the defines can result in build errors.
Therefore, user regular prototypes in <ctype.h>. Also build libutils without the -ffreestanding flag because it implies -fno-builtin and therefore may needlessly disable optimizations. The libutils environment cannot be considered "free standing" since it implements the standard header files with the expected semantics.
Our implementations of the <ctypes.h> functions (isalnum(), isalpha(), etc.) are defined with the __builtin_ prefix. This is not needed and is arguably wrong. Indeed, we want the functions in libutils to be present without the prefix, which GCC happens to be doing regardless. However, this __builtin_ prefix in the .c files makes things more complicated to support Clang. Therefore, remove it.
Link: [1] https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html (-fno-builtin) Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b38854bd | 09-Nov-2018 |
Bryan O'Donoghue <bryan.odonoghue@linaro.org> |
libutils: Import strtoul from newlib
This patch imports strtoul from newlib which the latest version of libfdt depends on.
Some modification of the original source is required to do this, specifica
libutils: Import strtoul from newlib
This patch imports strtoul from newlib which the latest version of libfdt depends on.
Some modification of the original source is required to do this, specifically:
This is an import of the newlib 1.19.0 version of strtoul dropping
- Headers and prototypes for re-entrancy
- Any reliance on errno
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 5b01430c | 07-May-2018 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: import strcpy() and strncpy()
Imports strcpy() and strncpy() from newlib with license added
Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@
libutils: import strcpy() and strncpy()
Imports strcpy() and strncpy() from newlib with license added
Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 51932e38 | 26-May-2016 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils/newlib: clean sub.mk
As most newlib source files needs more or less the same flags to compile, apply the flags with cflags-y and clags-remove-y instead of individual flags for each file.
R
libutils/newlib: clean sub.mk
As most newlib source files needs more or less the same flags to compile, apply the flags with cflags-y and clags-remove-y instead of individual flags for each file.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|