summaryrefslogtreecommitdiff
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* Add a feature_present(3) function which checks to see if a named kernelJohn Baldwin2008-01-103-2/+137
| | | | | | | | | feature is present by checking the kern.features sysctl MIB. MFC after: 1 week Notes: svn path=/head/; revision=175220
* Add a new file descriptor type for IPC shared memory objects and use it toJohn Baldwin2008-01-085-335/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implement shm_open(2) and shm_unlink(2) in the kernel: - Each shared memory file descriptor is associated with a swap-backed vm object which provides the backing store. Each descriptor starts off with a size of zero, but the size can be altered via ftruncate(2). The shared memory file descriptors also support fstat(2). read(2), write(2), ioctl(2), select(2), poll(2), and kevent(2) are not supported on shared memory file descriptors. - shm_open(2) and shm_unlink(2) are now implemented as system calls that manage shared memory file descriptors. The virtual namespace that maps pathnames to shared memory file descriptors is implemented as a hash table where the hash key is generated via the 32-bit Fowler/Noll/Vo hash of the pathname. - As an extension, the constant 'SHM_ANON' may be specified in place of the path argument to shm_open(2). In this case, an unnamed shared memory file descriptor will be created similar to the IPC_PRIVATE key for shmget(2). Note that the shared memory object can still be shared among processes by sharing the file descriptor via fork(2) or sendmsg(2), but it is unnamed. This effectively serves to implement the getmemfd() idea bandied about the lists several times over the years. - The backing store for shared memory file descriptors are garbage collected when they are not referenced by any open file descriptors or the shm_open(2) virtual namespace. Submitted by: dillon, peter (previous versions) Submitted by: rwatson (I based this on his version) Reviewed by: alc (suggested converting getmemfd() to shm_open()) Notes: svn path=/head/; revision=175164
* Enable both sbrk(2)- and mmap(2)-based memory acquisition methods byJason Evans2008-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. Notes: svn path=/head/; revision=175075
* Fix a major chunk-related memory leak in chunk_dealloc_dss_record(). [1]Jason Evans2007-12-311-65/+56
| | | | | | | | | | | Clean up DSS-related locking and protect all pertinent variables with dss_mtx (remove dss_chunks_mtx). This fixes race conditions that could cause chunk leaks. Reported by: [1] kris Notes: svn path=/head/; revision=175011
* Fix a bug related to sbrk() calls that could cause address space leaks.Jason Evans2007-12-311-186/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a long-standing bug, but until recent changes it was difficult to trigger, and even then its impact was non-catastrophic, with the exception of revision 1.157. Optimize chunk_alloc_mmap() to avoid the need for unmapping pages in the common case. Thanks go to Kris Kennaway for a patch that inspired this change. Do not maintain a record of previously mmap'ed chunk address ranges. The original intent was to avoid the extra system call overhead in chunk_alloc_mmap(), which is no longer a concern. This also allows some simplifications for the tree of unused DSS chunks. Introduce huge_mtx and dss_chunks_mtx to replace chunks_mtx. There was no compelling reason to use the same mutex for these disjoint purposes. Avoid memset() for huge allocations when possible. Maintain two trees instead of one for tracking unused DSS address ranges. This allows scalable allocation of multi-chunk huge objects in the DSS. Previously, multi-chunk huge allocation requests failed if the DSS could not be extended. Notes: svn path=/head/; revision=175004
* Back out premature commit of previous version.Jason Evans2007-12-281-183/+113
| | | | Notes: svn path=/head/; revision=174957
* Maintain two trees instead of one (old_chunks --> old_chunks_{ad,szad}) inJason Evans2007-12-281-113/+183
| | | | | | | | | | | | order to support re-use of multi-chunk unused regions within the DSS for huge allocations. This generalization is important to correct function when mmap-based allocation is disabled. Avoid zeroing re-used memory in the DSS unless it really needs to be zeroed. Notes: svn path=/head/; revision=174956
* Release chunks_mtx for all paths through chunk_dealloc().Jason Evans2007-12-281-1/+4
| | | | | | | Reported by: kris Notes: svn path=/head/; revision=174953
* Add the 'D' and 'M' run time options, and use them to control whetherJason Evans2007-12-272-315/+492
| | | | | | | | | | | | | | | | | | | | | memory is acquired from the system via sbrk(2) and/or mmap(2). By default, use sbrk(2) only, in order to support traditional use of resource limits. Additionally, when both options are enabled, prefer the data segment to anonymous mappings, in order to coexist better with large file mappings in applications on 32-bit platforms. This change has the potential to increase memory fragmentation due to the linear nature of the data segment, but from a performance perspective this is mitigated by the use of madvise(2). [1] Add the ability to interpret integer prefixes in MALLOC_OPTIONS processing. For example, MALLOC_OPTIONS=lllllllll can now be specified as MALLOC_OPTIONS=9l. Reported by: [1] rwatson Design review: [1] alc, peter, rwatson Notes: svn path=/head/; revision=174950
* Fix a typo in regards to the ENOENT error.John Baldwin2007-12-271-1/+1
| | | | | | | | | PR: docs/118929 Submitted by: mymtom of hotmail MFC after: 3 days Notes: svn path=/head/; revision=174945
* Clean up some of the pts(4) vs pty(4) stuff in grantpt(3) and friends:John Baldwin2007-12-211-22/+23
| | | | | | | | | | | | | - Use PTY* for all pty(4) related constants. - Use PTMX* for all pts(4) related constants. - Consistently use _PATH_DEV PTMX rather than "/dev/ptmx". - Revert 1.7 and properly fix it by using the correct prefix string for pts(4) masters. MFC after: 3 days Notes: svn path=/head/; revision=174842
* Reduce lock contention for simple cases.Warner Losh2007-12-191-16/+22
| | | | | | | | | # this really should be done with pthread_once, but I've debugged this code. Reviewed by: arch@ Notes: svn path=/head/; revision=174766
* Add note about other systems.Warner Losh2007-12-191-0/+3
| | | | Notes: svn path=/head/; revision=174765
* Move all the xprintf-related symbols to FBSDprivate_1.0.David Schultz2007-12-181-9/+13
| | | | | | | Discussed with: deischen, kan, phk Notes: svn path=/head/; revision=174760
* Since nan() is supposed to work the same as strtod("nan(...)", NULL),David Schultz2007-12-184-12/+0
| | | | | | | | | | | | | | | my original implementation made both use the same code. Unfortunately, this meant libm depended on a vendor header at compile time and previously- unexposed vendor bits in libc at runtime. Hence, I just wrote my own version of the relevant vendor routine. As it turns out, mine has a factor of 8 fewer of lines of code, and is a bit more readable anyway. The strtod() and *scanf() routines still use vendor code. Reviewed by: bde Notes: svn path=/head/; revision=174759
* Use fixed point integer math instead of floating point math whenJason Evans2007-12-181-42/+47
| | | | | | | | | | | | | calculating run sizes. Use of the floating point unit was a potential pessimization to context switching for applications that do not otherwise use floating point math. [1] Reformat cpp macro-related comments to improve consistency. Submitted by: das Notes: svn path=/head/; revision=174745
* Catch up with vfprintf.c,v 1.77.David Schultz2007-12-181-0/+1
| | | | Notes: svn path=/head/; revision=174733
* Moved logging out of the nss_method_lookup() in order not toMichael Bushkov2007-12-171-9/+13
| | | | | | | flood logs with failed fallback method lookup attempts. Notes: svn path=/head/; revision=174716
* Refactor features a bit in order to make it possible to disable lazyJason Evans2007-12-171-52/+127
| | | | | | | | | | | | deallocation and dynamic load balancing via the MALLOC_LAZY_FREE and MALLOC_BALANCE knobs. This is a non-functional change, since these features are still enabled when possible. Clean up a few things that more pedantic compiler settings would cause complaints over. Notes: svn path=/head/; revision=174695
* Implement and document nan(), nanf(), and nanl(). This commitDavid Schultz2007-12-161-4/+23
| | | | | | | | | | adds two new directories in msun: ld80 and ld128. These are for long double functions specific to the 80-bit long double format used on x86-derived architectures, and the 128-bit format used on sparc64, respectively. Notes: svn path=/head/; revision=174684
* Export gdtoa's __ULto{x,Q}_D2A routine in a private namespace soDavid Schultz2007-12-165-0/+17
| | | | | | | libm can use it. Notes: svn path=/head/; revision=174681
* Arrange so that the NaN returned by strtod("nan", NULL) is the same asDavid Schultz2007-12-165-27/+27
| | | | | | | the NaN returned by strtod("nan()", NULL). Notes: svn path=/head/; revision=174680
* Increment the version namespace for 8.0-current. New symbols andDaniel Eischen2007-12-141-0/+5
| | | | | | | symbols whose ABI has changed should be added to FBSD_1.1. Notes: svn path=/head/; revision=174595
* Update posix_openpt(3) to handle 512 ptys. This was missed in the earlierJohn Baldwin2007-12-131-2/+2
| | | | | | | | | pty(4) changes. MFC after: 3 days Notes: svn path=/head/; revision=174565
* Remove license clause 3 to agree with the now-standard BSD license.Wes Peters2007-12-123-14/+0
| | | | | | | Prompted by: Glenn Halperin, Symbian Software Notes: svn path=/head/; revision=174553
* Implementing 'fallback' nsswitch source. 'fallback' source is usedMichael Bushkov2007-12-123-116/+220
| | | | | | | | | | | | | | | when particular function can't be found in nsswitch-module. For example, getgrouplist(3) will use module-supplied 'getgroupmembership' function (which can work in an optimal way for such source as LDAP) and will fall back to the stanard iterate-through-all-groups implementation otherwise. PR: ports/114655 Submitted by: Michael Hanselmann <freebsd AT hansmi DOT ch> Reviewed by: brooks (mentor) Notes: svn path=/head/; revision=174547
* Remove 3rd clause of licenseAlexey Zelkin2007-12-121-4/+0
| | | | | | | Per request of: glenn halperin at symbian.com Notes: svn path=/head/; revision=174546
* Fix typo in the commentAndrey A. Chernov2007-12-111-1/+1
| | | | Notes: svn path=/head/; revision=174541
* Remove some test instrumentation. (The Symbol.map changes broke it anyway.)David Schultz2007-12-092-8/+0
| | | | Notes: svn path=/head/; revision=174495
* Fix handling of subnormals on i386/ia64/amd64.David Schultz2007-12-091-2/+0
| | | | | | | PR: 85080 Notes: svn path=/head/; revision=174488
* Make the warning a bit less 'broad' then it used to be. The accessRemko Lodder2007-12-081-1/+10
| | | | | | | | | | | | is seems to be a problem for SUID applications, which we like to prevent as much as possible. PR: docs/39530 Submitted by: Soren Spies <sspies at apple dot com> MFC After: 3 days Notes: svn path=/head/; revision=174463
* Merge BIND 9.4.2 into main chunk.Hajimu UMEMOTO2007-12-032-18/+25
| | | | Notes: svn path=/head/; revision=174226
* This commit was generated by cvs2svn to compensate for changes in r174223,Hajimu UMEMOTO2007-12-031-2/+2
|\ | | | | | | | | | | | | which included commits to RCS files with non-trunk default branches. Notes: svn path=/head/; revision=174224
| * Vendor import of BIND 9.4.2vendor/resolver/9.4.2Hajimu UMEMOTO2007-12-033-21/+32
| | | | | | | | | | Notes: svn path=/vendor/resolver/dist/; revision=174223 svn path=/vendor/resolver/9.4.2/; revision=174225; tag=vendor/resolver/9.4.2
| * Vendor import of BIND 9.4.1vendor/resolver/9.4.1Hajimu UMEMOTO2007-06-031-2/+7
| | | | | | | | | | Notes: svn path=/vendor/resolver/dist/; revision=170245 svn path=/vendor/resolver/9.4.1/; revision=170246; tag=vendor/resolver/9.4.1
* | Since jb@ fixed the type of dd_lock in <dirent.h>, these casts are noDag-Erling Smørgrav2007-12-034-11/+11
| | | | | | | | | | | | | | longer required. Notes: svn path=/head/; revision=174221
* | In scanf, round according to the current rounding mode.David Schultz2007-12-037-8/+20
| | | | | | | | Notes: svn path=/head/; revision=174204
* | Only zero large allocations when necessary (for calloc()).Jason Evans2007-11-281-1/+1
| | | | | | | | Notes: svn path=/head/; revision=174002
* | Add _pthread_mutex_init_calloc_cb to libc's map, for which malloc definesJason Evans2007-11-271-0/+1
| | | | | | | | | | | | | | a stub. Notes: svn path=/head/; revision=173986
* | Document the B and L MALLOC_OPTIONS.Jason Evans2007-11-271-1/+26
| | | | | | | | Notes: svn path=/head/; revision=173969
* | Implement dynamic load balancing of thread-->arena mapping, based on lockJason Evans2007-11-271-58/+297
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | contention. The intent is to dynamically adjust to load imbalances, which can cause severe contention. Use pthread mutexes where possible instead of libc "spinlocks" (they aren't actually spin locks). Conceptually, this change is meant only to support the dynamic load balancing code by enabling the use of spin locks, but it has the added apparent benefit of substantially improving performance due to reduced context switches when there is moderate arena lock contention. Proper tuning parameter configuration for this change is a finicky business, and it is very much machine-dependent. One seemingly promising solution would be to run a tuning program during operating system installation that computes appropriate settings for load balancing. (The pthreads adaptive spin locks should probably be similarly tuned.) Notes: svn path=/head/; revision=173968
* | Implement lazy deallocation of small objects. For each arena, maintain aJason Evans2007-11-271-0/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | vector of slots for lazily freed objects. For each deallocation, before doing the hard work of locking the arena and deallocating, try several times to randomly insert the object into the vector using atomic operations. This approach is particularly effective at reducing contention for multi-threaded applications that use the producer-consumer model, wherein one producer thread allocates objects, then multiple consumer threads deallocate those objects. Notes: svn path=/head/; revision=173966
* | Avoid re-zeroing memory in calloc() when possible.Jason Evans2007-11-271-143/+218
| | | | | | | | Notes: svn path=/head/; revision=173965
* | Fix stats printing of the amount of memory currently consumed by hugeJason Evans2007-11-271-36/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | allocations. [1] Fix calculation of the number of arenas when 'n' is specified via MALLOC_OPTIONS. Clean up various style inconsistencies. Obtained from: [1] NetBSD Notes: svn path=/head/; revision=173964
* | Use an intermediate pointer to avoid a strict aliasing warning.John Birrell2007-11-231-1/+2
| | | | | | | | Notes: svn path=/head/; revision=173859
* | Use an intermediate pointer to avoid a strict aliasing warning.John Birrell2007-11-211-1/+2
| | | | | | | | | | | | | | | | | | Note that ULong in this code is actually defined as an unsigned integer across all arches so that the gdtoa() function always processes 32 bit data despite the unfortunate naming of "ULong". Notes: svn path=/head/; revision=173793
* | Use intermediate pointers to avoid strict alias type check failuresJohn Birrell2007-11-207-15/+47
| | | | | | | | | | | | | | | | using gcc 4.2. This is required for tinderbox which doesn't have -fno-strict-aliasing in it's custom CFLAGS. Notes: svn path=/head/; revision=173763
* | Change the casts from (pthread_mutex_t *) to (void *) to keep gcc quiet.Olivier Houchard2007-11-191-3/+3
| | | | | | | | | | | | | | Anybody with a cleaner solution feel free to change it. Notes: svn path=/head/; revision=173757
* | Fix bad rule and bad dependency for nsparser.h that canRuslan Ermilov2007-11-151-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | cause the build to fail because y.tab.c can have a more recent modification time than y.tab.h, and the bad rule relied on the opposite. (The last write to y.tab.c by yacc(1) happens after the last write to y.tab.h, according to truss(1).) Reported by: kensmith Notes: svn path=/head/; revision=173660
* | - Include runetype.h for _RuneLocale_Rong-En Fan2007-11-071-0/+2
| | | | | | | | Notes: svn path=/head/; revision=173420