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. 04 3月, 2015 1 次提交
    • R
      make all objects used with atomic operations volatile · 56fbaa3b
      Rich Felker 提交于
      the memory model we use internally for atomics permits plain loads of
      values which may be subject to concurrent modification without
      requiring that a special load function be used. since a compiler is
      free to make transformations that alter the number of loads or the way
      in which loads are performed, the compiler is theoretically free to
      break this usage. the most obvious concern is with atomic cas
      constructs: something of the form tmp=*p;a_cas(p,tmp,f(tmp)); could be
      transformed to a_cas(p,*p,f(*p)); where the latter is intended to show
      multiple loads of *p whose resulting values might fail to be equal;
      this would break the atomicity of the whole operation. but even more
      fundamental breakage is possible.
      
      with the changes being made now, objects that may be modified by
      atomics are modeled as volatile, and the atomic operations performed
      on them by other threads are modeled as asynchronous stores by
      hardware which happens to be acting on the request of another thread.
      such modeling of course does not itself address memory synchronization
      between cores/cpus, but that aspect was already handled. this all
      seems less than ideal, but it's the best we can do without mandating a
      C11 compiler and using the C11 model for atomics.
      
      in the case of pthread_once_t, the ABI type of the underlying object
      is not volatile-qualified. so we are assuming that accessing the
      object through a volatile-qualified lvalue via casts yields volatile
      access semantics. the language of the C standard is somewhat unclear
      on this matter, but this is an assumption the linux kernel also makes,
      and seems to be the correct interpretation of the standard.
      56fbaa3b
  3. 16 4月, 2014 1 次提交
    • R
      add working vdso clock_gettime support, including static linking · 58e75db4
      Rich Felker 提交于
      the vdso symbol lookup code is based on the original 2011 patch by
      Nicholas J. Kain, with some streamlining, pointer arithmetic fixes,
      and one symbol version matching fix.
      
      on the consumer side (clock_gettime), per-arch macros for the
      particular symbol name and version to lookup are added in
      syscall_arch.h, and no vdso code is pulled in on archs which do not
      define these macros. at this time, vdso is enabled only on x86_64.
      
      the vdso support at the dynamic linker level is no longer useful to
      libc, but is left in place for the sake of debuggers (which may need
      the vdso in the link map to find its functions) and possibly use with
      dlsym.
      58e75db4
  4. 15 4月, 2014 1 次提交
  5. 08 8月, 2011 1 次提交
    • R
      use weak aliase rather than weak reference for vdso clock_gettime · cdfb725c
      Rich Felker 提交于
      this works around pcc's lack of working support for weak references,
      and in principle is nice because it gets us back to the stage where
      the only weak symbol feature we use is weak aliases, nothing else.
      
      having fewer dependencies on fancy linker features is a good thing.
      cdfb725c
  6. 24 7月, 2011 3 次提交
  7. 20 3月, 2011 1 次提交
  8. 10 3月, 2011 1 次提交
    • R
      fix errno behavior in clock_* functions · 1b538acb
      Rich Felker 提交于
      these functions are specified inconsistent in whether they're
      specified to return an error value, or return -1 and set errno.
      hopefully now they all match what POSIX requires.
      1b538acb
  9. 20 2月, 2011 1 次提交
  10. 12 2月, 2011 1 次提交