summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix typos and spelling mistakes.joel2010-08-061-1/+1
|
* Comment out IEEE Std 1003.1-2001 conformance proclaimed too early,ache2010-08-051-5/+5
| | | | | see problems described in the comment to: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/128933
* mdoc: remove unbalanced quotesuqs2010-08-021-2/+2
|
* Provide 64-bit PowerPC support in libc.nwhitehorn2010-07-101-1/+6
| | | | Obtained from: projects/ppc64
* In threaded processes, destroy the mutex atexit_mutex when we'vecperciva2010-06-131-0/+3
| | | | | | | | | | finished using it. This allows the mutex's allocated memory to be freed. This is one sense a rather silly change, since at this point we're less than a microsecond away from calling _exit; but fixing this memory leak is likely to make life easier for anyone trying to track down other memory leaks.
* mdoc: move CAVEATS, BUGS and SECURITY CONSIDERATIONS sections to theuqs2010-05-131-12/+12
| | | | | | | | | | | bottom of the manpages and order them consistently. GNU groff doesn't care about the ordering, and doesn't even mention CAVEATS and SECURITY CONSIDERATIONS as common sections and where to put them. Found by: mdocml lint run Reviewed by: ru
* The previous revision actually removed the bug being hinted at, sobrueffer2010-05-121-3/+2
| | | | | | | | go ahead and remove the hint. PR: 143944 Submitted by: Jeremy Huddleston <jeremyhu@apple.com> MFC after: 1 week
* C language does not has references, it provides pointers.kib2010-04-211-2/+2
| | | | | Suggested by: bde MFC after: 2 weeks
* Add standards section, improve wording, taking into account the handlingkib2010-04-211-6/+8
| | | | | | | of NULL and changed type in declaration. Suggested by: bde MFC after: 2 weeks
* Free() is not allowed to modify errno, remove safety brackets around it [1].kib2010-04-201-13/+5
| | | | | | | | | Add small optimization, do not copy a string to the buffer that is to be freed immediately after. Noted by: jh [1] Reviewed by: jh MFC after: 2 weeks
* Slightly modernize realpath(3).kib2010-04-202-8/+65
| | | | | | | | | | | 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(). PR: kern/121897 [1] MFC after: 2 weeks
* mdoc: order prologue macros consistently by Dd/Dt/Osuqs2010-04-142-2/+2
| | | | | | | | Although groff_mdoc(7) gives another impression, this is the ordering most widely used and also required by mdocml/mandoc. Reviewed by: ru Approved by: philip, ed (mentors)
* In reallocf(3), free the memory only when size != 0. Otherwise, when thejh2010-03-031-1/+8
| | | | | | | | System V compatibility option (malloc "V" flag) is in effect a zero sized reallocf() could cause a double free. PR: bin/141753 Submitted by: Dan Lukes
* Rewrite red-black trees to do lazy balance fixup. This improvesjasone2010-02-282-772/+837
| | | | insert/remove speed by ~30%.
* Define TLS_MODEL for PowerPC as well. Since PowerPC uses variant I,marcel2010-02-161-0/+1
| | | | like ia64, leave it empty (default model).
* Unbreak ia64: tls_model("initial-exec") is invalid, because it assumesmarcel2010-02-161-11/+9
| | | | | | the static TLS model, which is fundamentally different from the dynamic TLS model. The consequence was data corruption. Limit the attribute to i386 and amd64.
* Fix PRcracauer2010-02-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/143350 Empty string test gone wrong. Testing this requires that you have a locale that has the sign string unset but has int_n_sign_posn set (the default locale falls through to use "()" around negative numbers which is probably another bug). I created that setup by hand and indeed without this fix negative numbers are put out as positive numbers (doesn't fall through to use "-" as default indicator). Unfixed example in nl_NL.ISO8859-1 with lc->negative_sign set to empty string: strfmon(buf, sizeof(buf), "%-8i", -42.0); ==> example2: 'EUR 42,00' 'Eu 42,00' Fixed: example2: 'EUR 42,00-' 'Eu 42,00-' This file and suggested fix are identical in at least freebsd-8. Backport might be appropriate but some expert on locales should probably have a look at us defaulting to negative numbers in parenthesis when LC_* is default. That doesn't look right and is not what other OSes are doing. PR: 143350 Submitted by: Corinna Vinschen Reviewed by: bug reporter submitted, tested by me
* Fix bugs:jasone2010-01-314-1352/+2256
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix a race in chunk_dealloc_dss(). * Check for allocation failure before zeroing memory in base_calloc(). Merge enhancements from a divergent version of jemalloc: * Convert thread-specific caching from magazines to an algorithm that is more tunable, and implement incremental GC. * Add support for medium size classes, [4KiB..32KiB], 2KiB apart by default. * Add dirty page tracking for pages within active small/medium object runs. This allows malloc to track precisely which pages are in active use, which makes dirty page purging more effective. * Base maximum dirty page count on proportion of active memory. * Use optional zeroing in arena_chunk_alloc() to avoid needless zeroing of chunks. This is useful in the context of DSS allocation, since a long-lived application may commonly recycle chunks. * Increase the default chunk size from 1MiB to 4MiB. Remove feature: * Remove the dynamic rebalancing code, since thread caching reduces its utility.
* Add missing return, in a rare case where we can't allocate memory inemaste2010-01-271-0/+1
| | | | | | | deallocate. Submitted by: Ryan Stone (rysto32 at gmail dot com) Approved by: jasone
* Simplify arena_run_reg_dalloc(), and remove a bug that was due to incorrectjasone2009-12-101-89/+28
| | | | initialization of ssize_invs.
* Fix the posix_memalign() changes in r196861 to actually return a NULL pointerjasone2009-12-101-0/+1
| | | | | | as intended. PR: standards/138307
* Revert behavior change to setenv(), unsetenv() and putenv() until a morescf2009-12-071-3/+6
| | | | thorough security review has been completed.
* Update the getenv(3) man page to reflect the recent change to the behaviorscf2009-12-061-9/+9
| | | | | | | of setenv(), putenv() and unsetenv() when dealing with corrupt entries in environ. They now output a warning and complete their task without error. MFC after: 1 week
* Change the behavior of setenv(), putenv() and unsetenv() to continue parsingscf2009-12-061-6/+3
| | | | | | | | | | | | instead of returning an error if a corrupt (not a "name=value" string) entry in the environ array is detected when (re)-building the internal environment. This should prevent applications or libraries from experiencing issues arising from the expectation that these calls will complete even with corrupt entries. The behavior is now as it was prior to 7.0. Reviewed by: jilles MFC after: 1 week
* Improve the comment within getenv() explaining the search order it takes toscf2009-12-061-8/+9
| | | | | | | | | | find a variable. Include a note that it must not cause the internal environment to be generated since malloc() depends upon getenv(). To call malloc() would create a circular dependency. Recommended by: green Approved by: jilles MFC after: 1 week
* Fix many "function declaration isn't a prototype" warnings in libc.ed2009-12-051-2/+1
| | | | | I've only fixed code that seems to be written by `us'. There are still many warnings like this present in resolv/, rpc/, stdtime/ and yp/.
* Temporarily revert the previous change because the linker has beengreen2009-12-011-36/+28
| | | | modified so that it will abort when the environment is bad.
* Do not gratuitously fail *env(3) operations due to corrupt ('='-less)green2009-12-011-28/+36
| | | | | | | | | | | | | **environ entries. This puts non-getenv(3) operations in line with getenv(3) in that bad environ entries do not cause all operations to fail. There is still some inconsistency in that getenv(3) in the absence of any environment-modifying operation does not emit corrupt environ entry warnings. I also fixed another inconsistency in getenv(3) where updating the global environ pointer would not be reflected in the return values. It would have taken an intermediary setenv(3)/putenv(3)/unsetenv(3) in order to see the change.
* Change the utrace log entry for malloc_init from (0, 0, 0) to (-1, 0, 0)cperciva2009-11-141-1/+1
| | | | | | in order to distinguish it from free(NULL), which is logged as (0, 0, 0). Reviewed by: jhb
* Make malloc(3) superpage aware. Specifically, if getpagesizes(3) returnsalc2009-09-262-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | a large page size that is greater than malloc(3)'s default chunk size but less than or equal to 4 MB, then increase the chunk size to match the large page size. Most often, using a chunk size that is less than the large page size is not a problem. However, consider a long-running application that allocates and frees significant amounts of memory. In particular, it frees enough memory at times that some of that memory is munmap()ed. Up until the first munmap(), a 1MB chunk size is just fine; it's not a problem for the virtual memory system. Two adjacent 1MB chunks that are aligned on a 2MB boundary will be promoted automatically to a superpage even though they were allocated at different times. The trouble begins with the munmap(), releasing a 1MB chunk will trigger the demotion of the containing superpage, leaving behind a half-used 2MB reservation. Now comes the real problem. Unfortunately, when the application needs to allocate more memory, and it recycles the previously munmap()ed address range, the implementation of mmap() won't be able to reuse the reservation. Basically, the coalescing rules in the virtual memory system don't allow this new range to combine with its neighbor. The effect being that superpage promotion will not reoccur for this range of addresses until both 1MB chunks are freed at some point in the future. Reviewed by: jasone MFC after: 3 weeks
* Handle zero size for posix_memalign. Return NULL or unique addresskib2009-09-051-0/+9
| | | | | | | according to the 'V' option. PR: standards/138307 MFC after: 1 week
* Our implementation of granpt(3) could be valid in the future.ed2009-08-241-15/+11
| | | | | | | | | | | | | | | | | | | | | 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) MFC after: 3 days
* Simplify. We can just use .sinclude here.ed2009-06-231-3/+1
| | | | Submitted by: Christoph Mallon
* Our grantpt(3) and unlockpt(3) don't comply with POSIX.ed2009-05-041-3/+7
|
* "-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
OpenPOWER on IntegriCloud