ISO C11 requires operations on the same stream (or whatever a FILE struct 
handles) _not_ to interleave with each other.
This should include outputting each character using puts() or printf() 
functions, since they both manipulate the `stdout` stream.

It should be noted that mingw-w64 has never claimed C11 compatibility. On the 
other hand, GCC has enabled -std=gnu11 since GCC 5.
Such interleaving behavior would conflict with GCC's new default expectation.

---
WG14 N1570 (a.k.a. draft for ISO C11)

7.21.2 Streams
7 Each stream has an associated lock that is used to prevent data races when 
multiple
threads of execution access a stream, and to restrict the interleaving of 
stream operations
performed by multiple threads. Only one thread may hold this lock at a time. 
The lock is
reentrant: a single thread may hold the lock multiple times at a given time.
8 All functions that read, write, position, or query the position of a stream 
lock the stream
before accessing it. They release the lock associated with the stream when the 
access is
complete.

------------------                               
Best regards,
lh_mouse
2015-08-03

-------------------------------------------------------------
发件人:Dongsheng Song <dongsheng.s...@gmail.com>
发送日期:2015-08-03 10:58
收件人:mingw64
抄送:
主题:Re: [Mingw-w64-public] Patch for locking printf

On Sat, Aug 1, 2015 at 6:56 AM, JonY <jo...@users.sourceforge.net> wrote:
>
> On 7/23/2015 06:24, JonY wrote:
> > Hi,
> >
> > Patch introduces a new macro __MINGW_PRINTF_LOCKING for fprintf and
> > vfprintf so when called on the same FILE stream, the operations are not
> > overlapped. __USE_MINGW_ANSI_STDIO must also be set for the new macro to
> > take effect.
> >
> > The reason why it is done in such a way is so programs that already
> > doing their own locking will not be affected.
> >
> > Idea from user Mateusz of Sourceforge. Patch OK?
> >
>
> Ping?


I like the idea. But  AFAIK, this code is not portable since it's
neither a standard extension nor the standards of practice.

------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public



------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to