summaryrefslogtreecommitdiffstats
path: root/libc
Commit message (Collapse)AuthorAgeFilesLines
* libc: add strnlen()Oliver O'Halloran2017-09-152-0/+14
| | | | | | | Sometimes handy. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libc/test/run-snprintf: int -> unsigned intStewart Smith2017-08-241-1/+2
| | | | | | | UBSan: libc/test/run-snprintf.c:123:9: runtime error: left shift of 268435456 by 4 places cannot be represented in type 'int' Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* mktime: fix off-by-one error calling days_in_monthStewart Smith2017-08-241-1/+1
| | | | | | | | | | From auditing all the mktime() users, there seems to be only a *very* small window around new years day where we could possibly return incorrect data to the OS, and even then, there would have to be FSP reset/reload on FSP machines. I don't *think* there's an opportunity on other machines. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libc/time.c: days_in_month() use char rather than intStewart Smith2017-08-241-1/+1
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libc: Add labs() to stdlibShilpasri G Bhat2017-05-314-1/+34
| | | | | | Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> Acked-by: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* gcov: fix typo preventing libc coverage reportStewart Smith2017-05-011-1/+1
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libc/stdio/vsnprintf.c: add explicit fallthroughStewart Smith2017-02-021-0/+1
| | | | | | silences recent GCC warning Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* stdio: Fix default definition of pr_fmtBenjamin Herrenschmidt2017-01-051-1/+1
| | | | | | | | And change include order in libpore to avoid a compile failure due to the default definition Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* snprintf: increase testing, %u and 0 paddingStewart Smith2016-10-171-0/+53
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libc : Changes variable data type where return value of strlen() stored from ↵Mukesh Ojha2016-10-113-4/+4
| | | | | | | | | | | | | int to size_t Reason of the change as integer value may overflow, and it can give negative value for the length. This patch also changes the data type of variable which is compared with strlen() as the comparison also has to be done on the same level. Signed-off-by: Mukesh Ojha <mukesh02@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libc/string: add memcpy_from_ci()Claudio Carvalho2016-10-053-5/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds memcpy_from_ci, a cache inhibited version of memcpy, required by secure boot. The secure boot verification code is stored in a secure ROM and the logic that contains the ROM within the processor is implemented in a way that it only responds to CI (cache inhibited) operations. Due to performance issues we copy the verification code from the secure ROM to RAM and we use memcpy_ci for that. What makes memcpy_ci vs ordinary memcpy? memcpy copies data like in the example below and the compiler translates that to load instructions that are not cache inhibited (e.g. lbzx - load byte and zero indexed). In other words, the data is cached. a[i] = b[i] memcpy_ci copies data using the cache inhibited version of load instructions: in_8() and in_be32(), both defined in include/io.h. These functions use lbzcix and lwzcix assembly instructions, respectively. In this case, the data is not cached as required by the logic that contains the ROM. *((uint8_t*) destp) = in_8((uint8_t*)srcp); *((uint32_t*) destp) = in_be32((uint32_t*)srcp) Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* strlen: use size_t for lenStewart Smith2016-09-021-1/+1
| | | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Reviewed-by: Mukesh Ojha <mukesh02@linux.vnet.ibm.com>
* consolidate gcov flags into HOSTGCOVFLAGS for host binariesStewart Smith2016-09-021-2/+2
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libc: Use 8-bytes stores for non-0 memset tooBenjamin Herrenschmidt2016-08-181-1/+8
| | | | | | | | Memory poisoning hammers this, so let's be a bit smart about it and avoid falling back to byte stores when the data is not 0 Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libc: Remove NULL check for format argument in snprintf()Cyril Bur2016-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | libc printf style functions are annotated with __attribute__((format (printf, x, y))) which causes GCC to perform compile time checks against these arguments. As of at least gcc 6.1.1 [(GCC) 6.1.1 20160602] this causes an error running make check. GCC appears to be guaranteeing that the format argument won't be NULL and complaining about explicit checks. In file included from core/test/run-console-log-buf-overrun.c:48:0: core/test/run-console-log-buf-overrun.c: In function ‘snprintf’: core/test/../../libc/stdio/snprintf.c:21:19: error: nonnull argument ‘format’compared to NULL [-Werror=nonnull-compare] if ((buff==NULL) || (format==NULL)) ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [core/test/Makefile.check:59:core/test/run-console-log-buf-overrun] Error 1 Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add "ffs" inline functionBenjamin Herrenschmidt2016-07-061-0/+5
| | | | | | Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Fix for typosFrederic Bonnard2016-06-202-2/+2
| | | | | | | | | While reviewing the Debian packaging, codespell found those. Most proposed fixes are based on codespell's default dictionnary. Signed-off-by: Frederic Bonnard <frediz@linux.vnet.ibm.com> Reviewed-by: Mukesh Ojha <mukesh02@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* */test/*: Added '<subdir>-check' make targetsOliver O'Halloran2016-03-301-2/+5
| | | | | | | Currently these exist for some parts of the source tree, but not all of it. They're nice if you are only modifing code in a one part of the tree as the full test suite can be a little slow. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Remove unused scanf and variantsStewart Smith2015-11-135-455/+3
| | | | | | | We don't use scanf at all, so solve the bugs found by static analysis by just removing it. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Move FSP specific abort() code to platform layerVasant Hegde2015-09-092-10/+4
| | | | | | | | | | | | | | | Presently abort() call sets up HID0, triggers attention and finally calls infinite for loop. FSP takes care of collecting required logs and reboots the system. This sequence is specific to FSP machine and it will not work on BMC based machine. Hence move FSP specific code to hw/fsp/fsp-attn.c. Note that this patch adds new parameter to abort call. Hence replaced _abort() by abort() in exception.c so that we can capture file info as well. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* fix wrong operator use in stdlib/rand.cStewart Smith2015-07-081-1/+1
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Increase unit test coverage of printf h and z length modifiersStewart Smith2015-07-021-0/+31
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Increase unit test coverage of printf %p and %oStewart Smith2015-07-021-0/+22
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc tolower() and toupper()Stewart Smith2015-06-242-0/+22
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc isdigit, isprint, isspace, isxdigitStewart Smith2015-06-242-0/+93
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc memmoveStewart Smith2015-06-242-2/+27
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc strncasecmpStewart Smith2015-06-242-0/+17
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc strcasecmpStewart Smith2015-06-242-0/+27
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc strcmpStewart Smith2015-06-242-0/+10
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc memcmpStewart Smith2015-06-242-0/+10
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add tests for libc memchrStewart Smith2015-06-242-0/+13
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* libflash/blocklevel: Extend the block level to be able to do eccCyril Bur2015-06-231-0/+2
| | | | | | | | | | | | | | | | At the moment ECC reads and writes are still being handled by the low level core of libflash. ECC should be none of libflashes concern, it is primarily a hardware access backend. It makes sense for blocklevel to take care of ECC but currently it has no way of knowing. With some simple modifications (which are rudimentary at the moment and will need a performance improvement) blocklevel can handle ECC, and with a little more effort this can be extended to provide read and write protection in blocklevel. Reviewed-By: Alistair Popple <alistair@popple.id.au> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Remove unused struct tm elementsStewart Smith2015-06-151-5/+0
| | | | | | Better to error out than suddenly have places use uninitalized data. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Optimized memset() implementation for POWERStewart Smith2015-06-013-0/+55
| | | | | | | | | | | | This uses the dcbz instruction to clear cacheline at a time rather than byte at a time. This means that even without high levels of optimization, we *dramatically* improve boot performance with SKIBOOT_GCOV=1 and probably ever so slightly speed things up for normal builds. We currently just hard-code 128 as cacheline size as all CPUs that skiboot currently boots on have 128 byte cachelines. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add pr_fmt to do printf/prlog prefixing automagicallyStewart Smith2015-05-121-1/+9
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* sparse: fix libc declarationsCédric Le Goater2015-02-261-6/+8
| | | | | Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* sparse: fix Using plain integer as NULL pointer warningCédric Le Goater2015-02-262-2/+2
| | | | | Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* sparse: declare errnoCédric Le Goater2015-02-261-0/+1
| | | | | Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* atoi/atol should assume base 10, not autodetect base.Daniel Axtens2015-02-233-6/+9
| | | | | | | | | The behaviour of atoi/atol on glibc (and according to the spec) is to assume base 10, not to autodetect the base. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Don't recognise a double hex prefix (0x0xNN) as valid.Daniel Axtens2015-02-233-8/+3
| | | | | | | | | When autodetecting the base, the code would strip hex prefixes twice. Now the string is not modified in the detection stage. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Test libc stdlib functions (atoi/strtol and friends)Daniel Axtens2015-02-231-0/+60
| | | | | | | | This increases coverage of atoi, atol, strtol and strtoul to 100%. Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Make abort() update sp attn area (like assert does)Stewart Smith2015-02-111-1/+7
| | | | | | Gives better diagnostics in error logs/dumps Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Fix commit 16c80346Jeremy Kerr2015-02-091-2/+11
| | | | | | | | | Commit 16c80346 change included some reverts of previous commits, which we need. This change reverts those reverts, leaving the original intent of that change. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add OPAL_INVALID_CALL explicitly in opal.h and docsStewart Smith2015-02-051-11/+2
| | | | | | | Was mentioned in linux as possibly being used by some external test modules. It's harmless to make this official behaviour. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Makefile: clean the gcov files created during coverageNeelesh Gupta2015-02-051-2/+11
| | | | | | | | Fix the Makefile to clean up the coverage data files generated through gcov. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* add libc/test/.gitignore for the new libc unit testsStewart Smith2015-01-271-0/+10
| | | | Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add skeleton for libc/ctype unit testsStewart Smith2015-01-203-1/+62
| | | | | | Now it shows up as untested in lcov! Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add skeleton for libc/stdlib unit testStewart Smith2015-01-203-1/+62
| | | | | | Now it shows up as untested in lcov! Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Skeleton unit tests for libc memops (libc/string/*)Stewart Smith2015-01-203-1/+71
| | | | | | This means that it shows up in lcov as untested. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
* Add some skiboot snprintf test casesStewart Smith2015-01-204-5/+242
| | | | | | Initial implementation and support for more libc test cases Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
OpenPOWER on IntegriCloud