1. 30 5月, 2014 1 次提交
    • R
      support linux kernel apis (new archs) with old syscalls removed · dd5f50da
      Rich Felker 提交于
      such archs are expected to omit definitions of the SYS_* macros for
      syscalls their kernels lack from arch/$ARCH/bits/syscall.h. the
      preprocessor is then able to select the an appropriate implementation
      for affected functions. two basic strategies are used on a
      case-by-case basis:
      
      where the old syscalls correspond to deprecated library-level
      functions, the deprecated functions have been converted to wrappers
      for the modern function, and the modern function has fallback code
      (omitted at the preprocessor level on new archs) to make use of the
      old syscalls if the new syscall fails with ENOSYS. this also improves
      functionality on older kernels and eliminates the incentive to program
      with deprecated library-level functions for the sake of compatibility
      with older kernels.
      
      in other situations where the old syscalls correspond to library-level
      functions which are not deprecated but merely lack some new features,
      such as the *at functions, the old syscalls are still used on archs
      which support them. this may change at some point in the future if or
      when fallback code is added to the new functions to make them usable
      (possibly with reduced functionality) on old kernels.
      dd5f50da
  2. 25 3月, 2014 1 次提交
    • R
      always initialize thread pointer at program start · dab441ae
      Rich Felker 提交于
      this is the first step in an overhaul aimed at greatly simplifying and
      optimizing everything dealing with thread-local state.
      
      previously, the thread pointer was initialized lazily on first access,
      or at program startup if stack protector was in use, or at certain
      random places where inconsistent state could be reached if it were not
      initialized early. while believed to be fully correct, the logic was
      fragile and non-obvious.
      
      in the first phase of the thread pointer overhaul, support is retained
      (and in some cases improved) for systems/situation where loading the
      thread pointer fails, e.g. old kernels.
      
      some notes on specific changes:
      
      - the confusing use of libc.main_thread as an indicator that the
        thread pointer is initialized is eliminated in favor of an explicit
        has_thread_pointer predicate.
      
      - sigaction no longer needs to ensure that the thread pointer is
        initialized before installing a signal handler (this was needed to
        prevent a situation where the signal handler caused the thread
        pointer to be initialized and the subsequent sigreturn cleared it
        again) but it still needs to ensure that implementation-internal
        thread-related signals are not blocked.
      
      - pthread tsd initialization for the main thread is deferred in a new
        manner to minimize bloat in the static-linked __init_tp code.
      
      - pthread_setcancelstate no longer needs special handling for the
        situation before the thread pointer is initialized. it simply fails
        on systems that cannot support a thread pointer, which are
        non-conforming anyway.
      
      - pthread_cleanup_push/pop now check for missing thread pointer and
        nop themselves out in this case, so stdio no longer needs to avoid
        the cancellable path when the thread pointer is not available.
      
      a number of cases remain where certain interfaces may crash if the
      system does not support a thread pointer. at this point, these should
      be limited to pthread interfaces, and the number of such cases should
      be fewer than before.
      dab441ae
  3. 09 8月, 2013 1 次提交
    • R
      block signals during fork · d4d6d6f3
      Rich Felker 提交于
      there are several reasons for this. some of them are related to race
      conditions that arise since fork is required to be async-signal-safe:
      if fork or pthread_create is called from a signal handler after the
      fork syscall has returned but before the subsequent userspace code has
      finished, inconsistent state could result. also, there seem to be
      kernel and/or strace bugs related to arrival of signals during fork,
      at least on some versions, and simply blocking signals eliminates the
      possibility of such bugs.
      d4d6d6f3
  4. 09 11月, 2012 1 次提交
    • R
      clean up sloppy nested inclusion from pthread_impl.h · efd4d87a
      Rich Felker 提交于
      this mirrors the stdio_impl.h cleanup. one header which is not
      strictly needed, errno.h, is left in pthread_impl.h, because since
      pthread functions return their error codes rather than using errno,
      nearly every single pthread function needs the errno constants.
      
      in a few places, rather than bringing in string.h to use memset, the
      memset was replaced by direct assignment. this seems to generate much
      better code anyway, and makes many functions which were previously
      non-leaf functions into leaf functions (possibly eliminating a great
      deal of bloat on some platforms where non-leaf functions require ugly
      prologue and/or epilogue).
      efd4d87a
  5. 07 8月, 2011 1 次提交
  6. 17 7月, 2011 1 次提交
  7. 21 4月, 2011 1 次提交
    • R
      fix minor bugs due to incorrect threaded-predicate semantics · 870cc679
      Rich Felker 提交于
      some functions that should have been testing whether pthread_self()
      had been called and initialized the thread pointer were instead
      testing whether pthread_create() had been called and actually made the
      program "threaded". while it's unlikely any mismatch would occur in
      real-world problems, this could have introduced subtle bugs. now, we
      store the address of the main thread's thread descriptor in the libc
      structure and use its presence as a flag that the thread register is
      initialized. note that after fork, the calling thread (not necessarily
      the original main thread) is the new main thread.
      870cc679
  8. 18 4月, 2011 1 次提交
  9. 13 4月, 2011 1 次提交
    • R
      speed up threaded fork · e2915eee
      Rich Felker 提交于
      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.
      e2915eee
  10. 20 3月, 2011 1 次提交
  11. 10 3月, 2011 1 次提交
  12. 19 2月, 2011 1 次提交
    • R
      add pthread_atfork interface · e9417fff
      Rich Felker 提交于
      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.
      e9417fff
  13. 12 2月, 2011 1 次提交