1. 09 Jan, 2022 22 commits
  2. 29 Nov, 2021 2 commits
  3. 19 Oct, 2021 1 commit
    • Rich Felker's avatar
      fix struct layout mismatch in sound ioctl time32 fallback conversion · 3733c831
      Rich Felker authored
      the snd_pcm_mmap_control struct used with SNDRV_PCM_IOCTL_SYNC_PTR was
      mistakenly defined in the kernel uapi with "before u32" padding both
      before and after the first u32 member. our conversion between the
      modern struct and the legacy time32 struct was written without
      awareness of that mistake, and assumed the time64 version of the
      struct was the intended form with padding to match the layout on
      64-bit archs. as a result, the struct was not converted correctly when
      running on old kernels, with audio glitches as the likely result.
      
      this was discovered thanks to a related bug in the kernel, whereby
      32-bit userspace running on a 64-bit kernel also suffered from the
      types mismatching. the mistaken layout is now the ABI and can't be
      changed -- or at least making a new ioctl to change it would just
      result in a worse situation.
      
      our conversion here is changed to treat the snd_pcm_mmap_control
      substruct as two separate substructs at locations dependent on
      endianness (since the displacement depends on endianness), using the
      existing conversion framework.
      3733c831
  4. 24 Sep, 2021 1 commit
    • Érico Nogueira's avatar
      add qsort_r and make qsort a wrapper around it · b76f37fd
      Érico Nogueira authored
      we make qsort a wrapper by providing a wrapper_cmp function that uses
      the extra argument as a function pointer. should be optimized to a tail
      call on most architectures, as long as it's built with
      -fomit-frame-pointer, so the performance impact should be minimal.
      
      to keep the git history clean, for now qsort_r is implemented in qsort.c
      and qsort is implemented in qsort_nr.c.  qsort.c also received a few
      trivial cleanups, including replacing (*cmp)() calls with cmp().
      qsort_nr.c contains only wrapper_cmp and qsort as a qsort_r wrapper
      itself.
      b76f37fd
  5. 23 Sep, 2021 1 commit
    • Rich Felker's avatar
      add SPE FPU support to powerpc-sf · 7be59733
      Rich Felker authored
      When the soft-float ABI for PowerPC was added in commit
      5a92dd95, with Freescale cpus using
      the alternative SPE FPU as the main use case, it was noted that we
      could probably support hard float on them, but that it would involve
      determining some difficult ABI constraints. This commit is the
      completion of that work.
      
      The Power-Arch-32 ABI supplement defines the ABI profiles, and indeed
      ATR-SPE is built on ATR-SOFT-FLOAT. But setjmp/longjmp compatibility
      are problematic for the same reason they're problematic on ARM, where
      optional float-related parts of the register file are "call-saved if
      present". This requires testing __hwcap, which is now done.
      
      In keeping with the existing powerpc-sf subarch definition, which did
      not have fenv, the fenv macros are not defined for SPE and the SPEFSCR
      control register is left (and assumed to start in) the default mode.
      7be59733
  6. 12 Sep, 2021 1 commit
    • Rich Felker's avatar
      fix undefined behavior in getdelim via null pointer arithmetic and memcpy · e3e7189c
      Rich Felker authored
      both passing a null pointer to memcpy with length 0, and adding 0 to a
      null pointer, are undefined. in some sense this is 'benign' UB, but
      having it precludes use of tooling that strictly traps on UB. there
      may be better ways to fix it, but conditioning the operations which
      are intended to be no-ops in the k==0 case on k being nonzero is a
      simple and safe solution.
      e3e7189c
  7. 12 Aug, 2021 1 commit
    • Rich Felker's avatar
      fix excessively slow TLS performance on some mips models · b713b8b2
      Rich Felker authored
      commit 6d99ad91 introduced this
      regression as part of a larger change, based on an incorrect
      assumption that rdhwr being part of the mips r2 ISA level meant that
      the TLS register, known in the mips documentation as UserLocal, was
      unconditionally present on chips providing this ISA level and would
      not need trap-and-emulate. this turns out to be false.
      
      based on research by Stanislav Kljuhhin and Abilio Marques, who
      reported the problem as a performance regression on certain routers
      using OpenWRT vs older uclibc-based versions, it turns out the mips
      manuals document the UserLocal register as a feature that might or
      might not be implemented or enabled, reflected by a cpu capability bit
      in the CONFIG3 register, and that Linux checks for this and has to
      explicitly enable it on models that have it.
      
      thus, it's indeed possible that r2+ chips can lack the feature,
      bringing us back to the situation where Linux only has a fast
      trap-and-emulate path for the case where the destination register is
      $3. so, always read the thread pointer through $3. this may incur a
      gratuitous move to the desired final register on chips where it's not
      needed, but it really doesn't matter.
      b713b8b2
  8. 06 Aug, 2021 1 commit
  9. 30 Jul, 2021 1 commit
    • Rich Felker's avatar
      fix libc-internal signal blocking on mips archs · 3f701faa
      Rich Felker authored
      due to historical reasons, the mips signal set has 128 bits rather
      than 64 like on every other arch. this was special-cased correctly, at
      least for 32-bit mips, at one time, but was inadvertently broken in
      commit 7c440977, and seems never to
      have been right on mips64/n32.
      
      as consequenct of this bug, applications making use of high realtime
      signal numbers on mips may have been able to execute application code
      in contexts where doing so was unsafe.
      3f701faa
  10. 07 Jul, 2021 1 commit
    • Rich Felker's avatar
      fix broken struct shmid_ds on powerpc (32-bit) · 0fbd7d66
      Rich Felker authored
      the kernel structure has padding of the shm_segsz member up to 64
      bits, as well as 2 unused longs at the end. somehow that was
      overlooked when the powerpc port was added, and it has been broken
      ever since; applications compiled with the wrong definition do not
      correctly see the shm_segsz, shm_cpid, and shm_lpid members.
      
      fixing the definition just by adding the missing padding would break
      the ABI size of the structure as well as the position of the time64
      shm_atime and shm_dtime members we added at the end. instead, just
      move one of the unused padding members from the original end (before
      time64) of the structure to the position of the missing padding. this
      preserves size and preserves correct behavior of any compiled code
      that was already working. programs affected by the wrong definition
      need to be recompiled with the correct one.
      0fbd7d66
  11. 06 Jul, 2021 1 commit
  12. 23 Jun, 2021 1 commit
    • Rich Felker's avatar
      fix TZ parsing logic for identifying POSIX-form strings · 937822ab
      Rich Felker authored
      previously, the contents of the TZ variable were considered a
      candidate for a file/path name only if they began with a colon or
      contained a slash before any comma. the latter was very sloppy logic
      to avoid treating any valid POSIX TZ string as a file name, but it
      also triggered on values that are not valid POSIX TZ strings,
      including 3-letter timezone names without any offset.
      
      instead, only treat the TZ variable as POSIX form if it begins with a
      nonzero standard time name followed by +, -, or a digit.
      
      also, special case GMT and UTC to always be treated as POSIX form
      (with implicit zero offset) so that a stray file by the same name
      cannot break software that depends on setting TZ=GMT or TZ=UTC.
      937822ab
  13. 05 Jun, 2021 1 commit
  14. 27 Apr, 2021 1 commit
  15. 20 Apr, 2021 4 commits
    • Érico Nogueira's avatar
      remove unnecessary cast for map_library return · b7a130e0
      Érico Nogueira authored
      the function already returns (void *)
      b7a130e0
    • Érico Rolim's avatar
      add pthread_getname_np function · bd3b9c4c
      Érico Rolim authored
      based on the pthread_setname_np implementation
      bd3b9c4c
    • Rich Felker's avatar
      fix popen not to leak pipes from one child to another · e1a51185
      Rich Felker authored
      POSIX places an obscure requirement on popen which is like a limited
      version of close-on-exec:
      
          "The popen() function shall ensure that any streams from previous
          popen() calls that remain open in the parent process are closed in
          the new child process."
      
      if the POSIX-future 'e' mode flag is passed, producing a pipe FILE
      with FD_CLOEXEC on the underlying pipe, this requirement is
      automatically satisfied. however, for applications which use multiple
      concurrent popen pipes but don't request close-on-exec, fd leaks from
      earlier popen calls to later ones could produce deadlock situations
      where processes are waiting for a pipe EOF that will never happen.
      
      to fix this, iterate through all open FILEs and add close actions for
      those obtained from popen. this requires holding a lock on the open
      file list across the posix_spawn call so that additional popen FILEs
      are not created after the list is traversed. note that it's still
      possible for another popen call to start and create its pipe while the
      lock is held, but such pipes are created with O_CLOEXEC and only drop
      close-on-exec status (when 'e' flag is omitted) under control of the
      lock.
      e1a51185
    • Rich Felker's avatar
      remove spurious lock in popen · e74acd59
      Rich Felker authored
      the newly allocated FILE * has not yet leaked to the application and
      is only visible to stdio internals until popen returns. since we do
      not change any fields of the structure observed by libc internals,
      only the pipe_pid member, locking is not necessary.
      e74acd59