about summary refs log tree commit diff
path: root/src/internal
Commit message (Collapse)AuthorAgeFilesLines
* fix float parsing logic for long decimal expansionsRich Felker2012-08-171-1/+1
| | | | | | | | | | | | | | | | this affects at least the case of very long inputs, but may also affect shorter inputs that become long due to growth while upscaling. basically, the logic for the circular buffer indices of the initial base-10^9 digit and the slot one past the final digit, and for simplicity of the loop logic, assumes an invariant that they're not equal. the upscale loop, which can increase the length of the base-10^9 representation, attempted to preserve this invariant, but was actually only ensuring that the end index did not loop around past the start index, not that the two never become equal. the main (only?) effect of this bug was that subsequent logic treats the excessively long number as having no digits, leading to junk results.
* add bsd fgetln functionRich Felker2012-08-111-1/+1
| | | | | optimized to avoid allocation and return lines directly out of the stream buffer whenever possible.
* fix (hopefully) all hard-coded 8's for kernel sigset_t sizeRich Felker2012-08-091-2/+5
| | | | | | | | | | some minor changes to how hard-coded sets for thread-related purposes are handled were also needed, since the old object sizes were not necessarily sufficient. things have gotten a bit ugly in this area, and i think a cleanup is in order at some point, but for now the goal is just to get the code working on all supported archs including mips, which was badly broken by linux rejecting syscalls with the wrong sigset_t size.
* save AT_HWCAP from auxv for subsequent use in machine-specific codeRich Felker2012-07-272-0/+3
| | | | | | | it's expected that this will be needed/useful only in asm, so I've given it its own symbol that can be addressed in pc-relative ways from asm rather than adding a field in the __libc structure which would require hard-coding the offset wherever it's used.
* fix several locks that weren't updated right for new futex-based __lockRich Felker2012-07-121-3/+3
| | | | | | these could have caused memory corruption due to invalid accesses to the next field. all should be fixed now; I found the errors with fgrep -r '__lock(&', which is bogus since the argument should be an array.
* fix breakage of x86_64 sigaction from recent changes for mipsRich Felker2012-07-121-1/+1
|
* initial version of mips (o32) port, based on work by Richard Pennington (rdp)Rich Felker2012-07-111-0/+22
| | | | | | | | | | | | | basically, this version of the code was obtained by starting with rdp's work from his ellcc source tree, adapting it to musl's build system and coding style, auditing the bits headers for discrepencies with kernel definitions or glibc/LSB ABI or large file issues, fixing up incompatibility with the old binutils from aboriginal linux, and adding some new special cases to deal with the oddities of sigaction and pipe syscall interfaces on mips. at present, minimal test programs work, but some interfaces are broken or missing. threaded programs probably will not link.
* use unsigned bitmask for consistency in ksigactionRich Felker2012-07-111-1/+1
| | | | | the type doesn't actually matter, just the size, but it's nice to be consistent...
* fix breakage from last commit: forgot to include ksigaction.hRich Felker2012-07-111-0/+6
| | | | this file can be overridden by a same-named file in an arch dir.
* remove flush hook cruft that was never used from stdioRich Felker2012-06-191-1/+1
| | | | | | | there is no need/use for a flush hook. the write function serves this purpose already. i originally created the hook for implementing mem streams based on a mistaken reading of posix, and later realized it wasn't useful but never removed it until now.
* add pthread_attr_setstack interface (and get)Rich Felker2012-06-091-1/+2
| | | | | | | | | | | | | i originally omitted these (optional, per POSIX) interfaces because i considered them backwards implementation details. however, someone later brought to my attention a fairly legitimate use case: allocating thread stacks in memory that's setup for sharing and/or fast transfer between CPU and GPU so that the thread can move data to a GPU directly from automatic-storage buffers without having to go through additional buffer copies. perhaps there are other situations in which these interfaces are useful too.
* fix scanning of "-0x" pseudo-hex float (must give negative zero)Rich Felker2012-06-081-1/+1
|
* 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.
* enable LARGEFILE64 aliasesRich Felker2012-05-311-2/+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.
* remove cruft from pthread structure (old cancellation stuff)Rich Felker2012-05-251-2/+0
|
* remove everything related to forkallRich Felker2012-05-221-1/+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 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.
* add FORCE_EVAL macro to evaluate float expr for their side effectnsz2012-05-061-0/+13
| | | | | updated nextafter* to use FORCE_EVAL, it can be used in many other places in the math code to improve readability.
* overhaul SSP support to use a real canaryRich Felker2012-05-031-0/+4
| | | | | | | | | | | | | pthread structure has been adjusted to match the glibc/GCC abi for where the canary is stored on i386 and x86_64. it will need variants for other archs to provide the added security of the canary's entropy, but even without that it still works as well as the old "minimal" ssp support. eventually such changes will be made anyway, since they are also needed for GCC/C11 thread-local storage support (not yet implemented). care is taken not to attempt initializing the thread pointer unless the program actually uses SSP (by reference to __stack_chk_fail).
* fix off-by-one error that caused uninitialized memory read in floatscanRich Felker2012-04-301-1/+1
| | | | | | this caused misreading of certain floating point values that are exact multiples of large powers of ten, unpredictable depending on prior stack contents.
* ditch the priority inheritance locks; use malloc's version of lockRich Felker2012-04-242-3/+3
| | | | | | | | | | | | | | | | | | | i did some testing trying to switch malloc to use the new internal lock with priority inheritance, and my malloc contention test got 20-100 times slower. if priority inheritance futexes are this slow, it's simply too high a price to pay for avoiding priority inversion. maybe we can consider them somewhere down the road once the kernel folks get their act together on this (and perferably don't link it to glibc's inefficient lock API)... as such, i've switch __lock to use malloc's implementation of lightweight locks, and updated all the users of the code to use an array with a waiter count for their locks. this should give optimal performance in the vast majority of cases, and it's simple. malloc is still using its own internal copy of the lock code because it seems to yield measurably better performance with -O3 when it's inlined (20% or more difference in the contention stress test).
* new internal locking primitive; drop spinlocksRich Felker2012-04-241-1/+2
| | | | | | we use priority inheritance futexes if possible so that the library cannot hit internal priority inversion deadlocks in the presence of realtime priority scheduling (full support to be added later).
* remove redundant (unmaintained) check in floatscanRich Felker2012-04-221-3/+3
| | | | also be extra careful to avoid wrapping the circular buffer early
* make floatscan correctly set errno for overflow/underflowRich Felker2012-04-211-4/+16
| | | | | | | | | | | care is taken that the setting of errno correctly reflects underflow condition. scanning exact denormal values does not result in ERANGE, nor does scanning values (such as the usual string definition of FLT_MIN) which are actually less than the smallest normal number but which round to a normal result. only the decimal case is handled so far; hex float require a separate fix to come later.
* skip leading zeros even after decimal point in floatscanRich Felker2012-04-211-4/+9
| | | | | | in principle this should just be an optimization, but it happens to also fix a nasty bug where values like 0.00000000001 were getting caught by the early zero detection path and wrongly scanned as zero.
* fix overread (consuming an extra byte) scanning NANRich Felker2012-04-211-1/+1
| | | | bug detected by glib test suite
* fix really bad breakage in strtol, etc.: failure to accept leading spacesRich Felker2012-04-193-4/+5
|
* fix typo in exponent reading code or floatsRich Felker2012-04-181-1/+1
| | | | | this was basically harmless, but could have resulted in misreading inputs with more than a few gigabytes worth of digits..
* fix failure to read infinity in scanfRich Felker2012-04-171-3/+4
| | | | | | this code worked in strtod, but not in scanf. more evidence that i should design a better interface for discarding multiple tail characters than just calling unget repeatedly...
* fix failure of int parser to unget an initial mismatching characterRich Felker2012-04-171-0/+1
|
* use the new integer parser (FILE/shgetc based) for strtol, wcstol, etc.Rich Felker2012-04-162-127/+0
|
* new scanf implementation and corresponding integer parser/converterRich Felker2012-04-163-0/+107
| | | | | | | | | | | | | | | advantages over the old code: - correct results for floating point (old code was bogus) - wide/regular scanf separated so scanf does not pull in wide code - well-defined behavior on integers that overflow dest type - support for %[a-b] ranges with %[ (impl-defined by widely used) - no intermediate conversion of fmt string to wide string - cleaner, easier to share code with strto* functions - better standards conformance for corner cases the old code remains in the source tree, as the wide versions of the scanf-family functions are still using it. it will be removed when no longer needed.
* fix buggy limiter handling in shgetcRich Felker2012-04-161-4/+3
| | | | this is needed for upcoming new scanf
* fix broken shgetc limiter logic (wasn't working)Rich Felker2012-04-162-2/+5
|
* floatscan: fix incorrect count of leading nonzero digitsRich Felker2012-04-161-1/+1
| | | | | | | this off-by-one error was causing values with just one digit past the decimal point to be treated by the integer case. in many cases it would yield the correct result, but if expressions are evaluated in excess precision, double rounding may occur.
* use fast version of the int reading code for the high-order digits tooRich Felker2012-04-131-3/+13
| | | | | this increases code size slightly, but it's considerably faster, especially for power-of-2 bases.
* use macros instead of inline functions in shgetc.hRich Felker2012-04-131-20/+4
| | | | | | at -Os optimization level, gcc refuses to inline these functions even though the inlined code would roughly the same size as the function call, and much faster. the easy solution is to make them into macros.
* fix spurious overflows in strtoull with small basesRich Felker2012-04-131-7/+3
| | | | | | | whenever the base was small enough that more than one digit could still fit after UINTMAX_MAX/36-1 was reached, only the first would be allowed; subsequent digits would trigger spurious overflow, making it impossible to read the largest values in low bases.
* remove magic numbers from floatscanRich Felker2012-04-121-5/+5
|
* optimize more integer cases in floatscan; comment the whole procedureRich Felker2012-04-121-8/+27
|
* revert invalid optimization in floatscanRich Felker2012-04-111-2/+2
|
* fix stupid typo in floatscan that caused excess rounding of some valuesRich Felker2012-04-111-1/+1
|
* optimize floatscan downscaler to skip results that won't be neededRich Felker2012-04-111-2/+3
| | | | | | | | | | | | | | when upscaling, even the very last digit is needed in cases where the input is exact; no digits can be discarded. but when downscaling, any digits less significant than the mantissa bits are destined for the great bitbucket; the only influence they can have is their presence (being nonzero). thus, we simply throw them away early. the result is nearly a 4x performance improvement for processing huge values. the particular threshold LD_B1B_DIG+3 is not chosen sharply; it's simply a "safe" distance past the significant bits. it would be nice to replace it with a sharp bound, but i suspect performance will be comparable (within a few percent) anyway.
* simplify/debloat radix point alignment code in floatscanRich Felker2012-04-111-9/+4
| | | | | | | | | | | | now that this is the first operation, it can rely on the circular buffer contents not being wrapped when it begins. we limit the number of digits read slightly in the initial parsing loops too so that this code does not have to consider the case where it might cause the circular buffer to wrap; this is perfectly fine because KMAX is chosen as a power of two for circular-buffer purposes and is much larger than it otherwise needs to be, anyway. these changes should not affect performance at all.
* optimize floatscan: avoid excessive upscalingRich Felker2012-04-111-27/+27
| | | | | | | | | | upscaling by even one step too much creates 3-29 extra iterations for the next loop. this is still suboptimal since it always goes by 2^29 rather than using a smaller upscale factor when nearing the target, but performance on common, small-magnitude, few-digit values has already more than doubled with this change. more optimizations on the way...
* fix incorrect initial count in shgetc when data is already bufferedRich Felker2012-04-111-1/+1
|
* fix bug parsing lone zero followed by junk, and hex float over-readingRich Felker2012-04-111-6/+5
|
* fix float scanning of certain values ending in zerosRich Felker2012-04-101-1/+3
| | | | | | | for example, "1000000000" was being read as "1" due to this loop exiting early. it's necessary to actually update z and zero the entries so that the subsequent rounding code does not get confused; before i did that, spurious inexact exceptions were being raised.
* fix potential overflow in exponent readingRich Felker2012-04-101-1/+1
| | | | | | | note that there's no need for a precise cutoff, because exponents this large will always result in overflow or underflow (it's impossible to read enough digits to compensate for the exponent magnitude; even at a few nanoseconds per digit it would take hundreds of years).
* set errno properly when parsing floating pointRich Felker2012-04-101-4/+21
|