about summary refs log tree commit diff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* clean up handling of thread/nothread mode, lockingRich Felker2011-04-178-27/+16
|
* debloat: use __syscall instead of syscall where possibleRich Felker2011-04-177-8/+8
| | | | | | don't waste time (and significant code size due to function call overhead!) setting errno when the result of a syscall does not matter or when it can't fail.
* fix bugs in cancellable syscall asmRich Felker2011-04-173-11/+12
| | | | | | | | | | | | | | | | x86_64 was just plain wrong in the cancel-flag-already-set path, and crashing. the more subtle error was not clearing the saved stack pointer before returning to c code. this could result in the signal handler misidentifying c code as the pre-syscall part of the asm, and acting on cancellation at the wrong time, and thus resource leak race conditions. also, now __cancel (in the c code) is responsible for clearing the saved sp in the already-cancelled branch. this means we have to use call rather than jmp to ensure the stack pointer in the c will never match what the asm saved.
* optimize cancellation enable/disable codeRich Felker2011-04-174-4/+11
| | | | | | | | | | | | | | | | | | the goal is to be able to use pthread_setcancelstate internally in the implementation, whenever a function might want to use functions which are cancellation points but avoid becoming a cancellation point itself. i could have just used a separate internal function for temporarily inhibiting cancellation, but the solution in this commit is better because (1) it's one less implementation-specific detail in functions that need to use it, and (2) application code can also get the same benefit. previously, pthread_setcancelstate dependend on pthread_self, which would pull in unwanted thread setup overhead for non-threaded programs. now, it temporarily stores the state in the global libc struct if threads have not been initialized, and later moves it if needed. this way we can instead use __pthread_self, which has no dependencies and assumes that the thread register is already valid.
* don't use pthread_once when there is no danger in raceRich Felker2011-04-171-2/+5
|
* fix some minor issues in cancellation handling patchRich Felker2011-04-173-11/+19
| | | | | signals were wrongly left masked, and cancellability state was not switched to disabled, during the execution of cleanup handlers.
* overhaul pthread cancellationRich Felker2011-04-1745-218/+235
| | | | | | | | | | | | | | | | | | | | | | this patch improves the correctness, simplicity, and size of cancellation-related code. modulo any small errors, it should now be completely conformant, safe, and resource-leak free. the notion of entering and exiting cancellation-point context has been completely eliminated and replaced with alternative syscall assembly code for cancellable syscalls. the assembly is responsible for setting up execution context information (stack pointer and address of the syscall instruction) which the cancellation signal handler can use to determine whether the interrupted code was in a cancellable state. these changes eliminate race conditions in the previous generation of cancellation handling code (whereby a cancellation request received just prior to the syscall would not be processed, leaving the syscall to block, potentially indefinitely), and remedy an issue where non-cancellable syscalls made from signal handlers became cancellable if the signal handler interrupted a cancellation point. x86_64 asm is untested and may need a second try to get it right.
* remove stupid debug code in wordexpRich Felker2011-04-151-1/+0
|
* implement wordexp. first try, may be buggy. intended to be safe.Rich Felker2011-04-151-0/+128
|
* avoid setting errno when checking for ttyRich Felker2011-04-152-2/+2
| | | | | | | setting errno here is completely valid, but some programs, notably busybox printf, assume that errno will not be set during output and treat this as an error condition. in any case, skipping it slightly reduces code size and saves time.
* make tmpfile slightly more efficient (use unlink syscall instead of remove)Rich Felker2011-04-141-1/+1
|
* change sem_trywait algorithm so it never has to call __wakeRich Felker2011-04-141-3/+2
|
* cheap trick to further optimize locking normal mutexesRich Felker2011-04-142-2/+2
|
* use a separate signal from SIGCANCEL for SIGEV_THREAD timersRich Felker2011-04-146-11/+29
| | | | | | otherwise we cannot support an application's desire to use asynchronous cancellation within the callback function. this change also slightly debloats pthread_create.c.
* simplify cancellation point handlingRich Felker2011-04-132-16/+5
| | | | | | we take advantage of the fact that unless self->cancelpt is 1, cancellation cannot happen. so just increment it by 2 to temporarily block cancellation. this drops pthread_create.o well under 1k.
* simplify syslog, add vsyslog interface (nonstandard)Rich Felker2011-04-131-31/+36
| | | | | | | | with datagram sockets, depending on fprintf not to flush the output early was very fragile; the new version simply uses a small fixed-size buffer. it could be updated to dynamic-allocate large buffers if needed, but i can't envision any admin being happy about finding 64kb-long lines in their syslog...
* remove useless SIGPIPE protection from syslogRich Felker2011-04-131-9/+0
| | | | per the standard, SIGPIPE is not generated for SOCK_DGRAM.
* fix syslog (corrected SIGPIPE blocking, and using dgram instead of stream)Rich Felker2011-04-131-10/+8
| | | | | | it actually appears the hacks to block SIGPIPE are probably not necessary, and potentially harmful. if i can confirm this, i'll remove them.
* numerous fixes to sysv ipcRich Felker2011-04-133-5/+5
| | | | | | | | | | some of these definitions were just plain wrong, others based on outdated ancient "non-64" versions of the kernel interface. as much as possible has now been moved out of bits/* these changes break abi (the old abi for these functions was wrong), but since they were not working anyway it can hardly matter.
* add syscall wrapper for flockRich Felker2011-04-131-0/+7
| | | | | | | | it should be noted that flock does not mix well with standard fcntl locking, but nonetheless some applications will attempt to use flock instead of fcntl if both exist. options to configure or small patches may be needed. debian maintainers have plenty of experience with this unfortunate situation...
* fix bug whereby getopt_long allowed mismatch in last char of option nameRich Felker2011-04-131-1/+1
|
* implement getgrouplist (for initgroups), formerly dummied-out v0.7.8Rich Felker2011-04-131-4/+16
|
* fix prototypes/signature for setgroups, etc.Rich Felker2011-04-131-1/+1
|
* implement memrchr (nonstandard) and optimize strrchr in terms of itRich Felker2011-04-132-4/+15
|
* add ptsname_r (nonstandard) and split ptsname (standard) to separate fileRich Felker2011-04-132-11/+16
| | | | this eliminates the ugly static buffer in programs that use ptsname_r.
* speed up threaded forkRich Felker2011-04-121-2/+1
| | | | | | after fork, we have a new process and the pid is equal to the tid of the new main thread. there is no need to make two separate syscalls to obtain the same number.
* optimize ntohl etc. in terms of bswap functionsRich Felker2011-04-124-20/+12
| | | | | | | we can do this without violating the namespace now that they are macros/inline functions rather than extern functions. the motivation is that gcc was generating giant, slow, horrible code for the old functions, and now generates a single byte-swapping instruction.
* move bswap functions to static inline in byteswap.hRich Felker2011-04-122-16/+0
|
* fix broken bswap_32Rich Felker2011-04-121-1/+1
|
* fix printf("%.9g", 1.1) and similar not dropping trailing zerosRich Felker2011-04-121-1/+3
|
* fix errno handling in scandir:Rich Felker2011-04-111-2/+1
| | | | | | 1. saved errno was not being restored, illegally clearing errno to 0. 2. no need to backup and save errno around free; it will not touch except perhaps when the program has already invoked UB...
* fix fputwc return valueRich Felker2011-04-111-1/+1
|
* remove ugly warning-suppression hack from crypt - this invokes UB!Rich Felker2011-04-111-1/+1
|
* run pthread tsd destructors when a timer thread pretends to exitRich Felker2011-04-091-0/+6
|
* greatly improve SIGEV_THREAD timersRich Felker2011-04-093-15/+21
| | | | | calling pthread_exit from, or pthread_cancel on, the timer callback thread will no longer destroy the timer.
* work around a nasty bug in linux readv syscallRich Felker2011-04-091-3/+4
| | | | | | | | | | | | | | | | according to posix, readv "shall be equivalent to read(), except..." that it places the data into the buffers specified by the iov array. however on linux, when reading from a terminal, each iov element behaves almost like a separate read. this means that if the first iov exactly satisfied the request (e.g. a length-one read of '\n') and the second iov is nonzero length, the syscall will block again after getting the blank line from the terminal until another line is read. simply put, entering a single blank line becomes impossible. the solution, fortunately, is simple. whenever the buffer size is nonzero, reduce the length of the requested read by one byte and let the last byte go through the buffer. this way, readv will already be in the second (and last) iov, and won't re-block on the second iov.
* better fix sysconf pthread stack minRich Felker2011-04-081-1/+1
|
* consistency with pthread stack min in limits.hRich Felker2011-04-081-1/+1
|
* fix broken sigsetjmp on x86_64Rich Felker2011-04-081-7/+9
|
* workaround broken msghdr struct on 64bit linuxRich Felker2011-04-082-0/+21
| | | | | | | | | | | POSIX clearly specifies the type of msg_iovlen and msg_controllen, and Linux ignores it and makes them both size_t instead. to work around this we add padding (instead of just using the wrong types like glibc does), but we also need to patch-up the struct before passing it to the kernel in case the caller did not zero-fill it. if i could trust the kernel to just ignore the upper 32 bits, this would not be necessary, but i don't think it will ignore them...
* fix ipv6 address printing: 2001 appeared as 201, etc.Rich Felker2011-04-081-3/+5
|
* fix broken dns response parsing code that made most ipv6 lookups failRich Felker2011-04-081-4/+6
|
* return the requested string as the "canonical name" for numeric addressesRich Felker2011-04-081-0/+1
| | | | | | | | previously NULL was returned in ai_canonname, resulting in crashes in some callers. this behavior was incorrect. note however that the new behavior differs from glibc, which performs reverse dns lookups. POSIX is very clear that a reverse DNS lookup must not be performed for numeric addresses.
* fix uninitialized variables in dns lookup codeRich Felker2011-04-071-2/+2
|
* fix bug in TRE found by clang (typo && instead of &)Rich Felker2011-04-071-1/+1
|
* fix misplaced *'s in string functions (harmless)Rich Felker2011-04-073-3/+3
|
* fix broken unsigned comparison in wcstoumaxRich Felker2011-04-071-1/+1
|
* fix breakage due to converting a return type to size_t in iconv...Rich Felker2011-04-071-1/+1
|
* fixed crash in new rsyscall (failure to set sa_flags for signal handler)Rich Felker2011-04-061-0/+2
|
* consistency: change all remaining syscalls to use SYS_ rather than __NR_ prefixRich Felker2011-04-0638-40/+40
|