summaryrefslogtreecommitdiffstats
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
...
* Add __FBSDID() tags.rwatson2008-03-074-8/+12
| | | | MFC after: 3 days
* Add cpuset, an api for thread to cpu binding and cpu resource groupingjeff2008-03-021-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | and assignment. - Add a reference to a struct cpuset in each thread that is inherited from the thread that created it. - Release the reference when the thread is destroyed. - Add prototypes for syscalls and macros for manipulating cpusets in sys/cpuset.h - Add syscalls to create, get, and set new numbered cpusets: cpuset(), cpuset_{get,set}id() - Add syscalls for getting and setting affinity masks for cpusets or individual threads: cpuid_{get,set}affinity() - Add types for the 'level' and 'which' parameters for the cpuset. This will permit expansion of the api to cover cpu masks for other objects identifiable with an id_t integer. For example, IRQs and Jails may be coming soon. - The root set 0 contains all valid cpus. All thread initially belong to cpuset 1. This permits migrating all threads off of certain cpus to reserve them for special applications. Sponsored by: Nokia Discussed with: arch, rwatson, brooks, davidxu, deischen Reviewed by: antoine
* Use the easily-greppable copyright notice template fromphilip2008-02-297-119/+119
| | | | | | src/share/examples/mdoc/POSIX-copyright. Requested by: ru
* 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
* Add <limits.h> for SHRT_MAX.jhb2008-02-273-0/+3
| | | | Pointy hat to: jhb
* File descriptors are an int, but our stdio FILE object uses a short to holdjhb2008-02-273-0/+39
| | | | | | | | | | | | | | | | | them. Thus, any fd whose value is greater than SHRT_MAX is handled incorrectly (the short value is sign-extended when converted to an int). An unpleasant side effect is that if fopen() opens a file and gets a backing fd that is greater than SHRT_MAX, fclose() will fail and the file descriptor will be leaked. Better handle this by fixing fopen(), fdopen(), and freopen() to fail attempts to use a fd greater than SHRT_MAX with EMFILE. At some point in the future we should look at expanding the file descriptor in FILE to an int, but that is a bit complicated due to ABI issues. MFC after: 1 week Discussed on: arch Reviewed by: wollman
* stdio is currently limited to file descriptors not greater thanwollman2008-02-271-1/+19
| | | | | | | | {SHRT_MAX}, so {STREAM_MAX} should be no greater than that. (This does not exactly meet the letter of POSIX but comes reasonably close to it in spirit.) MFC after: 14 days
* Added the "restrict" type-qualifier to the readlink() prototype.ru2008-02-261-2/+2
|
* Add missing words.brueffer2008-02-251-2/+2
| | | | MFC after: 3 days
* Let PowerPC world optionally build with -msoft-float. For FPU-less PowerPCraj2008-02-246-0/+12
| | | | | | | | | variations (e500 currently), this provides a gcc-level FPU emulation and is an alternative approach to the recently introduced kernel-level emulation (FPU_EMU). Approved by: cognet (mentor) MFp4: e500
* Note, as required by our agreement with IEEE/The Open Group, that the messagephilip2008-02-217-0/+140
| | | | | | | | queue manual pages excerpt the POSIX standard. Spotted by: Mindaugas Rasiukevicius <rmind -at- NetBSD.org> Reviewed by: imp MFC after: 1 day
* getopt(3) returns -1, not EOF.kevlo2008-02-183-3/+3
|
* 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.
* Allow underscore in domain names while resolving. While having underscoredelphij2008-02-161-1/+2
| | | | | | | | | | is a violation of RFC 1034 [STD 13], it is accepted by certain name servers as well as other popular operating systems' resolver library. Bugs are mine. Obtained from: ume MFC after: 2 weeks
* Change readlink(2)'s return type and type of the last argumentru2008-02-121-4/+4
| | | | | | to match POSIX. Prodded by: Alexey Lyashkov
* After issueing a ntpdate [1] I noticed it's already 2008, reflect thatremko2008-02-111-1/+1
| | | | | | in the last modified date. Noticed by: brueffer [1]
* Fix typo (s/existance/existence/)remko2008-02-111-2/+2
| | | | Noticed by: ceri
* 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>
* Add pthread_mutex_isowned_np() so there is no need for an additionaldes2008-02-062-0/+2
| | | | | | prototype next to the implementation. MFC after: 2 weeks
* 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 incomplete support of AI_ALL and AI_V4MAPPED.ume2008-02-031-21/+0
| | | | Reported by: "Heiko Wundram (Beenic)" <wundram__at__beenic.net>
* Give sendfile(2) a SF_SYNC flag which makes it wait until all mbufsphk2008-02-031-1/+14
| | | | | | | | referencing the files VM pages are returned from the network stack, making changes to the file safe. This flag does not guarantee that the data has been transmitted to the other end.
* Update this manual page to describe the extattr_list_file() and thetrhodes2008-01-291-6/+13
| | | | | | | | extattr_list_fd() functions. PR: 108142 Submitted by: Richard Dawe <rich@phekda.gotadsl.co.uk> Reviewed by: kientzle
* Our fts(3) API, as inherited from 4.4BSD, suffers from integeryar2008-01-266-93/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fields in FTS and FTSENT structs being too narrow. In addition, the narrow types creep from there into fts.c. As a result, fts(3) consumers, e.g., find(1) or rm(1), can't handle file trees an ordinary user can create, which can have security implications. To fix the historic implementation of fts(3), OpenBSD and NetBSD have already changed <fts.h> in somewhat incompatible ways, so we are free to do so, too. This change is a superset of changes from the other BSDs with a few more improvements. It doesn't touch fts(3) functionality; it just extends integer types used by it to match modern reality and the C standard. Here are its points: o For C object sizes, use size_t unless it's 100% certain that the object will be really small. (Note that fts(3) can construct pathnames _much_ longer than PATH_MAX for its consumers.) o Avoid the short types because on modern platforms using them results in larger and slower code. Change shorts to ints as follows: - For variables than count simple, limited things like states, use plain vanilla `int' as it's the type of choice in C. - For a limited number of bit flags use `unsigned' because signed bit-wise operations are implementation-defined, i.e., unportable, in C. o For things that should be at least 64 bits wide, use long long and not int64_t, as the latter is an optional type. See FTSENT.fts_number aka FTS.fts_bignum. Extending fts_number `to satisfy future needs' is pointless because there is fts_pointer, which can be used to link to arbitrary data from an FTSENT. However, there already are fts(3) consumers that require fts_number, or fts_bignum, have at least 64 bits in it, so we must allow for them. o For the tree depth, use `long'. This is a trade-off between making this field too wide and allowing for 64-bit inode numbers and/or chain-mounted filesystems. On the one hand, `long' is almost enough for 32-bit filesystems on a 32-bit platform (our ino_t is uint32_t now). On the other hand, platforms with a 64-bit (or wider) `long' will be ready for 64-bit inode numbers, as well as for several 32-bit filesystems mounted one under another. Note that fts_level has to be signed because -1 is a magic value for it, FTS_ROOTPARENTLEVEL. o For the `nlinks' local var in fts_build(), use `long'. The logic in fts_build() requires that `nlinks' be signed, but our nlink_t currently is uint16_t. Therefore let's make the signed var wide enough to be able to represent 2^16-1 in pure C99, and even 2^32-1 on a 64-bit platform. Perhaps the logic should be changed just to use nlink_t, but it can be done later w/o breaking fts(3) ABI any more because `nlinks' is just a local var. This commit also inludes supporting stuff for the fts change: o Preserve the old versions of fts(3) functions through libc symbol versioning because the old versions appeared in all our former releases. o Bump __FreeBSD_version just in case. There is a small chance that some ill-written 3-rd party apps may fail to build or work correctly if compiled after this change. o Update the fts(3) manpage accordingly. In particular, remove references to fts_bignum, which was a FreeBSD-specific hack to work around the too narrow types of FTSENT members. Now fts_number is at least 64 bits wide (long long) and fts_bignum is an undocumented alias for fts_number kept around for compatibility reasons. According to Google Code Search, the only big consumers of fts_bignum are in our own source tree, so they can be fixed easily to use fts_number. o Mention the change in src/UPDATING. PR: bin/104458 Approved by: re (quite a while ago) Discussed with: deischen (the symbol versioning part) Reviewed by: -arch (mostly silence); das (generally OK, but we didn't agree on some types used; assuming that no objections on -arch let me to stick to my opinion)
* Fix longstanding mb/wc functions segfault if error occurseache2008-01-231-29/+39
| | | | | inside _<encoding>_init(). Currently _EUC_init() only was affected.
* Better fix for longstanding segfault. Don't touch current locale at allache2008-01-231-17/+29
| | | | on unknown encoding. Previous fix resets it to POSIX.
* 1) Add (void) cast to _none_init() (while I am here)ache2008-01-231-2/+4
| | | | | 2) Fix longstanding segfault in mb/wc code when unknown encoding is specified in the locale file (mb/wc functions becomes NULL in that case).
* Xref flopen.3 which references this manual page.trhodes2008-01-221-1/+2
| | | | PR: 112650
* Introduce new encoding: "ASCII"ache2008-01-214-1/+191
| | | | | It differs from default C/POSIX "NONE" mainly by stricter 8bit check for mb*towc*/wc*tomb* family, returning EILSEQ
* Add a new union member to access the exponent and sign of a long doubledas2008-01-181-0/+5
| | | | in a single op. Idea from bde.
* Add an alternative view of the bits in an 80-bit long double (64+16bde2008-01-173-3/+24
| | | | | | | | | | | | | | | | | | | | instead of 32+32+15+1) on all arches that have such long doubles (amd64, ia64 and i386). Large objects should be be accessed in large units, and the 32+32+15+1[+padding] decomposition asks for almost the opposite of that, sometimes resulting in very slow accesses depending on how well the compiler ignores what we ask for and converts to the best units for the given machine. E.g., on Athlons, there is a 10-20 cycle penalty for accessing the middle 32-bit word immediately after an 80-bit store. Whether actually using the alternative view is better is very machine- dependent. A 32+32+16 view is probably best with old 32-bit systems and gcc through 4.2.1. The compiler should mostly avoid the view and generate best accesses, but gcc-4.2.1 is far from doing that. I think 64+16 is best for now. Similarly for doubles -- they should be using 64+0 especially on 64-bit machines, but fdlibm uses 32+32 extensively for them. Fortunately, in 64-bit mode for doubles, gcc already ignores the 32+32-bit view and generates best accesses in many cases.
* Fix some style nits.remko2008-01-161-4/+4
| | | | | Prodded by: brueffer MFC After: 3 days
* 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.
* In getttyent(3), if /etc/ttys doesn't end in a newline, don'tdas2008-01-151-1/+1
| | | | | | | freak out and keep trying to expand the buffer until realloc() fails. PR: 114398
* Fix issues which allow snooping on ptys. [08:01]cperciva2008-01-142-50/+39
| | | | | | | 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
* Add a feature_present(3) function which checks to see if a named kerneljhb2008-01-103-2/+137
| | | | | | feature is present by checking the kern.features sysctl MIB. MFC after: 1 week
* Add a new file descriptor type for IPC shared memory objects and use it tojhb2008-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())
* 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.
* Fix a major chunk-related memory leak in chunk_dealloc_dss_record(). [1]jasone2007-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
* Fix a bug related to sbrk() calls that could cause address space leaks.jasone2007-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.
* Back out premature commit of previous version.jasone2007-12-281-183/+113
|
* Maintain two trees instead of one (old_chunks --> old_chunks_{ad,szad}) injasone2007-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.
* Release chunks_mtx for all paths through chunk_dealloc().jasone2007-12-281-1/+4
| | | | Reported by: kris
* Add the 'D' and 'M' run time options, and use them to control whetherjasone2007-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
OpenPOWER on IntegriCloud