summaryrefslogtreecommitdiffstats
path: root/libc/stdlib
Commit message (Collapse)AuthorAgeFilesLines
* libc: fix signal handling in system()Richard Braun2012-01-231-17/+20
| | | | | | | | | | | | | | | When built without NPTL support (or for a sparc target), the system() function doesn't conform to its specification. Namely, it uses signal() to install/save/restore signal handlers, which may break applications using custom handlers installed with sigaction(). In addition, it resets the SIGCHLD handler to SIG_DFL instead of blocking the signal, which may result in "lost" signals if a custom handler was installed. Fix system() by replacing uses of signal() with appropriate calls to sigaction() and sigprocmask(). Signed-off-by: Richard Braun <rbraun@sceen.net> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libc: build abort with unwind-info for backtraceBernhard Reutner-Fischer2012-01-151-0/+2
| | | | | | | If backtrace support is turned on, build raise() and abort() with unwind info (fixup 4c9b7f3c21ff21c199e54bfad2fdf3445fa4573d). Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* libc: allow to backtrace out of abort callCarmelo Amoroso2012-01-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Build raise and abort function with dwarf2 info by using -fasynchronous-unwind-tables to make backtrace() working across a call to abort. A scenario where it could be useful is within a signal handler that wants to dump a backtrace when catching some signal (i.e SIGABRT). Without having abort & raise built with DWARF2 information, it is not possible for the libgcc stack unwinder to walk through the call stack out of the abort/raise function. Impacts in terms of size are really limited Current text data bss dec hex filename 164 0 0 164 a4 ./libpthread/nptl/sysdeps/unix/sysv/linux/raise.os 164 0 0 164 a4 ./libpthread/nptl/sysdeps/unix/sysv/linux/raise.oS 220 24 4 248 f8 ./libc/stdlib/abort.os With (-fasynchronous-unwind-tables) text data bss dec hex filename 216 0 0 216 d8 ./libpthread/nptl/sysdeps/unix/sysv/linux/raise.os 216 0 0 216 d8 ./libpthread/nptl/sysdeps/unix/sysv/linux/raise.oS 280 24 4 308 134 ./libc/stdlib/abort.os Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com> Acked-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* stdlib: add qsort_rBernhard Reutner-Fischer2011-11-073-6/+26
| | | | | | GNU extension like qsort but takes a 3 parameter comparision function. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* Defeat compiler optimization which assumes function addresses are never NULLDenys Vlasenko2011-09-152-20/+42
| | | | | | | | | | | | | From email: A warning for people who can be hit by the same or similar issue: gcc 4.1.2 with -march=i486 here with -Os and even with -O2 or -O is "optimizing away" the check if (_stdio_term) in libc/stdlib/_atexit.c which results in a "call 0" and a segfault at exit if you do not happen to link in stdio. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* __uc_malloc: Fix memory-leak in error pathBernhard Reutner-Fischer2011-05-101-0/+1
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* Fix malloc alignmentBernd Schmidt2011-04-112-3/+5
| | | | | | | | | | | | | In commit 3e0a1f388, Richard tried to fix malloc alignments by using alignof (double __attribute_aligned__(sizeof (size_t))). This doesn't work, since attribute_aligned overrides the alignment rather than providing a minimum. On C6X, malloc returns four-byte aligned values rather than the necessary eight-byte alignment. It's simpler to use a comparison and pick the bigger of the two values, so that's what I've done. Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
* memalign: include sys/param.h for MAXBernhard Reutner-Fischer2011-03-161-2/+1
| | | | | | | | | | | | | libc/stdlib/malloc/memalign.c:22:1: warning: "MAX" redefined In file included from ./libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h:25, from ./include/bits/libc-lock.h:36, from ./include/bits/stdio-lock.h:23, from ./include/bits/uClibc_mutex.h:71, from libc/stdlib/malloc/malloc.h:135, from libc/stdlib/malloc/memalign.c:18: ./include/sys/param.h:75:1: warning: this is the location of the previous definition Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* really fix missing __libc_drand48_dataPeter S. Mazinger2011-03-101-0/+4
| | | | Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* Revert "missing prototype of __libc_drand48_data fixed"Peter S. Mazinger2011-03-101-1/+0
| | | | | | This reverts commit e2cea9b9edabe885b9bf2586f9541ffb8fe93f3f. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* missing prototype of __libc_drand48_data fixedPeter S. Mazinger2011-03-101-0/+1
| | | | Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* stdlib.c, _strtod.c, stdlib.h: remove unused hidden functionsPeter S. Mazinger2011-03-092-23/+6
| | | | Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* arc4random.c, stdlib.h: get rid of hidden arc4random_stirPeter S. Mazinger2011-03-091-5/+5
| | | | | | The function is used only in one file, make an internal static version for this Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* move prototype for __drand48_iterate and __libc_drand48_data to stdlib.hPeter S. Mazinger2011-03-0912-45/+0
| | | | | | Move them to a common header guarded by _LIBC Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* stdlib.c: remove duplicate libc_hidden_proto for strtoul/strtoul_lPeter S. Mazinger2011-03-091-1/+0
| | | | Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* _strtod.c: only strtod hidden version is neededPeter S. Mazinger2011-03-091-2/+3
| | | | | | Do not provide hidden strtod_l, wcstod and wcstod_l Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* style updatePeter S. Mazinger2011-03-031-12/+5
| | | | | | Style update avoiding compile warnings Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* libc: fix strtoqNatanael Copa2010-12-011-0/+3
| | | | | | | | strtoq should always return a quad_t and be an alias of strtol on 64 bit and strtoll on 32 bit. Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* libc: silence warningBernhard Reutner-Fischer2010-11-241-0/+1
| | | | | | about implicit declaration of memset in system() Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* *: inline constant __sig{add,del}set and __sigismemberDenys Vlasenko2010-10-221-2/+3
| | | | | | | | | | | | text data bss dec hex filename - 318 4 0 322 142 libc/pwd_grp/lckpwdf.o + 312 4 0 316 13c libc/pwd_grp/lckpwdf.o - 166 0 1 167 a7 libc/stdlib/abort.o + 157 0 1 158 9e libc/stdlib/abort.o - 42 0 0 42 2a libc/sysdeps/linux/common/pause.o + 27 0 0 27 1b libc/sysdeps/linux/common/pause.o Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* libc: Add canonicalize_file_name functionCarmelo Amoroso2010-09-163-1/+40
| | | | | | | | Add canonicalize_file_name function and its related tests. Required by elfutils and coreutils (readlink). Signed-off-by: Salvatore Cro <salvatore.cro@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
* malloc: simplify MAP_UNINITIALIZE ifdef logicMike Frysinger2010-07-271-7/+4
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* malloc-simple: Make calloc() return zeroed memorySteven J. Magnani2010-07-271-5/+4
| | | | | | | | | | The 0.9.31 release included a change to malloc-simple to request uninitialized memory from noMMU kernels. Unfortunately, the corresponding calloc() code assumed that memory returned by malloc() was already zeroed, which leads to all kinds of nastiness. Signed-off-by: Steven J. Magnani <steve@digidescorp.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* silence some warnings about missing prototypesBernhard Reutner-Fischer2010-06-111-1/+1
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* nptl: fix malloc library lockingTimo Teräs2010-04-222-10/+8
| | | | | | | | Update malloc library to use internal uclibc locking primitives to get the libpthread calls correct. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* Merge commit 'origin/master' into nptlAustin Foxley2010-04-024-8/+8
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile.in extra/Configs/Config.in libc/sysdeps/linux/common/bits/kernel-features.h libc/sysdeps/linux/common/poll.c libc/sysdeps/linux/common/sysdep.h libc/sysdeps/linux/sh/sysdep.h Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
| * prettify make cleanBernhard Reutner-Fischer2010-03-254-8/+8
| | | | | | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
| * libc: Fix l64a to return the correct buffer pointerFilippo Arcidiacono2010-02-031-1/+1
| | | | | | | | | | | | | | | | | | l64a was returning the pointer to the end of the internal buffer instead of the start. This caused an infinite loop in passwd application. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
* | sparc: disable cancellable system, as it fails in strange ways right nowAustin Foxley2010-02-191-1/+4
| | | | | | | | Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* | libc: Fix l64a to return the correct buffer pointerFilippo Arcidiacono2010-02-031-1/+1
| | | | | | | | | | | | | | | | | | l64a was returning the pointer to the end of the internal buffer instead of the start. This caused an infinite loop in passwd application. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
* | Fix accidently dropped hunk during last merge from master.Khem Raj2010-02-011-21/+8
| | | | | | | | Signed-off-by: Khem Raj <raj.khem@gmail.com>
* | Merge commit 'origin/master' into nptlKhem Raj2010-02-011-32/+19
|\| | | | | | | | | | | | | Conflicts: libc/stdlib/Makefile.in Signed-off-by: Khem Raj <raj.khem@gmail.com>
| * convert to foo-y kbuild styleBernhard Reutner-Fischer2010-01-261-54/+27
| | | | | | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* | Merge commit 'origin/master' into nptlAustin Foxley2009-12-192-6/+7
|\| | | | | | | | | | | | | | | Conflicts: libc/signal/sigpause.c libc/string/x86_64/memset.S Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
| * malloc: fix race condition and other bugs in the no-mmu mallocFreeman Wang2009-12-192-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes multiple race conditions on mmb list. This was done by making the mmb_heap_lock into a recursive lock and making the regular heap_lock extend to cover the mmb heap handling. Also move the new_mmb allocation up to before the mmb list is iterated through to find the insertion point. When the mmb_heap also runs out and needs to be extended when the regular heap is just extended, the mmb list could be messed up. Signed-off-by: Freeman Wang <xwang@ubicom.com> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* | Merge remote branch 'origin/master' into nptlAustin Foxley2009-11-283-3/+3
|\| | | | | | | Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
| * nommu: use MAP_UNINITIALIZE for mallocsMike Frysinger2009-11-233-3/+3
| | | | | | | | | | | | | | | | | | Now that the kernel supports MAP_UNINITIALIZE, have the malloc places use it to get real uninitialized memory on no-mmu systems. This avoids a lot of normally useless overhead involved in zeroing out all of the memory (sometimes multiple times). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* | Merge remote branch 'origin/master' into nptl_mergeAustin Foxley2009-11-221-14/+8
|\| | | | | | | | | | | | | | | | | Conflicts: Rules.mak libc/misc/sysvipc/msgq.c test/Rules.mak Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
| * realpath: SUSv4 compliantBernhard Reutner-Fischer2009-11-141-14/+8
| | | | | | | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* | Extend __gen_tempname with mode argumentMikhail Gusarov2009-11-094-4/+7
| | | | | | | | | | | | | | | | | | | | sem_open(3) needs to create a temporary file in a way which can't be efficiently implemented in terms of POSIX API. Extend __gen_tempname with mode_t mode argument in order to ease sem_open implementation. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* | whitespace fixesAustin Foxley2009-10-171-1/+1
| | | | | | | | Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* | cancellation support for a large amount of the required syscallsAustin Foxley2009-10-171-0/+201
| | | | | | | | Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* | some tweaks under libc/ needed for nptlAustin Foxley2009-10-171-3/+4
|/ | | | | | | | | | * updated kernel-features.h * system is provided by pt-system with nptl * _exit should do exit_group with nptl * tsd tls ptr in libc * rt_sigwaitinfo impl added Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* mktemp does not depend on floatsAustin Foxley2009-10-171-1/+5
| | | | Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* malloc: handle size overflows in realloc()Mike Frysinger2009-10-151-0/+3
| | | | | | | | | The malloc() code checks the incoming size to make sure the header adjustment doesn't cause overflow in the size storage. Add the same check to realloc() to catch stupid stuff like realloc(..., -1). Reported-by: James Coleman <james.coleman@ubicom.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* remove a few more empty #if/#endif pairsDenys Vlasenko2009-09-191-2/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* convert // comments to /**/; remove empty #if/#endif pairs. no code changesDenys Vlasenko2009-09-183-9/+0
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* trim Experimentally off and uncommented hiddenBernhard Reutner-Fischer2009-09-1848-153/+0
| | | | | | | | sed -i -e '/Experimentally off - /d' $(grep -rl "Experimentally off - " *) sed -i -e '/^\/\*[[:space:]]*libc_hidden_proto(/d' $(grep -rl "libc_hidden_proto" *) should be a nop Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* support building out-of-treeBernhard Reutner-Fischer2009-08-174-0/+8
| | | | | | Handle O= Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* - Add strtouq alias (to strtoul) for 64bitBernhard Reutner-Fischer2009-03-251-0/+3
| | | | | | | | The strtouq alias was only available on 32bit, breaking compilation of stuff using strtouq on 64bit machines. At the same time use the correct return type (u_quad_t). Signed-of-by: Peter Korsgaard <jacmet@sunsite.dk>