1. 05 2月, 2020 2 次提交
  2. 04 2月, 2020 1 次提交
    • R
      move riscv64 register index constants to signal.h · 329e7929
      Rich Felker 提交于
      under _GNU_SOURCE for namespace cleanliness, analogous to other archs.
      the original placement in sys/reg.h seems not to have been motivated;
      such a header isn't even present on other implementations.
      329e7929
  3. 31 1月, 2020 1 次提交
    • R
      remove legacy clock_gettime and gettimeofday from public syscall.h · 5a105f19
      Rich Felker 提交于
      some nontrivial number of applications have historically performed
      direct syscalls for these operations rather than using the public
      functions. such usage is invalid now that time_t is 64-bit and these
      syscalls no longer match the types they are used with, and it was
      already harmful before (by suppressing use of vdso).
      
      since syscall() has no type safety, incorrect usage of these syscalls
      can't be caught at compile-time. so, without manually inspecting or
      running additional tools to check sources, the risk of such errors
      slipping through is high.
      
      this patch renames the syscalls on 32-bit archs to clock_gettime32 and
      gettimeofday_time32, so that applications using the original names
      will fail to build without being fixed.
      
      note that there are a number of other syscalls that may also be unsafe
      to use directly after the time64 switchover, but (1) these are the
      main two that seem to be in widespread use, and (2) most of the others
      continue to have valid usage with a null timeval/timespec argument, as
      the argument is an optional timeout or similar.
      5a105f19
  4. 26 1月, 2020 1 次提交
  5. 23 1月, 2020 1 次提交
    • L
      fix riscv64 a_cas inline asm operand sign extension · 83350eb1
      Luís Marques 提交于
      This patch adds an explicit cast to the int arguments passed to the
      inline asm used in the RISC-V's implementation of `a_cas`, to ensure
      that they are properly sign extended to 64 bits. They aren't
      automatically sign extended by Clang, and GCC technically also doesn't
      guarantee that they will be sign extended.
      83350eb1
  6. 31 12月, 2019 5 次提交
  7. 05 11月, 2019 1 次提交
    • R
      fix build regression on mips64 due to endian.h removal · 90251cf7
      Rich Felker 提交于
      commit 4d3a162d overlooked that the
      mips64 reloc.h dependent on endian.h not only for setting the ABI ldso
      name to match the byte order, but also for use of the byte swapping
      macros. they are needed to override R_TYPE, R_SYM, and R_INFO, to
      compensate for a mips "quirk" of always using big endian order for
      symbol references in relocations.
      
      part of that commit canot be reverted because the original code was
      wrong: it's invalid to define _GNU_SOURCE or any feature test macro
      in reloc.h, or anywhere except at the top of a source file. however,
      thanks to commit 316730cd, the feature
      test macro is no longer needed to access the endian-swapping macros,
      so simply bringing back the #include directive suffices.
      90251cf7
  8. 03 11月, 2019 8 次提交
    • R
      move time_t and suseconds_t definitions to common alltypes.h.in · d6dcfe4d
      Rich Felker 提交于
      now that all 32-bit archs have 64-bit time_t (and suseconds_t), the
      arch-provided _Int64 macro (long or long long, as appropriate) can be
      used to define them, and arch-specific definitions are no longer
      needed.
      d6dcfe4d
    • R
      move time64 ioctl numbers to generic bits/ioctl.h · b60fdf13
      Rich Felker 提交于
      now that all 32-bit archs have 64-bit time types, the values for the
      time-related ioctls can be shared. the mechanism for this is an
      arch/generic version of the bits header. archs which don't use the
      generic header still need to duplicate the definitions.
      
      x32, which does not use the new time64 values of the macros, already
      has its own overrides, so this commit does not affect it.
      b60fdf13
    • R
      move time64 socket options from arch bits to top-level sys/socket.h · c71dbb24
      Rich Felker 提交于
      now that all 32-bit archs have 64-bit time types, the values for the
      time-related socket option macros can be treated as universal for
      32-bit archs. the sys/socket.h mechanism for this predates
      arch/generic and is instead in the top-level header.
      
      x32, which does not use the new time64 values of the macros, already
      has its own overrides, so this commit does not affect it.
      c71dbb24
    • R
      switch all existing 32-bit archs to 64-bit time_t · 38143339
      Rich Felker 提交于
      this commit preserves ABI fully for existing interface boundaries
      between libc and libc consumers (applications or libraries), by
      retaining existing symbol names for the legacy 32-bit interfaces and
      redirecting sources compiled against the new headers to alternate
      symbol names. this does not necessarily, however, preserve the
      pairwise ABI of libc consumers with one another; where they use
      time_t-derived types in their interfaces with one another, it may be
      necessary to synchronize updates with each other.
      
      the intent is that ABI resulting from this commit already be stable
      and permanent, but it will not be officially so until a release is
      made. changes to some header-defined types that do not play any role
      in the ABI between libc and its consumers may still be subject to
      change.
      
      mechanically, the changes made by this commit for each 32-bit arch are
      as follows:
      
      - _REDIR_TIME64 is defined to activate the symbol redirections in
        public headers
      
      - COMPAT_SRC_DIRS is defined in arch.mak to activate build of ABI
        compat shims to serve as definitions for the original symbol names
      
      - time_t and suseconds_t definitions are changed to long long (64-bit)
      
      - IPC_STAT definition is changed to add the IPC_TIME64 bit (0x100),
        triggering conversion of semid_ds, shmid_ds, and msqid_ds split
        low/high time bits into new time_t members
      
      - structs semid_ds, shmid_ds, msqid_ds, and stat are modified to add
        new 64-bit time_t/timespec members at the end, maintaining existing
        layout of other members.
      
      - socket options (SO_*) and ioctl (sockios) command macros are
        redefined to use the kernel's "_NEW" values.
      
      in addition, on archs where vdso clock_gettime is used, the
      VDSO_CGT_SYM macro definition in syscall_arch.h is changed to use a
      new time64 vdso function if available, and a new VDSO_CGT32_SYM macro
      is added for use as fallback on kernels lacking time64.
      38143339
    • R
      add x32 bits/ioctl_fix.h defining time-related sockios macros · 5127927f
      Rich Felker 提交于
      these definitions are copied from generic bits/ioctl.h, so that x32
      keeps the "_OLD" versions (which are already time64 on x32) when
      32-bit archs switch to 64-bit time_t.
      5127927f
    • R
      add back x32 bits/socket.h defining time-related socket options · aad3e0c5
      Rich Felker 提交于
      these definitions are merely copied from the top-level sys/socket.h,
      so there is no functional change at this time. however, the top-level
      definitions will change to use the time64 "_NEW" versions on 32-bit
      archs when time_t is switched over to 64-bit. this commit ensures that
      change will be suppressed on x32.
      aad3e0c5
    • R
      move msghdr and cmsghdr out of bits/socket.h · a0252bc7
      Rich Felker 提交于
      these structures can now be defined generically in terms of endianness
      and long size. previously, the 32-bit archs all shared a common
      definition from the generic bits header, and each 64-bit arch had to
      repeat the 64-bit version, with endian conditionals if the arch had
      variants of each endianness.
      
      I would prefer getting rid of the preprocessor conditionals for
      padding and instead using unnamed bitfield members, like commit
      9b2921be did for struct timespec.
      however, at present sendmsg, recvmsg, and recvmmsg need access to the
      padding members by name to zero them. this could perhaps be cleaned up
      in the future.
      a0252bc7
    • R
      fix x32 msghdr struct by removing x32 bits/socket.h · 573a4d2d
      Rich Felker 提交于
      being that it contains pointers and (from the kernel perspective,
      which is wrong) size_t members, x32 uses the 32-bit version of the
      structure, not a half-32-bit, half-64-bit layout like we had here. the
      x86_64 definition was inadvertently copied when x32 was first added.
      
      unlike errors in the opposite direction (missing padding), this error
      was not easily detected breakage, because the layout of the commonly
      used initial subset of members still matched. breakage could only be
      observed in the presence of control messages or flags.
      573a4d2d
  9. 29 10月, 2019 1 次提交
  10. 20 10月, 2019 3 次提交
    • R
      internally, define time64 rusage syscalls on x32 as the existing ones · 7e817114
      Rich Felker 提交于
      this is analogous to commit 40aa18d5.
      so far, there are not any actual time64 versions of the rusage
      syscalls (getrusage and wait4) and might never be. however, the
      existing x32 ones behave the way time64 versions would if they
      existed: using 64-bit slots in place of all longs.
      
      presently, wait4 and getrusage are broken on x32, storing the timevals
      correctly but messing up everything else due to the long/kernel-long
      mismatch. this would be a huge buffer overflow if not for the 16
      reserved slots we left long ago, which suffice to prevent 14
      double-sized longs from overflowing into unrelated memory. this commit
      will make it possible to fix them.
      7e817114
    • R
      use struct pt_regs * rather than void * for powerpc[64] sigcontext regs · c2518a8e
      Rich Felker 提交于
      this is to match the kernel and glibc interfaces. here, struct pt_regs
      is an incomplete type, but that's harmless, and if it's completed by
      inclusion of another header then members of the struct pointed to by
      the regs member can be accessed directly without going through a cast
      or intermediate pointer object.
      c2518a8e
    • R
      fix fpregset_t type on powerpc64 · c9f48cde
      Rich Felker 提交于
      the userspace ucontext API has this as an array rather than a
      structure.
      
      commit 3c59a868 fixed the
      corresponding mistake for vrregset_t, namely that the original
      powerpc64 port used a mix of types from 32-bit powerpc and powerpc64
      rather than matching the 64-bit types.
      c9f48cde
  11. 18 10月, 2019 7 次提交
    • R
      move pthread types out of per-arch alltypes.h · 2d3083e7
      Rich Felker 提交于
      policy has long been that these definitions are purely a function of
      whether long/pointer is 32- or 64-bit, and that they are not allowed
      to vary per-arch. move the definition to the shared alltypes.h.in
      fragment, using integer constant expressions in terms of sizeof to
      vary the array dimensions appropriately. I'm not sure whether this is
      more or less ugly than using preprocessor conditionals and two sets of
      definitions here, but either way is a lot less ugly than repeating the
      same thing for every arch.
      2d3083e7
    • R
      define LONG_MAX via arch alltypes.h, strip down bits/limits.h · 7cc79d10
      Rich Felker 提交于
      LLONG_MAX is uniform for all archs we support and plenty of header and
      code level logic assumes it is, so it does not make sense for limits.h
      bits mechanism to pretend it's variable.
      
      LONG_BIT can be defined in terms of LONG_MAX; there's no reason to put
      it in bits.
      
      by moving LONG_MAX definition to __LONG_MAX in alltypes.h and moving
      LLONG_MAX out of bits, there are now no plain-C limits that are
      defined in the bits header, so the bits header only needs to be
      included in the POSIX or extended profiles. this allows the feature
      test macro logic to be removed from the bits header, facilitating a
      long-term goal of getting such logic out of bits.
      
      having __LONG_MAX in alltypes.h will allow further generalization of
      headers.
      
      archs without a constant PAGESIZE no longer need bits/limits.h at all.
      7cc79d10
    • R
      remove use of endian.h from arch reloc.h headers, clean up · 4d3a162d
      Rich Felker 提交于
      building on commit 97d35a55,
      __BYTE_ORDER is now available wherever alltypes.h is included. since
      reloc.h is only used from src/internal/dynlink.h, it can be assumed
      that __BYTE_ORDER is exposed. reloc.h is not permitted to be included
      in other contexts, and generally, like most arch headers, lacks
      inclusion guards that would allow such usage. the mips64 version
      mistakenly included such guards; they are removed for consistency.
      4d3a162d
    • R
      remove indirect use of endian.h from public headers · 71d23fbe
      Rich Felker 提交于
      building on commit 97d35a55,
      __BYTE_ORDER is now available wherever alltypes.h is included.
      endian.h should not be used since, in the future, it will expose
      identifiers that are not in the reserved namespace for the headers
      which were previously using it.
      71d23fbe
    • R
      move __BYTE_ORDER definition to alltypes.h · 97d35a55
      Rich Felker 提交于
      this change is motivated by the intersection of several factors.
      presently, despite being a nonstandard header, endian.h is exposing
      the unprefixed byte order macros and functions only if _BSD_SOURCE or
      _GNU_SOURCE is defined. this is to accommodate use of endian.h from
      other headers, including bits headers, which need to define structure
      layout in terms of endianness. with time64 switch-over, even more
      headers will need to do this.
      
      at the same time, the resolution of Austin Group issue 162 makes
      endian.h a standard header for POSIX-future, requiring that it expose
      the unprefixed macros and the functions even in standards-conforming
      profiles. changes to meet this new requirement would break existing
      internal usage of endian.h by causing it to violate namespace where
      it's used.
      
      instead, have the arch's alltypes.h define __BYTE_ORDER, either as a
      fixed constant or depending on the right arch-specific predefined
      macros for determining endianness. explicit literals 1234 and 4321 are
      used instead of __LITTLE_ENDIAN and __BIG_ENDIAN so that there's no
      danger of getting the wrong result if a macro is undefined and
      implicitly evaluates to 0 at the preprocessor level.
      
      the powerpc (32-bit) bits/endian.h being removed had logic for varying
      endianness, but our powerpc arch has never supported that and has
      always been big-endian-only. this logic is not carried over to the new
      __BYTE_ORDER definition in alltypes.h.
      97d35a55
    • R
      remove per-arch definitions for va_list · 00ec11d1
      Rich Felker 提交于
      now that commit f7f10797 removed the
      legacy i386 conditional definition, va_list is in no way
      arch-specific, and has no reason to be in the future. move it to the
      shared part of alltypes.h.in
      00ec11d1
    • R
      remove i386 support for legacy struct __va_list · f7f10797
      Rich Felker 提交于
      commit ffaaa6d2 removed the
      corresponding stdarg.h support for compilers without va_list builtins,
      but failed to remove the alternate type definition, leaving incorrect
      va_list definitions in place with compilers that don't define __GNUC__
      with a value >= 3.
      f7f10797
  12. 02 10月, 2019 1 次提交
    • R
      reintroduce riscv64 struct sigcontext · a0993f8f
      Rich Felker 提交于
      commit ab3eb89a removed it as part of
      correcting the mcontext_t definition, but there is still code using
      struct sigcontext and expecting the member names present in it, most
      notably libgcc_eh. almost all such usage is incorrect, but bring back
      struct sigcontext at least for now so as not to introduce regressions.
      a0993f8f
  13. 30 9月, 2019 2 次提交
    • R
      fix riscv64 elf_fpregset_t type and member names mismatch · 2c2477da
      Rich Felker 提交于
      in order for sys/procfs.h (provided by sys/user.h) to be useful, it
      needs to match the API its consumers (gdb, etc.) expect, including the
      member names established by glibc.
      
      this partly reverts commit 29e8737f,
      which partly reverted d493206d,
      eliminating struct user_fpregs_struct which seems to have had no
      precedent and using union __riscv_mc_fp_state for elf_fpregset_t. this
      requires indirect inclusion of signal.h to make union
      __riscv_mc_fp_state visible, but being that these are nonstandard
      "junk" headers with no official restrictions on what they can pull in,
      that's no big deal.
      
      split off and expanded from patch by Khem Raj.
      2c2477da
    • R
      fix riscv64 signal.h namespace violations and ucontext API mismatches · ab3eb89a
      Rich Felker 提交于
      the top-level mcontext_t member names were namespace-violating in
      standards profiles before, and nested-level member names (some of them
      single-letter) were egregiously bad namespace impositions even in
      non-strict profiles. moreover, they mismatched those used in the
      public API first defined in glibc, breaking any code making use of
      them.
      
      unlike most archs, the public API used in glibc for riscv mcontext_t
      members was designed to be namespace-safe, so we can and should expose
      the members regardless of feature test macros. only the typedefs for
      greg_t, gregset_t, and fpregset_t need to be protected behind FTMs.
      
      the struct tags for mcontext_t and ucontext_t are also changed. for
      mcontext_t this is necessary to make the common definition across
      profiles namespace-safe. for ucontext_t, it's just a matter of
      matching the tag from the glibc-defined API.
      
      these changes are split off and expanded from a patch by Khem Raj.
      ab3eb89a
  14. 27 9月, 2019 2 次提交
    • R
      clean up mips (32-bit, o32) syscall asm constraints · 604f8d3d
      Rich Felker 提交于
      analogous to commit ddc7c4f9 for
      mips64 and n32, remove the hack to load the syscall number into $2 via
      asm, and use a constraint to let the compiler load it instead.
      
      now, only $4, $5, and $6 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.
      
      as before, $8, $9, and $10 are conditionally input-output registers
      for 5-, 6-, and 7-argument syscalls. their role in input is carrying
      in the values that will be stored on the stack for arguments 5-7.
      their role in output is carrying back whatever the kernel has
      clobbered them with, so that the compiler cannot assume they still
      contain the input values.
      604f8d3d
    • R
      fix mips r6 syscall clobber lists not to include hi/lo registers · 9f6dd785
      Rich Felker 提交于
      mips r6 (an incompatible isa from traditional mips) removes the hi and
      lo registers used for mul/div results. older gcc versions accepted
      them in the clobber list for asm, but their presence is incorrect and
      breaks on later versions.
      
      in the process of fixing this, the clobber list for 32-bit mips
      syscalls has been deduplicated via a macro like on mips64 and n32.
      9f6dd785
  15. 26 9月, 2019 1 次提交
    • P
      correct the operand specifiers in the riscv64 CAS routines · 7d5c5706
      Palmer Dabbelt 提交于
      The operand sepcifiers in a_cas and a_cas_p for riscv64 were incorrect:
      there's a backwards branch in the routine, so despite tmp being written
      at the end of the assembly fragment it cannot be allocated in one of the
      input registers because the input values may be needed for another trip
      around the loop.
      
      For code that follows the guaranteed forward progress requirements, the
      backwards branch is rarely taken: SiFive's hardware only fails a store
      conditional on execptional cases (ie, instruction cache misses inside
      the loop), and until recently a bug in QEMU allowed back-to-back
      store conditionals to succeed.  The bug has been fixed in the latest
      QEMU release, but it turns out that the fix caused this latent bug in
      musl to manifest.
      7d5c5706
  16. 11 9月, 2019 2 次提交
    • S
      aarch64: add HWCAP2 flags from linux v5.2 · 9920bf45
      Szabolcs Nagy 提交于
      AT_HWCAP2 flags, see
      
        linux commit 671db581815faf17cbedd7fcbc48823a247d90b1
        arm64: Expose DC CVADP to userspace
      
        linux commit 06a916feca2b262ab0c1a2aeb68882f4b1108a07
        arm64: Expose SVE2 features for userspace
      9920bf45
    • S
      add new syscall numbers from linux v5.2 · b6076309
      Szabolcs Nagy 提交于
      new mount api syscalls were added, same numers on all targets, see
      
        linux commit a07b20004793d8926f78d63eb5980559f7813404
        vfs: syscall: Add open_tree(2) to reference or clone a mount
      
        linux commit 2db154b3ea8e14b04fee23e3fdfd5e9d17fbc6ae
        vfs: syscall: Add move_mount(2) to move mounts around
      
        linux commit 24dcb3d90a1f67fe08c68a004af37df059d74005
        vfs: syscall: Add fsopen() to prepare for superblock creation
      
        linux commit ecdab150fddb42fe6a739335257949220033b782
        vfs: syscall: Add fsconfig() for configuring and managing a context
      
        linux commit 93766fbd2696c2c4453dd8e1070977e9cd4e6b6d
        vfs: syscall: Add fsmount() to create a mount for a superblock
      
        linux commit cf3cba4a429be43e5527a3f78859b1bfd9ebc5fb
        vfs: syscall: Add fspick() to select a superblock for reconfiguration
      
        linux commit 9c8ad7a2ff0bfe58f019ec0abc1fb965114dde7d
        uapi, x86: Fix the syscall numbering of the mount API syscalls [ver #2]
      
        linux commit d8076bdb56af5e5918376cd1573a6b0007fc1a89
        uapi: Wire up the mount API syscalls on non-x86 arches [ver #2]
      b6076309
  17. 09 9月, 2019 1 次提交
    • R
      honor __WCHAR_TYPE__ on archs with legacy long definition of wchar_t · 1f0e9f9c
      Rich Felker 提交于
      historically, a number of 32-bit archs used long rather than int for
      wchar_t, for no good reason. GCC still uses the historical types, but
      clang replaced them all with int, and it seems PCC uses int too.
      mismatching the compiler's type for wchar_t is not an option due to
      wide string literals.
      
      note that the mismatch does not affect C++ ABI since wchar_t is its
      own builtin type/keyword in C++, distinct from both int and long, not
      a typedef.
      
      i386 already worked around this by honoring __WCHAR_TYPE__ if defined
      by the compiler, and only using the official legacy ABI type if not.
      add the same to the other affected archs.
      
      it might make sense at some point to switch to using int as the
      default if __WCHAR_TYPE__ is not defined, if the expectations is that
      new compilers will treat int as the correct choice, but it's unlikely
      that the case where __WCHAR_TYPE__ is undefined will ever be used
      anyway. I actually wanted to move the definition of wchar_t to the
      top-level shared alltypes.h.in, using __WCHAR_TYPE__ and falling back
      to int if not defined, but that can't be done without assuming all
      compilers define __WCHAR_TYPE__ thanks to some pathological archs
      where the ABI has wchar_t as an unsigned type.
      1f0e9f9c