summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
Commit message (Collapse)AuthorAgeFilesLines
* "-isoC-99" should be spelled without 'c'.delphij2009-03-011-1/+1
|
* Add two new routines: fdevname() and fdevname_r().ed2009-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
* Fix language on atol(3) manpage. Add a COMPATIBILITY sectionkeramida2009-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
* Fix a lock order reversal bug that could cause deadlock during fork(2).jasone2008-12-011-11/+37
| | | | Reported by: kib
* Adjust an assertion to handle the case where a lock is contested, butjasone2008-11-301-1/+1
| | | | | | spinning is avoided due to running on a single-CPU system. Reported by: stefanf
* Do not spin when trying to lock on a single-CPU system.jasone2008-11-301-11/+13
| | | | Reported by: davidxu
* Revert to preferring mmap(2) over sbrk(2) when mapping memory, due tojasone2008-11-032-13/+18
| | | | | | | potential extreme contention in the kernel for multi-threaded applications on SMP systems. Reported by: kris
* MTC r183949:netchild2008-10-171-0/+5
| | | | | | | Allow to define MALLOC_PRODUCTION with a make variable instead of polluting the global CFLAGS. Reviewed by: jasone
* Use PAGE_{SIZE,MASK,SHIFT} from machine/param.h rather than hard-codingjasone2008-09-101-120/+88
| | | | | | page size and using sysconf(3). Suggested by: marcel
* Unbreak ia64: pges are 8KB.marcel2008-09-061-1/+1
|
* Add thread-specific caching for small size classes, based on magazines.jasone2008-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.
* Remove grantpt.c, which should have been deleted in the MPSAFE TTY commit.ed2008-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.
* Integrate the new MPSAFE TTY layer to the FreeBSD operating system.ed2008-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
* Move CPU_SPINWAIT into the innermost spin loop, in order to allow fasterjasone2008-08-141-2/+3
| | | | | | preemption while busy-waiting. Submitted by: Mike Schuster <schuster@adobe.com>
* Re-order the terms of an expression in arena_run_reg_dalloc() to correctlyjasone2008-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.
* Remove variables which are assigned values and never used thereafter.cperciva2008-08-081-5/+1
| | | | | Found by: LLVM/Clang Static Checker Approved by: jasone
* Restructure and use different variables in the tests that involvescf2008-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
* Detect if the application has cleared the environ variable by settingscf2008-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
* Enhance arena_chunk_map_t to directly support run coalescing, and usejasone2008-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.
* - This code was intially obtained from NetBSD, but it's missing licencedanger2008-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
* - Add description about a missing return valuedanger2008-07-061-2/+6
| | | | | | PR: docs/75995 Submitted by: Tarc <tarc@po.cs.msu.su> MFC after: 3 days
* - remove superfluous worddanger2008-07-061-3/+3
| | | | | | - remove contractions MFC after: 3 days
* Mark the section describing return values with an appropriate section flag.danger2008-06-261-1/+1
| | | | | PR: docs/122818 MFC after: 3 days
* Don't export the unused __use_pts() routine.ed2008-06-172-2/+1
| | | | | | | | | | The __use_pts() routine was once probably used by libutil to determine if we are using BSD or UNIX98 style PTY device names. It doesn't seem to be used outside grantpt.c, which means we can make it static and remove it from the Symbol.map. Reviewed by: cognet, kib Approved by: philip (mentor)
* In the error path through base_alloc(), release base_mtx [1].jasone2008-06-101-3/+7
| | | | | | Fix bit vector initialization for run headers. Submitted by: [1] Mike Schuster <schuster@adobe.com>
* Clean up cpp logic and comments.jasone2008-05-141-8/+21
|
* Fix a comment.jasone2008-05-031-1/+1
|
* Add a separate tree to track arena chunks that contain dirty pages.jasone2008-05-011-157/+133
| | | | | | | This substantially improves worst case allocation performance, since O(lg n) tree search can be used instead of O(n) tree iteration. Use rb_wrap() instead of directly calling rb_*() macros.
* Add rb_wrap(), which creates C function wrappers for most rb_*()jasone2008-05-011-36/+194
| | | | | | | | | | macros. Add rb_foreach_next() and rb_foreach_reverse_prev(), which make it possible to re-synchronize tree iteration after the tree has been modified. Rename rb_tree_new() to rb_new().
* Set QUANTUM_2POW_MIN and SIZEOF_PTR_2POW parameters for MIPSgonzo2008-04-291-0/+5
| | | | Approved by: imp
* Check for integer overflow before calling sbrk(2), since it uses ajasone2008-04-291-0/+7
| | | | signed increment argument, but the size is an unsigned integer.
* Stricter check for integer overflow.ru2008-04-241-0/+2
|
* Implement red-black trees without using parent pointers, and store thejasone2008-04-232-116/+947
| | | | | | | | | color bit in the least significant bit of the right child pointer, in order to reduce red-black tree linkage overhead by ~2X as compared to sys/tree.h. Use the new red-black tree implementation in malloc, which drops memory usage by ~0.5 or ~1%, for 32- and 64-bit systems, respectively.
* Don't forget to free() currency_symbol and asciivalue when multipleru2008-04-191-0/+4
| | | | | | | | conversion specifiers for them are present. Submitted by: Maxim Dounin <mdounin@mdounin.ru> Obtained from: NetBSD (partially) MFC after: 3 days
* Better strfmon(3) conversion specifiers sanity checking.ru2008-04-191-1/+8
| | | | | | | | | | There were no checks for left and right precisions at all, and a check for field width had integer overflow bug. Reported by: Maksymilian Arciemowicz Security: http://securityreason.com/achievement_securityalert/53 Submitted by: Maxim Dounin <mdounin@mdounin.ru> MFC after: 3 days
* Use calloc() instaed of zeroing memory ourselves.delphij2008-04-131-2/+1
|
* Remove stale #include <machine/atomic.h>, which as needed by lazyjasone2008-03-071-4/+4
| | | | deallocation.
* Replace the use of warnx() with direct output to stderr using _write().scf2008-02-281-12/+36
| | | | | | | | | | | | | | | | This reduces the size of a statically-linked binary by approximately 100KB in a trivial "return (0)" test application. readelf -S was used to verify that the .text section was reduced and that using strlen() saved a few more bytes over using sizeof(). Since the section of code is only called when environ is corrupt (program bug), I went with fewer bytes over fewer cycles. I made minor edits to the submitted patch to make the output resemble warnx(). Submitted by: kib bz Approved by: wes (mentor) MFC after: 5 days
* Fix a race condition in arena_ralloc() for shrinking in-place largejasone2008-02-171-25/+41
| | | | | | | | reallocation, when junk filling is enabled. Junk filling must occur prior to shrinking, since any deallocated trailing pages are immediately available for use by other threads. Reported by: Mats Palmgren <mats.palmgren@bredband.net>
* Remove support for lazy deallocation. Benchmarks across a wide range ofjasone2008-02-172-221/+4
| | | | | | | | allocation patterns, number of CPUs, and MALLOC_OPTIONS settings indicate that lazy deallocation has the potential to worsen throughput dramatically. Performance degradation occurs when multiple threads try to clear the lazy free cache simultaneously. Various experiments to avoid this bottleneck failed to completely solve this problem, while adding yet more complexity.
* Fix a bug in lazy deallocation that was introduced whenjasone2008-02-081-7/+10
| | | | | | | | arena_dalloc_lazy_hard() was split out of arena_dalloc_lazy() in revision 1.162. Reduce thundering herd problems in lazy deallocation by randomly varying how many probes a thread does before taking the slow path.
* Clean up manipulation of chunk page map elements to remove some tenuousjasone2008-02-081-362/+357
| | | | | | | | | | | assumptions about whether bits are set at various times. This makes adding other flags safe. Reorganize functions in order to inline i{m,c,p,s,re}alloc(). This allows the entire fast-path call chains for malloc() and free() to be inlined. [1] Suggested by: [1] Stuart Parmenter <stuart@mozilla.com>
* Track dirty unused pages so that they can be purged if they exceed ajasone2008-02-062-679/+973
| | | | | | | | | | | | | | | | | | | | | | | | | threshold, according to the 'F' MALLOC_OPTIONS flag. This obsoletes the 'H' flag. Try to realloc() large objects in place. This substantially speeds up incremental large reallocations in the common case. Fix a bug in arena_ralloc() that caused relocation of sub-page objects even if the old and new sizes were in the same size class. Maintain trees of runs and simplify the per-chunk page map. This allows logarithmic-time searching for sufficiently large runs in arena_run_alloc(), whereas the previous algorithm required linear time in the worst case. Break various large functions into smaller sub-functions, and inline only the functions that are in the fast path for small object allocation/deallocation. Remove an unnecessary check in base_pages_alloc_mmap(). Avoid integer division in choose_arena() for the NO_TLS case on single-CPU systems.
* Remove some now-unused macros.jhb2008-01-151-3/+1
| | | | MFC after: 1 week
* Put back the openpty(3) and ptsname(3) fixes but don't disable ptsname(3)jhb2008-01-151-46/+31
| | | | | on pts(4) devices this time. This fixes the issues while leaving pts(4) enabled on HEAD.
* Back out last commit, since it accidentally broke pts.cperciva2008-01-151-37/+48
| | | | | The security fix will be re-committed soon, hopefully without breaking anything.
* Fix issues which allow snooping on ptys. [08:01]cperciva2008-01-141-48/+37
| | | | | | | Fix an off-by-one error in inet_network(3). [08:02] Security: FreeBSD-SA-08:01.pty Security: FreeBSD-SA-08:02.libc
* Changing 'r' to a size_t in the previous commit turned quicksortdas2008-01-141-4/+5
| | | | | | | into slowsort for some sequences because different parts of the code used 'r' to store two different things, one of which was signed. Clean things up by splitting 'r' into two variables, and use a more meaningful name.
* Use size_t to avoid overflow when sorting arrays larger than 2 GB.das2008-01-132-2/+3
| | | | | PR: 111085 MFC after: 2 weeks
* Enable both sbrk(2)- and mmap(2)-based memory acquisition methods byjasone2008-01-032-19/+20
| | | | | | | | | default. This has the disadvantage of rendering the datasize resource limit irrelevant, but without this change, legitimate uses of more memory than will fit in the data segment are thwarted by default. Fix chunk_alloc_mmap() to work correctly if initial mapping is not chunk-aligned and mapping extension fails.
OpenPOWER on IntegriCloud