History log of /seL4-test-master/projects/musllibc/src/stdio/open_wmemstream.c
Revision Date Author Comments
# 7b9f57f2 08-Oct-2015 Rich Felker <dalias@aerifal.cx>

fix open_[w]memstream behavior when no writes take place

the specification for these functions requires that the buffer/size
exposed to the caller be valid after any successful call to fflush or
fclose on the stream. the implementation's approach is to update them
only at flush time, but that misses the case where fflush or fclose is
called without any writes having taken place, in which case the write
flushing callback will not be called.

to fix both the observable bug and the desired invariant, setup empty
buffers at open time and fail the open operation if no memory is
available.


# 1b0cdc87 16-Jun-2015 Rich Felker <dalias@aerifal.cx>

refactor stdio open file list handling, move it out of global libc struct

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.


# dc059f03 09-Nov-2012 Rich Felker <dalias@aerifal.cx>

always add memory streams to stdio open file list

per interpretation for austin group issue #626, fflush(0) and exit()
must block waiting for a lock if another thread has locked a memory
stream with flockfile. this adds some otherwise-unnecessary
synchronization cost to use of memory streams, but there was already a
synchronization cost calling malloc anyway.

previously the stream was only added to the open file list in
single-threaded programs, so that upon subsequent call to
pthread_create, locking could be turned on for the stream.


# 835f9f95 08-Nov-2012 Rich Felker <dalias@aerifal.cx>

clean up stdio_impl.h

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.


# 7ee3dcb3 04-Sep-2011 Rich Felker <dalias@aerifal.cx>

memstreams: fix incorrect handling of file pos > current size

the addition is safe and cannot overflow because both operands are
positive when considered as signed quantities.


# c88f36f5 03-Sep-2011 Rich Felker <dalias@aerifal.cx>

optimize seek function for memory streams


# 32d67e93 03-Sep-2011 Rich Felker <dalias@aerifal.cx>

fix twos complement overflow bug in mem streams boundary check

the expression -off is not safe in case off is the most-negative
value. instead apply - to base which is known to be non-negative and
bounded within sanity.


# 1e693764 03-Sep-2011 Rich Felker <dalias@aerifal.cx>

fix some length calculations in memory streams


# 1461e027 03-Sep-2011 Rich Felker <dalias@aerifal.cx>

implement open_wmemstream

not heavily tested, but it seems to be correct, including the odd
behavior that seeking is in terms of wide character count. this
precludes any simple buffering, so we just make the stream unbuffered.