Read to stdout doesn't trigger correct action

IGotD- nise at nise.com
Mon Jun 22 18:44:51 UTC 2020


On Monday, 22 June 2020 at 14:27:18 UTC, Steven Schveighoffer 
wrote:
>
> I'm sure if there is a clib that doesn't work with this, it is 
> a bug with druntime, and should be addressed. I don't know 
> enough about the exact functionality to be able to write such a 
> bug report, but you probably should if it's not working for you.
>
> -Steve

I don't really have a good solution for this and it seems to work 
for existing supported C libraries. One solution would be to move 
the makeGlobal implementation to become OS/C-library specific and 
each platform would have a suitable implementation but that kind 
of contradicts having as little platform specific code possible.

Another thing that is a bit sketchy here is the usage of raw 
atomics as spinlocks as it would have side effects in case of 
locking (CPU could spin for several milliseconds if the locker 
CPU is preempted and does something else). I guess in this 
particular case it is used because it would be race creating a 
mutex as well because we want lazy initialization. While I kind 
of like lazy initialization myself it kind creates situations 
like these. I don't quite follow the exact reason behind avoiding 
static ctors, lazy initialization is nice for many things but 
ctors have their place as well. Using C stdio without druntime 
would read the OS specific FILE* directly, or what am I missing 
here?


More information about the Digitalmars-d-learn mailing list