1. 28 1月, 2016 1 次提交
    • R
      improve clock_gettime and adapt it to support slightly-broken vdso · a5ba2d75
      Rich Felker 提交于
      these changes are motivated by a functionally similar patch by Hauke
      Mehrtens to address the needs of the new mips vdso clock_gettime,
      which wrongly fails with ENOSYS rather than falling back to making a
      syscall for clock ids it cannot handle from userspace. in the process
      of preparing to handle that case, it was noticed that the old
      clock_gettime use of the vdso was actually wrong with respect to error
      handling -- the tail call to the vdso function failed to set errno and
      instead returned an error code.
      
      since tail calls to vdso are no longer possible and since the plain
      syscall code is now needed as a fallback path anyway, it does not make
      sense to use a function pointer to call the plain syscall code path.
      instead, it's inlined at the end of the main clock_gettime function.
      
      the new code also avoids the need to test for initialization of the
      vdso function pointer by statically initializing it to a self-init
      function, and eliminates redundant loads from the volatile pointer
      object.
      
      finally, the use of a_cas_p on an object of type other than void *,
      which is not permitted aliasing, is replaced by using an object with
      the correct type and casting the value.
      a5ba2d75
  2. 27 1月, 2016 1 次提交
    • S
      change the internal socketcall selection logic · a5e133bf
      Szabolcs Nagy 提交于
      only use SYS_socketcall if SYSCALL_USE_SOCKETCALL is defined
      internally, otherwise use direct syscalls.
      
      this commit does not change the current behaviour, it is
      preparation for adding direct syscall numbers for i386.
      a5e133bf
  3. 26 1月, 2016 9 次提交
  4. 22 1月, 2016 7 次提交
    • R
      0f5eb3de
    • R
    • R
      230bfe1a
    • R
      move x32 sysinfo impl and syscall fixup code out of arch/x32/src · 66215afc
      Rich Felker 提交于
      all such arch-specific translation units are being moved to
      appropriate arch dirs under the main src tree.
      66215afc
    • R
      move arm-specific translation units out of arch/arm/src, to src/*/arm · e617b9ee
      Rich Felker 提交于
      this is possible with the new build system that allows src/*/$(ARCH)/*
      files which do not shadow a file in the parent directory, and yields a
      more logical organization. eventually it will be possible to remove
      arch/*/src from the build system.
      e617b9ee
    • R
      overhaul sh atomics for new atomics framework, add j-core cas.l backend · 61b1e75f
      Rich Felker 提交于
      sh needs runtime-selected atomic backends since there are a number of
      supported models that use non-forwards-compatible (non-smp-compatible)
      atomic mechanisms. previously, the code paths for this were highly
      inefficient since they involved C function calls with multiple
      branches in the callee and heavy spills in the caller. the new code
      performs calls the runtime-selected asm fragment from inline asm with
      extremely minimal clobbers, rather than using a function call.
      
      for the sh4a case where the atomic mechanism is known and there is no
      forward-compatibility issue, the movli.l and movco.l instructions are
      provided as a_ll and a_sc, allowing the new shared atomic.h to
      generate efficient inline versions of all the basic atomic operations
      without needing a cas loop.
      61b1e75f
    • R
      refactor internal atomic.h · 1315596b
      Rich Felker 提交于
      rather than having each arch provide its own atomic.h, there is a new
      shared atomic.h in src/internal which pulls arch-specific definitions
      from arc/$(ARCH)/atomic_arch.h. the latter can be extremely minimal,
      defining only a_cas or new ll/sc type primitives which the shared
      atomic.h will use to construct everything else.
      
      this commit avoids making heavy changes to the individual archs'
      atomic implementations. definitions which are identical or
      near-identical to what the new shared atomic.h would produce have been
      removed, but otherwise the changes made are just hooking up the
      arch-specific files to the new infrastructure. major changes to take
      advantage of the new system will come in subsequent commits.
      1315596b
  5. 21 1月, 2016 1 次提交
  6. 20 1月, 2016 4 次提交
  7. 18 1月, 2016 1 次提交
  8. 07 1月, 2016 1 次提交
  9. 20 12月, 2015 2 次提交
    • R
      fix overly pessimistic realloc strategy in getdelim · c673158d
      Rich Felker 提交于
      previously, getdelim was allocating twice the space needed every time
      it expanded its buffer to implement exponential buffer growth (in
      order to avoid quadratic run time). however, this doubling was
      performed even when the final buffer length needed was already known,
      which is the common case that occurs whenever the delimiter is in the
      FILE's buffer.
      
      this patch makes two changes to remedy the situation:
      
      1. over-allocation is no longer performed if the delimiter has already
      been found when realloc is needed.
      
      2. growth factor is reduced from 2x to 1.5x to reduce the relative
      excess allocation in cases where the delimiter is not initially in the
      buffer, including unbuffered streams.
      
      in theory these changes could lead to quadratic time if the same
      buffer is reused to process a sequence of lines successively
      increasing in length, but once this length exceeds the stdio buffer
      size, the delimiter will not be found in the buffer right away and
      exponential growth will still kick in.
      c673158d
    • R
      avoid updating caller's size when getdelim fails to realloc · d87f0a9a
      Rich Felker 提交于
      getdelim was updating *n, the caller's stored buffer size, before
      calling realloc. if getdelim then failed due to realloc failure, the
      caller would see in *n a value larger than the actual size of the
      allocated block, and use of that value is unsafe. in particular,
      passing it again to getdelim is unsafe.
      
      now, temporary storage is used for the desired new size, and *n is not
      written until realloc succeeds.
      d87f0a9a
  10. 16 12月, 2015 1 次提交
  11. 09 12月, 2015 4 次提交
  12. 01 12月, 2015 1 次提交
    • J
      properly handle point-to-point interfaces in getifaddrs() · 7b712844
      Jo-Philipp Wich 提交于
      With point-to-point interfaces, the IFA_ADDRESS netlink attribute
      contains the peer address while an extra attribute IFA_LOCAL carries
      the actual local interface address.
      
      Both the glibc and uclibc implementations of getifaddrs() handle this
      case by moving the ifa_addr contents to the broadcast/remote address
      union and overwriting ifa_addr upon receipt of an IFA_LOCAL attribute.
      
      This patch adds the same special treatment logic of IFA_LOCAL to
      musl's implementation of getifaddrs() in order to align its behaviour
      with that of uclibc and glibc.
      Signed-off-by: NJo-Philipp Wich <jow@openwrt.org>
      7b712844
  13. 29 11月, 2015 1 次提交
    • S
      ldso: fix the dtv update logic in __tls_get_new · 12978acb
      Szabolcs Nagy 提交于
      if two or more threads accessed tls in a dso that was loaded after
      the threads were created, then __tls_get_new could do out-of-bound
      memory access (leading to segfault).
      
      accidentally byte count was used instead of element count when
      the new dtv pointer was computed. (dso->new_dtv is (void**).)
      
      it is rare that the same dso provides dtv for several threads,
      the crash was not observed in practice, but possible to trigger.
      12978acb
  14. 22 11月, 2015 1 次提交
    • R
      math: explicitly promote expressions to excess-precision types · 8eead3ef
      Rich Felker 提交于
      a conforming compiler for an arch with excess precision floating point
      (FLT_EVAL_METHOD!=0; presently i386 is the only such arch supported)
      computes all intermediate results in the types float_t and double_t
      rather than the nominal type of the expression. some incorrect
      compilers, however, only keep excess precision in registers, and
      convert down to the nominal type when spilling intermediate results to
      memory, yielding unpredictable results that depend on the compiler's
      choices of what/when to spill. in particular, this happens on old gcc
      versions with -ffloat-store, which we need in order to work around
      bugs where the compiler wrongly keeps explicitly-dropped excess
      precision.
      
      by explicitly converting to double_t where expressions are expected be
      be evaluated in double_t precision, we can avoid depending on the
      compiler to get types correct when spilling; the nominal and
      intermediate precision now match. this commit should not change the
      code generated by correct compilers, or by old ones on non-i386 archs
      where double_t is defined as double.
      
      this fixes a serious bug in argument reduction observed on i386 with
      gcc 4.2: for values of x outside the unit circle, sin(x) was producing
      results outside the interval [-1,1]. changes made in commit
      0ce946cf were likely responsible for
      breaking compatibility with this and other old gcc versions.
      
      patch by Szabolcs Nagy.
      8eead3ef
  15. 20 11月, 2015 1 次提交
    • R
      remove undef weak refs to init/fini array symbols in libc.so · 19caa25d
      Rich Felker 提交于
      commit ad1cd43a eliminated
      preprocessor-level omission of references to the init/fini array
      symbols from object files going into libc.so. the references are weak,
      and the intent was that the linker would resolve them to zero in
      libc.so, but instead it leaves undefined references that could be
      satisfied at runtime. normally these references would be harmless,
      since the code using them does not even get executed, but some older
      binutils versions produce a linking error: when linking a program
      against libc.so, ld first tries to use the hidden init/fini array
      symbols produced by the linker script to satisfy the references in
      libc.so, then produces an error because the definitions are hidden.
      
      ideally ld would have already provided definitions of these symbols
      when linking libc.so, but the linker script for -shared omits them.
      
      to avoid this situation, the dynamic linker now provides its own dummy
      definitions of the init/fini array symbols for libc.so. since they are
      hidden, everything binds at ld time and no references remain in the
      dynamic symbol table. with modern binutils and --gc-sections, both
      the dummy empty array objects and the code referencing them get
      dropped at link time, anyway.
      
      the _init and _fini symbols are also switched back to using weak
      definitions rather than weak references since the latter behave
      somewhat problematically in general, and the weak definition approach
      was known to work well.
      19caa25d
  16. 16 11月, 2015 1 次提交
    • R
      use private maps even for read-only segments of FDPIC libraries · 5fe38516
      Rich Felker 提交于
      the nommu kernel shares memory when it can anyway for private
      read-only maps, but semantically the map should be private. this can
      make a difference when debugging breakpoints are to be used, in which
      case the kernel may need to ensure that the mapping is not shared.
      
      the new behavior matches how the kernel FDPIC loader maps the main
      program and/or program interpreter (dynamic linker) binary.
      5fe38516
  17. 13 11月, 2015 2 次提交
    • R
      remove use of SHARED macro in dynamic linker version reporting · 9e0a317d
      Rich Felker 提交于
      also fix visibility of the glue function used.
      9e0a317d
    • R
      unify static and dynamic linked implementations of thread-local storage · d56460c9
      Rich Felker 提交于
      this both allows removal of some of the main remaining uses of the
      SHARED macro and clears one obstacle to static-linked dlopen support,
      which may be added at some point in the future.
      
      specialized single-TLS-module versions of __copy_tls and __reset_tls
      are removed and replaced with code adapted from their dynamic-linked
      versions, capable of operating on a whole chain of TLS modules, and
      use of the dynamic linker's DSO chain (which contains large struct dso
      objects) by these functions is replaced with a new chain of struct
      tls_module objects containing only the information needed for
      implementing TLS. this may also yield some performance benefit
      initializing TLS for a new thread when a large number of modules
      without TLS have been loaded, since since there is no need to walk
      structures for modules without TLS.
      d56460c9
  18. 12 11月, 2015 1 次提交
    • R
      unify static and dynamic libc init/fini code paths · ad1cd43a
      Rich Felker 提交于
      use weak definitions that the dynamic linker can override instead of
      preprocessor conditionals on SHARED so that the same libc start and
      exit code can be used for both static and dynamic linking.
      ad1cd43a