aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
AgeCommit message (Collapse)AuthorFilesLines
2023-02-28Fix typos in the remaining lib foldersThomas Huth1-4/+3
Found with the "codespell" utility. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2021-10-01lib/libc/README.txt: Fix "cannel" typoThomas Huth1-2/+2
It should be "channel" instead of "cannel", obviously. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2021-02-09libc: Compile with -WextraAlexey Kardashevskiy2-7/+8
-Wextra enables a bunch of rather useful checks which this fixes. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- Changes: v2: * replaced cast to int with cast to size_t
2018-06-07libc: Add a simple implementation of an assert() functionThomas Huth1-0/+36
... useful for "this should never happen" situations, where you want to make sure that it really never happens. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> [aik: removed extra ';' and empty line] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2018-05-29libc: Add the snprintf() functionThomas Huth3-1/+30
Code has been taken from the sprintf() function (which is almost the same, except that snprintf calls vsnprintf instead of vsprintf internally). Signed-off-by: Thomas Huth <thuth@redhat.com> [aik: fixed traling spaces] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2018-05-24libc: Check for NULL pointers in free()Thomas Huth1-1/+3
POSIX says that the free() function should simply do nothing if a NULL pointer argument has been specified. So let's be a little bit more compliant in our libc and add a NULL pointer check here, too. Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2018-05-24libc: Implement strrchr()Thomas Huth2-1/+29
This function will be used in one of the next patches to find the last slash in a file name string. Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2017-07-07libc: Declare size_t as unsigned longThomas Huth1-2/+1
If size_t is only "int", memset() and friends are limited to 4 GB. And ssize_t is already declared as "long", so it is somewhat inconsequent to define size_t as "int" only. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2017-06-08libc: The arguments of puts() can be marked as "const"Thomas Huth2-2/+2
puts() does not change the string, so the parameter can be "const". Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-09-14paflof: Add socket(), send() and recv() functions to paflofThomas Huth1-0/+53
Code is slightly based on the implementation from net-snk, but has been adapted to use the forth_eval() and forth_push/pop() macros instead. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-23libc: Add srand() callThomas Huth2-0/+6
Needed for seeding the state of the pseudo-random number generator. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-23libc: Fix the rand() function to return non-zero valuesThomas Huth1-2/+2
The rand() function in SLOF's libc has a bug which caused the function to always return zero: The _rand value was shifted left by 16, and then ANDed with 0x7fff. Obviously, the shift operation should be ">>" instead of "<<". And while we're at it, also increase the constant for the multiplaction in there so that more upper bits are affected. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-02libc: Port vsnprintf back from skibootAlexey Kardashevskiy1-62/+118
Since initial port from slof to skiboot, vsnprintf() has improved in skiboot so let's port the improved version back. Suggested-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2013-07-24Add standard header stdbool.hNikunj A Dadhania1-0/+20
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Acked-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2011-12-20Silenced some compiler warnings that occur when compiling with prototype checksThomas Huth4-0/+7
The compiler flags -Wmissing-prototypes and -Wstrict-prototypes generally help to write code with proper prototypes. This way one can avoid some ugly bugs because it helps to identify functions that do not have prototypes in headers. It also helps to improve performance since local functions then have to be declared "static", so the compiler can do better optimizations. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2010-12-01Initial import of slof-JX-1.7.0-4Benjamin Herrenschmidt68-0/+3187
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>