1. 16 5月, 2023 1 次提交
    • R
      Optimize fread in stdio API · 0b1a046b
      robottoy 提交于
      Original stdio read use readv as default syscall,calling vfs_read twice will
      reduce I/O throughout, use syscall read instead with buffer if possible
      
      Issue:I70LQ0
      Test: libc-test, benchmark
      Signed-off-by: Nrobottoy <wangyaofeng.wang@huawei.com>
      Change-Id: I2e5c0298fcd665edb3228ca400ee77fbf25a298c
      0b1a046b
  2. 02 11月, 2022 3 次提交
  3. 11 3月, 2021 1 次提交
  4. 09 9月, 2020 1 次提交
  5. 31 8月, 2020 1 次提交
  6. 25 8月, 2020 1 次提交
    • R
      add tcgetwinsize and tcsetwinsize functions, move struct winsize · 4d578654
      Rich Felker 提交于
      these have been adopted for future issue of POSIX as the outcome of
      Austin Group issue 1151, and are simply functions performing the roles
      of the historical ioctls. since struct winsize is being standardized
      along with them, its definition is moved to the appropriate header.
      
      there is some chance this will break source files that expect struct
      winsize to be defined by sys/ioctl.h without including termios.h. if
      this happens, further changes will be needed to have sys/ioctl.h
      expose it too.
      4d578654
  7. 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
  8. 16 6月, 2015 1 次提交
    • R
      refactor stdio open file list handling, move it out of global libc struct · 1b0cdc87
      Rich Felker 提交于
      functions which open in-memory FILE stream variants all shared a tail
      with __fdopen, adding the FILE structure to stdio's open file list.
      replacing this common tail with a function call reduces code size and
      duplication of logic. the list is also partially encapsulated now.
      
      function signatures were chosen to facilitate tail call optimization
      and reduce the need for additional accessor functions.
      
      with these changes, static linked programs that do not use stdio no
      longer have an open file list at all.
      1b0cdc87
  9. 24 2月, 2015 1 次提交
    • R
      fix possible isatty false positives and unwanted device state changes · 2de85a98
      Rich Felker 提交于
      the equivalent checks for newly opened stdio output streams, used to
      determine buffering mode, are also fixed.
      
      on most archs, the TCGETS ioctl command shares a value with
      SNDCTL_TMR_TIMEBASE, part of the OSS sound API which was apparently
      used with certain MIDI and timer devices. for file descriptors
      referring to such a device, TCGETS will not fail with ENOTTY as
      expected; it may produce a different error, or may succeed, and if it
      succeeds it changes the mode of the device. while it's unlikely that
      such devices are in use, this is in principle very harmful behavior
      for an operation which is supposed to do nothing but query whether the
      fd refers to a tty.
      
      TIOCGWINSZ, used to query logical window size for a terminal, was
      chosen as an alternate ioctl to perform the isatty check. it does not
      share a value with any other ioctl commands, and it succeeds on any
      tty device.
      
      this change also cleans up strace output to be less ugly and
      misleading.
      2de85a98
  10. 07 2月, 2014 2 次提交
    • R
      in fdopen, avoid setting O_APPEND flag if it's already set · 758ab35a
      Rich Felker 提交于
      this saves a syscall in the case where the underlying open already
      took place with O_APPEND, which is common because fopen with append
      modes sets O_APPEND at the time of open before passing the file
      descriptor to __fdopen.
      758ab35a
    • R
      fix ftello result for append streams with unflushed output · 3af2edee
      Rich Felker 提交于
      when there is unflushed output, ftello (and ftell) compute the logical
      stream position as the underlying file descriptor's offset plus an
      adjustment for the amount of buffered data. however, this can give the
      wrong result for append-mode streams where the unflushed writes should
      adjust the logical position to be at the end of the file, as if a seek
      to end-of-file takes place before the write.
      
      the solution turns out to be a simple trick: when ftello (indirectly)
      calls lseek to determine the current file offset, use SEEK_END instead
      of SEEK_CUR if the stream is append-mode and there's unwritten
      buffered data.
      
      the ISO C rules regarding switching between reading and writing for a
      stream opened in an update mode, along with the POSIX rules regarding
      switching "active handles", conveniently leave undefined the
      hypothetical usage cases where this fix might lead to observably
      incorrect offsets.
      
      the bug being fixed was discovered via the test case for glibc issue
      3af2edee
  11. 09 11月, 2012 1 次提交
    • R
      clean up stdio_impl.h · 835f9f95
      Rich Felker 提交于
      this header evolved to facilitate the extremely lazy practice of
      omitting explicit includes of the necessary headers in individual
      stdio source files; not only was this sloppy, but it also increased
      build time.
      
      now, stdio_impl.h is only including the headers it needs for its own
      use; any further headers needed by source files are included directly
      where needed.
      835f9f95
  12. 30 9月, 2012 1 次提交
  13. 18 6月, 2012 1 次提交
  14. 30 7月, 2011 1 次提交
    • R
      add proper fuxed-based locking for stdio · dba68bf9
      Rich Felker 提交于
      previously, stdio used spinlocks, which would be unacceptable if we
      ever add support for thread priorities, and which yielded
      pathologically bad performance if an application attempted to use
      flockfile on a key file as a major/primary locking mechanism.
      
      i had held off on making this change for fear that it would hurt
      performance in the non-threaded case, but actually support for
      recursive locking had already inflicted that cost. by having the
      internal locking functions store a flag indicating whether they need
      to perform unlocking, rather than using the actual recursive lock
      counter, i was able to combine the conditionals at unlock time,
      eliminating any additional cost, and also avoid a nasty corner case
      where a huge number of calls to ftrylockfile could cause deadlock
      later at the point of internal locking.
      
      this commit also fixes some issues with usage of pthread_self
      conflicting with __attribute__((const)) which resulted in crashes with
      some compiler versions/optimizations, mainly in flockfile prior to
      pthread_create.
      dba68bf9
  15. 18 4月, 2011 1 次提交
  16. 16 4月, 2011 1 次提交
    • R
      avoid setting errno when checking for tty · 69cf09c8
      Rich Felker 提交于
      setting errno here is completely valid, but some programs, notably
      busybox printf, assume that errno will not be set during output and
      treat this as an error condition. in any case, skipping it slightly
      reduces code size and saves time.
      69cf09c8
  17. 20 3月, 2011 1 次提交
  18. 12 2月, 2011 1 次提交