aboutsummaryrefslogtreecommitdiff
path: root/src/internal (follow)
Commit message (Expand)AuthorAgeFilesLines
* overhaul cancellation to fix resource leaks and dangerous behavior with signals•••this commit addresses two issues: 1. a race condition, whereby a cancellation request occurring after a syscall returned from kernelspace but before the subsequent CANCELPT_END would cause cancellable resource-allocating syscalls (like open) to leak resources. 2. signal handlers invoked while the thread was blocked at a cancellation point behaved as if asynchronous cancellation mode wer in effect, resulting in potentially dangerous state corruption if a cancellation request occurs. the glibc/nptl implementation of threads shares both of these issues. with this commit, both are fixed. however, cancellation points encountered in a signal handler will not be acted upon if the signal was received while the thread was already at a cancellation point. they will of course be acted upon after the signal handler returns, so in real-world usage where signal handlers quickly return, it should not be a problem. it's possible to solve this problem too by having sigaction() wrap all signal handlers with a function that uses a pthread_cleanup handler to catch cancellation, patch up the saved context, and return into the cancellable function that will catch and act upon the cancellation. however that would be a lot of complexity for minimal if any benefit... Rich Felker2011-03-241-1/+2
* global cleanup to use the new syscall interfaceRich Felker2011-03-201-22/+0
* syscall overhaul part two - unify public and internal syscall interface•••with this patch, the syscallN() functions are no longer needed; a variadic syscall() macro allows syscalls with anywhere from 0 to 6 arguments to be made with a single macro name. also, manually casting each non-integer argument with (long) is no longer necessary; the casts are hidden in the macros. some source files which depended on being able to define the old macro SYSCALL_RETURNS_ERRNO have been modified to directly use __syscall() instead of syscall(). references to SYSCALL_SIGSET_SIZE and SYSCALL_LL have also been changed. x86_64 has not been tested, and may need a follow-up commit to fix any minor bugs/oversights. Rich Felker2011-03-191-0/+32
* remove comment cruft that got left behind in x86_64 syscall.sRich Felker2011-03-191-1/+0
* overhaul syscall interface•••this commit shuffles around the location of syscall definitions so that we can make a syscall() library function with both SYS_* and __NR_* style syscall names available to user applications, provides the syscall() library function, and optimizes the code that performs the actual inline syscalls in the library itself. previously on i386 when built as PIC (shared library), syscalls were incurring bus lock (lock prefix) overhead at entry and exit, due to the way the ebx register was being loaded (xchg instruction with a memory operand). now the xchg takes place between two registers. further cleanup to arch/$(ARCH)/syscall.h is planned. Rich Felker2011-03-194-11/+46
* implement [v]swprintfRich Felker2011-03-181-1/+1
* implement robust mutexes•••some of this code should be cleaned up, e.g. using macros for some of the bit flags, masks, etc. nonetheless, the code is believed to be working and correct at this point. Rich Felker2011-03-171-0/+5
* reorder mutex struct fields to make room for pointers (upcoming robust mutexes)•••the layout has been chosen so that pointer slots 3 and 4 fit between the integer slots on 32-bit archs, and come after the integer slots on 64-bit archs. Rich Felker2011-03-171-1/+3
* unify lock and owner fields of mutex structure•••this change is necessary to free up one slot in the mutex structure so that we can use doubly-linked lists in the implementation of robust mutexes. Rich Felker2011-03-171-1/+0
* implement flockfile api, rework stdio lockingRich Felker2011-03-122-12/+11
* optimize pthread termination in the non-detached case•••we can avoid blocking signals by simply using a flag to mark that the thread has exited and prevent it from getting counted in the rsyscall signal-pingpong. this restores the original pthread create/join throughput from before the sigprocmask call was added. Rich Felker2011-03-101-0/+1
* fix and optimize non-default-type mutex behavior•••problem 1: mutex type from the attribute was being ignored by pthread_mutex_init, so recursive/errorchecking mutexes were never being used at all. problem 2: ownership of recursive mutexes was not being enforced at unlock time. Rich Felker2011-03-081-0/+1
* use the selected clock from the condattr for pthread_cond_timedwaitRich Felker2011-03-071-0/+1
* various changes in preparation for dynamic linking support•••prefer using visibility=hidden for __libc internal data, rather than an accessor function, if the compiler has visibility. optimize with -O3 for PIC targets (shared library). without heavy inlining, reloading the GOT register in small functions kills performance. 20-30% size increase for a single libc.so is not a big deal, compared to comparaible size increase in every static binaries. use -Bsymbolic-functions, not -Bsymbolic. global variables are subject to COPY relocations, and thus binding their addresses in the library at link time will cause library functions to read the wrong (original) copies instead of the copies made in the main program's bss section. add entry point, _start, for dynamic linker. Rich Felker2011-02-242-5/+13
* use an accessor function for __libc data pointer when compiled as PIC•••prior to this change, a large portion of libc was unusable prior to relocation by the dynamic linker, due to dependence on the global data in the __libc structure and the need to obtain its address through the GOT. with this patch, the accessor function __libc_loc is now able to obtain the address of __libc via PC-relative addressing without using the GOT. this means the majority of libc functionality is now accessible right away. naturally, the above statements all depend on having an architecture where PC-relative addressing and jumps/calls are feasible, and a compiler that generates the appropriate code. Rich Felker2011-02-202-4/+19
* add pthread_atfork interface•••note that this presently does not handle consistency of the libc's own global state during forking. as per POSIX 2008, if the parent process was threaded, the child process may only call async-signal-safe functions until one of the exec-family functions is called, so the current behavior is believed to be conformant even if non-ideal. it may be improved at some later time. Rich Felker2011-02-181-0/+1
* reorganize pthread data structures and move the definitions to alltypes.h•••this allows sys/types.h to provide the pthread types, as required by POSIX. this design also facilitates forcing ABI-compatible sizes in the arch-specific alltypes.h, while eliminating the need for developers changing the internals of the pthread types to poke around with arch-specific headers they may not be able to test. Rich Felker2011-02-171-0/+19
* move arch-specific internal headers into placeRich Felker2011-02-154-637/+0
* finish unifying thread register handling in preparation for portingRich Felker2011-02-151-8/+2
* begin unifying clone/thread management interface in preparation for portingRich Felker2011-02-151-5/+3
* cleaning up syscalls in preparation for x86_64 port•••- hide all the legacy xxxxxx32 name cruft in syscall.h so the actual source files can be clean and uniform across all archs. - cleanup llseek/lseek and mmap2/mmap handling for 32/64 bit systems - alternate implementation for nice if the target lacks nice syscall Rich Felker2011-02-131-9/+40
* ensure that the compiler doesn't try to reorder around atomic opsRich Felker2011-02-121-13/+13
* initial check-in, version 0.5.0Rich Felker2011-02-1211-0/+852