1. 13 9月, 2018 1 次提交
    • 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
  2. 02 7月, 2016 1 次提交
    • R
      fix posix_fadvise syscall args on powerpc, unify with arm fix · 3dd27f3a
      Rich Felker 提交于
      commit 6d38c9cf provided an
      arm-specific version of posix_fadvise to address the alternate
      argument order the kernel expects on arm, but neglected to address
      that powerpc (32-bit) has the same issue. instead of having arch
      variant files in duplicate, simply put the alternate version in the
      top-level file under the control of a macro defined in syscall_arch.h.
      3dd27f3a
  3. 30 6月, 2016 2 次提交
  4. 22 4月, 2015 1 次提交
    • R
      remove dead case for F_SETLKW in fcntl · ea1b6bb6
      Rich Felker 提交于
      the first switch already returns in the F_SETLKW code path so it need
      not be handled in the second switch. moreover the code in the second
      switch is wrong for the F_SETLKW command: it's not cancellable.
      ea1b6bb6
  5. 01 11月, 2014 1 次提交
  6. 31 10月, 2014 2 次提交
  7. 07 6月, 2014 2 次提交
    • R
      avoid invalid use of va_arg in open · 9c2d437c
      Rich Felker 提交于
      reading the variadic mode argument is only valid when the O_CREAT flag
      is present. this probably does not matter, but is needed for formal
      correctness, and could affect LTO or other full-program analysis.
      9c2d437c
    • R
      add O_CLOEXEC fallback for open and related functions · 7765706c
      Rich Felker 提交于
      since there is no easy way to detect whether open honored or ignored
      the O_CLOEXEC flag, the optimal solution to providing a fallback is
      simply to make the fcntl syscall to set the close-on-exec flag
      immediately after open returns.
      7765706c
  8. 25 5月, 2014 1 次提交
    • R
      support kernels with no SYS_open syscall, only SYS_openat · 594c827a
      Rich Felker 提交于
      open is handled specially because it is used from so many places, in
      so many variants (2 or 3 arguments, setting errno or not, and
      cancellable or not). trying to do it as a function would not only
      increase bloat, but would also risk subtle breakage.
      
      this is the first step towards supporting "new" archs where linux
      lacks "old" syscalls.
      594c827a
  9. 08 3月, 2014 1 次提交
    • R
      in fcntl, use unsigned long instead of long for variadic argument type · b576766d
      Rich Felker 提交于
      neither is correct; different commands take different argument types,
      and some take no arguments at all. I have a much larger overhaul of
      fcntl prepared to address this, but it's not appropriate to commit
      during freeze.
      
      the immediate problem being addressed affects forward-compatibility on
      x32: if new commands are added and they take pointers, but the
      libc-level fcntl function is not aware of them, using long would
      sign-extend the pointer to 64 bits and give the kernel an invalid
      pointer. on the kernel side, the argument to fcntl is always treated
      as unsigned long, so no harm is done by treating possibly-signed
      integer arguments as unsigned. for every command that takes an integer
      argument except for F_SETOWN, large integer arguments and negative
      arguments are handled identically anyway. in the case of F_SETOWN, the
      kernel is responsible for converting the argument which it received as
      unsigned long to int, so the sign of negative arguments is recovered.
      
      the other problem that will be addressed later is that the type passed
      to va_arg does not match the type in the caller of fcntl. an advanced
      compiler doing cross-translation-unit analysis could potentially see
      this mismatch and issue warnings or otherwise make trouble.
      
      on i386, this patch was confirmed not to alter the code generated by
      gcc 4.7.3. in principle the generated code should not be affected on
      any arch except x32.
      b576766d
  10. 08 1月, 2014 1 次提交
    • R
      in fcntl, avoid passing pointer arguments to syscalls as longs · 131871a3
      Rich Felker 提交于
      really, fcntl should be changed to use the correct type corresponding
      to cmd when calling va_arg, and to carry the correct type through
      until making the syscall. however, this greatly increases binary size
      and does not seem to offer any benefits except formal correctness, so
      I'm holding off on that change for now.
      
      the minimal changes made in this patch are in preparation for addition
      of the x32 port, where the syscall macros need to know whether their
      arguments are pointers or integers in order to properly pass them to
      the 64-bit kernel.
      131871a3
  11. 07 1月, 2014 1 次提交
  12. 12 12月, 2013 1 次提交
  13. 27 3月, 2013 1 次提交
    • R
      provide emulation of fcntl F_DUPFD_CLOEXEC on old kernels · 00f1521f
      Rich Felker 提交于
      I'm not entirely happy with the amount of ugliness here, but since
      F_DUPFD_CLOEXEC is used elsewhere in code that's expected to work on
      old kernels (popen), it seems necessary. reportedly even some modern
      kernels went back and broke F_DUPFD_CLOEXEC (making it behave like
      plain F_DUPFD), so it might be necessary to add some additional fixup
      code later to deal with that issue too.
      00f1521f
  14. 08 9月, 2012 3 次提交
  15. 21 6月, 2012 1 次提交
  16. 01 6月, 2012 1 次提交
    • R
      enable LARGEFILE64 aliases · a5412976
      Rich Felker 提交于
      these will NOT be used when compiling with -D_LARGEFILE64_SOURCE on
      musl; instead, they exist in the hopes of eventually being able to run
      some glibc-linked apps with musl sitting in place of glibc.
      
      also remove the (apparently incorrect) fcntl alias.
      a5412976
  17. 10 10月, 2011 1 次提交
    • R
      fix F_GETOWN return value handling · 8e8ddeff
      Rich Felker 提交于
      the fcntl syscall can return a negative value when the command is
      F_GETOWN, and this is not an error code but an actual value. thus we
      must special-case it and avoid calling __syscall_ret to set errno.
      this fix is better than the glibc fix (using F_GETOWN_EX) which only
      works on newer kernels and is more complex.
      8e8ddeff
  18. 22 9月, 2011 1 次提交
  19. 21 4月, 2011 1 次提交
  20. 17 4月, 2011 1 次提交
    • R
      overhaul pthread cancellation · feee9890
      Rich Felker 提交于
      this patch improves the correctness, simplicity, and size of
      cancellation-related code. modulo any small errors, it should now be
      completely conformant, safe, and resource-leak free.
      
      the notion of entering and exiting cancellation-point context has been
      completely eliminated and replaced with alternative syscall assembly
      code for cancellable syscalls. the assembly is responsible for setting
      up execution context information (stack pointer and address of the
      syscall instruction) which the cancellation signal handler can use to
      determine whether the interrupted code was in a cancellable state.
      
      these changes eliminate race conditions in the previous generation of
      cancellation handling code (whereby a cancellation request received
      just prior to the syscall would not be processed, leaving the syscall
      to block, potentially indefinitely), and remedy an issue where
      non-cancellable syscalls made from signal handlers became cancellable
      if the signal handler interrupted a cancellation point.
      
      x86_64 asm is untested and may need a second try to get it right.
      feee9890
  21. 20 3月, 2011 1 次提交
  22. 12 2月, 2011 1 次提交