summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
Commit message (Collapse)AuthorAgeFilesLines
* Fix cut/paste brain-o. Spell #endif correctly.Peter Wemm2014-08-071-1/+1
| | | | Notes: svn path=/stable/8/; revision=269684
* Like on stable/9 and later, don't redefine MALLOC_PRODUCTIONPeter Wemm2014-08-071-0/+2
| | | | Notes: svn path=/stable/8/; revision=269683
* MFC r253380,253413: name passed into __setenv is not necessarily NUL-terminatedAndriy Gapon2013-07-241-3/+2
| | | | Notes: svn path=/stable/8/; revision=253600
* When r241373 was merged, one file appears to have been missed from theGavin Atkinson2013-03-281-2/+1
| | | | | | | | | | | | | | | | | commit. Merge it: Remove undefined behavior from sranddev() and srandomdev(). This doesn't actually work with any modern C compiler: In particular, both clang and modern gcc verisons silently elide any xor operation with 'junk'. No mergeinfo changes with this commit as r241475 already updated the mergeinfo. Notes: svn path=/stable/8/; revision=248821
* MFH (r240107,240111,240361): warn against using weak PRNGsDag-Erling Smørgrav2013-02-282-16/+19
| | | | Notes: svn path=/stable/8/; revision=247500
* MFH r247014, r247050 and r247051.Giorgos Keramidas2013-02-251-1/+41
| | | | | | | | | | | | | Add a sample program that shows how a custom comparison function and qsort(3) can work together to sort an array of integers. PR: docs/176197 Submitted by: Fernando, fapesteguia at opensistemas.com Christoph Mallon, christoph.mallon at gmx.de Approved by: gjb (mentor), remko (mentor) Notes: svn path=/stable/8/; revision=247276
* MFC r241373:Eitan Adler2012-10-121-2/+1
| | | | | | | | | | | | | | | Remove undefined behavior from sranddev() and srandomdev(). This doesn't actually work with any modern C compiler: In particular, both clang and modern gcc verisons silently elide any xor operation with 'junk'. Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=241475
* MFC r235286:Glen Barber2012-05-182-3/+4
| | | | | | | | | General mdoc(7) and typo fixes. PR: 167734 Notes: svn path=/stable/8/; revision=235576
* MFC r211706:Konstantin Belousov2012-05-091-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | On shared object unload, in __cxa_finalize, call and clear all installed atexit and __cxa_atexit handlers that are either installed by unloaded dso, or points to the functions provided by the dso. Use _rtld_addr_phdr to locate segment information from the address of private variable belonging to the dso, supplied by crtstuff.c. Provide utility function __elf_phdr_match_addr to do the match of address against dso executable segment. Call back into libthr from __cxa_finalize using weak __pthread_cxa_finalize symbol to remove any atfork handler which function points into unloaded object. The rtld needs private __pthread_cxa_finalize symbol to not require resolution of the weak undefined symbol at initialization time. This cannot work, since rtld is relocated before sym_zero is set up. MFC r211894: Do not call __pthread_cxa_finalize with invalid struct dl_phdr_info. Requested and tested by: Peter Jeremy <peter rulingia com> Notes: svn path=/stable/8/; revision=235198
* MFC r228885:Glen Barber2012-01-022-3/+6
| | | | | | | | | r228885: - Add missing opening and closing brackets in getopt_long.3 and getsubopt.3 to make the examples reflect reality more closely. Notes: svn path=/stable/8/; revision=229330
* MFC r212405 (by davidxu):Konstantin Belousov2011-10-011-1/+1
| | | | | | | | | | | Because POSIX does not allow EINTR to be returned from sigwait(), add a wrapper for it in libc and rework the code in libthr, the system call still can return EINTR, we keep this feature. Discussed with: davidxu Notes: svn path=/stable/8/; revision=225896
* MFC r217144:Konstantin Belousov2011-01-151-4/+5
| | | | | | | | Fix some style(9) issues. Do not use strlcpy() where simple assignment is enough. Notes: svn path=/stable/8/; revision=217441
* MFC r214147:Benedict Reuschling2010-10-261-2/+1
| | | | | | | | | | | Sync with OpenBSD rev. 1.13: strtonum does not require limits.h Obtained from: OpenBSD Discussed with: ru@ Notes: svn path=/stable/8/; revision=214379
* MFC r213476:Konstantin Belousov2010-10-132-1/+11
| | | | | | | | | | | Add cross-references to lrand48(3) and arc4random(3) from rand(3) and random(3). MFC r213477: Missed space. Notes: svn path=/stable/8/; revision=213773
* MFC r206622,207939,208593,208732,209031: mdoc cleanupUlrich Spörlein2010-08-272-2/+2
| | | | | | | | | | - order prologue by Dd/Dt/Os - fix prologue - remove empty lines and other garbage - uppercase document title Notes: svn path=/stable/8/; revision=211872
* MFC r211704:Konstantin Belousov2010-08-261-2/+2
| | | | | | | Style. Notes: svn path=/stable/8/; revision=211840
* MFC r204636:Jaakko Heinonen2010-08-021-1/+8
| | | | | | | | | | | In reallocf(3), free the memory only when size != 0. Otherwise, when the System V compatibility option (malloc "V" flag) is in effect a zero sized reallocf() could cause a double free. PR: bin/141753 Notes: svn path=/stable/8/; revision=210745
* MFC: r207946Christian Brueffer2010-07-041-3/+2
| | | | | | | | The previous revision actually removed the bug being hinted at, so go ahead and remove the hint. Notes: svn path=/stable/8/; revision=209698
* MFC r207009:Konstantin Belousov2010-05-051-2/+2
| | | | | | | C language does not has references, it provides pointers. Notes: svn path=/stable/8/; revision=207654
* MFC r206893:Konstantin Belousov2010-05-042-11/+62
| | | | | | | | | | | | | | | | | | | | | | | | | Slightly modernize realpath(3). SUSv4 requires that implementation returns EINVAL if supplied path is NULL, and ENOENT if path is empty string [1]. Bring prototype in conformance with SUSv4, adding restrict keywords. Allow the resolved path buffer pointer be NULL, in which case realpath(3) allocates storage with malloc(). MFC r206898: Free() is not allowed to modify errno, remove safety brackets around it. Add small optimization, do not copy a string to the buffer that is to be freed immediately after. MFC r206997: Move realpath(3) prototype to a POSIX section. MFC r206998: Add standards section, improve wording, taking into account the handling of NULL and changed type in declaration. Notes: svn path=/stable/8/; revision=207599
* MFC r203077:Ed Maste2010-02-091-0/+1
| | | | | | | | | | | Add missing return, in a rare case where we can't allocate memory in deallocate. Submitted by: Ryan Stone (rysto32 at gmail dot com) Approved by: jasone Notes: svn path=/stable/8/; revision=203701
* MFC r197524Alan Cox2009-11-022-2/+19
| | | | | | | Make malloc(3) superpage aware. Notes: svn path=/stable/8/; revision=198815
* MFC r196861:Konstantin Belousov2009-09-121-0/+9
| | | | | | | | | | Handle zero size for posix_memalign. Return NULL or unique address according to the 'V' option. Approved by: re (kensmith) Notes: svn path=/stable/8/; revision=197127
* Remove extra debugging support that is turned on for head but turned offKen Smith2009-09-101-1/+1
| | | | | | | | | | | | | | | | | | for stable branches: - shift to MALLOC_PRODUCTION - turn off automatic crash dumps - Remove kernel debuggers, INVARIANTS*[1], WITNESS* from GENERIC kernel config files[2] [1] INVARIANTS* left on for ia64 by request marcel [2] sun4v was left as-is Reviewed by: marcel, kib Approved by: re (implicit) Notes: svn path=/stable/8/; revision=197065
* MFC r196508:Ed Schouten2009-08-281-15/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Our implementation of granpt(3) could be valid in the future. When I wrote the pseudo-terminal driver for the MPSAFE TTY code, Robert Watson and I agreed the best way to implement this, would be to let posix_openpt() create a pseudo-terminal with proper permissions in place and let grantpt() and unlockpt() be no-ops. This isn't valid behaviour when looking at the spec. Because I thought it was an elegant solution, I filed a bug report at the Austin Group about this. In their last teleconference, they agreed on this subject. This means that future revisions of POSIX may allow grantpt() and unlockpt() to be no-ops if an open() on /dev/ptmx (if the implementation has such a device) and posix_openpt() already do the right thing. I'd rather put this in the manpage, because simply mentioning we don't comply to any standard makes it look worse than it is. Right now we don't, but at least we took care of it. Approved by: re (kib) Notes: svn path=/stable/8/; revision=196614
* Simplify. We can just use .sinclude here.Ed Schouten2009-06-231-3/+1
| | | | | | | Submitted by: Christoph Mallon Notes: svn path=/head/; revision=194703
* Our grantpt(3) and unlockpt(3) don't comply with POSIX.Ed Schouten2009-05-041-3/+7
| | | | Notes: svn path=/head/; revision=191789
* "-isoC-99" should be spelled without 'c'.Xin LI2009-03-011-1/+1
| | | | Notes: svn path=/head/; revision=189207
* Add two new routines: fdevname() and fdevname_r().Ed Schouten2009-02-111-5/+3
| | | | | | | | | | | | | | | | | A more elegant way of obtaining a name of a character device by its file descriptor on FreeBSD, is to use the FIODGNAME ioctl. Because a valid file descriptor implies a file descriptor is visible in /dev, it will always resolve a valid device name. I'm adding a more friendly wrapper for this ioctl, called fdevname(). It is a lot easier to use than devname() and also has better error handling. When a device name cannot be resolved, it will just return NULL instead of a generated device name that makes no sense. Discussed with: kib Notes: svn path=/head/; revision=188497
* Fix language on atol(3) manpage. Add a COMPATIBILITY sectionGiorgos Keramidas2009-02-081-3/+32
| | | | | | | | | | | | | stating that in FreeBSD the atol() and atoll() functions affect errno in the same way as strtol() and stroll(). PR: docs/126487 Submitted by: edwin Reviewed by: trhodes, gabor MFC after: 1 week Notes: svn path=/head/; revision=188305
* Fix a lock order reversal bug that could cause deadlock during fork(2).Jason Evans2008-12-011-11/+37
| | | | | | | Reported by: kib Notes: svn path=/head/; revision=185514
* Adjust an assertion to handle the case where a lock is contested, butJason Evans2008-11-301-1/+1
| | | | | | | | | spinning is avoided due to running on a single-CPU system. Reported by: stefanf Notes: svn path=/head/; revision=185483
* Do not spin when trying to lock on a single-CPU system.Jason Evans2008-11-301-11/+13
| | | | | | | Reported by: davidxu Notes: svn path=/head/; revision=185468
* Revert to preferring mmap(2) over sbrk(2) when mapping memory, due toJason Evans2008-11-032-13/+18
| | | | | | | | | | potential extreme contention in the kernel for multi-threaded applications on SMP systems. Reported by: kris Notes: svn path=/head/; revision=184602
* MTC r183949:Alexander Leidinger2008-10-171-0/+5
| | | | | | | | | | Allow to define MALLOC_PRODUCTION with a make variable instead of polluting the global CFLAGS. Reviewed by: jasone Notes: svn path=/head/; revision=183969
* Use PAGE_{SIZE,MASK,SHIFT} from machine/param.h rather than hard-codingJason Evans2008-09-101-120/+88
| | | | | | | | | page size and using sysconf(3). Suggested by: marcel Notes: svn path=/head/; revision=182906
* Unbreak ia64: pges are 8KB.Marcel Moolenaar2008-09-061-1/+1
| | | | Notes: svn path=/head/; revision=182809
* Add thread-specific caching for small size classes, based on magazines.Jason Evans2008-08-273-256/+1133
| | | | | | | | | | | | | | | | | | | | | | | | | | | This caching allows for completely lock-free allocation/deallocation in the steady state, at the expense of likely increased memory use and fragmentation. Reduce the default number of arenas to 2*ncpus, since thread-specific caching typically reduces arena contention. Modify size class spacing to include ranges of 2^n-spaced, quantum-spaced, cacheline-spaced, and subpage-spaced size classes. The advantages are: fewer size classes, reduced false cacheline sharing, and reduced internal fragmentation for allocations that are slightly over 512, 1024, etc. Increase RUN_MAX_SMALL, in order to limit fragmentation for the subpage-spaced size classes. Add a size-->bin lookup table for small sizes to simplify translating sizes to size classes. Include a hard-coded constant table that is used unless custom size class spacing is specified at run time. Add the ability to disable tiny size classes at compile time via MALLOC_TINY. Notes: svn path=/head/; revision=182225
* Remove grantpt.c, which should have been deleted in the MPSAFE TTY commit.Ed Schouten2008-08-201-286/+0
| | | | | | | | | The routines in grantpt.c have been moved to ptsname.c in the MPSAFE TTY layer, because grantpt() is now effectively a no-op. I forgot to remove the corresponding source file from libc. Notes: svn path=/head/; revision=181915
* Integrate the new MPSAFE TTY layer to the FreeBSD operating system.Ed Schouten2008-08-204-100/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last half year I've been working on a replacement TTY layer for the FreeBSD kernel. The new TTY layer was designed to improve the following: - Improved driver model: The old TTY layer has a driver model that is not abstract enough to make it friendly to use. A good example is the output path, where the device drivers directly access the output buffers. This means that an in-kernel PPP implementation must always convert network buffers into TTY buffers. If a PPP implementation would be built on top of the new TTY layer (still needs a hooks layer, though), it would allow the PPP implementation to directly hand the data to the TTY driver. - Improved hotplugging: With the old TTY layer, it isn't entirely safe to destroy TTY's from the system. This implementation has a two-step destructing design, where the driver first abandons the TTY. After all threads have left the TTY, the TTY layer calls a routine in the driver, which can be used to free resources (unit numbers, etc). The pts(4) driver also implements this feature, which means posix_openpt() will now return PTY's that are created on the fly. - Improved performance: One of the major improvements is the per-TTY mutex, which is expected to improve scalability when compared to the old Giant locking. Another change is the unbuffered copying to userspace, which is both used on TTY device nodes and PTY masters. Upgrading should be quite straightforward. Unlike previous versions, existing kernel configuration files do not need to be changed, except when they reference device drivers that are listed in UPDATING. Obtained from: //depot/projects/mpsafetty/... Approved by: philip (ex-mentor) Discussed: on the lists, at BSDCan, at the DevSummit Sponsored by: Snow B.V., the Netherlands dcons(4) fixed by: kan Notes: svn path=/head/; revision=181905
* Move CPU_SPINWAIT into the innermost spin loop, in order to allow fasterJason Evans2008-08-141-2/+3
| | | | | | | | | preemption while busy-waiting. Submitted by: Mike Schuster <schuster@adobe.com> Notes: svn path=/head/; revision=181733
* Re-order the terms of an expression in arena_run_reg_dalloc() to correctlyJason Evans2008-08-141-2/+2
| | | | | | | | | detect whether the integer division table is large enough to handle the divisor. Before this change, the last two table elements were never used, thus causing the slow path to be used for those divisors. Notes: svn path=/head/; revision=181732
* Remove variables which are assigned values and never used thereafter.Colin Percival2008-08-081-5/+1
| | | | | | | | Found by: LLVM/Clang Static Checker Approved by: jasone Notes: svn path=/head/; revision=181438
* Restructure and use different variables in the tests that involveSean Farley2008-08-031-13/+15
| | | | | | | | | | | | environ[0] to be more obvious that environ is not NULL before environ[0] is tested. Although I believe the previous code worked, this change improves code maintainability. Reviewed by: ache MFC after: 3 days Notes: svn path=/head/; revision=181266
* Detect if the application has cleared the environ variable by settingSean Farley2008-08-021-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | the first value (environ[0]) to NULL. This is in addition to the current detection of environ being replaced, which includes being set to NULL. Without this fix, the environment is not truly wiped, but appears to be by getenv() until an *env() call is made to alter the enviroment. This change is necessary to support those applications that use this method for clearing environ such as Dovecot and Postfix. Applications such as Sendmail and the base system's env replace environ (already detected). While neither of these methods are defined by SUSv3, it is best to support them due to historic reasons and in lieu of a clean, defined method. Add extra units tests for clearing environ using four different methods: 1. Set environ to NULL pointer. 2. Set environ[0] to NULL pointer. 3. Set environ to calloc()'d NULL-terminated array. 4. Set environ to static NULL-terminated array. Noticed by: Timo Sirainen MFC after: 3 days Notes: svn path=/head/; revision=181150
* Enhance arena_chunk_map_t to directly support run coalescing, and useJason Evans2008-07-181-394/+338
| | | | | | | | | | the chunk map instead of red-black trees where possible. Remove the red-black trees and node objects that are obsoleted by this change. The net result is a ~1-2% memory savings, and a substantial allocation speed improvement. Notes: svn path=/head/; revision=180599
* - This code was intially obtained from NetBSD, but it's missing licenceDaniel Gerzo2008-07-061-1/+29
| | | | | | | | | | | | statement. Add the one from the current NetBSD version. - Also bump a date to reflect my content changes I have done in previous revision Approved by: imp MFC after: 3 days Notes: svn path=/head/; revision=180329
* - Add description about a missing return valueDaniel Gerzo2008-07-061-2/+6
| | | | | | | | | PR: docs/75995 Submitted by: Tarc <tarc@po.cs.msu.su> MFC after: 3 days Notes: svn path=/head/; revision=180325
* - remove superfluous wordDaniel Gerzo2008-07-061-3/+3
| | | | | | | | | - remove contractions MFC after: 3 days Notes: svn path=/head/; revision=180323
* Mark the section describing return values with an appropriate section flag.Daniel Gerzo2008-06-261-1/+1
| | | | | | | | PR: docs/122818 MFC after: 3 days Notes: svn path=/head/; revision=180024