| Commit message (Expand) | Author | Age | Files | Lines |
| * | remove volatile qualification from category pointers in __locale_struct•••commit 63c188ec42e76ff768e81f6b65b11c68fc43351e missed making this
change when switching from atomics to locking for modification of the
global locale, leaving access to locale structures unnecessarily
burdened with the restrictions of volatile.
the volatile qualification was originally added in commit
56fbaa3bbe73f12af2bfbbcf2adb196e6f9fe264.
| Rich Felker | 2018-10-20 | 1 | -1/+1 |
| * | adapt setlocale to support possibility of failure•••introduce a new LOC_MAP_FAILED sentinel for errors, since null
pointers for a category's locale map indicate the C locale. at this
time, __get_locale does not fail, so there should be no functional
change by this commit.
| Rich Felker | 2018-10-20 | 1 | -0/+2 |
| * | adjust types in FILE struct to make line buffering check less expensive•••the choice of signed char for lbf was a theoretically space-saving
hack that was not helping, and was unwantedly expensive. while
comparing bytes against a byte-sized member sounds easy, the trick
here was that the byte to be compared was unsigned while the lbf
member was signed, making it possible to set lbf negative to disable
line buffering. however, this imposed a requirement to promote both
operands, zero-extending one and sign-extending the other, in order to
compare them.
to fix this, repurpose the waiters count slot (unused since commit
c21f750727515602a9e84f2a190ee8a0a2aeb2a1). while we're at it, switch
mode (orientation) from signed char to int as well. this makes no
semantic difference (its only possible values are -1, 0, and 1) but it
might help on archs where byte access is awkward.
| Rich Felker | 2018-10-18 | 1 | -4/+2 |
| * | optimize internal putc_unlocked macro used in putc•••to check whether flush due to line buffering is needed, the int-type
character argument must be truncated to unsigned char for comparison.
if the original value is subsequently passed to __overflow, it must be
preserved, adding to register pressure. since it doesn't matter,
truncate all uses so the original value is no longer live.
| Rich Felker | 2018-10-18 | 1 | -1/+2 |
| * | fix wrong result for putc variants due to operator precedence•••the internal putc_unlocked macro was wrongly returning a meaningless
boolean result rather than the written character or EOF.
bug was found by reading (very surprising) asm.
| Rich Felker | 2018-10-18 | 1 | -1/+1 |
| * | move stdio locking MAYBE_WAITERS definition to stdio_impl.h•••don't repeat definition in two places.
| Rich Felker | 2018-10-16 | 1 | -0/+2 |
| * | combine arch ABI's DTP_OFFSET into DTV pointers•••as explained in commit 6ba5517a460c6c438f64d69464fdfc3269a4c91a, some
archs use an offset (typicaly -0x8000) with their DTPOFF relocations,
which __tls_get_addr needs to invert. on affected archs, which lack
direct support for large immediates, this can cost multiple extra
instructions in the hot path. instead, incorporate the DTP_OFFSET into
the DTV entries. this means they are no longer valid pointers, so
store them as an array of uintptr_t rather than void *; this also
makes it easier to access slot 0 as a valid slot count.
commit e75b16cf93ebbc1ce758d3ea6b2923e8b2457c68 left behind cruft in
two places, __reset_tls and __tls_get_new, from back when it was
possible to have uninitialized gap slots indicated by a null pointer
in the DTV. since the concept of null pointer is no longer meaningful
with an offset applied, remove this cruft.
presently there are no archs with both TLSDESC and nonzero DTP_OFFSET,
but the dynamic TLSDESC relocation code is also updated to apply an
inverted offset to its offset field, so that the offset DTV would not
impose a runtime cost in TLSDESC resolver functions.
| Rich Felker | 2018-10-12 | 1 | -2/+3 |
| * | increase default thread stack/guard size•••stack size default is increased from 80k to 128k. this coincides with
Linux's hard-coded default stack for the main thread (128k is
initially committed; growth beyond that up to ulimit is contingent on
additional allocation succeeding) and GNU ld's default PT_GNU_STACK
size for FDPIC, at least on sh.
guard size default is increased from 4k to 8k to reduce the risk of
guard page jumping on overflow, since use of just over 4k of stack is
common (PATH_MAX buffers, etc.).
| Rich Felker | 2018-09-18 | 1 | -2/+2 |
| * | limit the configurable default stack/guard size for threads•••limit to 8MB/1MB, repectively. since the defaults cannot be reduced
once increased, excessively large settings would lead to an
unrecoverably broken state. this change is in preparation to allow
defaults to be increased via program headers at the linker level.
creation of threads that really need larger sizes needs to be done
with an explicit attribute.
| Rich Felker | 2018-09-18 | 1 | -2/+5 |
| * | fix deletion of pthread tsd keys that still have non-null values stored•••per POSIX, deletion of a key for which some threads still have values
stored is permitted, and newly created keys must initially hold the
null value in all threads. these properties were not met by our
implementation; if a key was deleted with values left and a new key
was created in the same slot, the old values were still visible.
moreover, due to lack of any synchronization in pthread_key_delete,
there was a TOCTOU race whereby a concurrent pthread_exit could
attempt to call a null destructor pointer for the newly orphaned
value.
this commit introduces a solution based on __synccall, stopping the
world to zero out the values for deleted keys, but only does so lazily
when all key slots have been exhausted. pthread_key_delete is split
off into a separate translation unit so that static-linked programs
which only create keys but never delete them will not pull in the
__synccall machinery.
a global rwlock is added to synchronize creation and deletion of keys
with dtor execution. since the dtor execution loop now has to release
and retake the lock around its call to each dtor, checks are made not
to call the nodtor dummy function for keys which lack a dtor.
| Rich Felker | 2018-09-18 | 1 | -0/+3 |
| * | fix null pointer subtraction and comparison in stdio•••morally, for null pointers a and b, a-b, a<b, and a>b should all be
defined as 0; however, C does not define any of them.
the stdio implementation makes heavy use of such pointer comparison
and subtraction for buffer logic, and also uses null pos/base/end
pointers to indicate that the FILE is not in the corresponding (read
or write) mode ready for accesses through the buffer.
all of the comparisons are fixed trivially by using != in place of the
relational operators, since the opposite relation (e.g. pos>end) is
logically impossible. the subtractions have been reviewed to check
that they are conditional the stream being in the appropriate reading-
or writing-through-buffer mode, with checks added where needed.
in fgets and getdelim, the checks added should improve performance for
unbuffered streams by avoiding a do-nothing call to memchr, and should
be negligible for buffered streams.
| Rich Felker | 2018-09-16 | 1 | -2/+2 |
| * | fix undefined behavior in strto* via FILE buffer pointer abuse•••in order to produce FILE objects to pass to the intscan/floatscan
backends without any (prohibitively costly) extra buffering layer, the
strto* functions set the FILE's rend (read end) buffer pointer to an
invalid value at the end of the address space, or SIZE_MAX/2 past the
beginning of the string. this led to undefined behavior comparing and
subtracting the end pointer with the buffer position pointer (rpos).
the comparison issue is easily eliminated by using != instead of <.
however the subtractions require nontrivial changes:
previously, f->shcnt stored the count that would have been read if
consuming the whole buffer, which required an end pointer for the
buffer. the purpose for this was that it allowed reading it and adding
rpos-rend at any time to get the actual count so far, and required no
adjustment at the time of __shgetc (actual function call) since the
call would only happen when reaching the end of the buffer.
to get rid of the dependency on rend, instead offset shcnt by buf-rpos
(start of buffer) at the time of last __shlim/__shgetc call. this
makes for slightly more work in __shgetc the function, but for the
inline macro it's still just as easy to compute the current count.
since the scan helper interfaces used here are a big hack, comments
are added to document their contracts and what's going on with their
implementations.
| Rich Felker | 2018-09-15 | 2 | -8/+40 |
| * | fix regression with compilers not incorporating C99 DR#289 resolution•••as originally published, the C99 syntax only allowed static index
parameter declarators when a gratuitous parameter name was included.
gcc 3, which some projects use for bootstrapping, is a supported C99
compiler, but does not have the fix to the standard incorporated, so
edit the affected declaration to conform to the earlier buggy C99
syntax.
| Rich Felker | 2018-09-13 | 1 | -1/+1 |
| * | remove vis.h protected-visibility hack•••since commit dc2f368e565c37728b0d620380b849c3a1ddd78f this has been
disabled by default, but was left available in case users unhappy with
the resulting size or performance regressions wanted to try to make it
work. now that we make widespread use of hidden visibility for
internal interfaces, this no longer makes sense. if any costly calls
remain they can be fixed with hidden aliases.
| Rich Felker | 2018-09-12 | 1 | -27/+0 |
| * | split internal lock API out of libc.h, creating lock.h•••this further reduces the number of source files which need to include
libc.h and thereby be potentially exposed to libc global state and
internals.
this will also facilitate further improvements like adding an inline
fast-path, if we want to do so later.
| Rich Felker | 2018-09-12 | 2 | -6/+9 |
| * | move misplaced __fork_handler declaration•••pthread_atfork.c does not actually include pthread_impl.h and has no
reason to, so it wasn't getting the declaration. move it to libc.h
which is already included by both fork.c and pthread_atfork.c. this
makes more sense anyway since the function has little to do with
pthreads anyway aside from the name.
| Rich Felker | 2018-09-12 | 2 | -1/+1 |
| * | remove spurious inclusion of libc.h for LFS64 ABI aliases•••the LFS64 macro was not self-documenting and barely saved any
characters. simply use weak_alias directly so that it's clear what's
being done, and doesn't depend on a header to provide a strange macro.
| Rich Felker | 2018-09-12 | 1 | -6/+0 |
| * | reduce spurious inclusion of libc.h•••libc.h was intended to be a header for access to global libc state and
related interfaces, but ended up included all over the place because
it was the way to get the weak_alias macro. most of the inclusions
removed here are places where weak_alias was needed. a few were
recently introduced for hidden. some go all the way back to when
libc.h defined CANCELPT_BEGIN and _END, and all (wrongly implemented)
cancellation points had to include it.
remaining spurious users are mostly callers of the LOCK/UNLOCK macros
and files that use the LFS64 macro to define the awful *64 aliases.
in a few places, new inclusion of libc.h is added because several
internal headers no longer implicitly include libc.h.
declarations for __lockfile and __unlockfile are moved from libc.h to
stdio_impl.h so that the latter does not need libc.h. putting them in
libc.h made no sense at all, since the macros in stdio_impl.h are
needed to use them correctly anyway.
| Rich Felker | 2018-09-12 | 7 | -8/+7 |
| * | remove unused __futex function and source file•••the direct syscall or various thin and mostly-inline wrappers around
it are used instead internally. at some point a public futex function
should be added, but it's not yet clear what the signature should be,
and in the mean time this file is not useful.
| Rich Felker | 2018-09-12 | 1 | -2/+0 |
| * | declare and make hidden additional internal init/exit symbols | Rich Felker | 2018-09-12 | 1 | -0/+4 |
| * | declare and make hidden additional internal stdio symbols | Rich Felker | 2018-09-12 | 1 | -0/+5 |
| * | declare and make hidden more internal locale functions | Rich Felker | 2018-09-12 | 1 | -0/+2 |
| * | move additional pthread internal declarations to pthread_impl.h, hide•••these were overlooked for various reasons in earlier stages.
| Rich Felker | 2018-09-12 | 1 | -0/+15 |
| * | apply hidden visibility to various remaining internal interfaces | Rich Felker | 2018-09-12 | 7 | -22/+22 |
| * | apply hidden visibility to sigreturn code fragments•••these were overlooked in the declarations overhaul work because they
are not properly declared, and the current framework even allows their
declared types to vary by arch. at some point this should be cleaned
up, but I'm not sure what the right way would be.
| Rich Felker | 2018-09-12 | 1 | -1/+3 |
| * | apply hidden visibility to pthread internals | Rich Felker | 2018-09-12 | 1 | -11/+11 |
| * | apply hidden visibility to stdio internals | Rich Felker | 2018-09-12 | 1 | -26/+26 |
| * | apply hidden visibility to internal math functions•••this makes significant differences to codegen on archs with an
expensive PLT-calling ABI; on i386 and gcc 7.3 for example, the sin
and sinf functions no longer touch call-saved registers or the stack
except for pushing outgoing arguments. performance is likely improved
too, but no measurements were taken.
| Rich Felker | 2018-09-12 | 1 | -21/+21 |
| * | overhaul internally-public declarations using wrapper headers•••commits leading up to this one have moved the vast majority of
libc-internal interface declarations to appropriate internal headers,
allowing them to be type-checked and setting the stage to limit their
visibility. the ones that have not yet been moved are mostly
namespace-protected aliases for standard/public interfaces, which
exist to facilitate implementing plain C functions in terms of POSIX
functionality, or C or POSIX functionality in terms of extensions that
are not standardized. some don't quite fit this description, but are
"internally public" interfacs between subsystems of libc.
rather than create a number of newly-named headers to declare these
functions, and having to add explicit include directives for them to
every source file where they're needed, I have introduced a method of
wrapping the corresponding public headers.
parallel to the public headers in $(srcdir)/include, we now have
wrappers in $(srcdir)/src/include that come earlier in the include
path order. they include the public header they're wrapping, then add
declarations for namespace-protected versions of the same interfaces
and any "internally public" interfaces for the subsystem they
correspond to.
along these lines, the wrapper for features.h is now responsible for
the definition of the hidden, weak, and weak_alias macros. this means
source files will no longer need to include any special headers to
access these features.
over time, it is my expectation that the scope of what is "internally
public" will expand, reducing the number of source files which need to
include *_impl.h and related headers down to those which are actually
implementing the corresponding subsystems, not just using them.
| Rich Felker | 2018-09-12 | 3 | -22/+6 |
| * | declare __getopt_msg in stdio_impl.h•••it's not ideal, but the function is essentially an extended stdio
function specialized to getopt's needs. the only reason it exists is
avoiding pulling printf code into every program using getopt.
| Rich Felker | 2018-09-12 | 1 | -0/+2 |
| * | move __memalign declaration to malloc_impl.h•••the malloc-implementation-private header is the only right place for
this, because, being in the reserved namespace, __memalign is not
interposable and thus not valid to use anywhere else. anything outside
of the malloc implementation must call an appropriate-namespace public
function (aligned_alloc or posix_memalign).
| Rich Felker | 2018-09-12 | 1 | -0/+2 |
| * | make arch __set_thread_area backends hidden•••this is not a public interface, and does not even necessarily match
the syscall on all archs that have a syscall by that name.
on archs where it's implemented in C, no action on the source file is
needed; the hidden declaration in pthread_arch.h suffices.
| Rich Felker | 2018-09-12 | 1 | -1/+1 |
| * | make arch __clone backends hidden•••these are not a public interface and are not intended to be callable
from anywhere but the public clone function or other places in libc.
| Rich Felker | 2018-09-12 | 1 | -1/+1 |
| * | move tlsdesc and internal dl function declarations to dynlink.h | Rich Felker | 2018-09-12 | 1 | -0/+10 |
| * | move __stdio_exit_needed to stdio_impl.h•••this functions is glue for linking dependency logic.
| Rich Felker | 2018-09-12 | 1 | -0/+2 |
| * | move __loc_is_allocated declaration to locale_impl.h | Rich Felker | 2018-09-12 | 1 | -0/+1 |
| * | move declarations of tls setup/access functions to pthread_impl.h•••it's already included in all places where these are needed, and aside
from __tls_get_addr, they're all implementation internals.
| Rich Felker | 2018-09-12 | 1 | -0/+6 |
| * | move lgamma-related internal declarations to libm.h | Rich Felker | 2018-09-12 | 1 | -0/+4 |
| * | move declarations for malloc internals to malloc_impl.h | Rich Felker | 2018-09-12 | 1 | -0/+4 |
| * | improve machinery for ldso to report libc version•••eliminate gratuitous glue function for reporting the version, which
was probably leftover from the old dynamic linker design which lacked
a clear barrier for when/how it could access global data. put the
declaration for the data object that replaces it in libc.h where it
can be type checked.
| Rich Felker | 2018-09-12 | 2 | -6/+3 |
| * | make internal declarations for flockfile tracking functions checkable•••logically these belong to the intersection of the stdio and pthread
subsystems, and either place the declarations could go (stdio_impl.h
or pthread_impl.h) requires a forward declaration for one of the
argument types.
| Rich Felker | 2018-09-12 | 1 | -0/+5 |
| * | move and deduplicate declarations of __vdsosym to make it checkable | Rich Felker | 2018-09-12 | 1 | -0/+2 |
| * | move and deduplicate declarations of __procfdname to make it checkable•••syscall.h was chosen as the header to declare it, since its intended
usage is alongside syscalls as a fallback for operations the direct
syscall does not support.
| Rich Felker | 2018-09-12 | 2 | -0/+4 |
| * | remove leftover declarations for removed functions from pthread_impl.h | Rich Felker | 2018-09-05 | 1 | -4/+0 |
| * | define and use internal macros for hidden visibility, weak refs•••this cleans up what had become widespread direct inline use of "GNU C"
style attributes directly in the source, and lowers the barrier to
increased use of hidden visibility, which will be useful to recovering
some of the efficiency lost when the protected visibility hack was
dropped in commit dc2f368e565c37728b0d620380b849c3a1ddd78f, especially
on archs where the PLT ABI is costly.
| Rich Felker | 2018-09-05 | 6 | -25/+23 |
| * | fix missing timeout argument to futex syscall in __futexwait | Patrick Oppenlander | 2018-06-26 | 1 | -2/+2 |
| * | add m68k port•••three ABIs are supported: the default with 68881 80-bit fpu format and
results returned in floating point registers, softfloat-only with the
same format, and coldfire fpu with IEEE single/double only. only the
first is tested at all, and only under qemu which has fpu emulation
bugs.
basic functionality smoke tests have been performed for the most
common arch-specific breakage via libc-test and qemu user-level
emulation. some sysvipc failures remain, but are shared with other big
endian archs and will be fixed separately.
| Rich Felker | 2018-06-19 | 1 | -0/+9 |
| * | add support for m68k 80-bit long double variant•••since x86 and m68k are the only archs with 80-bit long double and each
has mandatory endianness, select the variant via endianness.
differences are minor: apparently just byte order and representation
of infinities. the m68k format is not well-documented anywhere I could
find, so if other differences are found they may require additional
changes later.
| Rich Felker | 2018-06-14 | 1 | -0/+11 |
| * | make linking of thread-start with explicit scheduling conditional•••the wrapper start function that performs scheduling operations is
unreachable if pthread_attr_setinheritsched is never called, so move
it there rather than the pthread_create source file, saving some code
size for static-linked programs.
| Rich Felker | 2018-05-09 | 1 | -0/+8 |
| * | improve design of thread-start with explicit scheduling attributes•••eliminate the awkward startlock mechanism and corresponding fields of
the pthread structure that were only used at startup.
instead of having pthread_create perform the scheduling operations and
having the new thread wait for them to be completed, start the new
thread with a wrapper start function that performs its own scheduling,
sending the result code back via a futex. this way the new thread can
use storage from the calling thread's stack rather than permanent
fields in the pthread structure.
| Rich Felker | 2018-05-09 | 1 | -2/+0 |