1. 26 10月, 2013 1 次提交
    • R
      add legacy ftime function and sys/timeb.h · 4b15d9f4
      Rich Felker 提交于
      despite being marked legacy, this was specified by SUSv3 as part of
      the XSI option; only the most recent version of the standard dropped
      it. reportedly there's actual code using it.
      4b15d9f4
  2. 25 8月, 2013 5 次提交
    • R
      add the %s (seconds since the epoch) format to strftime · 242a4bb4
      Rich Felker 提交于
      this is a nonstandard extension but will be required in the next
      version of POSIX, and it's widely used/useful in shell scripts
      utilizing the date utility.
      242a4bb4
    • R
      fix strftime regression in %e format · 2828a130
      Rich Felker 提交于
      %e pads with spaces instead of zeros.
      2828a130
    • R
      properly fill in tzname[] for old (pre-64-bit-format) zoneinfo files · 190bbb99
      Rich Felker 提交于
      in this case, the first standard-time and first daylight-time rules
      should be taken as the "default" ones to expose.
      190bbb99
    • R
      minor fix to tz name checking · 32985d4f
      Rich Felker 提交于
      if a zoneinfo file is not (or is no longer) in use, don't check the
      abbrevs pointers, which may be invalid.
      32985d4f
    • R
      fix strftime handling of time zone data · d78be392
      Rich Felker 提交于
      this may need further revision in the future, since POSIX is rather
      unclear on the requirements, and is designed around the assumption of
      POSIX TZ specifiers which are not sufficiently powerful to represent
      real-world timezones (this is why zoneinfo support was added).
      
      the basic issue is that strftime gets the string and numeric offset
      for the timezone from the extra fields in struct tm, which are
      initialized when calling localtime/gmtime/etc. however, a conforming
      application might have created its own struct tm without initializing
      these fields, in which case using __tm_zone (a pointer) could crash.
      other zoneinfo-based implementations simply check for a null pointer,
      but otherwise can still crash of the field contains junk.
      
      simply ignoring __tm_zone and using tzname[] would "work" but would
      give incorrect results in time zones with more complex rules. I feel
      like this would lower the quality of implementation.
      
      instead, simply validate __tm_zone: unless it points to one of the
      zone name strings managed by the timezone system, assume it's invalid.
      
      this commit also fixes several other minor bugs with formatting:
      tm_isdst being negative is required to suppress printing of the zone
      formats, and %z was using the wrong format specifiers since the type
      of val was changed, resulting in bogus output.
      d78be392
  3. 24 8月, 2013 1 次提交
  4. 23 8月, 2013 6 次提交
  5. 04 8月, 2013 3 次提交
    • R
      have new timer threads unblock their own SIGTIMER · a7f18a55
      Rich Felker 提交于
      unblocking it in the pthread_once init function is not sufficient,
      since multiple threads, some of them with the signal blocked, could
      already exist before this is called; timers started from such threads
      would be non-functional.
      a7f18a55
    • R
      add system for resetting TLS to initial values · 7c6c2906
      Rich Felker 提交于
      this is needed for reused threads in the SIGEV_THREAD timer
      notification system, and could be reused elsewhere in the future if
      needed, though it should be refactored for such use.
      
      for static linking, __init_tls.c is simply modified to export the TLS
      info in a structure with external linkage, rather than using statics.
      this perhaps makes the code more clear, since the statics were poorly
      named for statics. the new __reset_tls.c is only linked if it is used.
      
      for dynamic linking, the code is in dynlink.c. sharing code with
      __copy_tls is not practical since __reset_tls must also re-zero
      thread-local bss.
      7c6c2906
    • R
      fix multiple bugs in SIGEV_THREAD timers · 7356c255
      Rich Felker 提交于
      1. the thread result field was reused for storing a kernel timer id,
      but would be overwritten if the application code exited or cancelled
      the thread.
      
      2. low pointer values were used as the indicator that the timer id is
      a kernel timer id rather than a thread id. this is not portable, as
      mmap may return low pointers on some conditions. instead, use the fact
      that pointers must be aligned and kernel timer ids must be
      non-negative to map pointers into the negative integer space.
      
      3. signals were not blocked until after the timer thread started, so a
      race condition could allow a signal handler to run in the timer thread
      when it's not supposed to exist. this is mainly problematic if the
      calling thread was the only thread where the signal was unblocked and
      the signal handler assumes it runs in that thread.
      7356c255
  6. 03 8月, 2013 1 次提交
  7. 28 7月, 2013 2 次提交
    • R
      fix semantically incorrect use of LC_GLOBAL_LOCALE · 1ae4bc42
      Rich Felker 提交于
      LC_GLOBAL_LOCALE refers to the global locale, controlled by setlocale,
      not the thread-local locale in effect which these functions should be
      using. neither LC_GLOBAL_LOCALE nor 0 has an argument to the *_l
      functions has behavior defined by the standard, but 0 is a more
      logical choice for requesting the callee to lookup the current locale.
      in the future I may move the current locale lookup the the caller (the
      non-_l-suffixed wrapper).
      
      at this point, all of the locale logic is dummied out, so no harm was
      done, but it should at least avoid misleading usage.
      1ae4bc42
    • R
      reorder strftime to eliminate the incorrect indention level · d53b1f82
      Rich Felker 提交于
      this change is in preparation for possibly adding support for the
      field width and padding specifiers added in POSIX 2008.
      d53b1f82
  8. 25 7月, 2013 3 次提交
  9. 17 7月, 2013 3 次提交
  10. 29 6月, 2013 3 次提交
  11. 08 6月, 2013 1 次提交
    • R
      support cputime clocks for processes/threads other than self · ea200e38
      Rich Felker 提交于
      apparently these features have been in Linux for a while now, so it
      makes sense to support them. the bit twiddling seems utterly illogical
      and wasteful, especially the negation, but that's how the kernel folks
      chose to encode pids/tids into the clock id.
      ea200e38
  12. 24 5月, 2013 1 次提交
    • R
      fix overflow behavior of clock() function · 05453b37
      Rich Felker 提交于
      per Austin Group interpretation for issue #686, which cites the
      requirements of ISO C, clock() cannot wrap. if the result is not
      representable, it must return (clock_t)-1. in addition, the old code
      was performing wrapping via signed overflow and thus invoking
      undefined behavior.
      
      since it seems impossible to accurately check for overflow with the
      old times()-based fallback code, I have simply dropped the fallback
      code for now, thus always returning -1 on ancient systems. if there's
      a demand for making it work and somebody comes up with a way, it could
      be reinstated, but the clock() function is essentially useless on
      32-bit system anyway (it overflows in less than an hour).
      
      it should be noted that I used LONG_MAX rather than ULONG_MAX, despite
      32-bit archs using an unsigned type for clock_t. this discrepency with
      the glibc/LSB type definitions will be fixed now; since wrapping of
      clock_t is no longer supported, there's no use in it being unsigned.
      05453b37
  13. 06 5月, 2013 2 次提交
    • R
      fix incorrect clock tick scaling in fallback case of clock() · da49b872
      Rich Felker 提交于
      since CLOCKS_PER_SEC is 1000000 (required by XSI) and the times
      syscall reports values in 1/100 second units (Linux), the correct
      scaling factor is 10000, not 100. note that only ancient kernels which
      lack clock_gettime are affected.
      da49b872
    • R
      do not interpret errors in return value of times() syscall · 9293b765
      Rich Felker 提交于
      all return values are valid, and on 32-bit systems, values that look
      like errors can and will occur. since the only actual error this
      function could return is EFAULT, and it is only returnable when the
      application has invoked undefined behavior, simply ignore the
      possibility that the return value is actually an error code.
      9293b765
  14. 07 4月, 2013 1 次提交
  15. 02 4月, 2013 1 次提交
  16. 27 3月, 2013 1 次提交
    • R
      remove __SYSCALL_SSLEN arch macro in favor of using public _NSIG · ccc7b4c3
      Rich Felker 提交于
      the issue at hand is that many syscalls require as an argument the
      kernel-ABI size of sigset_t, intended to allow the kernel to switch to
      a larger sigset_t in the future. previously, each arch was defining
      this size in syscall_arch.h, which was redundant with the definition
      of _NSIG in bits/signal.h. as it's used in some not-quite-portable
      application code as well, _NSIG is much more likely to be recognized
      and understood immediately by someone reading the code, and it's also
      shorter and less cluttered.
      
      note that _NSIG is actually 65/129, not 64/128, but the division takes
      care of throwing away the off-by-one part.
      ccc7b4c3
  17. 02 2月, 2013 1 次提交
  18. 27 1月, 2013 1 次提交
  19. 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
  20. 30 9月, 2012 1 次提交
  21. 07 9月, 2012 1 次提交
    • R
      use restrict everywhere it's required by c99 and/or posix 2008 · 400c5e5c
      Rich Felker 提交于
      to deal with the fact that the public headers may be used with pre-c99
      compilers, __restrict is used in place of restrict, and defined
      appropriately for any supported compiler. we also avoid the form
      [restrict] since older versions of gcc rejected it due to a bug in the
      original c99 standard, and instead use the form *restrict.
      400c5e5c