summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
Commit message (Collapse)AuthorAgeFilesLines
* MFC r269901:pfg2014-08-161-7/+7
| | | | | | Minor style tweaks. Obtained from: OpenBSD (CVS rev. 1.7)
* MFC r268945:pfg2014-08-041-1/+0
| | | | | | | | | | | | | | | | | | Fix hdestroy() compliance issue. 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. There is no need to bump the __FreeBSD_version as we have always claimed XPG4.2 compliance but if some reference is required, the bump for r269484 can be used. Reference: http://bugs.dragonflybsd.org/issues/1398
* MFC r268644:pfg2014-07-213-22/+14
| | | | | | | | libc/stdlib: Minor cleanups to code originating in NetBSD Mostly ANSIfication and typos. Obtained from: NetBSD
* MFC r268569:pfg2014-07-191-5/+3
| | | | | | | | strfmon: reduce unnecessary snprintf. No need for the snprintf/asprintf dance; use fixed width formats. Obtained from: NetBSD (CVS rev. 1.8)
* MFC r268393: [mdoc] Fix previous.pluknet2014-07-081-1/+1
|
* MFC 267756:ache2014-07-071-18/+12
| | | | | Merge intermediate OpenBSD v1.25 changes (almost identical to ours) to reduce diff and bump OpenBSD patch level to v1.26.
* MFC r267745, r268268:pfg2014-07-073-8/+22
| | | | | | | | | | | | getopt(3): recognize option:: as GNU extension for "optional options". 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
* MFC r264417: realpath(): Properly fail "." or ".." components afterjilles2014-06-061-20/+6
| | | | | | | | | | | | | | non-directories. 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: 82980
* MFC r259042:kib2013-12-131-5/+10
| | | | | | Do not force to run atexit handlers, which text comes from a dso owning the handle passed to __cxa_finalize() but which are registered by other dso, when the process is inside exit(3).
* system(): Restore behaviour for SIGINT and SIGQUIT.jilles2013-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.
* Make example more correct (errstr is a pointer, not boolean).pjd2013-08-181-1/+1
|
* vfork(2) was listed as deprecated in 1994 (r1573) and was the falsepeter2013-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.
* [fix to r253380] __setenv: be explicit about placing '=' after nameavg2013-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
* libc: name passed into __setenv is not necessarily NUL-terminatedavg2013-07-161-1/+1
| | | | | | That's particularly true when __setenv is called from __merge_environ. MFC after: 4 days
* Style fix noted by bde@ache2013-07-041-4/+8
|
* After fixing ranges restore POSIX requirement: rand() call withoutache2013-07-041-1/+6
| | | | | srand() must be the same as srand(1); rand(); (yet one increment)
* In addition to prev. commit, for repeated rand_r(3) calls don't forgetache2013-07-031-1/+5
| | | | | | | to compensate back at the end incremented at the start internal state. MFC after: 2 weeks
* 1) POSIX requires rand(3) return values to be in the [0, RAND_MAX] range,ache2013-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
* Renumber clauses to reduce diffs to other versionsemaste2013-06-1328-28/+28
| | | | | NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3, so follow suit to make comparison easier.
* Renumber clauses to reduce diffs to other versionsemaste2013-05-2827-27/+27
| | | | | NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3, so follow suit to make comparison easier.
* Make the malloc(3) family of functions weak and make their non-weakmarcel2013-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
* Fix a typo: It should be "strtoll" and not "stroll".hiren2013-05-141-3/+3
| | | | | | | PR: 178642 Reported by: Michael Galassi (michaelgalassi@gmail.com) Approved by: sbruno (mentor) MFC after: 1 week
* Add example.joel2013-04-211-1/+42
| | | | | | PR: 177025 Submitted by: Fernando <fernando.apesteguia@gmail.com> Reviewed by: theraven
* - Correct mispellings of the word occurrencegabor2013-04-171-1/+1
| | | | Submitted by: Christoph Mallon <christoph.mallon@gmx.de> (via private mail)
* Replace access to /dev/random with the kernel pseudo-random numberdelphij2013-04-024-55/+32
| | | | | | | | source sysctl(KERN_ARND) and remove the fallback code. Obtained from: OpenBSD Reviewed by: secteam MFC after: 1 month
* Add restrict keyword to realpath manpage.kevlo2013-03-181-1/+1
|
* Now that qsort(3) has a sample comparison function, point to thatkeramida2013-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
* Sort sections.joel2013-02-201-6/+6
|
* Various improvements to the qsort(3) usage example:keramida2013-02-201-14/+8
| | | | | | | | | | | | | | | - Remove unused #include. - Do not cast away const. - Use the canonical idiom to compare two numbers. - Use proper type for sizes, i.e. size_t instead of int. - Correct indentation. - Simplify printf("\n") to puts(""). - Use return instead of exit() in main(). Submitted by: Christoph Mallon, christoph.mallon at gmx.de Approved by: gjb (mentor) Reviewed by: stefanf MFC after: 1 week
* Add a sample program that shows how a custom comparison function andkeramida2013-02-191-1/+47
| | | | | | | | | qsort(3) can work together to sort an array of integers. PR: docs/176197 Submitted by: Fernando, fapesteguia at opensistemas.com Approved by: gjb (mentor) MFC after: 1 week
* Remove undefined behavior from sranddev() andeadler2012-10-092-4/+2
| | | | | | | | | | | | srandomdev(). This doesn't actually work with any modern C compiler: In particular, both clang and modern gcc verisons silently elide any xor operation with 'junk'. Approved by: secteam MFC after: 3 days
* Optimize prev. commit for speed.ache2012-10-031-3/+7
| | | | | | | | | 1) Don't iterate the loop from the environment array beginning each time, iterate it under the last place we deactivate instead. 2) Call __rebuild_environ() not on each iteration but once, only at the end of whole loop (of course, only in case if something is changed). MFC after: 1 week
* Using putenv() and later direct pointer contents modification it is possibeache2012-10-021-1/+3
| | | | | | | | | | | | to craft environment variables with similar names like that: a=1 a=2 ... unsetenv("a") should remove them all to make later getenv("a") impossible. Fix it to do so (this is GNU autoconf test #3 failure too). PR: 172273 MFC after: 1 week
* libc: Use O_CLOEXEC for various internal file descriptors.jilles2012-09-292-2/+2
| | | | | | | | | This fixes a race condition where another thread may fork() before CLOEXEC is set, unintentionally passing the descriptor to the child process. This commit only adds O_CLOEXEC flags to open() or openat() calls where no fcntl(fd, F_SETFD, FD_CLOEXEC) follows. The separate fcntl() call still leaves a race window so it should be fixed later.
* Slight stylification.des2012-09-281-18/+11
|
* According to a clarification at http://austingroupbugs.net/view.php?id=503emaste2012-09-122-4/+3
| | | | | | | ptsname may set errno, so avoid saving and restoring errno across the function. PR: standards/171572
* Avoid mapping ENOENT to ENOTDIR for non-existent path components.emaste2012-09-121-2/+0
| | | | | | | | | | | | | | | The ENOTDIR mapping was introduced in r235266 for kern/128933 based on an interpretation of the somewhat ambiguous language in the POSIX realpath specification. The interpretation is inconsistent with Solaris and Linux, a regression from 9.0, and does not appear to be permitted by the description of ENOTDIR: 20 ENOTDIR Not a directory. A component of the specified pathname existed, but it was not a directory, when a directory was expected. PR: standards/171577 MFC after: 3 days
* Add the same warning to rand48(3) as to rand(3) and random(3).des2012-09-111-1/+0
| | | | MFC after: 3 days
* Bump dates.des2012-09-042-2/+2
| | | | Reminded by: bz@
* Add a prominent warning about these functions' unsuitability fordes2012-09-042-13/+17
| | | | cryptographic purposes, and recommend using arc4random(3) instead.
* Make 'junk' volatile so that compilers won't be tempted to optimizekevlo2012-08-171-1/+1
| | | | | Reviewed by: ache MFC after: 3 days
* Update the 'C1x draft' reference to '.St -isoC-2011' mdoc macro.pluknet2012-07-262-2/+4
| | | | | Reviewed by: theraven MFC after: 1 week
* Remove end of line whitespace.joel2012-06-261-1/+1
|
* Add more locale-specific functions to the relevant man pages andissyl02012-06-252-1/+19
| | | | | | | | | | Makefiles: - libc/stdtime/strftime.3 - libc/stdtime/strptime.3 - libc/stdlib/strfmon.3 Reviewed by: theraven Approved by: gabor (mentor)
* Switch from 4-clause to 2-clause BSD license. (OpenBSD r1.22)delphij2012-06-111-8/+1
| | | | | | No functional change. Obtained from: NetBSD via OpenBSD
* 1) Although unpublished version of standardache2012-06-051-17/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | http://austingroupbugs.net/view.php?id=385#c713 (Resolved state) recommend this way for the current standard (called "earlier" in the text) "However, earlier versions of this standard did not require this, and the same example had to be written as: // buf was obtained by malloc(buflen) ret = write(fd, buf, buflen); if (ret < 0) { int save = errno; free(buf); errno = save; return ret; } " from feedback I have for previous commit it seems that many people prefer to avoid mass code change needed for current standard compliance and prefer to track unpublished standard instead, which requires now that free() itself must save errno, not its usage code. So, I back out "save errno across free()" part of previous commit, and will fill PR for changing free() isntead. 2) Remove now unused serrno. MFC after: 1 week
* 1) IEEE Std 1003.1-2008, "errno" section, is explicit thatache2012-06-041-6/+16
| | | | | | | | | | | | | | | | | "The setting of errno after a successful call to a function is unspecified unless the description of that function specifies that errno shall not be modified." However, free() in IEEE Std 1003.1-2008 does not mention its interaction with errno, so MAY modify it after successful call (it depends on particular free() implementation, OS-specific, etc.). So, save errno across free() calls to make code portable and POSIX-conformant. 2) Remove unused serrno assignment. MFC after: 1 week
* General mdoc(7) and typo fixes.gjb2012-05-112-3/+4
| | | | | | PR: 167734 Submitted by: Nobuyuki Koganemaru (kogane!jp.freebsd.org) MFC after: 3 days
* According to SUSv4, realpath(3) must fail ifkib2012-05-112-12/+29
| | | | | | | | | | | | | | | | | [ENOENT] A component of file_name does not name an existing file or file_name points to an empty string. [ENOTDIR] A component of the path prefix is not a directory, or the file_name argument contains at least one non- <slash> character and ends with one or more trailing <slash> characters and the last pathname component names an existing file that is neither a directory nor a symbolic link to a directory. Add checks for the listed conditions, and set errno accordingly. Update the realpath(3) manpage to mention SUS behaviour. Remove the requirement to include sys/param.h before stdlib.h. PR: 128933 MFC after: 3 weeks
* Import jemalloc 9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa (dev branch,jasone2012-04-1711-8241/+167
| | | | | | | | prior to 3.0.0 release) as contrib/jemalloc, and integrate it into libc. The code being imported by this commit diverged from lib/libc/stdlib/malloc.c in March 2010, which means that a portion of the jemalloc 1.0.0 ChangeLog entries are relevant, as are the entries for all subsequent releases.
OpenPOWER on IntegriCloud