summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen
Commit message (Collapse)AuthorAgeFilesLines
* Use umtx to implement process sharable semaphore, to make this work,davidxu2010-01-055-79/+680
| | | | | | | | | | | | | | | | | | | | | | now type sema_t is a structure which can be put in a shared memory area, and multiple processes can operate it concurrently. User can either use mmap(MAP_SHARED) + sem_init(pshared=1) or use sem_open() to initialize a shared semaphore. Named semaphore uses file system and is located in /tmp directory, and its file name is prefixed with 'SEMD', so now it is chroot or jail friendly. In simplist cases, both for named and un-named semaphore, userland code does not have to enter kernel to reduce/increase semaphore's count. The semaphore is designed to be crash-safe, it means even if an application is crashed in the middle of operating semaphore, the semaphore state is still safely recovered by later use, there is no waiter counter maintained by userland code. The main semaphore code is in libc and libthr only has some necessary stubs, this makes it possible that a non-threaded application can use semaphore without linking to thread library. Old semaphore implementation is kept libc to maintain binary compatibility. The kernel ksem API is no longer used in the new implemenation. Discussed on: threads@
* Modernize scandir(3) and alphasort(3) interfaces according to the IEEEkib2010-01-043-18/+15
| | | | | | | | | | | | | | | | | | | | Std 1003.1-2008. Both Linux and Solaris conforms to the new definitions, so we better follow too (older glibc used old BSDish alphasort prototype and corresponding type of the comparision function for scandir). While there, change the definitions of the functions to ANSI C and fix several style issues nearby. Remove requirement for "sys/types.h" include for functions from manpage. POSIX also requires that alphasort(3) sorts as if strcoll(3) was used, but leave the strcmp(3) call in the function for now. Adapt in-tree callers of scandir(3) to new declaration. The fact that select_sections() from catman(1) could modify supplied struct dirent is a bug. PR: standards/142255 MFC after: 2 weeks
* Document CLOCK_SECOND, add cross-reference from time(3) to clock_gettime(2).kib2009-12-291-0/+1
| | | | | Based on submission by: pluknet gmail com MFC after: 3 days
* Use clock_gettime(CLOCK_SECOND) instead of gettimeofday(2) forkib2009-12-291-4/+3
| | | | | | | | implementation of time(3). CLOCK_SECOND is much faster. No objections from: phk Submitted by: Valentin Nechayev <netch segfault kiev ua> MFC after: 1 week
* (S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.antoine2009-12-281-1/+1
| | | | | | | | | Fix some wrong usages. Note: this does not affect generated binaries as this argument is not used. PR: 137213 Submitted by: Eygene Ryabinkin (initial version) MFC after: 1 month
* sem_init(3): document process shared semaphores and their restrictionsjilles2009-12-081-18/+9
|
* Fix many "function declaration isn't a prototype" warnings in libc.ed2009-12-057-32/+18
| | | | | I've only fixed code that seems to be written by `us'. There are still many warnings like this present in resolv/, rpc/, stdtime/ and yp/.
* Don't let the C library depend on <utmp.h>.ed2009-12-052-10/+9
| | | | | | The maximum length of a username has nothing to do with the size of the username in the utmp files. Use MAXLOGNAME, which is defined as 17 (UT_USERSIZE + 1).
* Remove warnings from exec.c.ed2009-12-051-20/+19
| | | | | | | | The entries in the argv array are not const themselves, but sometimes we want to fill in const values. Just make the array const and use __DECONST() to make it const for the execve()-call itself. Also convert the only K&R prototype to ANSI.
* Use ANSI C prototypes inside termios.ed2009-12-051-31/+13
| | | | While there, add a missing __unused to hide a warning in tcsetbreak().
* Remove (hidden) warning about missing prototypes for fdevname(3).ed2009-12-051-0/+1
|
* Properly use the envp argument in execvPe().ed2009-11-271-2/+2
| | | | | | | | | | | | | | | execvPe() is called by _execvpe(), which we added to implement posix_spawnp(). We just took execvP() and added the envp argument. Unfortunately we forgot to change the implementation to use envp over environ. This fixes the following piece of code: | char * const arg[2] = { "env", NULL }; | char * const env[2] = { "FOO=BAR", NULL }; | posix_spawnp(NULL, "/usr/bin/env", NULL, NULL, arg, env); MFC after: 2 weeks
* Reset path name back to original correctly in fts_build() whenjh2009-11-261-5/+2
| | | | | | | | | | | FTS_NOCHDIR option is used. fts_build() could strip a trailing slash from path name in post-order visit if a path pointing to an empty directory was given for fts_open(). PR: bin/133907, kern/134513 Reviewed by: das Approved by: trasz (mentor) MFC after: 1 month
* Clarify that the value of the fts_info field is different in post-order.jh2009-11-261-4/+3
| | | | | | Discussed with: das Approved by: trasz (mentor) MFC after: 1 week
* Eliminate more dead stores.wollman2009-11-253-5/+4
| | | | | Found by: Clang static analyzer MFC after: 7 days
* Revert the previous change to pthread_once() stub in libc. It is actuallyjhb2009-11-202-6/+3
| | | | | | | | a feature that libstdc++ depends on to simulate the behavior of libc's internal '__isthreaded' variable. One benefit of this is that _libc_once() is now private to _once_stub.c. Requested by: kan
* Add an internal _once() method. This works identical to pthread_once(3)jhb2009-11-203-2/+70
| | | | | | | | | | | | | with the additional property that it is safe for routines in libc to use in both single-threaded and multi-threaded processes. Multi-threaded processes use the pthread_once() implementation from the threading library while single-threaded processes use a simplified "stub" version internal to libc. The libc stub-version of pthread_once() now also uses the simplified "stub" version as well instead of being a nop. Reviewed by: deischen, Matthew Fleming @ Isilon Suggested by: alc MFC after: 1 week
* Catch up with r130332 which changed the default timezone from GMT to UTC.obrien2009-11-171-2/+2
| | | | | Otherwise the tzload() (when called by gmtload()) fails to locate the UTC file and loads the posixrules.
* Fix a copy+paste error by checking the correct variable against MM_NULLACT.brueffer2009-11-081-1/+1
| | | | | | PR: 140386 Submitted by: soulcatcher <soulcatcher13@gmail.com MFC after: 1 week
* Use our canonical .Dd format.brueffer2009-11-0210-10/+10
| | | | Submitted by: Ulrich Spoerlein
* Move pselect(3) man page to section 2.kib2009-10-282-123/+1
| | | | | Noted by: jhb MFC after: 1 month
* Commit libc files missed in r198508kib2009-10-273-8/+1
|
* Current pselect(3) is implemented in usermode and thus vulnerable tokib2009-10-271-78/+0
| | | | | | | | | | | | | | | | | well-known race condition, which elimination was the reason for the function appearance in first place. If sigmask supplied as argument to pselect() enables a signal, the signal might be delivered before thread called select(2), causing lost wakeup. Reimplement pselect() in kernel, making change of sigmask and sleep atomic. Since signal shall be delivered to the usermode, but sigmask restored, set TDP_OLDMASK and save old mask in td_oldsigmask. The TDP_OLDMASK should be cleared by ast() in case signal was not gelivered during syscall execution. Reviewed by: davidxu Tested by: pho MFC after: 1 month
* wordexp(3): fix some bugs with signals and long outputsjilles2009-10-231-19/+57
| | | | | | | | | | | | * retry various system calls on EINTR * retry the rest after a short read (common if there is more than about 1K of output) * block SIGCHLD like system(3) does (note that this does not and cannot work fully in threaded programs, they will need to be careful with wait functions) PR: 90580 MFC after: 1 month
* Make getcwd(3) faster, simpler and more compliant using *at syscalls.jilles2009-10-131-45/+18
| | | | | It is no longer necessary to construct long paths consisting of repeated "../" which may be slow to process and may exceed PATH_MAX.
* Add a new errno, ENOTCAPABLE, to be returned when a process requests anrwatson2009-10-071-0/+1
| | | | | | | | operation on a file descriptor that is not authorized by the descriptor's capability flags. MFC after: 1 month Sponsored by: Google
* Add basename_r(3) to complement basename(3). basename_r(3) which acceptsrwatson2009-10-064-13/+33
| | | | | | | | a caller-allocated buffer of at least MAXPATHLEN, rather than using a global buffer. MFC after: 1 month Sponsored by: Google
* fts_open() requires that the list passed as argument to contain at leastdelphij2009-10-052-2/+8
| | | | | | | | | one path. When the list is empty (contain only a NULL pointer), return EINVAL instead of pretending to succeed, which will cause a NULL pointer deference in a later fts_read() call. Noticed by: Christoph Mallon (via rdivacky@) MFC after: 2 weeks
* Correct the pthread stub prototype for pthread_mutexattr_settype to allow formarcus2009-10-011-1/+1
| | | | | | | | | the type argument. This is known to fix some pthread_mutexattr_settype() invocations, especially when it comes to pulseaudio. Approved by: kib deischen (threads) MFC after: 3 days
* Correct a section name; specifically, "AUTHOR" should be "AUTHORS". [1]alc2009-09-211-3/+4
| | | | | | Turn the "AUTHORS" section into a full sentence. Pointed out by: ru [1]
* Add getpagesizes(3). This functions either the number of supported pagealc2009-09-194-3/+183
| | | | | | | sizes or some number of the sizes themselves. It is functionally compatible with a function by the same name under Solaris. Reviewed by: jhb
* It is believed the last subsystem that limited ID sizes to somethingkensmith2009-07-221-7/+18
| | | | | | | | | | other than the current system-wide size (32-bits) has been updated so for now just cautiously turn the check off. While here fix the check for IDs being too large which doesn't work due to type mis-matches. Reviewed by: jhb (previous version) Approved by: re (kib) MFC after: 1 month (type mis-match fixes only)
* Implement RTLD_NOLOAD flag for dlopen(3).kib2009-07-171-1/+8
| | | | | | Requested and tested by: jkim Reviewed by: kan Approved by: re (kensmith)
* Move msg{snd,recv,get,ctl} manual pages from section 3 to 2.trasz2009-07-136-761/+4
| | | | Approved by: re (kib)
* Make the structure definitions in the man pages match the real code, andkib2009-06-291-9/+5
| | | | | | remove no longer valid caution. Approved by: re (kensmith)
* Change the ABI of some of the structures used by the SYSV IPC API:jhb2009-06-242-3/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The uid/cuid members of struct ipc_perm are now uid_t instead of unsigned short. - The gid/cgid members of struct ipc_perm are now gid_t instead of unsigned short. - The mode member of struct ipc_perm is now mode_t instead of unsigned short (this is merely a style bug). - The rather dubious padding fields for ABI compat with SV/I386 have been removed from struct msqid_ds and struct semid_ds. - The shm_segsz member of struct shmid_ds is now a size_t instead of an int. This removes the need for the shm_bsegsz member in struct shmid_kernel and should allow for complete support of SYSV SHM regions >= 2GB. - The shm_nattch member of struct shmid_ds is now an int instead of a short. - The shm_internal member of struct shmid_ds is now gone. The internal VM object pointer for SHM regions has been moved into struct shmid_kernel. - The existing __semctl(), msgctl(), and shmctl() system call entries are now marked COMPAT7 and new versions of those system calls which support the new ABI are now present. - The new system calls are assigned to the FBSD-1.1 version in libc. The FBSD-1.0 symbols in libc now refer to the old COMPAT7 system calls. - A simplistic framework for tagging system calls with compatibility symbol versions has been added to libc. Version tags are added to system calls by adding an appropriate __sym_compat() entry to src/lib/libc/incldue/compat.h. [1] PR: kern/16195 kern/113218 bin/129855 Reviewed by: arch@, rwatson Discussed with: kan, kib [1]
* Use const instead of __const, and merge the license change from NetBSD.delphij2009-06-231-9/+3
| | | | Obtained from: NetBSD
* In preparation for raising NGROUPS and NGROUPS_MAX, change basebrooks2009-06-192-6/+22
| | | | | | | | | | | | | | | | | | | | | | system callers of getgroups(), getgrouplist(), and setgroups() to allocate buffers dynamically. Specifically, allocate a buffer of size sysconf(_SC_NGROUPS_MAX)+1 (+2 in a few cases to allow for overflow). This (or similar gymnastics) is required for the code to actually follow the POSIX.1-2008 specification where {NGROUPS_MAX} may differ at runtime and where getgroups may return {NGROUPS_MAX}+1 results on systems like FreeBSD which include the primary group. In id(1), don't pointlessly add the primary group to the list of all groups, it is always the first result from getgroups(). In principle the old code was more portable, but this was only done in one of the two places where getgroups() was called to the overall effect was pointless. Document the actual POSIX requirements in the getgroups(2) and setgroups(2) manpages. We do not yet support a dynamic NGROUPS, but we may in the future. MFC after: 2 weeks
* Rename the queue macros I introduced last year.ed2009-05-271-1/+1
| | | | | | | | | | | | | | | | Last year I added SLIST_REMOVE_NEXT and STAILQ_REMOVE_NEXT, to remove entries behind an element in the list, using O(1) time. I recently discovered NetBSD also has a similar macro, called SLIST_REMOVE_AFTER. In my opinion this approach is a lot better: - It doesn't have the unused first argument of the list pointer. I added this, mainly because OpenBSD also had it. - The _AFTER suffix makes a lot more sense, because it is related to SLIST_INSERT_AFTER. _NEXT is only used to iterate through the list. The reason why I want to rename this now, is to make sure we don't release a major version with the badly named macros.
* As the comment says, close() frees the variable, record. So we obtaindelphij2009-05-141-1/+1
| | | | | | | | the length by evaluating the value from the copy, cbuf instead. This fixes a crash caused by previous commit (use-after-free) Submitted by: Dimitry Andric <dimitry andric com> Pointy hat to: delphij
* TTYs don't necessarily use /dev/ttyxx.ed2009-05-091-3/+2
| | | | Submitted by: csjp
* Add tcsetsid(3).ed2009-05-075-3/+109
| | | | | | | | | | | The entire world seems to use the non-standard TIOCSCTTY ioctl to make a TTY a controlling terminal of a session. Even though tcsetsid(3) is also non-standard, I think it's a lot better to use in our own source code, mainly because it's similar to tcsetpgrp(), tcgetpgrp() and tcgetsid(). I stole the idea from QNX. They do it the other way around; their TIOCSCTTY is just a wrapper around tcsetsid(). tcsetsid() then calls into an IPC framework.
* Fix whitespace and sorting in Symbol.map.ed2009-05-041-25/+25
|
* Allow the NULL, RTLD_SELF and RTLD_NEXT handles to work with dlfunc(3).kib2009-04-033-31/+9
| | | | | | | | | | | | | | | | dlfunc() called dlsym() to do the work, and dlsym() determines the dso that originating the call by the return address. Due to this, dlfunc() operated as if the caller is always the libc. To fix this, move the dlfunc() to rtld, where it can call the internal implementation of dlsym, and still correctly fetch return address. Provide usual weak stub for the symbol from libc for static binaries. dlfunc is put to FBSD_1.0 symver namespace in the ld.so export to override dlfunc@FBSD_1.0 weak symbol, exported by libc. Reported, analyzed and tested by: Tijl Coosemans <tijl ulyssis org> PR: standards/133339 Reviewed by: kan
* Properly handle malloc() failures.delphij2009-04-021-5/+7
| | | | PR: bin/83338
* Properly update the shm_open/shm_unlink symbol versioning metadata afterjhb2009-04-021-2/+0
| | | | | | | these functions were moved into the kernel: - Move the version entries from gen/ to sys/. Since the ABI of the actual routines did not change, I'm still exporting them as FBSD 1.0 on purpose. - Add FBSD-private versions for the _ and __sys_ variants.
* Document RTLD_NODELETE, -z nodelete and -z origin support.kib2009-04-011-2/+9
|
* Fix a file descriptor leak in fts_child().das2009-03-041-1/+3
| | | | Obtained from: NetBSD
* Sync license changes.delphij2009-03-042-20/+3
| | | | Obtained from: NetBSD
* Properly invalidate highest pts number when calling setttyent().ed2009-02-121-5/+4
| | | | | | | | | When calling setttyent() after calling endttyent(), pts_valid will never be set to 1, because the readdir()-loop will likely never vind a pts that has a higher number than before. Simplify the code by removing pts_valid. We'll just set maxpts to -1 when we don't have a valid count yet.
OpenPOWER on IntegriCloud