summaryrefslogtreecommitdiffstats
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* MFC r304703, r304755ache2016-08-261-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | 1) _locale.h LC_*_MASK bit shifting order was partially broken from the initial commit time at year 2012. Only LC_COLLATE_MASK and LC_CTYPE_MASK are in the right order. The order here should match XLC_* from "xlocale_private.h" which, in turn, match LC_* publicly visible order from <locale.h> which determines how locale components are stored in the structure. LC_*_MASK -> XLC_* translation done as "ffs(mask) - 1" in the querylocale() and equivalent shift loop in the newlocale(), so mapped to some wrong components (excluding two mentioned above). Formally the fix is ABI breakage, but old code using those masks never works properly in any case. Only newlocale() and querylocale() are affected. 2) msgcat.c Use current locale (f.e. set by thread). It was global locale always previously. PR: 211743
* MFC 304476: Fix various nits in the aio operation manpages.jhb2016-08-224-26/+15
| | | | | | | | | | | | | | | | | | - Avoid double use of "request" in a single sentence. Instead, describe aio_sigevent as being used to request notification of the associated operation's completion. This matches the language used to describe aio_sigevent in aio(4). - Simplify the prohibition on modifying buffers while requests are in flight. - Fix case mismatch. - Drop note about not using stack variables. C programmers should be able to figure out if a stack variable is safe based on the later warning about the life cycle requirements of control blocks. - Remove prohibition on modifying the I/O buffer for aio_fsync() since it does not use an I/O buffer. For aio_mlock(), prohibit modifications to the mapping (e.g. due to mprotect, munmap, mmap, etc.) but do not prohibit modifications to the memory backing the buffer (stores into the pages backing the buffer).
* MFC r303795:kib2016-08-209-1/+453
| | | | Add __cxa_thread_atexit(3) API implementation.
* MFC r303794:kib2016-08-201-1/+5
| | | | Create namespace for the symbols added during 12-CURRENT cycle.
* MFC r304288:bdrewery2016-08-201-6/+0
| | | | Garbage collect _umtx_lock(2)/_umtx_unlock(2) references removed in r263318.
* MFC 303001: Add PTRACE_VFORK to trace vfork events.jhb2016-08-191-0/+42
| | | | | | | | | First, PL_FLAG_FORKED events now also set a PL_FLAG_VFORKED flag when the new child was created via vfork() rather than fork(). Second, a new PL_FLAG_VFORK_DONE event can now be enabled via the PTRACE_VFORK event mask. This new stop is reported after the vfork parent resumes due to the child calling exit or exec. Debuggers can use this stop to reinsert breakpoints in the vfork parent process before it resumes.
* MFC r302943,r302944,r303004,r303010,r303011,r303013,r303014,r303074,ache2016-08-172-203/+329
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r303088,r303142,r303208,r303210,r303530,r303536,r303564,r303565, r303706 In short: 1) All situations with glob(3) error return codes are well defined by POSIX, so rewrite old sporadic errors processing to match those definitions. Including subcases: Both C99 and POSIX directly prohibits any standard function to set errno to 0. Breaking this rule in 2001 NetBSD hack was imported which attempts to workaround very limited glob(3) return codes amount. Use POSIX-compatible workaround now with E2BIG which can't comes from other functions used instead of prohibited 0. Process errors happpens in (*readdirfunc)() too, as POSIX requires. Per POSIX GLOB_NOCHECK should return original pattern, unmodified, if no matches found. But our code strips all '\' returning it. Rewrite the code to allow to return original pattern. GLOB_ERR and gl_errfunc are supposed to work only for real directories per POSIX, so don't act on missing or plain files for ENOENT or ENOTDIR (as TODO in the code suggested). Remove the hack in the manpage describing how to skip ENOENT and ENOTDIR in gl_errfunc, it is unneeded now. Per POSIX GLOB_ERR must be considered even if gl_errfunc is not set, old code skips it in that case. 2) For near MAXPATHLEN long pathes old glob(3) code can operate on truncated results, prevent it in several places. 3) Results was not sorted according to collate as POSIX requires. 4) globtilde() forget to convert expanded user home dir from multibyte to wide chars. Moreover, those chars are addded as not protected, so can be treated as special chars. 5) Backward hack for EILSEQ in g_Ctoc() was not implemented, so all pathes with illegal byte sequences are skipped as result, implement it now. 6) GLOB_BRACE was somehow broken. First it repeatedly calls glob0() in globexp1() recursive calls, but glob0() was not supposed to be called repeatedly in the original code. It finalize results by possible adding original pattern for no match case, may return GLOB_NOMATCH error and by sorting all things. Original pattern adding or GLOB_NOMATCH error can happens each time glob0() called repeatedly, and sorting happens for one item only, all things are never sorted. Second, f.e. "a{a" pattern does not match "a{a" file but match "a" file instead. Third, some errors (f.e. for limits or overflow) can be ignored by GLOB_BRACE code because it forces return (0). Add non-finalizing flag to glob0() and make globexp0() wrapper around recursively called globexp1() to finalize things like glob0() does. Reorganize braces code to work correctly. 7) Don't allow MB_CUR_MAX * strlen overallocation hits GLOB_LIMIT_STRING (ARG_MAX) limit, use final string length, not malloced space for it.
* MFC r302824ache2016-08-176-24/+18
| | | | | | | | | | | | | 1) Eliminate possibility to call __*collate_range_cmp() with inclomplete locale (which cause core dump) by removing whole 'table' argument by which it passed. 2) Restore __collate_range_cmp() in __sccl(). 3) Collating [a-z] range in regcomp() work only for single bytes locales (we can't do it now for other ones). In previous code only first 256 wchars are considered and all others are just silently dropped from the range.
* MFC 302900,302902,302921,303461,304009:jhb2016-08-151-41/+178
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a mask of optional ptrace() events. 302900: Add a test for user signal delivery. This test verifies we get the correct ptrace event details when a signal is posted to a traced process from userland. 302902: Add a mask of optional ptrace() events. ptrace() now stores a mask of optional events in p_ptevents. Currently this mask is a single integer, but it can be expanded into an array of integers in the future. Two new ptrace requests can be used to manipulate the event mask: PT_GET_EVENT_MASK fetches the current event mask and PT_SET_EVENT_MASK sets the current event mask. The current set of events include: - PTRACE_EXEC: trace calls to execve(). - PTRACE_SCE: trace system call entries. - PTRACE_SCX: trace syscam call exits. - PTRACE_FORK: trace forks and auto-attach to new child processes. - PTRACE_LWP: trace LWP events. The S_PT_SCX and S_PT_SCE events in the procfs p_stops flags have been replaced by PTRACE_SCE and PTRACE_SCX. PTRACE_FORK replaces P_FOLLOW_FORK and PTRACE_LWP replaces P2_LWP_EVENTS. The PT_FOLLOW_FORK and PT_LWP_EVENTS ptrace requests remain for compatibility but now simply toggle corresponding flags in the event mask. While here, document that PT_SYSCALL, PT_TO_SCE, and PT_TO_SCX both modify the event mask and continue the traced process. 302921: Rename PTRACE_SYSCALL to LINUX_PTRACE_SYSCALL. 303461: Note that not all optional ptrace events use SIGTRAP. New child processes attached due to PTRACE_FORK use SIGSTOP instead of SIGTRAP. All other ptrace events use SIGTRAP. 304009: Remove description of P_FOLLOWFORK as this flag was removed.
* MFC r303687:bdrewery2016-08-081-0/+1
| | | | | | Add link for getnetgrent_r(3). Approved by: re (kib)
* MFC r303486:ed2016-08-052-7/+16
| | | | | | | | | | Mention that basename(3) and dirname(3) will change in the future. Update the existing manual pages for basename(3) and dirname(3) to mention that in future versions of FreeBSD, these functions will no longer use internal buffers for storing the results. Approved by: re@
* MFC r303104, r303106:brooks2016-08-031-2/+21
| | | | | | | | | | | | | | | | | | Update to reflect the fact that pipe() is a wrapper around the pipe2() system call. Reviewed by: jhb, wblock Sponsored by: DAPRA, AFRL Change wording to use function rather than system call in the description as well. Authored by: zeising Reviewed by: brooks Approved by: re (gjb) Sponsored by: DAPRA, AFRL
* MFC 303164: Add more documentation regarding unsafe AIO requests.jhb2016-07-284-20/+16
| | | | | | | | | | | | | | | | | | | | | The asynchronous I/O changes made previously result in different behavior out of the box. Previously all AIO requests failed with ENOSYS / SIGSYS unless aio.ko was explicitly loaded. Now, some AIO requests complete and others ("unsafe" requests) fail with EOPNOTSUPP. Reword the introductory paragraph in aio(4) to add a general description of AIO before describing the vfs.aio.enable_unsafe sysctl. Remove the ENOSYS error description from aio_fsync(2), aio_read(2), and aio_write(2) and replace it with a description of EOPNOTSUPP. Remove the ENOSYS error description from aio_mlock(2). Log a message to the system log the first time a process requests an "unsafe" AIO request that fails with EOPNOTSUPP. This is modeled on the log message used for processes using the legacy pty devices. Approved by: re (gjb)
* MFC r303046:pfg2016-07-261-12/+12
| | | | | | | | | | | | | | libc: tag the rune initialization function prototypes visibility as hidden. It is good practice to export as few symbols as possible from your shared libraries, so use the GCC visibility attribute in this case, matching what Apple's libc does. Reference: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html Hinted by: Apple's libc 1082.20.4 Approved by: re (gjb)
* MFC 302899: Add documentation for the sigevent structure.jhb2016-07-257-22/+175
| | | | | | | | | | | | - Add a sigevent(3) manpage to give a general overview of the sigevent structure and the available notification mechanisms. - Document that AIO requests contain a nested sigevent structure that can be used to request completion notification. - Expand the sigevent details in other manuals to note details such as the extra values stored in a queued signal's information or in a posted kevent. Approved by: re (gjb)
* MFC: r302916bapt2016-07-201-1/+5
| | | | | | | | | Revert 302324 and properly fix the crash with ISO-8859-5 locales PR: 211135 Reported by: jkim Tested by: jkim Approved by: re (gjb)
* fcntl(2): Document interrupt/restart for file locks.jilles2016-07-071-1/+22
| | | | | | | | | | | | | Since r302216, thread suspension causes advisory file locks to restart (instead of continuing to wait) and for a long time SA_RESTART has affected advisory file locks. These are both not compliant to POSIX.1. To clarify that restarting means something, add a paragraph about fair queuing. Note that the network lock manager does not implement fair queuing. Reviewed by: kib (previous version) Approved by: re (gjb)
* Fix a bad test resulting in a segfault with ISO-8859-5 localesbapt2016-07-031-1/+1
| | | | | Reported by: Lauri Tirkkonen from Illumos Approved by: re@ (gjb)
* Use on crypto.x and rpc.x from the source tree.bdrewery2016-06-282-2/+2
| | | | | | | | | This fixes the build when DESTDIR may be blank or not yet populated. It also fixes reproducibility. Submitted by: brooks Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D6455
* This commit addresses regression introduceded in r302177cy2016-06-281-0/+14
| | | | | | | | (WITH_SYSTEM_COMPILER: Enable by default) and it's prerequisite: r300354, caused i386 builds to fail when cross-built on an amd64 host. Reviewed by: bdrewery, delphij, gjb Approved by: re (gjb)
* Replace use of the pipe(2) system call with pipe2(2) with a zero flagsbrooks2016-06-2220-457/+29
| | | | | | | | | | | | | | | | value. This eliminates the need for machine dependant assembly wrappers for pipe(2). It also make passing an invalid address to pipe(2) return EFAULT rather than triggering a segfault. Document this behavior (which was already true for pipe2(2), but undocumented). Reviewed by: andrew Approved by: re (gjb) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D6815
* Fix regression from r301461.pfg2016-06-101-3/+3
| | | | | | | | | | | | The fix to the __collate_range_cmp() ABI breakage missed some replacements in libc's vfscanf(). Replace them with __wcollate_range_cmp() which does what is expected. This was breaking applications like xterm and pidgin when using wide characters. Reported by: Vitalij Satanivskij Approved by: re
* libc/rpc: Make use of some xdr_* macros. (part 2)pfg2016-06-093-19/+19
| | | | | | xdr_rpcproc, xdr_rpcprog and xdr_rpcvers were broken in older versions of FreeBSD but fixed in r296394. Give them some use hoping they help make the code somewhat more readable.
* utimes(2),utime(3): Add deprecation in favour of utimensat(2) and futimens(2).jilles2016-06-092-4/+19
| | | | | | | Setting time by seconds or microseconds may cause unexpected effects especially if sysctl vfs.timestamp_precision=3 (not default). Calling the obsolete functions with NULL timestamps is acceptable.
* libc/rpc: Make use of some xdr_* macros.pfg2016-06-092-7/+7
| | | | | | xdr_rpcprog and xdr_rpcvers were broken in older versions of FreeBSD but were fixed in r296394. Give them some use hoping they help make the code somewhat more readable.
* Fix the rpcb_getaddr() definition to match its declaration.kevlo2016-06-091-1/+1
| | | | Submitted by: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
* Implement an NSS backend for netgroups and add getnetgrent_r(3).markj2016-06-093-115/+470
| | | | | | | | | | | | | | | | | | This support appears to have been documented in nsswitch.conf(5) for some time. The implementation adds two NSS netgroup providers to libc. The default, compat, provides the behaviour documented in netgroup(5), so this change does not make any user-visible behaviour changes. A files provider is also implemented. innetgr(3) is implemented as an optional NSS method so that providers such as NIS which are able to implement efficient reverse lookup can do so. A fallback implementation is used otherwise. getnetgrent_r(3) is added for convenience and to provide compatibility with glibc and Solaris. With a small patch to net/nss_ldap, it's possible to specify an ldap netgroup provider, allowing one to query nisNetgroupTriple entries. Sponsored by: EMC / Isilon Storage Division
* Fix an infinite loop in setnetgrent(3) with NIS netgroups.markj2016-06-091-0/+4
| | | | | | | | | | Handle an empty result from yp_match() by returning NULL, which is consistent with the handling of an empty netgroup in /etc/netgroup. setnetgrent(3) has no return value, so there is no particular need to distinguish this case from an error. PR: 26486 MFC after: 2 weeks
* Use a more common spelling for "(char *)0" in the getnetgrent man page.markj2016-06-091-2/+2
| | | | MFC after: 3 days
* Revert r301707ngie2016-06-081-2/+2
| | | | | | | | | getnetent_p doesn't return NULL like getnetent does. coccinelle got confused and I didn't verify that it worked before committing the change MFC after: 1 week X-MFC with: r301707 Pointyhat to: ngie
* Use NULL instead of `0` in _ht_getnetbyname(..)ngie2016-06-081-2/+2
| | | | | | | | - getnetent returns NULL on completion/error. - .h_aliases is NULL terminated. MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
* Test for strchr(3) returning NULL, not 0ngie2016-06-081-1/+1
| | | | | | MFC after: 3 days Reported by: coccinelle Sponsored by: EMC / Isilon Storage Division
* Update to a June 8th snapshot of (un)vis form NetBSD.brooks2016-06-081-0/+1
| | | | | | | | | | This adds stravis() and some new encoding flags VIS_SHELL, VIS_META, and VIS_NOLOCALE. Assorted cleanups and fixes includeing a manpage typo[0]. PR: 210013 [0] Submitted by: pi [0]
* Don't leak olinep if malloc() fails.truckman2016-06-081-0/+2
| | | | | | | | | | | If malloc() fails to allocate linep, then free olinep (if it exists) before returning to avoid a memory leak. Reported by: Coverity CID: 1016716 Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6755
* Don't leak addrinfo if ai->ai_addrlen <= minsiz test fails.truckman2016-06-081-12/+13
| | | | | | | | | | | | | | If the ai->ai_addrlen <= minsiz test fails, then freeaddrinfo() does not get called to free the memory just allocated by getaddrinfo(). Fix by moving ai->ai_addrlen <= minsiz to a separate nested if block, and keep freeaddrinfo() in the outer block so that freeaddrinfo() will be called whenever getaddrinfo() succeeds. Reported by: Coverity CID: 1273652 Reviewed by: ume MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D6756
* Introduce the PD_CLOEXEC for pdfork(2).oshogbo2016-06-081-1/+5
| | | | Reviewed by: mjg
* libc/locale: Fix type breakage in __collate_range_cmp().pfg2016-06-055-11/+25
| | | | | | | | | | | | | | | | When collation support was brought in, the second and third arguments in __collate_range_cmp() were changed from int to wchar_t, breaking the ABI. Change them to a "char" type which makes more sense and keeps the ABI compatible. Also introduce __wcollate_range_cmp() which does work with wide characters. This function is used only internally in libc so we don't export it. Use the new function in glob(3), fnmatch(3), and regexec(3). PR: 179721 Suggested by: ache. jilles MFC after: 3 weeks (perhaps partial only)
* Reflect error indication according to POSIX and what those functionsache2016-06-051-2/+2
| | | | currently do.
* Fix markup.kib2016-06-041-1/+1
| | | | Sponsored by: The FreeBSD Foundation
* Improve errno documentation in pthread_create(3) and thr_new(2)vangyzen2016-06-032-4/+11
| | | | | | | | | | Add some missing errno values to thr_new(2) and pthread_create(3). In particular, EDEADLK was not documented in the latter. While I'm here, improve some English and cross-references. Reviewed by: kib Sponsored by: Dell Inc. Differential Revision: https://reviews.freebsd.org/D6663
* citrus: Remove redundant code in _citrus_esdb_get_list().pfg2016-06-021-12/+6
| | | | | | | | It appears "sorted" may have not been implemented. Sorted or not, we always follow the same action so simplify the code. Leave a note for future generations. CID: 1347084
* thr_*(2): Add xrefs to what libthr implements using each syscall.jilles2016-06-015-8/+29
| | | | | | | | | | | Add text to thr_exit(2) and thr_new(2) discouraging their use in applications since calling these in a process with libthr loaded will confuse libthr and is likely to cause hangs or crashes. The thr_kill2(2) call is not used by libthr and may be useful in special applications. The other calls can be used in applications but it should not be necessary.
* Document behavior of wait introduced in the r286698.oshogbo2016-06-011-1/+9
| | | | | | Suggested by: glebius Reviewed by: wblock, bjk Differential Revision: https://reviews.freebsd.org/D6080
* Don't use fixup for C99 and up, the compiler result is already correct.ache2016-06-014-0/+8
| | | | | | Suggested by: bde MFC after: 1 week
* For EILSEQ case in mbsnrtowcs() and wcsnrtombs() update src to point toache2016-05-312-0/+3
| | | | | | | | the character after the one this conversion stopped at. PR: 209907 Submitted by: Roel Standaert <roel@abittechnical.com> (partially) MFC after: 3 days
* Fix prototype of dbm_open().ed2016-05-312-2/+2
| | | | | | | | The last argument of dbm_open() should be a mode_t according to POSIX; not an int. Reviewed by: pfg, kib Differential Revision: https://reviews.freebsd.org/D6650
* Let dbm's datum::dptr use the right type.ed2016-05-301-2/+2
| | | | | | | | | According to POSIX, it should use void *, not char *. Unfortunately, the dsize field also has the wrong type. It should be size_t. I'm not going to change that, as that will break the ABI. Reviewed by: pfg Differential Revision: https://reviews.freebsd.org/D6647
* Fix the signature of the psignal() function.ed2016-05-302-4/+4
| | | | | | | | POSIX 2008 added the psignal() function which has already been part of the BSDs for a long time. The only difference is, the POSIX version uses an 'int' for the signal number, unlike our version which uses an 'unsigned int'. Fix up the function to use an 'int'. This should not affect the ABI.
* Mark jail(2), and the sysctls that it (and only it) uses as deprecated.jamie2016-05-301-1/+1
| | | | jail(8) has long used jail_set(2), and those sysctl only cause confusion.
* Micro optimize: C standard guarantees that right shift for unsigned valueache2016-05-291-1/+1
| | | | | | | fills left bits with zero, and we have exact 32bit unsigned value (uint32_t), so there is no reason to add "& 0x7fffffff" here. MFC after: 1 week
OpenPOWER on IntegriCloud