about summary refs log tree commit diff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* ensure that abort always worksRich Felker2012-06-021-0/+2
| | | | | | | | | | | | | | | | Per POSIX, "The abort() function shall cause abnormal process termination to occur, unless the signal SIGABRT is being caught and the signal handler does not return." If SIGABRT is blocked or if a signal handler is installed and does return, abort is still required to cause abnormal program termination. We cannot use a_crash() to do this, since a SIGILL handler could also be installed (and might even longjmp out of the abort, not expecting to be invoked from within abort), nor can we rely on resetting the signal handler and re-raising the signal (this has race conditions in multi-threaded programs). On the other hand, SIGKILL is a perfectly safe, unblockable way to obtain abnormal program termination, and it requires no ugly loop-and-retry logic.
* add some ugly aliases for LSB ABI compatibilityRich Felker2012-06-027-0/+8
| | | | | | for some nonsensical reason, glibc's headers use inline functions that redirect some of the standard functions to ugly nonstandard names (and likewise for some of their nonstandard functions).
* increase default thread stack size to 80kRich Felker2012-06-021-1/+1
| | | | | | | | | | | | | | | | I've been looking for data that would suggest a good default, and since little has shown up, i'm doing this based on the limited data I have. the value 80k is chosen to accommodate 64k of application data (which happens to be the size of the buffer in git that made it crash without a patch to call pthread_attr_setstacksize) plus the max stack usage of most libc functions (with a few exceptions like crypt, which will be fixed soon to avoid excessive stack usage, and [n]ftw, which inherently uses a fair bit in recursive directory searching). if further evidence emerges suggesting that the default should be larger, I'll consider changing it again, but I'd like to avoid it getting too large to avoid the issues of large commit charge and rapid address space exhaustion on 32-bit machines.
* remove implementation-reserved bits when saving signal maskRich Felker2012-06-021-1/+11
| | | | | | | | this fix is necessary because a program could be started with some of the implementation-reserved signals masked (e.g. due to exec having been called from a signal handler, or from a non-musl program) and then could obtain an invalid-to-use-later sigset_t as the old/saved signal mask.
* remove no-longer-needed unblocking of signals in pthread_createRich Felker2012-06-021-1/+0
| | | | | | | this action is now performed in pthread_self initialization; it must be performed there in case the first call to pthread_create is from a signal handler, in which case the old signal mask could be restored on return from the signal.
* add LSB abi junk for ctype functionsRich Felker2012-06-023-0/+104
| | | | | | | | this should be the last major fix needed to support running glibc-linked conforming POSIX programs with musl in place of glibc, as long as musl provides the features they need and they don't use pthread cancellation (which is implemented as c++ exceptions in glibc, and fundamentally incompatible with musl).
* use fistpll mnemonic instead of fistpq (more widely supported) on x86_64 tooRich Felker2012-06-021-1/+1
| | | | | this was fixed previously on i386 but the corresponding code on x86_64 was missed.
* add LSB ABI __xstat, etc. junkRich Felker2012-05-314-0/+36
|
* enable LARGEFILE64 aliasesRich Felker2012-05-312-4/+1
| | | | | | | | these will NOT be used when compiling with -D_LARGEFILE64_SOURCE on musl; instead, they exist in the hopes of eventually being able to run some glibc-linked apps with musl sitting in place of glibc. also remove the (apparently incorrect) fcntl alias.
* add ldd and main program loading support to dynamic linkerRich Felker2012-05-274-21/+89
|
* cleanup dynamic linker start code cruftRich Felker2012-05-273-13/+6
| | | | | | | | | | | | | two actual issues: one is that __dynlink no longer wants/needs a GOT pointer argument, so the code to generate that argument can be removed. the other issue was that in the i386 code, argc/argv were being loaded into registers that would be call-clobbered, then copied to preserved registers, rather than just being loaded into the proper call-preserved registers to begin with. this cleanup is in preparation for adding new dynamic linker functionality (ability to explicitly invoke the dynamic linker to run a program).
* fix overrun (n essentially ignored) in wcsncmpRich Felker2012-05-261-1/+1
| | | | bug report and solution by Richard Pennington
* fix failure of mbsinit(0) (not UB; required to return nonzero)Rich Felker2012-05-261-1/+1
| | | | issue reported by Richard Pennington; slightly simpler fix applied
* fix failure of strrchr(str, 0)Rich Felker2012-05-261-1/+1
| | | | bug report and solution by Richard Pennington
* avoid using pthread cleanup push/pop in stdio when not neededRich Felker2012-05-252-6/+14
| | | | | | | | | | | | unfortunately in dynamic-linked programs, these macros cause pthread_self to be initialized, which costs a couple syscalls, and (much worse) would necessarily fail, crash, and burn on ancient (2.4 and earlier) kernels where setting up a thread pointer does not work. i'd like to do this in a more generic way that avoids all use of cleanup push/pop before pthread_self has been successfully called and avoids ugly if/else constructs like the one in this commit, but for now, this will suffice.
* ensure pthread-internal signals are unblocked before threads are usedRich Felker2012-05-251-0/+1
| | | | | | | | | | | if the process started with these signals blocked, cancellation could fail or setxid could deadlock. there is no way to globally unblock them after threads have been created. by unblocking them in the pthread_self initialization for the main thread, we ensure that they're unblocked before any other threads are created and also outside of any signal handler context (sigaction initialized pthread_self), which is important so that return from a signal handler won't re-block them.
* fix regex on armRich Felker2012-05-251-1/+1
| | | | | | | | | | | TRE has a broken assumption that wchar_t is signed, which is a sane expectation, but not required by the standard, and false on ARM's ABI. i leave tre_char_t as wchar_t for now, since a pointer to it is directly passed to functions that need pointer to wchar_t. it does not seem to break anything. and since the maximum unicode scalar value is 0x10ffff, just use that explicitly rather than using the max value of any particular C type.
* remove cruft from pthread structure (old cancellation stuff)Rich Felker2012-05-251-2/+0
|
* remove leftover cp_sp cruft from cancellation code, fix small bugRich Felker2012-05-251-3/+1
| | | | | | | | | | | the bug was that cancellation requests which arrived while a cancellation point was interrupted by a signal handler would not be acted upon when the signal handler returns. this was because cp_sp was never set; it's no longer needed or used. instead, just always re-raise the signal when cancellation was not acted upon. this wastes a tiny amount of time in the rare case where it even matters, but it ensures correctness and simplifies the code.
* avoid deprecated (by linux) alarm syscall; use setitimer insteadRich Felker2012-05-241-1/+4
|
* linux deprecated SYS_utime on some archs, so use SYS_utimes insteadRich Felker2012-05-241-1/+8
| | | | | | | | the old code could be kept for cases where SYS_utime is available, but it's not really worth the ifdef ugliness. and better to avoid deprecated stuff just in case the kernel devs ever get crazy enough to start removing it from archs where it was part of the ABI and breaking static bins...
* fix bad opcode in arm syscall_cp_asmRich Felker2012-05-231-1/+1
|
* fix issue with longjmp out of signal handlers and cancellationRich Felker2012-05-234-52/+35
| | | | | | | | | | | | | | | | | | | stale state information indicating that a thread was possibly blocked at a cancellation point could get left behind if longjmp was used to exit a signal handler that interrupted a cancellation point. to fix the issue, we throw away the state information entirely and simply compare the saved instruction pointer to a range of code addresses in the __syscall_cp_asm function. all the ugly PIC work (which becomes minimal anyway with this approach) is defered to cancellation time instead of happening at every syscall, which should improve performance too. this commit also fixes cancellation on arm, which was mildly broken (race condition, not checking cancellation flag once inside the cancellation point zone). apparently i forgot to implement that. the new arm code is untested, but appears correct; i'll test and fix it later if there are problems.
* simplify cancellation push/pop slightlyRich Felker2012-05-232-12/+9
| | | | | no need to pass unnecessary extra arguments on to the core code in pthread_create.c. this just wastes cycles and code bloat.
* remove everything related to forkallRich Felker2012-05-223-77/+0
| | | | | | | | | | i made a best attempt, but the intended semantics of this function are fundamentally contradictory. there is no consistent way to handle ownership of locks when forking a multi-threaded process. the code could have worked by accident for programs that only used normal mutexes and nothing else (since they don't actually store or care about their owner), but that's about it. broken-by-design interfaces that aren't even in glibc (only solaris) don't belong in musl.
* fix typo in utimes function that made it mess up file timesRich Felker2012-05-211-1/+1
|
* fix out-of-bounds array access in pthread barriers on 64-bitRich Felker2012-05-211-1/+1
| | | | | it's ok to overlap with integer slot 3 on 32-bit because only slots 0-2 are used on process-local barriers.
* fix misplaced semicolon in preprocessor directive (#undef h_errno)Rich Felker2012-05-161-1/+1
|
* remove some no-op end of string tests from regex parserRich Felker2012-05-131-4/+0
| | | | | | | | these are cruft from the original code which used an explicit string length rather than null termination. i blindly converted all the checks to null terminator checks, without noticing that in several cases, the subsequent switch statement would automatically handle the null byte correctly.
* another BRE fix: in ^*, * is literalRich Felker2012-05-131-0/+2
| | | | | | i don't understand why this has to be conditional on being in BRE mode, but enabling this code unconditionally breaks a huge number of ERE test cases.
* let sysconf accurately report # of cpus availableRich Felker2012-05-131-2/+10
| | | | | i've been trying out openmp and it seems like it won't be much use without this...
* use __h_errno_location for h_errnoRich Felker2012-05-122-0/+9
| | | | | | we do not bother making h_errno thread-local since the only interfaces that use it are inherently non-thread-safe. but still use the potentially-thread-local ABI to access it just to avoid lock-in.
* search: add comments to tsearch_avl.cnsz2012-05-131-0/+6
|
* search: add tdestroy (gnu extension)nsz2012-05-131-0/+21
|
* Merge remote-tracking branch 'nsz/master'Rich Felker2012-05-103-5/+8
|\
| * math: fix remquo.c when x==-y and a subnormal remainder bug as wellnsz2012-05-083-5/+8
| | | | | | | | | | backported fix from freebsd: http://svnweb.FreeBSD.org/base?view=revision&revision=233973
* | remove __lock dependency from exitRich Felker2012-05-101-2/+4
| | | | | | | | | | | | | | there's no sense in using a powerful lock in exit, because it will never be unlocked. a thread that arrives at exit while exit is already in progress just needs to hang forever. use the pause syscall for this because it's cheap and easy and universally available.
* | fix missing static (namespace clash)Rich Felker2012-05-101-1/+1
|/
* some assemblers don't like fistpq; use the alt. mnemonic fistpllRich Felker2012-05-073-3/+3
|
* fix error checking for \ at end of regex (this was broken previously)Rich Felker2012-05-071-1/+1
|
* fix copy and paste error in regex code causing mishandling of \) in BRERich Felker2012-05-071-1/+1
|
* fix regex breakage in last commit (failure to handle empty regex, etc.)Rich Felker2012-05-071-4/+1
|
* fix ugly bugs in TRE regex parserRich Felker2012-05-071-60/+31
| | | | | | | | | | | | | | | | | | | | | | 1. * in BRE is not special at the beginning of the regex or a subexpression. this broke ncurses' build scripts. 2. \\( in BRE is a literal \ followed by a literal (, not a literal \ followed by a subexpression opener. 3. the ^ in \\(^ in BRE is a literal ^ only at the beginning of the entire BRE. POSIX allows treating it as an anchor at the beginning of a subexpression, but TRE's code for checking if it was at the beginning of a subexpression was wrong, and fixing it for the sake of supporting a non-portable usage was too much trouble when just removing this non-portable behavior was much easier. this patch also moved lots of the ugly logic for empty atom checking out of the default/literal case and into new cases for the relevant characters. this should make parsing faster and make the code smaller. if nothing else it's a lot more readable/logical. at some point i'd like to revisit and overhaul lots of this code...
* add FORCE_EVAL macro to evaluate float expr for their side effectnsz2012-05-066-24/+25
| | | | | updated nextafter* to use FORCE_EVAL, it can be used in many other places in the math code to improve readability.
* fix unused variable warnings in new nextafter/nexttoward codeRich Felker2012-05-065-6/+12
| | | | | | | apparently initializing a variable is not "using" it but assigning to it is "using" it. i don't really like this fix, but it's better than trying to make a bigger cleanup just before a release, and it should work fine (tested against nsz's math tests).
* Merge remote-tracking branch 'nsz/master'Rich Felker2012-05-065-291/+176
|\
| * math: nextafter and nexttoward cleanupnsz2012-05-065-291/+176
| | | | | | | | | | make nexttoward, nexttowardf independent of long double representation. fix nextafterl: it did not raise underflow flag when the result was 0.
* | add isastream (obsolete STREAMS junk)Rich Felker2012-05-061-0/+7
|/ | | | | | apparently some packages see stropts.h and want to be able to use this. the implementation checks that the file descriptor is valid by using fcntl/F_GETFD so it can report an error if not (as specified).
* update license of njk contributed code (x86_64 asm)Rich Felker2012-05-055-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | these changes are based on the following communication via email: "I hereby grant that all of the code I have contributed to musl on or before April 23, 2012 may be licensed under the terms of the following MIT license: Copyright (c) 2011-2012 Nicholas J. Kain Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
* make pthread stacks non-executableRich Felker2012-05-041-1/+1
| | | | | | | | | | | | | this change is necessary or pthread_create will always fail on security-hardened kernels. i considered first trying to make the stack executable and simply retrying without execute permissions when the first try fails, but (1) this would incur a serious performance penalty on hardened systems, and (2) having the stack be executable is just a bad idea from a security standpoint. if there is real-world "GNU C" code that uses nested functions with threads, and it can't be fixed, we'll have to consider other ways of solving the problem, but for now this seems like the best fix.