1. 13 9月, 2018 11 次提交
    • R
      reduce spurious inclusion of libc.h · 5ce37379
      Rich Felker 提交于
      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.
      5ce37379
    • R
      c52ae698
    • R
      3fe595de
    • R
    • R
      overhaul internally-public declarations using wrapper headers · 13d1afa4
      Rich Felker 提交于
      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.
      13d1afa4
    • R
      move declarations of tls setup/access functions to pthread_impl.h · 91c6a187
      Rich Felker 提交于
      it's already included in all places where these are needed, and aside
      from __tls_get_addr, they're all implementation internals.
      91c6a187
    • R
      move __strftime_fmt_1 declaration to time_impl.h · 01294da7
      Rich Felker 提交于
      this is a helper function from strftime that's also used by wcsftime.
      01294da7
    • R
      move __tm_to_tzname declaration to time_impl.h with related functions · 72bc6cbf
      Rich Felker 提交于
      this function was added later for strftime use and the existence of
      time_impl.h as the appropriate place for it seems to have been
      overlooked.
      72bc6cbf
    • R
      fix type-mismatched declarations of __nl_langinfo_l in source files · 405102dc
      Rich Felker 提交于
      obviously the type "should be" const, but it inherited non-const from
      the standard nl_langinfo_l.
      405102dc
    • R
      use idiomatic weak alias approach for defining asctime_r · b5dbf4d4
      Rich Felker 提交于
      get rid of a gratuitous translation unit and call frame between
      asctime_r and the actual implementation of the function. this is the
      way gmtime_r and localtime_r are already done.
      b5dbf4d4
    • R
      cb229f61
  2. 28 8月, 2018 1 次提交
    • A
      time: fix incorrect DST offset when using POSIX timezones without DST · 92c52644
      A. Wilcox 提交于
      This manifests itself in mktime if tm_isdst = 1 and the current TZ= is
      a POSIX timezone specification. mktime would see that tm_isdst was set
      to 0 by __secs_to_zone, and subtract 'oppoff' (dst_off) - gmtoff from
      the resultant time. This meant that mktime returned a time that was
      exactly double the GMT offset of the desired timezone when tm_isdst
      was = 1.
      92c52644
  3. 08 8月, 2018 1 次提交
    • R
      fix sign of strftime %z output with offsets <1 hour west of UTC · 1ad81388
      Rich Felker 提交于
      the sign character produced came from the sign of tm_gmtoff/3600 as an
      integer division, which is zero for negative offsets smaller in
      magnitude than 3600. instead of printing the hours and minutes as
      separate fields, print them as a single value of the form
      hours*100+minutes, which naturally has the correct sign.
      1ad81388
  4. 27 6月, 2018 1 次提交
  5. 08 4月, 2018 1 次提交
    • S
      implement wcsftime padding specifier extensions · ea81529f
      Samuel Holland 提交于
      Commit 8a6bd730 added support for
      padding specifier extensions to strftime, but did not modify wcsftime.
      In the process, it added a parameter to __strftime_fmt_1 in strftime.c,
      but failed to update the prototype in wcsftime.c. This was found by
      compiling musl with LTO:
      
          src/time/wcsftime.c:7:13: warning: type of '__strftime_fmt_1' does \
              not match original declaration [-Wlto-type-mismatch]
      
      Fix the prototype of __strftime_fmt_1 in wcsftime.c, and generate the
      'pad' argument the same way as it is done in strftime.
      ea81529f
  6. 07 2月, 2018 1 次提交
    • R
      adjust strftime + modifier to match apparent intent of POSIX · c7f0da41
      Rich Felker 提交于
      it's unclear from the specification whether the word "consumes" in
      "consumes more than four bytes to represent a year" refers just to
      significant places or includes leading zeros due to field width
      padding. however the examples in the rationale indicate that the
      latter was the intent. in particular, the year 270 is shown being
      formatted by %+5Y as +0270 rather than 00270.
      
      previously '+' prefixing was implemented just by comparing the year
      against 10000. instead, count the number of significant digits and
      padding bytes to be added, and use the total to determine whether to
      apply the '+' prefix.
      
      based on testing by Dennis Wölfing.
      c7f0da41
  7. 06 2月, 2018 1 次提交
    • R
      fix strftime field widths with %F format and zero year · 596207aa
      Rich Felker 提交于
      the code to strip initial sign and leading zeros inadvertently
      stripped all the zeros and the subsequent '-' separating the month.
      instead, only strip sign characters from the very first position, and
      only strip zeros when they are followed by another digit.
      
      based on testing by Dennis Wölfing.
      596207aa
  8. 10 1月, 2018 1 次提交
  9. 15 12月, 2017 1 次提交
    • N
      use the name UTC instead of GMT for UTC timezone · eb7f93c4
      Natanael Copa 提交于
      notes by maintainer:
      
      both C and POSIX use the term UTC to specify related functionality,
      despite POSIX defining it as something more like UT1 or historical
      (pre-UTC) GMT without leap seconds. neither specifies the associated
      string for %Z. old choice of "GMT" violated principle of least
      surprise for users and some applications/tests. use "UTC" instead.
      eb7f93c4
  10. 12 12月, 2017 1 次提交
    • T
      implement strftime padding specifier extensions · 8a6bd730
      Timo Teräs 提交于
      notes added by maintainer:
      
      the '-' specifier allows default padding to be suppressed, and '_'
      allows padding with spaces instead of the default (zeros).
      
      these extensions seem to be included in several other implementations
      including FreeBSD and derivatives, and Solaris. while portable
      software should not depend on them, time format strings are often
      exposed to the user for configurable time display. reportedly some
      python programs also use and depend on them.
      8a6bd730
  11. 10 11月, 2017 1 次提交
  12. 21 6月, 2017 1 次提交
    • R
      handle errors from localtime_r in ctime_r · 64f85587
      Rich Felker 提交于
      POSIX requires ctime_r return a null pointer on failure, which can
      occur if the input time_t value is not representable in broken down
      form.
      
      based on patch by Alexander Monakov.
      64f85587
  13. 16 6月, 2017 1 次提交
    • R
      handle localtime errors in ctime · 5c10c33d
      Rich Felker 提交于
      ctime passes the result from localtime directly to asctime. But in case
      of error, localtime returns 0. This causes an error (NULL pointer
      dereference) in asctime.
      
      based on patch by Omer Anson.
      5c10c33d
  14. 15 6月, 2017 1 次提交
    • A
      getdate: correctly specify error number · 10800088
      A. Wilcox 提交于
      POSIX defines getdate error #5 as:
      "An I/O error is encountered while reading the template file."
      
      POSIX defines getdate error #7 as:
      "There is no line in the template that matches the input."
      
      This change correctly disambiguates between the two error conditions.
      10800088
  15. 22 3月, 2017 3 次提交
  16. 16 3月, 2017 1 次提交
    • R
      fix POSIX-format TZ dst transition times for southern hemisphere · dbff2bb8
      Rich Felker 提交于
      the time of day at which daylight time switches over is specified in
      local time in the dst state prior to the transition. the code for
      handling this wrongly assumed it needed to switch whether dst or
      standard offset is applied to the transition time when the dst end
      date is before the dst start date (souther hemisphere summer), but in
      fact the end transition time should always be adjusted for dst, and
      the start transition time should always be adjusted for standard time.
      dbff2bb8
  17. 03 1月, 2017 1 次提交
    • R
      fix strftime %y for negative years · 61fb81e3
      Rich Felker 提交于
      commit 583ea835 fixed the case where
      tm_year is negative but the resulting year (offset by 1900) was still
      positive, which is always the case for time_t values that fit in 32
      bits, but not for arbitrary inputs.
      
      based on an earlier patch by Julien Ramseier which was overlooked at
      the time the previous fix was applied.
      61fb81e3
  18. 08 11月, 2016 2 次提交
  19. 21 10月, 2016 1 次提交
  20. 20 10月, 2016 1 次提交
    • D
      fix clock_nanosleep error case · 3ca2d2d4
      Daniel Sabogal 提交于
      posix requires that EINVAL be returned if the first parameter specifies
      the cpu-time clock of the calling thread (CLOCK_THREAD_CPUTIME_ID).
      linux returns ENOTSUP instead so we handle this.
      3ca2d2d4
  21. 07 10月, 2016 1 次提交
  22. 08 7月, 2016 1 次提交
  23. 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
  24. 15 10月, 2015 1 次提交
    • R
      fix strftime handling of out-of-range struct tm fields · 8d93cb57
      Rich Felker 提交于
      strftime results are unspecified in this case, but should not invoke
      undefined behaviour.
      
      tm_wday, tm_yday, tm_mon and tm_year fields were used in signed int
      arithmetic that could overflow.
      
      based on patch by Szabolcs Nagy.
      8d93cb57
  25. 09 10月, 2015 1 次提交
    • R
      fix integer overflows in time_t/struct tm conversion code · c82d3bad
      Rich Felker 提交于
      as found and reported by Brian Mastenbrook, the expressions
      400*qc_cycles and years+100 in __secs_to_tm were both subject to
      integer overflow for extreme values of the input t.
      
      this patch by Szabolcs Nagy fixes the code by switching to larger
      types, and matches the original intent I had in mind when writing this
      code.
      c82d3bad
  26. 24 9月, 2015 1 次提交
    • S
      avoid reading uninitialized memory in __map_file · bd275378
      Szabolcs Nagy 提交于
      The value of *size is not relevant in case of failure, but it's
      better not to copy garbage from the stack into it.
      (The compiler cannot see through the syscall, so optimization
      was not affected by the unspecified value).
      bd275378
  27. 14 8月, 2015 1 次提交
    • N
      match historical behavior for tm_gmtoff member of struct tm · c13f2af1
      Natanael Copa 提交于
      tm_gmtoff is a nonstandard field, but on historical systems which have
      this field, it stores the offset of the local time zone from GMT or
      UTC. this is the opposite of the POSIX extern long timezone object and
      the offsets used in POSIX-form TZ strings, which represent the offset
      from local time to UTC. previously we were storing these negated
      offsets in tm_gmtoff too.
      
      programs which only used this field indirectly via strftime were not
      affected since strftime performed the negation for presentation.
      however, some programs and libraries accesse tm_gmtoff directly and
      were obtaining negated time zone offsets.
      c13f2af1