1. 28 7月, 2019 5 次提交
    • R
      implement settimeofday in terms of clock_settime, not old syscall · 2c2c3605
      Rich Felker 提交于
      this is yet another place where special handling of time syscalls can
      and should be avoided by implementing legacy functions in terms of
      their modern replacements. in theory a fallback to SYS_settimeofday
      could be added to clock_settime, but SYS_clock_settime has been
      available since Linux 2.6.0 or earlier, i.e. all the way back to the
      minimum supported version.
      2c2c3605
    • R
      internally, define plain syscalls, if missing, as their time64 variants · 4bbd7bae
      Rich Felker 提交于
      this commit has no effect whatsoever right now, but is in preparation
      for a future riscv32 port and other future 32-bit archs that will be
      "time64-only" from the start on the kernel side.
      
      together with the previous x32 changes, this commit ensures that
      syscall call points that don't care about time (passing null timeouts,
      etc.) can continue to do so without having to special-case time64-only
      archs, and allows code using the time64 syscalls to uniformly test for
      the need to fallback with SYS_foo != SYS_foo_time64, rather than
      needing to check defined(SYS_foo) && SYS_foo != SYS_foo_time64.
      4bbd7bae
    • R
      internally, define time64 syscalls on x32 as the existing syscalls · 40aa18d5
      Rich Felker 提交于
      x32 is odd in that it's the only ILP32 arch/ABI we have where time_t
      is 64-bit rather than (32-bit) long, and this has always been
      problematic in that it results in struct timespec having unused
      padding space, since tv_nsec has type long, which the kernel insists
      be zero- or sign-extended (due to negative tv_nsec being invalid, it
      doesn't matter which) to match the x86_64 type.
      
      up til now, we've had really ugly hacks in x32/syscall_arch.h to patch
      up the timespecs passed to the kernel. but the same requirement to
      zero- or sign-extend tv_nsec also applies to all the new time64
      syscalls on true 32-bit archs. so let's take advantage of this to
      clean things up.
      
      this patch defines all of the time64 syscalls for x32 as aliases for
      the existing syscalls by the same name. this establishes the following
      invariants:
      
      - if the time64 form is defined, it takes time arguments as 64-bit
        objects, and tv_nsec inputs must be zero-/sign-extended to 64-bit.
      
      - if the time64 form is not defined, or if the time64 form is defined
        and is not equal to the "plain" form, the plain form takes time
        arguments as longs.
      
      this will avoid the need for protocols for archs to define appropriate
      types for each family of syscalls, and for the reader of the code to
      have to be aware of such type definitions.
      
      in some sense it might be simpler if the plain syscall form were
      undefined for x32, so that it would always take longs if defined.
      however, a number of these syscalls are used in contexts with a null
      time argument, or (e.g. futex) for commands that don't involve time at
      all, and having to introduce time64-specific logic to all those call
      points does not make sense. thus, while the "plain" forms are kept now
      just because they're needed until the affected code is converted over,
      they'll also almost surely be kept in the future as well.
      40aa18d5
    • R
      don't use futimesat syscall as utimensat fallback on x32 · b93183e3
      Rich Felker 提交于
      kernel support for x32 was added long after the utimensat syscall was
      already available, so having a fallback is just wasted code size.
      
      also, for changes related to time64 support on 32-bit archs, I want to
      be able to assume the old futimesat syscall always works with longs,
      which is true except for x32. by ensuring that it's not used on x32,
      the needed invariant is established.
      b93183e3
    • R
      fix and simplify futimesat fallback in utimensat · cb856a61
      Rich Felker 提交于
      previously the fallback wrongly failed with EINVAL rather than ENOSYS
      when UTIME_NOW was used with one component but not both. commit
      dd5f50da introduced this behavior when
      initially adding the fallback support.
      
      instead, detect the case where both are UTIME_NOW early and replace
      with a null times pointer; this may improve performance slightly (less
      copy from user), and removes the complex logic from the fallback case.
      it also makes things slightly simpler for adding time64 code paths.
      cb856a61
  2. 27 7月, 2019 1 次提交
    • R
      refactor thrd_sleep and nanosleep in terms of clock_nanosleep · 331993e3
      Rich Felker 提交于
      for namespace-safety with thrd_sleep, this requires an alias, which is
      also added. this eliminates all but one direct call point for
      nanosleep syscalls, and arranges that 64-bit time_t conversion logic
      will only need to exist in one file rather than three.
      
      as a bonus, clock_nanosleep with CLOCK_REALTIME and empty flags is now
      implemented as SYS_nanosleep, thereby working on older kernels that
      may lack POSIX clocks functionality.
      331993e3
  3. 21 7月, 2019 3 次提交
    • S
      use the correct stat structure in the fstat path · 0ce49d0a
      Samuel Holland 提交于
      commit 01ae3fc6 modified fstatat to
      translate the kernel's struct stat ("kstat") into the libc struct stat.
      To do this, it created a local kstat object, and copied its contents
      into the user-provided object.
      
      However, the commit neglected to update the fstat compatibility path and
      its fallbacks. They continued to pass the user-supplied object to the
      kernel, later overwiting it with the uninitialized memory in the local
      temporary.
      0ce49d0a
    • R
      refactor adjtime function using adjtimex function instead of syscall · e53a91da
      Rich Felker 提交于
      this removes the assumption that userspace struct timex matches the
      syscall type and sets the stage for 64-bit time_t on 32-bit archs.
      e53a91da
    • R
      refactor adjtimex in terms of clock_adjtime · 107d68ad
      Rich Felker 提交于
      this sets the stage for having the conversion logic for 64-bit time_t
      all in one file, and as a bonus makes clock_adjtime for CLOCK_REALTIME
      work even on kernels too old to have the clock_adjtime syscall.
      107d68ad
  4. 19 7月, 2019 8 次提交
    • R
      fix inadvertent introduction of extern object stx · e468ed44
      Rich Felker 提交于
      commit dfc81828 accidentally defined
      an instance of struct statx along with the struct declaration.
      e468ed44
    • R
      implement fstatat with SYS_statx, conditional on undersized kstat time · dfc81828
      Rich Felker 提交于
      this commit adds a new backend for fstatat (and thereby the whole stat
      family) using the SYS_statx syscall, but conditions the new code on
      the kernel stat structure's time fields being smaller than time_t. in
      principle that should make it all dead code at present, but mips64 has
      a broken stat structure with 32-bit time fields despite having 64-bit
      time_t elsewhere, so on mips64 it is a functional change that makes
      post-Y2038 filesystem timestamps accessible.
      
      whenever the 32-bit archs end up getting 64-bit time_t, regardless of
      how that happens, the changes in this commit will automatically take
      effect for them too.
      dfc81828
    • R
    • R
      restore property that fstat(AT_FDCWD) fails with EBADF · eeff6060
      Rich Felker 提交于
      AT_FDCWD is not a valid file descriptor, so POSIX requires fstat to
      fail with EBADF. if passed to fstatat, the call would spuriously
      succeed and return results for the working directory.
      eeff6060
    • R
      remove mips/n32/64 stat struct hacks from syscall machinery · fa7d4218
      Rich Felker 提交于
      now that we have a kstat structure decoupled from the public struct
      stat, we can just use the broken kernel structures directly and let
      the code in fstatat do the translation.
      fa7d4218
    • R
      decouple struct stat from kernel type · 01ae3fc6
      Rich Felker 提交于
      presently, all archs/ABIs have struct stat matching the kernel
      stat[64] type, except mips/mipsn32/mips64 which do conversion hacks in
      syscall_arch.h to work around bugs in the kernel type. this patch
      completely decouples them and adds a translation step to the success
      path of fstatat. at present, this is just a gratuitous copying, but it
      opens up multiple possibilities for future support for 64-bit time_t
      on 32-bit archs and for cleaned-up/unified ABIs.
      
      for clarity, the mips hacks are not yet removed in this commit, so the
      mips kstat structs still correspond to the output of the hacks in
      their syscall_arch.h files, not the raw kernel type. a subsequent
      commit will fix this.
      01ae3fc6
    • R
      refactor all stat functions in terms of fstatat · 94938920
      Rich Felker 提交于
      equivalent logic for fstat+O_PATH fallback and direct use of
      stat/lstat syscalls where appropriate is kept, now in the fstatat
      function. this change both improves functionality (now, fstatat forms
      equivalent to fstat/lstat/stat will work even on kernels too old to
      have the at functions) and localizes direct interfacing with the
      kernel stat structure to one file.
      94938920
    • R
      remove utterly wrong includes from mips64/n32 bits/stat.h · 62a73d96
      Rich Felker 提交于
      these were overlooked during review. bits headers are not allowed to
      pull in additional headers (note: that rule is currently broken in
      other places but just for endian.h). string.h has no place here
      anyway, and including bits/alltypes.h without defining macros to
      request types from it is a nop.
      62a73d96
  5. 18 7月, 2019 3 次提交
    • R
      use register constraint instead of memory operand for riscv64 atomics · f0eb2e77
      Rich Felker 提交于
      the "A" constraint is simply for an address expression that's a single
      register, but it's not yet supported by clang, and has no advantage
      here over just using a register operand for the address. the latter is
      actually preferable in the a_cas_p case because it avoids aliasing an
      lvalue onto the memory.
      f0eb2e77
    • R
      fix riscv64 atomic asm constraints · 2dcbeabd
      Rich Felker 提交于
      most egregious problem was the lack of memory clobber and lack of
      volatile asm; this made the atomics memory barriers but not compiler
      barriers. use of "+r" rather than "=r" for a clobbered temp was also
      wrong, since the initial value is indeterminate.
      2dcbeabd
    • R
      fix riscv64 syscall asm constraint · 8eb49e04
      Rich Felker 提交于
      having "+r"(a0) is redundant with "0"(a0) in syscalls with at least 1
      arg, which is arguably a constraint violation (clang treats it as
      such), and an invalid input with indeterminate value in the 0-arg
      case. use the "=r"(a0) form instead.
      8eb49e04
  6. 17 7月, 2019 6 次提交
    • R
      fix broken lseek on x32 (x86_64/ILP32) with offsets larger than LONG_MAX · 1a28c6ea
      Rich Felker 提交于
      this is analogous to commit 918c5fa0
      which fixed the corresponding issue for mips n32.
      1a28c6ea
    • R
      fix broken lseek on mipsn32 with offsets larger than LONG_MAX · 918c5fa0
      Rich Felker 提交于
      mips n32 has 32-bit long, and generally uses long syscall arguments
      and return values, but provides only SYS_lseek, not SYS_llseek. we
      have some framework (syscall_arg_t, added for x32) to make syscall
      arguments 64-bit in such a setting, but it's not clear whether this
      could match the sign-extension semantics needed for 32-bit args to all
      the other syscalls, and we don't have any existing mechanism to allow
      the return value of syscalls to be something other than long.
      
      instead, just provide a custom mipsn32 version of the lseek function
      doing its own syscall asm with 64-bit arguments. as a result of commit
      03919b26, stdio will also get the new
      code, fixing fseeko/ftello too.
      918c5fa0
    • R
      clean up mips64/n32 syscall asm constraints · ddc7c4f9
      Rich Felker 提交于
      ever since inline syscalls were added for (o32) mips in commit
      328810d3, the asm has nonsensically
      loaded the syscall number, rather than taking $2 as an input
      constraint to let the compiler load it. commit
      cfc09b1e improved on this somewhat by
      allowing a constant syscall number to propagate into an immediate, but
      missed that the whole operation made no sense.
      
      now, only $4, $5, $6, $8, and $9 are potential input-only registers.
      $2 is always input and output, and $7 is both when it's an argument,
      otherwise output-only. previously, $7 was treated as an input (with a
      "1" constraint matching its output position) even when it was not an
      input, which was arguably undefined behavior (asm input from
      indeterminate value). this is corrected.
      ddc7c4f9
    • R
      deduplicate mips64/n32 syscall clobbered register lists · db2a148d
      Rich Felker 提交于
      this patch is not purely non-functional changes, since before, $8 and
      $9 were wrongly in the clobberlist for syscalls with fewer than 5 or 6
      arguments. of course it's impossible for syscalls to have different
      clobbers depending on their number of arguments. the clobberlist for
      the recently-added 5- and 6-argument forms was correct, and for the 0-
      to 4-argument forms was erroneously copied from the mips o32 ABI where
      the additional arguments had to be passed on the stack.
      
      in making this change, I reviewed the kernel sources, and $8 and $9
      are always saved for 64-bit kernels since they're part of the syscall
      argument list for n32 and n64 ABIs.
      db2a148d
    • R
      use namespace-safe __lseek for __stdio_seek instead of direct syscall · 03919b26
      Rich Felker 提交于
      this probably saves a few bytes, avoids duplicating the clunky
      lseek/_llseek syscall convention in two places, and sets the stage for
      fixing broken seeks on x32 and mipsn32.
      03919b26
    • R
      release 1.1.23 · b07d45eb
      Rich Felker 提交于
      b07d45eb
  7. 16 7月, 2019 3 次提交
    • R
      update year in COPYRIGHT file · d6dcd418
      Rich Felker 提交于
      d6dcd418
    • R
      update authors/contributors list · 7a6c8a0d
      Rich Felker 提交于
      these additions were made by scanning git log since the last major
      update in commit 1366b3c5.
      
      as before my aim was adding everyone with either substantial code
      contributions or a pattern of ongoing simple patch submission; any
      omissions are unintentional.
      7a6c8a0d
    • R
      fix build failure on arm building C code in thumb1 mode · 980f80f7
      Rich Felker 提交于
      a fully thumb1 build is not supported because some asm files are
      incompatible with thumb1, but apparently it works to compile the C
      code as thumb1
      
      commit 06fbefd1 caused this regression
      but introducing use of the clz instruction, which is not supported in
      arm mode prior to v5, and not supported in thumb prior to thumb2
      (v6t2). commit 1b9406b0 fixed the
      issue only for arm mode pre-v5 but left thumb1 broken.
      980f80f7
  8. 13 7月, 2019 1 次提交
  9. 11 7月, 2019 3 次提交
  10. 10 7月, 2019 2 次提交
  11. 09 7月, 2019 1 次提交
    • R
      prevent dup2 action for posix_spawn internal pipe fd · 75990040
      Rich Felker 提交于
      as reported by Tavian Barnes, a dup2 file action for the internal pipe
      fd used by posix_spawn could cause it to remain open after execve and
      allow the child to write an artificial error into it, confusing the
      parent. POSIX allows internal use of file descriptors by the
      implementation, with undefined behavior for poking at them, so this is
      not a conformance problem, but it seems preferable to diagnose and
      prevent the error when we can do so easily.
      
      catch attempts to apply a dup2 action to the internal pipe fd and
      emulate EBADF for it instead.
      75990040
  12. 07 7月, 2019 1 次提交
    • R
      fix inadvertent use of uninitialized variable in dladdr · 9b831820
      Rich Felker 提交于
      commit c8b49b2f introduced code that
      checked bestsym to determine whether a matching symbol was found, but
      bestsym is uninitialized if not. instead use best, consistent with use
      in the rest of the function.
      
      simplified from bug report and patch by Cheng Liu.
      9b831820
  13. 05 7月, 2019 2 次提交
  14. 03 7月, 2019 1 次提交