summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
Commit message (Collapse)AuthorAgeFilesLines
...
* Import reallocarray(3) from OpenBSDBaptiste Daroussin2015-05-014-2/+182
| | | | | | | | | | | | Add a manpage for it, assign the copyright to the OpenBSD project on it since it is mostly copy/paste from OpenBSD manpage. style(9) fixes Differential Revision: https://reviews.freebsd.org/D2420 Reviewed by: kib Notes: svn path=/head/; revision=282314
* qsort(3): small style(9) cleanups.Pedro F. Giffuni2015-03-051-10/+10
| | | | | | | | Basically spaces vs. tabs. No functional change. Notes: svn path=/head/; revision=279666
* qsort(3): enhance to handle 32-bit aligned data on 64-bit systemsPedro F. Giffuni2015-03-051-12/+21
| | | | | | | | | | | | | | | | | Implement a small enhancement to the original qsort implementation: If the data is 32 bit aligned we can side-step the long type version and use int instead. The change brings a modest but significant improvement in 32 bit workloads. Relnotes: yes PR: 135718 Taken from: ache Notes: svn path=/head/; revision=279663
* Adjust wording slightly to emphasize that random(3) should not be used forColin Percival2015-02-251-3/+2
| | | | | | | | | | | any applications which need unpredictable random numbers, not merely those which are cryptographic in nature. If you work for a lottery and you're using random(3) to select the winning numbers, please let me know. Notes: svn path=/head/; revision=279269
* Update comment and NetBSD ID tag.Pedro F. Giffuni2015-02-061-3/+3
| | | | | | | | The NetBSD revisions correspond to changes we have already done like __P() removal and ANSI-fication of definitions. Notes: svn path=/head/; revision=278315
* tdelete(3): don't delete the node we are about to return.Pedro F. Giffuni2015-02-051-1/+2
| | | | | | | | | CID: 272528 Obtained from: NetBSD (CVS rev. 1.4) MFC after: 2 weeks Notes: svn path=/head/; revision=278301
* Fix known issues which blow up the process after dlopen("libthr.so")Konstantin Belousov2015-01-033-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (or loading a dso linked to libthr.so into process which was not linked against threading library). - Remove libthr interposers of the libc functions, including __error(). Instead, functions calls are indirected through the interposing table, similar to how pthread stubs in libc are already done. Libc by default points either to syscall trampolines or to existing libc implementations. On libthr load, libthr rewrites the pointers to the cancellable implementations already in libthr. The interposition table is separate from pthreads stubs indirection table to not pull pthreads stubs into static binaries. - Postpone the malloc(3) internal mutexes initialization until libthr is loaded. This avoids recursion between calloc(3) and static pthread_mutex_t initialization. - Reinstall signal handlers with wrapper on libthr load. The _rtld_is_dlopened(3) is used to avoid useless calls to sigaction(2) when libthr is statically referenced from the main binary. In the process, fix openat(2), swapcontext(2) and setcontext(2) interposing. The libc symbols were exported at different versions than libthr interposers. Export both libc and libthr versions from libc now, with default set to the higher version from libthr. Remove unused and disconnected swapcontext(3) userspace implementation from libc/gen. No objections from: deischen Tested by: pho, antoine (exp-run) (previous versions) Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=276630
* Various mdoc fixes and a few EOL whitespace removals.Christian Brueffer2014-12-212-3/+3
| | | | | | | Found with: mandoc -Tlint Notes: svn path=/head/; revision=276006
* Fix quick_exit(3) manual page to match reality - the status was missing.Edward Tomasz Napierala2014-12-131-2/+2
| | | | | | | | MFC after: 1 month Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=275752
* Use the __DECONST macro rather than hand rolling the same thing.Brooks Davis2014-10-241-5/+1
| | | | | | | Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=273614
* Add bsearch_b to the libc map and the stdlib header.Pedro F. Giffuni2014-09-011-0/+1
| | | | | | | | | | | | | | | bsearch_b is the Apple blocks enabled version of bsearch(3). This was added to libc in Revision 264042 but the commit missed the declaration required to make use of it. While here move some other block-related functions to the BSD_VISIBLE block as these are non-standard. Phabric: D638 Reviewed by: theraven, wollman Notes: svn path=/head/; revision=270952
* Minor style tweaks.Pedro F. Giffuni2014-08-131-7/+7
| | | | | | | | Obtained from: OpenBSD (CVS rev. 1.7) MFC after: 3 days Notes: svn path=/head/; revision=269901
* Fix hdestroy() compliance issue.Pedro F. Giffuni2014-07-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | The hcreate(3) implementation and related functions we inherited from NetBSD used to free() the key value, something that is not supported by the standard implementation. This would cause a segmentation fault when attempting to run the examples from the opengroup and linux manpages. NetBSD has added non-standard calls to provide the previous behaviour but hdestroy is not very commonly used so at this time it seems excessive to bring those to FreeBSD. Bump the __FreeBSD_version as this is an ABI change. Reference: http://bugs.dragonflybsd.org/issues/1398 MFC after: 2 weeks Notes: svn path=/head/; revision=268945
* Update license.Pedro F. Giffuni2014-07-211-7/+2
| | | | | | | | | NetBSD has removed the advertisement clause from this file. Obtained from: NetBSD (CVS rev. 1,8) Notes: svn path=/head/; revision=268944
* Add re-entrant versions of the hash functions based on the GNU api.Pedro F. Giffuni2014-07-214-41/+153
| | | | | | | | | | While testing this I found a conformance issue in hdestroy() that will be fixed in a subsequent commit. Obtained from: NetBSD (hcreate.c, CVS Rev. 1.7) Notes: svn path=/head/; revision=268943
* libc/stdlib: Minor cleanups to code originating in NetBSDPedro F. Giffuni2014-07-153-22/+14
| | | | | | | | | | Mostly ANSIfication and typos. Obtained from: NetBSD MFC after: 5 days Notes: svn path=/head/; revision=268644
* strfmon: reduce unnecessary snprintf.Pedro F. Giffuni2014-07-121-5/+3
| | | | | | | | | | No need for the snprintf/asprintf dance; use fixed width formats. Obtained from: NetBSD (CVS rev. 1.8) MFC after: 1 week Notes: svn path=/head/; revision=268569
* [mdoc] Fix previous change.Sergey Kandaurov2014-07-081-1/+1
| | | | Notes: svn path=/head/; revision=268393
* getopt(3): clarify GNU instead of NetBSD.Pedro F. Giffuni2014-07-041-1/+1
| | | | | | | | | | | The manpage and the code for r267745 came from NetBSD but the option is inspired on GNU. Reported by: Ben Kaduk MFC after: 3 days Notes: svn path=/head/; revision=268268
* use .Mt to mark up email addresses consistently (part4)Baptiste Daroussin2014-06-232-3/+3
| | | | | | | | PR: 191174 Submitted by: Franco Fichtner <franco at lastsummer.de> Notes: svn path=/head/; revision=267774
* Merge intermediate OpenBSD v1.25 changes (almost identical to ours)Andrey A. Chernov2014-06-221-18/+12
| | | | | | | | | to reduce diff and bump OpenBSD patch level to v1.26. MFC after: 2 weeks Notes: svn path=/head/; revision=267756
* getopt(3): recognize option:: as GNU extension for "optional options".Pedro F. Giffuni2014-06-223-8/+22
| | | | | | | | | | | | | Also ANSIfy a function declaration. While here update the OpenBSD patch level in getopt_long.c as we already have the corresponding change. Obtained from: NetBSD MFC after: 2 weeks Notes: svn path=/head/; revision=267745
* realpath(): Properly fail "." or ".." components after non-directories.Jilles Tjoelker2014-04-131-20/+6
| | | | | | | | | | | | | | | | If realpath() is called on pathnames like "/dev/null/." or "/dev/null/..", it should fail with [ENOTDIR]. Pathnames like "/dev/null/" already failed as they should. Also, put the check for non-directories after lstatting the previous component instead of when the empty component (consecutive or trailing slashes) is detected, saving an lstat() call and some lines of code. PR: kern/82980 MFC after: 2 weeks Notes: svn path=/head/; revision=264417
* Silence a warning with GCC that was breaking the build with Juniper's GCC.David Chisnall2014-04-053-4/+7
| | | | | | | Reviewed by: marcel Notes: svn path=/head/; revision=264143
* Move _b functions into the 11.x symbol version namespace.David Chisnall2014-04-031-4/+7
| | | | Notes: svn path=/head/; revision=264070
* Add support for some block functions that come from OS X. These areDavid Chisnall2014-04-0212-29/+264
| | | | | | | | | | intended to build with any C compiler. Reviewed by: pfg MFC after: 3 weeks Notes: svn path=/head/; revision=264042
* Replace use of ${.CURDIR} by ${LIBC_SRCTOP} and define ${LIBC_SRCTOP}Marcel Moolenaar2014-03-042-8/+8
| | | | | | | | | | | | | | if not already defined. This allows building libc from outside of lib/libc using a reach-over makefile. A typical use-case is to build a standard ILP32 version and a COMPAT32 version in a single iteration by building the COMPAT32 version using a reach-over makefile. Obtained from: Juniper Networks, Inc. Notes: svn path=/head/; revision=262722
* Update jemalloc to version 3.5.0.Jason Evans2014-01-232-1/+19
| | | | Notes: svn path=/head/; revision=261071
* ANSI-fy prototype.Xin LI2014-01-141-3/+1
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=260618
* getopt_long.3: wording quibblesEitan Adler2013-12-131-2/+2
| | | | | | | | | | - Make wording more clear: "is expect" vs "is expected" [1] - Remove extraneous trailing period.. Reported by: dim [1] Notes: svn path=/head/; revision=259340
* Do not force to run atexit handlers, which text comes from a dsoKonstantin Belousov2013-12-061-5/+10
| | | | | | | | | | | | | | | | | | | | owning the handle passed to __cxa_finalize() but which are registered by other dso, when the process is inside exit(3). Running them makes the destruction order wrong, and there is hope that such destructors would not call dlclose(3), since it is pointless at this stage of the process existence. The change effectively disables the r211706 after the exit(3) is called. Reported and tested by: Michael Gmelin <freebsd@grem.de> Analyzed by: dim Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=259042
* system(): Restore behaviour for SIGINT and SIGQUIT.Jilles Tjoelker2013-09-011-0/+2
| | | | | | | | | | | | | | | As mentioned in r16117 and the book "Advanced Programming in the Unix Environment" by W. Richard Stevens, we should ignore SIGINT and SIGQUIT before forking, since it is not guaranteed that the parent process starts running soon enough. To avoid calling sigaction() in the vforked child, instead block SIGINT and SIGQUIT before vfork() and keep the sigaction() to ignore after vfork(). The FreeBSD kernel discards ignored signals, even if they are blocked; therefore, it is not necessary to unblock SIGINT and SIGQUIT earlier. Notes: svn path=/head/; revision=255129
* Make example more correct (errstr is a pointer, not boolean).Pawel Jakub Dawidek2013-08-181-1/+1
| | | | Notes: svn path=/head/; revision=254483
* vfork(2) was listed as deprecated in 1994 (r1573) and was the falsePeter Wemm2013-08-131-19/+19
| | | | | | | | | | | | | | reports of its impending demise were removed in 2009 (r199257). However, in 1996 (r16117) system(3) was switched from vfork(2) to fork(2) based partly on this. Switch back to vfork(2). This has a dramatic effect in cases of extreme mmap use - such as excessive abuse (500+) of shared libraries. popen(3) has used vfork(2) for a while. vfork(2) isn't going anywhere. Notes: svn path=/head/; revision=254297
* [fix to r253380] __setenv: be explicit about placing '=' after nameAndriy Gapon2013-07-171-2/+1
| | | | | | | | | | | | | This should a regression introduced in r253380 if malloc'ed memory happens to have '=' at the right place. Reported by: ache Pointyhat to: me (avg) MFC after: 1 day X-MFC with: r253380 Notes: svn path=/head/; revision=253413
* libc: name passed into __setenv is not necessarily NUL-terminatedAndriy Gapon2013-07-161-1/+1
| | | | | | | | | That's particularly true when __setenv is called from __merge_environ. MFC after: 4 days Notes: svn path=/head/; revision=253380
* Style fix noted by bde@Andrey A. Chernov2013-07-041-4/+8
| | | | Notes: svn path=/head/; revision=252698
* After fixing ranges restore POSIX requirement: rand() call withoutAndrey A. Chernov2013-07-041-1/+6
| | | | | | | | srand() must be the same as srand(1); rand(); (yet one increment) Notes: svn path=/head/; revision=252668
* In addition to prev. commit, for repeated rand_r(3) calls don't forgetAndrey A. Chernov2013-07-031-1/+5
| | | | | | | | | | to compensate back at the end incremented at the start internal state. MFC after: 2 weeks Notes: svn path=/head/; revision=252648
* 1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] range,Andrey A. Chernov2013-07-031-4/+16
| | | | | | | | | | | | | | | | | | | but ACM formula we use have internal state (and return value) in the [1, 0x7ffffffe] range, so our RAND_MAX (0x7fffffff) is never reached because it is off by one, zero is not reached too. Correct both RAND_MAX and rand(3) return value, shifting last one to the 0 by 1 subtracted, resulting POSIXed [0, 0x7ffffffd(=new RAND_MAX)] range. 2) Add a checks for not overflowing on too big seeds. It may happens on the machines, where sizeof(unsigned int) > 32 bits. Reviewed by: bde [1] MFC after: 2 weeks Notes: svn path=/head/; revision=252608
* Renumber clauses to reduce diffs to other versionsEd Maste2013-06-1328-28/+28
| | | | | | | | NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3, so follow suit to make comparison easier. Notes: svn path=/head/; revision=251672
* Renumber clauses to reduce diffs to other versionsEd Maste2013-05-2827-27/+27
| | | | | | | | NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3, so follow suit to make comparison easier. Notes: svn path=/head/; revision=251069
* Make the malloc(3) family of functions weak and make their non-weakMarcel Moolenaar2013-05-251-0/+11
| | | | | | | | | | | | | | | | | implementations visible for use by applications. The functions $F that are now weak symbols are: allocm, calloc, dallocm, free, malloc, malloc_usable_size, nallocm, posix_memalign, rallocm, realloc, sallocm The non-weak implementations of $F are exported as __$F. Submitted by: stevek@juniper.net Reviewed by: jasone@, kib@ Approved by: jasone@ (jemalloc) Obtained from: juniper Networks, Inc Notes: svn path=/head/; revision=250991
* Fix a typo: It should be "strtoll" and not "stroll".Hiren Panchasara2013-05-141-3/+3
| | | | | | | | | | PR: 178642 Reported by: Michael Galassi (michaelgalassi@gmail.com) Approved by: sbruno (mentor) MFC after: 1 week Notes: svn path=/head/; revision=250639
* Add example.Joel Dahl2013-04-211-1/+42
| | | | | | | | | PR: 177025 Submitted by: Fernando <fernando.apesteguia@gmail.com> Reviewed by: theraven Notes: svn path=/head/; revision=249721
* - Correct mispellings of the word occurrenceGabor Kovesdan2013-04-171-1/+1
| | | | | | | Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail) Notes: svn path=/head/; revision=249582
* Replace access to /dev/random with the kernel pseudo-random numberXin LI2013-04-024-55/+32
| | | | | | | | | | | source sysctl(KERN_ARND) and remove the fallback code. Obtained from: OpenBSD Reviewed by: secteam MFC after: 1 month Notes: svn path=/head/; revision=249035
* Add restrict keyword to realpath manpage.Kevin Lo2013-03-181-1/+1
| | | | Notes: svn path=/head/; revision=248453
* Now that qsort(3) has a sample comparison function, point to thatGiorgos Keramidas2013-02-231-1/+7
| | | | | | | | | | | | | example from bsearch(3) too, so that we don't have to duplicate the example code in both places. PR: docs/176197 Reviewed by: stefanf Approved by: remko (mentor), gjb (mentor) MFC after: 1 week Notes: svn path=/head/; revision=247189
* Sort sections.Joel Dahl2013-02-201-6/+6
| | | | Notes: svn path=/head/; revision=247051