1. 31 8月, 2020 1 次提交
  2. 17 8月, 2020 1 次提交
  3. 23 12月, 2019 2 次提交
  4. 22 12月, 2019 1 次提交
  5. 20 12月, 2019 1 次提交
    • R
      add further ioctl time64 fallback conversions · 2412638b
      Rich Felker 提交于
      this commit covers all remaining ioctls I'm aware of that use
      time_t-derived types in their interfaces. it may still be incomplete,
      and has undergone only minimal testing for a few commands used in
      audio playback.
      
      the SNDRV_PCM_IOCTL_SYNC_PTR command is special-cased because, rather
      than the whole structure expanding, it has two substructures each
      padded to 64 bytes that expand within their own 64-byte reserved zone.
      as long as it's the only one of its type, it doesn't really make sense
      to make a general framework for it, but the existing table framework
      is still used for the substructures in the special-case. one of the
      substructures, snd_pcm_mmap_status, has a snd_pcm_uframes_t member
      which is not a timestamp but is expanded just like one, to match the
      64-bit-arch version of the structure. this is handled just like a
      timestamp at offset 8, and is the motivation for the conversions table
      holding offsets of individual values to be expanded rather than
      timespec/timeval type pairs.
      
      for some of the types, the size to which they expand is dependent on
      whether the arch's ABI aligns 8-byte types on 8-byte boundaries.
      new_req entries in the table need to reflect this size to get the
      right ioctl request number that will match what callers pass, but we
      don't have access to the actual structure type definitions here and
      duplicating them would be cumbersome. instead, the new_misaligned
      macro introduced here constructs an artificial object whose size is
      the result of expanding a misaligned timespec/timeval to 64-bit and
      imposing the arch's alignment on the result, which can be passed to
      the _IO{R,W,WR} macros.
      2412638b
  6. 19 12月, 2019 2 次提交
    • R
      improve ioctl time64 conversion fallback framework · 64d0e865
      Rich Felker 提交于
      record offsets of individual slots that expand from 32- to 64-bit,
      rather than timespec/timeval pairs. this flexibility will be needed
      for some ioctls. reduce size of types in table. adjust representation
      of offsets to include a count rather than needing -1 padding so that
      the table is less ugly and doesn't need large diffs if we increase max
      number of slots.
      64d0e865
    • R
      convert ioctl time64 fallbacks to table-driven framework · 221b1a1d
      Rich Felker 提交于
      with the current set of supported ioctls, this conversion is hardly an
      improvement, but it sets the stage for being able to do alsa, v4l2,
      ppp, and other ioctls with timespec/timeval-derived types. without
      this capability, a lot of functionality users depend on would stop
      working with the time64 switchover.
      221b1a1d
  7. 24 10月, 2019 1 次提交
  8. 20 10月, 2019 1 次提交
    • R
      wait4, getrusage: add time64/x32 variant · 5850546e
      Rich Felker 提交于
      presently the kernel does not actually define time64 versions of these
      syscalls, and they're not really needed except to represent extreme
      cpu time usage. however, x32's versions of the syscalls already behave
      as time64 ones, meaning the functions were broken on x32 if the caller
      used any part of the rusage result other than ru_utime and ru_stime.
      commit 7e817114 made it possible to
      fix this by treating x32's syscalls as time64 versions.
      
      in the non-time64-syscall case, make the syscall with the rusage
      destination pointer adjusted so that all members but the timevals line
      up between the libc and kernel structures. on 64-bit archs, or present
      32-bit archs with 32-bit time_t, the timevals will line up too and no
      further work is needed. for future 32-bit archs with 64-bit time_t,
      the timevals are copied into place, contingent on time_t being larger
      than long.
      5850546e
  9. 31 8月, 2019 1 次提交
  10. 01 8月, 2019 1 次提交
    • R
      ioctl: add fallback for new time64 SIOCGSTAMP[NS] · 2e554617
      Rich Felker 提交于
      without this, the SIOCGSTAMP and SIOCGSTAMPNS ioctl commands, for
      obtaining timestamps, would stop working on pre-5.1 kernels after
      time_t is switched to 64-bit and their values are changed to the new
      time64 versions.
      
      new code is written such that it's statically unreachable on 64-bit
      archs, and on existing 32-bit archs until the macro values are changed
      to activate 64-bit time_t.
      2e554617
  11. 10 12月, 2018 2 次提交
  12. 13 9月, 2018 9 次提交
    • R
      split internal lock API out of libc.h, creating lock.h · 5f12ffe1
      Rich Felker 提交于
      this further reduces the number of source files which need to include
      libc.h and thereby be potentially exposed to libc global state and
      internals.
      
      this will also facilitate further improvements like adding an inline
      fast-path, if we want to do so later.
      5f12ffe1
    • R
      remove spurious inclusion of libc.h for LFS64 ABI aliases · 63a4c9ad
      Rich Felker 提交于
      the LFS64 macro was not self-documenting and barely saved any
      characters. simply use weak_alias directly so that it's clear what's
      being done, and doesn't depend on a header to provide a strange macro.
      63a4c9ad
    • 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
      3fe595de
    • 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
      declare __getopt_msg in stdio_impl.h · 8c1ac426
      Rich Felker 提交于
      it's not ideal, but the function is essentially an extended stdio
      function specialized to getopt's needs. the only reason it exists is
      avoiding pulling printf code into every program using getopt.
      8c1ac426
    • R
      use lighter internal stdio lock in getopt error printing · cf7db242
      Rich Felker 提交于
      the public flockfile interface is significantly heavier because it has
      to handle the possibility of caller returning or thread exiting while
      holding the lock.
      cf7db242
    • R
      move and deduplicate declarations of __procfdname to make it checkable · 6fcd60dd
      Rich Felker 提交于
      syscall.h was chosen as the header to declare it, since its intended
      usage is alongside syscalls as a fallback for operations the direct
      syscall does not support.
      6fcd60dd
    • R
      fix issues from public functions defined without declaration visible · c221d3e5
      Rich Felker 提交于
      policy is that all public functions which have a public declaration
      should be defined in a context where that public declaration is
      visible, to avoid preventable type mismatches.
      
      an audit performed using GCC's -Wmissing-declarations turned up the
      violations corrected here. in some cases the public header had not
      been included; in others, a feature test macro needed to make the
      declaration visible had been omitted.
      
      in the case of gethostent and getnetent, the omission seems to have
      been intentional, as a hack to admit a single stub definition for both
      functions. this kind of hack is no longer acceptable; it's UB and
      would not fly with LTO or advanced toolchains. the hack is undone to
      make exposure of the declarations possible.
      c221d3e5
  13. 23 8月, 2018 1 次提交
    • R
      getopt: update optarg and optind correctly on missing argument · 6aeb131b
      Rich Felker 提交于
      the text of the specification for getopt's handling of options that
      require an argument, which requires updating optarg and optind, does
      not exclude the error case where the end of the argument list has been
      reached. in that case, it is expected that optarg be assigned
      argv[argc] (normally null) and optind be incremented by 2, resulting
      in a value of argc+1.
      6aeb131b
  14. 27 4月, 2018 1 次提交
    • R
      getopt_long_only: don't prefix-match long-options that match short ones · 9be4ed5d
      Rich Felker 提交于
      for getopt_long, partial (prefix) matches of long options always begin
      with "--" and thus can never be ambiguous with a short option. for
      getopt_long_only, though, a single-character option can match both a
      short option and as a prefix for a long option. in this case, we
      wrongly interpreted it as a prefix for the long option.
      
      introduce a new pass, only in long-only mode, to check the prefix
      match against short options before accepting it. the only reason
      there's a slightly nontrivial loop being introduced rather than strchr
      is that our getopt already supports multibyte short options, and
      getopt_long_long should handle them consistently. a temp buffer and
      strstr could have been used, but the code to set it up would be just
      as large as what's introduced here and it would unnecessarily pull in
      relatively large code for strstr.
      9be4ed5d
  15. 26 2月, 2018 1 次提交
    • R
      add public interface headers to implementation files · 57b97b42
      Rich Felker 提交于
      general policy is that all source files defining a public API or an
      ABI mechanism referenced by a public header should include the public
      header that declares the interface, so that the compiler or analysis
      tools can check the consistency of the declarations. Alexander Monakov
      pointed out a number of violations of this principle a few years back.
      fix them now.
      57b97b42
  16. 24 2月, 2018 1 次提交
  17. 23 2月, 2018 1 次提交
    • R
      add getentropy function · 82f17680
      Rich Felker 提交于
      based loosely on patch by Hauke Mehrtens; converted to wrap the public
      API of the underlying getrandom function rather than direct syscalls,
      so that if/when a fallback implementation of getrandom is added it
      will automatically get picked up by getentropy too.
      82f17680
  18. 06 2月, 2018 1 次提交
    • A
      re-fix child reaping in wordexp · e53296f8
      Alexander Monakov 提交于
      Do not retry waitpid if the child was terminated by a signal. Do not
      examine status: since we are not passing any flags, we will not receive
      stop or continue notifications.
      e53296f8
  19. 01 2月, 2018 2 次提交
    • S
      getopt_long: accept prefix match of long options containing equals signs · 6f03b61b
      Samuel Holland 提交于
      Consider the first equals sign found in the option to be the delimiter
      between it and its argument, even if it matches an equals sign in the
      option name. This avoids consuming the equals sign, which would prevent
      finding the argument. Instead, it forces a partial match of the part of
      the option name before the equals sign.
      
      Maintainer's note: GNU getopt_long does not explicitly document this
      behavior, but it can be seen as a consequence of how partial matches
      are specified, and at least GNU (bfd) ld is known to make use of it.
      6f03b61b
    • S
      fix getopt_long arguments to partial matches · f1abc29b
      Samuel Holland 提交于
      If we find a partial option name match, we need to keep looking for
      ambiguous/conflicting options. However, we need to remember the position
      in the candidate argument to find its option-argument later, if there is
      one. This fixes e.g. option "foobar" being given as "--fooba=baz".
      f1abc29b
  20. 10 1月, 2018 1 次提交
  21. 14 10月, 2017 1 次提交
    • R
      fix incorrect base name offset from nftw when pathname ends in slash(es) · 5b5eb527
      Rich Felker 提交于
      the rightmost '/' character is not necessarily the delimiter before
      the basename; it could be a spurious trailing character on the
      directory name.
      
      this change does not introduce any normalization of pathnames or
      stripping of trailing slashes, contrary to at least glibc and perhaps
      other implementations; it jusst prevents their presence from breaking
      things. whether further changes should be made is an open question
      that may depend on conformance and/or application compatibility
      considerations.
      
      based loosely on patch by Joakim Sindholt.
      5b5eb527
  22. 05 1月, 2017 1 次提交
    • R
      fix getopt[_long] clobbering of optopt on success · 786fda87
      Rich Felker 提交于
      getopt is only specified to modify optopt on error, and some software
      apparently infers an error from optopt!=0.
      
      getopt_long is changed analogously. the resulting behavior differs
      slightly from the behavior of the GNU implementation of getopt_long,
      which keeps an internal shadow copy of optopt and copies it to the
      public one on return, but since the GNU implementation also exhibits
      this shadow-copy behavior for plain getopt where is is non-conforming,
      I think this can reasonably be considered a bug rather than an
      intentional behavior that merits mimicing.
      786fda87
  23. 21 10月, 2016 1 次提交
  24. 20 10月, 2016 1 次提交
  25. 24 5月, 2016 1 次提交
    • R
      fix a64l undefined behavior on ILP32 archs, wrong results on LP64 archs · 77baaa47
      Rich Felker 提交于
      the difference of pointers is a signed type ptrdiff_t; if it is only
      32-bit, left-shifting it by 30 bits produces undefined behavior. cast
      the difference to an appropriate unsigned type, uint32_t, before
      shifting to avoid this.
      
      the a64l function is specified to return a signed 32-bit result in
      type long. as noted in the bug report by Ed Schouten, converting
      implicitly from uint32_t only produces the desired result when long is
      a 32-bit type. since the computation has to be done in unsigned
      arithmetic to avoid overflow, simply cast the result to int32_t.
      
      further, POSIX leaves the behavior on invalid input unspecified but
      not undefined, so we should not take the difference between the
      potentially-null result of strchr and the base pointer without first
      checking the result. the simplest behavior is just returning the
      partial conversion already performed in this case, so do that.
      77baaa47
  26. 17 2月, 2016 1 次提交
    • R
      fix unlikely corner cases in getopt's message printing · ef2b5e9f
      Rich Felker 提交于
      like fputs (see commit 10a17dfb), the
      message printing code for getopt assumed that fwrite only returns 0 on
      failure, but it can also happen on success if the total length to be
      written is zero. programs with zero-length argv[0] were affected.
      
      commit 500c6886 introduced this
      problem in getopt by fixing the fwrite behavior to conform to the
      requirements of ISO C. previously the wrong expectations of the getopt
      code were met by the fwrite implementation.
      ef2b5e9f
  27. 21 8月, 2015 1 次提交
  28. 10 7月, 2015 1 次提交
    • R
      handle loss of syslog socket connection · 0f9c2666
      Rich Felker 提交于
      when traditional syslogd implementations are restarted, the old server
      socket ceases to exist and a new unix socket with the same pathname is
      created. when this happens, the default destination address associated
      with the client socket via connect is no longer valid, and attempts to
      send produce errors. this happens despite the socket being datagram
      type, and is in contrast to the behavior that would be seen with an IP
      datagram (UDP) socket.
      
      in order to avoid a situation where the application is unable to send
      further syslog messages without calling closelog, this patch makes
      syslog attempt to reconnect the socket when send returns an error
      indicating a lost connection.
      
      additionally, initial failure to connect the socket no longer results
      in the socket being closed. this ensures that an application which
      calls openlog to reserve the socket file descriptor will not run into
      a situation where transient connection failure (e.g. due to syslogd
      restart) prevents fd reservation. however, applications which may be
      unable to connect the socket later (e.g. due to chroot, restricted
      permissions, seccomp, etc.) will still fail to log if the syslog
      socket cannot be connected at openlog time or if it has to be
      reconnected later.
      0f9c2666